kvm-ppc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@linux.ibm.com>
To: kvm-ppc@vger.kernel.org
Cc: mario@locati.it, balaton@eik.bme.hu, mihai.caraman@freescale.com,
	linuxppc-dev@lists.ozlabs.org
Subject: [RFC PATCH] KVM: PPC: BookE: Load FP and Altivec state before soft enabling IRQs
Date: Mon, 12 Jul 2021 21:35:37 +0000	[thread overview]
Message-ID: <20210712213537.2204009-1-farosas@linux.ibm.com> (raw)

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: <mario@locati.it>
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
 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

                 reply	other threads:[~2021-07-12 21:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210712213537.2204009-1-farosas@linux.ibm.com \
    --to=farosas@linux.ibm.com \
    --cc=balaton@eik.bme.hu \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mario@locati.it \
    --cc=mihai.caraman@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).