Message ID | 20230120031047.628097-4-aik@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp674429wrn; Thu, 19 Jan 2023 19:15:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPWXuX7fe2UqCH/5OIh0eCNRMrprDXpC29SPJ1yBfX4A0CC9hKD98nZxwRBMdrK/r/yS9E X-Received: by 2002:a17:90a:530d:b0:229:f295:cae0 with SMTP id x13-20020a17090a530d00b00229f295cae0mr3589516pjh.31.1674184546583; Thu, 19 Jan 2023 19:15:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674184546; cv=pass; d=google.com; s=arc-20160816; b=gEUnNITjU3Vo0e3oMM0F+ak9xtsC6TIwsM/wNeEwHBldOo1g6Cv4c9xQgC+NyrDuV/ OIa6XrVLXe86lrvGPoWkXt2E237Qj2bwAbmGPnuq3y6k7b9feh0zQ9LiTzjDWKBjAWAB LjPEFcBsKDWhpI+omqPu4crwOdkIEi8eS89uUGiIvxqWZ41P8UmGOvxMVGjJhCuKLGgp As0IlNxd3fDw5GbNeUOfzYOD3bXhz6KaDlH2wyKvZmEJcW9cvNh46kMYgWugJ9s85ITN ek/AW0glBSXL057g525lwb0EdUCnpE3DlEMjQzoGQnuIBHI7uAH5nwWbue8oNlaJ/sEG yowg== 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=r55GGCszmmGL2c3WK5rvEb3vBVGxF2/mrici6yBv4V4=; b=hxABfvj0J8ZKzWaBTvIa4q6H/FcyG73AapfRqysIbUSmT3CSFELLHHixaKTa4cHv6p SEbbRqFYDPyv2Ju28U451aPNUCLopW25dQTbq2AJc+J+jzWZ7GdaLMc6J7cXi4aOIzYD 5XeweOmSTJrzSXfgBdSr7LDZtK2D4WmduTr/EOLhPM7gutJzkXmzVkhLcDkCLE+FpaP7 NwWHRaiwuKCk0uvvARJpAj2PRYmtCqYi5p1TFbK54NFb63ruVpOz65d4gzC17t61OUv3 rWiDYRpVbBwromSpFtU4E5vZiuSqnUsvfFsddbyTTDoAVcaiek1I22Lm6oQqrMT5WDBb 5Y+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=34AQ5sE3; 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 e189-20020a6369c6000000b004771126e2f7si40097786pgc.142.2023.01.19.19.15.32; Thu, 19 Jan 2023 19:15:46 -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=34AQ5sE3; 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 S229693AbjATDNa (ORCPT <rfc822;pavtiger@gmail.com> + 99 others); Thu, 19 Jan 2023 22:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjATDN0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Jan 2023 22:13:26 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF558AEDA2; Thu, 19 Jan 2023 19:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YPQL3Ug7Z5R7pj76EMFPQOXfs2qZyZRUwVBtMWZod2hQr6vlSyGu1/qsWGbBzU+l3KAMxdkWYz5/qfq1uVPy1aTL2zuvtLwAhk6UyM18yNjyMcj0pgGo+RteMM7CxJqpj3Wmiv6vk1LF3Q0CdUTOFqyFaNI+A13IHMpyRP27aCHl1k83VKzGN8ZHyTDhpbTIunEZBQ+R58ajlqJfCj5E1Up5Plt4i3i5odYVnHUxcKfBebMAH4luOzBwc4cLOOsc/0sxtKChV0Ytpb84TSvJnJNq6PqdUyAH+B2XVP2KR9gaTPeGU4hNAxWPLI4BF2qU9q7nEyqGay915wwBW5TZPg== 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=r55GGCszmmGL2c3WK5rvEb3vBVGxF2/mrici6yBv4V4=; b=dKuTlnZ+m6yYOZJKPdl2YKQNmDzxTJD/94T5BT6MejiKsjWZFxxstiO0YqOzSO8aOE0JI6zUvAXi8mCpA04epsGiLocb5pvJwe9YyHfE7sWkSf8VPdQKx9RsSdH1PQkZdkLgqsVHHSjz7wJWg2Dr5dmLyQTlAaY/QsqTMeavVx9oWRs3hEssq72ALgJX/R1u42YTA6IkGDJjafrDcCD23V7O0FqWyXNGcBfVYMHtkDkWNnFKXWEElMYJhiSdRAvUN1UD3/BSTp/vSoqmKLh9vCwjGLaSctYhWCYjQZ6L+JDfibJzFn4yv80ru0oI5r5m3T2KfogVMgGUFWUAQ/Tb5w== 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=r55GGCszmmGL2c3WK5rvEb3vBVGxF2/mrici6yBv4V4=; b=34AQ5sE3mVfzt07tCR9ff+mpGz3hqL9u+/BJGmD4n2CrKzqkKcGaBcNIs6En60KvtwqF3y4VO3+AW1QZ5gf8k8QMY8IdveG9XeC9TSJWjsbGNHGfAlhfZZPE8Rl+Z2TdBB/1pINAwwXOio0+NekFFOIuq7X88OdyjxkXpeahJfM= Received: from DS7PR03CA0303.namprd03.prod.outlook.com (2603:10b6:8:2b::19) by DM4PR12MB7622.namprd12.prod.outlook.com (2603:10b6:8:109::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Fri, 20 Jan 2023 03:13:20 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::9d) by DS7PR03CA0303.outlook.office365.com (2603:10b6:8:2b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25 via Frontend Transport; Fri, 20 Jan 2023 03:13:20 +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 DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Fri, 20 Jan 2023 03:13:20 +0000 Received: from aiemdeew.1.ozlabs.ru (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; Thu, 19 Jan 2023 21:13:07 -0600 From: Alexey Kardashevskiy <aik@amd.com> To: Alexey Kardashevskiy <aik@amd.com> CC: <kvm@vger.kernel.org>, <x86@kernel.org>, <linux-kernel@vger.kernel.org>, Yury Norov <yury.norov@gmail.com>, Venu Busireddy <venu.busireddy@oracle.com>, Tony Luck <tony.luck@intel.com>, Tom Lendacky <thomas.lendacky@amd.com>, Thomas Gleixner <tglx@linutronix.de>, "Sean Christopherson" <seanjc@google.com>, Sandipan Das <sandipan.das@amd.com>, Pawan Gupta <pawan.kumar.gupta@linux.intel.com>, Paolo Bonzini <pbonzini@redhat.com>, Michael Roth <michael.roth@amd.com>, Mario Limonciello <mario.limonciello@amd.com>, Kim Phillips <kim.phillips@amd.com>, Kees Cook <keescook@chromium.org>, Juergen Gross <jgross@suse.com>, Jakub Kicinski <kuba@kernel.org>, Ingo Molnar <mingo@redhat.com>, Dave Hansen <dave.hansen@linux.intel.com>, Daniel Sneddon <daniel.sneddon@linux.intel.com>, Brijesh Singh <brijesh.singh@amd.com>, Borislav Petkov <bp@alien8.de>, Arnaldo Carvalho de Melo <acme@redhat.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Adrian Hunter <adrian.hunter@intel.com>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, "Jason A. Donenfeld" <Jason@zx2c4.com>, "H. Peter Anvin" <hpa@zytor.com> Subject: [PATCH kernel v3 3/3] x86/sev: Do not handle #VC for DR7 read/write Date: Fri, 20 Jan 2023 14:10:47 +1100 Message-ID: <20230120031047.628097-4-aik@amd.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230120031047.628097-1-aik@amd.com> References: <20230120031047.628097-1-aik@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: DM6NAM11FT035:EE_|DM4PR12MB7622:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d553487-8014-4529-f8c2-08dafa944890 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R3JO53eyfBJpXDk7B8dWVFm02xOS6WpdG8jCcw9o+t7UZtdYNnTRQcqi/VusWuL4tpS8pG0BWsIvZeVIaHYo4ZI2k4CSSA8YOZJ3gUnFdyWvWCPTs7SC3UlVFMTw9TBhnWTPwLT1zcSZtarYyOozT9XsRd/lk077kAvK/BgBKE8hK6iarPQdc9TUjCqqzzB7nD6LIyBXk/Hl5p8VFnGdyHVjPMAfuxu8Wiy1hYUG4+4VZ+fgE2LG7U2o2hV2aOY0Ddsoh/KKwGxOMZ8lfoqLkIAx02HpJrnVwdFH0Dm7ComEoIplHCZdsRnhBQepFZYVrAnucbsQRRi6s6aHrU3o9HWOGgffAmUPP8BJcJ/4C45WzQDlu8c0ghiq2rwzRCo8ZU0hlUD9D8ploR54YXw0yzmmIdfBIeTCi+jekPpBh7DbND565jknAq0uMiYqmhml/FIDsn/GqRazrAU/VZOhe4o2bBPs6MQPolP5VcoBdM/IVLKs3Hptlvsr+O9UxmY1nNDItSlf7/3s7+7PF1QHOWct7rSwIbgcaqAy3gJZSMp8OI04VEk2xDLMX7LcRoAOSper30/naHknMFKZowsrFNaGZyMsqPzd7qNCEutsYlQHGfpD3HIg05wAhNh/wZ8JgNBTiDHxEMoUxQ8HEZDhTlFV9KVB719PrpCwPis6PTME8lzGg+NGcnyfSr9M7qP96bXh4zNSh7EV4xpVNLlJ68B6yNYGnUosMD1NXDJIa9s= 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:(13230022)(4636009)(39860400002)(346002)(396003)(376002)(136003)(451199015)(40470700004)(36840700001)(46966006)(82740400003)(81166007)(36860700001)(7049001)(5660300002)(356005)(2906002)(8676002)(4326008)(7416002)(6862004)(8936002)(70586007)(70206006)(426003)(40480700001)(2616005)(6200100001)(82310400005)(478600001)(47076005)(16526019)(186003)(26005)(336012)(1076003)(316002)(54906003)(41300700001)(40460700003)(6666004)(37006003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2023 03:13:20.5129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d553487-8014-4529-f8c2-08dafa944890 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: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7622 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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?1755509735069106545?= X-GMAIL-MSGID: =?utf-8?q?1755509735069106545?= |
Series |
KVM: SEV: Enable AMD SEV-ES DebugSwap
|
|
Commit Message
Alexey Kardashevskiy
Jan. 20, 2023, 3:10 a.m. UTC
With MSR_AMD64_SEV_DEBUG_SWAP enabled, the VM should not get #VC events for DR7 read/write which it rather avoided. Signed-off-by: Alexey Kardashevskiy <aik@amd.com> Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de> --- Changes: v2: * use new bit definition --- arch/x86/include/asm/msr-index.h | 1 + tools/arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/sev.c | 6 ++++++ 3 files changed, 8 insertions(+)
Comments
On 20/01/23 08:40, Alexey Kardashevskiy wrote: > With MSR_AMD64_SEV_DEBUG_SWAP enabled, the VM should not get #VC > events for DR7 read/write which it rather avoided. > SNP guest feature negotiation patch is part of tip now: https://lore.kernel.org/lkml/167414649850.4906.1693185384677559889.tip-bot2@tip-bot2/ MSR_AMD64_SNP_DEBUG_SWAP is already defined. As this requires guest side changes, please add MSR_AMD64_SNP_DEBUG_SWAP as part of SNP_FEATURES_PRESENT bit mask. Regards Nikunj
On 20/1/23 16:12, Nikunj A. Dadhania wrote: > On 20/01/23 08:40, Alexey Kardashevskiy wrote: >> With MSR_AMD64_SEV_DEBUG_SWAP enabled, the VM should not get #VC >> events for DR7 read/write which it rather avoided. >> > > SNP guest feature negotiation patch is part of tip now: https://lore.kernel.org/lkml/167414649850.4906.1693185384677559889.tip-bot2@tip-bot2/ Worth mentioning it is tip/x86/urgent (which does not have X86_FEATURE_NO_NESTED_DATA_BP), not tip/master (which has X86_FEATURE_NO_NESTED_DATA_BP). > > MSR_AMD64_SNP_DEBUG_SWAP is already defined. As this requires guest side changes, please add MSR_AMD64_SNP_DEBUG_SWAP as part of SNP_FEATURES_PRESENT bit mask. It is MSR_AMD64_SEV_DEBUG_SWAP (SEV, not SNP), it is an SEV-ES thing. Why is that feature negotiation SNP-only and not SEV?
On Fri, Jan 20, 2023 at 09:23:48PM +1100, Alexey Kardashevskiy wrote: > Worth mentioning it is tip/x86/urgent (which does not have > X86_FEATURE_NO_NESTED_DATA_BP), not tip/master (which has > X86_FEATURE_NO_NESTED_DATA_BP). Yeah, when you submit patches for tip, you can always use tip/master which has the latest lineup of all branches and should have all the required bits. Thx.
On 20/01/23 15:53, Alexey Kardashevskiy wrote: > It is MSR_AMD64_SEV_DEBUG_SWAP (SEV, not SNP), it is an SEV-ES thing. Yes, noticed that, earlier analysis was that Debug Swap shouldn't need any guest side changes, but it does need it. > Why is that feature negotiation SNP-only and not SEV? As per the spec, GHCB termination request: reason code: 0x2 is SNP features specific. Regards Nikunj
On 24/1/23 21:37, Nikunj A. Dadhania wrote:>> It is MSR_AMD64_SEV_DEBUG_SWAP (SEV, not SNP), it is an SEV-ES thing.> Yes, noticed that, earlier analysis was that Debug Swap shouldn't need any guest side changes, but it does need it.>>> Why is that feature negotiation SNP-only and not SEV?> > As per the spec, GHCB termination request: reason code: 0x2 is SNP features specific. Does the guest really need to terminate in such case? A VM could just not do the GHCB thing if it does not want to.
On 24/01/23 18:07, Alexey Kardashevskiy wrote: > > > On 24/1/23 21:37, Nikunj A. Dadhania wrote: >> It is MSR_AMD64_SEV_DEBUG_SWAP (SEV, not SNP), it is an SEV-ES thing. > Yes, noticed that, earlier analysis was that Debug Swap shouldn't need any guest side changes, but it does need it. >>> Why is that feature negotiation SNP-only and not SEV? >> As per the spec, GHCB termination request: reason code: 0x2 is SNP features specific. > Does the guest really need to terminate in such case? The termination is from the guest that do not have implementation for the hypervisor enabled feature, in this case DebugSwap. If DebugSwap is enabled by the hypervisor and not handled in guest #VC, then DR7 read/write can be intercepted by the malicious hypervisor, which can return unexpected values. > A VM could just not do the GHCB thing if it does not want to. In that case, the VM can have unexpected failures. Regards Nikunj
On 20/1/23 23:06, Borislav Petkov wrote: > On Fri, Jan 20, 2023 at 09:23:48PM +1100, Alexey Kardashevskiy wrote: >> Worth mentioning it is tip/x86/urgent (which does not have >> X86_FEATURE_NO_NESTED_DATA_BP), not tip/master (which has >> X86_FEATURE_NO_NESTED_DATA_BP). > > Yeah, when you submit patches for tip, you can always use tip/master which has > the latest lineup of all branches and should have all the required bits. The tip/master's head just a few days ago was 195df42eb64dcb "Merge branch into tip/master: 'x86/platform'" and did have dcf67f724b8ada "x86/cpu, kvm: Add the NO_NESTED_DATA_BP feature" but now tip/master does not have it - 8272720be044 "Merge x86/cache into tip/master". /me confused. What tree is the tree? > > Thx. >
On Wed, Jan 25, 2023 at 02:11:27PM +1100, Alexey Kardashevskiy wrote: > The tip/master's head just a few days ago was 195df42eb64dcb "Merge branch > into tip/master: 'x86/platform'" and did have dcf67f724b8ada "x86/cpu, kvm: > Add the NO_NESTED_DATA_BP feature" but now tip/master does not have it - Yeah, it had to be backed out. A new version will be queued soon. > 8272720be044 "Merge x86/cache into tip/master". /me confused. What tree is > the tree? It still is *the* tree - just there were some issues with the KVM side of Kim's series so it had to be dropped but he sent a new version which I need to queue soon. Then I'll have a look at yours. Thx.
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index cb3d0f6e6ac2..e15afe3500ff 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -574,6 +574,7 @@ #define MSR_AMD64_SEV_ENABLED BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT) #define MSR_AMD64_SEV_ES_ENABLED BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT) #define MSR_AMD64_SEV_SNP_ENABLED BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT) +#define MSR_AMD64_SEV_DEBUG_SWAP BIT_ULL(7) #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f diff --git a/tools/arch/x86/include/asm/msr-index.h b/tools/arch/x86/include/asm/msr-index.h index 37ff47552bcb..27c1c349e49b 100644 --- a/tools/arch/x86/include/asm/msr-index.h +++ b/tools/arch/x86/include/asm/msr-index.h @@ -565,6 +565,7 @@ #define MSR_AMD64_SEV_ENABLED BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT) #define MSR_AMD64_SEV_ES_ENABLED BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT) #define MSR_AMD64_SEV_SNP_ENABLED BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT) +#define MSR_AMD64_SEV_DEBUG_SWAP BIT_ULL(7) #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c index 679026a640ef..8184f8ba4edc 100644 --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -1618,6 +1618,9 @@ static enum es_result vc_handle_dr7_write(struct ghcb *ghcb, long val, *reg = vc_insn_get_rm(ctxt); enum es_result ret; + if (sev_status & MSR_AMD64_SEV_DEBUG_SWAP) + return ES_VMM_ERROR; + if (!reg) return ES_DECODE_FAILED; @@ -1655,6 +1658,9 @@ static enum es_result vc_handle_dr7_read(struct ghcb *ghcb, struct sev_es_runtime_data *data = this_cpu_read(runtime_data); long *reg = vc_insn_get_rm(ctxt); + if (sev_status & MSR_AMD64_SEV_DEBUG_SWAP) + return ES_VMM_ERROR; + if (!reg) return ES_DECODE_FAILED;