RE: [RFC PATCH 07/22] x86/fpu/xstate: Introduce helpers to manage an xstate area dynamically

From: Brown, Len
Date: Tue Oct 13 2020 - 18:00:36 EST




>
> From: Andy Lutomirski <luto@xxxxxxxxxx>
>
> > + /*
> > + * The caller may be under interrupt disabled condition. Ensure interrupt
> > + * allowance before the memory allocation, which may involve with page faults.
> > + */
> > + local_irq_enable();

> ... you can't just enable IRQs here. If IRQs are off, they're off for a reason. Secondly, if they're *on*, you just forgot that fact.

Good catch. This is a trap handler from user-space and should never be called with irqs disabled,
So the local_irq_enable() should be dead code. Chang suggested that he erroneously left it in
from a previous implementation.

> > + /* We need 64B aligned pointer, but vmalloc() returns a page-aligned address */
> > + state_ptr = vmalloc(newsz);

> And allocating this state from vmalloc() seems questionable. Why are you doing this?

While the buffer needs to be virtually contiguous, it doesn't need to be physically contiguous,
And so vmalloc() is less overhead than kmalloc() for this.

Thanks,
-Len