The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Jiaxun Yang <jiaxun.yang@flygoat.com>, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
	chang.seok.bae@intel.com, linux-kernel@vger.kernel.org,
	Jiaxun Yang <j.yang-87@sms.ed.ac.uk>
Subject: Re: [RFC PATCH 07/10] x86/fpu: Rellocate fpstate on save_fpregs_to_fpstate
Date: Fri, 3 Dec 2021 07:18:31 -0800	[thread overview]
Message-ID: <e4d3d685-eddd-a240-eea5-949637809fed@intel.com> (raw)
In-Reply-To: <57665273-e56e-4b66-9dbd-003d592eb65d@www.fastmail.com>

On 12/3/21 3:39 AM, Jiaxun Yang wrote:
>>>  	if (likely(use_xsave())) {
>>> +		xstate_update_size(fpu);
>>>  		os_xsave(fpu->fpstate);
>>>  		update_avx_timestamp(fpu);
>>>  		return;
>> Have you considered what exactly happens when you hit that WARN_ON_FPU()
>> which otherwise ignores the allocation error?  Have you considered what
>> happens on the os_xsave() that follows it immediately?  How about what
>> happens the next time this task runs after that failure?
> Thank you for the catch.
> This is a few questions that I don't have answer, so it's a RFC.
> 
> I thought it is unlikely to happen as kmalloc has emergency pool.
> But in case it happens, I guess the best way to handle it is just
> send SIGILL to corresponding user process or panic if it's kernel
> fpu use?

We've thought a *LOT* about this exact problem over the past few years.

Intel even added hardware (XFD) to prevent the situation where you land
in the context switch code, fail a memory allocation, and have to
destroy user data in registers.  Without XFD, there are also zero ways
to avoid this happening to apps, *other* than preallocating the memory
in the first place.

I don't think there is *any* viable path forward with this series.

  reply	other threads:[~2021-12-03 15:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  0:36 [RFC PATCH 00/10] x86: Allocate AVX512 xstate ondemand Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 01/10] x86/fpu: Remove duplicated declaration of __fpu_state_size_dynamic Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 02/10] x86/fpu: Split fpu_xfd_enabled from fpu_state_size_dynamic Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 03/10] x86/fpu: Calculate xsave state addr on fly Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 04/10] x86/fpu: Remove xstate_comp_offsets cache Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 05/10] x86/fpu: Cache xstate_is_aligned Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 06/10] x86/fpu/xcr: Return all enabled xfeature if CPU doesn't support Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 07/10] x86/fpu: Rellocate fpstate on save_fpregs_to_fpstate Jiaxun Yang
2021-12-03  0:44   ` Dave Hansen
2021-12-03 11:39     ` Jiaxun Yang
2021-12-03 15:18       ` Dave Hansen [this message]
2021-12-03 15:51         ` Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 08/10] x86/fpu: Don't keep state_size in perm struct Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 09/10] x86/fpu: Split out XFEATURE_MASK_KERNEL_DYNAMIC Jiaxun Yang
2021-12-03  0:36 ` [RFC PATCH 10/10] x86/fpu: Mark AVX512 xfeatures as kernel dynamic Jiaxun Yang
2021-12-03  0:40 ` [RFC PATCH 00/10] x86: Allocate AVX512 xstate ondemand Dave Hansen
2021-12-03  0:45   ` Jiaxun Yang
2021-12-03  0:58     ` Dave Hansen
2021-12-03  9:20       ` David Laight
2021-12-03 11:42       ` Jiaxun Yang
2021-12-03 11:51         ` Borislav Petkov
2021-12-03 11:55           ` Jiaxun Yang
2021-12-04 11:55 ` Peter Zijlstra

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=e4d3d685-eddd-a240-eea5-949637809fed@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=j.yang-87@sms.ed.ac.uk \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox