KVM: VMX: Refactor intel_pmu_{g,}set_msr() to align with other helpers
authorSean Christopherson <seanjc@google.com>
Fri, 27 Jan 2023 01:08:03 +0000 (17:08 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 6 Apr 2023 23:03:20 +0000 (16:03 -0700)
commit8bca8c5ce40b03862d782b9991da146909199327
tree00f6cfdd943cf9a14689b288e9b756c45f557de2
parentcdd2fbf6360e84c02ac4cea11733083c2ca8dace
KVM: VMX: Refactor intel_pmu_{g,}set_msr() to align with other helpers

Invert the flows in intel_pmu_{g,s}et_msr()'s case statements so that
they follow the kernel's preferred style of:

        if (<not valid>)
                return <error>

        <commit change>
        return <success>

which is also the style used by every other {g,s}et_msr() helper (except
AMD's PMU variant, which doesn't use a switch statement).

Modify the "set" paths with costly side effects, i.e. that reprogram
counters, to skip only the side effects, i.e. to perform reserved bits
checks even if the value is unchanged.  None of the reserved bits checks
are expensive, so there's no strong justification for skipping them, and
guarding only the side effect makes it slightly more obvious what is being
skipped and why.

No functional change intended (assuming no reserved bit bugs).

Link: https://lkml.kernel.org/r/Y%2B6cfen%2FCpO3%2FdLO%40google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/pmu_intel.c