From patchwork Wed Feb 5 16:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11366633 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 9A9BC1395 for ; Wed, 5 Feb 2020 16:52:07 +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 775EF20674 for ; Wed, 5 Feb 2020 16:52:07 +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="iNOM7RxG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 775EF20674 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 1izNtM-0000Pn-VL; Wed, 05 Feb 2020 16:51:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1izNtL-0000PZ-MT for xen-devel@lists.xenproject.org; Wed, 05 Feb 2020 16:51:07 +0000 X-Inumbo-ID: b17c133a-4837-11ea-8396-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b17c133a-4837-11ea-8396-bc764e2007e4; Wed, 05 Feb 2020 16:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580921463; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=w7ytyD/TCLp1VDxBKjEYmlzN9beHNXWINcG+VlSltN0=; b=iNOM7RxGJyLYTQ3UMs+3yrWasZI5pbcsNgPWlQoRTOoTEytjNV5efQZi Rka6krRF0zKZxB48GTLi5qCVm62rlkr2HfTlOHhkpxqZJmhyyoafmeTAd hzhamFJw/uKQZFOY/8ymXeOHwqeE+t11aqzJBp/tvGknvppONl6Xy+NV3 E=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: eU4oycvXqixxpKEP6blaTpC76iUyO9TQajsL+z/+6ofiAQ/gAvaOq5bGEBR8Ylt9OJIUK76DXE vVXjD/rvg5oAZJbp6iNdOFcrDZBJd0R4lwzAoFxTqe3P+MQg0lMzNsPHw1ME0j1CWdX2jshYv8 yGhJ1Q1dPDpSvFbLwZh6/y/w7et9OKO3ks6eEestgW+q5FAL8hJZgdnssGInqnA4CsmJ85RAZ7 eKh6cHtdAZL8FTZGrJIbHwYkSBgsN50bZGkNE1jf7ajlfCVgbU1rkLgDsUXqhC3nFePwrHdLQH 8fY= X-SBRS: 2.7 X-MesageID: 11991643 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,406,1574139600"; d="scan'208";a="11991643" From: Andrew Cooper To: Xen-devel Date: Wed, 5 Feb 2020 16:50:54 +0000 Message-ID: <20200205165056.11734-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200205165056.11734-1-andrew.cooper3@citrix.com> References: <20200205165056.11734-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/6] tools/libxl: Combine legacy CPUID handling logic 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" While we are in the process of overhauling boot time CPUID/MSR handling, the existing logic is going to have to remain in roughly this form for backwards compatibility. Fold libxl__cpuid_apply_policy() and libxl__cpuid_set() together into a single libxl__cpuid_legacy() to reduce the complexity for callers. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxl/libxl_cpuid.c | 15 ++++++++------- tools/libxl/libxl_dom.c | 4 +--- tools/libxl/libxl_internal.h | 5 ++--- tools/libxl/libxl_nocpuid.c | 8 ++------ 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c index 505ec1b048..49d3ca5b26 100644 --- a/tools/libxl/libxl_cpuid.c +++ b/tools/libxl/libxl_cpuid.c @@ -410,17 +410,18 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid, return 0; } -void libxl__cpuid_apply_policy(libxl_ctx *ctx, uint32_t domid) -{ - xc_cpuid_apply_policy(ctx->xch, domid, NULL, 0); -} - -void libxl__cpuid_set(libxl_ctx *ctx, uint32_t domid, - libxl_cpuid_policy_list cpuid) +void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, + libxl_domain_build_info *info) { + libxl_cpuid_policy_list cpuid = info->cpuid; int i; char *cpuid_res[4]; + xc_cpuid_apply_policy(ctx->xch, domid, NULL, 0); + + if (!cpuid) + return; + for (i = 0; cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) xc_cpuid_set(ctx->xch, domid, cpuid[i].input, (const char**)(cpuid[i].policy), cpuid_res); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index bbb1be75ba..71cb578923 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -454,9 +454,7 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, if (rc) return rc; - libxl__cpuid_apply_policy(ctx, domid); - if (info->cpuid != NULL) - libxl__cpuid_set(ctx, domid, info->cpuid); + libxl__cpuid_legacy(ctx, domid, info); if (info->type == 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 164d93b89b..4936446069 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2056,9 +2056,8 @@ struct libxl__cpuid_policy { char *policy[4]; }; -_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); +_hidden void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, + libxl_domain_build_info *info); /* Calls poll() again - useful to check whether a signaled condition * is still true. Cannot fail. Returns currently-true revents. */ diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libxl/libxl_nocpuid.c index a39babe754..7776574a0c 100644 --- a/tools/libxl/libxl_nocpuid.c +++ b/tools/libxl/libxl_nocpuid.c @@ -34,12 +34,8 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid, return 0; } -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) +void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, + libxl_domain_config *d_config) { }