lkml.org 
[lkml]   [2021]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state
Date
On Mar 26, 2021, at 09:34, Jann Horn <jannh@google.com> wrote:
> On Sun, Feb 21, 2021 at 7:56 PM Chang S. Bae <chang.seok.bae@intel.com> wrote:
>>
>> + if (handle_xfirstuse_event(&current->thread.fpu))
>> + return;
>
> What happens if handle_xfirstuse_event() fails because vmalloc()
> failed in alloc_xstate_buffer()? I think that should probably kill the
> task with something like force_sig() - but as far as I can tell, at
> the moment, it will instead end up at die(), which should only be used
> for kernel bugs.

This question was raised on v1 before [1].

In the end, people suggested to handle the failure, e.g., with tracepoints or
stats. So, proposed this on the allocation site:

+ state_ptr = vmalloc(newsz);
+ if (!state_ptr) {
+ trace_x86_fpu_xstate_alloc_failed(fpu);
+ return -ENOMEM;
+ }

Also, I tried to justify this to Boris [2]:

>> Maybe it is possible to backtrack this allocation failure out of #NM
>> handling. But the tracepoint can provide a clear context, although limited
>> to those using it.

> Yes, add it when it is really needed. Not slapping it proactively and
> hoping for any potential usage.

Let me know if you have a better way.

Thanks,
Chang

[1] https://lore.kernel.org/lkml/c4669d5f-11b8-3879-562c-78a791b86229@intel.com/
[2] https://lore.kernel.org/lkml/20210204131002.GA17068@zn.tnic/

\
 
 \ /
  Last update: 2021-03-29 20:16    [W:0.235 / U:4.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site