Skip to content

Commit 8f79b06

Browse files
Ben Gardonbonzini
authored andcommitted
kvm: mmu: Separate generating and setting mmio ptes
Separate the functions for generating MMIO page table entries from the function that inserts them into the paging structure. This refactoring will facilitate changes to the MMU sychronization model to use atomic compare / exchanges (which are not guaranteed to succeed) instead of a monolithic MMU lock. No functional change expected. Tested by running kvm-unit-tests on an Intel Haswell machine. This commit introduced no new failures. Signed-off-by: Ben Gardon <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Reviewed-by: Peter Shier <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0a2b64c commit 8f79b06

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ static u64 get_mmio_spte_generation(u64 spte)
451451
return gen;
452452
}
453453

454-
static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn,
455-
unsigned int access)
454+
static u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access)
456455
{
456+
457457
u64 gen = kvm_vcpu_memslots(vcpu)->generation & MMIO_SPTE_GEN_MASK;
458458
u64 mask = generation_mmio_spte_mask(gen);
459459
u64 gpa = gfn << PAGE_SHIFT;
@@ -464,6 +464,17 @@ static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn,
464464
mask |= (gpa & shadow_nonpresent_or_rsvd_mask)
465465
<< shadow_nonpresent_or_rsvd_mask_len;
466466

467+
return mask;
468+
}
469+
470+
static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn,
471+
unsigned int access)
472+
{
473+
u64 mask = make_mmio_spte(vcpu, gfn, access);
474+
unsigned int gen = get_mmio_spte_generation(mask);
475+
476+
access = mask & ACC_ALL;
477+
467478
trace_mark_mmio_spte(sptep, gfn, access, gen);
468479
mmu_spte_set(sptep, mask);
469480
}

0 commit comments

Comments
 (0)