public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	oliver.sang@intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Avoid KVM_SET_CPUID2 after KVM_RUN in vmx_pmu_msrs_test
Date: Thu, 16 Dec 2021 15:48:30 +0000	[thread overview]
Message-ID: <Ybtfzo6Fx6KLfK3V@google.com> (raw)
In-Reply-To: <87a6h0vs36.fsf@redhat.com>

On Thu, Dec 16, 2021, Vitaly Kuznetsov wrote:
> Sean Christopherson <seanjc@google.com> writes:
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 85127b3e3690..65e297875405 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -3424,7 +3424,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> >
> >                 if (!msr_info->host_initiated)
> >                         return 1;
> > -               if (guest_cpuid_has(vcpu, X86_FEATURE_PDCM) && kvm_get_msr_feature(&msr_ent))
> > +               if (kvm_get_msr_feature(&msr_ent))
> >                         return 1;
> >                 if (data & ~msr_ent.data)
> >                         return 1;
> 
> This looks OK.
> 
> > @@ -3779,14 +3779,12 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> >                 msr_info->data = vcpu->arch.microcode_version;
> >                 break;
> >         case MSR_IA32_ARCH_CAPABILITIES:
> > -               if (!msr_info->host_initiated &&
> > -                   !guest_cpuid_has(vcpu, X86_FEATURE_ARCH_CAPABILITIES))
> > +               if (!msr_info->host_initiated)
> >                         return 1;
> >                 msr_info->data = vcpu->arch.arch_capabilities;
> >                 break;
> >         case MSR_IA32_PERF_CAPABILITIES:
> > -               if (!msr_info->host_initiated &&
> > -                   !guest_cpuid_has(vcpu, X86_FEATURE_PDCM))
> > +               if (!msr_info->host_initiated)
> >                         return 1;
> >                 msr_info->data = vcpu->arch.perf_capabilities;
> >                 break;
> >
> 
> Hm, this change will unconditionally forbid reading
> MSR_IA32_ARCH_CAPABILITIES/MSR_IA32_PERF_CAPABILITIES from the guest. Is
> this what we want?

No, I completely misread the code.  The kvm_set_msr_common() goof seems to be
the only bug, and that would also explain the selftest's bad testcase.

  reply	other threads:[~2021-12-16 15:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 16:16 [PATCH] KVM: selftests: Avoid KVM_SET_CPUID2 after KVM_RUN in vmx_pmu_msrs_test Vitaly Kuznetsov
2021-12-15 17:59 ` Sean Christopherson
2021-12-16  9:04   ` Vitaly Kuznetsov
2021-12-16 15:48     ` Sean Christopherson [this message]
2021-12-16 16:00       ` Vitaly Kuznetsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ybtfzo6Fx6KLfK3V@google.com \
    --to=seanjc@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver.sang@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox