From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 5/6] x86/domctl: Fix migration of guests which are not using xsave
Date: Mon, 12 Sep 2016 13:46:18 +0100 [thread overview]
Message-ID: <8492187e-7367-f638-dfbf-9782260ddccb@citrix.com> (raw)
In-Reply-To: <57D6B854020000780010E048@prv-mh.provo.novell.com>
On 12/09/16 13:14, Jan Beulich wrote:
>>>> On 12.09.16 at 11:51, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/domctl.c
>> +++ b/xen/arch/x86/domctl.c
>> @@ -1158,7 +1158,15 @@ long arch_do_domctl(
>> goto vcpuextstate_out;
>> }
>>
>> - if ( evc->size <= PV_XSAVE_SIZE(_xcr0_accum) )
>> + if ( evc->size == PV_XSAVE_HDR_SIZE )
>> + ; /* Nothing to restore. */
>> + else if ( evc->size < PV_XSAVE_HDR_SIZE + XSTATE_AREA_MIN_SIZE )
>> + ret = -EINVAL; /* Can't be legitimate data. */
>> + else if ( xsave_area_compressed(_xsave_area) )
>> + ret = -EOPNOTSUPP; /* Don't support compressed data. */
>> + else if ( evc->size != PV_XSAVE_SIZE(_xcr0_accum) )
>> + ret = -EINVAL; /* Not legitimate data. */
> Can't this be moved ahead of the xsave_area_compressed() check,
> eliminating (as redundant) the check that's there right now?
No. That doesn't catch the case where _xcr0_accum is 0, which will
cause the xsave_area_compressed(_xsave_area) check to wander off the end
of the buffer.
>
> In any event the tightening to != you do here supports my desire to
> not do any relaxation of the size check in patch 2.
The two cases are different, and should not be conflated.
> Or alternatively
> you would want to consider restoring the behavior from prior to
> the xsaves change, where the <= which you now remove was still
> okay.
I looked back through the history and couldn't find any justification
for the check being <= as opposed to being more strict. We absolutely
don't want to be in the case where we only restore part of an xstate
component.
>
>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -1345,6 +1345,23 @@ static int hvm_load_cpu_xsave_states(struct domain *d, hvm_domain_context_t *h)
>> printk(XENLOG_G_WARNING
>> "HVM%d.%u restore mismatch: xsave length %#x > %#x\n",
>> d->domain_id, vcpuid, desc->length, size);
>> + /* Rewind desc->length to ignore the extraneous zeros. */
>> + desc->length = size;
> This is slightly ugly, as it will prevent eventually constifying dest (which
> it really should have been from the beginning).
Hmm yes. I hadn't considered that it was actually mutating the hvm
domain context buffer. I will switch to a shadow variable instead.
>
>> --- a/xen/include/asm-x86/xstate.h
>> +++ b/xen/include/asm-x86/xstate.h
>> @@ -131,4 +131,10 @@ static inline bool_t xstate_all(const struct vcpu *v)
>> (v->arch.xcr0_accum & XSTATE_LAZY & ~XSTATE_FP_SSE);
>> }
>>
>> +static inline bool __nonnull(1)
>> + xsave_area_compressed(const struct xsave_struct *xsave_area)
> This is certainly odd indentation.
It is where my editor naturally indents to. It would appear that emacs
is mistaking the __nonnull(1) as the function name, and presuming that
the following line is K&R style parameters.
It is certainly awkward that the attributes need to be that way around.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-12 12:46 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 ` [PATCH 1/6] x86/domctl: Introduce PV_XSAVE_HDR_SIZE and remove its opencoding Andrew Cooper
2016-09-12 11:05 ` 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 [this message]
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=8492187e-7367-f638-dfbf-9782260ddccb@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).