Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2488526pxk; Mon, 14 Sep 2020 15:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7G7Ua81kfESuDetEmGU9iUUa0fKDS4mgG0rnuwA6+IiDdux0QzEHYzv0XxkE9OfCcawyW X-Received: by 2002:a17:906:b6d5:: with SMTP id ec21mr16281481ejb.396.1600121089722; Mon, 14 Sep 2020 15:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600121089; cv=none; d=google.com; s=arc-20160816; b=Umu1S3DiLqmfTJyI9Zc10236J1kE0uPJKzLkOSDhDiJI5qZ2ywvR+wIm4ZFT+UlIn7 DRZQUxMx4yyW3O4Sdf+51MhjO2QG5doI1UpyfAHaof2ESqCR8J7OArEycSgvdWRvOWiU L8urZJBzDUssB9nrLwVMh6cts+HhZMJgh6glKzv6HOV0QvCdeHyz1jhWO56RsWV/OgOZ +3jmdfFLp1Er+8UHZJRnTXCVJW017s4nR2HZFNFTQivqF0txmqQcDZz2w6vCaZ7ZqRUZ wAtMqG0HiWOp8VyJMjYVmMTYhxelE7R/MkCnWnjohZ32AkntfQEzqrl+PQ3vJ2ooWAQo nb2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=YF5ZZfd1tbUQ52FMDM+1uMeckStWswMtPKcBqABP4Ko=; b=ceFfDUOP9KWxK90Yf9CjFgXGcxlO08mE0l/CGCWDOZ2Cy75nteXCqtNkd2DWhlmLSq FiYwhBFHcPi9rORFIWSXUh9SuzKkeytdauuWyGDuqImM+wj8Gqz+GVE9JqvIgO5g0jl/ GgKyv3XHwIZ6cDjNcnFQojmqLJYQYhGZtmtFxizcouuEEe5a9mKBaH/tu324J7TD2PDA lCz/bVvEZyjFhKC+ZhGgP57dfHVQurqBYPMAiBwUfNcwyDVexyJO5PyfzyqgVwP4DKAw mrUFokn6qRkBEKPLha0SUuhYP+KKaMHSSLi8LecXjshprMwXFmxqC6p6G08a5Yj8eqBV 2Tkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml23si8131865ejb.242.2020.09.14.15.04.27; Mon, 14 Sep 2020 15:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726034AbgINWA5 (ORCPT + 99 others); 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 >