From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH v3 07/32] xen/x86: fix arch_set_info_guest for HVM guests Date: Fri, 7 Aug 2015 13:15:50 +0100 Message-ID: <20150807121550.GA1778@deinos.phlegethon.org> References: <55B27AAB02000078000954A0@prv-mh.provo.novell.com> <55B26DB1.4020302@citrix.com> <55BF9CE6.1030904@citrix.com> <55BFA569.7050102@citrix.com> <55C0FF93.70501@citrix.com> <55C1DD1C.3060108@citrix.com> <55C22E1C.5020703@citrix.com> <55C23C6E.9010300@citrix.com> <55C23DD5.3030702@citrix.com> <55C243B5.50406@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZNgZA-0003Sy-75 for xen-devel@lists.xenproject.org; Fri, 07 Aug 2015 12:16:04 +0000 Content-Disposition: inline In-Reply-To: <55C243B5.50406@citrix.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: Roger Pau =?iso-8859-1?Q?Monn=E9?= Cc: Ian Campbell , Andrew Cooper , David Vrabel , Jan Beulich , xen-devel@lists.xenproject.org, Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org At 19:11 +0200 on 05 Aug (1438801877), Roger Pau Monn=E9 wrote: > El 05/08/15 a les 18.46, Andrew Cooper ha escrit: > > On 05/08/15 17:40, Roger Pau Monn=E9 wrote: > >> El 05/08/15 a les 17.39, Andrew Cooper ha escrit: > >>> On 05/08/15 10:53, Roger Pau Monn=E9 wrote: > >>>> El 04/08/15 a les 20.08, Andrew Cooper ha escrit: > >>>>> On 03/08/15 18:31, Roger Pau Monn=E9 wrote: > >>>>>> uint32_t cs_base; > >>>>>> uint32_t ds_base; > >>>>>> uint32_t ss_base; > >>>>>> uint32_t cs_limit; > >>>>>> uint32_t ds_limit; > >>>>>> uint32_t ss_limit; > >>>>>> uint16_t cs_ar; > >>>>>> uint16_t ds_ar; > >>>>>> uint16_t ss_ar; > >>>>> You need selector entries for each segment as well. > >>>> Really? What's the point in having the selector if we don't have a G= DT, > >>>> and we allow loading the cached part, which is the relevant one. > >>> push %cs; push 1f; lret > >>> > >>> At all points when segment details are updated, it is the responsibil= ity > >>> of software to ensure that the details match with the GDT/LDT entry. = > >>> See for example the Intel and AMD manuals for syscall/sysenter where > >>> similar "updating segment details behind the scenes" occurs. > >> I would certainly expect the user to have loaded a proper GDT and > >> reloaded the segments selectors before attempting to do something like > >> the above. > >> > >> I really don't mind adding a cs_sel, ds_sel, ss_sel and tr_sel, I just > >> think it's quite pointless because it's common practice to load a GDT > >> and then reload the segment selectors to point to the right entries. > > = > > Consider what would happen if the vcpu hits mmio and bounces into Xen > > for emulation before reloading the segment selectors. > = > I hope Xen is just going to kill the guest. > = > > The segment selector information needs to be consistent, as it might not > > be the guest which is the next entity to observe the vcpu state. > = > I guess I'm missing something, but AFAICT we already start the BSP in > such "inconsistent" state, the cached part of the selectors is right but > the selectors themselves don't point to valid GDT entries because > there's no GDT loaded. Yes, and in extending this call to HVM it should be fine to do the same. It would be nice to have a document describing the CPU state that the HVM guest will find itself in after this call. (In particular that the segments will be set up but not the descriptor tables, and that the selectors may not be relied upon). Cheers, Tim.