From patchwork Sat Jul 9 13:42:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912193 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3536DC43334 for ; Sat, 9 Jul 2022 13:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiGINnQ (ORCPT ); Sat, 9 Jul 2022 09:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbiGINnM (ORCPT ); Sat, 9 Jul 2022 09:43:12 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2057.outbound.protection.outlook.com [40.107.243.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED6C62717C; Sat, 9 Jul 2022 06:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EAhp7Z68n2Qczj54cGhZlomNrUE8NLggS2s2H1W3Dwwc3baMVYGJzHlit5IbAEkNzEJtxg6N4TL/8IGH6/+NybqPlKPq9OAFlUXkltrppNCaSkJDCgCYU3p+VMkT9DR2Qi5SV1VtMUTBHSN6NJOF/z5r0jj9mR3cz5Ez0EWOhrXEtxz7aBCkYvnKsvNppoh+d1NcshtBpQoXjPjaFcGSzJ2FlRDYmeeOC2Dxh2muS7MUqGlQ55KLk6Z8OaXfWaoxGcmzXoXQeOmrLinKGNq3B+jEa6+Cpc2D5GQwp30f6J29vi0m+OzU7q6t4NeQhFNLaGkv8vSsflpg9zVsmGyJpw== 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=n8uX1WWhMQFWuijUEv6WU4G+ruoPpAohX1CLqsKngrM=; b=AQCiVvlYT8ZFSArJ1VOFzK5IMEkAw5OQLBJLyJGCoOck+Jsk+/Dc29FCB4xL53lTF+64O4Tm/gPImqF5OGVg1/r9ieixPl9p/TIlvC5drG/3flWEP4o5DmjFogdt9LYMsZMlGZv9FAr2VNK/qaIATk3kXMpsxWvqKVzMaLPU9Kj2ZAazHS2Y5/r+t3uUTiH7qA72b/cVMkw5MzOvCa9aGIYcqrMXE7tD/gw6kz0tHLwP98q6lqtvVvzsBeUwimuepknCCCwnUMOJZ0ZvvZMNFyVMESK9DmTYinu41MCdEk3C7wFNMll1wfCnCAjwjNmfQiiierRUpjMVlmvKHYnKGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=n8uX1WWhMQFWuijUEv6WU4G+ruoPpAohX1CLqsKngrM=; b=anYL5pDLWz/suVp/RNX6CGVP1s4Y24EWt8n0wIzL0kSleDEpzLkaRtwGgXe+sXQfiWntXs5R4Sbg4b8UPDQc/VYZY/bt63ogQWJUH47374Qj/1ne1g7VZ/CQAFczr6p/JJWtPbiKYTEwoyWEyZUwwlX8KPwaoso1fCtkh/DfnPQ= Received: from DM6PR17CA0031.namprd17.prod.outlook.com (2603:10b6:5:1b3::44) by DM6PR12MB4044.namprd12.prod.outlook.com (2603:10b6:5:21d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Sat, 9 Jul 2022 13:43:08 +0000 Received: from DM6NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b3:cafe::a8) by DM6PR17CA0031.outlook.office365.com (2603:10b6:5:1b3::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.22 via Frontend Transport; Sat, 9 Jul 2022 13:43:07 +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 DM6NAM11FT022.mail.protection.outlook.com (10.13.172.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:43:07 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:43:03 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 1/7] x86/cpu: Add CPUID feature bit for VNMI Date: Sat, 9 Jul 2022 19:12:24 +0530 Message-ID: <20220709134230.2397-2-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ce48386-0a0f-4760-7016-08da61b0f4f5 X-MS-TrafficTypeDiagnostic: DM6PR12MB4044:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GWyfXYGzz1elvdAgTsl981dMkqfi8RpXcds/lsQ1kqfpDtW+HBEu7pnbRAvtEzwuDzDUjhnq+KYvUIiBDHvU7QRPHIS8liulNQWm00RIS3KU/F88USS2CbnR8c5MaJNlf+5OIOScX98nrvrR/AwoAZ3dq5+V8yd2YVOjJ2jXbtHTohTmc5F3aqA3KSrhKMpR5iONsu0cZuX3/I2Uhglh5CVKy6S6DnOKuNJflxamnOAXuxu1kLECJ+VdzvjphC8VqjjtdiRuow6qbyK9UkY5IDrlcqbchCMpnCM1y+nkqeiVu2yvcf1eK1huPcqMYd82nsn30E1cxWBz1y/xU3WBg+fAOfaHAsEYgdse7sRCyq9bzdjQv2l8V1rf3+xWGqmFqItJqE7bWstwbek1l97GQ7gT4Y734YGQZttL4/Ey6H09Q8UPGk7NeTOCFlcdesvpmU6dm0w81QDF5WTJlMenq59mQIEdEy9uXeO0Yk6s/73GmS1gfNDx/peABrt8WSTyKjMBDrLIh1tbf4hUZvpWRPKGXPR2uspwwKkrvzIzVD4hfrgbOoBm7D6gtRdx0SsJXKTvnMPqjnMPq8p4MLXGyM2v70MgQEdLRZQIcsc/6sZad8H5P5DxGdHZCaNk7j+2OCQub9m2NOWaNSoA6lYD6AUhe6g+7gp4u4zN2F7PaVIGNTDW67F5WMBUVSiAEmGwh2WMS3NF/j/v8jHTUHBgxuOoTBWVwpBHcEPNup6wmC04ToDOF4KouHyrKK30LlMwvmdVmJdban0Xzd084nJNc0ZfJqa6eKVjqOZ4gX6MwRyfzxA1s1/oRRds5BAbrCJmd/+z14GsBx5NCOoawyFR2/TtBe0K6US5D33XiV5n1o1eenCgLt9E5AwrR3eErabr 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:(13230016)(4636009)(346002)(396003)(39860400002)(376002)(136003)(46966006)(40470700004)(36840700001)(336012)(16526019)(47076005)(41300700001)(36860700001)(6666004)(40460700003)(1076003)(426003)(34020700004)(26005)(2616005)(316002)(7696005)(6916009)(54906003)(2906002)(5660300002)(8936002)(81166007)(44832011)(356005)(8676002)(40480700001)(70206006)(4326008)(36756003)(82740400003)(70586007)(186003)(82310400005)(86362001)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:43:07.7116 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce48386-0a0f-4760-7016-08da61b0f4f5 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: DM6NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4044 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Signed-off-by: Santosh Shukla --- v2: - Added Maxim reviewed-by. 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 03acc823838a..9a760236948c 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -346,6 +346,7 @@ #define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */ #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ #define X86_FEATURE_V_SPEC_CTRL (15*32+20) /* Virtual SPEC_CTRL */ +#define X86_FEATURE_V_NMI (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 */ From patchwork Sat Jul 9 13:42:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912198 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2B5BC43334 for ; Sat, 9 Jul 2022 13:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbiGINnt (ORCPT ); Sat, 9 Jul 2022 09:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbiGINnm (ORCPT ); Sat, 9 Jul 2022 09:43:42 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1CFB2A243; Sat, 9 Jul 2022 06:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3KjMSWvnbsIIjKEvUmPRkEKde5It+GolRTimFZPn6JsS1RIg9L1AP/1cvb05LyvFLtA/b5Fbt2zJCxH6dw+w+x8au2nXN4k6fSWYDfiRWl0tRuQCwPK6Ac5RrHiM3inUTiRVTHD1fC2TzUz/FFjlQxUgZBKUEz0H9EfEuBxCT34yAJPyaWjwu/2M31hxI+lF9KgZfDxlqvUi8rLcV3h60A2Zv8O8DF3JeoC3zIH3J9OsEwexWzKrbAClNC4apYw9D7A8VH1ot2QhwTIbq8QRwonUXnSlzSlnNz2BnPozrjC0G/Ae55UNvI2Vt8nUt/XUKIC0pT/zPz0OnrDbuS4yw== 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=PuLAWyjcFvPe5L4IXWgWHUqzNoVbFPfUnhccGbGKIf8=; b=UbudUrxvLgCwzOY/pemW/dEMkpme9N1mkLeyIeVfAQEYuzCZqQ0WxcoCph7JpgddrSM178TjN1Oo2heiK7tvxDG9BxWnHVSpNTfrnEdB2k9eQOyothktSt5814Z3xx3CaynndDvV4WKuJ2VUVYKJz3ODG/jC1misrjjXrvFzjBxiDaq8KuP/XE2MT0lzHDHrifvw4DrcEkW89gwwj6qxKOpjG3zoXwTctgGh5khtfNb+ZNk/9yR1h1ItqjoG1frxZm9fLeNN3FkBuA0t1tWWBZ5W0olvHeAs347wyeAJs/LJwI2pUYnil5pl/EQSsvS6Vah2yOsJUvoP2Teor44B9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=PuLAWyjcFvPe5L4IXWgWHUqzNoVbFPfUnhccGbGKIf8=; b=M3I5yezxDrMhPGHnbiKvVu53kBqlMoqsCp3w3+XmU5skQC+chCujoexIh2S3MvGljdRBoxIKMnUq58ifEDOXidQGvv2LAo8RgmurzYmtBsfLuv3XKM8XZBDK6nC0vjluIs/XzDKTxIBWLWNe3IxxjZUMMqWnya4bQhcD2sNA/y0= Received: from DM6PR02CA0071.namprd02.prod.outlook.com (2603:10b6:5:177::48) by DM4PR12MB6160.namprd12.prod.outlook.com (2603:10b6:8:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Sat, 9 Jul 2022 13:43:25 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::3d) by DM6PR02CA0071.outlook.office365.com (2603:10b6:5:177::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20 via Frontend Transport; Sat, 9 Jul 2022 13:43:25 +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 DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:43:25 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:43:21 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 2/7] KVM: SVM: Add VNMI bit definition Date: Sat, 9 Jul 2022 19:12:25 +0530 Message-ID: <20220709134230.2397-3-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7a30d47-eef7-4565-00d6-08da61b0ffb4 X-MS-TrafficTypeDiagnostic: DM4PR12MB6160:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QykM/ke3Qt90gMl+qzXRtROCBxfVxcKrszZxZTGF/lApHABJC92tCWKZa6jJJN8++LlvYSPj/iOngDOQmGxWppGbhv/yHJnxq/jFsCxm7Bk/PL5ks+/p++pXrP+AlywdjDssoWKIEXYaSzA1tE8ngF/VebUB/7Xp2+QINw7tnOGCUJe1CbH88AkL4v4Vgv/cscYA3bA3ivR/tU0Lm7pMf0gjUHNUtU0yQzmA0st6xYzTaUb/35v1IU0Un2iUl2J0nknrxXt+2vjvB2NpG7DXcou6HvY1rdjkICB3Brhf0IvU7CBv00w3kMl31E5nxMbT56ywbvwzIM/Ms8QgZvvu4thE9UIw00CFDLLkHNfNVpPnxiHMirsS2zSuXC0wj4O/H3+AZy/MmEhZHEt1FBmYO8/ecT5vpHGg+U/8vZPIHJXmBlZRzbQTLvnegJmSCOhxhl7s1RD0BrSrDSayja0Z85YvyZQhU35c+dzYbh7I6m1FrA3rpp4FFcCxXRF58GsQQafEflevd2dx5NwxcKuEwhWMF5JaWAqgtyHe6HReJlxjiQ6pnKUI/+f17LM0aXCXo6rFNGlCQWqrXYzobnNVRAPNf1BkEHfaqIQQKnnZO+lqz2fSRZrzXlWH1pGy2bsjb+pImIZj8xd4zmX/xtj85Zw8dRyLD6TKozuO3LoPUw7C8O0n+1+hffVSQl8r1czuyhCMw6zxe1RW3xMSxZyfQnJ3Ty8QyJr0pmJn6cZFnnRPVhnRZ1XEidI2+sV5sYXiEWNZ18QnRqPKHnc8pxlkqJCXJzblCAFH9VEiVwsDP52YUzfR9T8tqfEo4sc6zthGezFn8vo4iKWaBGKqTGQUEzY74T6GzVraqevjeFCAdVoFHbsoAxIyIswCGM5eTQ4Y 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:(13230016)(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(44832011)(40480700001)(47076005)(16526019)(82310400005)(70586007)(34020700004)(36756003)(54906003)(70206006)(356005)(316002)(8676002)(4326008)(186003)(36860700001)(2616005)(6916009)(86362001)(426003)(5660300002)(2906002)(40460700003)(478600001)(8936002)(26005)(41300700001)(7696005)(1076003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:43:25.7534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7a30d47-eef7-4565-00d6-08da61b0ffb4 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6160 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org VNMI exposes 3 capability bits (V_NMI, V_NMI_MASK, and V_NMI_ENABLE) to virtualize NMI and NMI_MASK, Those capability bits are part of VMCB::intr_ctrl - V_NMI(11) - Indicates whether a virtual NMI is pending in the guest. V_NMI_MASK(12) - Indicates whether virtual NMI is masked in the guest. V_NMI_ENABLE(26) - Enables the NMI virtualization feature for the guest. When Hypervisor wants to inject NMI, it will set V_NMI bit, Processor will clear the V_NMI bit and Set the V_NMI_MASK which means the Guest is handling NMI, After the guest handled the NMI, The processor will clear the V_NMI_MASK on the successful completion of IRET instruction Or if VMEXIT occurs while delivering the virtual NMI. To enable the VNMI capability, Hypervisor need to program V_NMI_ENABLE bit 1. Reviewed-by: Maxim Levitsky Signed-off-by: Santosh Shukla --- v2: - Added Maxim reviwed-by. arch/x86/include/asm/svm.h | 7 +++++++ arch/x86/kvm/svm/svm.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 1b07fba11704..22d918555df0 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -195,6 +195,13 @@ struct __attribute__ ((__packed__)) vmcb_control_area { #define AVIC_ENABLE_SHIFT 31 #define AVIC_ENABLE_MASK (1 << AVIC_ENABLE_SHIFT) +#define V_NMI_PENDING_SHIFT 11 +#define V_NMI_PENDING (1 << V_NMI_PENDING_SHIFT) +#define V_NMI_MASK_SHIFT 12 +#define V_NMI_MASK (1 << V_NMI_MASK_SHIFT) +#define V_NMI_ENABLE_SHIFT 26 +#define V_NMI_ENABLE (1 << V_NMI_ENABLE_SHIFT) + #define LBR_CTL_ENABLE_MASK BIT_ULL(0) #define VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK BIT_ULL(1) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 44bbf25dfeb9..baaf35be36e5 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -198,6 +198,8 @@ module_param(dump_invalid_vmcb, bool, 0644); bool intercept_smi = true; module_param(intercept_smi, bool, 0444); +static bool vnmi; +module_param(vnmi, bool, 0444); static bool svm_gp_erratum_intercept = true; @@ -4933,6 +4935,10 @@ static __init int svm_hardware_setup(void) svm_x86_ops.vcpu_get_apicv_inhibit_reasons = NULL; } + vnmi = vnmi && boot_cpu_has(X86_FEATURE_V_NMI); + if (vnmi) + pr_info("V_NMI enabled\n"); + if (vls) { if (!npt_enabled || !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) || From patchwork Sat Jul 9 13:42:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912199 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 347A5C43334 for ; Sat, 9 Jul 2022 13:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiGINoB (ORCPT ); Sat, 9 Jul 2022 09:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiGINnq (ORCPT ); Sat, 9 Jul 2022 09:43:46 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05F2D8C; Sat, 9 Jul 2022 06:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhWAXkwU0R5lj9ILRKLNKOo/g7T9tSf1S8/zXIf9exfW1w2UcYBSG8FHET7RvbnH4mT0DtcSUxWjG2AsY1GPMytZyt5kI8kfmtL1C+7om+Y4RxpRGeNo2+/B1UvzOeo+8HlJrF79mDzCNRRG8tbZjIHzogIwypgxnzVbRBFPbq09THu8CSmpO1GSzPvZDPwnnW2uYfFZsS0HiRk99D3P5jH04CVSuhQC5Y1Od1kBVSa09UMnQzvnpV2olgZFyEFEM/iZb09sDH9VhEEd9ZXIXZx2M4sJPIzrom+JEaNOoui1Ha/vkEhp13Z1M56o85vgkr/13p3AatM7VAgHy0fISQ== 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=7S3r0zTkTDWhSLMNu+3rW64b4ABCCXubWAIx76XI9gM=; b=ACiC6WMC+yA5yKmkKdLzjLVPKS738GwNzIYFo+HhmlXVyagK/vc+0wSAuR2+PHPj5NjSz6iO/Y1cSWL7cdy/nJbWKEwaYZ3wdua7oALuloApXS2lWTJ8VjQNQNWrWqyGUsLpNrCvfll0cOx6HLAGx2ccgT2NpZktXFX2PmhRaAKFEsG4/by2TURgbvJChepUNcNkgG4tzTOCwf7Mo8aSNaImxcZMBlIiVVhTI+1adoPKBZr/wusrtnMN69D2aVbHp/5FQUXEq8Q76pD2RNc66JFzjoFB79UWEEpfxi/hww0udKV3LVBAFfpf/xWl7TBw0HzUcpOjfPuBGvAgYlVl3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=7S3r0zTkTDWhSLMNu+3rW64b4ABCCXubWAIx76XI9gM=; b=3+Tmw7lpO8DzGYK5P4fXarj3kmtYZFEmNLNMCBzli1/33apTM5k3O5r+BKqcicnEKXNYCHMlPHNW1WPIplAfc9VJ60QMbAQkjERy7+6/nThtA/JwV3SkDxDQYiMu6DRni2xR4pfKdIoQej/xLxWL9gWX926VZXoNHTE3fV8MZjU= Received: from DM6PR02CA0065.namprd02.prod.outlook.com (2603:10b6:5:177::42) by MW4PR12MB5628.namprd12.prod.outlook.com (2603:10b6:303:185::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Sat, 9 Jul 2022 13:43:43 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::7b) by DM6PR02CA0065.outlook.office365.com (2603:10b6:5:177::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.17 via Frontend Transport; Sat, 9 Jul 2022 13:43:43 +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 DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:43:43 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:43:39 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 3/7] KVM: SVM: Add VNMI support in get/set_nmi_mask Date: Sat, 9 Jul 2022 19:12:26 +0530 Message-ID: <20220709134230.2397-4-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82f605ea-feef-42c2-d268-08da61b10a51 X-MS-TrafficTypeDiagnostic: MW4PR12MB5628:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aZHqn1em/qwsrcV7Ib9LZB9KHL1i6v4zCXDKwxup+Df6hjoylwD9/W5hnFzcID2lXPxSlYafqk5KoFjCUrmIyo8QwdvK1axPOMCQhxdQk0AhXIMf5yjKtE0ndfvETpD+D9R/tfdTorXvjHylIRVVqaG0jQY3oPON/gu42SYU9cOISsqAHL4YWQZj8+2/xYX6JUHbDgu3KXPstEaJM2Jd7WRRsyxM1CZ476YpKnGdQ0JwREyoJnadc7o+t/Qp5ffUv828r809cBgkQ8T91sHmy7FBo5Ufv401tPnbSlpDh6Ewg6dN1UVe73vnyOuTUwbWMrWp6Ai8O5hQgICjAul2T+upTnpoHqmK7fJ2m8DvjV0vaC1Cc8Jzw7LbrLCWHc8lDOaYoeTKv2qVdOBuW78Nwxxj/o9FVW0UxLIh6zqd3SFnGfOJCht7u2MGj42YWs7x3QT6iUdsarrjwWzpZx2tiwEb/hMZhug4e3EIyRxy8rM0FAZOD+xFwyCAn0iPxwmJ7zWkO63LQOETAnnRil+aFtgfwMqilfdDgzG99ljYCOYS+YQmnquNs6/wRnOoOzYXqDIE2wVdGmP4gh7wO6xVaDOHj5sD/hMZJwjUcz42/f/oIQU7nGRRY77MyevBNTiVEAXuN6lM0+D4aQfdwKwj2VHufAj+6sSIDoeTc1mqFOkM7ec1R4f7ksA1TSf3CYlQ7i4tMofcnPSmRa0bcQAxZw3y8ByAG0mepnZ5/4lvBUJpokGUzbuX79nfesFCyRzND/Mw2SXzVHpW2CqB/fi++V2OoD0M5akQ/sbrLH9KWt6xZQkKmD4d/hOrEgVRBrSt+0M8ANaNqWBkjDa05MZH5hq0ABXat7OOuii7pcCV33rG8PIrXvTLRfj9YXiX5OHj 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:(13230016)(4636009)(396003)(376002)(136003)(346002)(39860400002)(40470700004)(46966006)(36840700001)(47076005)(336012)(54906003)(81166007)(16526019)(426003)(6916009)(70586007)(83380400001)(356005)(186003)(40480700001)(8676002)(4326008)(5660300002)(36756003)(36860700001)(82740400003)(70206006)(34020700004)(2616005)(26005)(478600001)(316002)(6666004)(8936002)(86362001)(2906002)(41300700001)(40460700003)(44832011)(1076003)(7696005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:43:43.5492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82f605ea-feef-42c2-d268-08da61b10a51 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5628 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org VMCB intr_ctrl bit12 (V_NMI_MASK) is set by the processor when handling NMI in guest and is cleared after the NMI is handled. Treat V_NMI_MASK as read-only in the hypervisor and do not populate set accessors. Adding API(get_vnmi_vmcb) in order to return the correct vmcb for L1 or L2. Signed-off-by: Santosh Shukla --- v2: - Added get_vnmi_vmcb API to return vmcb for l1 and l2. - Use get_vnmi_vmcb to get correct vmcb in func - is_vnmi_enabled/_mask_set() - removed vnmi check from is_vnmi_enabled() func. arch/x86/kvm/svm/svm.c | 12 ++++++++++-- arch/x86/kvm/svm/svm.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index baaf35be36e5..3574e804d757 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -198,7 +198,7 @@ module_param(dump_invalid_vmcb, bool, 0644); bool intercept_smi = true; module_param(intercept_smi, bool, 0444); -static bool vnmi; +bool vnmi = true; module_param(vnmi, bool, 0444); static bool svm_gp_erratum_intercept = true; @@ -3503,13 +3503,21 @@ static int svm_nmi_allowed(struct kvm_vcpu *vcpu, bool for_injection) static bool svm_get_nmi_mask(struct kvm_vcpu *vcpu) { - return !!(vcpu->arch.hflags & HF_NMI_MASK); + struct vcpu_svm *svm = to_svm(vcpu); + + if (is_vnmi_enabled(svm)) + return is_vnmi_mask_set(svm); + else + return !!(vcpu->arch.hflags & HF_NMI_MASK); } static void svm_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked) { struct vcpu_svm *svm = to_svm(vcpu); + if (is_vnmi_enabled(svm)) + return; + if (masked) { vcpu->arch.hflags |= HF_NMI_MASK; if (!sev_es_guest(vcpu->kvm)) diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 9223ac100ef5..f36e30df6202 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -35,6 +35,7 @@ extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; extern bool npt_enabled; extern int vgif; extern bool intercept_smi; +extern bool vnmi; /* * Clean bits in VMCB. @@ -509,6 +510,37 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm) return svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE; } +static inline struct vmcb *get_vnmi_vmcb(struct vcpu_svm *svm) +{ + if (!vnmi) + return NULL; + + if (is_guest_mode(&svm->vcpu)) + return svm->nested.vmcb02.ptr; + else + return svm->vmcb01.ptr; +} + +static inline bool is_vnmi_enabled(struct vcpu_svm *svm) +{ + struct vmcb *vmcb = get_vnmi_vmcb(svm); + + if (vmcb) + return !!(vmcb->control.int_ctl & V_NMI_ENABLE); + else + return false; +} + +static inline bool is_vnmi_mask_set(struct vcpu_svm *svm) +{ + struct vmcb *vmcb = get_vnmi_vmcb(svm); + + if (vmcb) + return !!(vmcb->control.int_ctl & V_NMI_MASK); + else + return false; +} + /* svm.c */ #define MSR_INVALID 0xffffffffU From patchwork Sat Jul 9 13:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912200 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4594EC43334 for ; Sat, 9 Jul 2022 13:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbiGINoN (ORCPT ); Sat, 9 Jul 2022 09:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiGINoG (ORCPT ); Sat, 9 Jul 2022 09:44:06 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B307248E3; Sat, 9 Jul 2022 06:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mmf9/efocHgiG80i+8i0giLWzDFhFXcxLQmHwrlrRi1F7SAaAocjAK3U4iwBpiw6b9Db2vWY7zJ+A1u88aSnd0grfQPqOK6Fsm9fEqQiGtkhSrJQQU+RdQvSyoaJ7OWdA+U4bFFKV1jsJxm+1DhaYa/1D286cBABkpd/vEedVoLG6v4tz8ab05zqJduuWNe1K9A5E7uJiNPssHYmvXPBhZNSxY4IkUVCpqV+PwYNorrSDgiBjXvZRrhxbHlLME5O7mdfd0qDma4vALmfQpDHXJ8BMhaFmFoTgdqdxPZ8Wrr4zNaQYtIj2ZjKpLfejaMsMDeEfJxt0qWBs8Jtjalnxg== 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=zIJcqnDf62cs+J0uXCW1ySwJTy+QvBkF5HasLXwE7Ug=; b=eO7d/9Y1mBW9s+pEr4rUAIRYVB/PvNdhp3rKoxF3Ij9mEu2icd1SGiHLAE/t1lVm5xYGacYDRkAep/ZQji8m9ZhNSY4e2KsNfQWgw7RtxLKsIGR9r/f5MecVOj12pAoSQxsM3/mNz8BlDvlApXS3QZ6NfNHA21RcC6w1p/JdmnxGVm8QI4aUqomLuftl1VDbvpVtt8VVYXOTumq8RFm8UcW+ekN0oHpIvQR10HTKgsz3QM5pywNW8DyjzfNGhed1rwcVculTrnegxl8H2Szpm0kcrNoq0acgvhLFfwuyDrA6utgDVfF+kXUhUdi8Co3RqH2rOpNgF+6tDCxnUrCcVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=zIJcqnDf62cs+J0uXCW1ySwJTy+QvBkF5HasLXwE7Ug=; b=z40a9CORtL9pgUazCVVC21mTlhEJhKY3NaA+qccQRHHOObifbrd887lwXY6g9Dho5+v39kifWQktEkg3hP9FAYgMA/jD0VXPcyKX3svronpvGk6zXIBFK3z9yjE3IXJE50pB9EUsZGzrF+Cd40/mnRrGx4Gd09LDxE6e+SsHUQ0= Received: from DS7PR05CA0038.namprd05.prod.outlook.com (2603:10b6:8:2f::23) by DS7PR12MB5909.namprd12.prod.outlook.com (2603:10b6:8:7a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20; Sat, 9 Jul 2022 13:44:01 +0000 Received: from DM6NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::a5) by DS7PR05CA0038.outlook.office365.com (2603:10b6:8:2f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.6 via Frontend Transport; Sat, 9 Jul 2022 13:44:01 +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 DM6NAM11FT004.mail.protection.outlook.com (10.13.172.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:44:01 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:43:57 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 4/7] KVM: SVM: Report NMI not allowed when Guest busy handling VNMI Date: Sat, 9 Jul 2022 19:12:27 +0530 Message-ID: <20220709134230.2397-5-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc07e539-33aa-4dd7-1258-08da61b11508 X-MS-TrafficTypeDiagnostic: DS7PR12MB5909:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s+0pDCeO6SDbFP6MMMiB6RK9KoLfaC6kyzrqYA/SVfRX0t+4QNyEGfA2W22a80pgJW/rZB8QWm8/zZHJxXFJJyDQpqupbl1lJrZB7JnMZa7FnEvjGC8LzFZvzsMe34TANcsiHFm0M1rTR+dqY3LvDHq520XZ8v8yzYU8TrgPFouN40I4/j2XtpO8PBIeJOYtc6ZlKzfq5gjsUycZlUKHDlXG2Fkko4021Xc5qIcjAhjCK3Nirz9dutlVbdmbn1uO3q5r8/Bb6T3dyWqDvqVa6PHbV4Efzx2cWfINXkfRZ5gIJUF+Vb5bAj4gGXpmr3UYBlOaJh3Z5mcSs12E9GngbRMfVsqkr5BSt3jLi1y+s/7X0fSejW3ftue0BOX2U6+LNQQaXTmDN1NhdWWLfEZu3eLwgqjDUq2yAxBNy1sCk96BHgATEpKYuzfzMqhrMhJhNM9Qecp0ksP9WI7lVlbePqD37PxQMCZCS+NiL3yC4pzt+Cv2Fma3flioih1oJzYb219AAEvgBSSDlAUzxZGRkSIhcA+9Y962wt9OVApM0VScR/hhvKL6qXbT5FW+6xO3SD1Bxy5Q5PQWBuh3ySxoo93kJsMy62IvwFfmcFJvHACuqryF6izIB7U4zNeA/GeZY0i8qtZ+m/6CYvkfd8kEZd8QoyRDB8GVynZO2RoRlBdcEwniK/3HbsLhPnnCdHFMc1K7r3kOddqW4/+gAlxZMNq5FxZJFNlrd2Usb52a4IS+MXct8eeQXRT4RKWxBM1wfhz/4V1l9VJVXJwN68OsPjFiLhDIaMj7FVeM8aSRIuNxAm5flS9zAJLNUD1UTQCaV5gl0O8VcgP1ARSqRi4AjsQjm4YNuLK5AId2K62XFGn2y/93+8fN0CydPHo8Flcf 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:(13230016)(4636009)(376002)(39860400002)(136003)(346002)(396003)(46966006)(36840700001)(40470700004)(336012)(2616005)(186003)(1076003)(2906002)(8936002)(83380400001)(26005)(47076005)(426003)(36756003)(16526019)(44832011)(6666004)(5660300002)(41300700001)(7696005)(82310400005)(478600001)(34020700004)(40460700003)(81166007)(356005)(86362001)(82740400003)(54906003)(316002)(6916009)(36860700001)(4326008)(70206006)(40480700001)(8676002)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:44:01.5052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc07e539-33aa-4dd7-1258-08da61b11508 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: DM6NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5909 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In the VNMI case, Report NMI is not allowed when the processor set the V_NMI_MASK to 1 which means the Guest is busy handling VNMI. Signed-off-by: Santosh Shukla --- v2: - Moved vnmi check after is_guest_mode() in func _nmi_blocked(). - Removed is_vnmi_mask_set check from _enable_nmi_window(). as it was a redundent check. arch/x86/kvm/svm/svm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 3574e804d757..44c1f2317b45 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3480,6 +3480,9 @@ bool svm_nmi_blocked(struct kvm_vcpu *vcpu) if (is_guest_mode(vcpu) && nested_exit_on_nmi(svm)) return false; + if (is_vnmi_enabled(svm) && is_vnmi_mask_set(svm)) + return true; + ret = (vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) || (vcpu->arch.hflags & HF_NMI_MASK); @@ -3609,6 +3612,9 @@ static void svm_enable_nmi_window(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); + if (is_vnmi_enabled(svm)) + return; + if ((vcpu->arch.hflags & (HF_NMI_MASK | HF_IRET_MASK)) == HF_NMI_MASK) return; /* IRET will cause a vm exit */ From patchwork Sat Jul 9 13:42:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912201 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C793C43334 for ; Sat, 9 Jul 2022 13:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbiGINod (ORCPT ); Sat, 9 Jul 2022 09:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiGINoX (ORCPT ); Sat, 9 Jul 2022 09:44:23 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2065.outbound.protection.outlook.com [40.107.223.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF6DF10E2; Sat, 9 Jul 2022 06:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwsivmXYgOssrqXdzQp3yvY7QBXeKdatiVgqs5WGlg2JFiiQMXkbSXKRHJSq62e8Giq8hF8nG6LK64SlBKACjsNaaNBLLCXTrkk7hfM+GNrY9/I5nnN9JocezKFW9sKwXye6ToUmWFVSZWghO6kryIUEhV3ariBwpaacoqzYnKalMz5DG0yg/O4goNGPxTjt7qnCZM58cEglBDMVlAgwRngwB8x4K0Jl+3emTgscooptSydPnv2YR8EFAIYoFFloR9KigSp9DqZ4acRL4RfrbB9a2WrXzAkoeA9LKlTMFHSqLbrEHPIyEA9FmYHyhWIcKF+AdCke9zsRkY8HIy2xGA== 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=Ur8roISX+gf2f8n23sGGeG3gFOxcLKKYFkZ20+r20aM=; b=Stw0kaTpRkMVgcT9mSNz2aaGvmduPxM8J1A9y4YNOlDClkXYiN3utqNQu8IP/x7LnLMfvYC7mq377g0x7uNsvCSDPMt1i7kW2hzkrsrmrQMJNtaKBNgohWiTHqG1WybRd/4GlSLyBQL8f/EuSdPqa+fJZWrujlbItP5S7uVLSC60PYbsHDtS73/ZU8CEXkGCcBd9cK5dgDwKQMh1U7Vo3Ig0jefmIerx95PhQC6pgxgvZi5iZn4/rch7NnHOkCWZ67cImw2G5DH0aTB+0k0d+rIlx1x5yUzaIn/0VORngdY0ufQoSbZcYo43W/A9QNMFhArg9I9AfQqdrleQQ0aUeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=Ur8roISX+gf2f8n23sGGeG3gFOxcLKKYFkZ20+r20aM=; b=OUV0NvyvUgt08TZNKgELEfd3NNCWyX1oqPVeCEbyiHSBkMMcVE4GBJI9o7rnocNFWTky9G4b7dY9l/51XfMQ3iJxpTEBBCEG8V8UJEAaAbhnPodFcLR314Kfn8LOg+OPhMvmh7q5OxbRyjm+msjrn77r7Ey9ABE0g4MQKjkcNJM= Received: from DM6PR06CA0099.namprd06.prod.outlook.com (2603:10b6:5:336::32) by BL0PR12MB5524.namprd12.prod.outlook.com (2603:10b6:208:1cd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Sat, 9 Jul 2022 13:44:20 +0000 Received: from DM6NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::5d) by DM6PR06CA0099.outlook.office365.com (2603:10b6:5:336::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.17 via Frontend Transport; Sat, 9 Jul 2022 13:44:19 +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 DM6NAM11FT061.mail.protection.outlook.com (10.13.173.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:44:19 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:44:15 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 5/7] KVM: SVM: Add VNMI support in inject_nmi Date: Sat, 9 Jul 2022 19:12:28 +0530 Message-ID: <20220709134230.2397-6-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4d9786e-881b-421c-7763-08da61b11fc0 X-MS-TrafficTypeDiagnostic: BL0PR12MB5524:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dMTBE8XNVNyN2/2v7mNPcsyIlyk3hPSy9f9DsOdRcbii5D4zWEdSIDGVJ6BgOo0ieWlMpwnp1gnLH0mAvUcaaRy/wiGagHeC4/1Hk+CG+1BDWl0LA88UynQwKoum1VQrftyGePvMR8xjo5EKQs68plZaJbI7e3HYSn5vHsgNjv5WPsI4b6Icqmlo6Qw5nRhOl/9ILBIUqyfOnBs3uZVTea8NhdoWmujBleHxNZGpj6YIexw1R7ymv4QhjuXxLxMrbh5kNCL2ywjvHHKu++ZdqlaII3yDPnUfUSmZQRZJ+T1WLenqo5ug+RCakWqDEXk6p2sbG4hX9X3Y3PpTSmYkIHoXBhJnXpD513hlHLayHEAh8thNsObNd8JdF0aSFwKNilTfPZ2tUzkYWV7QhHiGnhA5JIfNXU+xdCxosg3u++7e+NnvpvfhyS8LzWfmEDtUo2zoQcSfw8jtUGEDKK+t8BXosuWtobQJZLvgIjFvFH7xulc+55GrWknM6YNsgeNrT9QBmIRiMOavmCROJxTudCfsj/gBV5gO8U+nWkaFjCCQymMT7bWiLvxmcK7BkwuU0NgAFzesowMLCCuLfJEKTGN5UBjAzI88WTk5K6lKDjWAYNcXOWFCX0Qi2tELrLKnqrCVRbWhUyIC+M4DF8AiRFqvoM20Kb704/TZ7X0cICCwNkqRkWRQIymfM3zzXRlcjOB9POMGNUNdT5QavSem12tfnfd/6Xi9lv8BxrqmGnO52UJaSg0qF3du9F7uuq3jD/E+pUn2EUO3XAfXMadOnIIjR3spHqzgKCPWA3ElRYBaAFJ0INbATo9vDMf432bt+ozn+guZvL+eMuqIViIjsB85xXRvX54OVJU09PIB2bbnvlKcZHc57i7OMFsjGnmG 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:(13230016)(4636009)(346002)(136003)(39860400002)(396003)(376002)(46966006)(36840700001)(40470700004)(34020700004)(356005)(40480700001)(36860700001)(7696005)(81166007)(86362001)(82740400003)(54906003)(2906002)(82310400005)(6666004)(6916009)(316002)(36756003)(426003)(44832011)(47076005)(41300700001)(83380400001)(40460700003)(70206006)(26005)(70586007)(336012)(186003)(8936002)(5660300002)(4326008)(2616005)(478600001)(8676002)(1076003)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:44:19.5221 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d9786e-881b-421c-7763-08da61b11fc0 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: DM6NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5524 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Inject the NMI by setting V_NMI in the VMCB interrupt control. processor will clear V_NMI to acknowledge processing has started and will keep the V_NMI_MASK set until the processor is done with processing the NMI event. Signed-off-by: Santosh Shukla --- v2: - Added WARN_ON check for vnmi pending. - use `get_vnmi_vmcb` to get correct vmcb so to inject vnmi. arch/x86/kvm/svm/svm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 44c1f2317b45..c73a1809a7c7 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3375,12 +3375,20 @@ static void pre_svm_run(struct kvm_vcpu *vcpu) static void svm_inject_nmi(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); + struct vmcb *vmcb = NULL; + + ++vcpu->stat.nmi_injections; + if (is_vnmi_enabled(svm)) { + vmcb = get_vnmi_vmcb(svm); + WARN_ON(vmcb->control.int_ctl & V_NMI_PENDING); + vmcb->control.int_ctl |= V_NMI_PENDING; + return; + } svm->vmcb->control.event_inj = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_NMI; vcpu->arch.hflags |= HF_NMI_MASK; if (!sev_es_guest(vcpu->kvm)) svm_set_intercept(svm, INTERCEPT_IRET); - ++vcpu->stat.nmi_injections; } static void svm_inject_irq(struct kvm_vcpu *vcpu) From patchwork Sat Jul 9 13:42:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912202 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F317EC433EF for ; Sat, 9 Jul 2022 13:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbiGINox (ORCPT ); Sat, 9 Jul 2022 09:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiGINoo (ORCPT ); Sat, 9 Jul 2022 09:44:44 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB977DF41; Sat, 9 Jul 2022 06:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VY6RpXyNLZNSmsDcUnCBaabnNDfu0Mfist1rU5trmeXqLTPo2ARXZQ1N8Nul2Zb1fT3s0wwsutd9X8mdC4gnWT4hvevKY7Z9wPuDcNR9MNYFB/kHbIIzEYPW2SjeDikIVvoh57kAWq11D52u0xzyv/2dcpKzv2nZrmT7YJ/Ip9yK/mMAAlkeyvAgzhEPBlDnerr3lBWn/F4zJykFeZoGnA+dMWafhkP9G91chyxnUJz64jf1ftqKEAJ2kGHRq5kd8KcJWY+VOuo49EUXc8xY/m2KQ/iOPNKL7j47e3CPVUgwN0Jlz0+ZA/YEjHr8WLmPO9lnLKFQKgtuIMfYVJvrtg== 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=6FVVfUIJQB6fSxS9GmZDX9PHoER4w6yIl0IQ/fAiEB4=; b=n708eWLuM/9hb8THVxO1vqBJSmBUK2lwGQfW7PHQWBDgtgl+3ihibknGH2FWxTSIPmzNiZMUMcn9kJQIbBI3w44jhUjLFsdM9wvwwZOlkcDuRnLlUUGYqwc/9cNtk2DR/1Z9VLUsJIpK5LqZyF4WubaG+mO2gJeOOiZpP3w7CT87G/KOO1vIsHruEpWmcrU2TwW6mtlsM6wagIEwwMOStPWkBa9cUyAn0D9bdqfadYkmjLoUMDbVVd9XROBUejaitsCKmLht/ZQg4SutRSybfllXo+zbrNDltKPTPtO2VtUvFrKZSBzZzMT52BIAXRVxUAposz4eJGMCQZ/PISPEgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=6FVVfUIJQB6fSxS9GmZDX9PHoER4w6yIl0IQ/fAiEB4=; b=QdUhgS0Ds4Sr6xwlQ70NcbvU9WrCkzi5eN8uJAKyW7Wc4eIXGexShwbduF2WWlL338KEmFa2073/TSjyi3s4Edyz4kbqqK2p48K/UWrBGqL1tTy+R0B9Njz7rRp3MVGBpVFg6dp/wphchJBHfSMGV93keg08H1r9m3WzE8ztWYg= Received: from BN6PR16CA0038.namprd16.prod.outlook.com (2603:10b6:405:14::24) by IA1PR12MB6532.namprd12.prod.outlook.com (2603:10b6:208:3a3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Sat, 9 Jul 2022 13:44:38 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:405:14:cafe::16) by BN6PR16CA0038.outlook.office365.com (2603:10b6:405:14::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21 via Frontend Transport; Sat, 9 Jul 2022 13:44:38 +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 BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:44:38 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:44:33 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 6/7] KVM: nSVM: implement nested VNMI Date: Sat, 9 Jul 2022 19:12:29 +0530 Message-ID: <20220709134230.2397-7-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30b8246b-7372-418c-4d76-08da61b12ae6 X-MS-TrafficTypeDiagnostic: IA1PR12MB6532:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9+ZpsWpBgC8AdPmWouX0r4TDPMsXyV7lEWc4M7SZObSKdXzcIPrB8lEE9C76Sc5ulH7rJEYnaFBBX0X+lRtbaA0yITlkZIJkFC860CtQmlqzEg3hX8UTbrv80/DQbChxa4IyJ+rh5ejDd1ms3HF94jFbrURxTJVPfpwXrEkI6VwkR3b5PtheCFYZg+UxQc76nSXHuBj4Zyb9qc/DQwArNEMs5Xf1yExu0KC/P3CMR+68VNQE1KIgKsNWBItQ56b/dbgbE6Iv8YR2fyqfaaH2laRC30u5XGOcg7MJiieIxBFw8Yi8J7TRvlQ2ywJG4FB5BWhAnIaaRBugJfaL87d8fC3WVVg1qEtOtJOrBiOQld96kPKwbycxcAr1cRT+NwYBegmyNjfoq2CpfQxps+lCja+Hbk6s/OcBI2Z9h4eJXT7xmu+H99IbfKC80AM5ObsiHat4Nl3nxoiUXdsXt5gD42Qxk74Rq/of4eQfSU/JLEgRTDiEEvucu7PDOy2Y6RMHzSj65DrhXZA42TFlwFfOMIzeyzX/CHnf36vn15QZf6oFCLlD8cie5surR4y++j/ct/YKUfJyN1o5FvA/yohsORIF/WCburvAXsnWeftr3vaJNQTQcjru7Ne9Q3Mpp87HkOfjy2dUxTYNlYjiovuyLGfK2GreLUDqvZCoTnubb7Q3+DZ1uvB/+ia7vrVS3o+96PSTTZSuO1I9YLEn+MwCYRJDepAF47JCGHMk6EWMJN75qTb/3YERC1fy91rrq9v05Dpn6YYj1JNrhzUDpWht1NqovguYd+s6lWe9R0DP2h9FIHicXhord/CpcH8BpnfN9R6dnz6aFz4/uqBzvU3IVX2BO/wF6GczjwOZGIc3y1XMgnl6LoQCHt/75RIYEgV5 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:(13230016)(4636009)(39860400002)(136003)(396003)(376002)(346002)(36840700001)(40470700004)(46966006)(40460700003)(26005)(426003)(16526019)(36860700001)(40480700001)(8936002)(1076003)(2616005)(44832011)(47076005)(336012)(8676002)(7696005)(186003)(36756003)(6916009)(54906003)(316002)(4326008)(86362001)(356005)(2906002)(34020700004)(478600001)(41300700001)(81166007)(82310400005)(6666004)(70586007)(70206006)(83380400001)(82740400003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:44:38.2563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30b8246b-7372-418c-4d76-08da61b12ae6 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: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6532 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Currently nested_vmcb02_prepare_control func checks and programs bits (V_TPR,_INTR, _IRQ) in nested mode, To support nested VNMI, extending the check for VNMI bits if VNMI is enabled and on vmexit save V_NMI_MASK/PENDING state to vmcb12. Tested with the KVM-unit-test and Nested Guest scenario. Signed-off-by: Santosh Shukla --- v2: - Save the V_NMI_PENDING/MASK state in vmcb12 on vmexit. - Tested nested environment - L1 injecting vnmi to L2. - Tested vnmi in kvm-unit-test. arch/x86/kvm/svm/nested.c | 16 +++++++++++++++- arch/x86/kvm/svm/svm.c | 5 +++++ arch/x86/kvm/svm/svm.h | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index ba7cd26f438f..f97651f317a0 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -629,6 +629,9 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) else int_ctl_vmcb01_bits |= (V_GIF_MASK | V_GIF_ENABLE_MASK); + if (nested_vnmi_enabled(svm)) + int_ctl_vmcb12_bits |= (V_NMI_PENDING | V_NMI_ENABLE); + /* Copied from vmcb01. msrpm_base can be overwritten later. */ vmcb02->control.nested_ctl = vmcb01->control.nested_ctl; vmcb02->control.iopm_base_pa = vmcb01->control.iopm_base_pa; @@ -951,10 +954,21 @@ int nested_svm_vmexit(struct vcpu_svm *svm) vmcb12->control.event_inj = svm->nested.ctl.event_inj; vmcb12->control.event_inj_err = svm->nested.ctl.event_inj_err; + if (nested_vnmi_enabled(svm)) { + if (vmcb02->control.int_ctl & V_NMI_MASK) + vmcb12->control.int_ctl |= V_NMI_MASK; + else + vmcb12->control.int_ctl &= ~V_NMI_MASK; + + if (vmcb02->control.int_ctl & V_NMI_PENDING) + vmcb12->control.int_ctl |= V_NMI_PENDING; + else + vmcb12->control.int_ctl &= ~V_NMI_PENDING; + } + if (!kvm_pause_in_guest(vcpu->kvm)) { vmcb01->control.pause_filter_count = vmcb02->control.pause_filter_count; vmcb_mark_dirty(vmcb01, VMCB_INTERCEPTS); - } nested_svm_copy_common_state(svm->nested.vmcb02.ptr, svm->vmcb01.ptr); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c73a1809a7c7..d81ad913542d 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4069,6 +4069,8 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) svm->vgif_enabled = vgif && guest_cpuid_has(vcpu, X86_FEATURE_VGIF); + svm->vnmi_enabled = vnmi && guest_cpuid_has(vcpu, X86_FEATURE_V_NMI); + svm_recalc_instruction_intercepts(vcpu, svm); /* For sev guests, the memory encryption bit is not reserved in CR3. */ @@ -4827,6 +4829,9 @@ static __init void svm_set_cpu_caps(void) if (vgif) kvm_cpu_cap_set(X86_FEATURE_VGIF); + if (vnmi) + kvm_cpu_cap_set(X86_FEATURE_V_NMI); + /* Nested VM can receive #VMEXIT instead of triggering #GP */ kvm_cpu_cap_set(X86_FEATURE_SVME_ADDR_CHK); } diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index f36e30df6202..0094ca2698fa 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -241,6 +241,7 @@ struct vcpu_svm { bool pause_filter_enabled : 1; bool pause_threshold_enabled : 1; bool vgif_enabled : 1; + bool vnmi_enabled : 1; u32 ldr_reg; u32 dfr_reg; @@ -510,6 +511,11 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm) return svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE; } +static inline bool nested_vnmi_enabled(struct vcpu_svm *svm) +{ + return svm->vnmi_enabled && (svm->nested.ctl.int_ctl & V_NMI_ENABLE); +} + static inline struct vmcb *get_vnmi_vmcb(struct vcpu_svm *svm) { if (!vnmi) From patchwork Sat Jul 9 13:42:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shukla, Santosh" X-Patchwork-Id: 12912203 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA435C43334 for ; Sat, 9 Jul 2022 13:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiGINpD (ORCPT ); Sat, 9 Jul 2022 09:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbiGINo7 (ORCPT ); Sat, 9 Jul 2022 09:44:59 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2042.outbound.protection.outlook.com [40.107.93.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A54EB1; Sat, 9 Jul 2022 06:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LGReujOR4lJx0Jtay6STlHIQeSn4fiwTeVUPwwftSNP1ioSsThfm0aNxgHOzM+3cB6hHznz9+LvJEtET/1uxZnztQEQRZsH2dH35Y4bn5nrrad40GTh7LIB2LpFKmggWACMl/01Z5yuxGXJac2YmtOj3qCB14HU0ZuUvdK3rkUgj7sQqBnWBjfgS395TUcpA1URIedAfDmKMldl6kYVBYsLdeAxCXPx6jaqBe8/jilVFzLthDm1gkkt/jkC7kaXw/yXddX0okfsW19GyazPpXYN/66zDChwVX6/QbGi6+r6UioYdPGlQldN+1SxOLI1HcN1ZyhEsos5qnilkUtoxVQ== 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=TxTTgQsSUO34lolM077g7Ih15YWqfRj7bZ7El5eKOI0=; b=K1w+wi9W9aaYjy8NDHs/O5pAoGa2qBDBzv4LcVgmXa2VHfsovPCcFo0gct/4/WD7cF2tTJUoZ/Jxg9cyLF/5TU9+Mj7zywvd9TabyMxd+yFXr7LuFA1FTayZW3KCfL4ylVa2P1wt6VV/jfNq7P4POPpY8fOnimGQ4AMuDnXOTba5MgLE4KsEoD4615oAk5uSdjkX6Mjm+hnu1a7SKRVP0+3kfqhs6wgJ9dxPzrW7doPFQI5kZLD+5yPeJihckvx0jT/tU4saq56PG5d5oNm+RlI5nK6XNBlshrgC4kbx1zsYiOhnZChYWIxpUJGevw7pWSjbwu+MYWs85QDykk5mcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=TxTTgQsSUO34lolM077g7Ih15YWqfRj7bZ7El5eKOI0=; b=uFVEcx6cVGDMQrAKinw6lstkCMU1UD7Tkzyz5rG04eQGyLCQdZG3qXJr1mbFp15njK66w6ifG/td/BiZlnrTxdZmdkAt7rms3J50UQhJVn66tbe7hJgBu4fSveV783+XRH3Xhrbkuhstj86dE7H7sP30vO+7sSAJtmII07g0Zxk= Received: from BN6PR2001CA0002.namprd20.prod.outlook.com (2603:10b6:404:b4::12) by BN6PR12MB1603.namprd12.prod.outlook.com (2603:10b6:405:b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Sat, 9 Jul 2022 13:44:56 +0000 Received: from BN8NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::18) by BN6PR2001CA0002.outlook.office365.com (2603:10b6:404:b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25 via Frontend Transport; Sat, 9 Jul 2022 13:44:56 +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 BN8NAM11FT017.mail.protection.outlook.com (10.13.177.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Sat, 9 Jul 2022 13:44:56 +0000 Received: from BLR-5CG113396M.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.28; Sat, 9 Jul 2022 08:44:52 -0500 From: Santosh Shukla To: Paolo Bonzini CC: Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , Maxim Levitsky , Tom Lendacky , , , Subject: [PATCHv2 7/7] KVM: SVM: Enable VNMI feature Date: Sat, 9 Jul 2022 19:12:30 +0530 Message-ID: <20220709134230.2397-8-santosh.shukla@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220709134230.2397-1-santosh.shukla@amd.com> References: <20220709134230.2397-1-santosh.shukla@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76cec911-0b31-4e05-d996-08da61b135b7 X-MS-TrafficTypeDiagnostic: BN6PR12MB1603:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QXp38N2uw/Z1eGtdaIKlCsxcafX/Y/TKuKXezHjhVBuuMaB6heVuRsxRTHlKtGx0FHU4Ed/HlSUpF+pVuSEoRufS85HBwcxPezjddhFMlQ22OwHqKMWoEv5oOCBYjg7W6PsKtw3qhtobGGwKVM5FK3jzcUaEHK5qmEN9c3tH7uMddIYVQurfuexkfe3o33zmN5QQ+JFl6GPFqrIM56ejK8KcpWfHYzkHfijnaDuLjPcV43JtUFijraMkoRg9j7eC7IzJIUXyqIXpDwa+uffWS2uRC+QUniHKPmJrn5tiiiTLhyGAy3KEfqe+e/p8F9y8Mz4xNcQzjfIZFgkrRBHuqSKUAsxVPF40hI2gw01FkciCk1Xi/dymVjqa7f6PFWKxrSgysm9R382KNIiWgG9s7ak5Q+uXLl2WOoIG1TRRx1JVBw+Dijz93Nwy3Gbddg23JFjp6MqKoTesMgWxP6VUqfhAdcT5lTDozgPKHqzMoOIRw7noarXInQ/NUlh5LBKQf+x196wlYzjdKKp3D1KjzKm2E8f8sz+tZanQxXRS9ZlKKFMF3Tln88RL2h8mLcUnLQHXFBxhQaUm+IJwtGnvzj5w7WZgca0+8eqQ7hA5Gh7OYZEh1zr9wTzIUnbdqTMK0wc2/hrWnMsLCeMEAeFTQOAushIttrQfZZ2Y1avdl0ZI9Hyq1/YvhblHCtE0Z2LYPgT7HdvUPvpyHjuLXpD25qRs5MmSKgP2LH7Ux2IpWXlGqyRTc21g2ckDwgWMCUomLPbItGy66bzr+i5Qng0D+nZ4ToJXgaewWOTpASNmQgmUwgEqWFb37cqAuyuQWnYmKEHnMDPEpVHoxZqNbkU3qsqgZexJ2igtydKvD2y/nKBkpS0B1/liSjaPRH1RbfLN 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:(13230016)(4636009)(396003)(346002)(136003)(376002)(39860400002)(46966006)(36840700001)(40470700004)(186003)(16526019)(2616005)(336012)(47076005)(86362001)(1076003)(40480700001)(356005)(34020700004)(40460700003)(36860700001)(426003)(82740400003)(70586007)(70206006)(36756003)(8676002)(8936002)(41300700001)(2906002)(44832011)(4326008)(54906003)(316002)(478600001)(6916009)(7696005)(82310400005)(81166007)(6666004)(5660300002)(26005)(4744005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2022 13:44:56.4068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76cec911-0b31-4e05-d996-08da61b135b7 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: BN8NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1603 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Enable the NMI virtualization (V_NMI_ENABLE) in the VMCB interrupt control when the vnmi module parameter is set. Signed-off-by: Santosh Shukla --- arch/x86/kvm/svm/svm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d81ad913542d..536aa392252b 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1208,6 +1208,9 @@ static void init_vmcb(struct kvm_vcpu *vcpu) if (kvm_vcpu_apicv_active(vcpu)) avic_init_vmcb(svm, vmcb); + if (vnmi) + svm->vmcb->control.int_ctl |= V_NMI_ENABLE; + if (vgif) { svm_clr_intercept(svm, INTERCEPT_STGI); svm_clr_intercept(svm, INTERCEPT_CLGI);