The test_pv_ipi test from the apic suite doesn't behave on some non-KVM hosts. (including TCG and macOS/hvf) The test has been gated on (compile-time...) presence of the test device rather than anything specifically indicating host support for the feature under test. This patch changes the test to check whether it's running on KVM, and whether KVM advertises the PV IPI hypercall feature. v2 is based on Sean Christopherson's draft patch which brings in kvm_para.h verbatim from the Linux source tree: https://lore.kernel.org/kvm/ZRQ5r0kn5RzDpf0C@xxxxxxxxxx/ In addition to Sean's changes, I've also added: * A wrapper for <linux/types.h> which provides the minimum required set of types for kvm_para.h to build on non-Linux platforms. * The check for whether we're running on KVM at all; the feature flag at bit 11 of eax at CPUID leaf 0x40000001 might mean just about anything on another hypervisor. * The +kvm-pv-ipi CPU feature flag on the APIC test suites' Qemu command lines, without which the hypercall is *supported* on KVM hosts, but not *advertised*. * Explicit 'skip' report when test_pv_ipi doesn't run. I find this helpful, and other tests also report back when their preconditions fail, but I'm equally happy to drop it if there's good reason to do so. Review notes: * checkpatch.pl complains about the formatting of KVM_STEAL_RESERVED_MASK but that's inherited from Linux upstream, so I've left it as-is. * checkpatch.pl also offers some warnings which I wasn't sure needed addressing. "Co-authored-by" is apparently not supported, but I'm not sure what the etiquette for multiple-author patches is here. Keeping Sean's patch as a stand-alone commit would cause build failures when bisecting on non-Linux platforms, so I didn't go that route. I've tested the patch builds and correctly executes on macOS (hvf & TCG) and Linux. (KVM & TCG) Phil Dennis-Jordan (1): x86/apic: test_pv_ipi checks cpuid before issuing KVM Hypercall lib/linux/kvm_para.h | 39 ++++++++++ lib/linux/types.h | 15 ++++ lib/asm-generic/kvm_para.h | 4 + lib/x86/asm/kvm_para.h | 153 +++++++++++++++++++++++++++++++++++++ lib/x86/processor.h | 40 ++++++++++ x86/apic.c | 4 +- x86/unittests.cfg | 6 +- 7 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 lib/linux/kvm_para.h create mode 100644 lib/linux/types.h create mode 100644 lib/asm-generic/kvm_para.h create mode 100644 lib/x86/asm/kvm_para.h -- 2.36.1