From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786564; cv=none; d=zohomail.com; s=zohoarc; b=jEhsTQU9QO6KlmGnXtlzDCG5/z3z5Sr8zhLYSrXDxEWG7M9UTE5d8gosqphKuSSHRZBxMslsIwTniRhSLSZq00ai+s55vQZ79qytnWKEuZKaW9LbbY7wSG90HQYItIu71UwKW5Fm7VcpYNGgApQvWNUJLFS0AOmPIx/V+b5fdwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786564; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=52BTUe4jpk+WRPGPjfc9HUIe/qPIv/ZJBRtNKVKcEa4=; b=aHzJm7mP5fvf20XXMZ76rhEJfJCJ+HmHS8fHjoRfdIdtIWd7Iwcv4FTWGkju/J1eGldHeq8xiD4cAR/yNLpf1LHD5vFrC/xPeMWi+ojPEu6TcRyawXBORAs/Paj+3XGXxPGnmFFzTzmTFwsJNgxGz1ZI0oEPuFOPtumhw3OdDls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1622786564845179.98580957866784; Thu, 3 Jun 2021 23:02:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136689.253336 (Exim 4.92) (envelope-from ) id 1lp2uW-0002hO-5R; Fri, 04 Jun 2021 06:02:24 +0000 Received: by outflank-mailman (output) from mailman id 136689.253336; Fri, 04 Jun 2021 06:02:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uW-0002hH-1J; Fri, 04 Jun 2021 06:02:24 +0000 Received: by outflank-mailman (input) for mailman id 136689; Fri, 04 Jun 2021 06:02:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uV-00029c-C6 for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:23 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8a99b291-3166-4068-be37-957b581354d1; Fri, 04 Jun 2021 06:02:17 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9706C1FD37; Fri, 4 Jun 2021 06:02:16 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 66EB511A98; Fri, 4 Jun 2021 06:02:16 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id yJwFGOjBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8a99b291-3166-4068-be37-957b581354d1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786536; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52BTUe4jpk+WRPGPjfc9HUIe/qPIv/ZJBRtNKVKcEa4=; b=KCOLNc9rrbfAUNqoCLZgCTaMV9Hsq6OfO/Caxjo4dk5E5foJXWirfH3urL65K91EVUPsx+ KMZHhfwC1cI/BLRxuzv7bvznYMjMG2tS/IK/TMzV1EvoUnw2icN8XSOnQS8vgbJ/Lv1aay GrGRyNhbbVYqyC02FrfRe5ugRdpuU/w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786536; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52BTUe4jpk+WRPGPjfc9HUIe/qPIv/ZJBRtNKVKcEa4=; b=KCOLNc9rrbfAUNqoCLZgCTaMV9Hsq6OfO/Caxjo4dk5E5foJXWirfH3urL65K91EVUPsx+ KMZHhfwC1cI/BLRxuzv7bvznYMjMG2tS/IK/TMzV1EvoUnw2icN8XSOnQS8vgbJ/Lv1aay GrGRyNhbbVYqyC02FrfRe5ugRdpuU/w= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 1/6] tools/libs/guest: fix max_pfn setting in map_p2m() Date: Fri, 4 Jun 2021 08:02:09 +0200 Message-Id: <20210604060214.14924-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" When setting the highest pfn used in the guest, don't subtract 1 from the value read from the shared_info data. The value read already is the correct pfn. Fixes: 91e204d37f449 ("libxc: try to find last used pfn when migrating") Signed-off-by: Juergen Gross Acked-by: Wei Liu --- This is a backport candidate --- tools/libs/guest/xg_sr_save_x86_pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libs/guest/xg_sr_save_x86_pv.c b/tools/libs/guest/xg_sr_= save_x86_pv.c index 4964f1f7b8..dae7f2817f 100644 --- a/tools/libs/guest/xg_sr_save_x86_pv.c +++ b/tools/libs/guest/xg_sr_save_x86_pv.c @@ -468,7 +468,7 @@ static int map_p2m(struct xc_sr_context *ctx) =20 ctx->x86.pv.p2m_generation =3D ~0ULL; ctx->x86.pv.max_pfn =3D GET_FIELD(ctx->x86.pv.shinfo, arch.max_pfn, - ctx->x86.pv.width) - 1; + ctx->x86.pv.width); p2m_cr3 =3D GET_FIELD(ctx->x86.pv.shinfo, arch.p2m_cr3, ctx->x86.pv.wi= dth); =20 return p2m_cr3 ? map_p2m_list(ctx, p2m_cr3) : map_p2m_tree(ctx); --=20 2.26.2 From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786565; cv=none; d=zohomail.com; s=zohoarc; b=bZZmpBzaKTwksEwT2FrXyDcyfWYbdyI0KoMTxsbOByWWr8kLkgGXa5hqpx4yzQnccegZ5Np1lxD7SL3PRnPalMZ95L0BJrL8ydpXViDr2WktXMBCvY5YMIPpwwd23kibrJIthO6SapGyX5E07DAx5aSe4iZoBc2WkFASUHDD3FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786565; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OwgDOczTgEHvqLD+ix9Tn8HCQdRqPLvi5r+OvXHSj60=; b=DdeiJR2Z1JraQJ/TFlwWfYzJzt33EewmNIcOB5Lm8v4M3srzrvDrAm+/mKKNr3Cu+oYfAcLx3Lzb14VUav/4FpXbA1mXoVTGTenYUUnqcHUpZSUlUrkAD0/yzSnm51pndwvMfBSoqWpRFUp7f8kVg7Cy8oTku7yuyt0+g9PXYEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1622786565055678.4078183635252; Thu, 3 Jun 2021 23:02:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136688.253317 (Exim 4.92) (envelope-from ) id 1lp2uS-0002DF-OJ; Fri, 04 Jun 2021 06:02:20 +0000 Received: by outflank-mailman (output) from mailman id 136688.253317; Fri, 04 Jun 2021 06:02:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uS-0002C4-KL; Fri, 04 Jun 2021 06:02:20 +0000 Received: by outflank-mailman (input) for mailman id 136688; Fri, 04 Jun 2021 06:02:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uQ-00029d-Pn for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:18 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fd639606-54a5-424a-ade5-a0bc748bb5f2; Fri, 04 Jun 2021 06:02:17 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D2D141FD3F; Fri, 4 Jun 2021 06:02:16 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 9F923118DD; Fri, 4 Jun 2021 06:02:16 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id IOG/JejBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fd639606-54a5-424a-ade5-a0bc748bb5f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786536; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OwgDOczTgEHvqLD+ix9Tn8HCQdRqPLvi5r+OvXHSj60=; b=jGNSg8htPDB6y00AVooNV8BpEsX2ZldYrK8DWFmwTrg/FvyDoalUMJ3MGdrB9Mm4lPh2Bg UhIClXNlrMniMUrqSKQf2ER1sNeQTKLAMx4io4ihHz4GWkoGQFGsIx5c6gXOQHuydkDBw/ R+Sg/BUQsn8IvMhGVJGI98bmum1X02I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786536; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OwgDOczTgEHvqLD+ix9Tn8HCQdRqPLvi5r+OvXHSj60=; b=jGNSg8htPDB6y00AVooNV8BpEsX2ZldYrK8DWFmwTrg/FvyDoalUMJ3MGdrB9Mm4lPh2Bg UhIClXNlrMniMUrqSKQf2ER1sNeQTKLAMx4io4ihHz4GWkoGQFGsIx5c6gXOQHuydkDBw/ R+Sg/BUQsn8IvMhGVJGI98bmum1X02I= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 2/6] tools/libs/ctrl: fix xc_core_arch_map_p2m() to support linear p2m table Date: Fri, 4 Jun 2021 08:02:10 +0200 Message-Id: <20210604060214.14924-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The core of a pv linux guest produced via "xl dump-core" is nor usable as since kernel 4.14 only the linear p2m table is kept if Xen indicates it is supporting that. Unfortunately xc_core_arch_map_p2m() is still supporting the 3-level p2m tree only. Fix that by copying the functionality of map_p2m() from libxenguest to libxenctrl. Additionally the mapped p2m isn't of a fixed length now, so the interface to the mapping functions needs to be adapted. In order not to add even more parameters, expand struct domain_info_context and use a pointer to that as a parameter. Fixes: dc6d60937121 ("libxc: set flag for support of linear p2m list in dom= ain builder") Signed-off-by: Juergen Gross Acked-by: Wei Liu --- This is a backport candidate. --- tools/include/xenguest.h | 1 + tools/libs/ctrl/xc_core.c | 5 +- tools/libs/ctrl/xc_core.h | 8 +- tools/libs/ctrl/xc_core_arm.c | 23 +-- tools/libs/ctrl/xc_core_x86.c | 256 ++++++++++++++++++++++++++++------ tools/libs/ctrl/xc_private.h | 1 + tools/libs/guest/xg_domain.c | 17 +-- 7 files changed, 233 insertions(+), 78 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index a4492038cf..f9fb0449ad 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -700,6 +700,7 @@ struct xc_domain_meminfo { xen_pfn_t *pfn_type; xen_pfn_t *p2m_table; unsigned long p2m_size; + unsigned int p2m_frames; }; =20 int xc_map_domain_meminfo(xc_interface *xch, uint32_t domid, diff --git a/tools/libs/ctrl/xc_core.c b/tools/libs/ctrl/xc_core.c index b47ab2f6d8..9576bec5a3 100644 --- a/tools/libs/ctrl/xc_core.c +++ b/tools/libs/ctrl/xc_core.c @@ -574,8 +574,7 @@ xc_domain_dumpcore_via_callback(xc_interface *xch, goto out; } =20 - sts =3D xc_core_arch_map_p2m(xch, dinfo->guest_width, &info, live_= shinfo, - &p2m, &dinfo->p2m_size); + sts =3D xc_core_arch_map_p2m(xch, dinfo, &info, live_shinfo, &p2m); if ( sts !=3D 0 ) goto out; =20 @@ -945,7 +944,7 @@ out: if ( memory_map !=3D NULL ) free(memory_map); if ( p2m !=3D NULL ) - munmap(p2m, PAGE_SIZE * P2M_FL_ENTRIES); + munmap(p2m, PAGE_SIZE * dinfo->p2m_frames); if ( p2m_array !=3D NULL ) free(p2m_array); if ( pfn_array !=3D NULL ) diff --git a/tools/libs/ctrl/xc_core.h b/tools/libs/ctrl/xc_core.h index 36fb755da2..8ea1f93a10 100644 --- a/tools/libs/ctrl/xc_core.h +++ b/tools/libs/ctrl/xc_core.h @@ -138,14 +138,14 @@ int xc_core_arch_memory_map_get(xc_interface *xch, xc_dominfo_t *info, shared_info_any_t *liv= e_shinfo, xc_core_memory_map_t **mapp, unsigned int *nr_entries); -int xc_core_arch_map_p2m(xc_interface *xch, unsigned int guest_width, +int xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *di= nfo, xc_dominfo_t *info, shared_info_any_t *live_shinf= o, - xen_pfn_t **live_p2m, unsigned long *pfnp); + xen_pfn_t **live_p2m); =20 -int xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_wi= dth, +int xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_co= ntext *dinfo, xc_dominfo_t *info, shared_info_any_t *live_shinfo, - xen_pfn_t **live_p2m, unsigned long *pfn= p); + xen_pfn_t **live_p2m); =20 int xc_core_arch_get_scratch_gpfn(xc_interface *xch, uint32_t domid, xen_pfn_t *gpfn); diff --git a/tools/libs/ctrl/xc_core_arm.c b/tools/libs/ctrl/xc_core_arm.c index 7b587b4cc5..93765a565f 100644 --- a/tools/libs/ctrl/xc_core_arm.c +++ b/tools/libs/ctrl/xc_core_arm.c @@ -66,33 +66,24 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct x= c_core_arch_context *unus =20 static int xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, - unsigned long *pfnp, int rw) + shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, int rw) { errno =3D ENOSYS; return -1; } =20 int -xc_core_arch_map_p2m(xc_interface *xch, unsigned int guest_width, xc_domin= fo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, - unsigned long *pfnp) +xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_dominfo_t *info, + shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m) { - struct domain_info_context _dinfo =3D { .guest_width =3D guest_width }; - struct domain_info_context *dinfo =3D &_dinfo; - return xc_core_arch_map_p2m_rw(xch, dinfo, info, - live_shinfo, live_p2m, pfnp, 0); + return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 0); } =20 int -xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width,= xc_dominfo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m, - unsigned long *pfnp) +xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_dominfo_t *info, + shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m) { - struct domain_info_context _dinfo =3D { .guest_width =3D guest_width }; - struct domain_info_context *dinfo =3D &_dinfo; - return xc_core_arch_map_p2m_rw(xch, dinfo, info, - live_shinfo, live_p2m, pfnp, 1); + return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 1); } =20 int diff --git a/tools/libs/ctrl/xc_core_x86.c b/tools/libs/ctrl/xc_core_x86.c index cb76e6207b..c8f71d4b75 100644 --- a/tools/libs/ctrl/xc_core_x86.c +++ b/tools/libs/ctrl/xc_core_x86.c @@ -17,6 +17,7 @@ * */ =20 +#include #include "xc_private.h" #include "xc_core.h" #include @@ -65,34 +66,169 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct = xc_core_arch_context *unus return 0; } =20 -static int -xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_dominfo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, - unsigned long *pfnp, int rw) +static inline bool is_canonical_address(uint64_t vaddr) { - /* Double and single indirect references to the live P2M table */ - xen_pfn_t *live_p2m_frame_list_list =3D NULL; - xen_pfn_t *live_p2m_frame_list =3D NULL; - /* Copies of the above. */ - xen_pfn_t *p2m_frame_list_list =3D NULL; - xen_pfn_t *p2m_frame_list =3D NULL; + return ((int64_t)vaddr >> 47) =3D=3D ((int64_t)vaddr >> 63); +} =20 - uint32_t dom =3D info->domid; - int ret =3D -1; - int err; - int i; +/* Virtual address ranges reserved for hypervisor. */ +#define HYPERVISOR_VIRT_START_X86_64 0xFFFF800000000000ULL +#define HYPERVISOR_VIRT_END_X86_64 0xFFFF87FFFFFFFFFFULL =20 - if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 ) +#define HYPERVISOR_VIRT_START_X86_32 0x00000000F5800000ULL +#define HYPERVISOR_VIRT_END_X86_32 0x00000000FFFFFFFFULL + +static xen_pfn_t * +xc_core_arch_map_p2m_list_rw(xc_interface *xch, struct domain_info_context= *dinfo, + uint32_t dom, shared_info_any_t *live_shinfo, + uint64_t p2m_cr3) +{ + uint64_t p2m_vaddr, p2m_end, mask, off; + xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn; + uint64_t *ptes =3D NULL; + xen_pfn_t *mfns =3D NULL; + unsigned int fpp, n_pages, level, n_levels, shift, + idx_start, idx_end, idx, saved_idx; + + p2m_vaddr =3D GET_FIELD(live_shinfo, arch.p2m_vaddr, dinfo->guest_widt= h); + fpp =3D PAGE_SIZE / dinfo->guest_width; + dinfo->p2m_frames =3D (dinfo->p2m_size - 1) / fpp + 1; + p2m_end =3D p2m_vaddr + dinfo->p2m_frames * PAGE_SIZE - 1; + + if ( dinfo->guest_width =3D=3D 8 ) { - ERROR("Could not get maximum GPFN!"); - goto out; + mask =3D 0x0000ffffffffffffULL; + n_levels =3D 4; + p2m_mfn =3D p2m_cr3 >> 12; + if ( !is_canonical_address(p2m_vaddr) || + !is_canonical_address(p2m_end) || + p2m_end < p2m_vaddr || + (p2m_vaddr <=3D HYPERVISOR_VIRT_END_X86_64 && + p2m_end > HYPERVISOR_VIRT_START_X86_64) ) + { + ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64, + p2m_vaddr, p2m_end); + errno =3D ERANGE; + goto out; + } + } + else + { + mask =3D 0x00000000ffffffffULL; + n_levels =3D 3; + if ( p2m_cr3 & ~mask ) + p2m_mfn =3D ~0UL; + else + p2m_mfn =3D (uint32_t)((p2m_cr3 >> 12) | (p2m_cr3 << 20)); + if ( p2m_vaddr > mask || p2m_end > mask || p2m_end < p2m_vaddr || + (p2m_vaddr <=3D HYPERVISOR_VIRT_END_X86_32 && + p2m_end > HYPERVISOR_VIRT_START_X86_32) ) + { + ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64, + p2m_vaddr, p2m_end); + errno =3D ERANGE; + goto out; + } } =20 - if ( dinfo->p2m_size < info->nr_pages ) + mfns =3D malloc(sizeof(*mfns)); + if ( !mfns ) { - ERROR("p2m_size < nr_pages -1 (%lx < %lx", dinfo->p2m_size, info->= nr_pages - 1); + ERROR("Cannot allocate memory for array of %u mfns", 1); goto out; } + mfns[0] =3D p2m_mfn; + off =3D 0; + saved_mfn =3D 0; + idx_start =3D idx_end =3D saved_idx =3D 0; + + for ( level =3D n_levels; level > 0; level-- ) + { + n_pages =3D idx_end - idx_start + 1; + ptes =3D xc_map_foreign_pages(xch, dom, PROT_READ, mfns, n_pages); + if ( !ptes ) + { + PERROR("Failed to map %u page table pages for p2m list", n_pag= es); + goto out; + } + free(mfns); + + shift =3D level * 9 + 3; + idx_start =3D ((p2m_vaddr - off) & mask) >> shift; + idx_end =3D ((p2m_end - off) & mask) >> shift; + idx =3D idx_end - idx_start + 1; + mfns =3D malloc(sizeof(*mfns) * idx); + if ( !mfns ) + { + ERROR("Cannot allocate memory for array of %u mfns", idx); + goto out; + } + + for ( idx =3D idx_start; idx <=3D idx_end; idx++ ) + { + mfn =3D (ptes[idx] & 0x000ffffffffff000ULL) >> PAGE_SHIFT; + if ( mfn =3D=3D 0 ) + { + ERROR("Bad mfn %#lx during page table walk for vaddr %#" P= RIx64 " at level %d of p2m list", + mfn, off + ((uint64_t)idx << shift), level); + errno =3D ERANGE; + goto out; + } + mfns[idx - idx_start] =3D mfn; + + /* Maximum pfn check at level 2. Same reasoning as for p2m tre= e. */ + if ( level =3D=3D 2 ) + { + if ( mfn !=3D saved_mfn ) + { + saved_mfn =3D mfn; + saved_idx =3D idx - idx_start; + } + } + } + + if ( level =3D=3D 2 ) + { + if ( saved_idx =3D=3D idx_end ) + saved_idx++; + max_pfn =3D ((xen_pfn_t)saved_idx << 9) * fpp; + if ( max_pfn < dinfo->p2m_size ) + { + dinfo->p2m_size =3D max_pfn; + dinfo->p2m_frames =3D (dinfo->p2m_size + fpp - 1) / fpp; + p2m_end =3D p2m_vaddr + dinfo->p2m_frames * PAGE_SIZE - 1; + idx_end =3D idx_start + saved_idx; + } + } + + munmap(ptes, n_pages * PAGE_SIZE); + ptes =3D NULL; + off =3D p2m_vaddr & ((mask >> shift) << shift); + } + + return mfns; + + out: + free(mfns); + if ( ptes ) + munmap(ptes, n_pages * PAGE_SIZE); + + return NULL; +} + +static xen_pfn_t * +xc_core_arch_map_p2m_tree_rw(xc_interface *xch, struct domain_info_context= *dinfo, + uint32_t dom, shared_info_any_t *live_shinfo) +{ + /* Double and single indirect references to the live P2M table */ + xen_pfn_t *live_p2m_frame_list_list; + xen_pfn_t *live_p2m_frame_list =3D NULL; + /* Copies of the above. */ + xen_pfn_t *p2m_frame_list_list =3D NULL; + xen_pfn_t *p2m_frame_list; + + int err; + int i; =20 live_p2m_frame_list_list =3D xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_READ, @@ -151,10 +287,60 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct dom= ain_info_context *dinfo, xc for ( i =3D P2M_FL_ENTRIES - 1; i >=3D 0; i-- ) p2m_frame_list[i] =3D ((uint32_t *)p2m_frame_list)[i]; =20 + dinfo->p2m_frames =3D P2M_FL_ENTRIES; + + return p2m_frame_list; + + out: + err =3D errno; + + if ( live_p2m_frame_list_list ) + munmap(live_p2m_frame_list_list, PAGE_SIZE); + + if ( live_p2m_frame_list ) + munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE); + + free(p2m_frame_list_list); + + errno =3D err; + + return NULL; +} + +static int +xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *din= fo, xc_dominfo_t *info, + shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, int rw) +{ + xen_pfn_t *p2m_frame_list =3D NULL; + uint64_t p2m_cr3; + uint32_t dom =3D info->domid; + int ret =3D -1; + int err; + + if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 ) + { + ERROR("Could not get maximum GPFN!"); + goto out; + } + + if ( dinfo->p2m_size < info->nr_pages ) + { + ERROR("p2m_size < nr_pages -1 (%lx < %lx", dinfo->p2m_size, info->= nr_pages - 1); + goto out; + } + + p2m_cr3 =3D GET_FIELD(live_shinfo, arch.p2m_cr3, dinfo->guest_width); + + p2m_frame_list =3D p2m_cr3 ? xc_core_arch_map_p2m_list_rw(xch, dinfo, = dom, live_shinfo, p2m_cr3) + : xc_core_arch_map_p2m_tree_rw(xch, dinfo, do= m, live_shinfo); + + if ( !p2m_frame_list ) + goto out; + *live_p2m =3D xc_map_foreign_pages(xch, dom, rw ? (PROT_READ | PROT_WRITE) : PROT_R= EAD, p2m_frame_list, - P2M_FL_ENTRIES); + dinfo->p2m_frames); =20 if ( !*live_p2m ) { @@ -162,21 +348,11 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct dom= ain_info_context *dinfo, xc goto out; } =20 - *pfnp =3D dinfo->p2m_size; - ret =3D 0; =20 out: err =3D errno; =20 - if ( live_p2m_frame_list_list ) - munmap(live_p2m_frame_list_list, PAGE_SIZE); - - if ( live_p2m_frame_list ) - munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE); - - free(p2m_frame_list_list); - free(p2m_frame_list); =20 errno =3D err; @@ -184,25 +360,17 @@ out: } =20 int -xc_core_arch_map_p2m(xc_interface *xch, unsigned int guest_width, xc_domin= fo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m, - unsigned long *pfnp) +xc_core_arch_map_p2m(xc_interface *xch, struct domain_info_context *dinfo,= xc_dominfo_t *info, + shared_info_any_t *live_shinfo, xen_pfn_t **live_p= 2m) { - struct domain_info_context _dinfo =3D { .guest_width =3D guest_width }; - struct domain_info_context *dinfo =3D &_dinfo; - return xc_core_arch_map_p2m_rw(xch, dinfo, info, - live_shinfo, live_p2m, pfnp, 0); + return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 0); } =20 int -xc_core_arch_map_p2m_writable(xc_interface *xch, unsigned int guest_width,= xc_dominfo_t *info, - shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m, - unsigned long *pfnp) +xc_core_arch_map_p2m_writable(xc_interface *xch, struct domain_info_contex= t *dinfo, xc_dominfo_t *info, + shared_info_any_t *live_shinfo, xen_pfn_t **= live_p2m) { - struct domain_info_context _dinfo =3D { .guest_width =3D guest_width }; - struct domain_info_context *dinfo =3D &_dinfo; - return xc_core_arch_map_p2m_rw(xch, dinfo, info, - live_shinfo, live_p2m, pfnp, 1); + return xc_core_arch_map_p2m_rw(xch, dinfo, info, live_shinfo, live_p2m= , 1); } =20 int diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index f0b5f83ac8..8ebc0b59da 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -79,6 +79,7 @@ struct iovec { =20 struct domain_info_context { unsigned int guest_width; + unsigned int p2m_frames; unsigned long p2m_size; }; =20 diff --git a/tools/libs/guest/xg_domain.c b/tools/libs/guest/xg_domain.c index 5019c84e0e..dd7db2cbd8 100644 --- a/tools/libs/guest/xg_domain.c +++ b/tools/libs/guest/xg_domain.c @@ -24,13 +24,9 @@ =20 int xc_unmap_domain_meminfo(xc_interface *xch, struct xc_domain_meminfo *m= info) { - struct domain_info_context _di =3D { .guest_width =3D minfo->guest_wid= th, - .p2m_size =3D minfo->p2m_size}; - struct domain_info_context *dinfo =3D &_di; - free(minfo->pfn_type); if ( minfo->p2m_table ) - munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE); + munmap(minfo->p2m_table, minfo->p2m_frames * PAGE_SIZE); minfo->p2m_table =3D NULL; =20 return 0; @@ -40,7 +36,6 @@ int xc_map_domain_meminfo(xc_interface *xch, uint32_t dom= id, struct xc_domain_meminfo *minfo) { struct domain_info_context _di; - struct domain_info_context *dinfo =3D &_di; =20 xc_dominfo_t info; shared_info_any_t *live_shinfo; @@ -96,16 +91,16 @@ int xc_map_domain_meminfo(xc_interface *xch, uint32_t d= omid, return -1; } =20 - if ( xc_core_arch_map_p2m_writable(xch, minfo->guest_width, &info, - live_shinfo, &minfo->p2m_table, - &minfo->p2m_size) ) + if ( xc_core_arch_map_p2m_writable(xch, &_di, &info, + live_shinfo, &minfo->p2m_table) ) { PERROR("Could not map the P2M table"); munmap(live_shinfo, PAGE_SIZE); return -1; } munmap(live_shinfo, PAGE_SIZE); - _di.p2m_size =3D minfo->p2m_size; + minfo->p2m_size =3D _di.p2m_size; + minfo->p2m_frames =3D _di.p2m_frames; =20 /* Make space and prepare for getting the PFN types */ minfo->pfn_type =3D calloc(sizeof(*minfo->pfn_type), minfo->p2m_size); @@ -141,7 +136,7 @@ failed: } if ( minfo->p2m_table ) { - munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE); + munmap(minfo->p2m_table, minfo->p2m_frames * PAGE_SIZE); minfo->p2m_table =3D NULL; } =20 --=20 2.26.2 From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786564; cv=none; d=zohomail.com; s=zohoarc; b=h0lXzMzG7VJLJDpN4B6wH6WJ8eAmR8Pbje6ZbbKSG6wXC5+Z71qjQMF624oujtVVI0KqeTrw/yG1fRrxBD6wUo+4cojF5hGxPCBYbwmrvkjByOI4BPPVDvyKq02sBh6IZAdhtZFbzvRwDfzIPXUrKkVa098Nqh8/4ynK2VUzuNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786564; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=isgrr2CDNqvffqwRlBKSl7qzhM9b8t1JhZ+3heZNMCc=; b=Y/KZSkBTpVI/7ywTFnQS4TzrjPcDZN3JLE/hbQRCHaodr3DfqwjWFjNfUEh+Dem0M0vG5K5SVjSYeXUvw4IBogy+NqWgcX4v8kPAY7OJ/d37KIgss6bRZMdomj59d3FMFAesH0wPBKNZTom4vcZqPo7uPb88ZJFwHsPUf+TfCjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1622786564951754.5497377191155; Thu, 3 Jun 2021 23:02:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136691.253358 (Exim 4.92) (envelope-from ) id 1lp2ub-0003MI-UF; Fri, 04 Jun 2021 06:02:29 +0000 Received: by outflank-mailman (output) from mailman id 136691.253358; Fri, 04 Jun 2021 06:02:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2ub-0003M7-Q7; Fri, 04 Jun 2021 06:02:29 +0000 Received: by outflank-mailman (input) for mailman id 136691; Fri, 04 Jun 2021 06:02:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2ua-00029c-CE for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:28 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dfc2046a-8261-4160-b6d7-d3a1b537cd64; Fri, 04 Jun 2021 06:02:17 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2375B21A09; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id DA946118DD; Fri, 4 Jun 2021 06:02:16 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 6Jg7NOjBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dfc2046a-8261-4160-b6d7-d3a1b537cd64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=isgrr2CDNqvffqwRlBKSl7qzhM9b8t1JhZ+3heZNMCc=; b=sUAmI//60kTaXOn6AY4IceYBFhGxX7lavmSv7qagAijQs3IOOcvv5Nfo+bfH7tUS8HzZSY 2tcteC707wNGr67m4I6R2Dywco3AMlboOQZufig/4sI+R5cXm+wk6WMlyxhsAndifNKIyH gi9AXLn8Sn92r/uaqrcb02Y6bYmg+jE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=isgrr2CDNqvffqwRlBKSl7qzhM9b8t1JhZ+3heZNMCc=; b=sUAmI//60kTaXOn6AY4IceYBFhGxX7lavmSv7qagAijQs3IOOcvv5Nfo+bfH7tUS8HzZSY 2tcteC707wNGr67m4I6R2Dywco3AMlboOQZufig/4sI+R5cXm+wk6WMlyxhsAndifNKIyH gi9AXLn8Sn92r/uaqrcb02Y6bYmg+jE= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu , Christian Lindig , David Scott Subject: [PATCH v2 3/6] tools/libs/ctrl: use common p2m mapping code in xc_domain_resume_any() Date: Fri, 4 Jun 2021 08:02:11 +0200 Message-Id: <20210604060214.14924-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Instead of open coding the mapping of the p2m list use the already existing xc_core_arch_map_p2m() call, especially as the current code does not support guests with the linear p2m map. It should be noted that this code is needed for colo/remus only. Switching to xc_core_arch_map_p2m() drops the need to bail out for bitness of tool stack and guest differing. Signed-off-by: Juergen Gross Acked-by: Christian Lindig Acked-by: Wei Liu --- This might be a backport candidate V2: - add missing #include in ocaml stub (Andrew Cooper) --- tools/libs/ctrl/xc_resume.c | 66 +++++++++-------------------- tools/ocaml/libs/xc/xenctrl_stubs.c | 1 + 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/tools/libs/ctrl/xc_resume.c b/tools/libs/ctrl/xc_resume.c index 94c6c9fb31..e3c8e83aa9 100644 --- a/tools/libs/ctrl/xc_resume.c +++ b/tools/libs/ctrl/xc_resume.c @@ -20,6 +20,7 @@ #include #include #include +#include "xc_core.h" =20 static int modify_returncode(xc_interface *xch, uint32_t domid) { @@ -137,12 +138,10 @@ static int xc_domain_resume_any(xc_interface *xch, ui= nt32_t domid) struct domain_info_context _dinfo =3D { .guest_width =3D 0, .p2m_size =3D 0 }; struct domain_info_context *dinfo =3D &_dinfo; - unsigned long mfn; + xen_pfn_t mfn, store_mfn, console_mfn; vcpu_guest_context_any_t ctxt; - start_info_t *start_info; - shared_info_t *shinfo =3D NULL; - xen_pfn_t *p2m_frame_list_list =3D NULL; - xen_pfn_t *p2m_frame_list =3D NULL; + start_info_any_t *start_info; + shared_info_any_t *shinfo =3D NULL; xen_pfn_t *p2m =3D NULL; #endif =20 @@ -164,11 +163,6 @@ static int xc_domain_resume_any(xc_interface *xch, uin= t32_t domid) PERROR("Could not get domain width"); return rc; } - if ( dinfo->guest_width !=3D sizeof(long) ) - { - ERROR("Cannot resume uncooperative cross-address-size guests"); - return rc; - } =20 /* Map the shared info frame */ shinfo =3D xc_map_foreign_range(xch, domid, PAGE_SIZE, @@ -179,34 +173,8 @@ static int xc_domain_resume_any(xc_interface *xch, uin= t32_t domid) goto out; } =20 - dinfo->p2m_size =3D shinfo->arch.max_pfn; - - p2m_frame_list_list =3D - xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ, - shinfo->arch.pfn_to_mfn_frame_list_list); - if ( p2m_frame_list_list =3D=3D NULL ) - { - ERROR("Couldn't map p2m_frame_list_list"); - goto out; - } - - p2m_frame_list =3D xc_map_foreign_pages(xch, domid, PROT_READ, - p2m_frame_list_list, - P2M_FLL_ENTRIES); - if ( p2m_frame_list =3D=3D NULL ) - { - ERROR("Couldn't map p2m_frame_list"); - goto out; - } - - /* Map all the frames of the pfn->mfn table. For migrate to succeed, - the guest must not change which frames are used for this purpose. - (its not clear why it would want to change them, and we'll be OK - from a safety POV anyhow. */ - p2m =3D xc_map_foreign_pages(xch, domid, PROT_READ, - p2m_frame_list, - P2M_FL_ENTRIES); - if ( p2m =3D=3D NULL ) + /* Map the p2m list */ + if ( xc_core_arch_map_p2m(xch, dinfo, &info, shinfo, &p2m) ) { ERROR("Couldn't map p2m table"); goto out; @@ -228,8 +196,20 @@ static int xc_domain_resume_any(xc_interface *xch, uin= t32_t domid) goto out; } =20 - start_info->store_mfn =3D p2m[start_info->store_mfn]; - start_info->console.domU.mfn =3D p2m[start_info->console.domU.mfn]; + store_mfn =3D GET_FIELD(start_info, store_mfn, dinfo->guest_width); + console_mfn =3D GET_FIELD(start_info, console.domU.mfn, dinfo->guest_w= idth); + if ( dinfo->guest_width =3D=3D 4 ) + { + store_mfn =3D ((uint32_t *)p2m)[store_mfn]; + console_mfn =3D ((uint32_t *)p2m)[console_mfn]; + } + else + { + store_mfn =3D ((uint64_t *)p2m)[store_mfn]; + console_mfn =3D ((uint64_t *)p2m)[console_mfn]; + } + SET_FIELD(start_info, store_mfn, store_mfn, dinfo->guest_width); + SET_FIELD(start_info, console.domU.mfn, console_mfn, dinfo->guest_widt= h); =20 munmap(start_info, PAGE_SIZE); #endif /* defined(__i386__) || defined(__x86_64__) */ @@ -250,11 +230,7 @@ static int xc_domain_resume_any(xc_interface *xch, uin= t32_t domid) out: #if defined(__i386__) || defined(__x86_64__) if (p2m) - munmap(p2m, P2M_FL_ENTRIES*PAGE_SIZE); - if (p2m_frame_list) - munmap(p2m_frame_list, P2M_FLL_ENTRIES*PAGE_SIZE); - if (p2m_frame_list_list) - munmap(p2m_frame_list_list, PAGE_SIZE); + munmap(p2m, dinfo->p2m_frames * PAGE_SIZE); if (shinfo) munmap(shinfo, PAGE_SIZE); #endif diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index d05d7bb30e..6e4bc567f5 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -32,6 +32,7 @@ =20 #define XC_WANT_COMPAT_MAP_FOREIGN_API #include +#include #include =20 #include "mmap_stubs.h" --=20 2.26.2 From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786564; cv=none; d=zohomail.com; s=zohoarc; b=LaGOCHbKNuxudUZJW2X3NQf5sItE169VGKU5OSYy9xx44hSZNUSCeR0kO8k1t9MkCq6C/nhx27QwGmHKn54aCxyg38ThmtfBwnWx/aooVrNpldVHFFglrRZqDgaEvQPeM9zXKn+zCLrvTeL2yvvA2pEm3eJLAUhn2VLYT6gX5x8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786564; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eIBjeTC4n1sKa6paY8ti6Xavmo8jAw6kAIRZige1e6Q=; b=XCFJlme61Megq2TGS3xGTSlSkoTcMgVmrfampma4KsuW1Hk9P07H5V56Tuq15tVe+DLUZSQgpUg8UBNuP2s1vp/bf+CBdY+HHp+HI/awOjEqMQMscFjlB7hNCCEKHIFV8+s3kjY8/uEO3UiPEQTx4Q0ZW+kTjQVsAO52XpZVA9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1622786564853898.8874868533895; Thu, 3 Jun 2021 23:02:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136690.253342 (Exim 4.92) (envelope-from ) id 1lp2uW-0002kh-KF; Fri, 04 Jun 2021 06:02:24 +0000 Received: by outflank-mailman (output) from mailman id 136690.253342; Fri, 04 Jun 2021 06:02:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uW-0002jS-Ah; Fri, 04 Jun 2021 06:02:24 +0000 Received: by outflank-mailman (input) for mailman id 136690; Fri, 04 Jun 2021 06:02:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uV-00029d-Kq for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:23 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3e75bed6-f25e-4c17-bf1d-2c16cc88ec47; Fri, 04 Jun 2021 06:02:18 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5BBDD21A0A; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 2B50C118DD; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id OJZkCenBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3e75bed6-f25e-4c17-bf1d-2c16cc88ec47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eIBjeTC4n1sKa6paY8ti6Xavmo8jAw6kAIRZige1e6Q=; b=npwQj0bxc5WTZl2jMjTKIHJfkGlQuZssSGTpjmDOzqVoBRhh8q7l9R1XA95x3VjW/B9y5F iUS/Q9avZoWD9kk0/pJQopzAaTcs7tOHac8VMEYNWpTjjF1QUnUb6K5Cm7/6zt4KPdqBUP DCu53gUpKeUjsgoHmOQ482WfAM9c0SM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eIBjeTC4n1sKa6paY8ti6Xavmo8jAw6kAIRZige1e6Q=; b=npwQj0bxc5WTZl2jMjTKIHJfkGlQuZssSGTpjmDOzqVoBRhh8q7l9R1XA95x3VjW/B9y5F iUS/Q9avZoWD9kk0/pJQopzAaTcs7tOHac8VMEYNWpTjjF1QUnUb6K5Cm7/6zt4KPdqBUP DCu53gUpKeUjsgoHmOQ482WfAM9c0SM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 4/6] tools/libs: move xc_resume.c to libxenguest Date: Fri, 4 Jun 2021 08:02:12 +0200 Message-Id: <20210604060214.14924-5-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The guest suspend functionality is already part of libxenguest. Move the resume functionality from libxenctrl to libxenguest, too. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/include/xenctrl.h | 63 ------------------- tools/include/xenguest.h | 62 ++++++++++++++++++ tools/libs/ctrl/Makefile | 1 - tools/libs/guest/Makefile | 1 + .../{ctrl/xc_resume.c =3D> guest/xg_resume.c} | 1 + 5 files changed, 64 insertions(+), 64 deletions(-) rename tools/libs/{ctrl/xc_resume.c =3D> guest/xg_resume.c} (99%) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 58d3377d6a..2a7c836a02 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -576,69 +576,6 @@ int xc_domain_destroy(xc_interface *xch, uint32_t domid); =20 =20 -/** - * This function resumes a suspended domain. The domain should have - * been previously suspended. - * - * Note that there are 'xc_domain_suspend' as suspending a domain - * is quite the endeavour. - * - * For the purpose of this explanation there are three guests: - * PV (using hypercalls for privilgied operations), HVM - * (fully hardware virtualized guests using emulated devices for everythin= g), - * and PVHVM (PV aware with hardware virtualisation). - * - * HVM guest are the simplest - they suspend via S3 / S4 and resume from - * S3 / S4. Upon resume they have to re-negotiate with the emulated device= s. - * - * PV and PVHVM communicate via hypercalls for suspend (and resume). - * For suspend the toolstack initiates the process by writing an value - * in XenBus "control/shutdown" with the string "suspend". - * - * The PV guest stashes anything it deems neccessary in 'struct - * start_info' in case of failure (PVHVM may ignore this) and calls - * the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall (for PV as - * argument it passes the MFN to 'struct start_info'). - * - * And then the guest is suspended. - * - * The checkpointing or notifying a guest that the suspend failed or - * cancelled (in case of checkpoint) is by having the - * SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return a non-zero - * value. - * - * The PV and PVHVM resume path are similar. For PV it would be - * similar to bootup - figure out where the 'struct start_info' is (or - * if the suspend was cancelled aka checkpointed - reuse the saved - * values). - * - * From here on they differ depending whether the guest is PV or PVHVM - * in specifics but follow overall the same path: - * - PV: Bringing up the vCPUS, - * - PVHVM: Setup vector callback, - * - Bring up vCPU runstates, - * - Remap the grant tables if checkpointing or setup from scratch, - * - * - * If the resume was not checkpointing (or if suspend was succesful) we wo= uld - * setup the PV timers and the different PV events. Lastly the PV drivers - * re-negotiate with the backend. - * - * This function would return before the guest started resuming. That is - * the guest would be in non-running state and its vCPU context would be - * in the the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return path - * (for PV and PVHVM). For HVM it would be in would be in QEMU emulated - * BIOS handling S3 suspend. - * - * @parm xch a handle to an open hypervisor interface - * @parm domid the domain id to resume - * @parm fast use cooperative resume (guest must support this) - * return 0 on success, -1 on failure - */ -int xc_domain_resume(xc_interface *xch, - uint32_t domid, - int fast); - /** * This function will shutdown a domain. This is intended for use in * fully-virtualized domains where this operation is analogous to the diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index f9fb0449ad..61d0a82f48 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -689,6 +689,68 @@ int xc_query_page_offline_status(xc_interface *xch, un= signed long start, =20 int xc_exchange_page(xc_interface *xch, uint32_t domid, xen_pfn_t mfn); =20 +/** + * This function resumes a suspended domain. The domain should have + * been previously suspended. + * + * Note that there are 'xc_domain_suspend' as suspending a domain + * is quite the endeavour. + * + * For the purpose of this explanation there are three guests: + * PV (using hypercalls for privilgied operations), HVM + * (fully hardware virtualized guests using emulated devices for everythin= g), + * and PVHVM (PV aware with hardware virtualisation). + * + * HVM guest are the simplest - they suspend via S3 / S4 and resume from + * S3 / S4. Upon resume they have to re-negotiate with the emulated device= s. + * + * PV and PVHVM communicate via hypercalls for suspend (and resume). + * For suspend the toolstack initiates the process by writing an value + * in XenBus "control/shutdown" with the string "suspend". + * + * The PV guest stashes anything it deems neccessary in 'struct + * start_info' in case of failure (PVHVM may ignore this) and calls + * the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall (for PV as + * argument it passes the MFN to 'struct start_info'). + * + * And then the guest is suspended. + * + * The checkpointing or notifying a guest that the suspend failed or + * cancelled (in case of checkpoint) is by having the + * SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return a non-zero + * value. + * + * The PV and PVHVM resume path are similar. For PV it would be + * similar to bootup - figure out where the 'struct start_info' is (or + * if the suspend was cancelled aka checkpointed - reuse the saved + * values). + * + * From here on they differ depending whether the guest is PV or PVHVM + * in specifics but follow overall the same path: + * - PV: Bringing up the vCPUS, + * - PVHVM: Setup vector callback, + * - Bring up vCPU runstates, + * - Remap the grant tables if checkpointing or setup from scratch, + * + * + * If the resume was not checkpointing (or if suspend was succesful) we wo= uld + * setup the PV timers and the different PV events. Lastly the PV drivers + * re-negotiate with the backend. + * + * This function would return before the guest started resuming. That is + * the guest would be in non-running state and its vCPU context would be + * in the the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return path + * (for PV and PVHVM). For HVM it would be in would be in QEMU emulated + * BIOS handling S3 suspend. + * + * @parm xch a handle to an open hypervisor interface + * @parm domid the domain id to resume + * @parm fast use cooperative resume (guest must support this) + * return 0 on success, -1 on failure + */ +int xc_domain_resume(xc_interface *xch, + uint32_t domid, + int fast); =20 /** * Memory related information, such as PFN types, the P2M table, diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile index ce9ecae710..fbeb3a3537 100644 --- a/tools/libs/ctrl/Makefile +++ b/tools/libs/ctrl/Makefile @@ -20,7 +20,6 @@ SRCS-y +=3D xc_rt.c SRCS-y +=3D xc_tbuf.c SRCS-y +=3D xc_pm.c SRCS-y +=3D xc_cpu_hotplug.c -SRCS-y +=3D xc_resume.c SRCS-y +=3D xc_vm_event.c SRCS-y +=3D xc_vmtrace.c SRCS-y +=3D xc_monitor.c diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile index 6d2a1d5bbc..2a2323ff09 100644 --- a/tools/libs/guest/Makefile +++ b/tools/libs/guest/Makefile @@ -9,6 +9,7 @@ endif SRCS-y +=3D xg_private.c SRCS-y +=3D xg_domain.c SRCS-y +=3D xg_suspend.c +SRCS-y +=3D xg_resume.c ifeq ($(CONFIG_MIGRATE),y) SRCS-y +=3D xg_sr_common.c SRCS-$(CONFIG_X86) +=3D xg_sr_common_x86.c diff --git a/tools/libs/ctrl/xc_resume.c b/tools/libs/guest/xg_resume.c similarity index 99% rename from tools/libs/ctrl/xc_resume.c rename to tools/libs/guest/xg_resume.c index e3c8e83aa9..3bdefb2eef 100644 --- a/tools/libs/ctrl/xc_resume.c +++ b/tools/libs/guest/xg_resume.c @@ -14,6 +14,7 @@ */ =20 #include "xc_private.h" +#include "xenguest.h" =20 #if defined(__i386__) || defined(__x86_64__) =20 --=20 2.26.2 From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786564; cv=none; d=zohomail.com; s=zohoarc; b=LqaA/w/geZdz6pXqvDQRr4cCpn4YqD9W3Y7nhnGOadVdxaTKKSbvgpliVpajOEPPCAO88wjmhQE5SW5UN2/KI8W5jg0Qr5zWCnlCa2x+AFYBaS9hnchWyDn6Ju29KZQ0fICQtwx46wcMY7ezqu9F1bpgip5IISCcC5Wb9wKgin4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786564; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4SWUo43YolLMrmlsJ+DCRZBL/Dp0uw3nhnsJOscj6IQ=; b=L8+WP20BjJMeooXTuZNL0X8nRtIuiDyTBRfpxsz8zeJQg4OHxDhvHR4fTTHVd4JkWns0pzQmKx2bGk5sxc1LRUisZOAYrRtZeRj3XQtBneVuqPbk5jg8S+qJWiorO2YdowefHrIS0TVo/qdKjlD7Wu10hjTx3lN7V64sQt4DBo0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162278656485266.13494592053621; Thu, 3 Jun 2021 23:02:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136692.253363 (Exim 4.92) (envelope-from ) id 1lp2uc-0003QG-Cg; Fri, 04 Jun 2021 06:02:30 +0000 Received: by outflank-mailman (output) from mailman id 136692.253363; Fri, 04 Jun 2021 06:02:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uc-0003Ov-4U; Fri, 04 Jun 2021 06:02:30 +0000 Received: by outflank-mailman (input) for mailman id 136692; Fri, 04 Jun 2021 06:02:28 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2ua-00029d-Kt for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:28 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cfd6595e-b914-4951-a782-26a003d51af0; Fri, 04 Jun 2021 06:02:18 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 939601FD47; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 63E28118DD; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id ONwuF+nBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cfd6595e-b914-4951-a782-26a003d51af0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4SWUo43YolLMrmlsJ+DCRZBL/Dp0uw3nhnsJOscj6IQ=; b=oWE0POBUbFMpkvHQHjCvq/oGFyH14joaNMlK3UIR6DoVacZWV0YsPMY9oqFDQkoxt31ggC BxxIszmrgJuMQNvTL9IPn6SYtbCP48RVWEOaf/cVoFDkp7G8EYzLM3XL+THpYwJPT2iaTX RG+sLduwpctq78ul69tXxKcg91xaMt8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4SWUo43YolLMrmlsJ+DCRZBL/Dp0uw3nhnsJOscj6IQ=; b=oWE0POBUbFMpkvHQHjCvq/oGFyH14joaNMlK3UIR6DoVacZWV0YsPMY9oqFDQkoxt31ggC BxxIszmrgJuMQNvTL9IPn6SYtbCP48RVWEOaf/cVoFDkp7G8EYzLM3XL+THpYwJPT2iaTX RG+sLduwpctq78ul69tXxKcg91xaMt8= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 5/6] tools/libs: move xc_core* from libxenctrl to libxenguest Date: Fri, 4 Jun 2021 08:02:13 +0200 Message-Id: <20210604060214.14924-6-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" The functionality in xc_core* should be part of libxenguest instead of libxenctrl. Users are already either in libxenguest, or in xl. There is one single exception: xc_core_arch_auto_translated_physmap() is being used by xc_domain_memory_mapping(), which is used by qemu. So leave the xc_core_arch_auto_translated_physmap() functionality in libxenctrl. This will make it easier to merge common functionality of xc_core* and xg_sr_save*. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/libs/ctrl/Makefile | 3 --- tools/libs/ctrl/xc_domain.c | 2 -- tools/libs/ctrl/xc_private.h | 12 ++++++++++++ tools/libs/guest/Makefile | 3 +++ tools/libs/{ctrl/xc_core.c =3D> guest/xg_core.c} | 2 +- tools/libs/{ctrl/xc_core.h =3D> guest/xg_core.h} | 5 ++--- .../libs/{ctrl/xc_core_arm.c =3D> guest/xg_core_arm.c} | 8 +------- .../libs/{ctrl/xc_core_arm.h =3D> guest/xg_core_arm.h} | 0 .../libs/{ctrl/xc_core_x86.c =3D> guest/xg_core_x86.c} | 8 +------- .../libs/{ctrl/xc_core_x86.h =3D> guest/xg_core_x86.h} | 0 tools/libs/guest/xg_dom_boot.c | 2 +- tools/libs/guest/xg_domain.c | 2 +- tools/libs/guest/xg_offline_page.c | 2 +- tools/libs/guest/xg_resume.c | 2 +- 14 files changed, 24 insertions(+), 27 deletions(-) rename tools/libs/{ctrl/xc_core.c =3D> guest/xg_core.c} (99%) rename tools/libs/{ctrl/xc_core.h =3D> guest/xg_core.h} (97%) rename tools/libs/{ctrl/xc_core_arm.c =3D> guest/xg_core_arm.c} (96%) rename tools/libs/{ctrl/xc_core_arm.h =3D> guest/xg_core_arm.h} (100%) rename tools/libs/{ctrl/xc_core_x86.c =3D> guest/xg_core_x86.c} (99%) rename tools/libs/{ctrl/xc_core_x86.h =3D> guest/xg_core_x86.h} (100%) diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile index fbeb3a3537..519246b0d6 100644 --- a/tools/libs/ctrl/Makefile +++ b/tools/libs/ctrl/Makefile @@ -2,9 +2,6 @@ XEN_ROOT =3D $(CURDIR)/../../.. include $(XEN_ROOT)/tools/Rules.mk =20 SRCS-y +=3D xc_altp2m.c -SRCS-y +=3D xc_core.c -SRCS-$(CONFIG_X86) +=3D xc_core_x86.c -SRCS-$(CONFIG_ARM) +=3D xc_core_arm.c SRCS-y +=3D xc_cpupool.c SRCS-y +=3D xc_domain.c SRCS-y +=3D xc_evtchn.c diff --git a/tools/libs/ctrl/xc_domain.c b/tools/libs/ctrl/xc_domain.c index e7cea4a17d..7d118848f1 100644 --- a/tools/libs/ctrl/xc_domain.c +++ b/tools/libs/ctrl/xc_domain.c @@ -19,8 +19,6 @@ * Copyright (c) 2003, K A Fraser. */ =20 -#include "xc_private.h" -#include "xc_core.h" #include "xc_private.h" #include #include diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index 8ebc0b59da..dff0f0289b 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -467,6 +467,18 @@ void *xc_vm_event_enable(xc_interface *xch, uint32_t d= omain_id, int param, =20 int do_dm_op(xc_interface *xch, uint32_t domid, unsigned int nr_bufs, ...); =20 +#if defined (__i386__) || defined (__x86_64__) +static inline int xc_core_arch_auto_translated_physmap(const xc_dominfo_t = *info) +{ + return info->hvm; +} +#elif defined (__arm__) || defined(__aarch64__) +static inline int xc_core_arch_auto_translated_physmap(const xc_dominfo_t = *info) +{ + return 1; +} +#endif + #endif /* __XC_PRIVATE_H__ */ =20 /* diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile index 2a2323ff09..2ce92d247e 100644 --- a/tools/libs/guest/Makefile +++ b/tools/libs/guest/Makefile @@ -24,6 +24,9 @@ SRCS-y +=3D xg_offline_page.c else SRCS-y +=3D xg_nomigrate.c endif +SRCS-y +=3D xg_core.c +SRCS-$(CONFIG_X86) +=3D xg_core_x86.c +SRCS-$(CONFIG_ARM) +=3D xg_core_arm.c =20 CFLAGS +=3D -I$(XEN_libxenctrl) =20 diff --git a/tools/libs/ctrl/xc_core.c b/tools/libs/guest/xg_core.c similarity index 99% rename from tools/libs/ctrl/xc_core.c rename to tools/libs/guest/xg_core.c index 9576bec5a3..c52f1161c1 100644 --- a/tools/libs/ctrl/xc_core.c +++ b/tools/libs/guest/xg_core.c @@ -61,7 +61,7 @@ */ =20 #include "xc_private.h" -#include "xc_core.h" +#include "xg_core.h" #include #include =20 diff --git a/tools/libs/ctrl/xc_core.h b/tools/libs/guest/xg_core.h similarity index 97% rename from tools/libs/ctrl/xc_core.h rename to tools/libs/guest/xg_core.h index 8ea1f93a10..f07584aaa6 100644 --- a/tools/libs/ctrl/xc_core.h +++ b/tools/libs/guest/xg_core.h @@ -131,7 +131,6 @@ struct xc_core_memory_map { uint64_t size; }; typedef struct xc_core_memory_map xc_core_memory_map_t; -int xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info); struct xc_core_arch_context; int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *arch_ctxt, @@ -152,9 +151,9 @@ int xc_core_arch_get_scratch_gpfn(xc_interface *xch, ui= nt32_t domid, =20 =20 #if defined (__i386__) || defined (__x86_64__) -# include "xc_core_x86.h" +# include "xg_core_x86.h" #elif defined (__arm__) || defined(__aarch64__) -# include "xc_core_arm.h" +# include "xg_core_arm.h" #else # error "unsupported architecture" #endif diff --git a/tools/libs/ctrl/xc_core_arm.c b/tools/libs/guest/xg_core_arm.c similarity index 96% rename from tools/libs/ctrl/xc_core_arm.c rename to tools/libs/guest/xg_core_arm.c index 93765a565f..aaabd07558 100644 --- a/tools/libs/ctrl/xc_core_arm.c +++ b/tools/libs/guest/xg_core_arm.c @@ -17,7 +17,7 @@ */ =20 #include "xc_private.h" -#include "xc_core.h" +#include "xg_core.h" =20 #include =20 @@ -31,12 +31,6 @@ xc_core_arch_gpfn_may_present(struct xc_core_arch_contex= t *arch_ctxt, return 0; } =20 -int -xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info) -{ - return 1; -} - int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context= *unused, xc_dominfo_t *info, shared_info_any_t *live_sh= info, diff --git a/tools/libs/ctrl/xc_core_arm.h b/tools/libs/guest/xg_core_arm.h similarity index 100% rename from tools/libs/ctrl/xc_core_arm.h rename to tools/libs/guest/xg_core_arm.h diff --git a/tools/libs/ctrl/xc_core_x86.c b/tools/libs/guest/xg_core_x86.c similarity index 99% rename from tools/libs/ctrl/xc_core_x86.c rename to tools/libs/guest/xg_core_x86.c index c8f71d4b75..09f5d696ce 100644 --- a/tools/libs/ctrl/xc_core_x86.c +++ b/tools/libs/guest/xg_core_x86.c @@ -19,7 +19,7 @@ =20 #include #include "xc_private.h" -#include "xc_core.h" +#include "xg_core.h" #include =20 int @@ -33,12 +33,6 @@ xc_core_arch_gpfn_may_present(struct xc_core_arch_contex= t *arch_ctxt, return 1; } =20 -int -xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info) -{ - return info->hvm; -} - int xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context= *unused, xc_dominfo_t *info, shared_info_any_t *live_sh= info, diff --git a/tools/libs/ctrl/xc_core_x86.h b/tools/libs/guest/xg_core_x86.h similarity index 100% rename from tools/libs/ctrl/xc_core_x86.h rename to tools/libs/guest/xg_core_x86.h diff --git a/tools/libs/guest/xg_dom_boot.c b/tools/libs/guest/xg_dom_boot.c index 2a002e7349..dac96b17a5 100644 --- a/tools/libs/guest/xg_dom_boot.c +++ b/tools/libs/guest/xg_dom_boot.c @@ -31,7 +31,7 @@ #include =20 #include "xg_private.h" -#include "xc_core.h" +#include "xg_core.h" #include #include =20 diff --git a/tools/libs/guest/xg_domain.c b/tools/libs/guest/xg_domain.c index dd7db2cbd8..155e337427 100644 --- a/tools/libs/guest/xg_domain.c +++ b/tools/libs/guest/xg_domain.c @@ -20,7 +20,7 @@ */ =20 #include "xg_private.h" -#include "xc_core.h" +#include "xg_core.h" =20 int xc_unmap_domain_meminfo(xc_interface *xch, struct xc_domain_meminfo *m= info) { diff --git a/tools/libs/guest/xg_offline_page.c b/tools/libs/guest/xg_offli= ne_page.c index d4722f0e8c..cfe0e2d537 100644 --- a/tools/libs/guest/xg_offline_page.c +++ b/tools/libs/guest/xg_offline_page.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include =20 #include "xc_private.h" #include "xg_private.h" diff --git a/tools/libs/guest/xg_resume.c b/tools/libs/guest/xg_resume.c index 3bdefb2eef..d201c1488d 100644 --- a/tools/libs/guest/xg_resume.c +++ b/tools/libs/guest/xg_resume.c @@ -21,7 +21,7 @@ #include #include #include -#include "xc_core.h" +#include "xg_core.h" =20 static int modify_returncode(xc_interface *xch, uint32_t domid) { --=20 2.26.2 From nobody Thu May 2 20:28:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1622786568; cv=none; d=zohomail.com; s=zohoarc; b=GAGwCIPJ289HbuOPQRNXUa4aURoKbKjaStTtrFyyIIYHNHfNW/8yVNij3SrNdFZfAMCA0SCrbqU8TAPyt7KOVGX/ig7WcaP4fugusCwxkR6rKbdD6H572ub6zls6ii5WNOVSZfzZWqdgB3rIg3kaLFfUaZrjo4Cu8Gl3RSaWWwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622786568; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8dbnJVTwfYU2q9IE6Ab5h4nWrKb9atrgQLfiOOr8PBc=; b=Fvfyfm0vTUZ9EXwRcPzNl065B3BT7jK0VzlUihyVv+6eLD+lKyppm8aDo61iRFbUjs/v5KmJ5HTE0Qr9vM3+CKcnsncfthjBEBgcfs4O33Cu/PSzPkAFYsi0g+7B8kt9yIswdtUzFWzhbFOnfaB+dVdICl4lXJhcP9MlC9Vdv9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1622786568040472.0934983621223; Thu, 3 Jun 2021 23:02:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.136693.253379 (Exim 4.92) (envelope-from ) id 1lp2ug-000452-M5; Fri, 04 Jun 2021 06:02:34 +0000 Received: by outflank-mailman (output) from mailman id 136693.253379; Fri, 04 Jun 2021 06:02:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2ug-00044r-Ig; Fri, 04 Jun 2021 06:02:34 +0000 Received: by outflank-mailman (input) for mailman id 136693; Fri, 04 Jun 2021 06:02:33 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lp2uf-00029d-L9 for xen-devel@lists.xenproject.org; Fri, 04 Jun 2021 06:02:33 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9d3de1b3-3223-44a0-aaa8-1c7101803c80; Fri, 04 Jun 2021 06:02:18 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CDB1A1FD4A; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 9BE5B118DD; Fri, 4 Jun 2021 06:02:17 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id QEfCJOnBuWCyGwAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 06:02:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9d3de1b3-3223-44a0-aaa8-1c7101803c80 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dbnJVTwfYU2q9IE6Ab5h4nWrKb9atrgQLfiOOr8PBc=; b=ODhxW/t+SwuqmSbFWx4OwmnrItQONZiqU56yh+iFlKM0V3PVS6fKnSOFL/79EThVBfUvnY ijBB65YG1ryNhGGzI2/4D17mMsG0WYq5UFHaDoZgrV1cKHWLsJApw/xR2M89iLZn7BDucM MHfWONi29pi3L5KPexMkppxLkhdxRJU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622786537; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dbnJVTwfYU2q9IE6Ab5h4nWrKb9atrgQLfiOOr8PBc=; b=ODhxW/t+SwuqmSbFWx4OwmnrItQONZiqU56yh+iFlKM0V3PVS6fKnSOFL/79EThVBfUvnY ijBB65YG1ryNhGGzI2/4D17mMsG0WYq5UFHaDoZgrV1cKHWLsJApw/xR2M89iLZn7BDucM MHfWONi29pi3L5KPexMkppxLkhdxRJU= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2 6/6] tools/libs/guest: make some definitions private to libxenguest Date: Fri, 4 Jun 2021 08:02:14 +0200 Message-Id: <20210604060214.14924-7-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210604060214.14924-1-jgross@suse.com> References: <20210604060214.14924-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" There are some definitions which are used in libxenguest only now. Move them from libxenctrl over to libxenguest. Remove an unused macro. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/libs/ctrl/xc_private.h | 32 -------------------------------- tools/libs/guest/xg_core.h | 2 +- tools/libs/guest/xg_core_x86.c | 16 +++++++++++++++- tools/libs/guest/xg_private.h | 16 +++++++++++++++- tools/libs/guest/xg_resume.c | 2 +- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index dff0f0289b..3e299b943f 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -65,38 +65,6 @@ struct iovec { =20 #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) =20 -#define GET_FIELD(_p, _f, _w) (((_w) =3D=3D 8) ? ((_p)->x64._f) : ((_p)->x= 32._f)) - -#define SET_FIELD(_p, _f, _v, _w) do { \ - if ((_w) =3D=3D 8) \ - (_p)->x64._f =3D (_v); \ - else \ - (_p)->x32._f =3D (_v); \ -} while (0) - -/* XXX SMH: following skanky macros rely on variable p2m_size being set */ -/* XXX TJD: also, "guest_width" should be the guest's sizeof(unsigned long= ) */ - -struct domain_info_context { - unsigned int guest_width; - unsigned int p2m_frames; - unsigned long p2m_size; -}; - -/* Number of xen_pfn_t in a page */ -#define FPP (PAGE_SIZE/(dinfo->guest_width)) - -/* Number of entries in the pfn_to_mfn_frame_list_list */ -#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP)) - -/* Number of entries in the pfn_to_mfn_frame_list */ -#define P2M_FL_ENTRIES (((dinfo->p2m_size)+FPP-1)/FPP) - -/* Size in bytes of the pfn_to_mfn_frame_list */ -#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width)) -#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) * \ - max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_w= idth)) - #define DECLARE_DOMCTL struct xen_domctl domctl #define DECLARE_SYSCTL struct xen_sysctl sysctl #define DECLARE_PHYSDEV_OP struct physdev_op physdev_op diff --git a/tools/libs/guest/xg_core.h b/tools/libs/guest/xg_core.h index f07584aaa6..aaca9e0a8b 100644 --- a/tools/libs/guest/xg_core.h +++ b/tools/libs/guest/xg_core.h @@ -21,7 +21,7 @@ #define XC_CORE_H =20 #include "xen/version.h" -#include "xc_private.h" +#include "xg_private.h" #include "xen/libelf/elfstructs.h" =20 /* section names */ diff --git a/tools/libs/guest/xg_core_x86.c b/tools/libs/guest/xg_core_x86.c index 09f5d696ce..61106b98b8 100644 --- a/tools/libs/guest/xg_core_x86.c +++ b/tools/libs/guest/xg_core_x86.c @@ -18,10 +18,24 @@ */ =20 #include -#include "xc_private.h" +#include "xg_private.h" #include "xg_core.h" #include =20 +/* Number of xen_pfn_t in a page */ +#define FPP (PAGE_SIZE/(dinfo->guest_width)) + +/* Number of entries in the pfn_to_mfn_frame_list_list */ +#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP)) + +/* Number of entries in the pfn_to_mfn_frame_list */ +#define P2M_FL_ENTRIES (((dinfo->p2m_size)+FPP-1)/FPP) + +/* Size in bytes of the pfn_to_mfn_frame_list */ +#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width)) +#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) * \ + max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_w= idth)) + int xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, unsigned long pfn) diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index 25e46d7ce1..03d765da21 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -42,6 +42,21 @@ #endif #endif =20 +#define GET_FIELD(_p, _f, _w) (((_w) =3D=3D 8) ? ((_p)->x64._f) : ((_p)->x= 32._f)) + +#define SET_FIELD(_p, _f, _v, _w) do { \ + if ((_w) =3D=3D 8) \ + (_p)->x64._f =3D (_v); \ + else \ + (_p)->x32._f =3D (_v); \ +} while (0) + +struct domain_info_context { + unsigned int guest_width; + unsigned int p2m_frames; + unsigned long p2m_size; +}; + struct xc_dom_loader { const char *name; /* Sadly the error returns from these functions are not consistent: */ @@ -139,7 +154,6 @@ static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xe= n_pfn_t *p2m, /* Masks for PTE<->PFN conversions */ #define MADDR_BITS_X86 ((dinfo->guest_width =3D=3D 8) ? 52 : 44) #define MFN_MASK_X86 ((1ULL << (MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1) -#define MADDR_MASK_X86 (MFN_MASK_X86 << PAGE_SHIFT_X86) =20 int pin_table(xc_interface *xch, unsigned int type, unsigned long mfn, uint32_t dom); diff --git a/tools/libs/guest/xg_resume.c b/tools/libs/guest/xg_resume.c index d201c1488d..77e2451a3c 100644 --- a/tools/libs/guest/xg_resume.c +++ b/tools/libs/guest/xg_resume.c @@ -13,7 +13,7 @@ * License along with this library; If not, see . */ =20 -#include "xc_private.h" +#include "xg_private.h" #include "xenguest.h" =20 #if defined(__i386__) || defined(__x86_64__) --=20 2.26.2