Skip to content

Commit 4ececec

Browse files
committed
KVM: x86/mmu: Replace PFERR_NESTED_GUEST_PAGE with a more descriptive helper
Drop the globally visible PFERR_NESTED_GUEST_PAGE and replace it with a more appropriately named is_write_to_guest_page_table(). The macro name is misleading, because while all nNPT walks match PAGE|WRITE|PRESENT, the reverse is not true. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 1dc9cc1 commit 4ececec

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ enum x86_intercept_stage;
280280
#define PFERR_PRIVATE_ACCESS BIT_ULL(49)
281281
#define PFERR_SYNTHETIC_MASK (PFERR_IMPLICIT_ACCESS | PFERR_PRIVATE_ACCESS)
282282

283-
#define PFERR_NESTED_GUEST_PAGE (PFERR_GUEST_PAGE_MASK | \
284-
PFERR_WRITE_MASK | \
285-
PFERR_PRESENT_MASK)
286-
287283
/* apic attention bits */
288284
#define KVM_APIC_CHECK_VAPIC 0
289285
/*

arch/x86/kvm/mmu/mmu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5945,6 +5945,13 @@ void kvm_mmu_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
59455945
write_unlock(&vcpu->kvm->mmu_lock);
59465946
}
59475947

5948+
static bool is_write_to_guest_page_table(u64 error_code)
5949+
{
5950+
const u64 mask = PFERR_GUEST_PAGE_MASK | PFERR_WRITE_MASK | PFERR_PRESENT_MASK;
5951+
5952+
return (error_code & mask) == mask;
5953+
}
5954+
59485955
int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code,
59495956
void *insn, int insn_len)
59505957
{
@@ -6008,7 +6015,7 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err
60086015
* and resume the guest.
60096016
*/
60106017
if (vcpu->arch.mmu->root_role.direct &&
6011-
(error_code & PFERR_NESTED_GUEST_PAGE) == PFERR_NESTED_GUEST_PAGE) {
6018+
is_write_to_guest_page_table(error_code)) {
60126019
kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(cr2_or_gpa));
60136020
return 1;
60146021
}

0 commit comments

Comments
 (0)