OSDN Git Service

KVM: x86/mmu: Use boolean returns for (S)PTE accessors
authorSean Christopherson <seanjc@google.com>
Sat, 23 Jan 2021 00:30:03 +0000 (16:30 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Feb 2021 10:27:15 +0000 (05:27 -0500)
commit15e6a7e5324cc04a67891fc369ea834bbb7e7b42
tree06609dc07dfc5b29e162618929fa809f011e83ae
parentc910662c7c696ec0769766aaee5fc2fb54d921d5
KVM: x86/mmu: Use boolean returns for (S)PTE accessors

Return a 'bool' instead of an 'int' for various PTE accessors that are
boolean in nature, e.g. is_shadow_present_pte().  Returning an int is
goofy and potentially dangerous, e.g. if a flag being checked is moved
into the upper 32 bits of a SPTE, then the compiler may silently squash
the entire check since casting to an int is guaranteed to yield a
return value of '0'.

Opportunistically refactor is_last_spte() so that it naturally returns
a bool value instead of letting it implicitly cast 0/1 to false/true.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210123003003.3137525-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.h
arch/x86/kvm/mmu/spte.h