[RFC PATCH] KVM: PPC: BookE: Load FP and Altivec state before soft enabling IRQs

Fabiano Rosas <[email protected]>
Newsgroups org.kernel.vger.kvm-ppc,org.ozlabs.lists.linuxppc-dev
Message-ID <[email protected]>
The kvmppc_fix_ee_before_entry function sets the IRQ soft mask to
IRQS_ENABLED. This function is called right before loading the guest
FP and Altivec states at kvmppc_handle_exit. This triggers a
WARN_ON(preemptible()) at enable_kernel_fp/altivec when running with
CONFIG_PREEMPT_COUNT=y:

WARNING: CPU: 1 PID: 6585 at .enable_kernel_fp+0x30/0x78
Modules linked in: r8153_ecm cdc_ether usbnet r8152 uio_pdrv_genirq uio
CPU: 1 PID: 6585 Comm: qemu-system-ppc Tainted: G        W         5.12.10_e6500 #1
NIP:  c000000000003ec0 LR: c00000000004fb00 CTR: 0000000000000004
REGS: c0000000b38ab440 TRAP: 0700   Tainted: G        W          (5.12.10_e6500)
MSR:  0000000082023002 <VEC,CE,FP,ME>  CR: 24000208  XER: 00000000
IRQMASK: 0
GPR00: c00000000004fb00 c0000000b38ab6e0 c000000001a4e300 c0000000b3878000
GPR04: 0000000000000010 0000000080000003 0000000000000000 0000000000000000
GPR08: 00000000fe662000 0000000000000001 0000000000000000 0000000000000001
GPR12: 0000000024000208 c00000003ffff8c0 c0000000b3878000 c00000000183eb60
GPR16: 0000000000000000 0000000000000000 c0000000020a8d80 0000000000000001
GPR20: 0000000000000000 c000000001ab1a70 c0000000020a8d80 c0000000020a8d80
GPR24: c00000000183ed48 c0000000017c8ec0 c00000000183eec0 c0000000000b80e0
GPR28: 0000000000000000 00000000000b80e0 0000000000000000 c0000000b3878000
NIP [c000000000003ec0] .enable_kernel_fp+0x30/0x78
LR [c00000000004fb00] .kvmppc_load_guest_fp+0x2c/0x80
Call Trace:
[c0000000b38ab6e0] [c00000000183ed48] rcu_state+0x248/0x400 (unreliable)
[c0000000b38ab750] [c00000000004fb00] .kvmppc_load_guest_fp+0x2c/0x80
[c0000000b38ab7d0] [c000000000050f48] .kvmppc_handle_exit+0x5cc/0x5d8
[c0000000b38ab870] [c000000000053e64] .kvmppc_resume_host+0xcc/0x120
Instruction dump:
7c0802a6 f8010010 f821ff91 e92d0658 81490000 39200000 2c0a0000 40c20014
892d067a 552907fe 7d290034 5529d97e <0b090000> 38602000 4bfffe79 e86d0658

I'm assuming this was an oversight while introducing the call to
kvmppc_load_guest_fp and kvmppc_load_guest_altivec functions from
kvmppc_handle_exit. So this patch moves kvmppc_fix_ee_before_entry to
be again the last thing before exiting kvmppc_handle_exit.

Compile tested only since I don't have a BookE machine.

Fixes: 3efc7da61f6c ("KVM: PPC: Book3E: Increase FPU laziness")
Fixes: 95d80a294b1e ("KVM: PPC: Book3e: Add AltiVec support")
Reported-by: <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
---
 arch/powerpc/kvm/booke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 551b30d84aee..38179c45eb90 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1387,9 +1387,9 @@ int kvmppc_handle_exit(struct kvm_vcpu *vcpu, unsigned int exit_nr)
 			r = (s << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);
 		else {
 			/* interrupts now hard-disabled */
-			kvmppc_fix_ee_before_entry();
 			kvmppc_load_guest_fp(vcpu);
 			kvmppc_load_guest_altivec(vcpu);
+			kvmppc_fix_ee_before_entry();
 		}
 	}
 
-- 
2.29.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.