Skip to content

Commit 0c928ff

Browse files
committed
KVM: SVM: Fix benign "bool vs. int" comparison in svm_set_cr0()
Explicitly convert the return from is_paging() to a bool when comparing against old_paging, which is also a boolean. is_paging() sneakily uses kvm_read_cr0_bits() and returns an int, i.e. returns X86_CR0_PG or 0, not 1 or 0. Luckily, the bug is benign as it only results in a false positive, not a false negative, i.e. only causes a spurious refresh of CR4 when paging is enabled in both the old and new. Cc: Maxim Levitsky <mlevitsk@redhat.com> Fixes: c53bbe2 ("KVM: x86: SVM: don't passthrough SMAP/SMEP/PKE bits in !NPT && !gCR0.PG case") Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent fb509f7 commit 0c928ff

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,7 @@ void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
18021802

18031803
if (!npt_enabled) {
18041804
hcr0 |= X86_CR0_PG | X86_CR0_WP;
1805-
if (old_paging != is_paging(vcpu))
1805+
if (old_paging != !!is_paging(vcpu))
18061806
svm_set_cr4(vcpu, kvm_read_cr4(vcpu));
18071807
}
18081808

0 commit comments

Comments
 (0)