From 6861fe80cfc486c492f7c5f03f397b0c8aaba69f Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 26 Feb 2018 03:58:08 -0500 Subject: [PATCH] target-i386: Add a marker to end of the region zeroed on reset Instead of using cpuid_level, use an empty struct as a marker (like we already did with {start,end}_init_save). This will avoid accidentaly resetting the wrong fields if we change the field ordering on CPUX86State. Backports commit 5e992a8e337e710ea2d02f35668ac55a80e15f99 from qemu --- qemu/target-i386/cpu.c | 2 +- qemu/target-i386/cpu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/qemu/target-i386/cpu.c b/qemu/target-i386/cpu.c index 6632c0a4..7ef46033 100644 --- a/qemu/target-i386/cpu.c +++ b/qemu/target-i386/cpu.c @@ -2806,7 +2806,7 @@ static void x86_cpu_reset(CPUState *s) xcc->parent_reset(s); - memset(env, 0, offsetof(CPUX86State, cpuid_level)); + memset(env, 0, offsetof(CPUX86State, end_reset_fields)); tlb_flush(s, 1); diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h index 9162d770..a644f05e 100644 --- a/qemu/target-i386/cpu.h +++ b/qemu/target-i386/cpu.h @@ -1101,6 +1101,7 @@ typedef struct CPUX86State { CPU_COMMON /* Fields from here on are preserved across CPU reset. */ + struct {} end_reset_fields; /* processor features (e.g. for CPUID insn) */ uint32_t cpuid_level;