From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v2 2/2] target-i386: Intel MPX Date: Thu, 05 Dec 2013 17:52:46 +0100 Message-ID: <52A0AF5E.30800@redhat.com> References: <529EED47.2070607@redhat.com> <529F6527.1020707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , "qemu-devel@nongnu.org" , kvm To: "Liu, Jinsong" Return-path: Received: from mail-qe0-f43.google.com ([209.85.128.43]:48739 "EHLO mail-qe0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818Ab3LEQwy (ORCPT ); Thu, 5 Dec 2013 11:52:54 -0500 Received: by mail-qe0-f43.google.com with SMTP id 2so17361910qeb.2 for ; Thu, 05 Dec 2013 08:52:51 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 05/12/2013 16:26, Liu, Jinsong ha scritto: > Sorry, those macro seems too opaque to me, I try several ways but fail. > Would you help me to add incremental patch based on current patches? Something like this (untested): diff --git a/target-i386/machine.c b/target-i386/machine.c index ca8be7d..71379b1 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -75,23 +75,8 @@ static const VMStateDescription vmstate_bnd_regs = { } }; -#define VMSTATE_BNDREG_VARS(_field, _state, _n, _v) \ - VMSTATE_STRUCT_ARRAY(_field, _state, _n, _v, vmstate_bnd_regs, BNDReg) - -static const VMStateDescription vmstate_bndcs_regs = { - .name = "bndcs_regs", - .version_id = 1, - .minimum_version_id = 1, - .minimum_version_id_old = 1, - .fields = (VMStateField []) { - VMSTATE_UINT64(cfg, BNDCSReg), - VMSTATE_UINT64(sts, BNDCSReg), - VMSTATE_END_OF_LIST() - } -}; - -#define VMSTATE_BNDCSR_VARS(_field, _state, _v) \ - VMSTATE_STRUCT(_field, _state, _v, vmstate_bndcs_regs, BNDCSReg) +#define VMSTATE_BND_REGS(_field, _state, _n) \ + VMSTATE_STRUCT_ARRAY(_field, _state, _n, 0, vmstate_bnd_regs, BNDReg) static const VMStateDescription vmstate_mtrr_var = { .name = "mtrr_var", @@ -536,6 +521,29 @@ static const VMStateDescription vmstate_msr_architectural_pmu = { } }; +static bool mpx_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + } /* MISSING: Check for any MPX register != 0 here, return true if so. */ + return false; +} + +static const VMStateDescription vmstate_mpx = { + .name = "cpu/mpx", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_BND_REGS(env.bnd_regs, X86CPU, 4), + VMSTATE_UINT64(env.bndcs_regs.cfg, X86CPU), + VMSTATE_UINT64(env.bndcs_regs.sts, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -636,8 +642,6 @@ const VMStateDescription vmstate_x86_cpu = { VMSTATE_UINT64_V(env.xcr0, X86CPU, 12), VMSTATE_UINT64_V(env.xstate_bv, X86CPU, 12), VMSTATE_YMMH_REGS_VARS(env.ymmh_regs, X86CPU, CPU_NB_REGS, 12), - VMSTATE_BNDREG_VARS(env.bnd_regs, X86CPU, 4, 12), - VMSTATE_BNDCSR_VARS(env.bndcs_regs, X86CPU, 12), VMSTATE_END_OF_LIST() /* The above list is not sorted /wrt version numbers, watch out! */ }, @@ -670,6 +674,9 @@ const VMStateDescription vmstate_x86_cpu = { .vmsd = &vmstate_msr_architectural_pmu, .needed = pmu_enable_needed, } , { + .vmsd = &vmstate_mpx, + .needed = mpx_needed, + } , { /* empty */ } } This is the bulk of the required changes. Also, env.bndcs_regs.cfg is really BNDCFGU and should be called cfgu; and you need to save BNDCFGS too. This needs a small change above to vmstate_mpx, and other changes in kvm_get_supported_msrs, kvm_get_msrs, kvm_put_msrs and the CPUX86State struct. Paolo