KVM: PPC: Book3S: Enable XIVE native capability only if OPAL has required functions
authorPaul Mackerras <paulus@ozlabs.org>
Mon, 26 Aug 2019 06:21:21 +0000 (16:21 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Tue, 27 Aug 2019 01:45:49 +0000 (11:45 +1000)
commit2ad7a27deaf6d78545d97ab80874584f6990360e
treeafadf8ab79c6a31384a9467761779a3d6dd80f57
parentd22deab6960a6cb015a36e74a2dcbab6ca9f5544
KVM: PPC: Book3S: Enable XIVE native capability only if OPAL has required functions

There are some POWER9 machines where the OPAL firmware does not support
the OPAL_XIVE_GET_QUEUE_STATE and OPAL_XIVE_SET_QUEUE_STATE calls.
The impact of this is that a guest using XIVE natively will not be able
to be migrated successfully.  On the source side, the get_attr operation
on the KVM native device for the KVM_DEV_XIVE_GRP_EQ_CONFIG attribute
will fail; on the destination side, the set_attr operation for the same
attribute will fail.

This adds tests for the existence of the OPAL get/set queue state
functions, and if they are not supported, the XIVE-native KVM device
is not created and the KVM_CAP_PPC_IRQ_XIVE capability returns false.
Userspace can then either provide a software emulation of XIVE, or
else tell the guest that it does not have a XIVE controller available
to it.

Cc: stable@vger.kernel.org # v5.2+
Fixes: 3fab2d10588e ("KVM: PPC: Book3S HV: XIVE: Activate XIVE exploitation mode")
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/include/asm/xive.h
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/book3s_xive_native.c
arch/powerpc/kvm/powerpc.c
arch/powerpc/sysdev/xive/native.c