KVM: MMU: Introduce struct kvm_page_fault
Create a single structure for arguments that are passed from kvm_mmu_do_page_fault to the page fault handlers. Later the structure will grow to include various output parameters that are passed back to the next steps in the page fault handling. Suggested-by: Isaku Yamahata <isaku.yamahata@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d055f028a5
commit
6defd9bb17
@ -114,17 +114,45 @@ static inline void kvm_mmu_load_pgd(struct kvm_vcpu *vcpu)
|
|||||||
vcpu->arch.mmu->shadow_root_level);
|
vcpu->arch.mmu->shadow_root_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct kvm_page_fault {
|
||||||
|
/* arguments to kvm_mmu_do_page_fault. */
|
||||||
|
const gpa_t addr;
|
||||||
|
const u32 error_code;
|
||||||
|
const bool prefault;
|
||||||
|
|
||||||
|
/* Derived from error_code. */
|
||||||
|
const bool exec;
|
||||||
|
const bool write;
|
||||||
|
const bool present;
|
||||||
|
const bool rsvd;
|
||||||
|
const bool user;
|
||||||
|
|
||||||
|
/* Derived from mmu. */
|
||||||
|
const bool is_tdp;
|
||||||
|
};
|
||||||
|
|
||||||
int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
|
int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
|
||||||
bool prefault);
|
bool prefault);
|
||||||
|
|
||||||
static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
|
static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
|
||||||
u32 err, bool prefault)
|
u32 err, bool prefault)
|
||||||
{
|
{
|
||||||
|
struct kvm_page_fault fault = {
|
||||||
|
.addr = cr2_or_gpa,
|
||||||
|
.error_code = err,
|
||||||
|
.exec = err & PFERR_FETCH_MASK,
|
||||||
|
.write = err & PFERR_WRITE_MASK,
|
||||||
|
.present = err & PFERR_PRESENT_MASK,
|
||||||
|
.rsvd = err & PFERR_RSVD_MASK,
|
||||||
|
.user = err & PFERR_USER_MASK,
|
||||||
|
.prefault = prefault,
|
||||||
|
.is_tdp = likely(vcpu->arch.mmu->page_fault == kvm_tdp_page_fault),
|
||||||
|
};
|
||||||
#ifdef CONFIG_RETPOLINE
|
#ifdef CONFIG_RETPOLINE
|
||||||
if (likely(vcpu->arch.mmu->page_fault == kvm_tdp_page_fault))
|
if (fault.is_tdp)
|
||||||
return kvm_tdp_page_fault(vcpu, cr2_or_gpa, err, prefault);
|
return kvm_tdp_page_fault(vcpu, fault.addr, fault.error_code, fault.prefault);
|
||||||
#endif
|
#endif
|
||||||
return vcpu->arch.mmu->page_fault(vcpu, cr2_or_gpa, err, prefault);
|
return vcpu->arch.mmu->page_fault(vcpu, fault.addr, fault.error_code, fault.prefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user