From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B24DEC43461 for ; Mon, 14 Sep 2020 22:00:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77F43206F4 for ; Mon, 14 Sep 2020 22:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgINWA5 (ORCPT ); Mon, 14 Sep 2020 18:00:57 -0400 Received: from mga06.intel.com ([134.134.136.31]:58509 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgINWAz (ORCPT ); Mon, 14 Sep 2020 18:00:55 -0400 IronPort-SDR: 4pd/+N26yteZUk+NtgfB9AdjUfp13Qcjr2staSZqFGG3SBSrfTcEefIqoOgr+Hn/5t8iIaJKs5 aZkUxffv7VBA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="220722842" X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="220722842" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 15:00:54 -0700 IronPort-SDR: OAgPPJjpbuWZNBiA0wgpAdDIOIlAb5wp4CY5BsSZ5p8M48RTIc+ApgUIh8dSD8fBSEjlFEApl1 5yXtzLAqfcpA== X-IronPort-AV: E=Sophos;i="5.76,427,1592895600"; d="scan'208";a="482511319" Received: from sjchrist-ice.jf.intel.com (HELO sjchrist-ice) ([10.54.31.34]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 15:00:54 -0700 Date: Mon, 14 Sep 2020 15:00:52 -0700 From: Sean Christopherson To: Tom Lendacky Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Jim Mattson , Joerg Roedel , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: Re: [RFC PATCH 20/35] KVM: SVM: Add SEV/SEV-ES support for intercepting INVD Message-ID: <20200914220052.GH7192@sjchrist-ice> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 03:15:34PM -0500, Tom Lendacky wrote: > From: Tom Lendacky > > The INVD instruction intercept performs emulation. Emulation can't be done > on an SEV or SEV-ES guest because the guest memory is encrypted. > > Provide a specific intercept routine for the INVD intercept. Within this > intercept routine, skip the instruction for an SEV or SEV-ES guest since > it is emulated as a NOP anyway. > > Signed-off-by: Tom Lendacky > --- > arch/x86/kvm/svm/svm.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index 37c98e85aa62..ac64a5b128b2 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -2275,6 +2275,17 @@ static int iret_interception(struct vcpu_svm *svm) > return 1; > } > > +static int invd_interception(struct vcpu_svm *svm) > +{ > + /* > + * Can't do emulation on any type of SEV guest and INVD is emulated > + * as a NOP, so just skip it. > + */ > + return (sev_guest(svm->vcpu.kvm)) Should this be a standalone/backported fix for SEV? > + ? kvm_skip_emulated_instruction(&svm->vcpu) > + : kvm_emulate_instruction(&svm->vcpu, 0); > +} > + > static int invlpg_interception(struct vcpu_svm *svm) > { > if (!static_cpu_has(X86_FEATURE_DECODEASSISTS)) > @@ -2912,7 +2923,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = { > [SVM_EXIT_RDPMC] = rdpmc_interception, > [SVM_EXIT_CPUID] = cpuid_interception, > [SVM_EXIT_IRET] = iret_interception, > - [SVM_EXIT_INVD] = emulate_on_interception, > + [SVM_EXIT_INVD] = invd_interception, > [SVM_EXIT_PAUSE] = pause_interception, > [SVM_EXIT_HLT] = halt_interception, > [SVM_EXIT_INVLPG] = invlpg_interception, > -- > 2.28.0 >