From nobody Mon Feb 9 19:42:22 2026 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