Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c19986fe authored by Junaid Shahid's avatar Junaid Shahid Committed by Paolo Bonzini
Browse files

kvm: x86: Suppress CR3_PCID_INVD bit only when PCIDs are enabled



If the PCIDE bit is not set in CR4, then the MSb of CR3 is a reserved
bit. If the guest tries to set it, that should cause a #GP fault. So
mask out the bit only when the PCIDE bit is set.

Signed-off-by: default avatarJunaid Shahid <junaids@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent bcb2b94a
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -843,6 +843,9 @@ EXPORT_SYMBOL_GPL(kvm_set_cr4);
int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
{
{
#ifdef CONFIG_X86_64
#ifdef CONFIG_X86_64
	bool pcid_enabled = kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE);

	if (pcid_enabled)
		cr3 &= ~CR3_PCID_INVD;
		cr3 &= ~CR3_PCID_INVD;
#endif
#endif