Re: [PATCH 11/29] x86/fpu: Always init the `state' in fpu__clear()

From: Borislav Petkov
Date: Wed Dec 12 2018 - 12:11:41 EST


On Wed, Nov 28, 2018 at 11:20:17PM +0100, Sebastian Andrzej Siewior wrote:
> fpu__clear() only initializes the `state' if the FPU is present. This
> initialisation is also required for the FPU-less system and takes place
> math_emulate(). Since fpu__initialize() only performs the initialization
> if ->initialized is zero it does not matter that it is invoked each time
> an opcode is emulated. It makes the removal of ->initialized easier if
> the struct is also initialized in FPU-less case at the same time.
>
> Move fpu__initialize() before the FPU check so it is also performed in
> FPU-less case.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
> arch/x86/include/asm/fpu/internal.h | 1 -
> arch/x86/kernel/fpu/core.c | 5 ++---
> arch/x86/math-emu/fpu_entry.c | 3 ---
> 3 files changed, 2 insertions(+), 7 deletions(-)

...

> diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
> index 9e2ba7e667f61..a873da6b46d6b 100644
> --- a/arch/x86/math-emu/fpu_entry.c
> +++ b/arch/x86/math-emu/fpu_entry.c
> @@ -113,9 +113,6 @@ void math_emulate(struct math_emu_info *info)
> unsigned long code_base = 0;
> unsigned long code_limit = 0; /* Initialized to stop compiler warnings */
> struct desc_struct code_descriptor;
> - struct fpu *fpu = &current->thread.fpu;
> -
> - fpu__initialize(fpu);

Ok, you're removing it here but where is the FPU going to be initialized
now in the FPU-less case?

IOW, it is not clear to me where fpu__clear() get called for the FPU
emulation case now...

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.