@@ -212,6 +212,7 @@ int kvm_on_sigbus(int code, void *addr);
#ifdef NEED_CPU_H
#include "cpu.h"
+#include "cpu-param.h"
void kvm_flush_coalesced_mmio_buffer(void);
@@ -349,6 +350,10 @@ bool kvm_vcpu_id_is_valid(int vcpu_id);
/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
unsigned long kvm_arch_vcpu_id(CPUState *cpu);
+#if KVM_ARCH_HAVE_MCE_INJECTION
+#define KVM_HAVE_MCE_INJECTION
+#endif
+
#ifdef KVM_HAVE_MCE_INJECTION
void kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
#endif
@@ -30,7 +30,12 @@
*/
# define TARGET_PAGE_BITS_VARY
# define TARGET_PAGE_BITS_MIN 10
+#endif
+#ifdef TARGET_AARCH64
+#define KVM_ARCH_HAVE_MCE_INJECTION 1
+#else
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
#endif
#endif
@@ -30,10 +30,6 @@
/* ARM processors have a weak memory model */
#define TCG_GUEST_DEFAULT_MO (0)
-#ifdef TARGET_AARCH64
-#define KVM_HAVE_MCE_INJECTION 1
-#endif
-
#define EXCP_UDEF 1 /* undefined instruction */
#define EXCP_SWI 2 /* software interrupt */
#define EXCP_PREFETCH_ABORT 3
@@ -24,4 +24,6 @@
#endif
#define TARGET_PAGE_BITS 12
+#define KVM_ARCH_HAVE_MCE_INJECTION 1
+
#endif
@@ -33,8 +33,6 @@
/* The x86 has a strong memory model with some store-after-load re-ordering */
#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
-#define KVM_HAVE_MCE_INJECTION 1
-
/* support for self modifying code even if the modified instruction is
close to the modifying instruction */
#define TARGET_HAS_PRECISE_SMC
@@ -14,4 +14,6 @@
#define TARGET_PAGE_BITS 12
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
+
#endif
@@ -30,4 +30,6 @@
#define TARGET_PAGE_BITS_MIN 12
#endif
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
+
#endif
@@ -33,4 +33,6 @@
#endif
#define TARGET_PAGE_BITS 12
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
+
#endif
@@ -28,4 +28,6 @@
* - M mode HLV/HLVX/HSV 0b111
*/
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
+
#endif
@@ -13,4 +13,6 @@
#define TARGET_PHYS_ADDR_SPACE_BITS 64
#define TARGET_VIRT_ADDR_SPACE_BITS 64
+#define KVM_ARCH_HAVE_MCE_INJECTION 0
+
#endif
Instead of having KVM_HAVE_MCE_INJECTION optionally defined, always define KVM_ARCH_HAVE_MCE_INJECTION for each target, and set KVM_HAVE_MCE_INJECTION if it is not zero. It is now clearer for KVM targets to detect if they lack the MCE injection implementation. Also, moving headers around is no more painful, because if a target neglects to define KVM_ARCH_HAVE_MCE_INJECTION, the build will fail. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- I'd rather keep "cpu-param.h" simple/short. Is a per-target "kvm-param.h" any better? Or per-target "accel-param.h"? For example TCG_GUEST_DEFAULT_MO is TCG specific and could also go there. Otherwise it will go in "cpu-param.h". --- include/sysemu/kvm.h | 5 +++++ target/arm/cpu-param.h | 5 +++++ target/arm/cpu.h | 4 ---- target/i386/cpu-param.h | 2 ++ target/i386/cpu.h | 2 -- target/loongarch/cpu-param.h | 2 ++ target/mips/cpu-param.h | 2 ++ target/ppc/cpu-param.h | 2 ++ target/riscv/cpu-param.h | 2 ++ target/s390x/cpu-param.h | 2 ++ 10 files changed, 22 insertions(+), 6 deletions(-)