From patchwork Tue Sep 12 16:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13381922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0CD5CA0EF1 for ; Tue, 12 Sep 2023 16:23:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.600659.936380 (Exim 4.92) (envelope-from ) id 1qg6Ae-0003x9-4f; Tue, 12 Sep 2023 16:23:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 600659.936380; Tue, 12 Sep 2023 16:23:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qg6Ae-0003x2-20; Tue, 12 Sep 2023 16:23:24 +0000 Received: by outflank-mailman (input) for mailman id 600659; Tue, 12 Sep 2023 16:23:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qg6Ac-0003ww-8y for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 16:23:22 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ae3f6b3e-5188-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 18:23:19 +0200 (CEST) Received: from mail-dm6nam10lp2100.outbound.protection.outlook.com (HELO NAM10-DM6-obe.outbound.protection.outlook.com) ([104.47.58.100]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 12 Sep 2023 12:23:14 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by CH2PR03MB5334.namprd03.prod.outlook.com (2603:10b6:610:92::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19; Tue, 12 Sep 2023 16:23:13 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::efdb:990a:5b04:8783]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::efdb:990a:5b04:8783%6]) with mapi id 15.20.6768.029; Tue, 12 Sep 2023 16:23:12 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ae3f6b3e-5188-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1694535799; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=YCa3ncEOXYI+eakEP6UK5hkV84JSrjle5EGZWEQ2xo4=; b=bvDgtQcq6QkBRmpbV0kC8g5QNE16ohxTXiTsCiA2lo+SctL1daYmJeyb kpFG+R/1gJL7hO1ST1VCMu1nv57v4FyKC3J0KofTBzRVFS1y1SwS3FfwT LutATVnmRMjEVezMQWB4/qd8aA94rRzZ2XqxcYIu4gq0Pd1wJFrMlmPgk s=; X-CSE-ConnectionGUID: VZlXSnWyTe+rP16Yh2qicg== X-CSE-MsgGUID: yp6eicw7SCen5wqHwoAJCA== X-IronPort-RemoteIP: 104.47.58.100 X-IronPort-MID: 121071964 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED X-ThreatScanner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Iju6NGozfiV6bKBJd6 a0145Jpz+tY3QFYt7TPBQ4duLevcDMkJ78QTNuPW9E1DWz X-Talos-CUID: 9a23:0yfcQW+qWNh00ajXl7yVv3AmHvAedELM8HqTOXfhV1dpEqSUQlDFrQ== X-Talos-MUID: 9a23:ZhZquQ2sODAorWDkOoBziXPpezUj8rzwBUEGjso9kMSCaDNpGyiapRaca9py X-IronPort-AV: E=Sophos;i="6.02,139,1688443200"; d="scan'208";a="121071964" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YH93UOs5REbwneQb+uclG/qoDDk7aVspwbLbrzSxsCpfrEhHmov0NenKvGr/FkuG9xmddh9I4c7hYrsaJ0pqvXVlM9YWss4jBSo+dUJrY8H5Dm+/ifUbXz6td5k3fCRiJnBYgf+Oz36y1+l0MOwJNpNEIEDJTcgLFbx9lU4TcHQIbzt3CjAPsWJmo306GvcVzDedRHVuV4Y0VSqlLrUv4Mi9YBUsgho9fLeTyL9/G7v540dpJ38vWymlA6z05kxVrLSsk3T68BlG5NGUF/utEMiKQIG+uldxJgoHH8zw+KQSH2+QklfSz9vdH0bdUOC9Dr1UkpJznJQr3AbmwZ7EDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jUpOKr6vyLC9qpX+lF7k9otlROwoxEYvztY+ih7pXy0=; b=GtsbwNV0ydzRwFon4lgdWtZr6TLHhopiHN9VId17p0euB1A8DzllNV2v8e2rIQ1W+24aVpl9vW9UmUfRXHC0Z215e+uigp4MSjD3OnU9NSL3QCcUj5RbQqcgLWEXenRzeZN+Wo4t6arcfljWB7tKbIEnKOyfw350cdXdzX23r3WOiehAHTUqgbntoblecjzEQ5LrE9tAMZN8rMVzhvYjv+m0Kiyc2b/xDMlN6hHDbIYCrszNc3Cp/HqRHHUOhWCrXTHPhGM2ykX715HosvFPAiK3kurS6hwb2HzEiosxP6f5ytfSZF6vHKLTWvqXFcPmR9nBsr/+58aLk4g1xT6iMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jUpOKr6vyLC9qpX+lF7k9otlROwoxEYvztY+ih7pXy0=; b=snOs22ZoPgEkt3QLNaVJUdNFPtP4t+DSnoZ6a8/RPNAQHlkSAcoMmBwGKp+1ZC2hip/ljA7Q+o/+G8uNBQK6ix7B7YjuIA7Nze4Ro6+eQ8WyyN7784zycyNguUtPvQPuDcSc7Auuv0FJ1QKWnqPo+C02v7MFewuevSVuZR9EhqU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH] x86/amd: do not expose HWCR.TscFreqSel to guests Date: Tue, 12 Sep 2023 18:23:05 +0200 Message-ID: <20230912162305.34339-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: LO2P265CA0030.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::18) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|CH2PR03MB5334:EE_ X-MS-Office365-Filtering-Correlation-Id: 223d4bf5-ba68-44e4-26fb-08dbb3ac8f4e X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KG8bk11i0wHBQ+ErNfgknw3Pzy+339bkiCfFbgEbkFRvtdA9dLQ0h9kV24BRgQohIvIaaza3ei/kkEdf4b/JM9RriCNMiP5b+lGu6P9//2OH7aHfYrFjPfP2qUG/pUzP/SiBr3Z6NVjgeljgjNUgsZN88z7ay+osneoSyD4LDZwoBgGgC7vI4jk724rF0c88UgY9a47XdZhYGSrpFN45oT17H5ZmpM9HejcP/cTdUnOpP7RjuWlKtJ8gZmR3UakDLbYe4QgJd7BLHsJjkK0WbXZdOrMFnPj2N41ZI0sd55QTe3HGV7GBW8HGcj1wYCbm9MieB8zYvS8XXG1PtGocdwMTUzG+S8Kk9j/MfYK20GBodR5VdT3JxmjuZ4sh816wq0abivz+SAlWg5TZfhGSZrD8BC/qyD6UTPx38izVo0izN9sDmBrFigTkdbi/Y7qHpeKW/kgolo42LUP/ydtee+iUi/m7IaQQj7Ng93UoXBVqADvQPcsPR5tGblcSdFyYOheukyRPp9DQKhjjll0RE2eiTwuPq2PiwPu3bnTGHPlZEgkVBD/Lxpt6mHwGkrgDmTxCW0fAJKDXCPytpB29tSl6ERrfjbTHyY91cE34SFY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(366004)(346002)(376002)(39860400002)(451199024)(1800799009)(186009)(8676002)(8936002)(86362001)(4326008)(5660300002)(2906002)(36756003)(6666004)(38100700002)(83380400001)(82960400001)(6506007)(6486002)(6512007)(26005)(1076003)(6916009)(478600001)(2616005)(316002)(54906003)(66556008)(66476007)(66946007)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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z7l1JmH/qKxqzvWK/HCMzbD0CFqViUGeoUNazO5Y39ogQHON5JE8AaVSKQnCi?= =?utf-8?q?HeX0kSaUbnoZsfZKhm+v5fnCuj0JcPKu+9TSHPg5CPu5xM6zHlh6+UjaC41EPHHLE?= =?utf-8?q?W8aqkXkpMWU0w6gIVdo/2jDP6G/keN4tFGWEFb4B3gJg/u8gDyUNZyiI5lhPINLnM?= =?utf-8?q?nNUQcLI/4g3kdSL4JyGs0xOrUACo0WKet+vXJrfTcLKJVG6DT7Up16TokoYs3BQDV?= =?utf-8?q?y15i32ViOXE7vVcDKDxQtnXATfYgCR37u/kde0KZiuSe4QmDszYI0moZ9N6CxYhez?= =?utf-8?q?o7UmWTF7lgNWXLJzviBKNUHu6/c65Db/+MiuCQwL5LSmsfwSkSqrPzf0XOTYJaGks?= =?utf-8?q?fqWcOl2codIFEsRH+9ijCJxn6w41MnYoUN8TMQojVGOPVRFO331WXyvGz3gNGemlY?= =?utf-8?q?cDjbrFdUOv/HMmIf2D+R9JWFMvGh5iwpHQt8cGXgupt8NfWpJ9V6sZTuhWbaHDfCk?= =?utf-8?q?5Gmi86qRQlLCCpH9bZuaqxcYT9JrVHfcw4ty+7b3xsWk1IMsWy7qy32GxpwTMcAR6?= =?utf-8?q?37l+FX6VqVySVoYurc5FmOGMAKmpBf/cysa4EYMsqJkmWDW/knWR5G0OqPJaOefas?= =?utf-8?q?jz57vc96D2X2LmtnUeglEFZMziEdUE1XPd6PwasvMjq+X1sf3yUEn/6yYiCECYPI5?= =?utf-8?q?JgG+sV3eyc0g?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7JwmohV8m0Ppx0lwW7+d4yWrqo8Qh4s/3apC1aOcaIUlVYQb3YcDRb3jUhVWj+1LdTqEIuDnlIU/mqaQ6bN0YznSLqxlyBvDjBkN+baqF9tx5UwpNqpq+4erDlQLdoI473b7xGlIjmvIujtc7tg1BkCT8piB6XD4N+xhIaa/Jqz+tOK1lmqIRErZ0CC2yM8tdV4ijZC0ji15845qEAL7/OD0m1xzYH1YRt43mjPMeeJ/wyBZa6o1/Y0iJYju6hvcohisd5sFSupvgo49nqA/sOHfm0SxPtwnJKoGm3yi/HpdS/hxsl+YnDxmZgVQuA+sMnvWFaxv3D3Af3vDGH1xs8m3DjfPzZtWdK8OtGo0vpDZGVKOL3LDkPmaL1CNcX5OTMv9g4FbN+56a6egAqXS2oTrOZP3n0RUl9qJbvog5tJ1exKJghDZrJQosdCn+rY7Vwp9QXjMkGkAJPP8Cu1nAwzEk17wR6v1Rpkr695UA11c+TEY4AED51xzcHsJz86oaqOc/r9fp+0+eb15++obLRL4fJs5CCCMcAQ7U1TvMmvVT8wpnSB3U2+6Klq1pH87JwCJWlrq4Prp5KLpE4FSQ59pDZNt4KC+26ZKDy4vW6lsURCoOgfBLg6NGZ5BlmYGxrQ3XOHOU4G7700dLxixps3VmA+6FF7bb087K+btyJIK1VT+xiE95WupZwdHSnCZbalB02cAguLRWlGoamXEQu4Icp/qZeG+FnQKMmW4NlnPzQs9P5uxEFvQLlxAaSBfzDOxr76U4Tgjmocqamne8GnL+HuVvWilAuk5N47xxVL5yIFyiVUw60rB7aeqePjd X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 223d4bf5-ba68-44e4-26fb-08dbb3ac8f4e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 16:23:12.6250 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S8hW/QfgQdeMqO73gQ9+Az3SamR3Msp4RH9IycWAzMqb2qepFkiwtB2/nkboxTdjKRSazSxCeoW7trdqR4t3WA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR03MB5334 OpenBSD will attempt to unconditionally access PSTATE0 if HWCR.TscFreqSel is set, and will also attempt to unconditionally access HWCR if the TSC is reported as Invariant. The reasoning for exposing HWCR.TscFreqSel was to avoid Linux from printing a (bogus) warning message, but doing so at the cost of OpenBSD not booting is not a suitable solution. In order to fix expose an empty HWCR. Fixes: 14b95b3b8546 ('x86/AMD: expose HWCR.TscFreqSel to guests') Signed-off-by: Roger Pau Monné --- Not sure whether we want to expose something when is_cpufreq_controller() is true, seeing as there's a special wrmsr handler for the same MSR in that case. Likely should be done for PV only, but also likely quite bogus. Missing reported by as the issue came from the QubesOS tracker. --- xen/arch/x86/msr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 3f0450259cdf..964d500ff8a1 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -240,8 +240,12 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) case MSR_K8_HWCR: if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ) goto gp_fault; - *val = get_cpu_family(cp->basic.raw_fms, NULL, NULL) >= 0x10 - ? K8_HWCR_TSC_FREQ_SEL : 0; + /* + * OpenBSD 7.3 accesses HWCR unconditionally if the TSC is reported as + * Invariant. Do not set TSC_FREQ_SEL as that would trigger OpenBSD to + * also poke at PSTATE0. + */ + *val = 0; break; case MSR_VIRT_SPEC_CTRL: