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 <k...@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