Commit a3ca5281 authored by Chenyi Qiang's avatar Chenyi Qiang Committed by Paolo Bonzini
Browse files

KVM: MMU: Reset mmu->pkru_mask to avoid stale data



When updating mmu->pkru_mask, the value can only be added but it isn't
reset in advance. This will make mmu->pkru_mask keep the stale data.
Fix this issue.

Fixes: 2d344105 ("KVM, pkeys: introduce pkru_mask to cache conditions")
Signed-off-by: default avatarChenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20211021071022.1140-1-chenyi.qiang@intel.com>
Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 3a25dfa6
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -4596,10 +4596,10 @@ static void update_pkru_bitmask(struct kvm_mmu *mmu)
	unsigned bit;
	unsigned bit;
	bool wp;
	bool wp;


	if (!is_cr4_pke(mmu)) {
	mmu->pkru_mask = 0;
	mmu->pkru_mask = 0;

	if (!is_cr4_pke(mmu))
		return;
		return;
	}


	wp = is_cr0_wp(mmu);
	wp = is_cr0_wp(mmu);