From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?windows-1252?Q?Roger_Pau_Monn=E9?= Subject: Re: [PATCH v3 07/32] xen/x86: fix arch_set_info_guest for HVM guests Date: Wed, 5 Aug 2015 11:53:32 +0200 Message-ID: <55C1DD1C.3060108@citrix.com> References: <1435923310-9019-1-git-send-email-roger.pau@citrix.com> <1435923310-9019-8-git-send-email-roger.pau@citrix.com> <55A3E0F102000078000903B5@mail.emea.novell.com> <55B0C100.6000308@citrix.com> <55B0EC520200007800094842@prv-mh.provo.novell.com> <1437651718.19412.92.camel@citrix.com> <55B103DD.4030901@citrix.com> <55B125440200007800094BD2@prv-mh.provo.novell.com> <55B10CDB.5010708@citrix.com> <1437667259.24746.12.camel@citrix.com> <55B11316.2000201@citrix.com> <55B130420200007800094CB8@prv-mh.provo.novell.com> <55B11CBE.8050704@citrix.com> <55B1208C.9090207@citrix.com> <55B211D70200007800094FCF@prv-mh.provo.novell.com> <55B20C9D.5070708@citrix.com> <55B233890200007800095124@prv-mh.provo.novell.com> <55B22B5A.8020304@citrix.com> <55B24F4A02000078000952CC@prv-mh.provo.novell.com> <55B25941.9@citrix.com> <55B27AAB02000078000954A0@prv-mh.provo.novell.com> <55B26DB1.4020302@citrix.com> <55BF9CE6.1030904@citrix.com> <55BFA569.7050102@citrix.com> <55C0FF93.70501@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZMvOk-0000Fh-HV for xen-devel@lists.xenproject.org; Wed, 05 Aug 2015 09:54:10 +0000 In-Reply-To: <55C0FF93.70501@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: Andrew Cooper , Jan Beulich Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky , David Vrabel , Ian Campbell List-Id: xen-devel@lists.xenproject.org El 04/08/15 a les 20.08, Andrew Cooper ha escrit: > On 03/08/15 18:31, Roger Pau Monn=E9 wrote: >>> Therefore, I am leaning slightly towards the specify the internals side >>> of things, which removes some complexity from the Xen side of the hyper= call. >> I've updated the proposed structure, so now it looks like: >> >> (I still need to figure out how to order the bits in the access rights = >> (_ar) fields.) > = > All struct's need a flags register. I was unsure about adding the {e/r}flags register, I will add it in new versions. >> >> struct vcpu_hvm_x86_16 { >> uint16_t ax; >> uint16_t cx; >> uint16_t dx; >> uint16_t bx; >> uint16_t sp; >> uint16_t bp; >> uint16_t si; >> uint16_t di; >> uint16_t ip; >> >> uint32_t cr[8]; > = > Definitely no need for anything other than cr0 and 4 in 16 bit mode. Yes. Would you rather prefer to spell out the exact control registers that are going to be used instead of using an array? For 16bit mode this is going to be CR0/CR4, for 32bit or long mode mode CR0/CR3/CR4. >> >> 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; >> }; >> >> struct vcpu_hvm_x86_32 { >> uint32_t eax; >> uint32_t ecx; >> uint32_t edx; >> uint32_t ebx; >> uint32_t esp; >> uint32_t ebp; >> uint32_t esi; >> uint32_t edi; >> uint32_t eip; >> >> uint32_t cr[8]; > = > Don't need cr's 5-8. > = >> uint64_t efer; >> >> 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 GDT, and we allow loading the cached part, which is the relevant one. > = >> }; >> >> struct vcpu_hvm_x86_64 { >> uint64_t rax; >> uint64_t rcx; >> uint64_t rdx; >> uint64_t rbx; >> uint64_t rsp; >> uint64_t rbp; >> uint64_t rsi; >> uint64_t rdi; >> uint64_t r8; >> uint64_t r9; >> uint64_t r10; >> uint64_t r11; >> uint64_t r12; >> uint64_t r13; >> uint64_t r14; >> uint64_t r15; >> uint64_t rip; >> >> uint64_t cr[8]; >> uint64_t efer; > = > What has happened to the segment information? It cannot be omitted > completely, even in 64bit. I had in mind to set them to the values required for long mode: base =3D 0 limit =3D 0xffff and the attributes field for CS to: ar =3D 0x29b (L bit set) And for SS/DS: ar =3D 0x093 But maybe it makes sense to allow setting them in case someone wants to start in compatibility mode. >> }; >> >> typedef enum { >> VCPU_HVM_MODE_16B, /* 16bit fields of the structure will be us= ed. */ >> VCPU_HVM_MODE_32B, /* 32bit fields of the structure will be us= ed. */ >> VCPU_HVM_MODE_64B, /* 64bit fields of the structure will be us= ed. */ >> } vcpu_hvm_mode_t; >> >> struct vcpu_hvm_context { >> vcpu_hvm_mode_t mode; > = > The width of an enum is implementation defined, which makes them > unsuitable in the public interface. Right, I'm going to change it to a uint32_t and the modes to defines. > = >> >> /* CPU registers. */ >> union { >> struct vcpu_hvm_x86_16 x86_16; >> struct vcpu_hvm_x86_32 x86_32; >> struct vcpu_hvm_x86_64 x86_64; >> }; > = > We require C89 compatibility for the public interface, so no anonymous > unions. Ack, thanks for the review. Roger.