From nobody Mon Apr 29 01:42:20 2024 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 1580135731783599.2104569546733; Mon, 27 Jan 2020 06:35:31 -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 1iw5Tc-0001VV-To; Mon, 27 Jan 2020 14:34:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tb-0001V2-Ih for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:34:55 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2ccd57b0-4112-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 14:34:50 +0000 (UTC) X-Inumbo-ID: 2ccd57b0-4112-11ea-9fd7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hRcQnHFR+ElvQboU3vRO0ePioGcvx3TsdIdHzFSo0ms=; b=aYNZipaYRlBJJYSMtiqkYfUw6lAhdZ+mf1cDJBEsMUWZ1X71m7PEaakH n2989+neN7EcctVfiNw2D1GWeMB0qmiyjKoHDcuutQS+vByui6bZb4XLj eHvV5KtU3SlTeuoiA9Og3YEvAKKU6OqkgG0OcYi08IDuAt+dAgW6Tl+rV 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: f6iTksgXs19pfYSSefnu9+544fC/bU6sf6p+WAMTvmIxFTaYZXHS6aauX/rB4jH01/WJQzjqDh bIZVVPLTT+CpiU16hJzxJ+oGuFcaJKx4MeXiFCK0vi2KcPV3oazL2lTLu8s0oERyXpW9X80xqB GUSVezhRbPjM0wYOSrG/YERi8BGF4ctKb5dFe6oe8ov72/2mbowaVXC3rjgYipH4kjKcpDIv7A r5yh3NceG6PAJNGETTQDn5x6aVRnZIyDeFKff9WEfDVEPCZmnflm8IKdp3+Fl1Ey60A7JaVpfn GaA= X-SBRS: 2.7 X-MesageID: 11664970 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="11664970" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:28 +0000 Message-ID: <20200127143444.25538-2-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 01/17] tools/libxl: Remove libxl_cpuid_{set, apply_policy}() from the API 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: Anthony PERARD , 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) These functions should never have been exposed. They don't have external users, and can't usefully be used for several reasons. Move libxl_cpuid_{set,apply_policy}() to being internal functions, and leave an equivalent of the nop stubs in the API for caller compatibility. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD RFC for obvious reasons. An alternative would be to #if 0 them, which would result in a compile failure rather than silent stubbing. I'm not sure which is least bad, but I don't think either are going to cause a problem in practice. --- tools/libxl/libxl.h | 26 ++++++++++++++++++++++---- tools/libxl/libxl_cpuid.c | 6 +++--- tools/libxl/libxl_dom.c | 4 ++-- tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_nocpuid.c | 6 +++--- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 54abb9db1f..a02548f595 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -665,7 +665,7 @@ typedef struct libxl__ctx libxl_ctx; #if LIBXL_API_VERSION !=3D 0x040200 && LIBXL_API_VERSION !=3D 0x040300 && \ LIBXL_API_VERSION !=3D 0x040400 && LIBXL_API_VERSION !=3D 0x040500 && \ LIBXL_API_VERSION !=3D 0x040700 && LIBXL_API_VERSION !=3D 0x040800 && \ - LIBXL_API_VERSION !=3D 0x041300 + LIBXL_API_VERSION !=3D 0x041300 && LIBXL_API_VERSION !=3D 0x041400 #error Unknown LIBXL_API_VERSION #endif #endif @@ -2323,9 +2323,27 @@ libxl_device_pci *libxl_device_pci_assignable_list(l= ibxl_ctx *ctx, int *num); int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* s= tr); int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid, const char* str); -void libxl_cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid); -void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, - libxl_cpuid_policy_list cpuid); +#if LIBXL_API_VERSION < 0x041400 +/* + * Dropped from the API in Xen 4.14. At the time of writing, these functi= ons + * don't appear to ever have had external callers. + * + * These have always been used internally during domain construction, and + * can't easily be used externally because of their implicit parameters in + * other pieces of global state. + * + * Furthermore, an API user can't usefully determine whether they get + * libxl_cpuid (the real implementation) or libxl_nocpuid (no-op stubs). + * + * The internal behaviour of these functions also needs to change. Theref= ore + * for simplicitly, provide the no-op stubs. Yes technically this is an A= PI + * change in some cases for existing software, but there is 0 of that in + * practice. + */ +static inline void libxl_cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid= ) {} +static inline void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, + libxl_cpuid_policy_list cpuid) {} +#endif =20 /* * Functions for allowing users of libxl to store private data diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c index 5c52cbe0f9..505ec1b048 100644 --- a/tools/libxl/libxl_cpuid.c +++ b/tools/libxl/libxl_cpuid.c @@ -410,13 +410,13 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_= list *cpuid, return 0; } =20 -void libxl_cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid) +void libxl__cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid) { xc_cpuid_apply_policy(ctx->xch, domid, NULL, 0); } =20 -void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, - libxl_cpuid_policy_list cpuid) +void libxl__cpuid_set(libxl_ctx *ctx, uint32_t domid, + libxl_cpuid_policy_list cpuid) { int i; char *cpuid_res[4]; diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 573c63692b..b730365f47 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -454,9 +454,9 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, if (rc) return rc; =20 - libxl_cpuid_apply_policy(ctx, domid); + libxl__cpuid_apply_policy(ctx, domid); if (info->cpuid !=3D NULL) - libxl_cpuid_set(ctx, domid, info->cpuid); + libxl__cpuid_set(ctx, domid, info->cpuid); =20 if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && !libxl_ms_vm_genid_is_zero(&info->u.hvm.ms_vm_genid)) { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 64f6fdada8..50856ca703 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2042,6 +2042,10 @@ struct libxl__cpuid_policy { char *policy[4]; }; =20 +_hidden void libxl__cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid); +_hidden void libxl__cpuid_set(libxl_ctx *ctx, uint32_t domid, + libxl_cpuid_policy_list cpuid); + /* Calls poll() again - useful to check whether a signaled condition * is still true. Cannot fail. Returns currently-true revents. */ _hidden short libxl__fd_poll_recheck(libxl__egc *egc, int fd, short events= ); diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libxl/libxl_nocpuid.c index ef1161c434..a39babe754 100644 --- a/tools/libxl/libxl_nocpuid.c +++ b/tools/libxl/libxl_nocpuid.c @@ -34,12 +34,12 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_li= st *cpuid, return 0; } =20 -void libxl_cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid) +void libxl__cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid) { } =20 -void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid, - libxl_cpuid_policy_list cpuid) +void libxl__cpuid_set(libxl_ctx *ctx, uint32_t domid, + libxl_cpuid_policy_list cpuid) { } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580135727449718.7311223466967; Mon, 27 Jan 2020 06:35:27 -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 1iw5TZ-0001UD-HF; Mon, 27 Jan 2020 14:34:53 +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.89) (envelope-from ) id 1iw5TX-0001Th-Qg for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:34:51 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2cd87208-4112-11ea-855c-12813bfff9fa; Mon, 27 Jan 2020 14:34:51 +0000 (UTC) X-Inumbo-ID: 2cd87208-4112-11ea-855c-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135692; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=pvpzhNbntIVWvF1ywdzId5/B1YA3CMsL8tn8OeeGOE8=; b=MC8CEH4J/zlHLjdEp73KW1VNubFIYQtnt8UtmtHVS2bKThHEJ0TelU+9 Z2Q6m9OPVoWhXxL3TD/2FIa0J84w6cnl0CC6P0/IfpdVjVSPW1UhTqNaF 7HX20pr5XlLbWieJRWETveMLTpKxLfLjol/MquTQz2lXlRXnj0zvtmbI+ s=; 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: MuAm13dT2XQpxDVZ8uqhfigYFsa5zZU2Y7hU1Pxuv3ZtY6UBjaodLU2rRhBnO9JAkyy5iHFtoW k1fKu2zpupGFBFj1wVFYRbdIzEGFUPzzdXyO9bqOs/Xpx6Bji6Y8pIZxpXsLt2IGkHJMcxzUB/ IN8bQQ+F2x/VZDLDMlKysVLi6mEISw+XgEDFQ32ku58VM06MVmwP5P3dTx3DLztw8wrpobieqc iC1oszGtKirtOfc/8QiAlmQFMaA2Y6tJ4Gq8+A5iwMeUIm5IhCTPAgZuxKIzmWOA7KQd6NYjsS 4zQ= X-SBRS: 2.7 X-MesageID: 11664971 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="11664971" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:29 +0000 Message-ID: <20200127143444.25538-3-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 02/17] tools/libxl: Simplify callback handling in libxl-save-helper 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: Anthony PERARD , 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) The {save,restore}_callback helpers can have their scope reduced vastly, and helper_setcallbacks_{save,restore}() doesn't need to use a ternary operator= to write 0 (meaning NULL) into an already zeroed structure. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxl/libxl_save_helper.c | 16 ++++++---------- tools/libxl/libxl_save_msgs_gen.pl | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helpe= r.c index 017c7cd988..65dff389bf 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -217,8 +217,6 @@ int helper_getreply(void *user) =20 /*----- other callbacks -----*/ =20 -static struct save_callbacks helper_save_callbacks; - static void startup(const char *op) { xtl_log(&logger,XTL_DEBUG,0,program,"starting %s",op); =20 @@ -234,8 +232,6 @@ static void complete(int retval) { exit(0); } =20 -static struct restore_callbacks helper_restore_callbacks; - int main(int argc, char **argv) { int r; @@ -247,6 +243,7 @@ int main(int argc, char **argv) assert(mode); =20 if (!strcmp(mode,"--save-domain")) { + static struct save_callbacks cb; =20 io_fd =3D atoi(NEXTARG); recv_fd =3D atoi(NEXTARG); @@ -256,16 +253,16 @@ int main(int argc, char **argv) xc_stream_type_t stream_type =3D strtoul(NEXTARG,0,10); assert(!*++argv); =20 - helper_setcallbacks_save(&helper_save_callbacks, cbflags); + helper_setcallbacks_save(&cb, cbflags); =20 startup("save"); setup_signals(save_signal_handler); =20 - r =3D xc_domain_save(xch, io_fd, dom, flags, &helper_save_callback= s, - stream_type, recv_fd); + r =3D xc_domain_save(xch, io_fd, dom, flags, &cb, stream_type, rec= v_fd); complete(r); =20 } else if (!strcmp(mode,"--restore-domain")) { + static struct restore_callbacks cb; =20 io_fd =3D atoi(NEXTARG); send_back_fd =3D atoi(NEXTARG); @@ -278,7 +275,7 @@ int main(int argc, char **argv) xc_stream_type_t stream_type =3D strtoul(NEXTARG,0,10); assert(!*++argv); =20 - helper_setcallbacks_restore(&helper_restore_callbacks, cbflags); + helper_setcallbacks_restore(&cb, cbflags); =20 unsigned long store_mfn =3D 0; unsigned long console_mfn =3D 0; @@ -288,8 +285,7 @@ int main(int argc, char **argv) =20 r =3D xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn, store_domid, console_evtchn, &console_mfn, - console_domid, stream_type, - &helper_restore_callbacks, send_back_fd); + console_domid, stream_type, &cb, send_back_f= d); helper_stub_restore_results(store_mfn,console_mfn,0); complete(r); =20 diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_ms= gs_gen.pl index 6f1d79f821..831a15e0bb 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -333,7 +333,7 @@ END_ALWAYS my $c_v =3D "(1u<<$msgnum)"; my $c_cb =3D "cbs->$name"; $f_more_sr->(" if ($c_cb) cbflags |=3D $c_v;\n", $enumcallbacks= ); - $f_more_sr->(" $c_cb =3D (cbflags & $c_v) ? ${encode}_${name} := 0;\n", + $f_more_sr->(" if (cbflags & $c_v) $c_cb =3D ${encode}_${name};= \n", $setcallbacks); } $f_more_sr->(" return 1;\n }\n\n"); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580135746002971.0988073960164; Mon, 27 Jan 2020 06:35:46 -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 1iw5Th-0001Yl-QV; Mon, 27 Jan 2020 14:35:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tg-0001YC-I9 for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:00 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2d4e1e7c-4112-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 14:34:51 +0000 (UTC) X-Inumbo-ID: 2d4e1e7c-4112-11ea-9fd7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135692; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0GGzmlFGaEIMS+O2YuTNdygeIZmvyTogSE9zQHILJss=; b=QRqMd36lWNuqo6gQREBS0Yj6zBgTM0PO/iMMBIIwgj9Ptb7PVFa/HUT7 HImZgXp5qu5Uvq5o6hsLgq4zMxRfPj/WVPxJu4aK4EVml7JjiF2RWXXow dvJSni86f6kwITSeWnF7JaLrVJS0wXNzZnQlf/+26vc5iasEK+bCpZdIs 8=; 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: uD/1/QcMwLjZKhYOCHQptEskXtKhELTL2WbRym4fKnL5wpbxzYlGPAJE5cx9e26IX/n1ojwOWC JTmuY5BrpFbcESqfofUjAhe1iaRlOciOWQSf6geEbFzELGstp/dBrFyRgKDGxdG7v1a8JJMNLW bMIfaOYuKQOTw3gjOiPCpMF5+Kj92qd5HAEAzr8v+tPFoedHaHS3N6mw9auvUT0+COim7PIYgn Ra36uJoBEF9S5DK0kw0djjZoORBcPjsn2dKVtMznw09/qu9nQnHi/Dc3302j9s7EYrO1tPVPJt xhA= X-SBRS: 2.7 X-MesageID: 11664973 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="11664973" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:30 +0000 Message-ID: <20200127143444.25538-4-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 03/17] tools/migration: Drop IHDR_VERSION constant from libxc and python 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 , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , 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) Migration v3 is in the process of being introduced, meaning that the code h= as to cope with both versions. Use an explicit 2 for now. For the verify-stream-v2 and convert-legacy-stream scripts, update text to = say "v2 (or later)". What matters is the distinction vs legacy streams. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Marek Marczykowski-G=C3=B3recki --- tools/libxc/xc_sr_restore.c | 6 +++--- tools/libxc/xc_sr_save.c | 2 +- tools/libxc/xc_sr_stream_format.h | 1 - tools/python/scripts/convert-legacy-stream | 6 +++--- tools/python/scripts/verify-stream-v2 | 2 +- tools/python/xen/migration/libxc.py | 9 ++++----- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index 5e31908ca8..dc2ffcf855 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -35,10 +35,10 @@ static int read_headers(struct xc_sr_context *ctx) return -1; } =20 - if ( ihdr.version !=3D IHDR_VERSION ) + if ( ihdr.version !=3D 2 ) { - ERROR("Invalid Version: Expected %d, Got %d", - IHDR_VERSION, ihdr.version); + ERROR("Invalid Version: Expected 2, Got %d", + ihdr.version); return -1; } =20 diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index fa736a311f..5c5ce18ac3 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -13,7 +13,7 @@ static int write_headers(struct xc_sr_context *ctx, uint1= 6_t guest_type) struct xc_sr_ihdr ihdr =3D { .marker =3D IHDR_MARKER, .id =3D htonl(IHDR_ID), - .version =3D htonl(IHDR_VERSION), + .version =3D htonl(2), .options =3D htons(IHDR_OPT_LITTLE_ENDIAN), }; struct xc_sr_dhdr dhdr =3D { diff --git a/tools/libxc/xc_sr_stream_format.h b/tools/libxc/xc_sr_stream_f= ormat.h index 37a7da6eab..ae7c0de393 100644 --- a/tools/libxc/xc_sr_stream_format.h +++ b/tools/libxc/xc_sr_stream_format.h @@ -23,7 +23,6 @@ struct xc_sr_ihdr =20 #define IHDR_MARKER 0xffffffffffffffffULL #define IHDR_ID 0x58454E46U -#define IHDR_VERSION 2 =20 #define _IHDR_OPT_ENDIAN 0 #define IHDR_OPT_LITTLE_ENDIAN (0 << _IHDR_OPT_ENDIAN) diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scri= pts/convert-legacy-stream index 2922fb3185..02a194178f 100755 --- a/tools/python/scripts/convert-legacy-stream +++ b/tools/python/scripts/convert-legacy-stream @@ -79,7 +79,7 @@ def write_libxc_ihdr(): stream_write(pack(libxc.IHDR_FORMAT, libxc.IHDR_MARKER, # Marker libxc.IHDR_IDENT, # Ident - libxc.IHDR_VERSION, # Version + 2, # Version libxc.IHDR_OPT_LE, # Options 0, 0)) # Reserved =20 @@ -632,13 +632,13 @@ def main(): usage =3D ("%prog [options] -i INPUT -o OUTPUT" " -w WIDTH -g GUEST"), description =3D - "Convert a legacy stream to a v2 stream") + "Convert a legacy stream to a v2 (or later) stre= am") =20 # Required options parser.add_option("-i", "--in", dest =3D "fin", metavar =3D "", help =3D "Legacy input to convert") parser.add_option("-o", "--out", dest =3D "fout", metavar =3D "", - help =3D "v2 format output") + help =3D "v2 (or later) format output") parser.add_option("-w", "--width", dest =3D "twidth", metavar =3D "<32/64>", choices =3D ["32", "64"], help =3D "Legacy toolstack bitness") diff --git a/tools/python/scripts/verify-stream-v2 b/tools/python/scripts/v= erify-stream-v2 index 8bac04d566..fe82b86c11 100755 --- a/tools/python/scripts/verify-stream-v2 +++ b/tools/python/scripts/verify-stream-v2 @@ -108,7 +108,7 @@ def main(): =20 parser =3D OptionParser(usage =3D "%prog [options]", description =3D - "Verify a stream according to the v2 spec") + "Verify a stream according to the v2 (or later) = spec") =20 # Optional options parser.add_option("-i", "--in", dest =3D "fin", metavar =3D "", diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index 8a800df980..63b3558029 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -19,7 +19,6 @@ =20 IHDR_MARKER =3D 0xffffffffffffffff IHDR_IDENT =3D 0x58454E46 # "XENF" in ASCII -IHDR_VERSION =3D 2 =20 IHDR_OPT_BIT_ENDIAN =3D 0 IHDR_OPT_LE =3D (0 << IHDR_OPT_BIT_ENDIAN) @@ -113,7 +112,7 @@ HVM_PARAMS_FORMAT =3D "II" =20 class VerifyLibxc(VerifyBase): - """ Verify a Libxc v2 stream """ + """ Verify a Libxc v2 (or later) stream """ =20 def __init__(self, info, read): VerifyBase.__init__(self, info, read) @@ -144,9 +143,9 @@ def verify_ihdr(self): raise StreamError("Bad image id: Expected 0x%x, got 0x%x" % (IHDR_IDENT, ident)) =20 - if version !=3D IHDR_VERSION: - raise StreamError("Unknown image version: Expected %d, got %d"= % - (IHDR_VERSION, version)) + if version !=3D 2: + raise StreamError("Unknown image version: Expected 2, got %d" % + (version, )) =20 if options & IHDR_OPT_RESZ_MASK: raise StreamError("Reserved bits set in image options field: 0= x%x" % --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 15801357416791004.3473412759388; Mon, 27 Jan 2020 06:35:41 -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 1iw5Tm-0001cO-JC; Mon, 27 Jan 2020 14:35:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tl-0001bf-IN for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:05 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2dc7d0d2-4112-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 14:34:52 +0000 (UTC) X-Inumbo-ID: 2dc7d0d2-4112-11ea-9fd7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BQYyiiIthqwQ0O2nSrSpIQ/hytPrIvWX7cAdThOzMss=; b=WWe7M2yBS9oQ4/m0qtMubOUXGFqTHzjR1q0ubRfR2ah4bwLZwPGPzMts T1T7zIFs9641cgL7U0Oe6Udd/7udOqJ6UfmNgYPZ5TuQ/bjyEeAxqer30 WU29B/Rrfxh3/4X7cosDu4FWPyKJIHMi4eaZhd+lUdMakaZRRlEGpDddX 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: GeMvSajp3ZAu4WIqZ84loyW9WE6Pw+cN1rLeayriGgYiaSz+S6O1AKAw06jAziGyw1SvrSkJQG 2jmZp/NlyifDBDU5NuSd9O8Jpl2V4M0//oHY9Zj7iEZ5TK1V33wIDxgRN5z/mOWYaoaEy+ezoH IUXBxLC77m+wWOORDM/8Kpg83vFEyiIK9u9MBIoBVPmo1ZX2bRdRZiuATs2mNKKXAKfCgxxcSD SgCm0SWJL5oDLWF1sErIM+Lwtlk9dyZDYmdDyvRn4aB3wh0OrOB4pvDjLo4O4dvIISBr/NY0ky UU4= X-SBRS: 2.7 X-MesageID: 11664975 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="11664975" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:31 +0000 Message-ID: <20200127143444.25538-5-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 04/17] docs/migration Specify migration v3 and STATIC_DATA_END 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , 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) Migration data can be split into two parts - that which is invariant of guest execution, and that which is not. Separate these two with the STATIC_DATA_END record. The short term, we want to move the x86 CPU Policy data into the stream. In the longer term, we want to provisionally send the static data only to the destination as a more robust compatibility check. In both cases, we will want a callback into the higher level toolstack. Mandate the presence of the STATIC_DATA_END record, and declare this v3, along with instructions for how to compatibly interpret a v2 stream. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Marek Marczykowski-G=C3=B3recki --- docs/specs/libxc-migration-stream.pandoc | 39 ++++++++++++++++++++++++++++= +--- tools/libxc/xc_sr_common.c | 1 + tools/libxc/xc_sr_stream_format.h | 1 + tools/python/xen/migration/libxc.py | 2 ++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/specs/libxc-migration-stream.pandoc b/docs/specs/libxc-mi= gration-stream.pandoc index a7a8a08936..22ff306e0b 100644 --- a/docs/specs/libxc-migration-stream.pandoc +++ b/docs/specs/libxc-migration-stream.pandoc @@ -127,7 +127,7 @@ marker 0xFFFFFFFFFFFFFFFF. =20 id 0x58454E46 ("XENF" in ASCII). =20 -version 0x00000002. The version of this specification. +version 0x00000003. The version of this specification. =20 options bit 0: Endianness. 0 =3D little-endian, 1 =3D big-endian. =20 @@ -620,6 +620,21 @@ The count of pfns is: record->length/sizeof(uint64_t). =20 \clearpage =20 +STATIC_DATA_END +--------------- + +A static data end record marks the end of the static state. I.e. state wh= ich +is invariant of guest execution. + + + 0 1 2 3 4 5 6 7 octet + +-------------------------------------------------+ + +The end record contains no fields; its body_length is 0. + +\clearpage + + Layout =3D=3D=3D=3D=3D=3D =20 @@ -639,7 +654,9 @@ A typical save record for an x86 PV guest image would l= ook like: =20 * Image header * Domain header -* X86_PV_INFO record +* Static data records: + * X86_PV_INFO record + * STATIC_DATA_END * X86_PV_P2M_FRAMES record * Many PAGE_DATA records * X86_TSC_INFO @@ -667,6 +684,8 @@ A typical save record for an x86 HVM guest image would = look like: =20 * Image header * Domain header +* Static data records: + * STATIC_DATA_END * Many PAGE_DATA records * X86_TSC_INFO * HVM_PARAMS @@ -675,9 +694,23 @@ A typical save record for an x86 HVM guest image would= look like: HVM_PARAMS must precede HVM_CONTEXT, as certain parameters can affect the validity of architectural state in the context. =20 +Compatibility with older versions +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + +v3 compat with v2 +----------------- + +A v3 stream is compatible with a v2 stream, but mandates the presense of a +STATIC_DATA_END record ahead of any memory/register content. This is to e= ase +the introduction of new static configuration records over time. + +A v3-compatible reciever interpreting a v2 stream should infer the positio= n of +STATIC_DATA_END based on finding the first X86_PV_P2M_FRAMES record (for PV +guests), or PAGE_DATA record (for HVM guests) and behave as if STATIC_DATA= _END +had been sent. =20 Legacy Images (x86 only) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +------------------------ =20 Restoring legacy images from older tools shall be handled by translating the legacy format image into this new format. diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c index dd9a11b4b5..7f22cf0365 100644 --- a/tools/libxc/xc_sr_common.c +++ b/tools/libxc/xc_sr_common.c @@ -36,6 +36,7 @@ static const char *const mandatory_rec_types[] =3D [REC_TYPE_VERIFY] =3D "Verify", [REC_TYPE_CHECKPOINT] =3D "Checkpoint", [REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST] =3D "Checkpoint dirty pfn list= ", + [REC_TYPE_STATIC_DATA_END] =3D "Static data end", }; =20 const char *rec_type_to_str(uint32_t type) diff --git a/tools/libxc/xc_sr_stream_format.h b/tools/libxc/xc_sr_stream_f= ormat.h index ae7c0de393..81c9765b0a 100644 --- a/tools/libxc/xc_sr_stream_format.h +++ b/tools/libxc/xc_sr_stream_format.h @@ -73,6 +73,7 @@ struct xc_sr_rhdr #define REC_TYPE_VERIFY 0x0000000dU #define REC_TYPE_CHECKPOINT 0x0000000eU #define REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST 0x0000000fU +#define REC_TYPE_STATIC_DATA_END 0x00000010U =20 #define REC_TYPE_OPTIONAL 0x80000000U =20 diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index 63b3558029..d0c4f3527d 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -56,6 +56,7 @@ REC_TYPE_verify =3D 0x0000000d REC_TYPE_checkpoint =3D 0x0000000e REC_TYPE_checkpoint_dirty_pfn_list =3D 0x0000000f +REC_TYPE_static_data_end =3D 0x00000010 =20 rec_type_to_str =3D { REC_TYPE_end : "End", @@ -74,6 +75,7 @@ REC_TYPE_verify : "Verify", REC_TYPE_checkpoint : "Checkpoint", REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list", + REC_TYPE_static_data_end : "Static data end", } =20 # page_data --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580135735637355.99097893448095; Mon, 27 Jan 2020 06:35:35 -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 1iw5Te-0001Wn-Dz; Mon, 27 Jan 2020 14:34:58 +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.89) (envelope-from ) id 1iw5Tc-0001VS-R0 for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:34:56 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2cd8720a-4112-11ea-855c-12813bfff9fa; Mon, 27 Jan 2020 14:34:51 +0000 (UTC) X-Inumbo-ID: 2cd8720a-4112-11ea-855c-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135692; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=huVJ+0aCOpAGQCtN/yPRBaOtQQ4sNAcOCS16fjqXD/M=; b=GBA86jGTLj4pyvu/pXsIR2ZOnT4gKvbirbr5Li0JytDMcTutgmIPq/B7 oJw0z9sdsEvFJdwDdDgivdQqVSzWK8eVVuSMhDaoBvR9gXGDmF2omnZYG FMcaf+tnVNXVCqlGPZrfhsYqVL5vBuPouWKaUyx2bf5HDArQ3XxL0Q9Ff Y=; 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: oXiO09je6FvLpuTsU5ZM6xrk3eR10jdlgTw5Ha2agaokRcNMgWJBoCGBRxoxifDSMUBTGVJql+ AeLNMb12PjjmLL4TrgeVESbk9XUa3QoIOgr9WjsxME+nOolO4B81687fuFuWzJxcgEWB/pwCXv fYCN3sSKucvMcwW0vwZ04gwIpcWf0pWI3U4M64ue2RlDa0RZZJUgJgVLc7byYmtMrQVo0df5oX m1oA6PT8kRolAIBXQ7hwxbM9Ex5rytN9W18ysuvxds95RMO9iipHhPcEWMduOcrPRACk3PLtga RLs= X-SBRS: 2.7 X-MesageID: 11664974 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="11664974" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:32 +0000 Message-ID: <20200127143444.25538-6-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 05/17] python/migration: Update validation logic to understand a v3 stream 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 , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , 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) Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Marek Marczykowski-G=C3=B3recki --- tools/python/xen/migration/libxc.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index d0c4f3527d..5fb51b56ac 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -119,6 +119,7 @@ class VerifyLibxc(VerifyBase): def __init__(self, info, read): VerifyBase.__init__(self, info, read) =20 + self.version =3D 0 self.squashed_pagedata_records =3D 0 =20 =20 @@ -145,9 +146,12 @@ def verify_ihdr(self): raise StreamError("Bad image id: Expected 0x%x, got 0x%x" % (IHDR_IDENT, ident)) =20 - if version !=3D 2: - raise StreamError("Unknown image version: Expected 2, got %d" % - (version, )) + if not (2 <=3D version <=3D 3): + raise StreamError( + "Unknown image version: Expected 2 <=3D ver <=3D 3, got %d= " % + (version, )) + + self.version =3D version =20 if options & IHDR_OPT_RESZ_MASK: raise StreamError("Reserved bits set in image options field: 0= x%x" % @@ -164,7 +168,8 @@ def verify_ihdr(self): "Stream is not native endianess - unable to validate") =20 endian =3D ["little", "big"][options & IHDR_OPT_LE] - self.info("Libxc Image Header: %s endian" % (endian, )) + self.info("Libxc Image Header: Version %d, %s endian" % + (version, endian)) =20 =20 def verify_dhdr(self): @@ -424,6 +429,16 @@ def verify_record_checkpoint_dirty_pfn_list(self, cont= ent): raise RecordError("Found checkpoint dirty pfn list record in strea= m") =20 =20 + def verify_record_static_data_end(self, content): + """ static data end record """ + + if len(content) !=3D 0: + raise RecordError("End record with non-zero length") + + if self.version < 3: + raise RecordError("Static data end record found in v2 stream") + + record_verifiers =3D { REC_TYPE_end: VerifyLibxc.verify_record_end, @@ -465,4 +480,7 @@ def verify_record_checkpoint_dirty_pfn_list(self, conte= nt): VerifyLibxc.verify_record_checkpoint, REC_TYPE_checkpoint_dirty_pfn_list: VerifyLibxc.verify_record_checkpoint_dirty_pfn_list, + + REC_TYPE_static_data_end: + VerifyLibxc.verify_record_static_data_end, } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580135732761672.9575278427609; Mon, 27 Jan 2020 06:35:32 -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 1iw5Ti-0001Z7-5x; Mon, 27 Jan 2020 14:35:02 +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.89) (envelope-from ) id 1iw5Th-0001Yj-Ql for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:01 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2dfb9f2a-4112-11ea-855c-12813bfff9fa; Mon, 27 Jan 2020 14:34:52 +0000 (UTC) X-Inumbo-ID: 2dfb9f2a-4112-11ea-855c-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JByyWBMzNurByECMS+gx972j/F2ryr/mglT8o9Zi7Sk=; b=Q1BcAbqbkDQiX6M3VudAGduva48BAbtkqwJAKdGSgxbMXaMZ7AULERvn xBi1a8PnYJIEgz1pWdlyO2EM9WXcgUUroulgsUfHOLY2uNnhUjoH5Zgwr 6lUY0HEC+6cxZxgaJ5iDPhygA5BJundHAUAjwYkxeEAxQHSbLU2YDz8W+ Q=; 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: RxV/sk+Mll9oa8Dz0Ubef1VcJsEsH8wLBucBWs7mg+aYr4NLE/08kIcY+XWXCJrO+XbJIrxqIR K75hS75gzMh2KsA5T1Iic8ZooABpsFibXyf3BHT0bV+RTIPZZVobZ0UuPAR8YmrKRbqviaYnhb b87nszGB/MYYg3cP+XI2VACwOJDNUJo7vUm5Phzot4+dIAlOtAo2p5a2R2XaJ++w3/xvrHJCSa NgpKL+TMoQwh8I0ysGm91cQfkXobu6PBPD7CKnGYQ2WJS79BwmOzGCUDdDr7uEeYOO+T0DC357 cZY= X-SBRS: 2.7 X-MesageID: 11664977 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="11664977" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:33 +0000 Message-ID: <20200127143444.25538-7-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 06/17] libxc/restore: Support v3 streams and handle STATIC_DATA_END 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) Higher level toolstacks may wish to know when the static data is complete, = so introduce a restore_callback for the purpose. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu v2: * Split/rearranged from v1 --- tools/libxc/include/xenguest.h | 3 +++ tools/libxc/xc_sr_common.h | 3 +++ tools/libxc/xc_sr_restore.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index 19d828a7f2..efd90b0d42 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -139,6 +139,9 @@ 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. */ + int (*static_data_done)(void *data); + /* Called after a new checkpoint to suspend the guest. */ int (*suspend)(void *data); =20 diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index 5dd51ccb15..ae0ab70f76 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -253,6 +253,9 @@ struct xc_sr_context /* Currently buffering records between a checkpoint */ bool buffer_all_records; =20 + /* Whether a STATIC_DATA_END record has been seen. */ + bool seen_static_data_end; + /* * With Remus/COLO, we buffer the records sent by the primary at checkpoin= t, * in case the primary will fail, we can recover from the last diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index dc2ffcf855..9c924387ae 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -35,9 +35,9 @@ static int read_headers(struct xc_sr_context *ctx) return -1; } =20 - if ( ihdr.version !=3D 2 ) + if ( ihdr.version < 2 || ihdr.version > 3 ) { - ERROR("Invalid Version: Expected 2, Got %d", + ERROR("Invalid Version: Expected 2 <=3D ver <=3D 3, Got %d", ihdr.version); return -1; } @@ -631,6 +631,27 @@ static int buffer_record(struct xc_sr_context *ctx, st= ruct xc_sr_record *rec) return 0; } =20 +static int handle_static_data_end(struct xc_sr_context *ctx) +{ + xc_interface *xch =3D ctx->xch; + int rc =3D 0; + + if ( ctx->restore.seen_static_data_end ) + { + ERROR("Multiple STATIC_DATA_END records found"); + return -1; + } + + ctx->restore.seen_static_data_end =3D true; + + if ( ctx->restore.callbacks->static_data_done && + (rc =3D ctx->restore.callbacks->static_data_done( + ctx->restore.callbacks->data) !=3D 0) ) + ERROR("static_data_done() callback failed: %d\n", rc); + + return rc; +} + static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *= rec) { xc_interface *xch =3D ctx->xch; @@ -654,6 +675,10 @@ static int process_record(struct xc_sr_context *ctx, s= truct xc_sr_record *rec) rc =3D handle_checkpoint(ctx); break; =20 + case REC_TYPE_STATIC_DATA_END: + rc =3D handle_static_data_end(ctx); + break; + default: rc =3D ctx->restore.ops.process_record(ctx, rec); break; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 From nobody Mon Apr 29 01:42:20 2024 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 1580135745573518.0948533472592; Mon, 27 Jan 2020 06:35:45 -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 1iw5To-0001e4-6r; Mon, 27 Jan 2020 14:35:08 +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.89) (envelope-from ) id 1iw5Tm-0001ca-RC for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:06 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2dfb9f2b-4112-11ea-855c-12813bfff9fa; Mon, 27 Jan 2020 14:34:53 +0000 (UTC) X-Inumbo-ID: 2dfb9f2b-4112-11ea-855c-12813bfff9fa 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:content-transfer-encoding; bh=pCcCf0Qf97HTuetLmatBuIzDe46g+JOWxvGQNTxhwcs=; b=Hf8H8JiUetV5lKZjQV1AA74y0rPcwYB8Mx7373cIcJW6G2cGdYrCdD6e SPJefAdb6Ol92z5h4dRcAfARr8yxQnZxcYVMx0gT2dhhOyg3P6M3ibqG9 hIbNxjc6PIr3+tdOdvgnwEyFG7yFKtPVK8enNTr5AIUdd1tUkP4B8IM5f 8=; 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: q+An6nXEr/ePBARVvBBjl9otGh3Bki+ZRzOiHhjZOLO9Ggmc2Hjmj8kLPwRhgr1u1JNPPwSS5Y ijAYUQcCX1YkmcG4PNFQ9dPodWv3TSLH46iJ7qnivYbyP0CEK2v9oelF88JR48ZhN9etBPI1aq jvadiao2HTJSFZupuWaaXWpmQHC1Tq365Dz4sE5B4vNazvk/xyrFHKZIreT5teM/UV1hamwPt9 b8e8vCkx8AtAxq1zG4nYWblSXjGD6Ee9LZ+3PTjQYjcn/ivCTUeV8Xb4AWg2xcViccf8mxT04c EL8= X-SBRS: 2.7 X-MesageID: 11664978 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="11664978" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:35 +0000 Message-ID: <20200127143444.25538-9-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 08/17] libxc/save: Write a v3 stream 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 , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , 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) Introduce a new static_data() hook which is responsible for writing out any static data records. The HVM side continues to be a no-op, while the PV side moves write_x86_pv_info() into this earlier hook. The the common code writes out a STATIC_DATA_END record, and the stream version is bumped to 3. Update convert-legacy-stream to write a v3 stream, because this will bypass the compatibly logic in libxc. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Marek Marczykowski-G=C3=B3recki --- tools/libxc/xc_sr_common.h | 10 ++++++++-- tools/libxc/xc_sr_save.c | 20 +++++++++++++++++++- tools/libxc/xc_sr_save_x86_hvm.c | 6 ++++++ tools/libxc/xc_sr_save_x86_pv.c | 10 ++++++---- tools/python/scripts/convert-legacy-stream | 9 ++++++++- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index 51e3d3ee3b..fd7fb67305 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -63,8 +63,14 @@ struct xc_sr_save_ops int (*setup)(struct xc_sr_context *ctx); =20 /** - * Send records which need to be at the start of the stream. This is - * called once, after the Image and Domain headers are written. + * Send static records at the head of the stream. This is called once, + * after the Image and Domain headers are written. + */ + int (*static_data)(struct xc_sr_context *ctx); + + /** + * Send dynamic records which need to be at the start of the stream. = This + * is called after the STATIC_DATA_END record is written. */ int (*start_of_stream)(struct xc_sr_context *ctx); =20 diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index 5c5ce18ac3..2b6c55af2a 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -13,7 +13,7 @@ static int write_headers(struct xc_sr_context *ctx, uint1= 6_t guest_type) struct xc_sr_ihdr ihdr =3D { .marker =3D IHDR_MARKER, .id =3D htonl(IHDR_ID), - .version =3D htonl(2), + .version =3D htonl(3), .options =3D htons(IHDR_OPT_LITTLE_ENDIAN), }; struct xc_sr_dhdr dhdr =3D { @@ -55,6 +55,16 @@ static int write_end_record(struct xc_sr_context *ctx) } =20 /* + * Writes a STATIC_DATA_END record into the stream. + */ +static int write_static_data_end_record(struct xc_sr_context *ctx) +{ + struct xc_sr_record end =3D { .type =3D REC_TYPE_STATIC_DATA_END }; + + return write_record(ctx, &end); +} + +/* * Writes a CHECKPOINT record into the stream. */ static int write_checkpoint_record(struct xc_sr_context *ctx) @@ -849,6 +859,14 @@ static int save(struct xc_sr_context *ctx, uint16_t gu= est_type) if ( rc ) goto err; =20 + rc =3D ctx->save.ops.static_data(ctx); + if ( rc ) + goto err; + + rc =3D write_static_data_end_record(ctx); + if ( rc ) + goto err; + rc =3D ctx->save.ops.start_of_stream(ctx); if ( rc ) goto err; diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_= hvm.c index d99efe65e5..93bcc1c273 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -170,6 +170,11 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) return 0; } =20 +static int x86_hvm_static_data(struct xc_sr_context *ctx) +{ + return 0; +} + static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) { return 0; @@ -228,6 +233,7 @@ struct xc_sr_save_ops save_ops_x86_hvm =3D .pfn_to_gfn =3D x86_hvm_pfn_to_gfn, .normalise_page =3D x86_hvm_normalise_page, .setup =3D x86_hvm_setup, + .static_data =3D x86_hvm_static_data, .start_of_stream =3D x86_hvm_start_of_stream, .start_of_checkpoint =3D x86_hvm_start_of_checkpoint, .end_of_checkpoint =3D x86_hvm_end_of_checkpoint, diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_p= v.c index f3ccf5bb4b..46019d962d 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -1052,14 +1052,15 @@ static int x86_pv_setup(struct xc_sr_context *ctx) return 0; } =20 +static int x86_pv_static_data(struct xc_sr_context *ctx) +{ + return write_x86_pv_info(ctx); +} + static int x86_pv_start_of_stream(struct xc_sr_context *ctx) { int rc; =20 - rc =3D write_x86_pv_info(ctx); - if ( rc ) - return rc; - /* * Ideally should be able to change during migration. Currently * corruption will occur if the contents or location of the P2M changes @@ -1126,6 +1127,7 @@ struct xc_sr_save_ops save_ops_x86_pv =3D .pfn_to_gfn =3D x86_pv_pfn_to_gfn, .normalise_page =3D x86_pv_normalise_page, .setup =3D x86_pv_setup, + .static_data =3D x86_pv_static_data, .start_of_stream =3D x86_pv_start_of_stream, .start_of_checkpoint =3D x86_pv_start_of_checkpoint, .end_of_checkpoint =3D x86_pv_end_of_checkpoint, diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scri= pts/convert-legacy-stream index 02a194178f..ca93a93848 100755 --- a/tools/python/scripts/convert-legacy-stream +++ b/tools/python/scripts/convert-legacy-stream @@ -79,7 +79,7 @@ def write_libxc_ihdr(): stream_write(pack(libxc.IHDR_FORMAT, libxc.IHDR_MARKER, # Marker libxc.IHDR_IDENT, # Ident - 2, # Version + 3, # Version libxc.IHDR_OPT_LE, # Options 0, 0)) # Reserved =20 @@ -166,6 +166,9 @@ def write_libxc_hvm_params(params): pack(libxc.HVM_PARAMS_FORMAT, len(params) / 2, 0), pack("Q" * len(params), *params)) =20 +def write_libxc_static_data_end(): + write_record(libxc.REC_TYPE_static_data_end) + def write_libxl_end(): write_record(libxl.REC_TYPE_end) =20 @@ -590,6 +593,10 @@ def read_legacy_stream(vm): =20 if pv: read_pv_extended_info(vm) + + write_libxc_static_data_end() + + if pv: read_pv_p2m_frames(vm) =20 read_chunks(vm) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580135749496772.5892529786538; Mon, 27 Jan 2020 06:35:49 -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 1iw5Tx-0001mF-23; Mon, 27 Jan 2020 14:35:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Tv-0001lC-JN for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:35:15 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2f48dd2a-4112-11ea-9fd7-bc764e2007e4; Mon, 27 Jan 2020 14:34:54 +0000 (UTC) X-Inumbo-ID: 2f48dd2a-4112-11ea-9fd7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580135695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UbsHe1wi3bTySabmAStCVzWgNCVaNfk2EHfbK/LjL+0=; b=KSBI2A4ph531kVSEnmdRn5rfr2JFSaMRFj+rVPa4Y0CeemBv3yDX5z+c 27grabNur+x+Oa7DRtsWfBCPte1Vbab/7wA15c1NQ1feXJSUCmobXuzLH v0ZvHtD3AHXPPJ2sOhZTZ57WoM45BToU66peBOGCcc9+acn9/Sk9ZPKg1 o=; 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: n26TYleU3B6VHBVLUCxZWwCT7npHwNnkpCvMJx1MrqsJ8lg/s3nbzrTvRbiiVEcscmaqX8Zdvr jawnTBmQrGi7Bz8iMvPMjJvvncSL52srocGldwR/SbB+Fm7ivCWLHxjrKq7DusdJ/y1XcMffqt 5yY4iVobU77ZUO/KPWm3vu4i7LzqMXksyWlHbVnXE6Al3+MW5IIVpk1YhMrxEWWNffuXEawf9w XT9hfptcpibPmWdG37d+fnAZzj7WSYuc/MhfGB0o3vcUOJBb7juy20sE+KmwpSEFlYQGkttH4x q3E= X-SBRS: 2.7 X-MesageID: 11664983 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="11664983" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:36 +0000 Message-ID: <20200127143444.25538-10-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 09/17] tools/libxl: Provide a static_data_done callback for domain restore 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: Anthony PERARD , 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) This will be needed shortly to provide backwards compatiblity for migration streams which do not have CPUID information contained within them. No functional change yet. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD v2: * Split/rearranged from v1 --- tools/libxl/libxl_create.c | 12 ++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 32d45dcef0..12113185ac 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1227,6 +1227,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs =3D dcs; =20 /* Restore */ + callbacks->static_data_done =3D libxl__srm_callout_callback_static_dat= a_done; callbacks->restore_results =3D libxl__srm_callout_callback_restore_res= ults; =20 /* COLO only supports HVM now because it does not work very @@ -1296,6 +1297,17 @@ static void libxl__colo_restore_setup_done(libxl__eg= c *egc, libxl__stream_read_start(egc, &dcs->srs); } =20 +int libxl__srm_callout_callback_static_data_done(void *user) +{ + libxl__save_helper_state *shs =3D user; + libxl__domain_create_state *dcs =3D shs->caller_state; + STATE_AO_GC(dcs->ao); + + /* Nothing to do (yet). */ + + return 0; +} + void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, xen_pfn_t console_mfn, void *user) { diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_ms= gs_gen.pl index 831a15e0bb..93dc252370 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -29,6 +29,7 @@ our @msgs =3D ( [ 'srcxA', "wait_checkpoint", [] ], [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid unsigned enable)] ], + [ 'rcxW', "static_data_done", [] ], [ 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', 'xen_pfn_t', 'console_gfn'] ], [ 'srW', "complete", [qw(int retval --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136097234336.337565018187; Mon, 27 Jan 2020 06:41:37 -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 1iw5Zb-0003K5-09; Mon, 27 Jan 2020 14:41:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5Za-0003JG-2N for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:41:06 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0a8c5f56-4113-11ea-aecd-bc764e2007e4; Mon, 27 Jan 2020 14:41:03 +0000 (UTC) X-Inumbo-ID: 0a8c5f56-4113-11ea-aecd-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=XGsMkZQ7iaX5BEx0cLcWzcJNQZ5f9VzAHVUzuIVlipg=; b=EuxAUw6ltOFZthJwcIlqZdsdBhKTJiB43UnT/xIbynUECGlwUbJxhhDK GPlwhq1FJxB8UT94KY5qJWv6vvlm/+7qffxrzJkk8hVUQ6lHHZumsD0nT d4mvj7kb1AnvCnAZkT10ilXCpg5AHn7oCObxD6RUUOHkYeU2Hqggj5sw4 g=; 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: 5XO6lmxEIoHZgj509ViesNwMqRTesGGIjKBXCPWjizaE3FiKzkdhJCUyR6kSTyPkih0Dgt3lV2 819jDPUcI5wdOwoQeh2Kc7jO6youJvoJAApWo1geuZAAJ0PopDcAhz5QRdvo3FMCO5N6GVaSqb KD1o+wf2ELZsKkDbusvQsu9iwYYGR0suNoPYtV6bSZOOeOh8oiyYeZ9c0+l4u+4P2ekoYZz5BQ 4YS+LwQk3LeVUMrKvfXddxcvppdSmSmw7fXXlS1R7EGrA5qjkE8M+E0ALbwNYJZ/823eLO8OC1 e+4= X-SBRS: 2.7 X-MesageID: 11665364 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="11665364" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:37 +0000 Message-ID: <20200127143444.25538-11-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 10/17] tools/libxl: Plumb a restore boolean down into libxl__build_pre() 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: Anthony PERARD , 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) To fix CPUID handling, libxl__build_pre() is going to have to distinguish between a brand new VM vs one which is being migrated-in/resumed. No functional change. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD v2: * New. This is c/s aacc1430064 "tools/libxl: Plumb domain_create_state do= wn into libxl__build_pre()" take-2, without any collateral damage to stubdo= ms. --- tools/libxl/libxl_create.c | 9 +++++---- tools/libxl/libxl_dm.c | 2 +- tools/libxl/libxl_dom.c | 4 +++- tools/libxl/libxl_internal.h | 6 ++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 12113185ac..1d2e193509 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -434,14 +434,15 @@ static void init_console_info(libxl__gc *gc, int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, - libxl__domain_build_state *state) + libxl__domain_build_state *state, + bool restore) { libxl_domain_build_info *const info =3D &d_config->b_info; char **vments =3D NULL, **localents =3D NULL; struct timeval start_time; int i, ret; =20 - ret =3D libxl__build_pre(gc, domid, d_config, state); + ret =3D libxl__build_pre(gc, domid, d_config, state, restore); if (ret) goto out; =20 @@ -1218,7 +1219,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->sdss.callback =3D domcreate_devmodel_started; =20 if (restore_fd < 0 && dcs->domid_soft_reset =3D=3D INVALID_DOMID) { - rc =3D libxl__domain_build(gc, d_config, domid, state); + rc =3D libxl__domain_build(gc, d_config, domid, state, false); domcreate_rebuild_done(egc, dcs, rc); return; } @@ -1245,7 +1246,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto out; } =20 - rc =3D libxl__build_pre(gc, domid, d_config, state); + rc =3D libxl__build_pre(gc, domid, d_config, state, restore_fd >=3D 0); if (rc) goto out; =20 diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index e92e412c1b..d3dfa8751c 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2197,7 +2197,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stu= b_dm_spawn_state *sdss) if (ret) goto out; uint32_t dm_domid =3D sdss->pvqemu.guest_domid; - ret =3D libxl__domain_build(gc, dm_config, dm_domid, stubdom_state); + ret =3D libxl__domain_build(gc, dm_config, dm_domid, stubdom_state, fa= lse); if (ret) goto out; =20 diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index b730365f47..1bac277351 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -244,7 +244,9 @@ static int numa_place_domain(libxl__gc *gc, uint32_t do= mid, } =20 int libxl__build_pre(libxl__gc *gc, uint32_t domid, - libxl_domain_config *d_config, libxl__domain_build_state *st= ate) + libxl_domain_config *d_config, + libxl__domain_build_state *state, + bool restore) { libxl_domain_build_info *const info =3D &d_config->b_info; libxl_ctx *ctx =3D libxl__gc_owner(gc); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 50856ca703..e66b068d16 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1390,7 +1390,8 @@ _hidden void libxl__domain_build_state_dispose(libxl_= _domain_build_state *s); =20 _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, libxl_domain_config * const d_config, - libxl__domain_build_state *state); + libxl__domain_build_state *state, + bool restore); _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, libxl__domain_build_state *s= tate, char **vms_ents, char **local_ents); @@ -1963,7 +1964,8 @@ _hidden int libxl__domain_make(libxl__gc *gc, _hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, - libxl__domain_build_state *state); + libxl__domain_build_state *state, + bool restore); =20 /* for device model creation */ _hidden const char *libxl__domain_device_model(libxl__gc *gc, --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136085942334.5330559420023; Mon, 27 Jan 2020 06:41:25 -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 1iw5ZM-00039T-I9; Mon, 27 Jan 2020 14:40:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5ZL-000384-42 for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:40:51 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0302d7e2-4113-11ea-aecd-bc764e2007e4; Mon, 27 Jan 2020 14:40:50 +0000 (UTC) X-Inumbo-ID: 0302d7e2-4113-11ea-aecd-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=re8wKPUa0WJZ1jfdK9kaNjyJi81i0wauyu8vDs8BsBc=; b=eakj0HNqS09H1FxmZLtH+hn+UwUX/lAC7+DfInymYu/jAF7/NsAKuym1 XrbmkEeW5Y5rQacVvFkUM6bLZtPcuJzbHne4S1CWCXEhffgvmyMAG4BZ7 h9UajohiPNuwrNRQDmvPPb8iRPoMWxlZAT3Wejv772HTshD/YFpBs/ogm Q=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: NSvsbcCY1KsInLzIjJtOPUfe8nbLneMsgrZwbGmlM3lJVZpuaxwXPPGPwdotHEeAv7B9eBay1g Gtsohfo1AcQm87G/D1wDMWRQlJvJTvk/kUAusIYeQB4zvPMQo4aROHKkrjoewpVAxEgvhNeq58 F0iwZ0rfYCKI/lvTjy+fBmii5CKxKWEdnZg9v+S4iadhTOCXiCc8eq0WHFQIiGLJT32oiRpKFc R0K9OZmXRmksIO5YgLaUFt7z1h8TYRVeLpA5OgyOaWAccMJXVYJm96OCvEX9EMi3+8Yk/4SjsH ue4= X-SBRS: 2.7 X-MesageID: 11507064 X-Ironport-Server: esa2.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="11507064" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:38 +0000 Message-ID: <20200127143444.25538-12-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 11/17] tools/libxl: Re-position CPUID handling during domain construction 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: Anthony PERARD , 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) CPUID handling needs to be earlier in construction. Move it from its curre= nt position in libxl__build_post() to libxl__build_pre() for fresh builds, and libxl__srm_callout_callback_static_data_done() for the migration/resume cas= e. Later changes will make the migration/resume case conditional on whether CP= UID data was present in the migration stream, and the libxc layer took care of restoring it. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_dom.c | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 1d2e193509..09f84858d5 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1303,8 +1303,14 @@ int libxl__srm_callout_callback_static_data_done(voi= d *user) libxl__save_helper_state *shs =3D user; libxl__domain_create_state *dcs =3D shs->caller_state; STATE_AO_GC(dcs->ao); + libxl_ctx *ctx =3D libxl__gc_owner(gc); + + const libxl_domain_config *d_config =3D dcs->guest_config; + const libxl_domain_build_info *info =3D &d_config->b_info; =20 - /* Nothing to do (yet). */ + libxl__cpuid_apply_policy(ctx, dcs->guest_domid); + if (info->cpuid !=3D NULL) + libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid); =20 return 0; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 1bac277351..5dc8369eda 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -389,6 +389,18 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, =20 rc =3D libxl__arch_domain_create(gc, d_config, domid); =20 + /* Construct a CPUID policy, but only for brand new domains. Domains + * being migrated-in/restored have CPUID handled during the + * static_data_done() callback. */ + if (!restore) { + /* For x86 at least, libxl_cpuid_apply_policy() takes an implicit + * parameter, HVM_PARAM_PAE_ENABLED, which is only set up in + * libxl__arch_domain_create(). */ + libxl_cpuid_apply_policy(ctx, domid); + if (info->cpuid !=3D NULL) + libxl_cpuid_set(ctx, domid, info->cpuid); + } + return rc; } =20 @@ -456,10 +468,6 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, if (rc) return rc; =20 - libxl__cpuid_apply_policy(ctx, domid); - if (info->cpuid !=3D NULL) - libxl__cpuid_set(ctx, domid, info->cpuid); - if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && !libxl_ms_vm_genid_is_zero(&info->u.hvm.ms_vm_genid)) { rc =3D libxl__ms_vm_genid_set(gc, domid, --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136093066171.6840824051069; Mon, 27 Jan 2020 06:41:33 -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 1iw5ZP-0003BJ-TW; Mon, 27 Jan 2020 14:40:55 +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.89) (envelope-from ) id 1iw5ZO-0003Aw-Ly for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:40:54 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 040dfe5a-4113-11ea-855d-12813bfff9fa; Mon, 27 Jan 2020 14:40:51 +0000 (UTC) X-Inumbo-ID: 040dfe5a-4113-11ea-855d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bXEprMdLnMAsSlQbR/hJu92Hzj+lCqsYWq7oAUAnzeg=; b=fV/VkvHcZt3J05l9voE0EN3kw+1gbjeOG59TgTfK6Md7V0CcbqgZ/xHk gfWvc4v7S65Jocrke71fmlhZUIUS1THa7D9QsHznwYgqUAH7c0ZyM6YB/ ei2CgUMrrP4c29pJL1pTNNJMw8ferHHZRnNidTsqtupqHw3/IjyS8ELsy o=; 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: 5ta3NHyMIsvbjn5n4a9nDm4JM5WjFGU22wYj+RmH4qmzd3htd9KNC6H2U4u6ZYfvTtbbwsqB2m NqO62RAdLKAFDUoctaePIhsTg01mmX+Q36eL49v0ox7LtMfV+eqMFlda4e3fm/DBDhHd/gdHlH xEUAS7+zimHtHTaSEc3zwNkGHnJx32tVu/gzlpS7Bs3YH75R51+XU15rPTeISJXOLwg+J66Uki 6FwEXWEDCbZS6h/Z4YNFxk0rhj7kdVTP/DMY2yuzsLS3Ftlh4xdZ35JJ9QnKZ0bSoW1BSBbJmJ b/0= X-SBRS: 2.7 X-MesageID: 11665355 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="11665355" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:39 +0000 Message-ID: <20200127143444.25538-13-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 12/17] docs/migration: Specify X86_{CPUID, MSR}_POLICY records 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Julien Grall , 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) These two records move blobs from the XEN_DOMCTL_{get,set}_cpu_policy hypercall. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall CC: Marek Marczykowski-G=C3=B3recki --- docs/specs/libxc-migration-stream.pandoc | 42 ++++++++++++++++++++++++++++= +++ tools/libxc/xc_sr_common.c | 2 ++ tools/libxc/xc_sr_stream_format.h | 2 ++ tools/python/xen/migration/libxc.py | 43 ++++++++++++++++++++++++++++= ++++ 4 files changed, 89 insertions(+) diff --git a/docs/specs/libxc-migration-stream.pandoc b/docs/specs/libxc-mi= gration-stream.pandoc index 22ff306e0b..3a0915b795 100644 --- a/docs/specs/libxc-migration-stream.pandoc +++ b/docs/specs/libxc-migration-stream.pandoc @@ -634,6 +634,46 @@ The end record contains no fields; its body_length is = 0. =20 \clearpage =20 +X86_CPUID_POLICY +---------------- + +CPUID policy content, as accessed by the XEN_DOMCTL_{get,set}_cpu_policy +hypercall sub-ops. + + 0 1 2 3 4 5 6 7 octet + +-------------------------------------------------+ + | CPUID_policy | + ... + +-------------------------------------------------+ + +-------------------------------------------------------------------- +Field Description +------------ --------------------------------------------------- +CPUID_policy Array of xen_cpuid_leaf_t[]'s +-------------------------------------------------------------------- + +\clearpage + +X86_MSR_POLICY +-------------- + +MSR policy content, as accessed by the XEN_DOMCTL_{get,set}_cpu_policy +hypercall sub-ops. + + 0 1 2 3 4 5 6 7 octet + +-------------------------------------------------+ + | MSR_policy | + ... + +-------------------------------------------------+ + +-------------------------------------------------------------------- +Field Description +---------- --------------------------------------------------- +MSR_policy Array of xen_msr_entry_t[]'s +-------------------------------------------------------------------- + +\clearpage + =20 Layout =3D=3D=3D=3D=3D=3D @@ -656,6 +696,7 @@ A typical save record for an x86 PV guest image would l= ook like: * Domain header * Static data records: * X86_PV_INFO record + * X86_{CPUID,MSR}_POLICY * STATIC_DATA_END * X86_PV_P2M_FRAMES record * Many PAGE_DATA records @@ -685,6 +726,7 @@ A typical save record for an x86 HVM guest image would = look like: * Image header * Domain header * Static data records: + * X86_{CPUID,MSR}_POLICY * STATIC_DATA_END * Many PAGE_DATA records * X86_TSC_INFO diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c index 7f22cf0365..7c54b03414 100644 --- a/tools/libxc/xc_sr_common.c +++ b/tools/libxc/xc_sr_common.c @@ -37,6 +37,8 @@ static const char *const mandatory_rec_types[] =3D [REC_TYPE_CHECKPOINT] =3D "Checkpoint", [REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST] =3D "Checkpoint dirty pfn list= ", [REC_TYPE_STATIC_DATA_END] =3D "Static data end", + [REC_TYPE_X86_CPUID_POLICY] =3D "x86 CPUID policy", + [REC_TYPE_X86_MSR_POLICY] =3D "x86 MSR policy", }; =20 const char *rec_type_to_str(uint32_t type) diff --git a/tools/libxc/xc_sr_stream_format.h b/tools/libxc/xc_sr_stream_f= ormat.h index 81c9765b0a..8a0da26f75 100644 --- a/tools/libxc/xc_sr_stream_format.h +++ b/tools/libxc/xc_sr_stream_format.h @@ -74,6 +74,8 @@ struct xc_sr_rhdr #define REC_TYPE_CHECKPOINT 0x0000000eU #define REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST 0x0000000fU #define REC_TYPE_STATIC_DATA_END 0x00000010U +#define REC_TYPE_X86_CPUID_POLICY 0x00000011U +#define REC_TYPE_X86_MSR_POLICY 0x00000012U =20 #define REC_TYPE_OPTIONAL 0x80000000U =20 diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index 5fb51b56ac..9881f5ced4 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -57,6 +57,8 @@ REC_TYPE_checkpoint =3D 0x0000000e REC_TYPE_checkpoint_dirty_pfn_list =3D 0x0000000f REC_TYPE_static_data_end =3D 0x00000010 +REC_TYPE_x86_cpuid_policy =3D 0x00000011 +REC_TYPE_x86_msr_policy =3D 0x00000012 =20 rec_type_to_str =3D { REC_TYPE_end : "End", @@ -76,6 +78,8 @@ REC_TYPE_checkpoint : "Checkpoint", REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list", REC_TYPE_static_data_end : "Static data end", + REC_TYPE_x86_cpuid_policy : "x86 CPUID policy", + REC_TYPE_x86_msr_policy : "x86 MSR policy", } =20 # page_data @@ -113,6 +117,12 @@ HVM_PARAMS_ENTRY_FORMAT =3D "QQ" HVM_PARAMS_FORMAT =3D "II" =20 +# x86_cpuid_policy =3D> xen_cpuid_leaf_t[] +X86_CPUID_POLICY_FORMAT =3D "IIIIII" + +# x86_msr_policy =3D> xen_msr_entry_t[] +X86_MSR_POLICY_FORMAT =3D "QII" + class VerifyLibxc(VerifyBase): """ Verify a Libxc v2 (or later) stream """ =20 @@ -439,6 +449,34 @@ def verify_record_static_data_end(self, content): raise RecordError("Static data end record found in v2 stream") =20 =20 + def verify_record_x86_cpuid_policy(self, content): + """ x86 CPUID policy record """ + + if self.version < 3: + raise RecordError("x86 CPUID policy record found in v2 stream") + + sz =3D calcsize(X86_CPUID_POLICY_FORMAT) + contentsz =3D len(content) + + if contentsz < sz or (contentsz % sz) !=3D 0: + raise RecordError("Record length %u, expected multiple of %u" % + (contentsz, sz)) + + + def verify_record_x86_msr_policy(self, content): + """ x86 MSR policy record """ + + if self.version < 3: + raise RecordError("x86 MSR policy record found in v2 stream") + + sz =3D calcsize(X86_MSR_POLICY_FORMAT) + contentsz =3D len(content) + + if contentsz < sz or (contentsz % sz) !=3D 0: + raise RecordError("Record length %u, expected multiple of %u" % + (contentsz, sz)) + + record_verifiers =3D { REC_TYPE_end: VerifyLibxc.verify_record_end, @@ -483,4 +521,9 @@ def verify_record_static_data_end(self, content): =20 REC_TYPE_static_data_end: VerifyLibxc.verify_record_static_data_end, + + REC_TYPE_x86_cpuid_policy: + VerifyLibxc.verify_record_x86_cpuid_policy, + REC_TYPE_x86_msr_policy: + VerifyLibxc.verify_record_x86_msr_policy, } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136087852873.238474685153; Mon, 27 Jan 2020 06:41:27 -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 1iw5ZR-0003CG-90; Mon, 27 Jan 2020 14:40:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5ZQ-0003BN-2B for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:40:56 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 046a07e0-4113-11ea-b833-bc764e2007e4; Mon, 27 Jan 2020 14:40:52 +0000 (UTC) X-Inumbo-ID: 046a07e0-4113-11ea-b833-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=75uIekn1UFqgP1IYkhjUCMtjBDzTaPOeRFCIvL3sHNM=; b=bW5dNs2SDzxvfy+V1xov7UEk1Bn1YWMY5NxtIomKezhw/fK6u6ninfxc gk9ORwJY76fYySEneV2t+AdWyZWblDBQPHegeDVLKsnzTiRfQ3q/ww2ar LbO9HCxowzIoasmk5E/e+5POftLsR1VTZu5WGkrQoQHq9utNxWoKUr+3C k=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 99rYCcF8qyJOxufjPfepmMptk0ytFEYI3QS1wUt3t5VmIC9m3/3hdCEJk5M2vmMoW1w/qIRTUw JtH5NgXueo07xcWDGqAQ8ZNKQuyNiIEHc0IAOPqiQlXQXL6EzowGvNiVtYYkAw/JlxpCvLHPLR 3s2EcIJ30fKB6FLcZXZEtQ5jcbiDm0pcodQM4Dckhnq7eDdofShRXIzFEy68ngd9jYJgLF6ELT XdVvPlBL5mVqmoFmVcLDDMxtiW0VuVG53latCiVqjrt571wB1A92L+3RCvLlT5nUW5JBf3G7sg auw= X-SBRS: 2.7 X-MesageID: 12093209 X-Ironport-Server: esa4.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="12093209" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:40 +0000 Message-ID: <20200127143444.25538-14-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 13/17] libxc/restore: Handle X86_{CPUID, MSR}_DATA records 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) For now, the data are just stashed, and discarded at the end. A future change will restore the data, once libxl has been adjusted to avoid clobbering the data. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_common.h | 10 ++++++++++ tools/libxc/xc_sr_common_x86.c | 40 +++++++++++++++++++++++++++++++++= ++++ tools/libxc/xc_sr_common_x86.h | 14 +++++++++++++ tools/libxc/xc_sr_restore_x86_hvm.c | 9 +++++++++ tools/libxc/xc_sr_restore_x86_pv.c | 9 +++++++++ 5 files changed, 82 insertions(+) diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index fd7fb67305..7742260690 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -296,6 +296,16 @@ struct xc_sr_context { struct /* x86 */ { + /* Common save/restore data. */ + union + { + struct + { + /* X86_{CPUID,MSR}_DATA blobs for CPU Policy. */ + struct xc_sr_blob cpuid, msr; + } restore; + }; + struct /* x86 PV guest. */ { /* 4 or 8; 32 or 64 bit domain */ diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 011684df97..8980299e9a 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -42,6 +42,46 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struc= t xc_sr_record *rec) return 0; } =20 +int handle_x86_cpuid_policy(struct xc_sr_context *ctx, struct xc_sr_record= *rec) +{ + xc_interface *xch =3D ctx->xch; + int rc; + + if ( rec->length =3D=3D 0 || + rec->length % sizeof(xen_cpuid_leaf_t) !=3D 0 ) + { + ERROR("X86_CPUID_POLICY size %u should be multiple of %zu", + rec->length, sizeof(xen_cpuid_leaf_t)); + return -1; + } + + rc =3D update_blob(&ctx->x86.restore.cpuid, rec->data, rec->length); + if ( rc ) + ERROR("Unable to allocate %u bytes for X86_CPUID_POLICY", rec->len= gth); + + return rc; +} + +int handle_x86_msr_policy(struct xc_sr_context *ctx, struct xc_sr_record *= rec) +{ + xc_interface *xch =3D ctx->xch; + int rc; + + if ( rec->length =3D=3D 0 || + rec->length % sizeof(xen_msr_entry_t) !=3D 0 ) + { + ERROR("X86_MSR_POLICY size %u should be multiple of %zu", + rec->length, sizeof(xen_cpuid_leaf_t)); + return -1; + } + + rc =3D update_blob(&ctx->x86.restore.msr, rec->data, rec->length); + if ( rc ) + ERROR("Unable to allocate %u bytes for X86_MSR_POLICY", rec->lengt= h); + + return rc; +} + /* * Local variables: * mode: C diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h index ebc4355bd1..c458c1aa37 100644 --- a/tools/libxc/xc_sr_common_x86.h +++ b/tools/libxc/xc_sr_common_x86.h @@ -14,6 +14,20 @@ int write_x86_tsc_info(struct xc_sr_context *ctx); */ int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *re= c); =20 +/* + * Parses an X86_CPUID_POLICY record and stashes the content for applicati= on + * when a STATIC_DATA_END record is encountered. + */ +int handle_x86_cpuid_policy(struct xc_sr_context *ctx, + struct xc_sr_record *rec); + +/* + * Parses an X86_MSR_POLICY record and stashes the content for application + * when a STATIC_DATA_END record is encountered. + */ +int handle_x86_msr_policy(struct xc_sr_context *ctx, + struct xc_sr_record *rec); + #endif /* * Local variables: diff --git a/tools/libxc/xc_sr_restore_x86_hvm.c b/tools/libxc/xc_sr_restor= e_x86_hvm.c index 3f78248f32..cef99e0397 100644 --- a/tools/libxc/xc_sr_restore_x86_hvm.c +++ b/tools/libxc/xc_sr_restore_x86_hvm.c @@ -171,6 +171,12 @@ static int x86_hvm_process_record(struct xc_sr_context= *ctx, case REC_TYPE_HVM_PARAMS: return handle_hvm_params(ctx, rec); =20 + case REC_TYPE_X86_CPUID_POLICY: + return handle_x86_cpuid_policy(ctx, rec); + + case REC_TYPE_X86_MSR_POLICY: + return handle_x86_msr_policy(ctx, rec); + default: return RECORD_NOT_PROCESSED; } @@ -227,6 +233,9 @@ static int x86_hvm_cleanup(struct xc_sr_context *ctx) { free(ctx->x86.hvm.restore.context.ptr); =20 + free(ctx->x86.restore.cpuid.ptr); + free(ctx->x86.restore.msr.ptr); + return 0; } =20 diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore= _x86_pv.c index 3756225be6..3aac4bd502 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -1102,6 +1102,12 @@ static int x86_pv_process_record(struct xc_sr_contex= t *ctx, case REC_TYPE_X86_TSC_INFO: return handle_x86_tsc_info(ctx, rec); =20 + case REC_TYPE_X86_CPUID_POLICY: + return handle_x86_cpuid_policy(ctx, rec); + + case REC_TYPE_X86_MSR_POLICY: + return handle_x86_msr_policy(ctx, rec); + default: return RECORD_NOT_PROCESSED; } @@ -1173,6 +1179,9 @@ static int x86_pv_cleanup(struct xc_sr_context *ctx) if ( ctx->x86.pv.m2p ) munmap(ctx->x86.pv.m2p, ctx->x86.pv.nr_m2p_frames * PAGE_SIZE); =20 + free(ctx->x86.restore.cpuid.ptr); + free(ctx->x86.restore.msr.ptr); + return 0; } =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136095672124.62650819733608; Mon, 27 Jan 2020 06:41:35 -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 1iw5ZZ-0003Ie-KY; Mon, 27 Jan 2020 14:41:05 +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.89) (envelope-from ) id 1iw5ZY-0003Hh-MX for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:41:04 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 090e335d-4113-11ea-855d-12813bfff9fa; Mon, 27 Jan 2020 14:41:01 +0000 (UTC) X-Inumbo-ID: 090e335d-4113-11ea-855d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=gPYmytoJCiIil7BIfCHPDEH0I2F9VWQYPFwp/5YfzGQ=; b=XD2Vx4QL+99jZIRoTQEo2i+zAzSRaNJ6PuAQaS3ll2Bqs10Af2C5JtB3 cIRXJk5XurpEVg/Yq6a+DIIcEwROxMCsE5IRCX8UeOs/DtAhuZWKr+anl EkLtxJKRqbr03acpJ55FIlZoBomRF58FQeDz2P7CluFsRLLdQqPbCYOs+ 8=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: P+khazJWuKPgOKI0jEBz4RTB1+ykFeNrQROppQ29fqfrhkqxvxH3vsSQxkeDOP76258QZ77jtH 3ln0C8TrT7MICeRBn/PIa8UR0VjblLZXKVnaLUxag7QFsFheMNqVc0vGbqWEMqvxZ5VW/0woup +THHBoxDLvRpqEQGrbi2QAV2z1uIxXgznFA2OeVngXqGNIu0GlBOksT4Hz0Gd7IEc5W5olh1np uCZEKsHNzQzkg0C/lkADL0c7RFRx7WVskBn1UKl+9zWNh9M5hFrhDUOYYxfn/fgYj9OvuS+boK jbI= X-SBRS: 2.7 X-MesageID: 12093220 X-Ironport-Server: esa4.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="12093220" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:41 +0000 Message-ID: <20200127143444.25538-15-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 14/17] libxc/save: Write X86_{CPUID, MSR}_DATA records 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) With all other plumbing in place, obtain the CPU Policy from Xen and write it into the migration stream. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_common_x86.c | 50 ++++++++++++++++++++++++++++++++++++= ++++ tools/libxc/xc_sr_common_x86.h | 6 +++++ tools/libxc/xc_sr_save_x86_hvm.c | 2 +- tools/libxc/xc_sr_save_x86_pv.c | 12 +++++++++- 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 8980299e9a..6267655dab 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -42,6 +42,56 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struc= t xc_sr_record *rec) return 0; } =20 +int write_x86_cpu_policy_records(struct xc_sr_context *ctx) +{ + xc_interface *xch =3D ctx->xch; + struct xc_sr_record cpuid =3D { .type =3D REC_TYPE_X86_CPUID_POLICY, }; + struct xc_sr_record msrs =3D { .type =3D REC_TYPE_X86_MSR_POLICY, }; + uint32_t nr_leaves =3D 0, nr_msrs =3D 0; + int rc; + + if ( xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs) < 0 ) + { + PERROR("Unable to get CPU Policy size"); + return -1; + } + + cpuid.data =3D malloc(nr_leaves * sizeof(xen_cpuid_leaf_t)); + msrs.data =3D malloc(nr_msrs * sizeof(xen_msr_entry_t)); + if ( !cpuid.data || !msrs.data ) + { + ERROR("Cannot allocate memory for CPU Policy"); + rc =3D -1; + goto out; + } + + if ( xc_get_domain_cpu_policy(xch, ctx->domid, &nr_leaves, cpuid.data, + &nr_msrs, msrs.data) ) + { + PERROR("Unable to get d%d CPU Policy", ctx->domid); + rc =3D -1; + goto out; + } + + cpuid.length =3D nr_leaves * sizeof(xen_cpuid_leaf_t); + if ( cpuid.length ) + { + rc =3D write_record(ctx, &cpuid); + if ( rc ) + goto out; + } + + msrs.length =3D nr_msrs * sizeof(xen_msr_entry_t); + if ( msrs.length ) + rc =3D write_record(ctx, &msrs); + + out: + free(cpuid.data); + free(msrs.data); + + return rc; +} + int handle_x86_cpuid_policy(struct xc_sr_context *ctx, struct xc_sr_record= *rec) { xc_interface *xch =3D ctx->xch; diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h index c458c1aa37..d1050981dd 100644 --- a/tools/libxc/xc_sr_common_x86.h +++ b/tools/libxc/xc_sr_common_x86.h @@ -15,6 +15,12 @@ int write_x86_tsc_info(struct xc_sr_context *ctx); int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *re= c); =20 /* + * Obtains a domains CPU Policy from Xen, and writes X86_{CPUID,MSR}_POLICY + * records into the stream. + */ +int write_x86_cpu_policy_records(struct xc_sr_context *ctx); + +/* * Parses an X86_CPUID_POLICY record and stashes the content for applicati= on * when a STATIC_DATA_END record is encountered. */ diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_= hvm.c index 93bcc1c273..acf9264dec 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -172,7 +172,7 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) =20 static int x86_hvm_static_data(struct xc_sr_context *ctx) { - return 0; + return write_x86_cpu_policy_records(ctx); } =20 static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_p= v.c index 46019d962d..c7e246ef4f 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -1054,7 +1054,17 @@ static int x86_pv_setup(struct xc_sr_context *ctx) =20 static int x86_pv_static_data(struct xc_sr_context *ctx) { - return write_x86_pv_info(ctx); + int rc; + + rc =3D write_x86_pv_info(ctx); + if ( rc ) + return rc; + + rc =3D write_x86_cpu_policy_records(ctx); + if ( rc ) + return rc; + + return 0; } =20 static int x86_pv_start_of_stream(struct xc_sr_context *ctx) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136098045473.02371377120085; Mon, 27 Jan 2020 06:41:38 -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 1iw5ZX-0003Fi-0k; Mon, 27 Jan 2020 14:41:03 +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.89) (envelope-from ) id 1iw5ZV-0003Ee-IY for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:41:01 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 090e335c-4113-11ea-855d-12813bfff9fa; Mon, 27 Jan 2020 14:41:00 +0000 (UTC) X-Inumbo-ID: 090e335c-4113-11ea-855d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UNm4zczGTkV6kuIslxpw7OwaP9zsTScDkSBhFsLwK+k=; b=DvtpZI/qcssvtjiiIW8J9uwGqIwoZkpaE3cOYAqdrwcib3xE4H3ZWrY9 +txN7pbX8M4uGUG5e7N6HinNQ13R/5a1QSlIfEuqDIk6b5P12UBZ9GWUo VGEP3+RPUlzs6jzbDX9o6h2mqwqjnYRl6li6YwbS/v/nXnAc3cXoc1hPc Y=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Cbo4zisRT1ImK31wSjt/X7yFLMCHfc+COFa0Eq3+BIiEhdIv++cX7DvUUbVsqmguc50jmK6gpZ KBZVUXK6izi5l50T7lk9T8iaXvUIcpKiW0bdwAlb3t42DWsIQoSUYLcc9jf1/9gfh8m1JoGGp/ bFRb3k4RlLKa9C0R1Gsn89cNstuJjwe6V4iIoQyj2jBLp/T7eJZ1xEcEop2XP8ultozXF4ctgy J/GoYMl2OhNk2VBl4qq9yQbRePeSHqtBo2gfU3Ki2WAvn6Cs3Cti3ByRnA90NsJDhHT0MbJYHs i9Y= X-SBRS: 2.7 X-MesageID: 12093218 X-Ironport-Server: esa4.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="12093218" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:42 +0000 Message-ID: <20200127143444.25538-16-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 15/17] tools/libx[cl]: Plumb 'missing' through static_data_done() up into libxl 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: Anthony PERARD , 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) Pre Xen-4.14 streams will not contain any CPUID/MSR information. There is nothing libxc can do about this, and will have to rely on the higher level toolstack to provide backwards compatibility. To facilitate this, extend the static_data_done() callback, highlighting the missing information, and modify libxl to use it. At the libxc level, this requires an arch-specific hook which, for now, always reports CPUID and MSR= as missing. This will be adjusted in a later change. No overall functional change - this is just plumbing. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD v2: * Split/rearrange from v1 * Don't re-evalute 'k' on migrate --- tools/libxc/include/xenguest.h | 12 ++++++++++-- tools/libxc/xc_sr_common.h | 9 +++++++++ tools/libxc/xc_sr_common_x86.c | 8 ++++++++ tools/libxc/xc_sr_common_x86.h | 5 +++++ tools/libxc/xc_sr_restore.c | 7 ++++++- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + tools/libxc/xc_sr_restore_x86_pv.c | 1 + tools/libxl/libxl_create.c | 18 ++++++++++++++---- tools/libxl/libxl_save_msgs_gen.pl | 2 +- 9 files changed, 55 insertions(+), 8 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index b4df8d0ffe..7a12d21ff2 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -139,8 +139,16 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint3= 2_t dom, =20 /* callbacks provided by xc_domain_restore */ struct restore_callbacks { - /* Called once the STATIC_DATA_END record has been received/inferred. = */ - int (*static_data_done)(void *data); + /* + * Called once the STATIC_DATA_END record has been received/inferred. + * + * For compatibility with older streams, provides a list of static data + * expected to be found in the stream, which was missing. A higher le= vel + * toolstack is responsible for providing any necessary compatibiltiy. + */ +#define XGR_SDD_MISSING_CPUID (1 << 0) +#define XGR_SDD_MISSING_MSR (1 << 1) + int (*static_data_done)(unsigned int missing, void *data); =20 /* Called after a new checkpoint to suspend the guest. */ int (*suspend)(void *data); diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index 7742260690..f3bdea8006 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -159,6 +159,15 @@ struct xc_sr_restore_ops int (*process_record)(struct xc_sr_context *ctx, struct xc_sr_record *= rec); =20 /** + * Perform any actions required after the static data has arrived. Ca= lled + * when the STATIC_DATA_COMPLETE record has been recieved/inferred. + * 'missing' should be filled in for any data item the higher level + * toolstack needs to provide compatiblity for. + */ + int (*static_data_complete)(struct xc_sr_context *ctx, + unsigned int *missing); + + /** * Perform any actions required after the stream has been finished. Ca= lled * after the END record has been received. */ diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 6267655dab..a849891634 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -132,6 +132,14 @@ int handle_x86_msr_policy(struct xc_sr_context *ctx, s= truct xc_sr_record *rec) return rc; } =20 +int x86_static_data_complete(struct xc_sr_context *ctx, unsigned int *miss= ing) +{ + /* TODO: Become conditional on there being no data in the stream. */ + *missing =3D XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; + + return 0; +} + /* * Local variables: * mode: C diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h index d1050981dd..e08d81e0e7 100644 --- a/tools/libxc/xc_sr_common_x86.h +++ b/tools/libxc/xc_sr_common_x86.h @@ -34,6 +34,11 @@ int handle_x86_cpuid_policy(struct xc_sr_context *ctx, int handle_x86_msr_policy(struct xc_sr_context *ctx, struct xc_sr_record *rec); =20 +/* + * Perform common x86 actions required after the static data has arrived. + */ +int x86_static_data_complete(struct xc_sr_context *ctx, unsigned int *miss= ing); + #endif /* * Local variables: diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index bb94cd879d..bc811e6e3a 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -659,6 +659,7 @@ static int buffer_record(struct xc_sr_context *ctx, str= uct xc_sr_record *rec) int handle_static_data_end(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; + unsigned int missing =3D 0; int rc =3D 0; =20 if ( ctx->restore.seen_static_data_end ) @@ -669,9 +670,13 @@ int handle_static_data_end(struct xc_sr_context *ctx) =20 ctx->restore.seen_static_data_end =3D true; =20 + rc =3D ctx->restore.ops.static_data_complete(ctx, &missing); + if ( rc ) + return rc; + if ( ctx->restore.callbacks->static_data_done && (rc =3D ctx->restore.callbacks->static_data_done( - ctx->restore.callbacks->data) !=3D 0) ) + missing, ctx->restore.callbacks->data) !=3D 0) ) ERROR("static_data_done() callback failed: %d\n", rc); =20 return rc; diff --git a/tools/libxc/xc_sr_restore_x86_hvm.c b/tools/libxc/xc_sr_restor= e_x86_hvm.c index cef99e0397..9190edaee7 100644 --- a/tools/libxc/xc_sr_restore_x86_hvm.c +++ b/tools/libxc/xc_sr_restore_x86_hvm.c @@ -248,6 +248,7 @@ struct xc_sr_restore_ops restore_ops_x86_hvm =3D .localise_page =3D x86_hvm_localise_page, .setup =3D x86_hvm_setup, .process_record =3D x86_hvm_process_record, + .static_data_complete =3D x86_static_data_complete, .stream_complete =3D x86_hvm_stream_complete, .cleanup =3D x86_hvm_cleanup, }; diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore= _x86_pv.c index 3aac4bd502..1252cd1310 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -1194,6 +1194,7 @@ struct xc_sr_restore_ops restore_ops_x86_pv =3D .localise_page =3D x86_pv_localise_page, .setup =3D x86_pv_setup, .process_record =3D x86_pv_process_record, + .static_data_complete =3D x86_static_data_complete, .stream_complete =3D x86_pv_stream_complete, .cleanup =3D x86_pv_cleanup, }; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 09f84858d5..1d54cdc429 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1298,7 +1298,8 @@ static void libxl__colo_restore_setup_done(libxl__egc= *egc, libxl__stream_read_start(egc, &dcs->srs); } =20 -int libxl__srm_callout_callback_static_data_done(void *user) +int libxl__srm_callout_callback_static_data_done(unsigned int missing, + void *user) { libxl__save_helper_state *shs =3D user; libxl__domain_create_state *dcs =3D shs->caller_state; @@ -1308,9 +1309,18 @@ int libxl__srm_callout_callback_static_data_done(voi= d *user) const libxl_domain_config *d_config =3D dcs->guest_config; const libxl_domain_build_info *info =3D &d_config->b_info; =20 - libxl__cpuid_apply_policy(ctx, dcs->guest_domid); - if (info->cpuid !=3D NULL) - libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid); + /* + * CPUID/MSR information is not present in pre Xen-4.14 streams. + * + * Libxl used to always regenerate the CPUID policy from first princip= les + * on migrate. Continue to do so for backwards compatibility when the + * stream doesn't contain any CPUID data. + */ + if (missing & XGR_SDD_MISSING_CPUID) { + libxl__cpuid_apply_policy(ctx, dcs->guest_domid); + if (info->cpuid !=3D NULL) + libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid); + } =20 return 0; } diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_ms= gs_gen.pl index 93dc252370..5bfbd4fd10 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -29,7 +29,7 @@ our @msgs =3D ( [ 'srcxA', "wait_checkpoint", [] ], [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid unsigned enable)] ], - [ 'rcxW', "static_data_done", [] ], + [ 'rcxW', "static_data_done", [qw(unsigned missing)] ], [ 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', 'xen_pfn_t', 'console_gfn'] ], [ 'srW', "complete", [qw(int retval --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 1580136095039723.9447633178994; Mon, 27 Jan 2020 06:41:35 -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 1iw5ZW-0003FH-KY; Mon, 27 Jan 2020 14:41:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5ZV-0003EQ-21 for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:41:01 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 08733c9e-4113-11ea-aecd-bc764e2007e4; Mon, 27 Jan 2020 14:40:59 +0000 (UTC) X-Inumbo-ID: 08733c9e-4113-11ea-aecd-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lxptjlj048jFo1TZ9LyVIlXTZTWDMEbkHr8vGwFVWNg=; b=QNaJsMNitgmcH7Ot+yOOrBXZXgz9Jc0in8oZxsVpqHocT4jzHaszVlLE jEEcp9nNFwrzlxCGDH0TiORcp26aU0++6IG9c1s7beLtYm6QTZjVCefE6 +SuELYQ/c4YRmjY1fG+4rRWY+Xm53IO3bnYkFN36hHxETc4c/lpaQUEAi s=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: oXzaRxdCI02X1cK9/EbsP11aVANGkgCdNa7QuodbgXb5G2sOj4YYKeLtKt/3NYGEoerEfMfzGg rqWqpOc68f35SPndDt2gKLaul0kFNWxbK+K6yjt40ncg6PPerONjD0qkABil9SHkZOWz7HfVF7 VXqIp+58GvUOcNta9gbywVYAPaC+I0k2HVj699etbbcVj7IwtibDFVihUZs9YReuiI6w50n/D/ 4QKzUOw+DcKmG9qt4eVXPQJ9HlP//RsJnOXBBpdFF740tDoNG59isTry0m8Q5RR3L9VB8j7WGs lBM= X-SBRS: 2.7 X-MesageID: 11860148 X-Ironport-Server: esa5.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="11860148" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:43 +0000 Message-ID: <20200127143444.25538-17-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 16/17] tools/libxc: Restore CPUID/MSR data found in the migration stream 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 , Ian Jackson , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= 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) With all other pieces in place, it is now safe to restore the CPUID and MSR data in the migration stream, rather than discarding them and using the hig= her level toolstacks compatibility logic. While this is a small patch, it has large implications for migrated/resumed domains. Most obviously, the CPU family/model/stepping data, cache/tlb/etc. will no longer change behind the guests back. Another change is the interpretation of the Xend cpuid strings. The 'k' option is not a sensible thing to have ever supported, and 's' is how how t= he stream will end up behaving. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_cpuid_x86.c | 8 ++++---- tools/libxc/xc_sr_common_x86.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index ac38c1406e..c78d00bbc3 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -291,10 +291,9 @@ int xc_set_domain_cpu_policy(xc_interface *xch, uint32= _t domid, * '0' -> force to 0 * 'x' -> we don't care (use default) * 'k' -> pass through host value - * 's' -> pass through the first time and then keep the same value - * across save/restore and migration. + * 's' -> legacy alias for 'k' * - * For 's' and 'x' the configuration is overwritten with the value applied. + * In all cases, the returned string consists of just '0' and '1'. */ int xc_cpuid_set( xc_interface *xch, uint32_t domid, const unsigned int *input, @@ -420,7 +419,8 @@ int xc_cpuid_set( clear_feature(31 - j, regs[i]); =20 config_transformed[i][j] =3D config[i][j]; - if ( config[i][j] =3D=3D 's' ) + /* All non 0/1 values get overwritten. */ + if ( (config[i][j] & ~1) !=3D '0' ) config_transformed[i][j] =3D '0' + val; } } diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index a849891634..77ea044a74 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -134,8 +134,30 @@ int handle_x86_msr_policy(struct xc_sr_context *ctx, s= truct xc_sr_record *rec) =20 int x86_static_data_complete(struct xc_sr_context *ctx, unsigned int *miss= ing) { - /* TODO: Become conditional on there being no data in the stream. */ - *missing =3D XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; + xc_interface *xch =3D ctx->xch; + uint32_t nr_leaves =3D 0, nr_msrs =3D 0; + uint32_t err_l =3D ~0, err_s =3D ~0, err_m =3D ~0; + + if ( ctx->x86.restore.cpuid.ptr ) + nr_leaves =3D ctx->x86.restore.cpuid.size / sizeof(xen_cpuid_leaf_= t); + else + *missing |=3D XGR_SDD_MISSING_CPUID; + + if ( ctx->x86.restore.msr.ptr ) + nr_msrs =3D ctx->x86.restore.msr.size / sizeof(xen_msr_entry_t); + else + *missing |=3D XGR_SDD_MISSING_MSR; + + if ( (nr_leaves || nr_msrs) && + xc_set_domain_cpu_policy(xch, ctx->domid, + nr_leaves, ctx->x86.restore.cpuid.ptr, + nr_msrs, ctx->x86.restore.msr.ptr, + &err_l, &err_s, &err_m) ) + { + PERROR("Failed to set CPUID policy: leaf %08x, subleaf %08x, msr %= 08x", + err_l, err_s, err_m); + return -1; + } =20 return 0; } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 01:42:20 2024 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 158013608718914.905907113739772; Mon, 27 Jan 2020 06:41:27 -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 1iw5ZL-000386-2A; Mon, 27 Jan 2020 14:40:51 +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.89) (envelope-from ) id 1iw5ZK-00037v-8f for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:40:50 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 026bb376-4113-11ea-855d-12813bfff9fa; Mon, 27 Jan 2020 14:40:49 +0000 (UTC) X-Inumbo-ID: 026bb376-4113-11ea-855d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=KxBZdLUfu5p+vxv/yMA6EcE+zysbJli0udL61VhwHJY=; b=R8c4eYbTA7g8IktHVWFX97zTfoQVWvjpNozoaGmZAP6xkgXRWFa6ZIUi u3Ebx7YfI1nM0BSU6aaNrROitkdnLYL0PjTR3RMdr4FDnxpS3dmFJOXtB ImyeQ443bmtCqDcJQFZnmGU5QbPnC2FeqIFYdb91E5BqpqOeuqIcurU2M A=; 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: W8sA4/Sy3VixmI5FXI8s+GOSPsedtPbPZsQE/Vueks4Nqaz54KIOI9Eh3uYrfJPb8lweGqqpyV es1yP0T7t3aHPIC6APMAp+u+Sw9ra+BhpCvWzlAI1ZFCQNBeF9dTPXjqM6AOiNv5vfkgiUWlHh wKrRHBgZmiYQpPvkf7YyOAjJjuSvmDTBJlfcjT9d1tYRD93bIEZc9Asjj7Iedj8SjoZKkMAwga NoJvQfdpgbDS46ed4A7XtcuP0DYEhK+TQKnt1pHcyM1mUj+qacDMYSlUQuwIgbIt6v5W6mlim2 22E= X-SBRS: 2.7 X-MesageID: 11665349 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="11665349" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:44 +0000 Message-ID: <20200127143444.25538-18-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 17/17] docs/xl.cfg: Rewrite cpuid= section 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: Anthony PERARD , 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) This is partly to adjust the description of 'k' and 's' seeing as they have changed, but mostly restructuring the information for clarity. In particular, use indentation to clearly separate the areas discussing lib= xl format from xend format. In addition, extend the xend format section to discuss subleaf notation. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD v2: * New --- docs/man/xl.cfg.5.pod.in | 74 ++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 245d3f9472..1da68c4a07 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1964,26 +1964,42 @@ This option is disabled by default. Configure the value returned when a guest executes the CPUID instruction. Two versions of config syntax are recognized: libxl and xend. =20 -The libxl syntax is a comma separated list of key=3Dvalue pairs, preceded = by the -word "host". A few keys take a numerical value, all others take a single -character which describes what to do with the feature bit. - -Possible values for a single feature bit: +Both formats use a common notation for specifying a single feature bit. +Possible values are: '1' -> force the corresponding bit to 1 '0' -> force to 0 'x' -> Get a safe value (pass through and mask with the default policy) - 'k' -> pass through the host bit value - 's' -> as 'k' but preserve across save/restore and migration (not implem= ented) + 'k' -> pass through the host bit value (at boot only - value preserved o= n migrate) + 's' -> legacy alias for 'k' =20 -Note: when specifying B for hypervisor leaves (0x4000xxxx major gro= up) -only the lowest 8 bits of leaf's 0x4000xx00 EAX register are processed, the -rest are ignored (these 8 bits signify maximum number of hypervisor leaves= ). +B: + +=3Dover 4 + +The libxl format is a single string, starting with the word "host", and +followed by a comma separated list of key=3Dvalue pairs. A few keys take a +numerical value, all others take a single character which describes what t= o do +with the feature bit. e.g.: + +=3Dover 4 + +cpuid=3D"host,tm=3D0,sse3=3D0" + +=3Dback =20 List of keys taking a value: + +=3Dover 4 + apicidsize brandid clflush family localapicid maxleaf maxhvleaf model nc proccount procpkg stepping =20 +=3Dback + List of keys taking a character: + +=3Dover 4 + 3dnow 3dnowext 3dnowprefetch abm acpi adx aes altmovcr8 apic arat avx avx2 avx512-4fmaps avx512-4vnniw avx512bw avx512cd avx512dq avx512er avx512f avx512ifma avx512pf avx512vbmi avx512vl bmi1 bmi2 clflushopt clfsh clwb cm= ov @@ -1997,21 +2013,37 @@ ssse3 svm svm_decode svm_lbrv svm_npt svm_nrips svm= _pausefilt svm_tscrate svm_vmcbclean syscall sysenter tbm tm tm2 topoext tsc tsc-deadline tsc_adj= ust umip vme vmx wdt x2apic xop xsave xtpr =20 +=3Dback + +=3Dback + +B: =20 -The xend syntax is a list of values in the form of -'leafnum:register=3Dbitstring,register=3Dbitstring' - "leafnum" is the requested function, - "register" is the response register to modify - "bitstring" represents all bits in the register, its length must be 32 c= hars. - Each successive character represent a lesser-significant bit, possible v= alues - are listed above in the libxl section. +=3Dover 4 =20 -Example to hide two features from the guest: 'tm', which is bit #29 in EDX= , and -'pni' (SSE3), which is bit #0 in ECX: +Xend format consists of an array of one or more strings of the form +"leaf:reg=3Dbitstring,...". e.g. (matching the libxl example above): =20 -xend: [ "1:ecx=3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,edx=3Dxx0xxxxxxxxxxxxxxx= xxxxxxxxxxxxxx" ] +=3Dover 4 =20 -libxl: "host,tm=3D0,sse3=3D0" +cpuid=3D["1:ecx=3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0,edx=3Dxx0xxxxxxxxxxxxxx= xxxxxxxxxxxxxxx", ...] + +=3Dback + +"leaf" is an integer, either decimal or hex with a "0x" prefix. e.g. to +specify something in the AMD feature leaves, use "0x80000001:ecx=3D...". + +Some leaves have subleaves which can be specified as "leaf,subleaf". e.g.= for +the Intel structured feature leaf, use "7,0:ebx=3D..." + +The bitstring represents all bits in the register, its length must be 32 +chars. Each successive character represent a lesser-significant bit. + +=3Dback + +Note: when specifying B for hypervisor leaves (0x4000xxxx major gro= up) +only the lowest 8 bits of leaf's 0x4000xx00 EAX register are processed, the +rest are ignored (these 8 bits signify maximum number of hypervisor leaves= ). =20 More info about the CPUID instruction can be found in the processor manual= s, and on Wikipedia: L --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel