Skip to contentSkip to conversation

x86/fpu: fix compile error without kernel_fpu_disabled()

PATCH In review [email protected] 3 participants 3 messages May 16, 2022 – May 24, 2022 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/fpu: fix compile error without kernel_fpu_disabled()

From: Jamie <[email protected]>

In v5.18-evl-rebase, function kernel_fpu_disabled() has been removed in
commit 59f5ede3bc0f("x86/fpu: Prevent FPU state corruption"), so we will
get compile error when CONFIG_DOVETAIL is enabled:
arch/x86/kernel/fpu/core.c:931:6: error: implicit declaration of function ‘kernel_fpu_disabled’; did you mean ‘perf_pmu_disable’? [-Werror=implicit-function-declaration]

  if (kernel_fpu_disabled()) {
      ^~~~~~~~~~~~~~~~~~~
      perf_pmu_disable

cc1: all warnings being treated as errors
So, fix it.

---
 arch/x86/kernel/fpu/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/fpu/core.c +1 -1
index 6a0d1e7f278f..c3adbbb73226 100644
@@ -928,7 +928,7 @@ void fpu__suspend_inband(void)
 	 * preemption of an inband kernel context currently using the
 	 * fpu by a thread which resumes on the oob stage.
 	 */
-	if (kernel_fpu_disabled()) {
+	if (this_cpu_read(in_kernel_fpu)) {
 		save_fpregs_to_fpstate(kfpu);
 		__cpu_invalidate_fpregs_state();
 		oob_fpu_set_preempt(&tsk->thread.fpu);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Jamie Huang via Xenomai

From: Jamie <[email protected]>

It's up to Jan but I guess a complete name would be nice here. Same fore the Signed-off-by below.

Quoted 21 lines

In v5.18-evl-rebase, function kernel_fpu_disabled() has been removed in
commit 59f5ede3bc0f("x86/fpu: Prevent FPU state corruption"), so we will
get compile error when CONFIG_DOVETAIL is enabled:
arch/x86/kernel/fpu/core.c:931:6: error: implicit declaration of function ‘kernel_fpu_disabled’; did you mean ‘perf_pmu_disable’? [-Werror=implicit-function-declaration]

  if (kernel_fpu_disabled()) {
      ^~~~~~~~~~~~~~~~~~~
      perf_pmu_disable

cc1: all warnings being treated as errors
So, fix it.

---
 arch/x86/kernel/fpu/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/fpu/core.c +0 -0
index 6a0d1e7f278f..c3adbbb73226 100644

arch/x86/kernel/fpu/core.c void fpu__suspend_inband(void) · line 934

Quoted 8 lines
arch/x86/kernel/fpu/core.c +1 -1
@@ -928,7 +928,7 @@ void fpu__suspend_inband(void)
 	 * preemption of an inband kernel context currently using the
 	 * fpu by a thread which resumes on the oob stage.
 	 */
-	if (kernel_fpu_disabled()) {
+	if (this_cpu_read(in_kernel_fpu)) {
 		save_fpregs_to_fpstate(kfpu);
 		__cpu_invalidate_fpregs_state();
 		oob_fpu_set_preempt(&tsk->thread.fpu);

I noticed that while investigating the FPU test issue that I already reported, but missed that we already have a dovetail branch which is affected.

Non-Git reference would be
https://lore.kernel.org/lkml/[email protected]/

Best regards,
Florian Bezdeka

#2 lore raw
Quoted 5 lines · Florian via Xenomai
Quoted 1 line · Jamie Huang via Xenomai

From: Jamie <[email protected]>

It's up to Jan but I guess a complete name would be nice here. Same fore the Signed-off-by below.

Philippe is maintaining the dovetail tree but, yes, we generally need a real name to be able to check back regarding
https://developercertificate.org if any questions should arise in the future.

Jan

Quoted 44 lines
Quoted 22 lines

In v5.18-evl-rebase, function kernel_fpu_disabled() has been removed in
commit 59f5ede3bc0f("x86/fpu: Prevent FPU state corruption"), so we will
get compile error when CONFIG_DOVETAIL is enabled:
arch/x86/kernel/fpu/core.c:931:6: error: implicit declaration of function ‘kernel_fpu_disabled’; did you mean ‘perf_pmu_disable’? [-Werror=implicit-function-declaration]

  if (kernel_fpu_disabled()) {
      ^~~~~~~~~~~~~~~~~~~
      perf_pmu_disable

cc1: all warnings being treated as errors
So, fix it.

---
 arch/x86/kernel/fpu/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/fpu/core.c +0 -0
index 6a0d1e7f278f..c3adbbb73226 100644

arch/x86/kernel/fpu/core.c void fpu__suspend_inband(void) · line 934

Quoted 8 lines
arch/x86/kernel/fpu/core.c +1 -1
@@ -928,7 +928,7 @@ void fpu__suspend_inband(void)
 	 * preemption of an inband kernel context currently using the
 	 * fpu by a thread which resumes on the oob stage.
 	 */
-	if (kernel_fpu_disabled()) {
+	if (this_cpu_read(in_kernel_fpu)) {
 		save_fpregs_to_fpstate(kfpu);
 		__cpu_invalidate_fpregs_state();
 		oob_fpu_set_preempt(&tsk->thread.fpu);

I noticed that while investigating the FPU test issue that I already reported, but missed that we already have a dovetail branch which is affected.

Non-Git reference would be
https://lore.kernel.org/lkml/[email protected]/

Best regards,
Florian Bezdeka

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux