Received: from eggs.gnu.org ([2001:4830:134:3::10]:46317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5Nv-0001rr-Jd for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5Nt-0008C2-BU for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5Nt-0008Bq-5T for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:53:57 -0400 From: Eduardo Habkost Date: Thu, 22 Sep 2016 11:53:45 -0300 Message-Id: <1474556029-24992-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1474556029-24992-1-git-send-email-ehabkost@redhat.com> References: <1474556029-24992-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/6] target-i386: Add a marker to end of the region zeroed on reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Brijesh Singh , Bandan Das , Richard Henderson , Paolo Bonzini , Igor Mammedov 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. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 2 +- target-i386/cpu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 920b78f..26f0e59 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2714,7 +2714,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/target-i386/cpu.h b/target-i386/cpu.h index 27af9c3..604d591 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1108,6 +1108,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; -- 2.7.4