linux-stable/arch/powerpc/kvm
Cédric Le Goater 3f57d4b477 KVM: PPC: Book3S HV: XIVE: Free escalation interrupts before disabling the VP
[ Upstream commit 237aed48c6 ]

When a vCPU is brought done, the XIVE VP (Virtual Processor) is first
disabled and then the event notification queues are freed. When freeing
the queues, we check for possible escalation interrupts and free them
also.

But when a XIVE VP is disabled, the underlying XIVE ENDs also are
disabled in OPAL. When an END (Event Notification Descriptor) is
disabled, its ESB pages (ESn and ESe) are disabled and loads return all
1s. Which means that any access on the ESB page of the escalation
interrupt will return invalid values.

When an interrupt is freed, the shutdown handler computes a 'saved_p'
field from the value returned by a load in xive_do_source_set_mask().
This value is incorrect for escalation interrupts for the reason
described above.

This has no impact on Linux/KVM today because we don't make use of it
but we will introduce in future changes a xive_get_irqchip_state()
handler. This handler will use the 'saved_p' field to return the state
of an interrupt and 'saved_p' being incorrect, softlockup will occur.

Fix the vCPU cleanup sequence by first freeing the escalation interrupts
if any, then disable the XIVE VP and last free the queues.

Fixes: 90c73795af ("KVM: PPC: Book3S HV: Add a new KVM device for the XIVE native exploitation mode")
Fixes: 5af5099385 ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190806172538.5087-1-clg@kaod.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-10-11 18:18:43 +02:00
..
book3s.c KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list 2019-06-22 08:16:17 +02:00
book3s.h
book3s_32_mmu.c
book3s_32_mmu_host.c
book3s_32_sr.S
book3s_64_mmu.c KVM: PPC: Book3S PR: Fix WIMG handling under pHyp 2018-01-17 09:45:24 +01:00
book3s_64_mmu_host.c
book3s_64_mmu_hv.c KVM: PPC: Book3S HV: Don't truncate HPTE index in xlate function 2018-10-10 08:54:19 +02:00
book3s_64_mmu_radix.c KVM: PPC: Book3S HV: Fix handling of large pages in radix page fault handler 2018-05-16 10:10:31 +02:00
book3s_64_slb.S
book3s_64_vio.c KVM: PPC: Book3S: Fix incorrect guest-to-user-translation error handling 2019-09-06 10:21:00 +02:00
book3s_64_vio_hv.c KVM: PPC: Book3S: Fix incorrect guest-to-user-translation error handling 2019-09-06 10:21:00 +02:00
book3s_emulate.c
book3s_exports.c
book3s_hv.c KVM: PPC: Book3S HV: Don't lose pending doorbell request on migration on P9 2019-10-11 18:18:29 +02:00
book3s_hv_builtin.c
book3s_hv_hmi.c
book3s_hv_interrupts.S
book3s_hv_ras.c
book3s_hv_rm_mmu.c KVM: PPC: Book3S HV: trace_tlbie must not be called in realmode 2018-04-19 08:56:17 +02:00
book3s_hv_rm_xics.c
book3s_hv_rm_xive.c
book3s_hv_rmhandlers.S KVM: PPC: Book3S HV: Fix trap number return from __kvmppc_vcore_entry 2018-05-16 10:10:25 +02:00
book3s_interrupts.S
book3s_mmu_hpte.c
book3s_paired_singles.c
book3s_pr.c KVM: PPC: Book3S PR: Fix WIMG handling under pHyp 2018-01-17 09:45:24 +01:00
book3s_pr_papr.c
book3s_rmhandlers.S powerpc/64s: Simple RFI macro conversions 2018-01-23 19:58:10 +01:00
book3s_rtas.c KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list 2019-06-22 08:16:17 +02:00
book3s_segment.S powerpc/64s: Simple RFI macro conversions 2018-01-23 19:58:10 +01:00
book3s_xics.c
book3s_xics.h
book3s_xive.c KVM: PPC: Book3S HV: XIVE: Free escalation interrupts before disabling the VP 2019-10-11 18:18:43 +02:00
book3s_xive.h
book3s_xive_template.c
booke.c
booke.h
booke_emulate.c
booke_interrupts.S
bookehv_interrupts.S powerpc/fsl: Flush branch predictor when entering KVM 2019-04-03 06:25:14 +02:00
e500.c
e500.h
e500_emulate.c powerpc/fsl: Emulate SPRN_BUCSR register 2019-04-03 06:25:14 +02:00
e500_mmu.c
e500_mmu_host.c
e500_mmu_host.h
e500mc.c
emulate.c
emulate_loadstore.c
fpu.S
irq.h
Kconfig KVM: PPC: Book3S PR: Fix broken select due to misspelling 2018-02-16 20:23:03 +01:00
Makefile
mpic.c
powerpc.c KVM: Fix leak vCPU's VMCS value into other pCPU 2019-08-16 10:13:57 +02:00
timing.c
timing.h
trace.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-12-01 09:42:53 +01:00
trace_book3s.h
trace_booke.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-12-01 09:42:53 +01:00
trace_hv.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-12-01 09:42:53 +01:00
trace_pr.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-12-01 09:42:53 +01:00