Re: [PATCH v7 9/9] x86/mmu: Allocate/free PASID

From: Fenghua Yu
Date: Mon Sep 14 2020 - 14:39:29 EST


Hi, Boris,

On Mon, Sep 07, 2020 at 01:18:43PM +0200, Borislav Petkov wrote:
> On Thu, Aug 27, 2020 at 08:06:34AM -0700, Fenghua Yu wrote:
> > + */
> > + xsave = &fpu->state.xsave;
> > + xsave->header.xfeatures |= XFEATURE_MASK_PASID;
> > + ppasid_state = get_xsave_addr(xsave, XFEATURE_PASID);
> > + if (ppasid_state) {
> > + /*
> > + * Only update the task's PASID state when it's
> > + * different from the mm's pasid.
> > + */
> > + if (ppasid_state->pasid != pasid_state) {
> > + /*
> > + * Invalid fpregs so that xrstors will pick up
> ^^^^^^^
>
> Not "xrstors" but the "state restoring" or so.

Fixed.

> > + * the PASID state.
> > + */
> > + __fpu_invalidate_fpregs_state(fpu);
> > + ppasid_state->pasid = pasid_state;
> > + }
>
> What happens if get_xsave_addr() returns NULL? A WARN_ONCE maybe?

get_xsave_addr() will not return NULL because xsave->header.xfeatures has
XFEATURE_MASK_PASID set. I will remove the unnecessary check "if (ppasid_state)"
to optimize the function and add a comment on why the check is unnecessary.

> Ok, done with review.

I addressed all of your comments and will send out the updated series soon.

Thank you very much for your review!

-Fenghua