From: Tina Zhang QEMU's KVM memory-failure injection path builds synthetic MCI_STATUS records for the guest CPU. The status encoding is vendor-specific: Intel-style records use bits such as MCI_STATUS_S and MCI_STATUS_AR for action-required events, while the AMD path uses the AMD memory-failure encoding. Today QEMU selects the AMD status encoding only for AuthenticAMD guests. Hygon guests therefore get Intel-style injected status bits, including MCI_STATUS_S and MCI_STATUS_AR for action-required events, and a non-deferred action-optional record. Use the AMD injected-memory-failure MCE status encoding for Hygon guests as well. This does not depend on Hygon exposing CPUID 0x80000007.EBX recovery features such as SUCCOR, and it does not advertise any new recovery capability. The change is limited to QEMU's synthetic KVM memory-failure MCE status; it does not change CPUID, MCE bank state, or migrated CPU state. Signed-off-by: Tina Zhang --- target/i386/kvm/kvm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 64cc421abe..8e2bfbbe1d 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -698,6 +698,15 @@ static int kvm_get_mce_cap_supported(KVMState *s, uint64_t *mce_cap, return kvm_ioctl(s, KVM_X86_GET_MCE_CAP_SUPPORTED, mce_cap); } +/* + * Use AMD-style MCE status records for QEMU-injected memory failures on + * AMD and Hygon CPUs. + */ +static bool kvm_mce_inject_uses_amd_status(const CPUX86State *env) +{ + return IS_AMD_CPU(env) || IS_HYGON_CPU(env); +} + static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code) { CPUState *cs = CPU(cpu); @@ -707,7 +716,7 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code) uint64_t mcg_status = MCG_STATUS_MCIP | MCG_STATUS_RIPV; int flags = 0; - if (!IS_AMD_CPU(env)) { + if (!kvm_mce_inject_uses_amd_status(env)) { status |= MCI_STATUS_S | MCI_STATUS_UC; if (code == BUS_MCEERR_AR) { status |= MCI_STATUS_AR | 0x134; -- 2.43.7