From nobody Sun Apr 28 03:33:36 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=1623070843; cv=none; d=zohomail.com; s=zohoarc; b=PVrisHwFwkVWpsMDf9D4WjkrZ3Cv+KqHqLgDMFAZFf5XlJE8dMxYIEaYWfRY4+Z6V0E1j/ocM8pkqFQwZbH/qJeNu9OTHvM8U4aGZNoVmAo3vvDGHBGmx6fIbw1mTWwmUgt1Gj0DD0NpO+ZEF7TBTIa/MwVEUJDzBnhVruJcfP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623070843; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=bjaYWxACxRGpqsDAVvv6IZjzEWNKF4fA46tBnzk+epw=; b=RAFktBHshBG7GBHAF5CV0o/ZA8DkelFxuy7FRtU0KsebPm5Piure9xSAR3+rLPSTJD1O3yL52NGyiUBM6CMXR4QIaZLEmTl9RqrGLqBh5qZLvxz2bDVN2B90bUOnxe48Y0T+4/DQZUvWyVU/Fuuh5Lk7jMZRRneNY+X0OibhQB0= 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 1623070843319308.70252834023006; Mon, 7 Jun 2021 06:00:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.137949.255474 (Exim 4.92) (envelope-from ) id 1lqErT-0004Pj-D7; Mon, 07 Jun 2021 13:00:11 +0000 Received: by outflank-mailman (output) from mailman id 137949.255474; Mon, 07 Jun 2021 13:00:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqErT-0004Pc-A7; Mon, 07 Jun 2021 13:00:11 +0000 Received: by outflank-mailman (input) for mailman id 137949; Mon, 07 Jun 2021 13:00:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqErR-0004PW-Ru for xen-devel@lists.xenproject.org; Mon, 07 Jun 2021 13:00:09 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f7e6ad82-02b1-432a-9e63-a77c1d5abfdc; Mon, 07 Jun 2021 13:00:08 +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 E009321A8A; Mon, 7 Jun 2021 13:00:07 +0000 (UTC) Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id B1BE7118DD; Mon, 7 Jun 2021 13:00:07 +0000 (UTC) Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id 6qUzKlcYvmBAEAAALh3uQQ (envelope-from ); Mon, 07 Jun 2021 13:00:07 +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: f7e6ad82-02b1-432a-9e63-a77c1d5abfdc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1623070807; 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; bh=bjaYWxACxRGpqsDAVvv6IZjzEWNKF4fA46tBnzk+epw=; b=Msb4pOfV22zWWq5RK3WRR7MzSYe2mV9mDNliSiTu5O5TSLuw+mgnAOFa+PQs7+Xps3uiVB m2+H2k7+eG0aPS/vPHOdYQrBIT3UOHJmlr7h3xTEhRK24MzA/sfEdmc+7mR+AEwg7z3VMg BTqb06g6dC+cinEmGvNDA5TooFiAsWI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1623070807; 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; bh=bjaYWxACxRGpqsDAVvv6IZjzEWNKF4fA46tBnzk+epw=; b=Msb4pOfV22zWWq5RK3WRR7MzSYe2mV9mDNliSiTu5O5TSLuw+mgnAOFa+PQs7+Xps3uiVB m2+H2k7+eG0aPS/vPHOdYQrBIT3UOHJmlr7h3xTEhRK24MzA/sfEdmc+7mR+AEwg7z3VMg BTqb06g6dC+cinEmGvNDA5TooFiAsWI= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu Subject: [PATCH v2] tools/libs/guest: fix save and restore of pv domains after 32-bit de-support Date: Mon, 7 Jun 2021 15:00:05 +0200 Message-Id: <20210607130005.5475-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" After 32-bit PV-guests have been security de-supported when not running under PV-shim, the hypervisor will no longer be configured to support those domains per default when not being built as PV-shim. Unfortunately libxenguest will fail saving or restoring a PV domain due to this restriction, as it is trying to get the compat MFN list even for 64 bit guests. Fix that by obtaining the compat MFN list only for 32-bit PV guests. Fixes: 1a0f2fe2297d122a08fe ("SUPPORT.md: Un-shimmed 32-bit PV guests are n= o longer supported") Signed-off-by: Juergen Gross Reviewed-by: Andrew Cooper Reviewed-by: Jan Beulich --- V2: - set compat MFN to "invalid" instead of net setting it at all (Jan Beulich) - don't set compat MFN for 64-bit guests even if running as 32-bit domain (Andrew Cooper) --- tools/libs/guest/xg_sr_common.h | 2 +- tools/libs/guest/xg_sr_common_x86_pv.c | 37 +++++++++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_commo= n.h index cc3ad1c394..e2994e18ac 100644 --- a/tools/libs/guest/xg_sr_common.h +++ b/tools/libs/guest/xg_sr_common.h @@ -325,7 +325,7 @@ struct xc_sr_context xen_pfn_t max_mfn; /* Read-only machine to phys map */ xen_pfn_t *m2p; - /* first mfn of the compat m2p (Only needed for 32bit PV g= uests) */ + /* first mfn of the compat m2p (Only set for 32bit PV gues= ts) */ xen_pfn_t compat_m2p_mfn0; /* Number of m2p frames mapped */ unsigned long nr_m2p_frames; diff --git a/tools/libs/guest/xg_sr_common_x86_pv.c b/tools/libs/guest/xg_s= r_common_x86_pv.c index cd33406aab..f339ea4a79 100644 --- a/tools/libs/guest/xg_sr_common_x86_pv.c +++ b/tools/libs/guest/xg_sr_common_x86_pv.c @@ -149,27 +149,32 @@ int x86_pv_map_m2p(struct xc_sr_context *ctx) =20 ctx->x86.pv.nr_m2p_frames =3D (M2P_CHUNK_SIZE >> PAGE_SHIFT) * m2p_chu= nks; =20 + if ( ctx->x86.pv.levels =3D=3D 3 ) + { #ifdef __i386__ - /* 32 bit toolstacks automatically get the compat m2p */ - ctx->x86.pv.compat_m2p_mfn0 =3D entries[0].mfn; + /* 32 bit toolstacks automatically get the compat m2p */ + ctx->x86.pv.compat_m2p_mfn0 =3D entries[0].mfn; #else - /* 64 bit toolstacks need to ask Xen specially for it */ - { - struct xen_machphys_mfn_list xmml =3D { - .max_extents =3D 1, - .extent_start =3D { &ctx->x86.pv.compat_m2p_mfn0 }, - }; - - rc =3D do_memory_op(xch, XENMEM_machphys_compat_mfn_list, - &xmml, sizeof(xmml)); - if ( rc || xmml.nr_extents !=3D 1 ) + /* 64 bit toolstacks need to ask Xen specially for it */ { - PERROR("Failed to get compat mfn list from Xen"); - rc =3D -1; - goto err; + struct xen_machphys_mfn_list xmml =3D { + .max_extents =3D 1, + .extent_start =3D { &ctx->x86.pv.compat_m2p_mfn0 }, + }; + + rc =3D do_memory_op(xch, XENMEM_machphys_compat_mfn_list, + &xmml, sizeof(xmml)); + if ( rc || xmml.nr_extents !=3D 1 ) + { + PERROR("Failed to get compat mfn list from Xen"); + rc =3D -1; + goto err; + } } - } #endif + } + else + ctx->x86.pv.compat_m2p_mfn0 =3D INVALID_MFN; =20 /* All Done */ rc =3D 0; --=20 2.26.2