tree:
https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git x86/fixes
head: ab06bcee91bb7cbf6dc6af7e828cefafc6a54eee
commit: 9bb0e10e9d6c804979c5aa0408a12daa9c9a1afe [22/23] x86/fpu: Add
kernel_fpu_begin_mask() to selectively initialize state
config: x86_64-rhel (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
#
https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/commit/?id...
git remote add luto
https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git
git fetch --no-tags luto x86/fixes
git checkout 9bb0e10e9d6c804979c5aa0408a12daa9c9a1afe
# save the attached .config to linux build tree
make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
In file included from include/linux/export.h:43,
from include/linux/linkage.h:7,
from arch/x86/include/asm/cache.h:5,
from include/linux/cache.h:6,
from include/linux/time.h:5,
from include/linux/compat.h:10,
from arch/x86/include/asm/fpu/internal.h:14,
from arch/x86/kernel/fpu/core.c:9:
arch/x86/kernel/fpu/core.c: In function 'kernel_fpu_begin_mask':
> arch/x86/kernel/fpu/core.c:150:15: error: 'fpu_mask'
undeclared (first use in this function); did you mean 'kfpu_mask'?
150
| if (unlikely(fpu_mask & KFPU_387)) {
| ^~~~~~~~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
arch/x86/kernel/fpu/core.c:150:15: note: each undeclared identifier is reported only
once for each function it appears in
150 | if (unlikely(fpu_mask & KFPU_387)) {
| ^~~~~~~~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
vim +150 arch/x86/kernel/fpu/core.c
9 #include <asm/fpu/internal.h>
10 #include
<asm/fpu/regset.h>
11 #include <asm/fpu/signal.h>
12 #include <asm/fpu/types.h>
13 #include <asm/traps.h>
14 #include <asm/irq_regs.h>
15
16 #include <linux/hardirq.h>
17 #include <linux/pkeys.h>
18
19 #define CREATE_TRACE_POINTS
20 #include <asm/trace/fpu.h>
21
22 /*
23 * Represents the initial FPU state. It's mostly (but not completely) zeroes,
24 * depending on the FPU hardware format:
25 */
26 union fpregs_state init_fpstate __read_mostly;
27
28 /*
29 * Track whether the kernel is using the FPU state
30 * currently.
31 *
32 * This flag is used:
33 *
34 * - by IRQ context code to potentially use the FPU
35 * if it's unused.
36 *
37 * - to debug kernel_fpu_begin()/end() correctness
38 */
39 static DEFINE_PER_CPU(bool, in_kernel_fpu);
40
41 /*
42 * Track which context is using the FPU on the CPU:
43 */
44 DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
45
46 static bool kernel_fpu_disabled(void)
47 {
48 return this_cpu_read(in_kernel_fpu);
49 }
50
51 static bool interrupted_kernel_fpu_idle(void)
52 {
53 return !kernel_fpu_disabled();
54 }
55
56 /*
57 * Were we in user mode (or vm86 mode) when we were
58 * interrupted?
59 *
60 * Doing kernel_fpu_begin/end() is ok if we are running
61 * in an interrupt context from user mode - we'll just
62 * save the FPU state as required.
63 */
64 static bool interrupted_user_mode(void)
65 {
66 struct pt_regs *regs = get_irq_regs();
67 return regs && user_mode(regs);
68 }
69
70 /*
71 * Can we use the FPU in kernel mode with the
72 * whole "kernel_fpu_begin/end()" sequence?
73 *
74 * It's always ok in process context (ie "not interrupt")
75 * but it is sometimes ok even from an irq.
76 */
77 bool irq_fpu_usable(void)
78 {
79 return !in_interrupt() ||
80 interrupted_user_mode() ||
81 interrupted_kernel_fpu_idle();
82 }
83 EXPORT_SYMBOL(irq_fpu_usable);
84
85 /*
86 * These must be called with preempt disabled. Returns
87 * 'true' if the FPU state is still intact and we can
88 * keep registers active.
89 *
90 * The legacy FNSAVE instruction cleared all FPU state
91 * unconditionally, so registers are essentially destroyed.
92 * Modern FPU state can be kept in registers, if there are
93 * no pending FP exceptions.
94 */
95 int copy_fpregs_to_fpstate(struct fpu *fpu)
96 {
97 if (likely(use_xsave())) {
98 copy_xregs_to_kernel(&fpu->state.xsave);
99
100 /*
101 * AVX512 state is tracked here because its use is
102 * known to slow the max clock speed of the core.
103 */
104 if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512)
105 fpu->avx512_timestamp = jiffies;
106 return 1;
107 }
108
109 if (likely(use_fxsr())) {
110 copy_fxregs_to_kernel(fpu);
111 return 1;
112 }
113
114 /*
115 * Legacy FPU register saving, FNSAVE always clears FPU registers,
116 * so we have to mark them inactive:
117 */
118 asm volatile("fnsave %[fp]; fwait" : [fp] "=m"
(fpu->state.fsave));
119
120 return 0;
121 }
122 EXPORT_SYMBOL(copy_fpregs_to_fpstate);
123
124 void kernel_fpu_begin_mask(unsigned int kfpu_mask)
125 {
126 preempt_disable();
127
128 WARN_ON_FPU(!irq_fpu_usable());
129 WARN_ON_FPU(this_cpu_read(in_kernel_fpu));
130
131 this_cpu_write(in_kernel_fpu, true);
132
133 if (!(current->flags & PF_KTHREAD) &&
134 !test_thread_flag(TIF_NEED_FPU_LOAD)) {
135 set_thread_flag(TIF_NEED_FPU_LOAD);
136 /*
137 * Ignore return value -- we don't care if reg state
138 * is clobbered.
139 */
140 copy_fpregs_to_fpstate(¤t->thread.fpu);
141 }
142 __cpu_invalidate_fpregs_state();
143
144 /* Put sane initial values into the control registers. */
145 if (likely(kfpu_mask & KFPU_XMM)) {
146 if (boot_cpu_has(X86_FEATURE_XMM))
147 ldmxcsr(MXCSR_DEFAULT);
148 }
149
150 if (unlikely(fpu_mask & KFPU_387)) {
151 if
(boot_cpu_has(X86_FEATURE_FPU))
152 asm volatile ("fninit");
153 }
154 }
155 EXPORT_SYMBOL_GPL(kernel_fpu_begin_mask);
156
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org