From nobody Mon Feb 9 17:37:26 2026 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