From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>, Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/4] x86/domctl: Implement XEN_DOMCTL_{get, set}_vcpu_msrs
Date: Fri, 6 Jun 2014 15:53:52 +0100 [thread overview]
Message-ID: <5391D600.8010307@citrix.com> (raw)
In-Reply-To: <53908DE402000078000183DC@mail.emea.novell.com>
On 05/06/14 14:33, Jan Beulich wrote:
> <snip>
>> The sole use of this hypercall needs to ensure that all MSRs are gotten,
>> otherwise VM corruption will occur. Permitting a partial get will make
>> the return value ambiguous for making this hypercall a single time and
>> guessing at the size to use, although I suspect we are less interested
>> in this problem.
> Why would the return value ambiguous? You'd get -ENOBUFS if you
> provided too few slots, and you'd get to know the maximum number
> at that point at once.
>
> Jan
>
Having tried to implement these improvements, I hit problems so would
like to decide upon an interface before hacking futher.
Currently behaviour for get:
* Null guest handle returns msr_count set to maximum number of msrs Xen
might write
* msr_count < max_msrs fails with -ENOBUFS
* if msrs are written, msr_count reflects the number written (likely
less than max_msrs)
Current behaviour for set:
* msr_count > max_msrs fails with -EINVAL
* problems with individual msrs fail with -EINVAL
Suggestions:
* for get, msr_count < max_msrs should perform a partial write,
returning -ENOBUFS if Xen needs to write more than msr_count msrs.
This reduces the amount of code added to xc_domain_save() to fail
migrations actually using PV msrs. I am not too concerned about this
code, as it will be rm'd in the migration-v2 series which implements PV
MSR migration properly. I am a little bit hesitant about supporting
partial writes, although I suppose it is plausible to want to know "how
many MSRs is the vcpu currently using", and doing that with a single
hypercall is preferable to requiring two.
* for set, in the case of a bad msr, identify it back to the caller to
aid with debugging.
This is useful to help debugging, but needs disambiguating against the
other cases which fail with -EINVAL, including the paths which would
fail before having a chance to set msr_count to the index of the bad
msr. Therefore, msr_count *can't* be overloaded for this purpose.
I see one solution to these problems. Using:
struct xen_domctl_vcpu_msrs {
u32 vcpu;
union { u16 max_msrs, /* OUT from get */
u16 err_idx}; /* Possibly OUT from set */
u16 msr_count;
XEN_GUEST_HANDLE_64(xen_domctl_vcpu_msr_t) msrs;
};
max_msrs and current msrs can be reported at the same time (both on a
NULL guest handle). If the caller of set sets err_idx to ~0 before the
call, it can unambiguously determine the offending MSR, without
confusing other -EINVAL failure cases.
Does this look plausible? Can we get away with anonymous unions in the
public header files?
~Andrew
next prev parent reply other threads:[~2014-06-06 14:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 17:26 [PATCH 0/4] Fixes to several domctls for migration Andrew Cooper
2014-06-04 17:26 ` [PATCH 1/4] x86/domctl: Implement XEN_DOMCTL_{get, set}_vcpu_msrs Andrew Cooper
2014-06-05 12:46 ` Jan Beulich
2014-06-05 13:01 ` Andrew Cooper
2014-06-05 13:33 ` Jan Beulich
2014-06-06 14:53 ` Andrew Cooper [this message]
2014-06-06 15:09 ` Jan Beulich
2014-06-06 15:28 ` Andrew Cooper
2014-06-04 17:26 ` [PATCH 2/4] tools/libxc: Use an explicit check for PV MSRs in xc_domain_save() Andrew Cooper
2014-06-05 13:41 ` Jan Beulich
2014-06-05 15:52 ` Ian Campbell
2014-06-05 15:57 ` Andrew Cooper
2014-06-06 9:15 ` Ian Campbell
2014-06-06 9:44 ` Andrew Cooper
2014-06-06 9:48 ` Ian Campbell
2014-06-04 17:26 ` [PATCH 3/4] x86/domctl: Remove PV MSR parts of XEN_DOMCTL_[gs]et_ext_vcpucontext Andrew Cooper
2014-06-05 7:52 ` Frediano Ziglio
2014-06-05 9:25 ` Andrew Cooper
2014-06-04 17:26 ` [PATCH 4/4] x86/domctl: Two functional fixes to XEN_DOMCTL_[gs]etvcpuextstate Andrew Cooper
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=5391D600.8010307@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.