| From 4a6b809871c125823c70a0c77b78f1e5201c8683 Mon Sep 17 00:00:00 2001 |
| From: Yan Zhao <yan.y.zhao@intel.com> |
| Date: Fri, 5 Jan 2024 17:14:54 +0800 |
| Subject: [PATCH] BACKPORT: FROMLIST: KVM: x86: Add a new param "slot" to op |
| get_mt_mask in kvm_x86_ops |
| |
| Add param "slot" to op get_mt_mask in kvm_x86_ops. |
| This is a preparation patch to later honor guest PATs for certain memslots. |
| |
| No functional change intended. |
| |
| Suggested-by: Sean Christopherson <seanjc@google.com> |
| Cc: Kevin Tian <kevin.tian@intel.com> |
| Cc: Zhenyu Wang <zhenyuw@linux.intel.com> |
| Tested-by: Yongwei Ma <yongwei.ma@intel.com> |
| Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> |
| Signed-off-by: Dawn Han <dawnhan@google.com> |
| (am from https://lore.kernel.org/all/20240105091454.24700-1-yan.y.zhao@intel.com/) |
| |
| BUG=b:335525888 |
| UPSTREAM-TASK=b:321924870 |
| TEST=run against ARCVM with change patch |
| |
| Change-Id: Ib1c4d20e465e2e9bb2b50adba0f9a74489277c00 |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/5479188 |
| Commit-Queue: Dawn Han <dawnhan@google.com> |
| Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> |
| Tested-by: Dawn Han <dawnhan@google.com> |
| --- |
| arch/x86/include/asm/kvm_host.h | 3 ++- |
| arch/x86/kvm/mmu/spte.c | 3 ++- |
| arch/x86/kvm/vmx/vmx.c | 3 ++- |
| 3 files changed, 6 insertions(+), 3 deletions(-) |
| |
| diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h |
| index 5dadf09298bf3d06f804958501fe39f36434740d..f849f3dfe07bf5c1e4638bbc4f611d3a98810e54 100644 |
| --- a/arch/x86/include/asm/kvm_host.h |
| +++ b/arch/x86/include/asm/kvm_host.h |
| @@ -1741,7 +1741,8 @@ struct kvm_x86_ops { |
| int (*sync_pir_to_irr)(struct kvm_vcpu *vcpu); |
| int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); |
| int (*set_identity_map_addr)(struct kvm *kvm, u64 ident_addr); |
| - u8 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); |
| + u8 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio, |
| + const struct kvm_memory_slot *slot); |
| |
| void (*load_mmu_pgd)(struct kvm_vcpu *vcpu, hpa_t root_hpa, |
| int root_level); |
| diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c |
| index ab480e38d1474e3e39ab43fd92847aa0c0fec4c9..2630e07e2ca3c74c588b421de29ef7cac7957a7d 100644 |
| --- a/arch/x86/kvm/mmu/spte.c |
| +++ b/arch/x86/kvm/mmu/spte.c |
| @@ -214,7 +214,8 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, |
| |
| if (shadow_memtype_mask) |
| spte |= kvm_x86_call(get_mt_mask)(vcpu, gfn, |
| - kvm_is_mmio_pfn(pfn)); |
| + kvm_is_mmio_pfn(pfn), |
| + slot); |
| if (host_writable) |
| spte |= shadow_host_writable_mask; |
| else |
| diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c |
| index f18c2d8c7476e180005cef514953ab0e2ecb80bb..81c101bbc1aa9d40bdfca50f4ee47c0b7c6bbb11 100644 |
| --- a/arch/x86/kvm/vmx/vmx.c |
| +++ b/arch/x86/kvm/vmx/vmx.c |
| @@ -7648,7 +7648,8 @@ int vmx_vm_init(struct kvm *kvm) |
| return 0; |
| } |
| |
| -u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) |
| +u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio, |
| + const struct kvm_memory_slot *slot) |
| { |
| /* |
| * Force UC for host MMIO regions, as allowing the guest to access MMIO |
| -- |
| 2.46.0.rc2.264.g509ed76dc8-goog |
| |