In preparation for propagating GLOBAL_STATUS_CLR writes to hardware if the guest's mediated PMU context is loaded, ignore reserved bits when the guest writes AMD's GLOBAL_STATUS_CLR, as is already done for GLOBAL_STATUS_SET, so that guest-controlled reserved bits aren't written to hardware. Writes to Intel's GLOBAL_OVF_CTRL, which share the code, are unaffected, as they already #GP if any reserved bits are set. Signed-off-by: Yosry Ahmed --- arch/x86/kvm/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index d312f1b2f586a..81278a64be43f 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -962,7 +962,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) fallthrough; case MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR: if (!msr_info->host_initiated) - pmu->global_status &= ~data; + pmu->global_status &= ~(data & ~pmu->global_status_rsvd); break; case MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_SET: if (!msr_info->host_initiated) -- 2.56.1.809.ga0b61035b5-goog