aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorGravatar Jim Mattson <jmattson@google.com> 2021-11-05 13:20:58 -0700
committerGravatar Paolo Bonzini <pbonzini@redhat.com> 2021-11-11 10:56:19 -0500
commite6cd31f1a8ce2f1150225ae176a08d12119e2444 (patch)
tree0ea2227a0aa68b240a9ddb1f4ab68c8794c28c4a /arch/x86/kvm/x86.c
parentKVM: x86: Fix recording of guest steal time / preempted status (diff)
downloadlinux-e6cd31f1a8ce2f1150225ae176a08d12119e2444.tar.gz
linux-e6cd31f1a8ce2f1150225ae176a08d12119e2444.tar.bz2
linux-e6cd31f1a8ce2f1150225ae176a08d12119e2444.zip
kvm: x86: Convert return type of *is_valid_rdpmc_ecx() to bool
These function names sound like predicates, and they have siblings, *is_valid_msr(), which _are_ predicates. Moreover, there are comments that essentially warn that these functions behave unexpectedly. Flip the polarity of the return values, so that they become predicates, and convert the boolean result to a success/failure code at the outer call site. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Jim Mattson <jmattson@google.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Message-Id: <20211105202058.1048757-1-jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e7d2ef944cc8..6bfef1d70ce1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7476,7 +7476,9 @@ static void emulator_set_smbase(struct x86_emulate_ctxt *ctxt, u64 smbase)
static int emulator_check_pmc(struct x86_emulate_ctxt *ctxt,
u32 pmc)
{
- return kvm_pmu_is_valid_rdpmc_ecx(emul_to_vcpu(ctxt), pmc);
+ if (kvm_pmu_is_valid_rdpmc_ecx(emul_to_vcpu(ctxt), pmc))
+ return 0;
+ return -EINVAL;
}
static int emulator_read_pmc(struct x86_emulate_ctxt *ctxt,