Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3459838imu; Fri, 30 Nov 2018 00:12:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/V8jxHbu9stnKInQc2NQFdPjAO0gMCzFRMh/0nsLK6CnG+h5h+dwI6u1j5qMzGX5AyJzucD X-Received: by 2002:a63:2586:: with SMTP id l128mr4123797pgl.104.1543565540251; Fri, 30 Nov 2018 00:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543565540; cv=none; d=google.com; s=arc-20160816; b=xipDieLgSPlF3K400T3BKS4boH24Nmn+oNdWqWfvea5AKrxwB6UMyaRBvoUFr4wgSg 8IIEz6V1V5wvxRSx+PY9LBwzzto08mBv/WM3sQJZ84bHeuh86+RWyOJWBy6K+w4+gk2j gtUYmvIy94VIonKYXI84h+/6kI34vlS6Ps3Y+mRyZSb9S3pFIa3KrWCxgzCarSJOpYiK o016aUELrevX0m3QUpk8CzEUV84jCWk77sQcwzyAKZzleEL7OuSFmXNZjNeJ131Z8H6+ 1IfGZ2ySsoJ9w2dHvQEsROcajj8ungUNTjhYvYarib8m/Pj4vrzWFdojHpy/tppMxsop TEBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=q7Rd5a4j79aKmo9nB1te92BtPv7zKl+KL3dso02oL5g=; b=rnA9wNSr7oB2+wlwW4CCatslvAtmk/ZuJPcouxxq2dYeuwEt0hzkDVUJnenGGVPoOP yoBvgjULSUqfaBIEVK1wmQnNAxPol8gBu60GRpB0tD5n/05gu89qqqDUjY0cPR/nmjcn 35jAvCdsw/nn0VY9pkb7mfgujpOVy4b/mIhsOZkjKteUCla30Qud8oWEd4Lic6p8ynuC yHbuFDYJ6OEu9wF30hB1QP9gRQ8kYySuJOvelHj/91w4unqysHHQn6P3O1SQuoAPDKe2 oWJdQrUHqU5FXr6dukE9l+AqM9I5+MBdOg2A5B+JqKEPtpzo+kZFYiUL1O9BWfzVu9Up +8Bg== 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 t184si5000170pfb.22.2018.11.30.00.12.05; Fri, 30 Nov 2018 00:12:20 -0800 (PST) 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 S1727469AbeK3TSO (ORCPT + 99 others); Fri, 30 Nov 2018 14:18:14 -0500 Received: from mga07.intel.com ([134.134.136.100]:29561 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727444AbeK3TSN (ORCPT ); Fri, 30 Nov 2018 14:18:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Nov 2018 00:09:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,297,1539673200"; d="scan'208";a="94509030" Received: from linux.intel.com ([10.54.29.200]) by orsmga007.jf.intel.com with ESMTP; 30 Nov 2018 00:09:45 -0800 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.128]) by linux.intel.com (Postfix) with ESMTP id 3FFB5580213; Fri, 30 Nov 2018 00:09:43 -0800 (PST) From: Zhang Yi To: pbonzini@redhat.com, mdontu@bitdefender.com, ncitu@bitdefender.com Cc: rkrcmar@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Zhang Yi Subject: [RFC PATCH V2 11/11] KVM: VMX: implement setup SPP page structure in spp miss. Date: Fri, 30 Nov 2018 16:09:28 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We also should setup SPP page structure while we catch a SPP miss, some case, such as hotplug vcpu, should update the SPP page table in SPP miss handler. Signed-off-by: Zhang Yi --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/mmu.c | 12 ++++++++++++ arch/x86/kvm/vmx.c | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index ce6d258..a09ea39 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1406,6 +1406,8 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u64 error_code, int kvm_mmu_setup_spp_structure(struct kvm_vcpu *vcpu, u32 access_map, gfn_t gfn); +int kvm_mmu_get_spp_acsess_map(struct kvm *kvm, u32 *access_map, gfn_t gfn); + void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid); void kvm_mmu_new_cr3(struct kvm_vcpu *vcpu, gpa_t new_cr3, bool skip_tlb_flush); diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 287ee62..01cf85e 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4299,6 +4299,17 @@ static void mmu_spp_spte_set(u64 *sptep, u64 new_spte) __set_spte(sptep, new_spte); } +int kvm_mmu_get_spp_acsess_map(struct kvm *kvm, u32 *access_map, gfn_t gfn) +{ + struct kvm_memory_slot *slot; + + slot = gfn_to_memslot(kvm, gfn); + *access_map = *gfn_to_subpage_wp_info(slot, gfn); + + return 0; +} +EXPORT_SYMBOL_GPL(kvm_mmu_get_spp_acsess_map); + int kvm_mmu_setup_spp_structure(struct kvm_vcpu *vcpu, u32 access_map, gfn_t gfn) { @@ -4344,6 +4355,7 @@ int kvm_mmu_setup_spp_structure(struct kvm_vcpu *vcpu, spin_unlock(&kvm->mmu_lock); return -EFAULT; } +EXPORT_SYMBOL_GPL(kvm_mmu_setup_spp_structure); int kvm_mmu_get_subpages(struct kvm *kvm, struct kvm_subpage *spp_info) { diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b660812..b0ab645 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -9706,6 +9706,9 @@ static int handle_invpcid(struct kvm_vcpu *vcpu) static int handle_spp(struct kvm_vcpu *vcpu) { unsigned long exit_qualification; + gpa_t gpa; + gfn_t gfn; + u32 map; exit_qualification = vmcs_readl(EXIT_QUALIFICATION); @@ -9732,6 +9735,11 @@ static int handle_spp(struct kvm_vcpu *vcpu) * SPP table here. */ pr_debug("SPP: %s: SPPT Miss!!!\n", __func__); + + gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); + gfn = gpa >> PAGE_SHIFT; + kvm_mmu_get_spp_acsess_map(vcpu->kvm, &map, gfn); + kvm_mmu_setup_spp_structure(vcpu, map, gfn); return 1; } -- 2.7.4