From: "Jan Beulich" Subject: Re: [PATCH 09/18] PVH xen: Support privileged op emulation for PVH Date: Thu, 04 Jul 2013 09:04:48 +0100 Message-ID: <51D548C002000078000E2A3A@nat28.tlf.novell.com> References: <1372118507-16864-1-git-send-email-mukesh.rathor@oracle.com> <1372118507-16864-10-git-send-email-mukesh.rathor@oracle.com> <51C980C902000078000E0445@nat28.tlf.novell.com> <20130626154130.6c50b347@mantra.us.oracle.com> <51CC046202000078000E106E@nat28.tlf.novell.com> <20130627164339.476d2ef3@mantra.us.oracle.com> <51CD718F02000078000E17B3@nat28.tlf.novell.com> <20130702183815.621e95f8@mantra.us.oracle.com> <51D4174002000078000E26E3@nat28.tlf.novell.com> <20130703190016.1a20e418@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130703190016.1a20e418@mantra.us.oracle.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: Mukesh Rathor Cc: xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 04.07.13 at 04:00, Mukesh Rathor wrote: > On Wed, 03 Jul 2013 11:21:20 +0100 "Jan Beulich" wrote: >> Even if it really is (which I doubt), you still would make PVH >> different from both PV and HVM, which both don't populate the >> selector fields of the frame (PV obviously has ->cs and ->ss >> populated [by the CPU], but HVM avoids even that). > > And what's wrong with PVH being little different? There's nothing wrong with this as long as it's for a useful purpose, and without introducing hidden dependencies (the latter is what is happening here). Being different just for the purpose of being different is not desirable (and likely not even acceptable, as in any case this makes code more difficult to understand). >> We'll have to see - at the first glance I don't follow... > > Here's what I am talking about: > > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -1241,10 +1241,10 @@ static void save_segments(struct vcpu *v) > struct cpu_user_regs *regs = &v->arch.user_regs; > unsigned int dirty_segment_mask = 0; > > - regs->ds = read_segment_register(v, regs, ds); > - regs->es = read_segment_register(v, regs, es); > - regs->fs = read_segment_register(v, regs, fs); > - regs->gs = read_segment_register(v, regs, gs); > + regs->ds = read_segment_register(v, regs, x86_seg_ds); > + regs->es = read_segment_register(v, regs, x86_seg_es); > + regs->fs = read_segment_register(v, regs, x86_seg_fs); > + regs->gs = read_segment_register(v, regs, x86_seg_gs); This I think is completely pointless a change if you keep the thing being a macro (using token concatenation): #define read_segment_register(vcpu, regs, name) \ ({ u16 sel_; \ const struct vcpu *vcpu_ = (vcpu); \ const struct cpu_user_regs *regs_ = (regs); \ \ if ( is_pvh_vcpu(vcpu_) && guest_mode(regs_) ) \ sel_ = pvh_get_selector(vcpu_, x86_seg_##name); \ else \ asm volatile ( "movw %%" #name ",%0" : "=r" (sel_) ); \ sel_; \ }) Jan