From: "Jan Beulich" Subject: Re: [PATCH 1/4] x86/domctl: Implement XEN_DOMCTL_{get, set}_vcpu_msrs Date: Thu, 05 Jun 2014 14:33:56 +0100 Message-ID: <53908DE402000078000183DC@mail.emea.novell.com> References: <1401902794-15542-1-git-send-email-andrew.cooper3@citrix.com> <1401902794-15542-2-git-send-email-andrew.cooper3@citrix.com> <539082E20200007800018344@mail.emea.novell.com> <53906A39.3070506@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53906A39.3070506@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Keir Fraser , Xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 05.06.14 at 15:01, wrote: > On 05/06/14 13:46, Jan Beulich wrote: >>>>> On 04.06.14 at 19:26, wrote: >>> + if ( domctl->cmd == XEN_DOMCTL_get_vcpu_msrs ) >>> + { >>> + /* NULL guest handle is a request for max size. */ >>> + if ( guest_handle_is_null(vmsrs->msrs) || >>> + (vmsrs->msr_count < nr_msrs) ) >>> + { >>> + vmsrs->msr_count = nr_msrs; >>> + ret = guest_handle_is_null(vmsrs->msrs) ? 0 : -ENOBUFS; >> I don't think you should be failing "get" if there is enough space in >> the provided buffer to store the actually used number of MSRs. That >> way the caller may make a first call with a few (rather than none at >> all) entries, an grow the buffer only if this wasn't sufficient. > > I am not sure I agree. The MSRs are unordered in the buffer which the > caller cannot control, and issuing a hypercall again with a larger > buffer will rewrite it from the start again. And I didn't suggest incremental use. > 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