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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html