Message ID | 20230227084016.3368-9-santosh.shukla@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2309887wrd; Mon, 27 Feb 2023 01:03:17 -0800 (PST) X-Google-Smtp-Source: AK7set+2tz2jibgctWUxdxaZy/s84WQowdq4/BYHBZWD5mcWQHEizVPy+MnSZf3NPLvfUqaP9AMQ X-Received: by 2002:a17:903:22c8:b0:196:7c6d:2aee with SMTP id y8-20020a17090322c800b001967c6d2aeemr30442017plg.11.1677488597626; Mon, 27 Feb 2023 01:03:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677488597; cv=pass; d=google.com; s=arc-20160816; b=yzyxOPFzaBbYWO+9kW5Enz4jVcXexohGUMd9HbrdNQz/0TUbb84REUZsSsKl+npx5N pnimM6b68uTBuuRHsWq5OccV/X3r4ZSQbQDyNUvA0IvpJaoMbV6kPZUFvg544xNWkLjF f5vE+8e7ZnS7Heq7jQ1wwX72r5k8Fpm4avau/6DjIc4pD1edEqsYfhRPzB4QFrKraXsq mP4M0ODwbUpdDbQR3MDid0afgM1N5A3uO0lpuuXRF0IMeC6w9zP7dC9kAcbxENfd5BSF C7D/nR1bCcG1knMkmKdRGQn4IXvGUXdUKldSmc+mSJ5ODFGrsJ3vc0+SaZM5xCgg6D18 4R/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5ZoJBnY5c1ZWHmeG/NH0VLZt3i7xb5uH/tahYI69Vkw=; b=gJC5M2ihpHFLFY7xn6ImELZ3kgMCRcspKEoqwYdnKmB39+G6fb4sRUzI8XlLhE5Miy w6YEhcRXjXZ6JEhtJeaL57m1wuCGFUWF3DroP2zIi0K7+l5uCdI3LIgZI0/uhIhw7pjb nJRzawY/8YfheFzkue1MzHiO+RqWdSulVyMEZUTtIkU0UA4JThCOrY9dqLgP4OWLe1n+ CrwjnaFZcxEolzJvuftCo0T/HZVZdaf01Qy3vdD8DA0zxFp/UAd6ddoUvuJjzU8MVsO1 Wmg1qor/en7Eyr0FTu0UVGogX3I13K5Cg7GB5v8lI0YHm1bTPftUqlVmGgybHibYUqRh HBDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=2i+CezfS; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le16-20020a170902fb1000b0019a95a281b9si6865043plb.84.2023.02.27.01.03.04; Mon, 27 Feb 2023 01:03:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=2i+CezfS; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbjB0IxS (ORCPT <rfc822;sukrut.bellary@gmail.com> + 99 others); Mon, 27 Feb 2023 03:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjB0Iwq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Feb 2023 03:52:46 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::611]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8351EBF7; Mon, 27 Feb 2023 00:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VyB+WpaDaEiHX3Boil9LPddzHLuSofNHnHKxSCCjQX+YGhFRLo0+0O0pDV9RGyg4hnTJAuAq7HZSWECqb+ro3ccVo4XxHMaoXMhADYt5n4rp0dV4aPBEB7fp2/os4V+92AFRXxHNcVF+7PPtR7t8YnFOkVftrivhYtypqMfM6miS7y11O2z7OPqa08Ae4kgke3sVeoPkg2CJHg+RsDG9J0XvpveTOJs8hnG3UKeP9jAkwcsuePZYfPVhByrrStlhF/+6RiwzXlHO8/MBXvnOXb86PcPphMKDT6xKKls9JQjcHAfasKEP+x7NoP5uevFIHmDXI79P81hjU2pLiZcBog== 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=5ZoJBnY5c1ZWHmeG/NH0VLZt3i7xb5uH/tahYI69Vkw=; b=HPmGlwMQTpsi1NMRsMXM3m/qlBNP2DyQ/ZI+HzRBMbVyhFcmDnsFgVhXQOvKeCw2q5BczDy9HjkVBWldg0eM0F6bmXi/9dUdT9+miRp+hMROXID2Uu/EbFqVZRSsfAcVkSCgAiyLb1TYtpUG2Ue+35/KBhsd4HJ79DrywJz9Wf5KqxGroeXaqhNUQlpdOOdNqWowdgLcCaArfpNSaRBFyonsI6gzEZLLlmSAf3ZUjSV2NYQ7Cj1JKngIcIZB+4f/BxNeU0mqLlWsSKrj+Y+x5Gg8JUqcy57v+8WKtcQ5N5uhPSHsmtNJ2eBjd+ZeUJLzvYJNr6QFZxUU/CW6rIM3fA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ZoJBnY5c1ZWHmeG/NH0VLZt3i7xb5uH/tahYI69Vkw=; b=2i+CezfS3JsBcqyB99gBSxOcLwZYFmzCY70cBrfQpXNAA6GTr5lRZ6pa6OIDdtsDJ1UaVcjg9d21g9PInxYV71j8S9uKO2QFzQEqTf6QVdZtL34vSNKJLwy3WiW59zmFlDjEXtXFb1rzs8ROHDFleKHJGq/244yv2MqhMM6AO0s= Received: from MW4PR03CA0226.namprd03.prod.outlook.com (2603:10b6:303:b9::21) by PH8PR12MB8430.namprd12.prod.outlook.com (2603:10b6:510:259::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.26; Mon, 27 Feb 2023 08:43:59 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::78) by MW4PR03CA0226.outlook.office365.com (2603:10b6:303:b9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.28 via Frontend Transport; Mon, 27 Feb 2023 08:43:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.16 via Frontend Transport; Mon, 27 Feb 2023 08:43:58 +0000 Received: from BLR-L-SASHUKLA.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 27 Feb 2023 02:43:54 -0600 From: Santosh Shukla <santosh.shukla@amd.com> To: <kvm@vger.kernel.org>, <seanjc@google.com> CC: <pbonzini@redhat.com>, <jmattson@google.com>, <joro@8bytes.org>, <linux-kernel@vger.kernel.org>, <mail@maciej.szmigiero.name>, <mlevitsk@redhat.com>, <thomas.lendacky@amd.com>, <vkuznets@redhat.com> Subject: [PATCHv4 08/11] x86/cpu: Add CPUID feature bit for VNMI Date: Mon, 27 Feb 2023 14:10:13 +0530 Message-ID: <20230227084016.3368-9-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227084016.3368-1-santosh.shukla@amd.com> References: <20230227084016.3368-1-santosh.shukla@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT033:EE_|PH8PR12MB8430:EE_ X-MS-Office365-Filtering-Correlation-Id: c0f226e7-fc0d-4ac6-a7e6-08db189ec4c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZKLCUgdd0JWRnhdxmsS3IgIIGlw5rAT8csXkbFWQTHNFxWxbjZaBUwNF+9I9Kvy8glrQClK6WYmQg1flVKPA1pXR/2oqEech7WDXiP7gxbSCXPsrx8YBORC017vLRX7knWhmJplFgA6q4L2IXe3WgmuYYdhp6wGZgvaF0pYf8b3Zq8PQJP3AKHGsPqzJtt6TGYsEXOyUYbFKD89wnif+R1P0wGhVrqowimPuwLI+DnkjeZIDEUOx5xk3L2PpDYRRgzO1dij1hOVXFinT9vDqS9LkJrueNTNxXsnHTQxQuBPk/daWUlCAEqA82l96qoHklOMq3Ho+On13s9sNeJYaQXTHxHW1wR0sNfat06kQDaHsHFgouQBTyv8t8AlL9Abhq7qWlhi/CnuvZ8ec+ALdTWP6A48RR8UdnD2fqk7t5lZKL4z1BbUVuY3Sfjw/QR6fX2Hfvg+kUNfAm5hSGh4S7wsdkHJzZiBuIsQGWWffjEDOjVohpZ6FsaJbNPyEm8Q1Mk0Qbt3UOvjCWrpI5np/MoM8kdKK4gmkazm1QVNRYJcWn8tALyqDqv5QelwzrinFRnqCrfLp/jprY7w37inKEg1Ziec5dyo1ntDz4kR6mKv8bQtu6pasmelzu+F32Q6h+Yg2aVfOxUnVPVwD84rOM6F7jeDbMJQgy0uYr9XNjQMCa/dC28E5ABT0VAQK6ZXJqrUfozRN2f034P4A4ncTUbJ0A7NIrp3f+ya7Tyr30ZI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199018)(36840700001)(46966006)(40470700004)(44832011)(36860700001)(82310400005)(426003)(8936002)(5660300002)(47076005)(82740400003)(2906002)(81166007)(336012)(2616005)(41300700001)(70586007)(70206006)(8676002)(356005)(186003)(16526019)(4326008)(6666004)(26005)(1076003)(36756003)(478600001)(7696005)(54906003)(110136005)(40480700001)(86362001)(316002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 08:43:58.6550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0f226e7-fc0d-4ac6-a7e6-08db189ec4c3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB8430 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758974283710271521?= X-GMAIL-MSGID: =?utf-8?q?1758974283710271521?= |
Series |
SVM: virtual NMI
|
|
Commit Message
Santosh Shukla
Feb. 27, 2023, 8:40 a.m. UTC
VNMI feature allows the hypervisor to inject NMI into the guest w/o using Event injection mechanism, The benefit of using VNMI over the event Injection that does not require tracking the Guest's NMI state and intercepting the IRET for the NMI completion. VNMI achieves that by exposing 3 capability bits in VMCB intr_cntrl which helps with virtualizing NMI injection and NMI_Masking. The presence of this feature is indicated via the CPUID function 0x8000000A_EDX[25]. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Santosh Shukla <santosh.shukla@amd.com> --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+)
Comments
On Mon, Feb 27, 2023, Santosh Shukla wrote: > VNMI feature allows the hypervisor to inject NMI into the guest w/o > using Event injection mechanism, The benefit of using VNMI over the > event Injection that does not require tracking the Guest's NMI state and > intercepting the IRET for the NMI completion. VNMI achieves that by > exposing 3 capability bits in VMCB intr_cntrl which helps with > virtualizing NMI injection and NMI_Masking. > > The presence of this feature is indicated via the CPUID function > 0x8000000A_EDX[25]. > > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > Signed-off-by: Santosh Shukla <santosh.shukla@amd.com> > --- > arch/x86/include/asm/cpufeatures.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h > index cdb7e1492311..b3ae49f36008 100644 > --- a/arch/x86/include/asm/cpufeatures.h > +++ b/arch/x86/include/asm/cpufeatures.h > @@ -365,6 +365,7 @@ > #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ > #define X86_FEATURE_X2AVIC (15*32+18) /* Virtual x2apic */ > #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* Virtual SPEC_CTRL */ > +#define X86_FEATURE_AMD_VNMI (15*32+25) /* Virtual NMI */ Rather than carry VNMI and AMD_VNMI, what if we redefine VNMI to use AMD's real CPUID bit? The synthetic flag exists purely so that the converion to VMX feature flags didn't break /proc/cpuinfo. X86_FEATURE_VNMI isn't consumed by the kernel, and if that changes, having a common flag might actually be a good thing, e.g. would allow common KVM code to query vNMI support without needing VMX vs. SVM hooks. I.e. drop this in From: Sean Christopherson <seanjc@google.com> Date: Wed, 22 Mar 2023 11:33:08 -0700 Subject: [PATCH] x86/cpufeatures: Redefine synthetic virtual NMI bit as AMD's "real" vNMI The existing X86_FEATURE_VNMI is a synthetic feature flag that exists purely to maintain /proc/cpuinfo's ABI, the "real" Intel vNMI feature flag is tracked as VMX_FEATURE_VIRTUAL_NMIS, as the feature is enumerated through VMX MSRs, not CPUID. AMD is also gaining virtual NMI support, but in true VMX vs. SVM form, enumerates support through CPUID, i.e. wants to add real feature flag for vNMI. Redefine the syntheic X86_FEATURE_VNMI to AMD's real CPUID bit to avoid having both X86_FEATURE_VNMI and e.g. X86_FEATURE_AMD_VNMI. Signed-off-by: Sean Christopherson <seanjc@google.com> --- arch/x86/include/asm/cpufeatures.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 73c9672c123b..ced9e1832589 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -226,10 +226,9 @@ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ -#define X86_FEATURE_VNMI ( 8*32+ 1) /* Intel Virtual NMI */ -#define X86_FEATURE_FLEXPRIORITY ( 8*32+ 2) /* Intel FlexPriority */ -#define X86_FEATURE_EPT ( 8*32+ 3) /* Intel Extended Page Table */ -#define X86_FEATURE_VPID ( 8*32+ 4) /* Intel Virtual Processor ID */ +#define X86_FEATURE_FLEXPRIORITY ( 8*32+ 1) /* Intel FlexPriority */ +#define X86_FEATURE_EPT ( 8*32+ 2) /* Intel Extended Page Table */ +#define X86_FEATURE_VPID ( 8*32+ 3) /* Intel Virtual Processor ID */ #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */ #define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */ @@ -369,6 +368,7 @@ #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ #define X86_FEATURE_X2AVIC (15*32+18) /* Virtual x2apic */ #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* Virtual SPEC_CTRL */ +#define X86_FEATURE_VNMI (15*32+25) /* Virtual NMI */ #define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* "" SVME addr check */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */ base-commit: a3af52e7c9d801f5d7c1fcf5679aaf48c33b6e88 --
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index cdb7e1492311..b3ae49f36008 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -365,6 +365,7 @@ #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ #define X86_FEATURE_X2AVIC (15*32+18) /* Virtual x2apic */ #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* Virtual SPEC_CTRL */ +#define X86_FEATURE_AMD_VNMI (15*32+25) /* Virtual NMI */ #define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* "" SVME addr check */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 16 */