From: "Jan Beulich" Subject: Re: [PATCH RFC v12 14/21] pvh: read_descriptor for PVH guests. Date: Wed, 18 Sep 2013 16:00:03 +0100 Message-ID: <5239DC1302000078000F4719@nat28.tlf.novell.com> References: <1379089521-25720-1-git-send-email-george.dunlap@eu.citrix.com> <1379089521-25720-15-git-send-email-george.dunlap@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VMJEe-0003ie-IU for xen-devel@lists.xenproject.org; Wed, 18 Sep 2013 15:00:08 +0000 In-Reply-To: <1379089521-25720-15-git-send-email-george.dunlap@eu.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: George Dunlap Cc: xen-devel , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 13.09.13 at 18:25, George Dunlap wrote: > This is in preparation for enabling emulated privops for PVH guests. > > This one unfortunately has a bit more of an impedance mismatch: > > * For PV, the selector is hard-coded in by passing #name in the > #define. For PVH, we have to do a switch statement. > > * For PV, given the desrciptor, it can read the resulting base, limit, > &c directly; for PVH, we have to read the values currently loaded in the > vmcs. > > This leads to a rather awkward construct where we *both* read the > descriptor, *and* specify a selector, and introduce an intermediate > function, > read_descriptor_sel. > > Unfortunately, without introducing a rather pointless switch() > statement to the PV path similar to the one in the PVH path, there's > no way to make this less awkward. > > Signed-off-by: George Dunlap > Signed-off-by: Mukesh Rathor Reviewed-by: Jan Beulich with one really minor comment: > +static int read_descriptor_sel(unsigned int sel, > + enum x86_segment which_sel, > + struct vcpu *v, > + const struct cpu_user_regs *regs, > + unsigned long *base, > + unsigned long *limit, > + unsigned int *ar, > + unsigned int vm86attr) > +{ > + struct segment_register seg; > + bool_t long_mode; > + > + if ( !is_pvh_vcpu(v) ) > + return read_descriptor(sel, v, regs, base, limit, ar, vm86attr); > + > + hvm_get_segment_register(v, x86_seg_cs, &seg); > + long_mode = seg.attr.fields.l; > + > + if ( which_sel != x86_seg_cs ) > + hvm_get_segment_register(v, which_sel, &seg); > + > + /* "ar" is returned packed as in segment_attributes_t. Fix it up. */ > + *ar = seg.attr.bytes; > + *ar = (*ar & 0xff ) | ((*ar & 0xf00) << 4); Stray blank before the first closing parenthesis. Jan