lkml.org 
[lkml]   [2019]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 6/7] KVM: x86: Load Guest fpu state when accessing MSRs managed by XSAVES
On Wed, Oct 02, 2019 at 12:56:30PM -0700, Jim Mattson wrote:
> On Thu, Sep 26, 2019 at 7:17 PM Yang Weijiang <weijiang.yang@intel.com> wrote:
> >
> > From: Sean Christopherson <sean.j.christopherson@intel.com>
> >
> /*
> > * Read or write a bunch of msrs. All parameters are kernel addresses.
> > *
> > @@ -3009,11 +3017,23 @@ static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs,
> > int (*do_msr)(struct kvm_vcpu *vcpu,
> > unsigned index, u64 *data))
> > {
> > + bool fpu_loaded = false;
> > int i;
> > + const u64 cet_bits = XFEATURE_MASK_CET_USER | XFEATURE_MASK_CET_KERNEL;
> > + bool cet_xss = kvm_x86_ops->xsaves_supported() &&
> > + (kvm_supported_xss() & cet_bits);
>
> It seems like I've seen a lot of checks like this. Can this be
> simplified (throughout this series) by sinking the
> kvm_x86_ops->xsaves_supported() check into kvm_supported_xss()? That
> is, shouldn't kvm_supported_xss() return 0 if
> kvm_x86_ops->xsaves_supported() is false?
>
OK, let me add this check, thank you!

> > - for (i = 0; i < msrs->nmsrs; ++i)
> > + for (i = 0; i < msrs->nmsrs; ++i) {
> > + if (!fpu_loaded && cet_xss &&
> > + is_xsaves_msr(entries[i].index)) {
> > + kvm_load_guest_fpu(vcpu);
> > + fpu_loaded = true;
> > + }
> > if (do_msr(vcpu, entries[i].index, &entries[i].data))
> > break;
> > + }
> > + if (fpu_loaded)
> > + kvm_put_guest_fpu(vcpu);
> >
> > return i;
> > }
> > --
> > 2.17.2
> >

\
 
 \ /
  Last update: 2019-10-09 08:45    [W:0.051 / U:1.140 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site