Message ID | 20240227232100.478238-14-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | TDX/SNP part 1 of n, for 6.9 | expand |
On 2/28/2024 7:20 AM, Paolo Bonzini wrote: > From: Isaku Yamahata <isaku.yamahata@intel.com> > ... > The use of lower_32_bits() moves from kvm_mmu_page_fault() to > FNAME(page_fault), since walking is independent of the data in the > upper bits of the error code. Is it a must? I don't see any issue if full u64 error_code is passed to FNAME(page_fault) as well.
On Mon, Mar 04, 2024, Xiaoyao Li wrote: > On 2/28/2024 7:20 AM, Paolo Bonzini wrote: > > From: Isaku Yamahata <isaku.yamahata@intel.com> > > > ... > > The use of lower_32_bits() moves from kvm_mmu_page_fault() to > > FNAME(page_fault), since walking is independent of the data in the > > upper bits of the error code. > > Is it a must? I don't see any issue if full u64 error_code is passed to > FNAME(page_fault) as well. Heh, my thought as well. https://lore.kernel.org/all/20240228024147.41573-5-seanjc@google.com
On Mon, Mar 4, 2024 at 9:57 AM Xiaoyao Li <xiaoyao.li@intel.com> wrote: > > On 2/28/2024 7:20 AM, Paolo Bonzini wrote: > > From: Isaku Yamahata <isaku.yamahata@intel.com> > > > ... > > The use of lower_32_bits() moves from kvm_mmu_page_fault() to > > FNAME(page_fault), since walking is independent of the data in the > > upper bits of the error code. > > Is it a must? I don't see any issue if full u64 error_code is passed to > FNAME(page_fault) as well. The full error code *is* passed to kvm_mmu_do_page_fault() and FNAME(page_fault), it's only dropped when passed to FNAME(walk_addr). Paolo
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 195e46a1f00f..f58ca6cb789a 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5869,8 +5869,7 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err } if (r == RET_PF_INVALID) { - r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, - lower_32_bits(error_code), false, + r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, error_code, false, &emulation_type); if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm)) return -EIO; diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 0669a8a668ca..21f55e8b4dc6 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -190,7 +190,7 @@ static inline bool is_nx_huge_page_enabled(struct kvm *kvm) struct kvm_page_fault { /* arguments to kvm_mmu_do_page_fault. */ const gpa_t addr; - const u32 error_code; + const u64 error_code; const bool prefetch; /* Derived from error_code. */ @@ -280,7 +280,7 @@ enum { }; static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, - u32 err, bool prefetch, int *emulation_type) + u64 err, bool prefetch, int *emulation_type) { struct kvm_page_fault fault = { .addr = cr2_or_gpa, diff --git a/arch/x86/kvm/mmu/mmutrace.h b/arch/x86/kvm/mmu/mmutrace.h index ae86820cef69..195d98bc8de8 100644 --- a/arch/x86/kvm/mmu/mmutrace.h +++ b/arch/x86/kvm/mmu/mmutrace.h @@ -260,7 +260,7 @@ TRACE_EVENT( TP_STRUCT__entry( __field(int, vcpu_id) __field(gpa_t, cr2_or_gpa) - __field(u32, error_code) + __field(u64, error_code) __field(u64 *, sptep) __field(u64, old_spte) __field(u64, new_spte) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index bebd73cd61bb..ed2923d9a934 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -787,7 +787,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault * The bit needs to be cleared before walking guest page tables. */ r = FNAME(walk_addr)(&walker, vcpu, fault->addr, - fault->error_code & ~PFERR_RSVD_MASK); + lower_32_bits(fault->error_code) & ~PFERR_RSVD_MASK); /* * The page is not mapped by the guest. Let the guest handle it.