From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 1/6] x86/domctl: Introduce PV_XSAVE_HDR_SIZE and remove its opencoding
Date: Mon, 12 Sep 2016 10:51:35 +0100 [thread overview]
Message-ID: <1473673900-8585-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1473673900-8585-1-git-send-email-andrew.cooper3@citrix.com>
Also remove opencoding of PV_XSAVE_SIZE(). Undefine both when they are
done with.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/domctl.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index a904fd6..c9355ce 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1037,7 +1037,8 @@ long arch_do_domctl(
struct vcpu *v;
uint32_t offset = 0;
-#define PV_XSAVE_SIZE(xcr0) (2 * sizeof(uint64_t) + xstate_ctxt_size(xcr0))
+#define PV_XSAVE_HDR_SIZE (2 * sizeof(uint64_t))
+#define PV_XSAVE_SIZE(xcr0) (PV_XSAVE_HDR_SIZE + xstate_ctxt_size(xcr0))
ret = -ESRCH;
if ( (evc->vcpu >= d->max_vcpus) ||
@@ -1093,10 +1094,10 @@ long arch_do_domctl(
}
expand_xsave_states(v, xsave_area,
- size - 2 * sizeof(uint64_t));
+ size - PV_XSAVE_HDR_SIZE);
if ( copy_to_guest_offset(evc->buffer, offset, xsave_area,
- size - 2 * sizeof(uint64_t)) )
+ size - PV_XSAVE_HDR_SIZE) )
ret = -EFAULT;
xfree(xsave_area);
}
@@ -1110,9 +1111,8 @@ long arch_do_domctl(
const struct xsave_struct *_xsave_area;
ret = -EINVAL;
- if ( evc->size < 2 * sizeof(uint64_t) ||
- evc->size > 2 * sizeof(uint64_t) +
- xstate_ctxt_size(xfeature_mask) )
+ if ( evc->size < PV_XSAVE_HDR_SIZE ||
+ evc->size > PV_XSAVE_SIZE(xfeature_mask) )
goto vcpuextstate_out;
receive_buf = xmalloc_bytes(evc->size);
@@ -1131,11 +1131,11 @@ long arch_do_domctl(
_xcr0 = *(uint64_t *)receive_buf;
_xcr0_accum = *(uint64_t *)(receive_buf + sizeof(uint64_t));
- _xsave_area = receive_buf + 2 * sizeof(uint64_t);
+ _xsave_area = receive_buf + PV_XSAVE_HDR_SIZE;
if ( _xcr0_accum )
{
- if ( evc->size >= 2 * sizeof(uint64_t) + XSTATE_AREA_MIN_SIZE )
+ if ( evc->size >= PV_XSAVE_HDR_SIZE + XSTATE_AREA_MIN_SIZE )
ret = validate_xstate(_xcr0, _xcr0_accum,
&_xsave_area->xsave_hdr);
}
@@ -1155,7 +1155,7 @@ long arch_do_domctl(
if ( _xcr0_accum & XSTATE_NONLAZY )
v->arch.nonlazy_xstate_used = 1;
compress_xsave_states(v, _xsave_area,
- evc->size - 2 * sizeof(uint64_t));
+ evc->size - PV_XSAVE_HDR_SIZE);
vcpu_unpause(v);
}
else
@@ -1164,6 +1164,9 @@ long arch_do_domctl(
xfree(receive_buf);
}
+#undef PV_XSAVE_HDR_SIZE
+#undef PV_XSAVE_SIZE
+
vcpuextstate_out:
if ( domctl->cmd == XEN_DOMCTL_getvcpuextstate )
copyback = 1;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-12 9:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 9:51 [PATCH 0/6] Fix multiple issues with xsave state handling on migrate Andrew Cooper
2016-09-12 9:51 ` Andrew Cooper [this message]
2016-09-12 11:05 ` [PATCH 1/6] x86/domctl: Introduce PV_XSAVE_HDR_SIZE and remove its opencoding Jan Beulich
2016-09-12 9:51 ` [PATCH 2/6] x86/domctl: Fix TOCTOU race with the use of XEN_DOMCTL_getvcpuextstate Andrew Cooper
2016-09-12 11:17 ` Jan Beulich
2016-09-12 12:02 ` Andrew Cooper
2016-09-12 12:33 ` Jan Beulich
2016-09-12 13:09 ` Andrew Cooper
2016-09-12 13:35 ` Jan Beulich
2016-09-12 13:37 ` Jan Beulich
2016-09-12 9:51 ` [PATCH 3/6] x86/domctl: Simplfy XEN_DOMCTL_getvcpuextstate when xsave is not in use Andrew Cooper
2016-09-12 11:26 ` Jan Beulich
2016-09-12 9:51 ` [PATCH 4/6] x86/xstate: Fix latent bugs in expand_xsave_states() Andrew Cooper
2016-09-12 11:41 ` Jan Beulich
2016-09-12 12:29 ` Andrew Cooper
2016-09-12 12:41 ` Jan Beulich
2016-09-12 12:43 ` Jan Beulich
2016-09-12 13:57 ` Andrew Cooper
2016-09-12 14:13 ` Jan Beulich
2016-09-12 9:51 ` [PATCH 5/6] x86/domctl: Fix migration of guests which are not using xsave Andrew Cooper
2016-09-12 12:14 ` Jan Beulich
2016-09-12 12:46 ` Andrew Cooper
2016-09-12 13:41 ` Jan Beulich
2016-09-12 9:51 ` [PATCH 6/6] x86/xstate: Fix latent bugs in compress_xsave_states() Andrew Cooper
2016-09-12 12:27 ` Jan Beulich
2016-09-12 12:59 ` Andrew Cooper
2016-09-12 13:47 ` Jan Beulich
2016-09-12 15:28 ` Andrew Cooper
2016-09-12 16:10 ` Jan Beulich
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=1473673900-8585-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).