linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: MIPS/Emulate: Fix preemption warning
@ 2017-03-14  0:05 James Hogan
  2017-03-14  0:05 ` James Hogan
  2017-03-15 14:15 ` Ralf Baechle
  0 siblings, 2 replies; 3+ messages in thread
From: James Hogan @ 2017-03-14  0:05 UTC (permalink / raw)
  To: linux-mips
  Cc: Paolo Bonzini, Radim Krčmář,
	Ralf Baechle, kvm, stable, James Hogan

Host kernels with preemption enabled will emit the following preemption
warning when the guest FPU is used:

BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1495
caller is kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
...
Call Trace:
[<ffffffff81122d50>] show_stack+0x88/0xa8
[<ffffffff814307ac>] dump_stack+0x9c/0xd0
[<ffffffff81459f24>] check_preemption_disabled+0x124/0x130
[<ffffffffc000e908>] kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
[<ffffffffc000f9f0>] kvm_mips_emulate_inst+0x190/0x268 [kvm]
[<ffffffffc0016220>] kvm_trap_emul_handle_cop_unusable+0x48/0x160 [kvm]
[<ffffffffc000c120>] kvm_mips_handle_exit+0x520/0x7e0 [kvm]

This is due to the use of current_cpu_data.fpu_id from a preemptible
context to read the MIPS_FPIR_F64 bit. We don't currently support
asymmetric FPU capabilities with KVM, so just use boot_cpu_data instead
to silence the warning.

Fixes: 6cdc65e31d4f ("MIPS: KVM: Emulate FPU bits in COP0 interface")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Cc: <stable@vger.kernel.org> # 4.1.x-
---
 arch/mips/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index d40cfaad4529..9bc55619252a 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -1279,7 +1279,7 @@ enum emulation_result kvm_mips_emulate_CP0(union mips_instruction inst,
 				 * Also don't allow FR to be set if host doesn't
 				 * support it.
 				 */
-				if (!(current_cpu_data.fpu_id & MIPS_FPIR_F64))
+				if (!(boot_cpu_data.fpu_id & MIPS_FPIR_F64))
 					val &= ~ST0_FR;
 
 
-- 
2.11.1

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

* [PATCH] KVM: MIPS/Emulate: Fix preemption warning
  2017-03-14  0:05 [PATCH] KVM: MIPS/Emulate: Fix preemption warning James Hogan
@ 2017-03-14  0:05 ` James Hogan
  2017-03-15 14:15 ` Ralf Baechle
  1 sibling, 0 replies; 3+ messages in thread
From: James Hogan @ 2017-03-14  0:05 UTC (permalink / raw)
  To: linux-mips
  Cc: Paolo Bonzini, Radim Krčmář,
	Ralf Baechle, kvm, stable, James Hogan

Host kernels with preemption enabled will emit the following preemption
warning when the guest FPU is used:

BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1495
caller is kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
...
Call Trace:
[<ffffffff81122d50>] show_stack+0x88/0xa8
[<ffffffff814307ac>] dump_stack+0x9c/0xd0
[<ffffffff81459f24>] check_preemption_disabled+0x124/0x130
[<ffffffffc000e908>] kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
[<ffffffffc000f9f0>] kvm_mips_emulate_inst+0x190/0x268 [kvm]
[<ffffffffc0016220>] kvm_trap_emul_handle_cop_unusable+0x48/0x160 [kvm]
[<ffffffffc000c120>] kvm_mips_handle_exit+0x520/0x7e0 [kvm]

This is due to the use of current_cpu_data.fpu_id from a preemptible
context to read the MIPS_FPIR_F64 bit. We don't currently support
asymmetric FPU capabilities with KVM, so just use boot_cpu_data instead
to silence the warning.

Fixes: 6cdc65e31d4f ("MIPS: KVM: Emulate FPU bits in COP0 interface")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Cc: <stable@vger.kernel.org> # 4.1.x-
---
 arch/mips/kvm/emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index d40cfaad4529..9bc55619252a 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -1279,7 +1279,7 @@ enum emulation_result kvm_mips_emulate_CP0(union mips_instruction inst,
 				 * Also don't allow FR to be set if host doesn't
 				 * support it.
 				 */
-				if (!(current_cpu_data.fpu_id & MIPS_FPIR_F64))
+				if (!(boot_cpu_data.fpu_id & MIPS_FPIR_F64))
 					val &= ~ST0_FR;
 
 
-- 
2.11.1

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

* Re: [PATCH] KVM: MIPS/Emulate: Fix preemption warning
  2017-03-14  0:05 [PATCH] KVM: MIPS/Emulate: Fix preemption warning James Hogan
  2017-03-14  0:05 ` James Hogan
@ 2017-03-15 14:15 ` Ralf Baechle
  1 sibling, 0 replies; 3+ messages in thread
From: Ralf Baechle @ 2017-03-15 14:15 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-mips, Paolo Bonzini, Radim Krčmář, kvm, stable

On Tue, Mar 14, 2017 at 12:05:15AM +0000, James Hogan wrote:

> Host kernels with preemption enabled will emit the following preemption
> warning when the guest FPU is used:
> 
> BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1495
> caller is kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
> ...
> Call Trace:
> [<ffffffff81122d50>] show_stack+0x88/0xa8
> [<ffffffff814307ac>] dump_stack+0x9c/0xd0
> [<ffffffff81459f24>] check_preemption_disabled+0x124/0x130
> [<ffffffffc000e908>] kvm_mips_emulate_CP0+0xa48/0xea0 [kvm]
> [<ffffffffc000f9f0>] kvm_mips_emulate_inst+0x190/0x268 [kvm]
> [<ffffffffc0016220>] kvm_trap_emul_handle_cop_unusable+0x48/0x160 [kvm]
> [<ffffffffc000c120>] kvm_mips_handle_exit+0x520/0x7e0 [kvm]
> 
> This is due to the use of current_cpu_data.fpu_id from a preemptible
> context to read the MIPS_FPIR_F64 bit. We don't currently support
> asymmetric FPU capabilities with KVM, so just use boot_cpu_data instead
> to silence the warning.
> 
> Fixes: 6cdc65e31d4f ("MIPS: KVM: Emulate FPU bits in COP0 interface")
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: linux-mips@linux-mips.org
> Cc: kvm@vger.kernel.org
> Cc: <stable@vger.kernel.org> # 4.1.x-

Acked-by: Ralf Baechle <ralf@linux-mips.org>

James, we've fixed too many of these warnings over the past years, we
should look for a solution to kill this whole class of bugs.

  Ralf

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

end of thread, other threads:[~2017-03-15 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14  0:05 [PATCH] KVM: MIPS/Emulate: Fix preemption warning James Hogan
2017-03-14  0:05 ` James Hogan
2017-03-15 14:15 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).