Skip to content

Commit 6129ed8

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86/mmu: Set mmio_value to '0' if reserved #PF can't be generated
Set the mmio_value to '0' instead of simply clearing the present bit to squash a benign warning in kvm_mmu_set_mmio_spte_mask() that complains about the mmio_value overlapping the lower GFN mask on systems with 52 bits of PA space. Opportunistically clean up the code and comments. Cc: [email protected] Fixes: d43e267 ("KVM: x86: only do L1TF workaround on affected processors") Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d43e267 commit 6129ed8

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6143,25 +6143,16 @@ static void kvm_set_mmio_spte_mask(void)
61436143
u64 mask;
61446144

61456145
/*
6146-
* Set the reserved bits and the present bit of an paging-structure
6147-
* entry to generate page fault with PFER.RSV = 1.
6146+
* Set a reserved PA bit in MMIO SPTEs to generate page faults with
6147+
* PFEC.RSVD=1 on MMIO accesses. 64-bit PTEs (PAE, x86-64, and EPT
6148+
* paging) support a maximum of 52 bits of PA, i.e. if the CPU supports
6149+
* 52-bit physical addresses then there are no reserved PA bits in the
6150+
* PTEs and so the reserved PA approach must be disabled.
61486151
*/
6149-
6150-
/*
6151-
* Mask the uppermost physical address bit, which would be reserved as
6152-
* long as the supported physical address width is less than 52.
6153-
*/
6154-
mask = 1ull << 51;
6155-
6156-
/* Set the present bit. */
6157-
mask |= 1ull;
6158-
6159-
/*
6160-
* If reserved bit is not supported, clear the present bit to disable
6161-
* mmio page fault.
6162-
*/
6163-
if (shadow_phys_bits == 52)
6164-
mask &= ~1ull;
6152+
if (shadow_phys_bits < 52)
6153+
mask = BIT_ULL(51) | PT_PRESENT_MASK;
6154+
else
6155+
mask = 0;
61656156

61666157
kvm_mmu_set_mmio_spte_mask(mask, mask, ACC_WRITE_MASK | ACC_USER_MASK);
61676158
}

0 commit comments

Comments
 (0)