All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: avoid BUG warning in arch_check_elf
@ 2017-04-11 12:51 ` James Cowgill
  0 siblings, 0 replies; 3+ messages in thread
From: James Cowgill @ 2017-04-11 12:51 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips; +Cc: James.Cowgill

arch_check_elf contains a usage of current_cpu_data that will call
smp_processor_id() with preemption enabled and therefore triggers a
"BUG: using smp_processor_id() in preemptible" warning when an fpxx
executable is loaded.

As a follow-up to commit b244614a60ab ("MIPS: Avoid a BUG warning during
prctl(PR_SET_FP_MODE, ...)"), apply the same fix to arch_check_elf by
using raw_current_cpu_data instead. The rationale quoted from the previous
commit:

"It is assumed throughout the kernel that if any CPU has an FPU, then
all CPUs would have an FPU as well, so it is safe to perform the check
with preemption enabled - change the code to use raw_ variant of the
check to avoid the warning."

Fixes: 46490b572544 ("MIPS: kernel: elf: Improve the overall ABI and FPU mode checks")
Signed-off-by: James Cowgill <James.Cowgill@imgtec.com>
CC: <stable@vger.kernel.org> # 4.0+
---
 arch/mips/kernel/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c
index 6430bff21fff..5c429d70e17f 100644
--- a/arch/mips/kernel/elf.c
+++ b/arch/mips/kernel/elf.c
@@ -257,7 +257,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr,
 	else if ((prog_req.fr1 && prog_req.frdefault) ||
 		 (prog_req.single && !prog_req.frdefault))
 		/* Make sure 64-bit MIPS III/IV/64R1 will not pick FR1 */
-		state->overall_fp_mode = ((current_cpu_data.fpu_id & MIPS_FPIR_F64) &&
+		state->overall_fp_mode = ((raw_current_cpu_data.fpu_id & MIPS_FPIR_F64) &&
 					  cpu_has_mips_r2_r6) ?
 					  FP_FR1 : FP_FR0;
 	else if (prog_req.fr1)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] MIPS: avoid BUG warning in arch_check_elf
@ 2017-04-11 12:51 ` James Cowgill
  0 siblings, 0 replies; 3+ messages in thread
From: James Cowgill @ 2017-04-11 12:51 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips; +Cc: James.Cowgill

arch_check_elf contains a usage of current_cpu_data that will call
smp_processor_id() with preemption enabled and therefore triggers a
"BUG: using smp_processor_id() in preemptible" warning when an fpxx
executable is loaded.

As a follow-up to commit b244614a60ab ("MIPS: Avoid a BUG warning during
prctl(PR_SET_FP_MODE, ...)"), apply the same fix to arch_check_elf by
using raw_current_cpu_data instead. The rationale quoted from the previous
commit:

"It is assumed throughout the kernel that if any CPU has an FPU, then
all CPUs would have an FPU as well, so it is safe to perform the check
with preemption enabled - change the code to use raw_ variant of the
check to avoid the warning."

Fixes: 46490b572544 ("MIPS: kernel: elf: Improve the overall ABI and FPU mode checks")
Signed-off-by: James Cowgill <James.Cowgill@imgtec.com>
CC: <stable@vger.kernel.org> # 4.0+
---
 arch/mips/kernel/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c
index 6430bff21fff..5c429d70e17f 100644
--- a/arch/mips/kernel/elf.c
+++ b/arch/mips/kernel/elf.c
@@ -257,7 +257,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr,
 	else if ((prog_req.fr1 && prog_req.frdefault) ||
 		 (prog_req.single && !prog_req.frdefault))
 		/* Make sure 64-bit MIPS III/IV/64R1 will not pick FR1 */
-		state->overall_fp_mode = ((current_cpu_data.fpu_id & MIPS_FPIR_F64) &&
+		state->overall_fp_mode = ((raw_current_cpu_data.fpu_id & MIPS_FPIR_F64) &&
 					  cpu_has_mips_r2_r6) ?
 					  FP_FR1 : FP_FR0;
 	else if (prog_req.fr1)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: avoid BUG warning in arch_check_elf
  2017-04-11 12:51 ` James Cowgill
  (?)
@ 2017-04-12 14:16 ` Ralf Baechle
  -1 siblings, 0 replies; 3+ messages in thread
From: Ralf Baechle @ 2017-04-12 14:16 UTC (permalink / raw)
  To: James Cowgill; +Cc: linux-mips

On Tue, Apr 11, 2017 at 01:51:07PM +0100, James Cowgill wrote:

> arch_check_elf contains a usage of current_cpu_data that will call
> smp_processor_id() with preemption enabled and therefore triggers a
> "BUG: using smp_processor_id() in preemptible" warning when an fpxx
> executable is loaded.
> 
> As a follow-up to commit b244614a60ab ("MIPS: Avoid a BUG warning during
> prctl(PR_SET_FP_MODE, ...)"), apply the same fix to arch_check_elf by
> using raw_current_cpu_data instead. The rationale quoted from the previous
> commit:
> 
> "It is assumed throughout the kernel that if any CPU has an FPU, then
> all CPUs would have an FPU as well, so it is safe to perform the check
> with preemption enabled - change the code to use raw_ variant of the
> check to avoid the warning."

Which really is a bug though.  Multiprocessor systems with discrete CPUs
may use a mix of CPU versions and sometimes the associated FPUs were so
broken the kernel can't use them.  On MT with MIPS_MT_FPAFF there's only a
single FPU which stays associated with CPU 0 and we try to do terribly
clever games to force floating point intensive jobs to be scheduled to CPU 0
and use emulation on all other CPUs.

  Ralf

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-12 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 12:51 [PATCH] MIPS: avoid BUG warning in arch_check_elf James Cowgill
2017-04-11 12:51 ` James Cowgill
2017-04-12 14:16 ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.