From: Ian Campbell Subject: Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers Date: Wed, 23 Apr 2014 13:23:25 +0100 Message-ID: <1398255805.18537.73.camel@kazak.uk.xensource.com> References: <534EAE6402000078000098FB@nat28.tlf.novell.com> <534EB110020000780000996D@nat28.tlf.novell.com> <1398248621.18537.14.camel@kazak.uk.xensource.com> <5357C581020000780000B6A8@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WcwD5-0005xs-2G for xen-devel@lists.xenproject.org; Wed, 23 Apr 2014 12:23:31 +0000 In-Reply-To: <5357C581020000780000B6A8@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Keir Fraser , Tim Deegan , IanJackson , Aravind Gopalakrishnan , suravee.suthikulpanit@amd.com, xen-devel List-Id: xen-devel@lists.xenproject.org On Wed, 2014-04-23 at 12:52 +0100, Jan Beulich wrote: > >>> On 23.04.14 at 12:23, wrote: > > On Wed, 2014-04-16 at 15:34 +0100, Jan Beulich wrote: > >> @@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext { > >> uint16_t sysenter_callback_cs; > >> uint8_t syscall32_disables_events; > >> uint8_t sysenter_disables_events; > >> + uint16_t msr_count; > >> #if defined(__GNUC__) > >> union { > >> uint64_aligned_t mcg_cap; > >> @@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext { > >> #else > >> struct hvm_vmce_vcpu vmce; > >> #endif > >> + XEN_GUEST_HANDLE_64(xen_domctl_ext_vcpu_msr_t) msrs; > > > > I must be missing something because I can't see where the tools are > > initialising msrs, nor does the hypervisor appear to check it is valid > > before trying to save stuff to it (although that would be caught by the > > copy_to_user I expect). > > > > Also how does one go about determining the correct msr_count before > > retrieving this state? > > When msr_count is zero and MSRs are there that need storing, the > call will return -ENOBUFS and set msr_count to the required (minimum) > value. Furthermore the field is only being looked at if the size stored > inside the structure covers the entire msrs field. And yes, if > msr_count is non-zero but msrs doesn't point to a valid memory block, > copy_to_guest() will catch this (as usual). All makes sense. Worth a comment though? > So as is the tools are fine not explicitly setting msr_count (it's being > implicitly set to zero) - state save will fail in that case. It's the 3rd > (unfinished and now delayed until after Andrew's re-write) patch > that would be dealing with that error, re-issuing the call after > allocating a suitable array. That would be a bisection hazard wouldn't it? The tools side needs to be part of this patch I think. In any case I suppose this series should wait until the 3rd patch is available? Ian.