OSDN Git Service

KVM: PPC: Book3S HV: Don't call real-mode XICS hypercall handlers if not enabled
authorPaul Mackerras <paulus@ozlabs.org>
Thu, 26 Oct 2017 06:00:22 +0000 (17:00 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Nov 2017 08:40:53 +0000 (08:40 +0000)
commitf5073bc7c18358d08bc9dd39458bc469dc9e978d
treec71dae9fb59b41ee7f3b6133df7838498b714618
parent665e6619705a19910ab3aaa81eb34343e9628da4
KVM: PPC: Book3S HV: Don't call real-mode XICS hypercall handlers if not enabled

commit 00bb6ae5006205e041ce9784c819460562351d47 upstream.

When running a guest on a POWER9 system with the in-kernel XICS
emulation disabled (for example by running QEMU with the parameter
"-machine pseries,kernel_irqchip=off"), the kernel does not pass
the XICS-related hypercalls such as H_CPPR up to userspace for
emulation there as it should.

The reason for this is that the real-mode handlers for these
hypercalls don't check whether a XICS device has been instantiated
before calling the xics-on-xive code.  That code doesn't check
either, leading to potential NULL pointer dereferences because
vcpu->arch.xive_vcpu is NULL.  Those dereferences won't cause an
exception in real mode but will lead to kernel memory corruption.

This fixes it by adding kvmppc_xics_enabled() checks before calling
the XICS functions.

Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_hv_builtin.c