[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRZDu2Rk+KdRhh1U@zn.tnic>
Date: Fri, 13 Aug 2021 12:04:43 +0200
From: Borislav Petkov <bp@...en8.de>
To: "Bae, Chang Seok" <chang.seok.bae@...el.com>
Cc: "Lutomirski, Andy" <luto@...nel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...nel.org" <mingo@...nel.org>,
"x86@...nel.org" <x86@...nel.org>,
"Brown, Len" <len.brown@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>,
"Macieira, Thiago" <thiago.macieira@...el.com>,
"Liu, Jing2" <jing2.liu@...el.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v9 08/26] x86/fpu/xstate: Introduce helpers to manage the
XSTATE buffer dynamically
On Fri, Aug 13, 2021 at 08:04:54AM +0000, Bae, Chang Seok wrote:
> Yes, each state offset in the non-compacted format is fixed in a machine
> regardless of RFBM. So, simply take the size like that.
Comment above it please.
Also, why is this special case needed at all?
> But it might be better to simplify this hunk for readability. I
> suspect its call sites are not that performance-critical.
That's *exactly* what I'm driving at!
> Every task’s state_mask should begin as aligned with the default buffer.
> fpu_clone() sets this for all, except init_task.
> Maybe:
> “Make sure init_task’s state_mask aligned with its __default_state"
Why "make sure"?
There's nothing to make sure - it is simply so that initially, the FPU
buffer used is the static one, without dynamic states. Just say that
instead.
> How about enlarge_xstate_buffer() or realloc_xstate_buffer()?
realloc is fine along with a proper explanation above it why the realloc
is done/needed.
> The query is intended to check whether the xstate buffer is fully expanded or
> not -- no need to enlarge.
>
> If the buffer is already the maximum, the code to retrieve XSTATE_BV, this
> call, etc should be skipped there.
>
> If the query is moved here, I guess this call site code becomes a bit ugly.
Why does it become ugly?
You simply return early without touching the buffer at all.
> No, it is still pointed by fpu->state and will be freed in the exit path.
Exit path of the task?
All I see is "return -ENOMEM" and no callers of alloc_xstate_buffer()
are calling free_xstate_buffer()...
And looking further into the patchset:
exc_device_not_available does not call free_xstate_buffer() I'm assuming
force_sig_fault(SIGILL, ILL_ILLOPC,..
later will cause arch_release_task_struct() to happen which will call
free_xstate_buffer(). Yes, no?
I don't see any freeing in xstateregs_set() either, so what's happening
there when it returns -ENOMEM?
I guess there we remain with the old buffer, i.e., the ptrace operation
fails.
Am I close?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists