From patchwork Fri Nov 24 08:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13467163 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 C1F4AC61D97 for ; Fri, 24 Nov 2023 08:37:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.640221.998153 (Exim 4.92) (envelope-from ) id 1r6Rgj-0004y2-ED; Fri, 24 Nov 2023 08:37:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 640221.998153; Fri, 24 Nov 2023 08:37:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r6Rgj-0004xv-BS; Fri, 24 Nov 2023 08:37:25 +0000 Received: by outflank-mailman (input) for mailman id 640221; Fri, 24 Nov 2023 08:37:24 +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 1r6Rgi-0004xk-3m for xen-devel@lists.xenproject.org; Fri, 24 Nov 2023 08:37:24 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on20613.outbound.protection.outlook.com [2a01:111:f400:fe13::613]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b04f7fc5-8aa4-11ee-98e2-6d05b1d4d9a1; Fri, 24 Nov 2023 09:37:23 +0100 (CET) Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by PAXPR04MB8526.eurprd04.prod.outlook.com (2603:10a6:102:211::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.14; Fri, 24 Nov 2023 08:37:21 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::eb8e:fa24:44c1:5d44]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::eb8e:fa24:44c1:5d44%3]) with mapi id 15.20.7046.012; Fri, 24 Nov 2023 08:37:21 +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: b04f7fc5-8aa4-11ee-98e2-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTdOQQDEtZ69V/R2piTdWheOx84lxgcHhjefkyEC+jHoR4T71PW+1+FyZK3iL2HR2B7oaWBJ9/ABbWP6+jBv/7RMZc/XLzV5g3oxKPCC3QxxwwXnMmA75gjAAgKv76UwVklTjTmeKf+6u2wSkPalja71TOuhTujgtnRsnWC5yr5pd2o1ky91BaLXAneaGV+3pAMHem4rF7DIOOvcSEOQ19OyWXisB+6yS4j7S2GdguMW4KFOTv1BlNdDVMWpfNFjDVxS/s4/6gHO8bIBa0bfv1PwbMPmk58YeTCjM1UPpmmVTiqN2DX2+Iwl2inlEVplOPnmGMiiYphHTPjwOSgnDg== 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=WhVP6c4MwU+XZvpPh3/grpvaiJbYdKXcbJ07V03kqeM=; b=XY5bc6l7Ay7Z5tDuSGVqQ+lQnaS678WWsV25rzcgWbk44zJc8HIDryIwYYNz+M4YSFufQ3T051apWOUDylPJLjTypO+itu3Il32pHFyrosnCmkdAb3v13mrp962k7B/Bxf9VSlI0w6Ve4NSWFOamkyasS2i5/+NtXgHxVIfyC3W0kXDVaVG2FfoiUUd/PdPBeWgvFJQOKtQqZSX93UcvDH7bHIh0bR2SWdte0fPzKJDTI3ojumzJCS99np74u9VVacBbMX64kj61M/jUOXPdPG0AUqx4kUyDlLbW82PWyWY4H73J78Qgu0VWHtAPt5tepW916Su9d0CQBzgSXaOk7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WhVP6c4MwU+XZvpPh3/grpvaiJbYdKXcbJ07V03kqeM=; b=2QFc8vlY8T4jdoRuI7tyNj9C+BfGtwFPnIU/LmRjMQyu5yANkh2/tOceNJ5jSok14+FpnhXFMKEuyf5S8k8+oX6VrkWGZTW3FQzHc6E9z2n947uIXh/k8SSy+AIaq8OhIj909Jtgh+RkT5eMStd5c/Se9ZTbVf8P6pamJI1aKMlkAHAWKYrtTlJyB/7vkS6YruRp6Kjb9BfRpwSsHrvqXM0pbq1OTa7DcYO3h5vv9gtoahIpdktZGXTRBRH8tQEkU9ET6ZLz5+orX2arFKEjCkuV4K7o7DA2PNNBf/KIGtajEY0SVteUHOBshKkpu7HJgNNSjc54XgXg4NenYPJ+1A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <254ac524-4217-4bd4-9664-a340bf92db0b@suse.com> Date: Fri, 24 Nov 2023 09:37:20 +0100 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 02/15] x86/HVM: hide SVM/VMX when their enabling is prohibited by firmware Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Kevin Tian , Jun Nakajima References: Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: X-ClientProxiedBy: FR4P281CA0408.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:d0::6) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|PAXPR04MB8526:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fd54dde-d634-4210-1cf0-08dbecc8937e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: he7VwmcOepMajtoKQsqtchUPd2Ul0OwJriYmkXgLxpGNnu4vcV8pA9bDdqVWhWsKXeOGzQSfWqbj0ZEfUYPx8OGGXVBRK/NJim0YMmQnheITQqWEDI1YF/TphmaJRrepSpzZiGzEpRo+7/JaYUj5DTeBp6OeALATbBXF0eYWLOPU7Ld+pyMkLQIKbXmDfM0stQG1txolITuJxVk2JkBHEuowiOGVD3ea5rx3eX7csB2IY74eXRiOSY0U5KYHAzw+3xKexDW2pzXVymhPYpWeQzOIKRsmjGj4hlXS9qxHDbsrqvHOVd8i9a9W2j69yInm9ZJThLH7ANAEs3jy8kNIx57sqIEpDNpPnpRMtF0YnvrbpwqYk13byNM90dNUJWeOttYYrJbeTHCJUhqyoBeHQ0eXRUgISHVvMGE9bXI8tspv+8sH6KhEF2BNzpBd5U1aTvCKxTBSZ+VsQtRpz9rsUeL/7jQdOzrqZ/kBv8T2yF15jnU68rGCNpuD29FSQB6hI9ffzlYSfHi3oPRE78+8c5QoRoyalmnl6hRvMD4/4WjkrYxzfRVJzCW9e0tjSzG/TmiGnnF1cJ9v0b5WbtH/aSegmBkG7eS5OPJdWoOY2eGBmKBEgh8ArOyG4wbAxUou6GpJhiapRkJEAIlPQi8Srw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(376002)(136003)(366004)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(2906002)(5660300002)(36756003)(31696002)(86362001)(41300700001)(38100700002)(66946007)(6916009)(66476007)(66556008)(6512007)(26005)(2616005)(54906003)(316002)(478600001)(6486002)(31686004)(966005)(6506007)(4326008)(8676002)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9CsuSa6OuLfVpcYq1kDDQGpOg7iJ?= =?utf-8?q?gKOPp76qoZwHq6dlz/XSbl5x5caCjTPnVLlW5HN5H3NxsymKLLA73NgwHgGCbjaqH?= =?utf-8?q?VmTOHfsGC9nTW1HtzwM4swVmCcoBr2qZTv1Fi99c/ZR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JS9MzZQNbEi6nPZnH7XGPN?= =?utf-8?q?svVjNSxaoFcMi+ZTEA3PX/xRGy4cCQff8thZF+17Gx24c38Z9wcSLFg7ED2M5fpYf?= =?utf-8?q?O1odzyHKsMG/O9LYTnm7z0fQNdUQZkUFznjjZ0wZVrnxB8tJLI0UzFQZYMheigsK3?= =?utf-8?q?NrfVT578L3z6MPdSORTGWTrgI17A5NmcpwJQ0SLceF8+iG1bpur4UEXZQmJ667J/T?= =?utf-8?q?Eye/P2oi2Yfhe6Jp6XtDGSB1252wmEZEbE9mgBzg9WvL/761IgGqL4/Dygiz5FVCa?= =?utf-8?q?pfzcarbvvYEkgcixWTTI7pkjlBiB6VzxLHqhFv9TzblV2jPduMnSW+SV7NfHToxdW?= =?utf-8?q?ZvvI6VyFTLldK5oaVbYCRzDz1LPs9Ce/UpffaK9aEbMVvMIOgKsmOH3aGGPld3XeG?= =?utf-8?q?58WMVLsfcreO7xZBuwbEnCwktKlIt0EpZqmRorNsYp6cqatLurribkjaMNl/6k0kI?= =?utf-8?q?5t8Mogx6WY5BnhDJoeXbc5uZ0We2yvVRPdO9L22T1RQOObC8k+v4kSNBSlE2BQBh4?= =?utf-8?q?5Cx0jy0rWXTZ?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fd54dde-d634-4210-1cf0-08dbecc8937e X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2023 08:37:21.6506 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /QxOGBRXbu1EXC/fmPoKL8MP4g4zK7C9XgqW4yvTx4oMjLzkXaWH8QGaQVfouWnJcYkvQ5aH0SmO8+vuHrL1kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8526 ... or we fail to enable the functionality on the BSP for other reasons. The only place where hardware announcing the feature is recorded is the raw CPU policy/featureset. Inspired by https://lore.kernel.org/all/20230921114940.957141-1-pbonzini@redhat.com/. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2543,6 +2543,7 @@ const struct hvm_function_table * __init if ( _svm_cpu_up(true) ) { + setup_clear_cpu_cap(X86_FEATURE_SVM); printk("SVM: failed to initialise.\n"); return NULL; } --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -2162,6 +2162,23 @@ int __init vmx_vmcs_init(void) if ( !ret ) register_keyhandler('v', vmcs_dump, "dump VT-x VMCSs", 1); + else + { + setup_clear_cpu_cap(X86_FEATURE_VMX); + + /* + * _vmx_vcpu_up() may have made it past feature identification. + * Make sure all dependent features are off as well. + */ + vmx_basic_msr = 0; + vmx_pin_based_exec_control = 0; + vmx_cpu_based_exec_control = 0; + vmx_secondary_exec_control = 0; + vmx_vmexit_control = 0; + vmx_vmentry_control = 0; + vmx_ept_vpid_cap = 0; + vmx_vmfunc = 0; + } return ret; }