lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 26 Mar 2024 22:54:36 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org, Andy Lutomirski <luto@...capital.net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Dave Hansen <dave@...1.net>, Peter Zijlstra <peterz@...radead.org>,
	Borislav Petkov <bp@...en8.de>, "H . Peter Anvin" <hpa@...or.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Uros Bizjak <ubizjak@...il.com>
Subject: Re: [PATCH 1/1] headers/deps: x86/fpu: Make task_struct::thread
 constant size

On 03/26, Ingo Molnar wrote:
>
> * Oleg Nesterov <oleg@...hat.com> wrote:
>
> > > +static struct fpu x86_init_fpu __read_mostly;
> > > +
> > >  static void __init fpu__init_system_early_generic(void)
> > >  {
> > > +	{
> > > +		int this_cpu = smp_processor_id();
> > > +
> > > +		fpstate_reset(&x86_init_fpu);
> > > +		current->thread.fpu = &x86_init_fpu;
> > > +		per_cpu(fpu_fpregs_owner_ctx, this_cpu) = &x86_init_fpu;
> > > +		x86_init_fpu.last_cpu = this_cpu;
> > > +	}
> >
> > Can't x86_init_fpu be declared inside the block above?
>
> As a function-local static? I think globals are better defined in a visible
> fashion, not hidden among local variables where they are easy to overlook.

OK, but please see below.

> Yeah. Something like the delta patch below?

LGTM. And the whole patch too, although I don't think I can review it ;)

but... Ingo, let me ask 2 stupid questions.

1. Can you split this patch? I mean, 1/2 should add something like

	struct fpu *x86_task_fpu(struct task_struct *task)
	{
		return &target->thread.fpu;
	}

    somewhere in arch/x86/include and update all the users of ->thread.fpu
    to use the new helper. No functional changes.

    This way 2/2 which actually turns .fpu into a pointer will be MUCH simpler.

2. Now, 2/2 should change the new helper above to

		return target->thread.fpu;

   But! why do we need the thread_struct.fpu pointer at all? Can't we simply have

	struct fpu *x86_task_fpu(struct task_struct *task)
	{
		return (void *)task + sizeof(*task);
	}

   ? This is what fpu_clone() (with your patch) does anyway.

   Yes, this needs some changes:

   	- exit_thread() - trivial

	- arch_dup_task_struct() clears thread.fpu, but I guess this is unnecessary

	- fpu_clone() initializes dst->thread.fpu, no longer needed

	- finally, fpu__init_system_early_generic() which initializes the
	  init_task.thread.fpu pointer.

	  But this doesn't look difficult? Although I don't understand the magic in
	  arch/x86/kernel/vmlinux.lds.S ...

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ