From nobody Mon Feb 9 21:21:49 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1568403048; cv=none; d=zoho.com; s=zohoarc; b=WXa0+8mcgwPFjVud0/Hf8GEmlTA9QdmHqYTQ6ItP/kKr4YlNiPvrTnougH86eJjC2txJwbqE86NxN0ZxVfJvd22wqyBG1QE16V0Sx6AB0wrqxodGKWTeqYRtfmPYemghqSNXWtZSy6VGjZJcAC8Nzy+XZwza9F31vp9rUYRCQTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568403048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fdXcgX9AkJ6edP2yao4NSz5jP76ZfHIpcHS6/ZFGRN4=; b=KizJJsdtCg3quAmVOQJ4a8O8bmeZxF0bntAfN9U9OfAJjAVsHQu8b3nCKrW6xiQHlz+fcFP+nViYNMQ1cx0LZ+zQiATyTwRb9ixsoytS/r3B+3BgvBe7ejFv54ikJCawZtSk/KO7cXsXfjFgIke4AgVSNxniHWZH+OWXX6SBqWg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1568403048196580.3740278358715; Fri, 13 Sep 2019 12:30:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i8rF4-0006uY-On; Fri, 13 Sep 2019 19:28:26 +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 1i8rF4-0006uD-5r for xen-devel@lists.xenproject.org; Fri, 13 Sep 2019 19:28:26 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9e8fe85d-d65c-11e9-95b9-12813bfff9fa; Fri, 13 Sep 2019 19:28:10 +0000 (UTC) X-Inumbo-ID: 9e8fe85d-d65c-11e9-95b9-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568402890; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/upZBzGAszcwIpyuQpeTBNr65pTRgh7FR1YW/jSBUGQ=; b=AQztp1ba922OoAgxQQx2+Bnx+PxssqJQhDbNw7T+yTl1+YvfUy3amO4E ymxRGGk7tqmB2NY0QMpfk1lkOtEDZilVj7VvobdvDsJ+QabCoJ+wot5qK JGzLrLoszo1Pe8iIxmVg0BWPs3758S8zHXuVAOyCGq7Z420ONjonXdGB5 w=; 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 (zoho.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 ~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: Ci7k6c0lS09hF1NJvcVfiHB4szfMArsf6lPR7cg3ZEpIiHn6b3sJers+Sl+liUFZbiI/kMRL3l T56rOkp0Q3InVBo0F4GqM3ZxxKFmvCrvFIUYSHj6H2pn4aXqgfrU4TGEXPOtsBMZFjEhVd4+9P A5KhrOGk/VyOw2J5VB4v0nx0WWvyY+8TLiX3dWZQU3nB1SW5PJD7BL1DFeSIt0cza6KYPkcbLV L/3wDIrfXEBQzM0oW6z2YqaHsGEZCAkZEE413kTgXr9EH0jVGv+LzINU5H+j9eR5jhczPe6w9+ ye0= X-SBRS: 2.7 X-MesageID: 5754526 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.64,501,1559534400"; d="scan'208";a="5754526" From: Andrew Cooper To: Xen-devel Date: Fri, 13 Sep 2019 20:27:55 +0100 Message-ID: <20190913192759.10795-7-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190913192759.10795-1-andrew.cooper3@citrix.com> References: <20190913192759.10795-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 06/10] tools/libxc: Pre-cleanup for xc_cpuid_{set, apply_policy}() 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 , Jan Beulich , =?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) This patch is broken out just to simplify the following two. For xc_cpuid_set(), document how the 's' and 'k' options works because it is quite subtle. Replace a memset() with a for loop of 4 explicit NULL assigments. This mirrors the free()'s in the fail path. For xc_cpuid_apply_policy(), const-ify the featureset pointer. It isn't written to, and was never intended to be mutable. Drop three pieces of trailing whitespace. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 CC: Ian Jackson v2: * Adjust the comments to include 's' along with 'k' --- tools/libxc/include/xenctrl.h | 2 +- tools/libxc/xc_cpuid_x86.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 0da437318e..f4431687b3 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1800,7 +1800,7 @@ int xc_cpuid_set(xc_interface *xch, char **config_transformed); int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, - uint32_t *featureset, + const uint32_t *featureset, unsigned int nr_features); int xc_mca_op(xc_interface *xch, struct xen_mc *mc); int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 0f07317b54..8785cae329 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -1,5 +1,5 @@ /*************************************************************************= ***** - * xc_cpuid_x86.c=20 + * xc_cpuid_x86.c * * Compute cpuid of a domain. * @@ -329,7 +329,7 @@ static void cpuid(const unsigned int *input, unsigned i= nt *regs) =20 static int get_cpuid_domain_info(xc_interface *xch, uint32_t domid, struct cpuid_domain_info *info, - uint32_t *featureset, + const uint32_t *featureset, unsigned int nr_features) { struct xen_domctl domctl =3D {}; @@ -804,8 +804,7 @@ static void sanitise_featureset(struct cpuid_domain_inf= o *info) } =20 int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, - uint32_t *featureset, - unsigned int nr_features) + const uint32_t *featureset, unsigned int nr_feat= ures) { struct cpuid_domain_info info =3D {}; unsigned int input[2] =3D { 0, 0 }, regs[4]; @@ -895,7 +894,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, * 'k' -> pass through host value * 's' -> pass through the first time and then keep the same value * across save/restore and migration. - *=20 + * * For 's' and 'x' the configuration is overwritten with the value applied. */ int xc_cpuid_set( @@ -906,7 +905,8 @@ int xc_cpuid_set( unsigned int i, j, regs[4], polregs[4]; struct cpuid_domain_info info =3D {}; =20 - memset(config_transformed, 0, 4 * sizeof(*config_transformed)); + for ( i =3D 0; i < 4; ++i ) + config_transformed[i] =3D NULL; =20 rc =3D get_cpuid_domain_info(xch, domid, &info, NULL, 0); if ( rc ) @@ -924,7 +924,7 @@ int xc_cpuid_set( regs[i] =3D polregs[i]; continue; } - =20 + config_transformed[i] =3D calloc(33, 1); /* 32 bits, NUL terminato= r. */ if ( config_transformed[i] =3D=3D NULL ) { @@ -932,6 +932,13 @@ int xc_cpuid_set( goto fail; } =20 + /* + * Notes for following this algorithm: + * + * While it will accept any leaf data, it only makes sense to use = on + * feature leaves. regs[] initially contains the host values. Th= is, + * with the fall-through chain is how the 's' and 'k' options work= s. + */ for ( j =3D 0; j < 32; j++ ) { unsigned char val =3D !!((regs[i] & (1U << (31 - j)))); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel