Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1158348ybb; Fri, 20 Mar 2020 14:33:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsRlCUCyqu9p2m7DIGKT+/zfv6TIhecZ2DIJ03syqAwtuLGhs4t9UQcxnsoT84ob6b+vnOk X-Received: by 2002:aca:646:: with SMTP id 67mr7997750oig.4.1584740016766; Fri, 20 Mar 2020 14:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584740016; cv=none; d=google.com; s=arc-20160816; b=nSV9Cfzzvj/vAZGVHsCQFGz3C8tYh7O+P9sP1hQK1ShLU5UYjUaSL630/yD4/D5s/W r9iF0jsxW4Y41nbd0syDwBy3cUS6hD25ElRZbmnaMuko++4jnGFNgRKWsdIqX0zlP09c 5+EGE4p6FWySmp71iYvd/OnHtovRsdbN97cWMsADVdCosQ/qLe2pu1ygtg1FQIaTmqiH mNCpqHRZ6mKJHwdSJDJfNb7STjTmIgIPt5+2MoOXzA37aQP+5Xj5PO8OH4Ht58ogj15+ RP+REaUXAGttiWQ8th1gD0/9u80EoDb1EahshRMXOiuv6tA0Y83max+g0giUIq54vcfl xfqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=7s1gNQGsWOtJQEKKcyF/FAscV2ly1BtSYQd+OMSLnuE=; b=dKOgl2Du4ODCA0MKwJgrW2dRw1DGw6lb5qY79gMbirmxbmBsWV7WOJ9FRLXnJqQVkl ZZ3Gu0BPR3Ay7aI4N3J/sHWskmLeHSWy/F1xDwiN6F92JIqaaJ7gmMVocxJVbx2HDKxR 4mhWuR/5hAo23zRTVkzQRJ0STCl6v4TE2AgJHYoAdJPIF03G1n5dtZhWq353yfOI8UdT NvK995azS51PHjp0Esf1d49TD+DZk7RbwYPHAvq/2GJJsJV5omfQqq3rChpcaFxUyYFk 8jG4Eh4cadb1Rml6Hlm4ZGg7L9SgHhSwHH1fNpiQPPVulLuiv3eb/6+RMaG2vZ6OZety a3Fw== 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 l185si3578253oif.274.2020.03.20.14.33.24; Fri, 20 Mar 2020 14:33:36 -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 S1727267AbgCTVbk (ORCPT + 99 others); Fri, 20 Mar 2020 17:31:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:48429 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727128AbgCTV2p (ORCPT ); Fri, 20 Mar 2020 17:28:45 -0400 IronPort-SDR: i4s+z7Y6+bAk85agMVrJit9C4JmAguDyae4BYTu5nBRaSYARAvjzwC/PL4A273AtmV/5SVlhhF 16P6ok2Ue6HQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2020 14:28:45 -0700 IronPort-SDR: Ri1CUDQfhkEk7R8e0zAt8uCD3NG2kRKcNu47b6aobzCQXJ8+kBkoIiIv83g1MafQBM5WbvThUV 8wIDHxPGBDCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,286,1580803200"; d="scan'208";a="269224411" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.202]) by fmsmga004.fm.intel.com with ESMTP; 20 Mar 2020 14:28:44 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Junaid Shahid , Liran Alon , Boris Ostrovsky , John Haxby , Miaohe Lin , Tom Lendacky Subject: [PATCH v3 05/37] KVM: x86: Export kvm_propagate_fault() (as kvm_inject_emulated_page_fault) Date: Fri, 20 Mar 2020 14:28:01 -0700 Message-Id: <20200320212833.3507-6-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200320212833.3507-1-sean.j.christopherson@intel.com> References: <20200320212833.3507-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Export the page fault propagation helper so that VMX can use it to correctly emulate TLB invalidation on page faults in an upcoming patch. In the (hopefully) not-too-distant future, SGX virtualization will also want access to the helper for injecting page faults to the correct level (L1 vs. L2) when emulating ENCLS instructions. Rename the function to kvm_inject_emulated_page_fault() to clarify that it is (a) injecting a fault and (b) only for page faults. WARN if it's invoked with an exception other than PF_VECTOR. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 9a183e9d4cb1..328b1765ff76 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1447,6 +1447,8 @@ void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault); +bool kvm_inject_emulated_page_fault(struct kvm_vcpu *vcpu, + struct x86_exception *fault); int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, gfn_t gfn, void *data, int offset, int len, u32 access); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e54c6ad628a8..64ed6e6e2b56 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -611,8 +611,11 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault) } EXPORT_SYMBOL_GPL(kvm_inject_page_fault); -static bool kvm_propagate_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault) +bool kvm_inject_emulated_page_fault(struct kvm_vcpu *vcpu, + struct x86_exception *fault) { + WARN_ON_ONCE(fault->vector != PF_VECTOR); + if (mmu_is_nested(vcpu) && !fault->nested_page_fault) vcpu->arch.nested_mmu.inject_page_fault(vcpu, fault); else @@ -620,6 +623,7 @@ static bool kvm_propagate_fault(struct kvm_vcpu *vcpu, struct x86_exception *fau return fault->nested_page_fault; } +EXPORT_SYMBOL_GPL(kvm_inject_emulated_page_fault); void kvm_inject_nmi(struct kvm_vcpu *vcpu) { @@ -6373,7 +6377,7 @@ static bool inject_emulated_exception(struct kvm_vcpu *vcpu) { struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt; if (ctxt->exception.vector == PF_VECTOR) - return kvm_propagate_fault(vcpu, &ctxt->exception); + return kvm_inject_emulated_page_fault(vcpu, &ctxt->exception); if (ctxt->exception.error_code_valid) kvm_queue_exception_e(vcpu, ctxt->exception.vector, -- 2.24.1