From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH v4 09/31] libxc: introduce a xc_dom_arch for hvm-3.0-x86_32 guests Date: Fri, 7 Aug 2015 13:00:48 +0100 Message-ID: <20150807120048.GI6005@zion.uk.xensource.com> References: <1438942688-7610-1-git-send-email-roger.pau@citrix.com> <1438942688-7610-10-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" 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 1ZNgKV-0002Ae-Fb for xen-devel@lists.xenproject.org; Fri, 07 Aug 2015 12:00:55 +0000 Content-Disposition: inline In-Reply-To: <1438942688-7610-10-git-send-email-roger.pau@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 Monne Cc: xen-devel@lists.xenproject.org, Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Fri, Aug 07, 2015 at 12:17:46PM +0200, Roger Pau Monne wrote: > This xc_dom_arch will be used in order to build HVM domains. The code is > based on the existing xc_hvm_populate_memory and xc_hvm_populate_params > functions. > = > Signed-off-by: Roger Pau Monn=E9 > Cc: Ian Jackson > Cc: Stefano Stabellini > Cc: Ian Campbell > Cc: Wei Liu > --- > Changes since v3: > - Make sure c/s b9dbe33 is not reverted on this patch. > - Set the initial BSP state using {get/set}hvmcontext. > --- [...] > +static void build_hvm_info(void *hvm_info_page, struct xc_dom_image *dom) > +{ [...] > +} > + > +static int alloc_magic_pages_hvm(struct xc_dom_image *dom) > +{ [...] > +static int meminit_hvm(struct xc_dom_image *dom) > +{ I didn't do a line by line comparison with original implementation for every items in these functions, but if you forgot to move something here I'm pretty sure we can easily spot that in the future. :-) [...] > + xc_hvm_param_set(xch, domid, HVM_PARAM_IDENT_PT, > + special_pfn(SPECIALPAGE_IDENT_PT) << PAGE_SHIFT); > + > + dom->console_pfn =3D special_pfn(SPECIALPAGE_CONSOLE); > + dom->xenstore_pfn =3D special_pfn(SPECIALPAGE_XENSTORE); > + dom->parms.virt_hypercall =3D -1; > + > + rc =3D 0; > + goto out; > + error_out: > + rc =3D -1; > + out: > + > + return rc; You can just write: rc =3D 0; return rc; error_out: rc =3D -1 return rc; > +} > + > /* ---------------------------------------------------------------------= --- */ > = > static int start_info_x86_32(struct xc_dom_image *dom) > @@ -682,6 +833,103 @@ static int vcpu_x86_64(struct xc_dom_image *dom) > return rc; > } > = > +static int vcpu_hvm(struct xc_dom_image *dom) > +{ > + struct { > + struct hvm_save_descriptor header_d; > + HVM_SAVE_TYPE(HEADER) header; > + struct hvm_save_descriptor cpu_d; > + HVM_SAVE_TYPE(CPU) cpu; > + struct hvm_save_descriptor end_d; > + HVM_SAVE_TYPE(END) end; > + } bsp_ctx; > + uint8_t *full_ctx =3D NULL; > + int rc; > + > + DOMPRINTF_CALLED(dom->xch); > + > + /* > + * Get the full HVM context in order to have the header, it is not > + * possible to get the header with getcontext_partial, and crafting = one > + * from userspace is also not an option since cpuid is trapped and > + * modified by Xen. > + */ > + > + rc =3D xc_domain_hvm_getcontext(dom->xch, dom->guest_domid, NULL, 0); > + if ( rc <=3D 0 ) > + { > + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, > + "%s: unable to fetch HVM context size (rc=3D%d)", > + __func__, rc); > + return rc; > + } > + full_ctx =3D malloc(rc); xc_dom_malloc? But you perhaps need hypercall safe buffer here. The rest of this patch looks like purely mechanic changes to me so I skip. Wei.