From: Paolo Bonzini <pbonzini@redhat.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: Gleb Natapov <gleb@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] target-i386: Intel MPX
Date: Thu, 05 Dec 2013 17:52:46 +0100 [thread overview]
Message-ID: <52A0AF5E.30800@redhat.com> (raw)
In-Reply-To: <DE8DF0795D48FD4CA783C40EC829233501405F44@SHSMSX101.ccr.corp.intel.com>
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
prev parent reply other threads:[~2013-12-05 16:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-04 7:56 [PATCH v2 2/2] target-i386: Intel MPX Liu, Jinsong
2013-12-04 8:52 ` Paolo Bonzini
2013-12-04 11:30 ` Liu, Jinsong
2013-12-04 17:23 ` Paolo Bonzini
2013-12-05 15:26 ` Liu, Jinsong
2013-12-05 16:52 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A0AF5E.30800@redhat.com \
--to=pbonzini@redhat.com \
--cc=gleb@redhat.com \
--cc=jinsong.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox