All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yang Weijiang <weijiang.yang@intel.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	dave.hansen@intel.com, tglx@linutronix.de, peterz@infradead.org,
	pbonzini@redhat.com, rick.p.edgecombe@intel.com,
	kvm@vger.kernel.org, yang.zhong@intel.com, jing2.liu@intel.com,
	chao.gao@intel.com
Subject: Re: [RFC PATCH 2/8] x86/fpu/xstate: Fix guest fpstate allocation size calculation
Date: Sat, 21 Oct 2023 00:35:04 +0000	[thread overview]
Message-ID: <ZTMcuOutjGOnjVIY@google.com> (raw)
In-Reply-To: <ZTMbfUhyOkmA9czp@google.com>

On Fri, Oct 20, 2023, Sean Christopherson wrote:
> On Wed, Sep 13, 2023, Yang Weijiang wrote:
> > Fix guest xsave area allocation size from fpu_user_cfg.default_size to
> > fpu_kernel_cfg.default_size so that the xsave area size is consistent
> > with fpstate->size set in __fpstate_reset().
> > 
> > With the fix, guest fpstate size is sufficient for KVM supported guest
> > xfeatures.
> > 
> > Fixes: 69f6ed1d14c6 ("x86/fpu: Provide infrastructure for KVM FPU cleanup");
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
> > ---
> >  arch/x86/kernel/fpu/core.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> > index a86d37052a64..a42d8ad26ce6 100644
> > --- a/arch/x86/kernel/fpu/core.c
> > +++ b/arch/x86/kernel/fpu/core.c
> > @@ -220,7 +220,9 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
> >  	struct fpstate *fpstate;
> >  	unsigned int size;
> >  
> > -	size = fpu_user_cfg.default_size + ALIGN(offsetof(struct fpstate, regs), 64);
> > +	size = fpu_kernel_cfg.default_size +
> > +	       ALIGN(offsetof(struct fpstate, regs), 64);
> 
> This looks sketchy and incomplete.  I haven't looked at the gory details of
> fpu_user_cfg vs. fpu_kernel_cfg, but the rest of this function uses fpu_user_cfg,
> including a check on fpu_user_cfg.default_size.  That makes me think that changing
> just the allocation size isn't quite right.

Shoot, I didn't realize the CET virtualization series included this a day later.
I'll respond there.

  reply	other threads:[~2023-10-21  0:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14  3:23 [RFC PATCH 0/8] Introduce CET supervisor xstate support Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 1/8] x86/fpu/xstate: Manually check and add XFEATURE_CET_USER xstate bit Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 2/8] x86/fpu/xstate: Fix guest fpstate allocation size calculation Yang Weijiang
2023-10-21  0:29   ` Sean Christopherson
2023-10-21  0:35     ` Sean Christopherson [this message]
2023-09-14  3:23 ` [RFC PATCH 3/8] x86/fpu/xstate: Add CET supervisor mode state support Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 4/8] x86/fpu/xstate: Introduce kernel dynamic xfeature set Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 5/8] x86/fpu/xstate: Remove kernel dynamic xfeatures from kernel default_features Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 6/8] x86/fpu/xstate: Opt-in kernel dynamic bits when calculate guest xstate size Yang Weijiang
2023-09-14  3:23 ` [RFC PATCH 7/8] x86/fpu/xstate: Tweak guest fpstate to support kernel dynamic xfeatures Yang Weijiang
2023-09-14  9:06   ` kernel test robot
2023-09-14  3:23 ` [RFC PATCH 8/8] x86/fpu/xstate: WARN if normal fpstate contains " Yang Weijiang

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=ZTMcuOutjGOnjVIY@google.com \
    --to=seanjc@google.com \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=jing2.liu@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@linutronix.de \
    --cc=weijiang.yang@intel.com \
    --cc=x86@kernel.org \
    --cc=yang.zhong@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.