linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Denis Kirjanov <kda@linux-powerpc.org>
To: linuxppc-dev@ozlabs.org
Cc: benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@ozlabs.org,
	Denis Kirjanov <kda@linux-powerpc.org>
Subject: [PATCH] kvm: powerpc: book3s: Disable preemption while accessing paca xics_phys filed
Date: Mon, 27 Mar 2017 04:26:54 -0400	[thread overview]
Message-ID: <1490603214-30116-1-git-send-email-kda@linux-powerpc.org> (raw)

With CONFIG_DEBUG_PREEMPT enabled we see the following trace:

[  129.314426] BUG: using smp_processor_id() in preemptible [00000000]
code: modprobe/5459
[  129.314580] caller is .kvmppc_book3s_init_hv+0x184/0x350 [kvm_hv]
[  129.314697] CPU: 11 PID: 5459 Comm: modprobe Not tainted
4.11.0-rc3-00022-gc7e790c #1
[  129.314848] Call Trace:
[  129.314915] [c0000007d624b810] [c0000000023eef10] .dump_stack+0xe4/0x150 (unreliable)
[  129.315065] [c0000007d624b8a0] [c000000001f6ec04] .check_preemption_disabled+0x134/0x150
[  129.315210] [c0000007d624b940] [d00000000a010274] .kvmppc_book3s_init_hv+0x184/0x350 [kvm_hv]
[  129.315339] [c0000007d624ba00] [c00000000191d5cc] .do_one_initcall+0x5c/0x1c0
[  129.315416] [c0000007d624bad0] [c0000000023e9494] .do_init_module+0x84/0x240
[  129.315492] [c0000007d624bb70] [c000000001aade18] .load_module+0x1f68/0x2a10
[  129.315568] [c0000007d624bd20] [c000000001aaeb30] .SyS_finit_module+0xc0/0xf0
[  129.315645] [c0000007d624be30] [c00000000191baec] system_call+0x38/0xfc

Disable preemption while accessing paca struct to avoid inconsistent state

Fixes: f725758 ("KVM: PPC: Book3S HV: Use OPAL XICS emulation on POWER9")
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
 arch/powerpc/kvm/book3s_hv.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 1ec86d9..8e96bab 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3913,6 +3913,10 @@ static int kvmppc_radix_possible(void)
 static int kvmppc_book3s_init_hv(void)
 {
 	int r;
+#ifdef CONFIG_SMP
+	unsigned long xics_phys;
+#endif
+
 	/*
 	 * FIXME!! Do we need to check on all cpus ?
 	 */
@@ -3930,7 +3934,11 @@ static int kvmppc_book3s_init_hv(void)
 	 * indirectly, via OPAL.
 	 */
 #ifdef CONFIG_SMP
-	if (!get_paca()->kvm_hstate.xics_phys) {
+	preempt_disable();
+	xics_phys = get_paca()->kvm_hstate.xics_phys;
+	preempt_enable();
+
+	if (!xics_phys) {
 		struct device_node *np;
 
 		np = of_find_compatible_node(NULL, NULL, "ibm,opal-intc");
-- 
1.8.3.1

             reply	other threads:[~2017-03-27  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27  8:26 Denis Kirjanov [this message]
2017-03-29  1:07 ` [PATCH] kvm: powerpc: book3s: Disable preemption while accessing paca xics_phys filed Michael Ellerman
2017-03-29  8:54   ` Denis Kirjanov
2017-03-29  9:37   ` Paul Mackerras
2017-03-29  9:45     ` Denis Kirjanov
2017-03-29 10:46       ` Michael Ellerman

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=1490603214-30116-1-git-send-email-kda@linux-powerpc.org \
    --to=kda@linux-powerpc.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.org \
    /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 NNTP newsgroup(s).