From nobody Sat Nov 30 03:55:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1618322644; cv=pass; d=zohomail.com; s=zohoarc; b=LtIhTGFrNYAQ29xaE9DpB0wIlCXhO0e1gCywlFOC2t/calHbZl6ZRZ1ojaUEKhhk8ACJM5vNO062rlpQ1SWKW7b7a8rNBP1g4o4ftRfKXJ390bKcD5W+A7GZq4PoRcJaYx8RFshzWFuxWIB1uG30iSJTmaP6ysUOufdz893vYBA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618322644; 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; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=PouRmI3TTrEMdXAe35WCunX1OEs1bL86YrguFJEAuibasbm242+mbLaXdbS9MzlBJGcPFREH0KqNbD5jnXVSMv0JaoS21V1j0hIcV+fq7+oRCzBmNyZTA/rVnW9gOEl9TjmqVW38juS2sSB+r4lc/CkJt0C8M8SU7xNORFTrnjA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618322644697347.6681814826777; Tue, 13 Apr 2021 07:04:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109836.209721 (Exim 4.92) (envelope-from ) id 1lWJds-0006a5-Fu; Tue, 13 Apr 2021 14:03:48 +0000 Received: by outflank-mailman (output) from mailman id 109836.209721; Tue, 13 Apr 2021 14:03:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJds-0006Zx-Bt; Tue, 13 Apr 2021 14:03:48 +0000 Received: by outflank-mailman (input) for mailman id 109836; Tue, 13 Apr 2021 14:03:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWJdr-0006KX-Bn for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 14:03:47 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c487b8b6-adbe-429a-bc33-38996c013ab6; Tue, 13 Apr 2021 14:03:46 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c487b8b6-adbe-429a-bc33-38996c013ab6 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1618322626; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=cq7WRx5BpsCYjEAJzUUXhgmQH5KGs74ng/5qh4MPnF4=; b=PY3XZBHfGoA7tdRr7tO2ZPJZrJSPmiDv+j2Ok28y8tm3YR1Uw7oDSG8j Jyc+AwqAB25N8PteJeU2YUpM2f90me5ZIRXaJMGFQ0gAGrARvpYBoGd3C g3dR0JfhZJcq+FOQBm2UL31coOoCemSiWNL84ukdCD5Ffl3xfWisU3wYq A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: xzoOk2dYXHI5sGJAd5bxzv5J5AgygmBVfQ1pUdlD+YkSHSsmqN3o7qAhg0mXGknDp3LqvPVAY3 apgABNg3iyOhdj5uaJV0o9wBANuGLFM7WqM40QmgJRfC9IHA7RgcsZMR1IBiUvoq382qYt/UNR T4QEWK79eLxQqlW+QSUBtGkr5rQxQP7jW4I+Ik3rKV5cADXzDgqnTV44ncku254aojtPfGq1fw mvf2ltJG0N5kzhpj1bzKetMjxMFEFFi4H0PQxRGKc+exPmuWCkbe6FEr8p7K4FdSq7b3+nxSHw xW0= X-SBRS: 5.2 X-MesageID: 41614008 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:PoNK06HcFfkz5oBxpLqFbZTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7Lk/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeNJwTXzcQY76 tpdsFFZeHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLD1CQYsI1XYcNi+wFEpqSA5aQacjHJ 2H6cZd4xamc3IbbsO0b0N1I9TrjdvNiZ7gfFo6FwcqgTP+8A+AxZzbN1yj3hkYWy5S2rtKyw b4uiHw+6nLiYDc9jbyzGnWhq4m+ufJ6twGP8CUj9hQFzOEsHfSWK1Ee5mv+A84u/uu7lFCqq i9nz4FM95o433cOkGZyCGdojXI6zol53/8xVLwuxKKyqaYNVFKefZpvo5XfgDU7EAtprhHod h29lmUqoZNClf4lDn9juK4Ji1CrFa+onYpjIco/htieLYZAYUhyLA3zQd+FZcNGz/C84Y3EO ViJ9G03ocpTXqqK1/epWVh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ZP+X2gW8W8HUalHvNJ6cWzPRC0uZSRifTDxQvfeH+ccEQXhY pMaEwWYIBis1AZ/fIK+xn3bLf2rEIjm0ZZ+hd9mDfWq9Gb3Fs= X-IronPort-AV: E=Sophos;i="5.82,219,1613451600"; d="scan'208";a="41614008" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOSJ6fs7Jda5qlJKKj1FRQheVCHhY02lQwEPzFZi5y7bl4SG4kqgvi+1VgkPDpWVhCCRCL56tZGsACXtYD3hF9tU9u4rMaokYpaqV0JweymuyUeWahY+HCEgKSVAgYPzCvPRQ2XyXSxWmIlHyRf2kLXfJoe11wZzGjQHMGiXncM30pRLEsiqs2ndE8LtcRilV/IE3dunNzlHmZV/TOEXrDmSDSdvfGOAqoEDXMnmryVSdxm0tz+Nv4Q8KDutGuPGmOeiS0BFPZGx4Y0QrCE+Ija8BY44QCjBhBfoIPHedFNUC/+9G1YvBex9F8k9mve4MZhV0ftLCzpswzDmt+1bag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=bKxJukOyvWIKNlL6ThxCezHRGUu0aASvCJN9Wwlsm4mhJ1NCyN3Kb6CoK1lM5loHO+Rz3+ly4+kA6A8zVVTV7aj7SqMQCMTDw14sESRTbhNx+tm40tH+hosKlRsKTaWyA1kDXesIQ1BeaCNJkNJVs67JOUET/uPfy0pZ4B6S4Itw00bWIIoqbpmoMadoNmT3xFqVeYWS311dtyrZzNiJsUDgtiLJXnVELNXLDiHTUlIkous3s/KT+XM/zn70MVz3exCA8VXJVj12odTUwi1nT6D/TNS957grtDiBduU8DBAlcEeOYjB/uLLPxK9lnLoWFMsncUismloYDF57oMYPlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yfg3EpqS4Xb7uB8bCvTSbNySuLEELrQoy2D2h5/WPGY=; b=r2MA396HPbEKem0DYIL8tw+PEzo8w/8mWissdUQtIsS3unLfMorYieXtP4TPro/72MA/wUddLZWvUR4dqhhm1dt01dH8M37DAH+ASd6+qMh49sfMqh7hJMiXwm7pIJfpajpghzoiRuaXHOrsHRrroNqLY3Iayzx+WP3xeFCRkZI= From: Roger Pau Monne To: CC: Andrew Cooper , Roger Pau Monne , Ian Jackson , Wei Liu Subject: [PATCH v2 19/21] libs/guest: apply a featureset into a cpu policy Date: Tue, 13 Apr 2021 16:01:37 +0200 Message-ID: <20210413140140.73690-20-roger.pau@citrix.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413140140.73690-1-roger.pau@citrix.com> References: <20210413140140.73690-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0054.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::18) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c20a9d9-7e3b-4209-de21-08d8fe84f22c X-MS-TrafficTypeDiagnostic: DM5PR03MB2969: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eulKJr/ewBlWyflw6ePV2lqjWX3P+cnD3YBhymmCKOGwQs8NJW0D/Z/Zq8qgkvz2PNpxsa1aEgyYkootf71QKGwMbiqKlN5Bn/725TD3LKOGSVmSLDUMuwlVEqrrqbXiyBlWUo4+giD+EahfhgFLkEOQjA6mxH0qm/nYrC/9focEvHo9WSeq4q8hRFzr65+Gm/blsVKTC4xruyfGzN88QfuXTqY2CHpk5hkrB+tqTnTrK+9KPR9KfF6nqPcl6c2EvX3E+oJkZBCu8XIkDltBxmPRPknMe71puheHgQY4Ay/KYnXo7aVmjN/soH0JldcgM0AzJHUA2VrpTC4PKDTlbX8iiHelFnsB8M66BLXTMLCiyVhy6E6VlbgrHu5ktFsI1PkrFHjdT7zB/llJEtAxdxZ4I4FDyujSs6SX+ZPI5E43tuGkaoEeBUzNl/TK99CO9GrI+ZQ0835MzcZ6PcChJicsfbesOZ7/EtllGOrtpWgkYnt5zciGu0LUIbb0QtHmyGBEZpS7W3IvWBG916SvLyagJAfrBBirqo+9kejLSXw+Ea4buboCqU8+uN3jlPcoOsDVWh3rwKc8LEbfyAcxaUBLXjlgGHHx6cCzuWChjhc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(376002)(346002)(136003)(39850400004)(366004)(83380400001)(186003)(6496006)(316002)(2906002)(4326008)(36756003)(54906003)(6916009)(2616005)(6666004)(16526019)(26005)(478600001)(6486002)(1076003)(8676002)(8936002)(5660300002)(66556008)(66946007)(86362001)(66476007)(38100700002)(956004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?ckMyanJqSGsrUDJXVzlMRjhsVVZ3SXNVWktJVHJpbXZGOU85bWp5aGs2blM0?= =?utf-8?B?OG5nVmtQRGVEUmFCNHh0VGJXRHUrZFlIcmZSOXFuRU51eitReVV0ayttWFph?= =?utf-8?B?U0dUdCtSclZyenE3SWgyYU9RalQ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3VlIzYXhHOVRLUVB1SGNZNGZ1VHM4aVRIQzlJY040WDM5S0M5aEVOYncz?= =?utf-8?B?bWdBeng4SlpyYkRCSU9oYnJzMGxKb016ZVpDRExtNHVxZGJaWWZNVitrU01i?= =?utf-8?B?VDBpbFN3TUN5a1JzTk9hZ1NheVdOV1NxMlI3NlJ4Y2FaeGVVNlpOSG5Na2ND?= =?utf-8?B?aTFiZ3g1VTBldk1lQ3pLMU0zMVdtRnlDZ1dDeFJsa09nbFhkTnljREpIOFRk?= =?utf-8?B?Yk9XS0VqZXg0OEo5am1jRUFuVEhWdnZXajFiVjg0dXlvVlliMlBzeGdZZjBB?= =?utf-8?B?SllSOVFXMzU2a1Jwd2ltNzVCYU1HYVl4RlEwTDdyV2ZRdGtSUnpqNUdDS0x3?= =?utf-8?B?M1JqYmJvdmJqRkhXZ0FMQUxPMnpBZjRwekZLTFJlaW43QjAzcUpRNEdTcVBa?= =?utf-8?B?S2ZpRnlMMDlHTFJCSm1aeGY1d3kzREFSMFFtR1IzY0N5TXFhYjBvZ3NRSHZt?= =?utf-8?B?ZDNweEN2SnFUcmtGMEhVcVkvQS9UNVJ3akNHR2xWVCt4cGVDRFk4WFIrOEZG?= =?utf-8?B?TG5SUHN0TEt2TTZsRHJVQWV1Z3AzWGFTWmVvRkphSjhWK0NKZkZwY0x1aEkz?= =?utf-8?B?TFMxTnFCSUlSY3krMkJvbVo2ZDlwc0VpQW14cFc5LzdvL2RQY0hRRTlSaFkv?= =?utf-8?B?bE9HalNHSnNuTDZlN1owTDFCWWpmSHNSYkw2eFBKdk96RHhCLytPeE1pN3Q5?= =?utf-8?Q?jeBg3vTqYvYUSoP94Qvd0iBF7SDYpCd3cZsmd4z?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4c20a9d9-7e3b-4209-de21-08d8fe84f22c X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 14:03:42.6608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MGU0y1qrO/qX0kBv+NqlI6W64RCq9WKxlhAbOxFCYCU0d/e11g+HRSiRedo/mO39ayuhwYbksOS3bBvmeA3ZAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2969 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- tools/include/xenctrl.h | 5 ++ tools/libs/guest/xg_cpuid_x86.c | 95 ++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index ce0785f7654..3fef954d1d1 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2639,6 +2639,11 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch,= xc_cpu_policy_t policy, int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t policy, const struct xc_xend_cpuid *cpuid, bool hvm); =20 +/* Apply a featureset to the policy. */ +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t poli= cy, + const uint32_t *featureset, + unsigned int nr_features); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 06e3e8131d7..b0690d9799d 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -481,46 +481,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, =20 if ( featureset ) { - uint32_t disabled_features[FEATURESET_NR_ENTRIES], - feat[FEATURESET_NR_ENTRIES] =3D {}; - static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; - unsigned int i, b; - - /* - * The user supplied featureset may be shorter or longer than - * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-exten= d. - * Longer is fine, so long as it only padded with zeros. - */ - unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_featu= res); - - /* Check for truncated set bits. */ - rc =3D -EOPNOTSUPP; - for ( i =3D user_len; i < nr_features; ++i ) - if ( featureset[i] !=3D 0 ) - goto out; - - memcpy(feat, featureset, sizeof(*featureset) * user_len); - - /* Disable deep dependencies of disabled features. */ - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - disabled_features[i] =3D ~feat[i] & deep_features[i]; - - for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + policy.cpuid =3D *p; + rc =3D xc_cpu_policy_apply_featureset(xch, &policy, featureset, + nr_features); + if ( rc ) { - const uint32_t *dfs; - - if ( !test_bit(b, disabled_features) || - !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) - continue; - - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - { - feat[i] &=3D ~dfs[i]; - disabled_features[i] &=3D ~dfs[i]; - } + ERROR("Failed to apply featureset to policy"); + goto out; } - - cpuid_featureset_to_policy(feat, p); + *p =3D policy.cpuid; } else { @@ -1098,3 +1067,53 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch,= xc_cpu_policy_t policy, =20 return 0; } + +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t poli= cy, + const uint32_t *featureset, + unsigned int nr_features) +{ + uint32_t disabled_features[FEATURESET_NR_ENTRIES], + feat[FEATURESET_NR_ENTRIES] =3D {}; + static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; + unsigned int i, b; + + /* + * The user supplied featureset may be shorter or longer than + * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-extend. + * Longer is fine, so long as it only padded with zeros. + */ + unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_features); + + /* Check for truncated set bits. */ + for ( i =3D user_len; i < nr_features; ++i ) + if ( featureset[i] !=3D 0 ) + { + errno =3D EOPNOTSUPP; + return -1; + } + + memcpy(feat, featureset, sizeof(*featureset) * user_len); + + /* Disable deep dependencies of disabled features. */ + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + disabled_features[i] =3D ~feat[i] & deep_features[i]; + + for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + { + const uint32_t *dfs; + + if ( !test_bit(b, disabled_features) || + !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) + continue; + + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + { + feat[i] &=3D ~dfs[i]; + disabled_features[i] &=3D ~dfs[i]; + } + } + + cpuid_featureset_to_policy(feat, &policy->cpuid); + + return 0; +} --=20 2.30.1