From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v3 07/32] xen/x86: fix arch_set_info_guest for HVM guests Date: Fri, 24 Jul 2015 12:11:03 +0100 Message-ID: <55B21D47.4010109@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> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; Format="flowed" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIase-0002ml-8k for xen-devel@lists.xenproject.org; Fri, 24 Jul 2015 11:11:08 +0000 In-Reply-To: <55B20C9D.5070708@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: =?windows-1252?Q?Roger_Pau_Monn=E9?= , Jan Beulich Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky , Ian Campbell , David Vrabel List-Id: xen-devel@lists.xenproject.org On 24/07/15 10:59, Roger Pau Monn=E9 wrote: > El 24/07/15 a les 10.22, Jan Beulich ha escrit: >>>>> On 23.07.15 at 19:12, wrote: >>> I would go with Jan's suggestion and make >>> XEN_DOMCTL_{get/set}vcpucontext ineligible for use on HVM guests. >> Plus, as you said earlier, a new VCPUOP_initialize. > (Adding the Linux maintainers to get their opinion on the interface) > > Just to recap and to make sure I got all the points: > > - vCPU initialization from the toolstack (BSP initialization) is going > to be done using XEN_DOMCTL_sethvmcontext. > - XEN_DOMCTL_{get/set}vcpucontext is going to return EOPNOTSUPP for > HVM guests. > - A new vcpu_guest_contatext (vcpu_hvm_context?) is going to be > introduced together with a a new VCPUOP_initialize hypercall > (VCPUOP_hvm_initialize?). > > The following is a layout proposal for the new vcpu_context: > > struct vcpu_hvm_context { > /* 32bit fields of the structure will be used. */ > #define _VCPUHVM_MODE_32B 0 > #define VCPUHVM_MODE_32B (1<<_VCPUHVM_MODE_32B) > /* 64bit fields of the structure will be used. */ > #define _VCPUHVM_MODE_64B 1 > #define VCPUHVM_MODE_64B (1<<_VCPUHVM_MODE_64B) > #define _VCPUHVM_online 2 > #define VCPUHVM_online (1<<_VCPUHVM_online ) > uint32_t flags; /* VCPUHVM_* flags. */ > struct cpu_hvm_regs user_regs; /* CPU registers. */ > }; To avoid making the 32bit (and optionally 16bit) massive as a side = effect of 64bit, can I suggest uint32_t flags; union { cpu_hvm32_regs; cpu_hvm64_regs; }; Which allows hvm32_regs to be a far smaller structure. > > #if defined(__GNUC__) && !defined(__STRICT_ANSI__) > /* Anonymous union includes both 32- and 64-bit names (e.g., ebp/rbp). */ > # define __DECL_REG(n64, n32) union { \ > uint64_t n64; \ > uint32_t n32; \ > } > #else > /* Non-gcc sources must always use the proper 64-bit name (e.g., rbp). */ > #define __DECL_REG(n64, n32) uint64_t n64 > #endif > > #define __DECL_GP_REG(n) __DECL_REG(r##n, e##n) > > struct cpu_hvm_regs { > /* General purpose registers. */ > __DECL_GP_REG(bx); > __DECL_GP_REG(cx); > __DECL_GP_REG(dx); > __DECL_GP_REG(si); > __DECL_GP_REG(di); > __DECL_GP_REG(bp); > __DECL_GP_REG(ax); > __DECL_GP_REG(ip); > __DECL_GP_REG(sp); > __DECL_GP_REG(flags); > > /* Control registers. */ > uint64_t cr[8]; > /* Valid on amd64 only. */ > uint64_t efer; > > /* Debug registers. */ > uint64_t db[8]; > }; > > #undef __DECL_GP_REG > #undef __DECL_REG > > Of course the APs will be allowed to start in any mode they wish, > regardless of the mode the guest is currently running on. To start straight in 64bit, you need gdtr and cs as a minimum With that in mind, room for each of the task registers, and segment = selectors. ~Andrew