Skip to content

Commit 58ef246

Browse files
committed
KVM: x86/mmu: Make kvm_mmu_do_page_fault() return mapped level
The guest memory population logic will need to know what page size or level (4K, 2M, ...) is mapped. Signed-off-by: Isaku Yamahata <[email protected]> Message-ID: <eabc3f3e5eb03b370cadf6e1901ea34d7a020adc.1712785629.git.isaku.yamahata@intel.com> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent f5e7f00 commit 58ef246

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,7 +4292,7 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work)
42924292
return;
42934293

42944294
r = kvm_mmu_do_page_fault(vcpu, work->cr2_or_gpa, work->arch.error_code,
4295-
true, NULL);
4295+
true, NULL, NULL);
42964296

42974297
/*
42984298
* Account fixed page faults, otherwise they'll never be counted, but
@@ -5937,7 +5937,7 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err
59375937
vcpu->stat.pf_taken++;
59385938

59395939
r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, error_code, false,
5940-
&emulation_type);
5940+
&emulation_type, NULL);
59415941
if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm))
59425942
return -EIO;
59435943
}

arch/x86/kvm/mmu/mmu_internal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ static inline void kvm_mmu_prepare_memory_fault_exit(struct kvm_vcpu *vcpu,
288288
}
289289

290290
static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
291-
u64 err, bool prefetch, int *emulation_type)
291+
u64 err, bool prefetch,
292+
int *emulation_type, u8 *level)
292293
{
293294
struct kvm_page_fault fault = {
294295
.addr = cr2_or_gpa,
@@ -336,6 +337,8 @@ static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
336337

337338
if (fault.write_fault_to_shadow_pgtable && emulation_type)
338339
*emulation_type |= EMULTYPE_WRITE_PF_TO_SP;
340+
if (level)
341+
*level = fault.goal_level;
339342

340343
return r;
341344
}

0 commit comments

Comments
 (0)