From patchwork Tue Feb 1 16:46:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12732028 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 BBB70C433F5 for ; Tue, 1 Feb 2022 16:48:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.263672.456511 (Exim 4.92) (envelope-from ) id 1nEwJq-0002od-Ie; Tue, 01 Feb 2022 16:47:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 263672.456511; Tue, 01 Feb 2022 16:47:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nEwJq-0002oW-Ez; Tue, 01 Feb 2022 16:47:50 +0000 Received: by outflank-mailman (input) for mailman id 263672; Tue, 01 Feb 2022 16:47:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nEwJp-0001jp-EM for xen-devel@lists.xenproject.org; Tue, 01 Feb 2022 16:47:49 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ae893b9a-837e-11ec-8eb8-a37418f5ba1a; Tue, 01 Feb 2022 17:47:47 +0100 (CET) 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: ae893b9a-837e-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1643734067; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=iQ8aKLKi+QRqm0WFp5cY9I2IT2KtztKgt4ISNOrHVJo=; b=CnepMP1HNjytUTBCDPC5hdKLWqzSlqRFuLIda0T26xP3pwBJr3uzu0lD rpr1EBpE42sSWW2IyF13rgc8RfuWBV6ZBb7NhVAEV9fj0JxHNDUTALAUE EEZhCUK9b4v4oPpiu4VcJsM3RBISkVIbj/SjAcSgLE695Ukr8lcKbUaJL g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: rBm4U5mhg7EzJd67m+tOSkD1koJKCPx5b6mkyO5J4Hk32Mvk8mCEo1gp+JaYXLndmlnK/WKAoo 1IrDWcqdKO+UMUD3vtG0mtsluzZdA7iw1pKsDfP6LlJxXXuXPCDc3CuAD7HSh7vklsIE6HGcGW hnJALZOvI7qNpQVpZqK4FLtk7HZzjNMoyP2TqN67bVxPsLH+/HIICuJcr456/4rxCNOAq5l1A+ 5Azl0LsorCbpYTlbYggjtnzAbvUx4e4ZT09TuhKWYHxiZ5QEXKoZGXMoEgGGv2GOv/T+G2cuWE k9kSrRwiCab53pWQjHHCsMkq X-SBRS: 5.2 X-MesageID: 63644287 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:g2qAoaxIveAvFIEdeIp6t+e+wSrEfRIJ4+MujC+fZmUNrF6WrkUEz GAaCj+GOfnfNDHyctglb4m19k4FuZXSnYA1QVNs/iAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnvopW1TYhSEUOZugH9IQM8aZfHAhLeNYYH1500g7wbZg2tQAbeWRW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u/ +z+jlvWEcgZWgBvLMfKc/bznVm/imcQxbBpVEzSL9gNJEi1qNp2Kzb8h+McKt0XLUmR3SOT0 gubWE9KpeTEr4Iv3sPOgKSI89WgH+dkRxIIFGjH97emcyLd+zP7k4NHVe+JexHbVX/1p/r+N bkEkamkPaRezlhQsod6H7J69o4E5oPi9+1A0wBpPHTXdFD3WLluFWaLgJtUvapXy74H5QbvA hCT+sNXMKmiMd/+FAJDPxIsa+mO2K1GmjTW6vhpckz26DUuoeiCWERWeRKNlDZcPP1+N4Z8m bUtv8sf6gqejBs2M4nZ0nAIpjrUdnFQAb86spw6AZPwjlt5w15PVpXQFyvq7czdcN5LKEQrf meZiaeqa26wHaYen67fzUTw4Nc= IronPort-HdrOrdr: A9a23:Io519K/3Bij5WvpnrtRuk+E2db1zdoMgy1knxilNoENuHPBwxv rAoB1E73PJYVYqOE3Jmbi7Sc69qBTnhONICOgqTM2ftWzd2VdAQ7sSlLcKrweQfhEWldQtq5 uIEZIOcOEYZGIS5a2RjXjaYrQdKbG8gd+VbIzlvhFQpG9RGsVdB1ATMHfmLqQ6fngPObMJUL 6nouZXrTupfnoaKuy9G3k+RuDG4/nGjojvbxIqDwMurFDmt0Lj1JfKVzyjmjsOWTJGxrkvtU DDjgzC/62m99W20AXV2WP/54lf3PHh1txALsqRjdV9EESmti+YIKBaH5GStjE8p++irH4sjd n3uh8le/9+7nvAF1vF1ifF6k3F6nID+nXiwViXjT/IusriXg83DMJHmMZwbgbZw1BIhqAy7I t7m0ai87ZHBxLJmyrwo/LSUQtxq0ayqX0+1cYOkn1kV5cEYrM5l/1SwKpsKuZAIMvG0vFmLA E3Z/usp8q+MGnqIkwxh1MfjuBFBR8Ib1W7qktrgL3g79EZpgE986Ii/r1uop43zuNJd3B13Z W0Dk1WrsA8ciZvV9MHOA4ge7rANoWfe2OEDIqtSW6XZp3vfUi976LK3A== X-IronPort-AV: E=Sophos;i="5.88,334,1635220800"; d="scan'208";a="63644287" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nVZn64yVMjR/KyHngXzqdOmfNdtDKiqRqnOWqDJ4Bd/0IDq382Ygi6jYnktIR3WAM1Pfk1acmaTkKKvW1p7Oe5Q7R7rLZRmRiFlYKfuEVM6H8PelONuqtH+rhq5jC4laNGz2X3UOhjP8z1XV5+3E0ZUfvehK+tHocBm80UP4WGSzKAibdScsDmq6nYAzzCqRQmMShLsrKwzy8yzDCTaPh6/T1vxTf0fQcoWR8CiAcwr4cN59pCrG7cFl6xeoIJ4/9l69PSDVDwkYkoj2h62SzFs1TpJozh16jMYJmJXpVAnh578T2e8W7KXOuDHaC2U30kmDz7jJev27VW/4zRHkQw== 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=hGPY1jN8DxvfaKtqXBqMnzr4TdR32OJ/pPgeJPgLEX4=; b=kaxYvJmUBtk4jxsSkM6zeVqOWKPTXk8clMYZ0GSmDVnBTFibFHsXHKcHrL92TWcFQCoXJxDPqFr8NOWg4NiSQDMaNyV9IJpQMpDEQ8FtvVZC6xSunsfSlK4QBARJkY8EBfpcNtjtTjHTWuI3MPCq/7pjzYO0Nl+Cr0LnNKJj3FmW5yv8QvH061EdlcmeKsHGIWD6STiCiAC7VXla3v8/1JeTTlUTWl9EL/hqrk68DvlQT9KSfXcwcj7hHFXrlcK4lE+Vh5z0z8XwV0OweYSFhly3+zZY45VBbtAY15z6iECVaFoDppLBuQWCOYeiiJhs31IH+c9znKe/SiFpP5pTKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=hGPY1jN8DxvfaKtqXBqMnzr4TdR32OJ/pPgeJPgLEX4=; b=PoMM35FnbA8FyTbfKoJr8K9XKz4Il8FXKmbcy8GJN2m1D5G9FG/qjoutbar88+jPxTSqijcph/LuaJtlMfYE+h8M20G2IeWKnAU7S2qr2wjXK504Wy56EX4PT1TwPJWTjGWJUrQMdHZAFrkoPh7ArVnscTjTKBDjC7eGcA8T6IE= From: Roger Pau Monne To: CC: Roger Pau Monne , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu Subject: [PATCH 0/3] amd/msr: implement MSR_VIRT_SPEC_CTRL for HVM guests Date: Tue, 1 Feb 2022 17:46:48 +0100 Message-ID: <20220201164651.6369-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: LO4P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::12) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67e59fdb-8660-444c-61c3-08d9e5a280ec X-MS-TrafficTypeDiagnostic: SN6PR03MB3565:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eGxltsL0f/Za4UVeC5LQRhhNOe7mv+QfrtlZhjmBxpctJvYYIlZsCPGcVPsN3x4OVE5q40uk9Mt4UVRuY9piI2M1WcZf67VyDCmjP7xvvJQUie5/PLR/N+28fI2rBy0U8vBm7HNP2+SzLGyw2ivQuQO2lcdR1b6lMf4nx8i+g8qarfCvwSHfwo4V/e6GZL0LkDTtISd4vOI0ZL4niB8QzI4yqXzUGlc+FfM+jm/ktK7Ln74sUJkqA1aJjAW7PFO/LgmwevS3ZEAsuOVcHz+L0p98ChvgDNsuaqoYBXXGi+oJMqRylVf5fitlN5wxV+xvdJycM9hNElZ+GmWyM7xSqW7e0aguKeqPoTYiIO6fCkQjKjA80ZGzONfbGQwMX9hQRCs8mRWblJSU1XniUGnIlpu4M+rcrl5SFXqnWvU+ErFNeby6j3IhPCHY5aRKfIFOu2luslE3H2Eju+9u5oo+Z3tPr+KtJKer0ZmXVd/wLADRubJBzpEP3bW2k93p60tqsuJYMd4R1HXmAcfQ3q8HFCVAfkuTz5ie364mNLwwvL+/28WdMB0jYZ8WiPRtJd0i9WglBlh2MfAJYVgURQcmZ18saAKKy5ilEuLbdeAc9Ay3um6X2o1efIK8VbdF0KsUBx0Tkkf34E4iWOyybPTNVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6666004)(66476007)(66946007)(8936002)(4326008)(8676002)(508600001)(5660300002)(66556008)(6486002)(38100700002)(83380400001)(6506007)(36756003)(6916009)(82960400001)(6512007)(26005)(86362001)(1076003)(186003)(2616005)(2906002)(54906003)(316002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HZOPVQL38G7O4pgpV43fCij211r4?= =?utf-8?q?qyBxK0HOHwhrP9gQfBTaqeg0wp3/zN9zNq9+qPAcfdyJeWjp9d3YXAkip6Bo0AD7b?= =?utf-8?q?Fgv3zu4mtMOppjPNl2Wrn2iwIDrrsiMZflXGO3vSdD0q0Ye4gSbXc6GJnJNniv8uV?= =?utf-8?q?RvjH6T/pnvlSRexiT6i8v8cm3IUH1mM9sdh4glg2YP3UrvhGzcrQy6pXKxm40+RkX?= =?utf-8?q?f9yvdOmGE+HTnhcFrURZNc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52gNotUS0tK8uwAKe7Am29kxeFg7EI1X5vgKkKGPe79uAV1kw30Jim5xx?= =?utf-8?q?AfmPyX70gUi4s0qrnAyAR8YQiogt4gXwZMgYUps+lwJfQYDfJ8AZForKSnux9a/g+?= =?utf-8?q?V/99ljep5560Lfhc4FcHNR8XVs3QfTNig4WCVfaUB/Bpn+Z6OPASC2H8ack98ttg4?= =?utf-8?q?xuuH4DNLvMzUVWFS8ntgHmI6xSj9/8S/zfBC238udJaSWKWHd49HeN1Kl4M2o93rf?= =?utf-8?q?bPSPlQCUnSdnbpIwPcEUKNqwng5PkgigWd4seIyvQd2TfQsGIKcHiqeprIVIE0HdE?= =?utf-8?q?UHuBOQniDbt8NvBlgJvwSmfkFYkBkFIwuGaoo68DAWoo942svsjjKsjDg3BnRd5AO?= =?utf-8?q?g0lfFzIUSX+AoFkeec50210yiys9+g77oinsxHIwQObPt9L2ZwU66uzdWg0zJBPdn?= =?utf-8?q?75PB0eyibu1ItXNj3RyIIA9+H8aOCKBszjLxDMKO0bBF8hpc8clz7Tc=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 67e59fdb-8660-444c-61c3-08d9e5a280ec X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 16:47:16.1960 (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: uGcJfQOzqHlEU7tVt7ky2yj5IO7me2txUJ29ntI6JZRSGzyOipS1PXblHX006fwd5vEfnXDEmdAHgAM31pW1tA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB3565 X-OriginatorOrg: citrix.com Hello, The following series implements support for MSR_VIRT_SPEC_CTRL on different AMD CPU families. Note that the support is added backwards, starting with the newer CPUs that support MSR_SPEC_CTRL and moving to the older ones either using MSR_VIRT_SPEC_CTRL or the SSBD bit in LS_CFG. First patch is quite clean, as it uses the shadow SPEC_CTRL in order to set the SSBD bit and have it context switched by Xen using the existing logic recently added. The next two patches introduce a different way to context switch SSBD either depending on the underlying SSBD support, so it's either using VIRT_SPEC_CTRL or the LS_CFG MSR. They also kind of overload the usage of several spec_ctrl variables in the hypervisor in order to store the status of SSBD even when not using MSR_SPEC_CTRL itself. I've tried to document those in the commit messages, but it could be controversial. Thanks, Roger. Roger Pau Monne (3): amd/msr: implement VIRT_SPEC_CTRL for HVM guests on top of SPEC_CTRL amd/msr: allow passthrough of VIRT_SPEC_CTRL for HVM guests amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD docs/misc/xen-command-line.pandoc | 5 +- xen/arch/x86/cpu/amd.c | 116 +++++++++++++++++--- xen/arch/x86/cpuid.c | 18 +++ xen/arch/x86/hvm/hvm.c | 1 + xen/arch/x86/hvm/svm/entry.S | 8 +- xen/arch/x86/hvm/svm/svm.c | 67 +++++++++++ xen/arch/x86/include/asm/amd.h | 3 + xen/arch/x86/include/asm/cpufeatures.h | 2 + xen/arch/x86/include/asm/msr.h | 6 +- xen/arch/x86/msr.c | 15 +++ xen/arch/x86/spec_ctrl.c | 11 +- xen/include/public/arch-x86/cpufeatureset.h | 2 +- 12 files changed, 230 insertions(+), 24 deletions(-)