From nobody Fri Dec 19 08:04:48 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580135748960340.56742147363775; Mon, 27 Jan 2020 06:35:48 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tr-0001hL-Lp; Mon, 27 Jan 2020 14:35:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tq-0001gT-Jq for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:10 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2e842890-4112-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 14:34:53 +0000 (UTC) X-Inumbo-ID: 2e842890-4112-11ea-9fd7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135694; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3aA35RPqKDDf+uy1cNRXZI2JByEnYCgfR73vgRu/cwM=; b=Klu6LyiGAtZRTtwTsLsEK6yMu+/yMEJa6ZFrHppmR64aiDS/wJq9VWCK /vdANxUuGsuro/j9wS8Np5PPf6vQWK3Dh9IrSWve88AxasVPDvZRvTltH +268EmAZr9Yz4S1z5MxyjZOuWB9tjFHF2Vj0TxaI6PTTlWrdldKQgyRk1 U=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: hN8RMHMSB/9WP5mdJJGQBtL2+bJyjDXKroHxQxi9IrOStzwOZuxBG2xo7d94xGWN7+I9r3Ix1V HuMTKGC/iw0OKEZ3Qinf0Q7xEfEHfkqr99MLUuU7hsVW89mstaL9qNcOPjWrFkNY5EcUshIX3E WiCHFsT6OgiiL1JG3GU+N0cCKgUHh06ae2Q7bnwTBPrTiHARrqSjYhFkl6PrQAbn098Utc6JbN zzw5sY7cktzK8g4OQs+7pqAvNFKEP//CECZJiPXyztFNMoToYRkim1Z3EAZ330ZoxEmyVFvi4D fWw= X-SBRS: 2.7 X-MesageID: 11664979 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,370,1574139600"; d="scan'208";a="11664979" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:34 +0000 Message-ID: <20200127143444.25538-8-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200127143444.25538-1-andrew.cooper3@citrix.com> References: <20200127143444.25538-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 07/17] libxc/restore: STATIC_DATA_END inference for v2 compatibility X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) A v3 stream can compatibly read a v2 stream by inferring the position of the STATIC_DATA_END record. v2 compatibility is only needed for x86. No other architectures exist yet, but they will have a minimum of v3 when introduced. The x86 HVM compatibility point being in handle_page_data() (which is common code) is a bit awkward. However, as the two compatibility points are subtly different, and it is (intentionally) not possible to call into arch specific code from common code (except via the ops hooks), use some #ifdef-ary and opencode the check, rather than make handle_page_data() a per-arch helper. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu v2: * Split/rearranged from v1 * Rewrite the commit message to explain why compatibility is done this way. --- tools/libxc/include/xenguest.h | 2 +- tools/libxc/xc_sr_common.h | 5 ++++- tools/libxc/xc_sr_restore.c | 27 ++++++++++++++++++++++++++- tools/libxc/xc_sr_restore_x86_pv.c | 17 +++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index efd90b0d42..b4df8d0ffe 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -139,7 +139,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32= _t dom, =20 /* callbacks provided by xc_domain_restore */ struct restore_callbacks { - /* Called once the STATIC_DATA_END record has been received. */ + /* Called once the STATIC_DATA_END record has been received/inferred. = */ int (*static_data_done)(void *data); =20 /* Called after a new checkpoint to suspend the guest. */ diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index ae0ab70f76..51e3d3ee3b 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -253,7 +253,7 @@ struct xc_sr_context /* Currently buffering records between a checkpoint */ bool buffer_all_records; =20 - /* Whether a STATIC_DATA_END record has been seen. */ + /* Whether a STATIC_DATA_END record has been seen/inferred. */ bool seen_static_data_end; =20 /* @@ -428,6 +428,9 @@ int read_record(struct xc_sr_context *ctx, int fd, stru= ct xc_sr_record *rec); int populate_pfns(struct xc_sr_context *ctx, unsigned int count, const xen_pfn_t *original_pfns, const uint32_t *types); =20 +/* Handle a STATIC_DATA_END record. */ +int handle_static_data_end(struct xc_sr_context *ctx); + #endif /* * Local variables: diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index 9c924387ae..bb94cd879d 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -342,6 +342,31 @@ static int handle_page_data(struct xc_sr_context *ctx,= struct xc_sr_record *rec) xen_pfn_t *pfns =3D NULL, pfn; uint32_t *types =3D NULL, type; =20 + /* + * v2 compatibility only exists for x86 streams. This is a bit of a + * bodge, but it is less bad than duplicating handle_page_data() betwe= en + * different architectures. + */ +#if defined(__i386__) || defined(__x86_64__) + /* v2 compat. Infer the position of STATIC_DATA_END. */ + if ( ctx->restore.format_version < 3 && !ctx->restore.seen_static_data= _end ) + { + rc =3D handle_static_data_end(ctx); + if ( rc ) + { + ERROR("Inferred STATIC_DATA_END record failed"); + goto err; + } + rc =3D -1; + } + + if ( !ctx->restore.seen_static_data_end ) + { + ERROR("No STATIC_DATA_END seen"); + goto err; + } +#endif + if ( rec->length < sizeof(*pages) ) { ERROR("PAGE_DATA record truncated: length %u, min %zu", @@ -631,7 +656,7 @@ static int buffer_record(struct xc_sr_context *ctx, str= uct xc_sr_record *rec) return 0; } =20 -static int handle_static_data_end(struct xc_sr_context *ctx) +int handle_static_data_end(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; int rc =3D 0; diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore= _x86_pv.c index 16e738884e..3756225be6 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -679,6 +679,23 @@ static int handle_x86_pv_p2m_frames(struct xc_sr_conte= xt *ctx, unsigned int start, end, x, fpp =3D PAGE_SIZE / ctx->x86.pv.width; int rc; =20 + /* v2 compat. Infer the position of STATIC_DATA_END. */ + if ( ctx->restore.format_version < 3 && !ctx->restore.seen_static_data= _end ) + { + rc =3D handle_static_data_end(ctx); + if ( rc ) + { + ERROR("Inferred STATIC_DATA_END record failed"); + return rc; + } + } + + if ( !ctx->restore.seen_static_data_end ) + { + ERROR("No STATIC_DATA_END seen"); + return -1; + } + if ( !ctx->x86.pv.restore.seen_pv_info ) { ERROR("Not yet received X86_PV_INFO record"); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel