linux/arch/powerpc
Gautam Menghani a373830f96 KVM: PPC: Book3S HV: Mask off LPCR_MER for a vCPU before running it to avoid spurious interrupts
Running a L2 vCPU (see [1] for terminology) with LPCR_MER bit set and no
pending interrupts results in that L2 vCPU getting an infinite flood of
spurious interrupts. The 'if check' in kvmhv_run_single_vcpu() sets the
LPCR_MER bit if there are pending interrupts.

The spurious flood problem can be observed in 2 cases:
1. Crashing the guest while interrupt heavy workload is running
  a. Start a L2 guest and run an interrupt heavy workload (eg: ipistorm)
  b. While the workload is running, crash the guest (make sure kdump
     is configured)
  c. Any one of the vCPUs of the guest will start getting an infinite
     flood of spurious interrupts.

2. Running LTP stress tests in multiple guests at the same time
   a. Start 4 L2 guests.
   b. Start running LTP stress tests on all 4 guests at same time.
   c. In some time, any one/more of the vCPUs of any of the guests will
      start getting an infinite flood of spurious interrupts.

The root cause of both the above issues is the same:
1. A NMI is sent to a running vCPU that has LPCR_MER bit set.
2. In the NMI path, all registers are refreshed, i.e, H_GUEST_GET_STATE
   is called for all the registers.
3. When H_GUEST_GET_STATE is called for LPCR, the vcpu->arch.vcore->lpcr
   of that vCPU at L1 level gets updated with LPCR_MER set to 1, and this
   new value is always used whenever that vCPU runs, regardless of whether
   there was a pending interrupt.
4. Since LPCR_MER is set, the vCPU in L2 always jumps to the external
   interrupt handler, and this cycle never ends.

Fix the spurious flood by masking off the LPCR_MER bit before running a
L2 vCPU to ensure that it is not set if there are no pending interrupts.

[1] Terminology:
1. L0 : PAPR hypervisor running in HV mode
2. L1 : Linux guest (logical partition) running on top of L0
3. L2 : KVM guest running on top of L1

Fixes: ec0f6639fa ("KVM: PPC: Book3S HV nestedv2: Ensure LPCR_MER bit is passed to the L0")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
2024-11-06 11:36:09 +05:30
..
boot xz: remove XZ_EXTERN and extern from functions 2024-09-01 20:43:27 -07:00
configs ALong with the usual shower of singleton patches, notable patch series in 2024-09-21 07:29:05 -07:00
crypto move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
include ALong with the usual shower of singleton patches, notable patch series in 2024-09-21 07:29:05 -07:00
kernel powerpc/8xx: Fix kernel DTLB miss on dcbz 2024-10-11 15:53:06 +11:00
kexec powerpc updates for 6.11 2024-07-19 21:00:33 -07:00
kvm KVM: PPC: Book3S HV: Mask off LPCR_MER for a vCPU before running it to avoid spurious interrupts 2024-11-06 11:36:09 +05:30
lib powerpc/vdso32: Fix use of crtsavres for PPC64 2024-09-20 19:06:19 +10:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm ALong with the usual shower of singleton patches, notable patch series in 2024-09-21 07:29:05 -07:00
net powerpc updates for 6.11 2024-07-19 21:00:33 -07:00
perf powerpc/perf: Set cpumode flags using sample address 2024-06-17 22:47:16 +10:00
platforms powerpc/powernv: Free name on error in opal_event_init() 2024-10-16 09:26:50 +11:00
purgatory Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
sysdev powerpc: Switch back to struct platform_driver::remove() 2024-09-10 11:27:40 +10:00
tools powerpc/tools: Pass -mabi=elfv2 to gcc-check-mprofile-kernel.sh 2023-10-20 17:46:33 +11:00
xmon powerpc/xmon: Fix tmpstr length check in scanhex 2024-08-27 17:10:55 +10:00
Kbuild powerpc: Fix fatal warnings flag for LLVM's integrated assembler 2024-04-08 16:06:41 +10:00
Kconfig dma-mapping updates for linux 6.12 2024-09-19 11:12:49 +02:00
Kconfig.debug powerpc/64s: Remove the "fast endian switch" syscall 2024-09-05 22:30:05 +10:00
Makefile powerpc: Remove 40x from Kconfig and defconfig 2024-06-28 22:28:47 +10:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00