From patchwork Fri Jan 3 13:06:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C78EC138D for ; Fri, 3 Jan 2020 13:07:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A48E420866 for ; Fri, 3 Jan 2020 13:07:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="JA/eem2l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A48E420866 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMfI-0004B2-RS; Fri, 03 Jan 2020 13:06: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 1inMfH-0004AN-8i for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:55 +0000 X-Inumbo-ID: e56956bc-2e29-11ea-88e7-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e56956bc-2e29-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 13:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=p5FEpdaxz96h2yAh0G89UJzZg2BFVDzVF56s4ViHgDc=; b=JA/eem2luti+Uw/Dn/sXFr49/kjxcj9jQnWeVnmVb64UyvFdNgLsbiak ywzKjjZekwmYA9qeA9LKsfvy436LQHo2P7IDcUQKcyFoHXBL/Hd7qMGOR y4qqdTS1ijaW+t+jy8ASGpmnfYFD7EcNnPYpsW0/9hXwTVMmZe70kmHw3 s=; 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 (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: fKMR6Q9Bbwn+2k8260f4loJiGkMiARZ7eBUq7skpyvCMQTHuxba/KmIKA5m2zE4j5mEP+yMxyx 7f0GoLmUJn7noBJcS6NGxT835NcJxCZzesC5QFwihWaTpfVei/VlIblX5W4oB3CdJAxa+rR6Gs MGQJrIZ/2VP1kkCYzy1W/SYGUTlle1UHMA68Aa1TYW5mrgnkBmckJ1PAbgoDh/zDeU/JOVEdd6 25ye6Bm7eRV76/LKpVvKtTk0htHL42h7Yj7hJlCWjrZ7IBduPzaWZjSuM1HhmqeDyXj5c02R6I N94= X-SBRS: 2.7 X-MesageID: 10435308 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.69,390,1571716800"; d="scan'208";a="10435308" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:16 +0000 Message-ID: <20200103130616.13724-7-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 20/20] 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 , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With libxl suitably adjusted, it is now safe to restore the CPUID/MSR data directly from the migration stream. Adjust the XGR_SDD_MISSING_* flags for the static_data_done() callback appropriately. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_common_x86.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index c3d1d30d91..5c5b3e7635 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -45,11 +45,31 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) int x86_static_data_complete(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; + uint32_t nr_leaves = 0, nr_msrs = 0; + uint32_t err_l = ~0, err_s = ~0, err_m = ~0; unsigned int missing = 0; int rc; - /* TODO - something useful. */ - missing = XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; + if ( ctx->x86.restore.cpuid.ptr ) + nr_leaves = ctx->x86.restore.cpuid.size / sizeof(xen_cpuid_leaf_t); + else + missing |= XGR_SDD_MISSING_CPUID; + + if ( ctx->x86.restore.msr.ptr ) + nr_msrs = ctx->x86.restore.msr.size / sizeof(xen_msr_entry_t); + else + missing |= 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; + } rc = ctx->restore.callbacks->static_data_done( missing, ctx->restore.callbacks->data);