Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp933985rwb; Thu, 1 Dec 2022 10:06:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5X3/6vEdEAsSKTjdP6Oic3amNHn2j3AkkpIZN8ubaE/IosEcBrfweRcoR79aCrqAR1i+Ax X-Received: by 2002:a17:906:298c:b0:7c0:7d08:bfc with SMTP id x12-20020a170906298c00b007c07d080bfcmr15479960eje.72.1669918005709; Thu, 01 Dec 2022 10:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669918005; cv=none; d=google.com; s=arc-20160816; b=rOx8YGackAlH0J6GCN926+H4pkiUj2SacyUzUyE2EvkqCa4YO/0jY5OOsy+cvwUeEl 1n1nKdwfBvdmY7L/15pDRLmDQbfSOnkjA1BvUodNJ4jY4QJfGJ1PO5qaT9fXE/qnCada /Ek8DJEvuKSecupTwJ6xrK5zN4ZUkMIz6U/ryfIqzgGwNgX15WkXVyu8IzckD1CC+zEY mBHnxgPlze9uzPb0o1QX90DoVlkdX3VRfOhc6+Ex20uYm1zlnVby7+e+xIYRjvP14r8m ZWoijIYLPbuByUPYhB/voV2A0ou5FjrYjT00ODFiNbDK7VbueEqNWw3wj1dPAM8RhCi4 y4WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RiLEICTVmXLErxo4PMC+ee81eNOjxAzNcaRYbtLAGkw=; b=dBG/uJpoNSAULKjj9PV0N13bMNlUszVK0iXxvgjs5uaCBGOtsAi+sbNz4FE7OEQXsc Cw8Sv4Uhiq9ZzzThySKWJKOKfX98wj1VFB5wBaSNt4aEf+/MyP6+aJCPN7WPZ8f/jPVN N+UzOBoSgL5ii7Zm2ZDQh3BCWfW6Lh1/735g/LUa78e6UV7Ecz7IuLEEdJv+Cj8G19na Rs/S4hCiE7iqplDNbxD2dqBtNYRQvO3YF8VnvZxSN5y5r3VeQ3VEDJPPAKMSbDA9hGeD +QUbtcSACocTlH46N5xwmLFxscHubXSFaOV+lFGRkaIW7CgXzW0WtfWko4gYXuT2Dfa8 BrrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=XDQotCQu; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056402278b00b0046a6f32bbdbsi4589897ede.283.2022.12.01.10.06.24; Thu, 01 Dec 2022 10:06:45 -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=@google.com header.s=20210112 header.b=XDQotCQu; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbiLARim (ORCPT + 83 others); Thu, 1 Dec 2022 12:38:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbiLARik (ORCPT ); Thu, 1 Dec 2022 12:38:40 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 878D2A8095 for ; Thu, 1 Dec 2022 09:38:39 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id 140so2537871pfz.6 for ; Thu, 01 Dec 2022 09:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RiLEICTVmXLErxo4PMC+ee81eNOjxAzNcaRYbtLAGkw=; b=XDQotCQuLafW/S8wy/HVAsoUm9o/ZHjw3XKrM+Bqn5p5E67C/pz0UVI2LUOjt79/Pg tEe+YhcNxbi3j1P5F7sWiW+QPKAAZ3ATZC9bo/FxHxhacBlxgvCYVKgZM276E1vaGIJJ CiulalEN80ekH6KOte6HvU8X4S+bG10r3XmShP3NEo6dxxa1nQdmBEGIzBAaNts/n0Wo KNImaF2i7wSjF5NEEa2c0wtWAgqfRP/FJHgMr9NxLMOIq9NVOYKsofvjQL3mwknLNPI+ W53U9m5uPYCHS1C5z+T6nlHZGfXzWaNyH0l4+Wx4nAD6wyHfuDXJJbB+IWolwI+oOtsq pf2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RiLEICTVmXLErxo4PMC+ee81eNOjxAzNcaRYbtLAGkw=; b=b7RYwClI60q1piko8qQFhoKVTZB4IKXjd1UtOyxDPawRNURtv1+7lQkxl5uPCdm2f5 yE03qfoCkF1JC05mStWwAlmVtvGkXd/X7BXrBhhpoKk1txUKZf/jiuyvZJnKzwEqfEbY B5cS4ZzT9boe3RbwqNBNtF6ewLdPAYR+XEfgbTCu0h6p/uHdWBnm4jN5E+GqW7Qfn4KF i+XPF2bQzK4ZR4XkqxMIMd3vsK609IDFqJ099hCjCxfyJ8mcqoDwFSlhC5Axt73Bizyr tURbj7u9TDC92bhvkzvc+3jXka2zVMpdhhGy6zLwPkoz4yrlKJo4ODlCSEcDaahEjMMD J6TA== X-Gm-Message-State: ANoB5pmi1tB3wIRwUtUW7XtFITou6fiiVZVYMfUD/Fh3z6gtPdRDwk7L /nLsfVYEsMCUlNxAJ+N9zxh3L1pdBOUDcA== X-Received: by 2002:a62:e80f:0:b0:574:cc3d:a23f with SMTP id c15-20020a62e80f000000b00574cc3da23fmr31204117pfi.53.1669916317425; Thu, 01 Dec 2022 09:38:37 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id f2-20020a170902ff0200b0018975488514sm3897571plj.126.2022.12.01.09.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 09:38:37 -0800 (PST) Date: Thu, 1 Dec 2022 17:38:33 +0000 From: Sean Christopherson To: Alexey Kardashevskiy Cc: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Venu Busireddy , Tony Luck , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Michael Sterritt , Michael Roth , Mario Limonciello , Ingo Molnar , Heiko Carstens , Greg Kroah-Hartman , Dave Hansen , Borislav Petkov , Andrew Cooper , "Jason A. Donenfeld" , "H. Peter Anvin" Subject: Re: [PATCH kernel 3/3] x86/sev: Do not handle #VC for DR7 read/write Message-ID: References: <20221201021948.9259-1-aik@amd.com> <20221201021948.9259-4-aik@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221201021948.9259-4-aik@amd.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 01, 2022, Alexey Kardashevskiy wrote: > With SVM_SEV_FEAT_DEBUG_SWAP enabled, the VM should not get #VC events > for DR7 read/write which it rather avoided. > > Signed-off-by: Alexey Kardashevskiy > --- > arch/x86/kernel/sev.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c > index a428c62330d3..4e91b9f8742c 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 >> 2) & SVM_SEV_FEAT_DEBUG_SWAP) Probably high time to add a helper/macro to convert the SEV_STATUS to the SEV_FEATURES field. > + 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 >> 2) & SVM_SEV_FEAT_DEBUG_SWAP) > + return ES_VMM_ERROR; > + > if (!reg) > return ES_DECODE_FAILED; > > -- > 2.38.1 >