lkml.org 
[lkml]   [2022]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 3/3] x86/fpu: Make FPU protection more robust
On Sun, May 01, 2022 at 09:31:47PM +0200, Thomas Gleixner wrote:
> +void fpregs_lock(void)
> +{
> + if (!IS_ENABLED(CONFIG_PREEMPT_RT))
> + local_bh_disable();
> + else
> + preempt_disable();
> +
> + WARN_ON_ONCE(this_cpu_read(fpu_in_use));
> + this_cpu_write(fpu_in_use, true);

barrier();
> +}
> +EXPORT_SYMBOL_GPL(fpregs_lock);

> +void fpregs_unlock(void)
> +{
barrier();

> + WARN_ON_ONCE(!this_cpu_read(fpu_in_use));
> + this_cpu_write(fpu_in_use, false);
> +
> + if (!IS_ENABLED(CONFIG_PREEMPT_RT))
> + local_bh_enable();
> + else
> + preempt_enable();
> +}
> +EXPORT_SYMBOL_GPL(fpregs_unlock);

I think this isn't currently a problem because a function call is a C
sequence point, but 'funnily' C doesn't preserve sequence points when
inlining so LTO can actually break this without barrier() on.

\
 
 \ /
  Last update: 2022-05-03 11:04    [W:0.242 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site