Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4261917ybi; Mon, 29 Jul 2019 22:44:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwbJtT/Q+UPqesfLmH1wbinFamD//zLV2y9YOlgiWIXL+xv6+Tt5NyoSyKMaOBajjkCyeO X-Received: by 2002:a65:448a:: with SMTP id l10mr82037835pgq.327.1564465496660; Mon, 29 Jul 2019 22:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564465496; cv=none; d=google.com; s=arc-20160816; b=zvvPKWQyQym1a8QfEULaBBoUDwaRSfLDi5q34W0BYLRnnp6IcbdCYCM8gV0oZwZG51 xMrI9o/QrLzPgs4Zv0oZ9AL6zC4wOHCMPEvb+BTNNIk+S7takDk+Hfgx30lgMM7oY0NZ AY0lDLvsPovD98uG2uZ1iP+GMdiT/1sTnUlP5P0+aRW9ftaba7RNmlXN+cPnBwJFlK0k mb+3i3xMEtAOVKC9GdpTQU3UEYUkaNmyKNZCSA86jXDP9v8jOUxXez22/RXjFJx+icCS aWRLc0zyNT9Awych1P7IVkrEC5n/9d8xWACUj6q5yCrTTvjXDG2EH0ar06OWYd6BjSRq XeLg== 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; bh=haUDtu7SgsWEhu1wTImLOxl+zCFv3O4YPI7PAFLUk84=; b=zZv3fhQF5x1HQu2+nVaLV09+x9ghRz4ktvM1PSp3cC3CpMmXvm+C5VGPDTIl4E3Z+e h4zo6hiUFDc7eFvf/rHyjy+7uKV79XXIrVh7nfwlLqxVUDyddp2/InrCOAPEsxJz3Vbk yNWmiIg7RZwz18arxYv4G7kVxmK8u2KfqWJ5ToQuUY7Siz88a4mRNd7iH4f/FC2I5mBB eWbdjRt4pfr6rGwI1w5pO03ZKiRC94AYJwgKDy9VppN9CJPoVmTz0X3ZNCNxuauYCvW6 Nz4QWp6K1yJA6DuUH9fHJty4TLpBVkCyFdoREC/xbFotDo3iPkg2jkXU+aYD1/p3vWol gy3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h15si25707216plr.23.2019.07.29.22.44.42; Mon, 29 Jul 2019 22:44:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727036AbfG3DIx (ORCPT + 99 others); Mon, 29 Jul 2019 23:08:53 -0400 Received: from mga03.intel.com ([134.134.136.65]:15685 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbfG3DIw (ORCPT ); Mon, 29 Jul 2019 23:08:52 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jul 2019 20:08:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,325,1559545200"; d="scan'208";a="179599286" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jul 2019 20:08:51 -0700 Date: Mon, 29 Jul 2019 20:08:51 -0700 From: Sean Christopherson To: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Jarkko Sakkinen , Joerg Roedel Cc: "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, Andy Lutomirski Subject: Re: [RFC PATCH 08/21] KVM: x86: Add kvm_x86_ops hook to short circuit emulation Message-ID: <20190730030850.GM21120@linux.intel.com> References: <20190727055214.9282-1-sean.j.christopherson@intel.com> <20190727055214.9282-9-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190727055214.9282-9-sean.j.christopherson@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 26, 2019 at 10:52:01PM -0700, Sean Christopherson wrote: > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 48c865a4e5dd..0fb8b60eb136 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -7115,10 +7115,25 @@ static int nested_enable_evmcs(struct kvm_vcpu *vcpu, > return -ENODEV; > } > > -static bool svm_need_emulation_on_page_fault(struct kvm_vcpu *vcpu) > +static bool svm_is_emulatable(struct kvm_vcpu *vcpu, void *insn, int insn_len) > { > bool is_user, smap; > > + if (likely(!insn || insn_len)) > + return true; > + > + /* > + * Under certain conditions insn_len may be zero on #NPF. This can > + * happen if a guest gets a page-fault on data access but the HW table > + * walker is not able to read the instruction page (e.g instruction > + * page is not present in memory). In those cases we simply restart the > + * guest, with the exception of AMD Erratum 1096 which is unrecoverable. > + */ > + if (unlikely(insn && !insn_len)) { > + if (!kvm_x86_ops->need_emulation_on_page_fault(vcpu)) > + return 1; > + } Doh, obviously forgot to compile for SVM when rebasing.