From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841649; cv=pass; d=zohomail.com; s=zohoarc; b=clS02ARyl0JBk5w2IgIqCHO2aYt+UlyP2MQnNzEyHS0Rpr9OjebAjOOHvuTRC0/9yVrHVnUpNQR9d3EGtC+fd52knyElvG2CXAiE1baJrRNkLCGdjYI8nflsPw6vDDxpH7SuIGJYUxpN+UZrHo8ANo5iDTk9UMq2W+4PvtiNxA8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841649; 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=wf40HwzFigWxi5/seuFzBWojNz9BnyuqK0PdkFX/FF4=; b=ewicbcAs9oIUou+jt6qdNP91du6vPxAZQRWNvR51jgQMvt9SEY4p1rflvpHm9gUYpGbzcubHksttK3qQlPHxryUq7zpvkJASPskZAnhP6BZKWjg8e2PTL6WR/8LOSdDry2V281+vi2bEM4V60+Jmlw5q0k/Keu8vxe7HzXaJxMM= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841649948834.6282099204699; Thu, 20 Jul 2023 01:27:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566463.885291 (Exim 4.92) (envelope-from ) id 1qMOzv-0001dv-NZ; Thu, 20 Jul 2023 08:26:55 +0000 Received: by outflank-mailman (output) from mailman id 566463.885291; Thu, 20 Jul 2023 08:26:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMOzv-0001do-Kd; Thu, 20 Jul 2023 08:26:55 +0000 Received: by outflank-mailman (input) for mailman id 566463; Thu, 20 Jul 2023 08:26:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMOzt-0001O5-DN for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:26:53 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2d618f33-26d7-11ee-b23a-6b7b168915f2; Thu, 20 Jul 2023 10:26:51 +0200 (CEST) Received: from mail-co1nam11lp2172.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.172]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:26:50 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:26:49 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:26:48 +0000 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: 2d618f33-26d7-11ee-b23a-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841611; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/jv+CyPM3neLkaA4oQq4tIsXoYzSYlUOZobTjS+1d6o=; b=JqxdOhGYN9ytGTt38sZIIM2cHsvqD6WsjZ/wBU+NcuGgLQikjCjOJVVs RP5pgB9D7rHWgSg9LKjbhEL0fUfwPNwn8FhxVlHiItDAZcVNODkdMAxH5 f3o6OEn6g+loN0PphL3lJBm3mqMbXxL7w6jg7rwysUDXnvAZKelofMrVF c=; X-IronPort-RemoteIP: 104.47.56.172 X-IronPort-MID: 115538984 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:diGhKaqZsANmw6TTtCh3SEQeA4peBmI8ZBIvgKrLsJaIsI4StFCzt garIBmGPfeIMTakKNt/O9u0oRlSvMSHxtRqQQZpqi09E3sV9ZuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GpwUmAWP6gR5weBzSFNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXABcwV06dq/mp+oCmUOUzp5QqMeTPGIxK7xmMzRmBZRonabbqZvyToPR/hXI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jearaYWPEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdtPSebop6426LGV7kwBDkVNT2KKmtqgh2qea+xcK 1MV+TV7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3OcpQRQ62 1nPmMnmbRRtv6eSUmm17aqPoHW5Pi19EIMZTSoNTA9A6N66pog210vLVow6T/TzicDpEzbtx TzMtDI5m7gYkc8M0eO84EzDhDWv4JPOS2bZ+znqY45s1SshDKbNWmBiwQKzASpoRGpBcmS8g Q== IronPort-HdrOrdr: A9a23:VMB//qMs1pYPBsBcTsKjsMiBIKoaSvp037Dk7TEXdfU1SL3/qy nKpp4mPHDP+VUssR0b+exoW5PgfZq/z+8W3WB5B97LNzUO01HYSb2Kg7GSpwEI2BeTygee78 pdmmRFZ+EYxGIVsfrH X-Talos-CUID: 9a23:rIq9jm4cCjRNPVFsA9ss03MtRN4JaWLn/mrKLxCZWW90ZZmxRgrF X-Talos-MUID: =?us-ascii?q?9a23=3AnF0I7QzWjEm8hVEQmvaqL2/kfmeaqIS8DhhWi6w?= =?us-ascii?q?3gOqdOAhQCwmejCu2QZByfw=3D=3D?= X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="115538984" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OYHZmw3onIMwlx+x2QcGuggvDor1AZLdhwWYsq1bkEXNjtI7XPWLhe6UNNBTky+b83n+a+ZqALGIW+k6DUtm0vzCkPZVKzPW2O9vMc53btgoPcf2kGvR5Ml8OcDrffyRo34/1k7Ga1Em13oIiDqU1FiGjTmfJO6Ow8FbVyedwjHlEXsjLPC9w+kgdDjOP5RCoCrCp9hDERM83z6QlhdllFu2SD+Ofudq2gs9n+H4vyup3vl1ALwM+3Z7PQ0VKl2JU9MbfqkdFRmcs41spMPlcrZcPvguuKv58PWxwsrFKaVEL5kp9iq3fErVEsJxRy3tzN6Eqid1ZKhO1L4pSNX6ig== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wf40HwzFigWxi5/seuFzBWojNz9BnyuqK0PdkFX/FF4=; b=K2nhdNIG5pidwhGsM5yLxAW+81jnANx8QC1Lp23YUlUtxrf4HVSxjYY7fjGXtUl7tObo0qdsw/GaApqsvK6LigD4wOP6BpP2/3FakZydUM0jR0y+aCLvgp9siOLipb4amsfc7GnyPTAuhQMDsHlKmU5wVuv79If74OMnkkIjbWH9K/bsKbqfKcPGpOpln2iuEFRVGe5F3OIeJyYAhqltRuZvDrFb87jFYytIa0spBMsVUvo8UgrVPhPgWZ5Dm6Hyxmgkk0E/uoZC9uiaeGN8uP1kyVVaeGBZA4AeFE7FDVLkVIEdkxf0oroerjgoYdliyTAa2I6GpIerN0H5dlc1Aw== 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=wf40HwzFigWxi5/seuFzBWojNz9BnyuqK0PdkFX/FF4=; b=psy35O/FuEGcFKSbz6pdf4lz8DhsofDj8eWwpzQ4CwdVsPCx5Ma7evjCQweMoZNlMM5B74LwtQjAfINVxqyHVJaAjz5R9aukDIN6/ModqcNYx3EgPli5lF63/SBtAUc6fqcsr/lgD9mTgtg73Tg6ycn5TOy4vS8UE/0+diTi8Y8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 1/6] libs/guest: introduce support for setting guest MSRs Date: Thu, 20 Jul 2023 10:25:35 +0200 Message-ID: <20230720082540.69444-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0475.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::12) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: d2415a35-a972-4d4a-0598-08db88fb0fd7 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kv582ll4mqoAmt7WbnHrrQUfsGik9kNO1b37LohTzBZ0u7jHIzsyPbZ2BYCszPXQ/1cofHNBcCCGsJdEnwW3D4zLqlNdHMO43Hky3LYyDyTKmRUW52NhYfzOdKasG7xXjrQOukO0NlgH38Ev6u90hQtSwNjSIddhQODw6xHcjuSOqCrNKTFUUQpcu2d9q63ziMbRFTmIdp94R5y+xerXEAHSsybjuu51kZI3jy3IKevoDNvG4AHQ+mMgcjxMQ/roKlxj/kjovpLTyDPs0IA+W6Ajh+0jVImFyKvn0QkKb3voKtu5DuIUnBc6BNlSB+sjwiwQwqC36GPjqGRTl8E0hN1CgBuT4aGQ/wkW2dP/lurXi504TriHKQQ3INW0cFtQWGRpbEX6xvMrf17HO3CigBSjI3DUzceUsP+YYr/bYVfAnLMSXc66ywdXHGs2xegpXzxKwY4oSPhtA31R6kfjngGg5TlbaM7laa1QRCLfEzWCuqSYkDO7IzXMLArMKG8XBwqft9Sz5a1fzqRqjZ+WWqA8iHY/IAiILtKFV3IbA88r6HbP77BHZR8Zci64zE9g X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MkxRREg4U0pHcWFleUJhdXR5c2JYaEsxcVVteHlzWmpGQjBOYW9nTlRsK2VF?= =?utf-8?B?OTd3MG8yRnZkSWJ1K1FnMUoxeUFZVU81RVY3YWFLWTNnQTFNTnhpbEdoR3Nn?= =?utf-8?B?SXpORUs4MHpoWkZ0ZTZpRkUxamlSU0FiMXdvNENGY056VFVyTXk1UzAyRmhV?= =?utf-8?B?OG9TS0ZlekJnMTBScHBCWFIvb1QvYzBJS0UreE43T2dzbFlLUlp0bFkrRm1J?= =?utf-8?B?WDVnN3FWc2QzaUZvL0dKRm5hSnpQbkt5WEJqZ1psSjZ6YjZU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5cWpNNGVtcnpqSHA3YnNodGVZcUVwWEN5elI3?= =?utf-8?B?YVdoRERoeXB4NG5ra2RubUFWRU43NjY5Y0V3UnllYzhvUlhtTWpVZTBQRFZF?= =?utf-8?B?TFE9PQ==?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: t049lydf/QwAounfVlo7edgmcNuyYVxTd6g+wod/SzUpf2vvPv7dQZSHjJOvxp033Dl1TlHAD95G8kNXRQYG6yzBzT9BXZKmkzVxMgSuhiZp2txVVlWyxV3wnspdntH8acoRgKBLWf/+FI3Ndmbcezxcim+6rfA/kirROkMRDQn1gjVtIvfCFIxY595iX4qrm0BasJ8WgXsSz7O4y5QEdjxXl3qDz7P7vLb+C1Tuk38YH/hFQf5BogDoqiVIVA6/1ERFtNQ6gsFWh4M00ehfJB0N1ks8A9l1CPadtbuaiVedo/LCujfz8wEiIFKAMhWxDk4BriOEnps01kl6koR9GkU4AUuFYN/XKhcPKV7uYe9Q+wcmGahOttxWlArMd7Rj0k/X0zGoFr63KxGno+uTDp8uqgzPPLoiOHRGilp+XuVH6wWT3LwVhNzn9sat2ZvvUtZGYdL8wqB6t2q1yxwmJOEnuveNLY7qTVG9S3NfiCisdotpus0DVs3O0CReRJaeQTNmQnfEoPbvJNsMe0HmfKWS/dgBbL4aOvU0hJWaJLI5wxqkGJ+2GxkboOge1wcb5Efx6n6LSm1KXsRZMVE+QxUQuo5xD1UNkhe3lhH3Cdd8A1225TiiZX97dBZMmSn4RQwl4cJQxDcGBL8FH55s/TV6eWy7jh3O5lYBRfUA266BPQtfrY5/XeQvPUBrSMr2T+5NARQIX1s8Y4vCqts9x2E1i3vrSGTj0+SbpmiL2mqMZlgv8CBDiZ3bz+YDU2HTPZq81aOQfNlX4rtpQd8XmOncCHHEY7ximFWdtMpwI9BhJVgBZSK+R/D8OuL4nO0S X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2415a35-a972-4d4a-0598-08db88fb0fd7 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:26:48.9311 (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: Cllahq0gLwpSYYF1HS+fsgfKF8jND9HkO5iBJWm0T5787ydc1j2p71ih2W07hBnyh2kroWo803JwH/Muog6A5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841651642100001 Like it's done with CPUID, introduce support for passing MSR values to xc_cpuid_apply_policy(). The chosen format for expressing MSR policy data matches the current one used for CPUID. Note that existing callers of xc_cpuid_apply_policy() can pass NULL as the value for the newly introduced 'msr' parameter in order to preserve the same functionality, and in fact that's done in libxl on this patch. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Anthony PERARD --- Changes since v2: - Some code adjustment, no functional change. --- tools/include/xenctrl.h | 21 +++- tools/libs/guest/xg_cpuid_x86.c | 169 +++++++++++++++++++++++++++++++- tools/libs/light/libxl_cpuid.c | 2 +- 3 files changed, 188 insertions(+), 4 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index dba33d5d0f39..faec1dd82453 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1822,6 +1822,21 @@ struct xc_xend_cpuid { char *policy[4]; }; =20 +/* + * MSR policy data. + * + * The format of the policy string is the following: + * '1' -> force to 1 + * '0' -> force to 0 + * 'x' -> we don't care (use default) + * 'k' -> pass through host value + */ +struct xc_msr { + uint32_t index; + char policy[65]; +}; +#define XC_MSR_INPUT_UNUSED 0xffffffffu + /* * Make adjustments to the CPUID settings for a domain. * @@ -1833,13 +1848,15 @@ struct xc_xend_cpuid { * Either pass a full new @featureset (and @nr_features), or adjust indivi= dual * features (@pae, @itsc, @nested_virt). * - * Then (optionally) apply legacy XEND overrides (@xend) to the result. + * Then (optionally) apply legacy XEND CPUID overrides (@xend) or MSR (@ms= r) + * to the result. */ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, const uint32_t *featureset, unsigned int nr_features, bool pae, bool itsc, - bool nested_virt, const struct xc_xend_cpuid *xe= nd); + bool nested_virt, const struct xc_xend_cpuid *xe= nd, + const struct xc_msr *msr); int xc_mca_op(xc_interface *xch, struct xen_mc *mc); int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, xc_cpumap_t cpumap, unsigned int nr_cpus); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 5b035223f4f5..f2b1e809011d 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -423,10 +423,170 @@ static int xc_cpuid_xend_policy( return rc; } =20 +static int compare_msr(const void *l, const void *r) +{ + const xen_msr_entry_t *lhs =3D l; + const xen_msr_entry_t *rhs =3D r; + + if ( lhs->idx =3D=3D rhs->idx ) + return 0; + + return lhs->idx < rhs->idx ? -1 : 1; +} + +static xen_msr_entry_t *find_msr( + xen_msr_entry_t *msrs, unsigned int nr_msrs, + uint32_t index) +{ + const xen_msr_entry_t key =3D { .idx =3D index }; + + return bsearch(&key, msrs, nr_msrs, sizeof(*msrs), compare_msr); +} + + +static int xc_msr_policy(xc_interface *xch, domid_t domid, + const struct xc_msr *msr) +{ + int rc; + bool hvm; + xc_domaininfo_t di; + unsigned int nr_leaves, nr_msrs; + uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; + /* + * Three full policies. The host, default for the domain type, + * and domain current. + */ + xen_msr_entry_t *host =3D NULL, *def =3D NULL, *cur =3D NULL; + unsigned int nr_host, nr_def, nr_cur; + + if ( (rc =3D xc_domain_getinfo_single(xch, domid, &di)) < 0 ) + { + PERROR("Failed to obtain d%d info", domid); + rc =3D -errno; + goto out; + } + hvm =3D di.flags & XEN_DOMINF_hvm_guest; + + rc =3D xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs); + if ( rc ) + { + PERROR("Failed to obtain policy info size"); + rc =3D -errno; + goto out; + } + + if ( (host =3D calloc(nr_msrs, sizeof(*host))) =3D=3D NULL || + (def =3D calloc(nr_msrs, sizeof(*def))) =3D=3D NULL || + (cur =3D calloc(nr_msrs, sizeof(*cur))) =3D=3D NULL ) + { + ERROR("Unable to allocate memory for %u CPUID leaves", nr_leaves); + rc =3D -ENOMEM; + goto out; + } + + /* Get the domain's current policy. */ + nr_leaves =3D 0; + nr_cur =3D nr_msrs; + rc =3D get_domain_cpu_policy(xch, domid, &nr_leaves, NULL, &nr_cur, cu= r); + if ( rc ) + { + PERROR("Failed to obtain d%d current policy", domid); + rc =3D -errno; + goto out; + } + + /* Get the domain type's default policy. */ + nr_leaves =3D 0; + nr_def =3D nr_msrs; + rc =3D get_system_cpu_policy(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_defa= ult + : XEN_SYSCTL_cpu_policy_pv_default, + &nr_leaves, NULL, &nr_def, def); + if ( rc ) + { + PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); + rc =3D -errno; + goto out; + } + + /* Get the host policy. */ + nr_leaves =3D 0; + nr_host =3D nr_msrs; + rc =3D get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host, + &nr_leaves, NULL, &nr_host, host); + if ( rc ) + { + PERROR("Failed to obtain host policy"); + rc =3D -errno; + goto out; + } + + for ( ; msr->index !=3D XC_MSR_INPUT_UNUSED; ++msr ) + { + xen_msr_entry_t *cur_msr =3D find_msr(cur, nr_cur, msr->index); + const xen_msr_entry_t *def_msr =3D find_msr(def, nr_def, msr->inde= x); + const xen_msr_entry_t *host_msr =3D find_msr(host, nr_host, msr->i= ndex); + unsigned int i; + + if ( cur_msr =3D=3D NULL || def_msr =3D=3D NULL || host_msr =3D=3D= NULL ) + { + ERROR("Missing MSR %#x", msr->index); + rc =3D -ENOENT; + goto out; + } + + for ( i =3D 0; i < ARRAY_SIZE(msr->policy) - 1; i++ ) + { + bool val; + + if ( msr->policy[i] =3D=3D '1' ) + val =3D true; + else if ( msr->policy[i] =3D=3D '0' ) + val =3D false; + else if ( msr->policy[i] =3D=3D 'x' ) + val =3D test_bit(63 - i, &def_msr->val); + else if ( msr->policy[i] =3D=3D 'k' ) + val =3D test_bit(63 - i, &host_msr->val); + else + { + ERROR("MSR index %#x: bad character '%c' in policy string = '%s'", + msr->index, msr->policy[i], msr->policy); + rc =3D -EINVAL; + goto out; + } + + if ( val ) + set_bit(63 - i, &cur_msr->val); + else + clear_bit(63 - i, &cur_msr->val); + } + } + + /* Feed the transformed policy back up to Xen. */ + rc =3D xc_set_domain_cpu_policy(xch, domid, 0, NULL, nr_cur, cur, + &err_leaf, &err_subleaf, &err_msr); + if ( rc ) + { + PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr= %#x)", + domid, err_leaf, err_subleaf, err_msr); + rc =3D -errno; + goto out; + } + + /* Success! */ + + out: + free(cur); + free(def); + free(host); + + return rc; +} + int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore, const uint32_t *featureset, unsigned int nr_feat= ures, bool pae, bool itsc, bool nested_virt, - const struct xc_xend_cpuid *xend) + const struct xc_xend_cpuid *xend, + const struct xc_msr *msr) { int rc; bool hvm; @@ -663,6 +823,13 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, if ( xend && (rc =3D xc_cpuid_xend_policy(xch, domid, xend)) ) goto out; =20 + if ( msr ) + { + rc =3D xc_msr_policy(xch, domid, msr); + if ( rc ) + goto out; + } + rc =3D 0; =20 out: diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index f5ce9f97959c..c96aeb3bce46 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -502,7 +502,7 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,= bool restore, info->tsc_mode =3D=3D LIBXL_TSC_MODE_ALWAYS_EMULATE); =20 r =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, - pae, itsc, nested_virt, info->cpuid); + pae, itsc, nested_virt, info->cpuid, NULL); if (r) LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy"); =20 --=20 2.41.0 From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841651; cv=pass; d=zohomail.com; s=zohoarc; b=Bu8pYK/tjjEnY/RflHCbzrB0npiXjHymr9KpH5G+0MVhNpJi2oeM9afYH2mFw1C/IFPJs9ReGgk9QdtnlTrWLNA21B7TBiditYXwmBegzRaxlkfvqdUPmQv+4B+zviZq6rB9h5Uxy6cJ4BuIh68L6BVhFhOulsMn2cg/VjC2Ews= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841651; 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=OvAgEnMZzKsiO5gFVAUArv65sWJ/koiL8PS5eQmSiJs=; b=hChKsZCZHDVRrUqeVcps98JsH8PAoO3L382+Gr3m+i7qrFXeVxFwjeppIxa7M24BKp1NvWzknM90cZ16HtGqSoXb2qbn530RSS0236xAcsaBfmpHa6HA8kZIvPqOJLqOzCdHLwp4mS0Tprj9cSirC6XOIp8WR554vEjpQbJlGag= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841651021613.2736885713114; Thu, 20 Jul 2023 01:27:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566464.885301 (Exim 4.92) (envelope-from ) id 1qMP02-0001x6-24; Thu, 20 Jul 2023 08:27:02 +0000 Received: by outflank-mailman (output) from mailman id 566464.885301; Thu, 20 Jul 2023 08:27:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP01-0001wx-Ua; Thu, 20 Jul 2023 08:27:01 +0000 Received: by outflank-mailman (input) for mailman id 566464; Thu, 20 Jul 2023 08:27:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP01-0001wC-9g for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:27:01 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 30b1478a-26d7-11ee-8611-37d641c3527e; Thu, 20 Jul 2023 10:26:58 +0200 (CEST) Received: from mail-co1nam11lp2172.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.172]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:26:56 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:26:54 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:26:54 +0000 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: 30b1478a-26d7-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841618; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/DjRmCpyR41ndqdeo2ztSdCTQNy5XAVA3JYpNnatIeo=; b=ftnWY6hL7VgwqLsQWHpW9uHkZ1sj7j0WYvsNlDgAy4Fj4ycm/wRRfZvW 31Ib4tDGKldjlw+MFBvQOG7RNHG/EkNH7Ha3PBHee9QaeBgb2ZH6uTeri SAoPqskD1Tl7skas/R1Be1y2gwvGudeIBSPTZAmbGFFhnCHiKvNLM9/ra w=; X-IronPort-RemoteIP: 104.47.56.172 X-IronPort-MID: 119438774 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:Ch9616kpu7fNl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ii?q?9a23=3ArYQT+QwAMvpmTn1BATxJuho5TmmaqJ2HGUsRtJN?= =?us-ascii?q?egcneNid9Hjizrm+YUKZyfw=3D=3D?= X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="119438774" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mj6B5YE8huTW1l3U6Wii6rXCReMMG04xbfwLrRwDRGscaB9W2/Rxq5vUgVCcPOpBYYj7n+O9Twi+wjl3bxRPY1hbp/rZyUphN5fm7H0o4oYaEu/rkKps37hdLClNO0NCVUT9A5BdnQO/wyRU0emVVkj9pIrgXUrM4tHJIfRUpFtc5aQ3GLbEX7RXDGdlNR8wjrA9UWOwwKvxh//LQCHoK+DOqoj+LV+6aY0GLDTPMUtXKCMWVyctC8srJNBOd+nbfHbQ2X7udOOgWBmLEQm+66OZ9NKWSoTIvvKJIefqJmkzXc3BjBDnCn/QzgfwACLoRyCMJjdm6LPuvytSUotWbg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OvAgEnMZzKsiO5gFVAUArv65sWJ/koiL8PS5eQmSiJs=; b=e2oEeOkYJgPmgfgEC1MHxqbS/+82LlQl2tus4SyYDXdEhEsjNAaei33ZgUh54UrKOTPBikTSvNHj9wiPC/kSE17+xKm86BXWI0ScpYj/sPhoYnrNlG3qI0tggCUHYCD9fN5lSXN5QDQZILEBVv35a4YXE+lTPFT+DwhB9uIxY1A8v20aw69hv5VZ2OqLcc2EZfPlXK19HC9B+O3fZfhFxoPtwKkB7b6lPLPBSroOQvW/IwVhnWHDJInp544I8p5W6/Zq2kaOU1ebjQCmBfOfr93QV6Cr13d2pqBq71rODh4UJlX1EIHVJQtXUPHW5fFc0z/ZL4+SwGKcGvkI47Pkuw== 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=OvAgEnMZzKsiO5gFVAUArv65sWJ/koiL8PS5eQmSiJs=; b=QLrMQufRGVVfKDTMPYv+omkwjP5+eIV3lXbpZK07AgvBjBQa7QlWKGJCoe+uhyk10kKPjYo1EOnsLG03Hyg4aLxr6oCegOwI/LA/srngkrg3WU/pURlNxwpz4SfqXoqSywE7v7wGzzcwfFOmKyFz0dFAOSG9XYHvcdR28IL+WP8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 2/6] libxl: change the type of libxl_cpuid_policy_list Date: Thu, 20 Jul 2023 10:25:36 +0200 Message-ID: <20230720082540.69444-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P265CA0159.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::9) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: d2e00534-d6a8-4e32-58ad-08db88fb12fa X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B4uE0kWJPx/DzfZ/csNp1qO8g2z23vKPFWCQCkxOozLbu8qB/BjIjie3ImPL8UgzvwM1dJ3VMiqzY0l2eWAs5sKe0hr4E9lstcp4XvdG/50gGUM3xorZmciJbeQgqI4U8R5rkLz/6P7crEO2cRG8KJ7c7uiQMK3WXF+7koh5aS2T607xXTxjvXRqfx1gGvhC+VVWZ62kvXkV4z8chNDOg9rYfOazhZXHRB0TXoKXdHcNxZsbdXGUFppW2KkDe1UIz1V3a1I1dbl+yKJvS30AXu0T1ATj1Ms1JXfaKT2FSVZYaTATIHubAzHsQf4wvFvR+Kq9qtBQc/2ImRs+nbEAe2McQLWibeFgkWpjptUJw1O3YTbFT5BttD3fzpd25NqrYTf7fgRPaCFQ7/zJIrW7JQ6TjU+f4wqT0jTFomG6Iy1sIbz59XT3npkHZevn5uMPgr3uq3TIwj1WCtNUE0hMS90XfC6yrNKxxi5TnghrV/DdVJBZ2BeuGvB8BIszXFQqpqZynq11LxKeqVAU0a0gVAMEXAFMAEbgkiq++D6MyUERihyqqopnBkYK4B1JF+Iv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TTEzOTE1V2oxb3ZV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JNTkjWRgX1yo5KFvbUzpKmQXNuymUyvHM6EI+GHLJV9vf8hkV7bCFJtIcXzogVLOeWUH/NoIYcDHjK0RrN8LNcvDGdTxNIxR3VlmuiWR5bQu6FiMX3iL5338d6CkpiddTbv3oXT7RVQ0jtI3mtz1FmZoNHUKK86mavWijF3hYpYPF0auSnKxjhe+XFQRevQjwIBTBGGev/WhOR9zCJG4lEvp9LR5nRD5A06LTI0gBnCRQQJal9IvfkuRoAaHYL1DgexPPTC6zukQ/wuspJYid2Xkm2284wdqZ/jziFlbfDQWr0SSLBKw X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2e00534-d6a8-4e32-58ad-08db88fb12fa X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:26:54.2132 (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: ztLEp0jOqdlrkrEQMauEoJ6IlX78pwBVEt0tQtsYZds5goEJchQuxSd5zSr5vpUY6aPEbhcXHJXxIQFPrSmsIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841651659100002 Currently libxl_cpuid_policy_list is an opaque type to the users of libxl, and internally it's an array of xc_xend_cpuid objects. Change the type to instead be a structure that contains one array for CPUID policies, in preparation for it also holding another array for MSR policies. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Anthony PERARD --- Changes since v2: - Add braces in the inner loop. - Do not set the policy to NULL. --- tools/include/libxl.h | 8 +-- tools/libs/light/libxl_cpuid.c | 87 ++++++++++++++++++++----------- tools/libs/light/libxl_internal.h | 4 ++ 3 files changed, 63 insertions(+), 36 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index cac641a7eba2..f3975ecc021f 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1455,12 +1455,8 @@ typedef struct { void libxl_bitmap_init(libxl_bitmap *map); void libxl_bitmap_dispose(libxl_bitmap *map); =20 -/* - * libxl_cpuid_policy is opaque in the libxl ABI. Users of both libxl and - * libxc may not make assumptions about xc_xend_cpuid. - */ -typedef struct xc_xend_cpuid libxl_cpuid_policy; -typedef libxl_cpuid_policy * libxl_cpuid_policy_list; +struct libxl__cpu_policy; +typedef struct libxl__cpu_policy *libxl_cpuid_policy_list; void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list); int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l); void libxl_cpuid_policy_list_copy(libxl_ctx *ctx, diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index c96aeb3bce46..3c8b2a72c0b8 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -19,22 +19,29 @@ int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_lis= t *pl) return !libxl_cpuid_policy_list_length(pl); } =20 -void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list) +void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl) { - int i, j; - libxl_cpuid_policy_list cpuid_list =3D *p_cpuid_list; + libxl_cpuid_policy_list policy =3D *pl; =20 - if (cpuid_list =3D=3D NULL) + if (policy =3D=3D NULL) return; - for (i =3D 0; cpuid_list[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED; i++)= { - for (j =3D 0; j < 4; j++) - if (cpuid_list[i].policy[j] !=3D NULL) { - free(cpuid_list[i].policy[j]); - cpuid_list[i].policy[j] =3D NULL; + + if (policy->cpuid) { + unsigned int i, j; + struct xc_xend_cpuid *cpuid_list =3D policy->cpuid; + + for (i =3D 0; cpuid_list[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED; = i++) { + for (j =3D 0; j < 4; j++) { + if (cpuid_list[i].policy[j] !=3D NULL) { + free(cpuid_list[i].policy[j]); + } } + } + free(policy->cpuid); } - free(cpuid_list); - *p_cpuid_list =3D NULL; + + free(policy); + *pl =3D NULL; return; } =20 @@ -62,11 +69,17 @@ struct cpuid_flags { /* go through the dynamic array finding the entry for a specified leaf. * if no entry exists, allocate one and return that. */ -static libxl_cpuid_policy_list cpuid_find_match(libxl_cpuid_policy_list *l= ist, - uint32_t leaf, uint32_t subleaf) +static struct xc_xend_cpuid *cpuid_find_match(libxl_cpuid_policy_list *pl, + uint32_t leaf, uint32_t subl= eaf) { + libxl_cpuid_policy_list policy =3D *pl; + struct xc_xend_cpuid **list; int i =3D 0; =20 + if (policy =3D=3D NULL) + policy =3D *pl =3D calloc(1, sizeof(*policy)); + + list =3D &policy->cpuid; if (*list !=3D NULL) { for (i =3D 0; (*list)[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED; i++= ) { if ((*list)[i].input[0] =3D=3D leaf && (*list)[i].input[1] =3D= =3D subleaf) @@ -86,7 +99,7 @@ static libxl_cpuid_policy_list cpuid_find_match(libxl_cpu= id_policy_list *list, * Will overwrite earlier entries and thus can be called multiple * times. */ -int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* s= tr) +int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* = str) { #define NA XEN_CPUID_INPUT_UNUSED static const struct cpuid_flags cpuid_flags[] =3D { @@ -345,7 +358,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *c= puid, const char* str) if (flag->name =3D=3D NULL) { return 2; } - entry =3D cpuid_find_match(cpuid, flag->leaf, flag->subleaf); + entry =3D cpuid_find_match(policy, flag->leaf, flag->subleaf); resstr =3D entry->policy[flag->reg - 1]; num =3D strtoull(val, &endptr, 0); flags[flag->length] =3D 0; @@ -400,7 +413,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *c= puid, const char* str) * the strings for each register were directly exposed to the user. * Used for maintaining compatibility with older config files */ -int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid, +int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *policy, const char* str) { char *endptr; @@ -427,7 +440,7 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_li= st *cpuid, return 3; } str =3D endptr + 1; - entry =3D cpuid_find_match(cpuid, leaf, subleaf); + entry =3D cpuid_find_match(policy, leaf, subleaf); for (str =3D endptr + 1; *str !=3D 0;) { if (str[0] !=3D 'e' || str[2] !=3D 'x') { return 4; @@ -502,7 +515,8 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,= bool restore, info->tsc_mode =3D=3D LIBXL_TSC_MODE_ALWAYS_EMULATE); =20 r =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, - pae, itsc, nested_virt, info->cpuid, NULL); + pae, itsc, nested_virt, + info->cpuid ? info->cpuid->cpuid : NULL, NUL= L); if (r) LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy"); =20 @@ -527,16 +541,18 @@ static const char *policy_names[4] =3D { "eax", "ebx"= , "ecx", "edx" }; */ =20 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, - libxl_cpuid_policy_list *pcpuid) + libxl_cpuid_policy_list *pl) { - libxl_cpuid_policy_list cpuid =3D *pcpuid; + libxl_cpuid_policy_list policy =3D *pl; + struct xc_xend_cpuid *cpuid; yajl_gen_status s; int i, j; =20 s =3D yajl_gen_array_open(hand); if (s !=3D yajl_gen_status_ok) goto out; =20 - if (cpuid =3D=3D NULL) goto empty; + if (policy =3D=3D NULL || policy->cpuid =3D=3D NULL) goto empty; + cpuid =3D policy->cpuid; =20 for (i =3D 0; cpuid[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED; i++) { s =3D yajl_gen_map_open(hand); @@ -575,7 +591,7 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, libxl_cpuid_policy_list *p) { int i, size; - libxl_cpuid_policy_list l; + struct xc_xend_cpuid *l; flexarray_t *array; =20 if (!libxl__json_object_is_array(o)) @@ -586,8 +602,10 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, return 0; =20 size =3D array->count; + *p =3D libxl__calloc(NOGC, 1, sizeof(**p)); /* need one extra slot as sentinel */ - l =3D *p =3D libxl__calloc(NOGC, size + 1, sizeof(libxl_cpuid_policy)); + l =3D (*p)->cpuid =3D libxl__calloc(NOGC, size + 1, + sizeof(struct xc_xend_cpuid)); =20 l[size].input[0] =3D XEN_CPUID_INPUT_UNUSED; l[size].input[1] =3D XEN_CPUID_INPUT_UNUSED; @@ -630,8 +648,12 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *pl) { int i =3D 0; - libxl_cpuid_policy_list l =3D *pl; + const struct xc_xend_cpuid *l; + + if (*pl =3D=3D NULL) + return 0; =20 + l =3D (*pl)->cpuid; if (l) { while (l[i].input[0] !=3D XEN_CPUID_INPUT_UNUSED) i++; @@ -641,20 +663,25 @@ int libxl_cpuid_policy_list_length(const libxl_cpuid_= policy_list *pl) } =20 void libxl_cpuid_policy_list_copy(libxl_ctx *ctx, - libxl_cpuid_policy_list *dst, - const libxl_cpuid_policy_list *src) + libxl_cpuid_policy_list *pdst, + const libxl_cpuid_policy_list *psrc) { + struct xc_xend_cpuid **dst; + struct xc_xend_cpuid *const *src; GC_INIT(ctx); int i, j, len; =20 - if (*src =3D=3D NULL) { - *dst =3D NULL; + if (*psrc =3D=3D NULL) { + *pdst =3D NULL; goto out; } =20 - len =3D libxl_cpuid_policy_list_length(src); + *pdst =3D libxl__calloc(NOGC, 1, sizeof(**pdst)); + dst =3D &(*pdst)->cpuid; + src =3D &(*psrc)->cpuid; + len =3D libxl_cpuid_policy_list_length(psrc); /* one extra slot for sentinel */ - *dst =3D libxl__calloc(NOGC, len + 1, sizeof(libxl_cpuid_policy)); + *dst =3D libxl__calloc(NOGC, len + 1, sizeof(struct xc_xend_cpuid)); (*dst)[len].input[0] =3D XEN_CPUID_INPUT_UNUSED; (*dst)[len].input[1] =3D XEN_CPUID_INPUT_UNUSED; =20 diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 1cf3d400bfce..ef882cff3912 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -4869,6 +4869,10 @@ int libxl__setresuid(uid_t ruid, uid_t euid, uid_t s= uid); _hidden int libxl__domain_set_paging_mempool_size( libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid); =20 +struct libxl__cpu_policy { + struct xc_xend_cpuid *cpuid; +}; + #endif =20 /* --=20 2.41.0 From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841660; cv=pass; d=zohomail.com; s=zohoarc; b=goruBtuj+GIx3DYQubDz/NSdQEsJcuwfnkDWugjoHoPAIVYD8d4ADPppefXEKlHjaYkFfFuF0pfujhrkz/dZulsQ1seS2BJaoxyQYDI1Odr5abGjy+R6xr/0xsONGXZ8GRZUI1sEyC7fdiU4TxMTH28OdyT8naJbxy91XMwZD6c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841660; 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=2/LRt01+eEG0RC09vGzKXREvrvgUJopnQM/vveJrCdc=; b=IeOPqE68tif0gYow+vbmc5H9RX4dYbPxVsmvEp0o4/FBu10M+vwAcPHdWotiOebWrvhoTzNYoskyP38+k7GihFlLSpeM6vnonvT6lv0IrBVkRt4zILTSSukdL2eQhIuuxxwnRB6UzDqWRaoOp4yeklSVjESwGcMuev+91sEaTnk= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841660374636.3630767903644; Thu, 20 Jul 2023 01:27:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566465.885311 (Exim 4.92) (envelope-from ) id 1qMP08-0002Or-Gu; Thu, 20 Jul 2023 08:27:08 +0000 Received: by outflank-mailman (output) from mailman id 566465.885311; Thu, 20 Jul 2023 08:27:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP08-0002Oe-Df; Thu, 20 Jul 2023 08:27:08 +0000 Received: by outflank-mailman (input) for mailman id 566465; Thu, 20 Jul 2023 08:27:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP06-0001wC-Oa for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:27:06 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 343663dd-26d7-11ee-8611-37d641c3527e; Thu, 20 Jul 2023 10:27:04 +0200 (CEST) Received: from mail-co1nam11lp2172.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.172]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:27:02 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:27:00 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:27:00 +0000 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: 343663dd-26d7-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841624; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=PoGS6PLKgGovzFPQKOOfY9Pvlc4ex9V0H8gcinS47Ag=; b=Gt+mtOs3pvo+T0qyH3SMcqraOHRFPeaomUo1zWRO8TB13SFiJMz1zDZW JOX7OslVKmaBpoBSXMTZSQ+QwlR37UH354P4JOC+KLSwZi3fbgxzY+z0P PHEz/T1wsBLDtfXdIhc01JZ4rRHJ4NZMT+dQRIbyBNKfsd35O+lIhOAl0 g=; X-IronPort-RemoteIP: 104.47.56.172 X-IronPort-MID: 115538996 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:e+gJrKLBCU7Ynob6FE+R9ZQlxSXFcZb7ZxGr2PjKsXjdYENS1zADy mYdWmzTaPzeM2L8ftB1OYq380wA7cPRm4I3HVdlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA4QZmPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5lE1Bt9 OIcNwsxRR+niNDmnbOiTLZz05FLwMnDZOvzu1lG5BSAVLMNZsmGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dppTGMlmSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iv127KUzXKqBur+EpW27OBBnkXJ+lUPGR48CFaCm/eHmG6xDoc3x 0s8v3BGQbIJ3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQAsUTppeNEg8sgsSlQC1 FCTmMjyLSdyq7DTQnWYnop4thu3MCkRaGQFPCkNSFJc58G5+d5pyBXSUtxkDai5yMXvHi39y CyLqy54gKgPickM1OOw+lWvby+Qm6UlhzUdvm3/Nl9JJCsgDGJ5T+REMWTm0Ms= IronPort-HdrOrdr: A9a23:1yX65KjIUoG+zzZtwIv9hhCeVHBQXtkji2hC6mlwRA09TyVXrb HIoB17726TtN91YhsdcL+7Scq9qB/nlaKdgrNxAV7BZniFhILAFugLhrcKqAeQfhEWmNQtsZ uIsJITNDQzNzVHZArBjzVQ2uxP/OW6 X-Talos-CUID: =?us-ascii?q?9a23=3ABPhhamu6pzRLu9ijtnUMK3ZD6Is3YEz+zWnUPHS?= =?us-ascii?q?EImlNR4/FFF6J/vx7xp8=3D?= X-Talos-MUID: 9a23:9JI9gARcABS1sRlkRXTini9JKt8y352yGUMnzJg/gce6Jwx/bmI= X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="115538996" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CCRXOicWHAj9nEam5AAl05SmfyylXnGj50Fi3ENH8ZfEu97VZIfuDVJQd2+n5KyxTJiG1zr/+7VZkCdUgHJ25gp8zxHsIVnLDQBdWPbmdK+IxIZaFVd7hnwAl7TZSl/wiVYzIZLya89RfdDDyS6jGEgn/tQGORnzS65VLODcRTTpieH28jxvtENsM6oq+2L7hZQOxNRmw5RGlhGtDsA+esif5glkEf4IKFK+QF3b4IZ0ZOV23lRkMnn8HAGYQNb+uBA894cLcCJp5b5rfQ/fj2E9+c4CLBhcaOrVMZsczuKLojOt4h9DcMvCfXZBYeAm5txf9Oy7Uo1BL7MS794ZgA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2/LRt01+eEG0RC09vGzKXREvrvgUJopnQM/vveJrCdc=; b=JcBDwyO6+8HV7w1+UryyI7sTqZfEy98ACBit3u3og6bcectR8wcd+RsWPSm68egGoRkw6iujZbGkEocgr91gxsiAPMjNTTCOvbHTFb229/VyNFIGHZCcyN92ud2NxuCfbVAuUlJC57KVJ4ifRSMRFUq2WCYg0c/LFIuw6zY1SjfL6w4++KIJn/00sPoP91MOE+g1d4mOrZseLkeFmQIUxS2V3ptlNeo7DU4uIGaQTAoiUHia6ADG67b6S8Hzjn4YvU7h+NBCaF2gn4weNwWWIe3Zhsm5rsxJyOjx54AvlQGyk/+kAVD71UbkkkHn6SEx97aWn6znJFG2/0RxhlM33w== 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=2/LRt01+eEG0RC09vGzKXREvrvgUJopnQM/vveJrCdc=; b=KvlmP9kLvbXZXMd9d2dnHQEDUM5IvH024MLWclhx3pkR1VDxyf9GjWyR+FvXDfpVtdNFDFmZZQ2T0+wn9B3+kwtXkjt1iSKCsHMhMFTkB9KbwDTM6Hcm2VMbRYXXpyG84v/+WMYM0w7ObxbLgDG2DKKkxOBdUreXlmCBXfH+tbU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 3/6] libxl: introduce MSR data in libxl_cpuid_policy Date: Thu, 20 Jul 2023 10:25:37 +0200 Message-ID: <20230720082540.69444-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO3P123CA0004.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:ba::9) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b1fa335-f0b2-40b0-b4fe-08db88fb168d X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mpJ5Ulom3cy8Aq5OQEZmw89hFhI9oKQxwCIaJCP9xKeffL6RNVFl5MVIvuxsaqiHzCjHub3YQ5/SieFvQ6vTEDDlKc3U2+iEWGKTVSNRrOhx8hZbF9Kko+xvLAE8UQ5hiWkuM/e9SXNf7YurWwD9tluBywTcSj7jBBkHS6Pg8fNdWdt88ARXQ18FpnhE2ktJnYLydZOc1++J8oLYi1dp20BfuX1fvHJsa293IYFmXcBv0PX+YrdSudm32/JWcg1+weVf3Opb2Dy/NcL1GbLabZ37VzmqMitGEAypuZIn2U90HiPtJ8MC53KXSiUUECvo83L7XermNFiL4FpH46jujvwYlBTqypZXL/hbJjQbjTLr6xVBiqxHr5hLe6PqAK1g5elPjqiukga9Dg9bine2Qk6LHTNqkLUisHNozZ9w1MDYOgNPg56hEOv3WbG8Pt15ZmXqtzCDOXQ91betB8qilbQJ1ZIDgFmhZolZ/8p82mWsxxsHccRgJ60jNKkUpj/3QGlbP8/A6K66L2FVRac31JcCBQ7XW0z7twsLw9dH+OfIWjoYc/lAGxnrShQfmnt3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(36756003)(5660300002);DIR:OUT;SFP:1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VlRmK21pTTdlT2lXQTVtQTNPSkwvZVFFOU13?= =?utf-8?B?K1VMM0JpOGl1N2dhaDQyYWRVemxncm0wQ3JDd0lNbEFqbHBtQ2Y2YTZwTitK?= =?utf-8?B?a1VLMitLUkRxMjUvd1Uva3FlbkRsMmRaTUdXU3kzbFM1b3FDb25wZWtuS2ZW?= =?utf-8?B?cVBSczlmSEhlN1F1ZWQ5cFhaS3JDVjNnRWlIS3h6WUFLd3VKdk42R25wNFFM?= =?utf-8?B?WDZxdUlzMzRJZlAwSmdnc3ZPcThHQVM1NnBLT2xRY0dsUkVVMUdRK2ZhRTds?= =?utf-8?B?MStwQi9aN0RGUEtBSmgyejdmQ3dwQzhKWU1xMVpjNXBMMytuOGxhVm05M3Ny?= =?utf-8?B?cjRkbThqeVBPcnY1bjNVTkJKMzJxSDltZ29BeWlqRTRBdDdJemx4UFFGbERI?= =?utf-8?B?c3hVck1HMnFOaWFqcXJuTjF2bjFGMEdubXNxTzV1eGl6MlNRbVdtVFE4MGxz?= =?utf-8?B?MkE9PQ==?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VG7vtKK5icSJxQE37R0XmUdgLsTke1C6DQ0IiJA+KXqNSR+XYBEQHzBbX257hiqh/MipLzVFfX3K/SP9q9OdNMzygNiTmoJ7qZdUJfR/aWX6mXZYzMyJLecTDmaaaR7yk9gGbfLh+72jdnjCifSh67z5o15x9z6yxYVCtZuerCZe221sOfQxhNXkI81XW49KhW5YDsnbIPgPQAXkKtmAn0a0BqErXuXxXhKyFOs6blDKpQ/v4PE0+Lbdx8Md+I/SigzMrd5UNRlfqF690InPfZJQzIbxlS1fAQMZcx5fk3og17kBRI4pphwHjj7geBxoeKXjlwpiFdG34UOYb/4eAOgMHv/88/UXJclVoeQgMpKCM1njCu/QR5brCe+uuvmtyTFIcdACVCUAnaukXoCDeJo4NxXZFcPpgimb/tYO8/t53v35SgYvaYCW2cYhyleAZA2H9jlaZJj9NbSBl2NFbZTLCBQAs5uC6SdSduSTXTgr976LZdQAjdE5TifKq2VofhwO+ct/DafSvU9aP1xpU9WfqCyn/D92hxtRDQKBVDYjWUf22Jg1n9ZxAJm/t17yPxMEhWrxt82kZvKF0+wJ+IL3ILuBIIE7X0OS9A8sNsxogLjyh9RrJEQH40IeHNptFdCW23GgZrLcAauriTzYRn1kgtuFJpv6abLPbB4JE3rNRd+NANOrFjHk22pWxHIHql5f7AODDnLFpAHsVrEM6/ui+tn35PxGqJBmWqQPSZJA2hwSqTxDGsw/tAZmIdsbUShdtsesanTFbdFVe/nmelSxfq07FFUSG7zHrqmK7hhukHFz7qJNkLmuMb9K6IW1 X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b1fa335-f0b2-40b0-b4fe-08db88fb168d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:27:00.0946 (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: /ZyCqlIVpX1OMka4s1N2f7nNp13P37W2t7QFjQhIuaOrQkrCrV0kIqEnpxEAWh/mXq03wgv+dsU4+uQAjouiHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841661434100001 Add a new array field to libxl_cpuid_policy in order to store the MSR policies. Adding the MSR data in the libxl_cpuid_policy_list type is done so that existing users can seamlessly pass MSR features as part of the CPUID data, without requiring the introduction of a separate domain_build_info field, and a new set of handlers functions. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v2: - Unconditionally call free(). - Implement the JSON marshaling functions. --- It would be nice to rename the json output field to 'cpu_policy' instead of 'cpuid', so that it looks like: "cpu_policy": { "cpuid": [ { "leaf": 7, "subleaf": 0, "edx": "xx1xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "leaf": 1, "ebx": "xxxxxxxxxxxxxxxx00010000xxxxxxxx" } } } ], "msr": [ { "index": 266, "policy": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx= xxxxxx1xx1x1" } ] }, Sadly I have no idea how to do that, and can be done in a followup change anyway. --- tools/libs/light/libxl_cpuid.c | 142 ++++++++++++++++++++++++++---- tools/libs/light/libxl_internal.h | 1 + tools/libs/light/libxl_types.idl | 2 +- 3 files changed, 128 insertions(+), 17 deletions(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 3c8b2a72c0b8..68b797886642 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -16,7 +16,7 @@ =20 int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) { - return !libxl_cpuid_policy_list_length(pl); + return !*pl || (!libxl_cpuid_policy_list_length(pl) && !(*pl)->msr); } =20 void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl) @@ -40,6 +40,8 @@ void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl) free(policy->cpuid); } =20 + free(policy->msr); + free(policy); *pl =3D NULL; return; @@ -516,7 +518,8 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,= bool restore, =20 r =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, pae, itsc, nested_virt, - info->cpuid ? info->cpuid->cpuid : NULL, NUL= L); + info->cpuid ? info->cpuid->cpuid : NULL, + info->cpuid ? info->cpuid->msr : NULL); if (r) LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy"); =20 @@ -528,16 +531,22 @@ static const char *input_names[2] =3D { "leaf", "subl= eaf" }; static const char *policy_names[4] =3D { "eax", "ebx", "ecx", "edx" }; /* * Aiming for: - * [ - * { 'leaf': 'val-eax', - * 'subleaf': 'val-ecx', - * 'eax': 'filter', - * 'ebx': 'filter', - * 'ecx': 'filter', - * 'edx': 'filter' }, - * { 'leaf': 'val-eax', ..., 'eax': 'filter', ... }, - * ... etc ... - * ] + * { 'cpuid': [ + * { 'leaf': 'val-eax', + * 'subleaf': 'val-ecx', + * 'eax': 'filter', + * 'ebx': 'filter', + * 'ecx': 'filter', + * 'edx': 'filter' }, + * { 'leaf': 'val-eax', ..., 'eax': 'filter', ... }, + * ... etc ... + * ], + * 'msr': [ + * { 'index': 'val-index', + * 'policy': 'filter', }, + * ... etc ... + * ], + * } */ =20 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand, @@ -545,9 +554,16 @@ yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_= gen hand, { libxl_cpuid_policy_list policy =3D *pl; struct xc_xend_cpuid *cpuid; + struct xc_msr *msr; yajl_gen_status s; int i, j; =20 + s =3D yajl_gen_map_open(hand); + if (s !=3D yajl_gen_status_ok) goto out; + + s =3D libxl__yajl_gen_asciiz(hand, "cpuid"); + if (s !=3D yajl_gen_status_ok) goto out; + s =3D yajl_gen_array_open(hand); if (s !=3D yajl_gen_status_ok) goto out; =20 @@ -582,6 +598,39 @@ yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_= gen hand, =20 empty: s =3D yajl_gen_array_close(hand); + if (s !=3D yajl_gen_status_ok) goto out; + + s =3D libxl__yajl_gen_asciiz(hand, "msr"); + if (s !=3D yajl_gen_status_ok) goto out; + + s =3D yajl_gen_array_open(hand); + if (s !=3D yajl_gen_status_ok) goto out; + + if (!policy || !policy->msr) goto done; + msr =3D policy->msr; + + for (i =3D 0; msr[i].index !=3D XC_MSR_INPUT_UNUSED; i++) { + s =3D yajl_gen_map_open(hand); + if (s !=3D yajl_gen_status_ok) goto out; + + s =3D libxl__yajl_gen_asciiz(hand, "index"); + if (s !=3D yajl_gen_status_ok) goto out; + s =3D yajl_gen_integer(hand, msr[i].index); + if (s !=3D yajl_gen_status_ok) goto out; + s =3D libxl__yajl_gen_asciiz(hand, "policy"); + if (s !=3D yajl_gen_status_ok) goto out; + s =3D yajl_gen_string(hand, + (const unsigned char *)msr[i].policy, 64); + if (s !=3D yajl_gen_status_ok) goto out; + + s =3D yajl_gen_map_close(hand); + if (s !=3D yajl_gen_status_ok) goto out; + } + +done: + s =3D yajl_gen_array_close(hand); + if (s !=3D yajl_gen_status_ok) goto out; + s =3D yajl_gen_map_close(hand); out: return s; } @@ -592,17 +641,24 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, { int i, size; struct xc_xend_cpuid *l; + struct xc_msr *msr; + const libxl__json_object *co; flexarray_t *array; =20 - if (!libxl__json_object_is_array(o)) + if (!libxl__json_object_is_map(o)) return ERROR_FAIL; =20 - array =3D libxl__json_object_get_array(o); + co =3D libxl__json_map_get("cpuid", o, JSON_ARRAY); + if (!libxl__json_object_is_array(co)) + return ERROR_FAIL; + + *p =3D libxl__calloc(NOGC, 1, sizeof(**p)); + + array =3D libxl__json_object_get_array(co); if (!array->count) - return 0; + goto cpuid_empty; =20 size =3D array->count; - *p =3D libxl__calloc(NOGC, 1, sizeof(**p)); /* need one extra slot as sentinel */ l =3D (*p)->cpuid =3D libxl__calloc(NOGC, size + 1, sizeof(struct xc_xend_cpuid)); @@ -642,6 +698,40 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc, } } =20 +cpuid_empty: + co =3D libxl__json_map_get("msr", o, JSON_ARRAY); + if (!libxl__json_object_is_array(co)) + return ERROR_FAIL; + + array =3D libxl__json_object_get_array(co); + if (!array->count) + return 0; + size =3D array->count; + /* need one extra slot as sentinel */ + msr =3D (*p)->msr =3D libxl__calloc(NOGC, size + 1, sizeof(struct xc_m= sr)); + + msr[size].index =3D XC_MSR_INPUT_UNUSED; + + for (i =3D 0; i < size; i++) { + const libxl__json_object *t, *r; + + if (flexarray_get(array, i, (void**)&t) !=3D 0) + return ERROR_FAIL; + + if (!libxl__json_object_is_map(t)) + return ERROR_FAIL; + + r =3D libxl__json_map_get("index", t, JSON_INTEGER); + if (!r) return ERROR_FAIL; + msr[i].index =3D libxl__json_object_get_integer(r); + r =3D libxl__json_map_get("policy", t, JSON_STRING); + if (!r) return ERROR_FAIL; + if (strlen(libxl__json_object_get_string(r)) !=3D + ARRAY_SIZE(msr[i].policy) - 1) + return ERROR_FAIL; + strcpy(msr[i].policy, libxl__json_object_get_string(r)); + } + return 0; } =20 @@ -677,6 +767,10 @@ void libxl_cpuid_policy_list_copy(libxl_ctx *ctx, } =20 *pdst =3D libxl__calloc(NOGC, 1, sizeof(**pdst)); + + if (!(*psrc)->cpuid) + goto copy_msr; + dst =3D &(*pdst)->cpuid; src =3D &(*psrc)->cpuid; len =3D libxl_cpuid_policy_list_length(psrc); @@ -696,6 +790,22 @@ void libxl_cpuid_policy_list_copy(libxl_ctx *ctx, (*dst)[i].policy[j] =3D NULL; } =20 +copy_msr: + if ((*psrc)->msr) { + const struct xc_msr *msr =3D (*psrc)->msr; + + for (i =3D 0; msr[i].index !=3D XC_MSR_INPUT_UNUSED; i++) + ; + len =3D i; + (*pdst)->msr =3D libxl__calloc(NOGC, len + 1, sizeof(struct xc_msr= )); + (*pdst)->msr[len].index =3D XC_MSR_INPUT_UNUSED; + + for (i =3D 0; i < len; i++) { + (*pdst)->msr[i].index =3D msr[i].index; + strcpy((*pdst)->msr[i].policy, msr[i].policy); + } + } + out: GC_FREE; } diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index ef882cff3912..b1a7cd9f615b 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -4871,6 +4871,7 @@ _hidden int libxl__domain_set_paging_mempool_size( =20 struct libxl__cpu_policy { struct xc_xend_cpuid *cpuid; + struct xc_msr *msr; }; =20 #endif diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 9e48bb772646..887824fdd828 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -19,7 +19,7 @@ libxl_mac =3D Builtin("mac", json_parse_type=3D"JSON_STRI= NG", passby=3DPASS_BY_REFEREN libxl_bitmap =3D Builtin("bitmap", json_parse_type=3D"JSON_ARRAY", dispose= _fn=3D"libxl_bitmap_dispose", passby=3DPASS_BY_REFERENCE, check_default_fn=3D"libxl_bitmap_is_empty", copy_fn= =3D"libxl_bitmap_copy_alloc") libxl_cpuid_policy_list =3D Builtin("cpuid_policy_list", dispose_fn=3D"lib= xl_cpuid_dispose", passby=3DPASS_BY_REFERENCE, - json_parse_type=3D"JSON_ARRAY", check_de= fault_fn=3D"libxl__cpuid_policy_is_empty", + json_parse_type=3D"JSON_MAP", check_defa= ult_fn=3D"libxl__cpuid_policy_is_empty", copy_fn=3D"libxl_cpuid_policy_list_copy") =20 libxl_string_list =3D Builtin("string_list", dispose_fn=3D"libxl_string_li= st_dispose", passby=3DPASS_BY_REFERENCE, --=20 2.41.0 From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841661; cv=pass; d=zohomail.com; s=zohoarc; b=SauQw4zyykwxrylh7AHkFiiMIDrJiQXfb1Ezgp/CmjPMSd91gO9AJfhvKTyaAqvs88J9whtIMYUY1IOHveZWw5fVuDfcuWNdtgSDtnMS1xYi8qfYHot4MljTQG06lZe+0BwNMSjO9oFyHNfufYDLgkQQTKfjAdusvr78vz1PxEk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841661; 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=LHmNVAJhwJyrZMNRZ2DJFQDWxfGyOuELk3JbP/xrT3Q=; b=dr9zQ8m7usUJCdmS5XtUZz+EVQ4Hex4SoH2n4mdTftvRRcd/+GTZCmYiUZs3e/gIycFSLT3aqDRnXSPR5gz8g5h8qpW3qVhOSs072tB5OmAw1eyez+w1WWJRWfQ6CZYc4jhbb0JKisEtgi/xRt3jd++6t4baysSFouljejyLPeE= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841661707535.3138904685179; Thu, 20 Jul 2023 01:27:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566467.885321 (Exim 4.92) (envelope-from ) id 1qMP0E-0002pd-Qj; Thu, 20 Jul 2023 08:27:14 +0000 Received: by outflank-mailman (output) from mailman id 566467.885321; Thu, 20 Jul 2023 08:27:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0E-0002pU-NO; Thu, 20 Jul 2023 08:27:14 +0000 Received: by outflank-mailman (input) for mailman id 566467; Thu, 20 Jul 2023 08:27:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0D-0001wC-1W for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:27:13 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 37ecb9dd-26d7-11ee-8611-37d641c3527e; Thu, 20 Jul 2023 10:27:10 +0200 (CEST) Received: from mail-co1nam11lp2177.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.177]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:27:08 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:27:06 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:27:06 +0000 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: 37ecb9dd-26d7-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841630; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=z60meDtNx5jYvrY40BCNAM50IKsscj3nDQMwXvAX/mA=; b=cgr0S3a3lVFKsggm+jCO+CsRJfpIEIqeWmDkDNJMSxgQzCnz1TasDm9V ba5XReiP6di1n0u/mnpxK3qbisuTXxeMjf2klOklgG8AG53PEJqHFC9nD XDXjWeN5uwCGn0JyiN5LUyx7pFp+pE07SqMLXc0x5Z1qiQgCC5VoVqlWU g=; X-IronPort-RemoteIP: 104.47.56.177 X-IronPort-MID: 117268389 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:bgTMGK+xD0RiahemH4MiDrUDpH+TJUtcMsCJ2f8bNWPcYEJGY0x3n WcbXm+FbKneamP3LdByO4XipBlXucPTnYUwTwVuqSA8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks21BjOkGlA5AdmOqoT5Aa2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkly0 fsRKB8IVSnArOjx6au6R+BPitwaeZyD0IM34hmMzBn/JNN/GNXoZPyP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWNilUuj9ABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prraWwnmlCNlCRdVU8NZx0We842oMJSQoFhi5+9+mpXGVeOpmf hl8Fi0G6PJaGFaQZsnwWVi0rWCJujYYWsFMCKsq5QeV0K3W7g2FQG8eQVZpd9gOpMIwAzsw2 TehndzzAid0mKaIUn/b/bCRxQ5eIgAQJG4GICQDFA0M5oC6pJlp102QCNF+DKSyk9v5Xynqx CyHpzQ/gLNVitMX06K8/hbMhDfESoX1czPZLz7/BgqNhj6Vrqb8D2B0wTA3Ncp9Ebs= IronPort-HdrOrdr: A9a23:nBjeYq2BMe/74PLoEs3yUgqjBLEkLtp133Aq2lEZdPWaSL3+qy nOpoV86faQslwssR4b6LO90cW7IU80lqQV3WByB8bBYOCOggLBR72KhrGSpgEIdReOktK1Fp 0NT0G9MrDN5JRB4voSKTPXL+od X-Talos-CUID: 9a23:OguAtWxLYquZAFr0Eul9BgUoPscsclLY906TCEX/IH9oRbS2RUeprfY= X-Talos-MUID: 9a23:ymgbAQSmvgrALLRcRXT31QtNEcF3zp2QSwMPy7MZlPavFhRJbmI= X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="117268389" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuvGwHQlA5KWywFZDsOTo8OIOgG+1uQR8+iS/1C60frKPgdsrVL6KipGBr6dvxPYLriufKBfA98QS07p962U1BFT9PhfHVqVbc2eD6+NhVsw3u/NYIL3WjZzfhY/kLVVwHX7wUo1abNmnhuUUBHbC0/CAOxvWMNOeSeepCWSsM1iyhVjjfmEYW+E+9BAzM16MrHhBNmTChoq/DapjhrxUZm7jOLwgp3F6++e7z5XKqSc9PTrk8vlY07J4RL3TecmYzCilnrmw7tMh6TYDbrD3qts15aapuz+20Z4L71DDrI+5pljUJGF6L7fDVXJ0L8jQb02dry5PVbm3S8ac9X/dw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LHmNVAJhwJyrZMNRZ2DJFQDWxfGyOuELk3JbP/xrT3Q=; b=FUvZcNT5+HPslFHGsngP2St3wqOGHowKZwVyDibpXsG5GechAYFk5zmDWRXbKdktnXQM/KTuXyzZuV+k5AqcaH2DR9dV7H+/vau4UMQFb6kkOyWfI4xE6vZv4FLHk1Qq+Frft/XBW0BnCPK2BxFqyP3rDR7l32CDwHhcS8ty8FeKkDgu4rE7ZWqwTCmLAW07WQlupITP6M5+5kKKaUa0f8pwX3wwL0J+NGyUH/FFGNWmHJcrAt4yjxqrww1Lv5uh9bI03aK8a4JhbonQrr1mHC06+ljy/cMg+7NgETx9Eeea9K+H/qWC+ZXGKoH/Q3HbZsF4YHKQ2QIRKE4V8VcL2Q== 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=LHmNVAJhwJyrZMNRZ2DJFQDWxfGyOuELk3JbP/xrT3Q=; b=sTJ2TlGasGqAilrAbMvGvMwSoRTuTY2LocyqtrqvqUETnH9m2Lke48NTLsgo5Dvq+zh3Ve8buhhJrm92UGKeeXz5qLU0Zfs/UYzrRJ3+E2hDjxFYcqEH0ssUXtZYkii1J8rcIjQmS86e49n+Cdzof2uhS2ABM1miAy2JqrJjZC4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 4/6] libxl: split logic to parse user provided CPUID features Date: Thu, 20 Jul 2023 10:25:38 +0200 Message-ID: <20230720082540.69444-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LNXP265CA0048.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::36) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: 93afaddc-7181-46a9-ed88-08db88fb19fa X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5A0nSjhlQ7AMcdRVHyK6Qpdp0UUN8UQ9ES0nmA0UJybYx6+QKMDf1MMAxpxUupONFu+soZbTekvdifVpftQ9qjbbxcjtlwgdoROzFR2Dq29iGZd+O3AgNMDHqZ4/ZlR60pDHVpt6LLve9ZiirgU7kqIJKn9qBWiiT/GgfYhDpkzYcV4GHWqQ0DsakSIMB2rBWJEa0HK+nndkFKZ/qcsazMgoBa1MKuztF/3sAjzcuDpcQNmQtJVuCWv1fibG7jqPP/41oY92kgQExdCNS165fDHKkBbIWZy21+6K3ubbDJ/IxGk0wfjTmLOzFlIS80h/eli54uAuv6y89afJYtvcwxTU2RaggxLAmpx7HOgMrhvKa0e8hTxns8b6xWfyp+ezQJ6g6+kJSPPDKNMXZFaSqituBF4R5bp9QNd8AA+00el3Bo2fPGTw3Gb8JR2EsfeBXMVyb+Luhh+cdp5VAk2ukifDQPe8Sxup3Dwy1Gt1NxXFPo6KtryYrnaHZoBwW5r8d3SckZ+wW55S8g+zHsz1bDIu3dvDGmfA141VapEKgZ2HvwUNqok9nSVKa/4ObR/i X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Wk9RNjkrR1AxNGJDZEVIOGhPek5wRGljQ3ZJa1NVbjI4M0p4NHdZeVJrWUNZ?= =?utf-8?B?STY0dEtkRlZUWEpSR0JOQi9Ra1BMZlBuMEFYbmhwNmhGRXdPejlnQlNiTXhB?= =?utf-8?B?TGFyakZMLzhoYjIrYjNieVQ0YUhNdW1xZWxTK1FCUEdGU0RtUGFJdmZLNGZ5?= =?utf-8?B?blZsakQ2RGFxVW5aMVM5WnRhc1pMT2c5Q2ljT0hYdElFWUg5ZFRmSEZ5V2NN?= =?utf-8?B?N3FTeUlPYnhLbHJrSWR3dWRzdGlhNTc3RUY4RWN3ZFB2SWFEcWRhWWdxdkJl?= =?utf-8?B?MlpVNDBhU0Nab3dvYnoxdEQyWDJsMWxXV2c1dlFITmdLeXBVTTA4S2RQcmlu?= =?utf-8?B?NmhLWlZ2ZkpYanAwQ2NnSmFkWExqMGVqbGRpVG9hM0tJR04rL0JzZXdheVF3?= =?utf-8?B?ZEx0YSs0U0hNNzBnWTlSYlVvNmVHbHdCQTNJZFJQcmtxTUFVdFZydllZRmlz?= =?utf-8?B?c0g5VEhIVytvTnBZQ05FNEpaNElYN3NVRHVWamJZdXdCTkgwV1ZUV1ZVMzMx?= =?utf-8?B?dGRPeXZLTXV3d3dZNzBrSU05eVVSMVlmZGJtMFdjc0NTVkZtZy9sSFFrMk1M?= =?utf-8?B?Nm83ZTBJMThVSWErVmN0QTJrN1puQVphTUZyczhxVklPUzVuSFFXUHFjWlVV?= =?utf-8?B?MjBGTk9NQ0p5SnJucnpOQWZ6UFlxYk02VzBHRTJwVm9HRjlKb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nzA360TB7/kAMA5ZDFVbv+pDZJ0dUVr/dJ1wsW8IXYF07bcIP1mPyWqR2q7hfDAebeCJruO7zlWzy5x5ZUtLGHwktjmVfuCKgNWfgaEPl9OsG6M+O/f9eP2L8z5rB0gtUs3nOFfY1e+hl1jlOWu6tZRx8XhH7AZSCMKO7iGJ7085d7CgMGM+qGXgAGTUL9jZGblpwyQ10EaR4AKILTRZBXtLiEWo00+jReySHqwKKr2BRZdNH4dHmVvqGxzB3gK090XE9ICuaGUMFvHtTmCsfXFjHHXGWAsIcsZSqEe2qmK6HZAD1y+sHvcHtJmUojVA57BpQCztbHV9LEiRopfppVtI9JvdTdiEO1i9WP4UrYJ+hijMvgKjoY7ve7KOA2zF4fsjTs8sP2DhM3A/4so86fSmxy8xEM7X/uo99WQRLyfsT2zUm/A9NMdZ4mgP5cP28+VgC0IVCUTWpbAOZg8H/G9mU3JV/uuztFkrYXHIWoERgWhQ4l8pZRbK6MVHCrWW2WQtcKpwHt4kiJfYiSS8xeuoYjtdOC0/8YDw9p X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93afaddc-7181-46a9-ed88-08db88fb19fa X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:27:06.3522 (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: acJ6znnuepME0E9GuGQTcsgDUqaYu88GxjdOHvCSBOixQGCbml74V6VRJnnVtSHTj3Akz65uaxNOP/4dM5UwLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841663580100001 Move the CPUID value parsers out of libxl_cpuid_parse_config() into a newly created cpuid_add() local helper. This is in preparation for also adding MSR feature parsing support. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Anthony PERARD --- tools/libs/light/libxl_cpuid.c | 120 +++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 68b797886642..c62247f9bda7 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -96,6 +96,66 @@ static struct xc_xend_cpuid *cpuid_find_match(libxl_cpui= d_policy_list *pl, return *list + i; } =20 +static int cpuid_add(libxl_cpuid_policy_list *policy, + const struct cpuid_flags *flag, const char *val) +{ + struct xc_xend_cpuid *entry =3D cpuid_find_match(policy, flag->leaf, + flag->subleaf); + unsigned long num; + char flags[33], *resstr, *endptr; + unsigned int i; + + resstr =3D entry->policy[flag->reg - 1]; + num =3D strtoull(val, &endptr, 0); + flags[flag->length] =3D 0; + if (endptr !=3D val) { + /* if this was a valid number, write the binary form into the stri= ng */ + for (i =3D 0; i < flag->length; i++) { + flags[flag->length - 1 - i] =3D "01"[!!(num & (1 << i))]; + } + } else { + switch(val[0]) { + case 'x': case 'k': case 's': + memset(flags, val[0], flag->length); + break; + default: + return 3; + } + } + + if (resstr =3D=3D NULL) { + resstr =3D strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + } + + /* the family and model entry is potentially split up across + * two fields in Fn0000_0001_EAX, so handle them here separately. + */ + if (!strcmp(flag->name, "family")) { + if (num < 16) { + memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4); + memcpy(resstr + (32 - 8) - 20, "00000000", 8); + } else { + num -=3D 15; + memcpy(resstr + (32 - 4) - flag->bit, "1111", 4); + for (i =3D 0; i < 7; i++) { + flags[7 - i] =3D "01"[num & 1]; + num >>=3D 1; + } + memcpy(resstr + (32 - 8) - 20, flags, 8); + } + } else if (!strcmp(flag->name, "model")) { + memcpy(resstr + (32 - 4) - 16, flags, 4); + memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4); + } else { + memcpy(resstr + (32 - flag->length) - flag->bit, flags, + flag->length); + } + entry->policy[flag->reg - 1] =3D resstr; + + return 0; + +} + /* parse a single key=3Dvalue pair and translate it into the libxc * used interface using 32-characters strings for each register. * Will overwrite earlier entries and thus can be called multiple @@ -340,12 +400,8 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *= policy, const char* str) {NULL, 0, NA, CPUID_REG_INV, 0, 0} }; #undef NA - char *sep, *val, *endptr; - int i; + const char *sep, *val; const struct cpuid_flags *flag; - struct xc_xend_cpuid *entry; - unsigned long num; - char flags[33], *resstr; =20 sep =3D strchr(str, '=3D'); if (sep =3D=3D NULL) { @@ -355,60 +411,10 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list = *policy, const char* str) } for (flag =3D cpuid_flags; flag->name !=3D NULL; flag++) { if(!strncmp(str, flag->name, sep - str) && flag->name[sep - str] = =3D=3D 0) - break; - } - if (flag->name =3D=3D NULL) { - return 2; - } - entry =3D cpuid_find_match(policy, flag->leaf, flag->subleaf); - resstr =3D entry->policy[flag->reg - 1]; - num =3D strtoull(val, &endptr, 0); - flags[flag->length] =3D 0; - if (endptr !=3D val) { - /* if this was a valid number, write the binary form into the stri= ng */ - for (i =3D 0; i < flag->length; i++) { - flags[flag->length - 1 - i] =3D "01"[!!(num & (1 << i))]; - } - } else { - switch(val[0]) { - case 'x': case 'k': case 's': - memset(flags, val[0], flag->length); - break; - default: - return 3; - } - } - - if (resstr =3D=3D NULL) { - resstr =3D strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + return cpuid_add(policy, flag, val); } =20 - /* the family and model entry is potentially split up across - * two fields in Fn0000_0001_EAX, so handle them here separately. - */ - if (!strncmp(str, "family", sep - str)) { - if (num < 16) { - memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4); - memcpy(resstr + (32 - 8) - 20, "00000000", 8); - } else { - num -=3D 15; - memcpy(resstr + (32 - 4) - flag->bit, "1111", 4); - for (i =3D 0; i < 7; i++) { - flags[7 - i] =3D "01"[num & 1]; - num >>=3D 1; - } - memcpy(resstr + (32 - 8) - 20, flags, 8); - } - } else if (!strncmp(str, "model", sep - str)) { - memcpy(resstr + (32 - 4) - 16, flags, 4); - memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4); - } else { - memcpy(resstr + (32 - flag->length) - flag->bit, flags, - flag->length); - } - entry->policy[flag->reg - 1] =3D resstr; - - return 0; + return 2; } =20 /* parse a single list item from the legacy Python xend syntax, where --=20 2.41.0 From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841684; cv=pass; d=zohomail.com; s=zohoarc; b=U6v/+wgCp7B+EedatBF4NcQxnZ2wTCGW9N5DyAwJ4Q4QFYUL8mq4lXDzkoZHAmcQC9VjopehrnxkULBVERdxcRQV1j757H1V6iTAibehbwVpIzkjRjU+z9+nzZ6wKAyCO8qByVkdXNh4yYYKZ/ju4husDGtuSwnN64lLZBJvVME= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841684; 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=Wr+vnLcTbPIrPgM1brYLYBaOkRLAS+kv/AjEfRMs/yA=; b=R8/hJpJLkNKpw+vgO6ZbKTb8nGFjJLUYgUE2ZU6e2u59kNO6b1jju2W57nI9bj3B1hPdjSkvLpy+Fh6yLPUJIX6el+2KDYaTHTgYENF2+ATK+0mntCSXMGIG4A/XSkJCYpupsHanMJf/rE3cLMY4hJAiVw9Q+IjVcxOCUEJ25gk= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841684963562.3607340850572; Thu, 20 Jul 2023 01:28:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566472.885331 (Exim 4.92) (envelope-from ) id 1qMP0K-0003TN-9z; Thu, 20 Jul 2023 08:27:20 +0000 Received: by outflank-mailman (output) from mailman id 566472.885331; Thu, 20 Jul 2023 08:27:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0K-0003Sm-4M; Thu, 20 Jul 2023 08:27:20 +0000 Received: by outflank-mailman (input) for mailman id 566472; Thu, 20 Jul 2023 08:27:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0J-0001O5-3I for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:27:19 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3bbd46d0-26d7-11ee-b23a-6b7b168915f2; Thu, 20 Jul 2023 10:27:17 +0200 (CEST) Received: from mail-co1nam11lp2175.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.175]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:27:14 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:27:12 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:27:12 +0000 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: 3bbd46d0-26d7-11ee-b23a-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841636; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=hoBKfo+TVeXY+Ru/Ne7C1tp93GStY9RqGnNdAfAsbTI=; b=dBdQOsY/2aLw9hemL5ispWK3r5U0KeYva90WpemlpK/P5S+VvtEuI3ee UQD7BKAh5qtclbSoEOA5vri32cTz/om45nL1SA8g83beSrAKH+kAWMQQZ 0qN/qJ/aNHQ0cPLJovWYfi4u2DoFIlm59tacgnrhhllQrJ0zgimX+Y7n2 g=; X-IronPort-RemoteIP: 104.47.56.175 X-IronPort-MID: 115539014 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: R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: =?us-ascii?q?9a23=3AtTtJAmjLgJVb3BN7g+LBUGYE/DJudUyB0k7uKlO?= =?us-ascii?q?CFkk0S4bNE1O64/9Vqp87?= X-Talos-MUID: 9a23:tpfqDAsNb6SjIEj78s2nrghaMvli2fuUMEk3kZlXhsekNyhqJGLI X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="115539014" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TMjjG6dTRwA2mOQPmxcTsZSbAP6OaTYtCfTE5hpLj6wBBNIQn6QIBpWI6+ZC2g58Ht+caQigl1dA9rxZpFWoCKefkiaq6VroVHa1IEOvvgce97R2bIpQ0Vmdzv9YTzABH4nQE/+WRc732y1HAg092ctYZWTMOLsGLq9fB7aZJY4dNZvki6g4l2oCvcmXf1+2mdiOV4do6aSULjgbuZWP91mcJt1rVXNhAQtlb0Ha/S7Oy5e/fKIuGOJ0gRT6uDQOG3PUBr3e6nmb+v8UqmqeMDXOS6eMq2ct4YLgE8UAFLP9jZ5t+j/hRJtmqbW0EQNZ74R5KEqPkjYHqVbQQ+ujrA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wr+vnLcTbPIrPgM1brYLYBaOkRLAS+kv/AjEfRMs/yA=; b=HBmXjtECMkpoM7Y81HgRtHNb4nyuoA0rpVaCAonA8fNfW7oxw3/py5r53oYHC5cpQoX3G7ExSBj+8dMq7x1kXON2N+fn8hr9UKmdsS0oROqAJ8JqtX4keT/snX27S5iMoLd/95XBKvCl3vxBsXIs2laU9ij2/k/CW+9E7OLS06DTSWQ6NGfS8eMo//xRCVi+0Vm3oi6abMMjn82pevJdAYOvMyQHnahfVpNehAaPOnG+7+9H4LeQ7OSJEaolqmeEuJsgx/gEBRY0Gb2lgriNLJ3wLJOz7IRIk1u6RLoPTPchlMECNgTpVjD+i9fmsWRBN+fpfSgFioShadmvymVE9w== 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=Wr+vnLcTbPIrPgM1brYLYBaOkRLAS+kv/AjEfRMs/yA=; b=Pq316CvbQUt1kwRczptQJR5fwzW0b4Uh/mJ3Utd6Eg6gfMiRGv2xxQ5ivxSjpLB9W9ezuBl4XfkEHumL3NopDZPT+Q9KyXEjcVZDzDL5pINu+aH30Wbekv4fkR931OUcNJBhTM2bwCiX+/Lm6C+8Nb3r0URcsQQrP9BJ0fo1OJ4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 5/6] libxl: use the cpuid feature names from cpufeatureset.h Date: Thu, 20 Jul 2023 10:25:39 +0200 Message-ID: <20230720082540.69444-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0005.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::17) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: cf93da26-1f04-49b6-6aea-08db88fb1dd3 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rMPDAU2mXHxOgRO6AcOxA65zM4UiKlggjYK2jmqgsc6i2vSRqCa9sH3gmNFHZi8xc+b2AuUPFsmMoXSqyk/7tgABtvXNh+rxv1BdyS4/oijboymruxa+im7rhCyaSt4ELM/vYgRoKlqr9eme149/38g/+gahCswmRR5R4Ynns5PLFZ/FBfkJ9o5Q8tI6cZAnqusGF1W7JjJQd6W9gpID6lq6wpPw0KlJHedfTc30JocDA0t8YpWEOtckF4X3gstPCqrOoqO+l8URQKGx9liqFJrKtlfG/Ro99jauX9hULTXRp3DGT/hi1q+oukYlcbqPbsoaeqpuzqtHe9h7f0zTAUleX7SPIwA+Y6VyVAfFqtiUyiFU3RhWS8eD2HkxP4i1K3JZIa7aDPVob8GIEGV5RqVHJbV9WcQ9GiFP0vMLndyj0NpbeX83sliCgzsoc92U2ptGi87LdrxjWK6bgkjF8dojibuxXKHMf9Uuhsae8VxO7FURjmgZc0Il77p/lgDNOFx8rW5ZswWxR12epEuYqlK/5nD2lNCYybtEyQDssS4iFFjVCx/ImxzA9Zg4JLjbZN+nn/y24wsp8dKBwUOZsQCob7PBM+KbbTgayy5fbjU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(30864003)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(66574015)(36756003)(5660300002)(473944003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UldmQUdJZkhEOVEvRHJ1TmUzVytmZHB5bFVmWmFJRkpHdmRaNFMrZ2lqK2pS?= =?utf-8?B?MC9PVXpzWDRiK1pNSllFZG9CeUFCUGpobSthd1JjRVRSMnNTb2VNQjdsZ0tP?= =?utf-8?B?dW52akNKV0dBb1NUOWxxVktXWU8xWlg2QkVqZWZjZkh5cGptckN4QnpmMVow?= =?utf-8?B?NlJwU1J1VVNndGh6R0c2K3JTOVNndWJrSmJQSUZDSDFKQW9MdlVBSzhaalNF?= =?utf-8?B?NnlkdEl5bnFaRENWTWNiNzA0aHpBUHdrZi9PV0U4TXFUbm1mL21velh3QitZ?= =?utf-8?B?dEFKaUNDSXVIeThNVC9ET2VJVnFQVkRXOFJPY1hXSXlmVFNodUxvL1huc0V0?= =?utf-8?B?WExLUmhyM2xwMHJRWVgxcXhYbG5YVFE4UDhZM2FtTkhodStJZGpiTnVZUFNm?= =?utf-8?B?dUdobnNiU0MrV3Z2Z2RVVlpvKzJkbUo4TnF0VzVtaTVKYU9Vejdxa0diZHY1?= =?utf-8?B?aGJocjRaSDJWQk5pNXFpTGFPTEFrem1qMXRiUExIaDhqemtPQWFMN1k0VklR?= =?utf-8?B?dTBrbFo5V2ZUOWZJSHFuMHlweTQ0S1dma21QQzluTFQvUlU2dEl4U0pLcS82?= =?utf-8?B?M3dtZFhqeldJUk4rbEs0Z1p1N2szVllRZVNXVVZ4Y3F0OFFwWTVQamJGSmxo?= =?utf-8?B?dUZXYzZSRjIyWDdjTm5rVEhMazQ0a2draHlxUjY2TnpIa3lteHcwU1h2cGx4?= =?utf-8?B?V1h3cE13bU8rTnNnbXIxNDRld2J6WGlTWU0xWVVDRzFIWTJqbXNiYTd6M3NW?= =?utf-8?B?TXQ4WmpOQ25aQlg5ZFU1MX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XhHiZnVw/tFcT4RVnGjKHNJOGnhgsgbgSP8yR1uv8gU9RPDHCOSzD8pFvclROEoSVDamQDIvNlRCsRXfEExvJias54NoD9dCkB+qVANqvQ2aQYzYQ2c9q8eiZt3TwY8dVGogiyF9d09LB0ic5StEGic1mx7NpTWSiL3aJhNmCwbRnMktHYDRC/FYtQ9AXRLsHyVtKTWDr/VjEqeXBgLt7jMb5KERrhP74SEHCBLX20NjMrBdduYdpX7iDEtkquWkWSDmY2Nl4M84+dxxILdPHgxDqbQ2+P/9XQBZ2KyhvfaIdfckKf0/3qTckOe23eX1Yubm47xx5RT4h4DfVmuqBAUstXvHP/ZHJ/123I166ymDmzWYO7xFY3lOY9cno0NCXkylkwlwkRgYdWGCilZOP7sFYmP5ZFib X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf93da26-1f04-49b6-6aea-08db88fb1dd3 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:27:12.4568 (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: GjMrPipxEm6LBF+8vqa5pwhUxuBukPU1O4GedNm9ih7x8Q+oNWHYTMKzZT1GPokV+Hr/OO7gNh9T3XxYZUGdmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841685716100001 The current implementation in libxl_cpuid_parse_config() requires keeping a list of cpuid feature bits that should be mostly in sync with the contents of cpufeatureset.h. Avoid such duplication by using the automatically generated list of cpuid features in INIT_FEATURE_NAMES in order to map feature names to featureset bits, and then translate from featureset bits into cpuid leaf, subleaf, register tuple. Note that the full contents of the previous cpuid translation table can't be removed. That's because some feature names allowed by libxl are not described in the featuresets, or because naming has diverged and the previous nomenclature is preserved for compatibility reasons. Should result in no functional change observed by callers, albeit some new cpuid features will be available as a result of the change. While there constify cpuid_flags name field. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Anthony PERARD --- Changes since v1: - const unnamed structure cast. - Declare struct feature_name outside the function. - Use strcmp. - Fix indentation. - Add back missing feature name options. - Return ERROR_NOMEM if allocation fails. - Improve xl.cfg documentation about how to reference the features described in the public header. --- docs/man/xl.cfg.5.pod.in | 24 +-- tools/libs/light/libxl_cpuid.c | 267 ++++++++++++--------------------- tools/xl/xl_parse.c | 3 + 3 files changed, 107 insertions(+), 187 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 3979be2a590a..55161856f4c7 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2010,24 +2010,16 @@ proccount procpkg stepping =20 =3Dback =20 -List of keys taking a character: +List of keys taking a character can be found in the public header file +L =20 -=3Dover 4 - -3dnow 3dnowext 3dnowprefetch abm acpi adx aes altmovcr8 apic arat avx avx2 -avx512-4fmaps avx512-4vnniw avx512bw avx512cd avx512dq avx512er avx512f -avx512ifma avx512pf avx512vbmi avx512vl bmi1 bmi2 clflushopt clfsh clwb cm= ov -cmplegacy cmpxchg16 cmpxchg8 cmt cntxid dca de ds dscpl dtes64 erms est ex= tapic -f16c ffxsr fma fma4 fpu fsgsbase fxsr hle htt hypervisor ia64 ibs invpcid -invtsc lahfsahf lm lwp mca mce misalignsse mmx mmxext monitor movbe mpx msr -mtrr nodeid nx ospke osvw osxsave pae page1gb pat pbe pcid pclmulqdq pdcm -perfctr_core perfctr_nb pge pku popcnt pse pse36 psn rdrand rdseed rdtscp = rtm -sha skinit smap smep smx ss sse sse2 sse3 sse4.1 sse4.2 sse4_1 sse4_2 sse4a -ssse3 svm svm_decode svm_lbrv svm_npt svm_nrips svm_pausefilt svm_tscrate -svm_vmcbclean syscall sysenter tbm tm tm2 topoext tsc tsc-deadline tsc_adj= ust -umip vme vmx wdt x2apic xop xsave xtpr +The feature names described in C should be specified in a= ll +lowercase letters, and with underscores converted to hyphens. For example= in +order to reference feature C the string C should be used. =20 -=3Dback +Note that C is described as an option that takes a value, and that +takes precedence over the C flag in C. The feat= ure +flag must be referenced as C. =20 =3Dback =20 diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index c62247f9bda7..f8b2e45ee681 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -14,6 +14,8 @@ =20 #include "libxl_internal.h" =20 +#include + int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl) { return !*pl || (!libxl_cpuid_policy_list_length(pl) && !(*pl)->msr); @@ -60,7 +62,7 @@ void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl) * Used for the static structure describing all features. */ struct cpuid_flags { - char* name; + const char *name; uint32_t leaf; uint32_t subleaf; int reg; @@ -153,7 +155,19 @@ static int cpuid_add(libxl_cpuid_policy_list *policy, entry->policy[flag->reg - 1] =3D resstr; =20 return 0; +} + +struct feature_name { + const char *name; + unsigned int bit; +}; + +static int search_feature(const void *a, const void *b) +{ + const char *key =3D a; + const char *feat =3D ((const struct feature_name *)b)->name; =20 + return strcmp(key, feat); } =20 /* parse a single key=3Dvalue pair and translate it into the libxc @@ -176,208 +190,42 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list= *policy, const char* str) {"proccount", 0x00000001, NA, CPUID_REG_EBX, 16, 8}, {"localapicid", 0x00000001, NA, CPUID_REG_EBX, 24, 8}, =20 - {"sse3", 0x00000001, NA, CPUID_REG_ECX, 0, 1}, - {"pclmulqdq", 0x00000001, NA, CPUID_REG_ECX, 1, 1}, - {"dtes64", 0x00000001, NA, CPUID_REG_ECX, 2, 1}, - {"monitor", 0x00000001, NA, CPUID_REG_ECX, 3, 1}, - {"dscpl", 0x00000001, NA, CPUID_REG_ECX, 4, 1}, - {"vmx", 0x00000001, NA, CPUID_REG_ECX, 5, 1}, - {"smx", 0x00000001, NA, CPUID_REG_ECX, 6, 1}, {"est", 0x00000001, NA, CPUID_REG_ECX, 7, 1}, - {"tm2", 0x00000001, NA, CPUID_REG_ECX, 8, 1}, - {"ssse3", 0x00000001, NA, CPUID_REG_ECX, 9, 1}, {"cntxid", 0x00000001, NA, CPUID_REG_ECX, 10, 1}, - {"fma", 0x00000001, NA, CPUID_REG_ECX, 12, 1}, {"cmpxchg16", 0x00000001, NA, CPUID_REG_ECX, 13, 1}, - {"xtpr", 0x00000001, NA, CPUID_REG_ECX, 14, 1}, - {"pdcm", 0x00000001, NA, CPUID_REG_ECX, 15, 1}, - {"pcid", 0x00000001, NA, CPUID_REG_ECX, 17, 1}, - {"dca", 0x00000001, NA, CPUID_REG_ECX, 18, 1}, /* Linux uses sse4_{1,2}. Keep sse4.{1,2} for compatibility */ {"sse4_1", 0x00000001, NA, CPUID_REG_ECX, 19, 1}, {"sse4.1", 0x00000001, NA, CPUID_REG_ECX, 19, 1}, {"sse4_2", 0x00000001, NA, CPUID_REG_ECX, 20, 1}, {"sse4.2", 0x00000001, NA, CPUID_REG_ECX, 20, 1}, - {"x2apic", 0x00000001, NA, CPUID_REG_ECX, 21, 1}, - {"movbe", 0x00000001, NA, CPUID_REG_ECX, 22, 1}, - {"popcnt", 0x00000001, NA, CPUID_REG_ECX, 23, 1}, - {"tsc-deadline", 0x00000001, NA, CPUID_REG_ECX, 24, 1}, {"aes", 0x00000001, NA, CPUID_REG_ECX, 25, 1}, - {"xsave", 0x00000001, NA, CPUID_REG_ECX, 26, 1}, - {"osxsave", 0x00000001, NA, CPUID_REG_ECX, 27, 1}, - {"avx", 0x00000001, NA, CPUID_REG_ECX, 28, 1}, - {"f16c", 0x00000001, NA, CPUID_REG_ECX, 29, 1}, - {"rdrand", 0x00000001, NA, CPUID_REG_ECX, 30, 1}, - {"hypervisor", 0x00000001, NA, CPUID_REG_ECX, 31, 1}, - - {"fpu", 0x00000001, NA, CPUID_REG_EDX, 0, 1}, - {"vme", 0x00000001, NA, CPUID_REG_EDX, 1, 1}, - {"de", 0x00000001, NA, CPUID_REG_EDX, 2, 1}, - {"pse", 0x00000001, NA, CPUID_REG_EDX, 3, 1}, - {"tsc", 0x00000001, NA, CPUID_REG_EDX, 4, 1}, - {"msr", 0x00000001, NA, CPUID_REG_EDX, 5, 1}, - {"pae", 0x00000001, NA, CPUID_REG_EDX, 6, 1}, - {"mce", 0x00000001, NA, CPUID_REG_EDX, 7, 1}, + {"cmpxchg8", 0x00000001, NA, CPUID_REG_EDX, 8, 1}, - {"apic", 0x00000001, NA, CPUID_REG_EDX, 9, 1}, {"sysenter", 0x00000001, NA, CPUID_REG_EDX, 11, 1}, - {"mtrr", 0x00000001, NA, CPUID_REG_EDX, 12, 1}, - {"pge", 0x00000001, NA, CPUID_REG_EDX, 13, 1}, - {"mca", 0x00000001, NA, CPUID_REG_EDX, 14, 1}, - {"cmov", 0x00000001, NA, CPUID_REG_EDX, 15, 1}, - {"pat", 0x00000001, NA, CPUID_REG_EDX, 16, 1}, - {"pse36", 0x00000001, NA, CPUID_REG_EDX, 17, 1}, {"psn", 0x00000001, NA, CPUID_REG_EDX, 18, 1}, {"clfsh", 0x00000001, NA, CPUID_REG_EDX, 19, 1}, - {"ds", 0x00000001, NA, CPUID_REG_EDX, 21, 1}, - {"acpi", 0x00000001, NA, CPUID_REG_EDX, 22, 1}, - {"mmx", 0x00000001, NA, CPUID_REG_EDX, 23, 1}, - {"fxsr", 0x00000001, NA, CPUID_REG_EDX, 24, 1}, - {"sse", 0x00000001, NA, CPUID_REG_EDX, 25, 1}, - {"sse2", 0x00000001, NA, CPUID_REG_EDX, 26, 1}, - {"ss", 0x00000001, NA, CPUID_REG_EDX, 27, 1}, - {"htt", 0x00000001, NA, CPUID_REG_EDX, 28, 1}, {"tm", 0x00000001, NA, CPUID_REG_EDX, 29, 1}, {"ia64", 0x00000001, NA, CPUID_REG_EDX, 30, 1}, {"pbe", 0x00000001, NA, CPUID_REG_EDX, 31, 1}, =20 {"arat", 0x00000006, NA, CPUID_REG_EAX, 2, 1}, =20 - {"fsgsbase", 0x00000007, 0, CPUID_REG_EBX, 0, 1}, {"tsc_adjust", 0x00000007, 0, CPUID_REG_EBX, 1, 1}, - {"bmi1", 0x00000007, 0, CPUID_REG_EBX, 3, 1}, - {"hle", 0x00000007, 0, CPUID_REG_EBX, 4, 1}, - {"avx2", 0x00000007, 0, CPUID_REG_EBX, 5, 1}, - {"smep", 0x00000007, 0, CPUID_REG_EBX, 7, 1}, - {"bmi2", 0x00000007, 0, CPUID_REG_EBX, 8, 1}, - {"erms", 0x00000007, 0, CPUID_REG_EBX, 9, 1}, - {"invpcid", 0x00000007, 0, CPUID_REG_EBX, 10, 1}, - {"rtm", 0x00000007, 0, CPUID_REG_EBX, 11, 1}, {"cmt", 0x00000007, 0, CPUID_REG_EBX, 12, 1}, - {"mpx", 0x00000007, 0, CPUID_REG_EBX, 14, 1}, - {"avx512f", 0x00000007, 0, CPUID_REG_EBX, 16, 1}, - {"avx512dq", 0x00000007, 0, CPUID_REG_EBX, 17, 1}, - {"rdseed", 0x00000007, 0, CPUID_REG_EBX, 18, 1}, - {"adx", 0x00000007, 0, CPUID_REG_EBX, 19, 1}, - {"smap", 0x00000007, 0, CPUID_REG_EBX, 20, 1}, - {"avx512-ifma", 0x00000007, 0, CPUID_REG_EBX, 21, 1}, - {"clflushopt", 0x00000007, 0, CPUID_REG_EBX, 23, 1}, - {"clwb", 0x00000007, 0, CPUID_REG_EBX, 24, 1}, - {"proc-trace", 0x00000007, 0, CPUID_REG_EBX, 25, 1}, - {"avx512pf", 0x00000007, 0, CPUID_REG_EBX, 26, 1}, - {"avx512er", 0x00000007, 0, CPUID_REG_EBX, 27, 1}, - {"avx512cd", 0x00000007, 0, CPUID_REG_EBX, 28, 1}, - {"sha", 0x00000007, 0, CPUID_REG_EBX, 29, 1}, - {"avx512bw", 0x00000007, 0, CPUID_REG_EBX, 30, 1}, - {"avx512vl", 0x00000007, 0, CPUID_REG_EBX, 31, 1}, - - {"prefetchwt1", 0x00000007, 0, CPUID_REG_ECX, 0, 1}, - {"avx512-vbmi", 0x00000007, 0, CPUID_REG_ECX, 1, 1}, - {"umip", 0x00000007, 0, CPUID_REG_ECX, 2, 1}, - {"pku", 0x00000007, 0, CPUID_REG_ECX, 3, 1}, - {"ospke", 0x00000007, 0, CPUID_REG_ECX, 4, 1}, - {"avx512-vbmi2", 0x00000007, 0, CPUID_REG_ECX, 6, 1}, - {"cet-ss", 0x00000007, 0, CPUID_REG_ECX, 7, 1}, - {"gfni", 0x00000007, 0, CPUID_REG_ECX, 8, 1}, - {"vaes", 0x00000007, 0, CPUID_REG_ECX, 9, 1}, - {"vpclmulqdq", 0x00000007, 0, CPUID_REG_ECX, 10, 1}, - {"avx512-vnni", 0x00000007, 0, CPUID_REG_ECX, 11, 1}, - {"avx512-bitalg",0x00000007, 0, CPUID_REG_ECX, 12, 1}, - {"avx512-vpopcntdq",0x00000007,0,CPUID_REG_ECX, 14, 1}, - {"rdpid", 0x00000007, 0, CPUID_REG_ECX, 22, 1}, - {"cldemote", 0x00000007, 0, CPUID_REG_ECX, 25, 1}, - {"pks", 0x00000007, 0, CPUID_REG_ECX, 31, 1}, - - {"avx512-4vnniw",0x00000007, 0, CPUID_REG_EDX, 2, 1}, - {"avx512-4fmaps",0x00000007, 0, CPUID_REG_EDX, 3, 1}, - {"fsrm", 0x00000007, 0, CPUID_REG_EDX, 4, 1}, - {"avx512-vp2intersect",0x00000007,0,CPUID_REG_EDX,8, 1}, - {"srbds-ctrl", 0x00000007, 0, CPUID_REG_EDX, 9, 1}, - {"md-clear", 0x00000007, 0, CPUID_REG_EDX, 10, 1}, - {"serialize", 0x00000007, 0, CPUID_REG_EDX, 14, 1}, - {"tsxldtrk", 0x00000007, 0, CPUID_REG_EDX, 16, 1}, - {"cet-ibt", 0x00000007, 0, CPUID_REG_EDX, 20, 1}, - {"avx512-fp16", 0x00000007, 0, CPUID_REG_EDX, 23, 1}, - {"ibrsb", 0x00000007, 0, CPUID_REG_EDX, 26, 1}, - {"stibp", 0x00000007, 0, CPUID_REG_EDX, 27, 1}, - {"l1d-flush", 0x00000007, 0, CPUID_REG_EDX, 28, 1}, - {"arch-caps", 0x00000007, 0, CPUID_REG_EDX, 29, 1}, - {"core-caps", 0x00000007, 0, CPUID_REG_EDX, 30, 1}, - {"ssbd", 0x00000007, 0, CPUID_REG_EDX, 31, 1}, - - {"avx-vnni", 0x00000007, 1, CPUID_REG_EAX, 4, 1}, - {"avx512-bf16", 0x00000007, 1, CPUID_REG_EAX, 5, 1}, - {"fzrm", 0x00000007, 1, CPUID_REG_EAX, 10, 1}, - {"fsrs", 0x00000007, 1, CPUID_REG_EAX, 11, 1}, - {"fsrcs", 0x00000007, 1, CPUID_REG_EAX, 12, 1}, - {"wrmsrns", 0x00000007, 1, CPUID_REG_EAX, 19, 1}, - {"avx-ifma", 0x00000007, 1, CPUID_REG_EAX, 23, 1}, - - {"avx-vnni-int8",0x00000007, 1, CPUID_REG_EDX, 4, 1}, - {"avx-ne-convert",0x00000007, 1, CPUID_REG_EDX, 5, 1}, - {"cet-sss", 0x00000007, 1, CPUID_REG_EDX, 18, 1}, - - {"intel-psfd", 0x00000007, 2, CPUID_REG_EDX, 0, 1}, - {"ipred-ctrl", 0x00000007, 2, CPUID_REG_EDX, 1, 1}, - {"rrsba-ctrl", 0x00000007, 2, CPUID_REG_EDX, 2, 1}, - {"ddp-ctrl", 0x00000007, 2, CPUID_REG_EDX, 3, 1}, - {"bhi-ctrl", 0x00000007, 2, CPUID_REG_EDX, 4, 1}, - {"mcdt-no", 0x00000007, 2, CPUID_REG_EDX, 5, 1}, =20 {"lahfsahf", 0x80000001, NA, CPUID_REG_ECX, 0, 1}, {"cmplegacy", 0x80000001, NA, CPUID_REG_ECX, 1, 1}, - {"svm", 0x80000001, NA, CPUID_REG_ECX, 2, 1}, - {"extapic", 0x80000001, NA, CPUID_REG_ECX, 3, 1}, {"altmovcr8", 0x80000001, NA, CPUID_REG_ECX, 4, 1}, - {"abm", 0x80000001, NA, CPUID_REG_ECX, 5, 1}, - {"sse4a", 0x80000001, NA, CPUID_REG_ECX, 6, 1}, - {"misalignsse", 0x80000001, NA, CPUID_REG_ECX, 7, 1}, - {"3dnowprefetch",0x80000001, NA, CPUID_REG_ECX, 8, 1}, - {"osvw", 0x80000001, NA, CPUID_REG_ECX, 9, 1}, - {"ibs", 0x80000001, NA, CPUID_REG_ECX, 10, 1}, - {"xop", 0x80000001, NA, CPUID_REG_ECX, 11, 1}, - {"skinit", 0x80000001, NA, CPUID_REG_ECX, 12, 1}, - {"wdt", 0x80000001, NA, CPUID_REG_ECX, 13, 1}, - {"lwp", 0x80000001, NA, CPUID_REG_ECX, 15, 1}, - {"fma4", 0x80000001, NA, CPUID_REG_ECX, 16, 1}, {"nodeid", 0x80000001, NA, CPUID_REG_ECX, 19, 1}, - {"tbm", 0x80000001, NA, CPUID_REG_ECX, 21, 1}, - {"topoext", 0x80000001, NA, CPUID_REG_ECX, 22, 1}, {"perfctr_core", 0x80000001, NA, CPUID_REG_ECX, 23, 1}, {"perfctr_nb", 0x80000001, NA, CPUID_REG_ECX, 24, 1}, =20 - {"syscall", 0x80000001, NA, CPUID_REG_EDX, 11, 1}, - {"nx", 0x80000001, NA, CPUID_REG_EDX, 20, 1}, - {"mmxext", 0x80000001, NA, CPUID_REG_EDX, 22, 1}, - {"ffxsr", 0x80000001, NA, CPUID_REG_EDX, 25, 1}, - {"page1gb", 0x80000001, NA, CPUID_REG_EDX, 26, 1}, - {"rdtscp", 0x80000001, NA, CPUID_REG_EDX, 27, 1}, - {"lm", 0x80000001, NA, CPUID_REG_EDX, 29, 1}, - {"3dnowext", 0x80000001, NA, CPUID_REG_EDX, 30, 1}, - {"3dnow", 0x80000001, NA, CPUID_REG_EDX, 31, 1}, - {"procpkg", 0x00000004, 0, CPUID_REG_EAX, 26, 6}, =20 {"invtsc", 0x80000007, NA, CPUID_REG_EDX, 8, 1}, =20 - {"clzero", 0x80000008, NA, CPUID_REG_EBX, 0, 1}, - {"rstr-fp-err-ptrs", 0x80000008, NA, CPUID_REG_EBX, 2, 1}, - {"wbnoinvd", 0x80000008, NA, CPUID_REG_EBX, 9, 1}, - {"ibpb", 0x80000008, NA, CPUID_REG_EBX, 12, 1}, - {"ibrs", 0x80000008, NA, CPUID_REG_EBX, 14, 1}, - {"amd-stibp", 0x80000008, NA, CPUID_REG_EBX, 15, 1}, - {"ibrs-always", 0x80000008, NA, CPUID_REG_EBX, 16, 1}, - {"stibp-always", 0x80000008, NA, CPUID_REG_EBX, 17, 1}, - {"ibrs-fast", 0x80000008, NA, CPUID_REG_EBX, 18, 1}, - {"ibrs-same-mode", 0x80000008, NA, CPUID_REG_EBX, 19, 1}, - {"no-lmsl", 0x80000008, NA, CPUID_REG_EBX, 20, 1}, {"ppin", 0x80000008, NA, CPUID_REG_EBX, 23, 1}, - {"amd-ssbd", 0x80000008, NA, CPUID_REG_EBX, 24, 1}, - {"virt-ssbd", 0x80000008, NA, CPUID_REG_EBX, 25, 1}, - {"ssb-no", 0x80000008, NA, CPUID_REG_EBX, 26, 1}, - {"psfd", 0x80000008, NA, CPUID_REG_EBX, 28, 1}, {"btc-no", 0x80000008, NA, CPUID_REG_EBX, 29, 1}, - {"ibpb-ret", 0x80000008, NA, CPUID_REG_EBX, 30, 1}, =20 {"nc", 0x80000008, NA, CPUID_REG_ECX, 0, 8}, {"apicidsize", 0x80000008, NA, CPUID_REG_ECX, 12, 4}, @@ -391,17 +239,63 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list = *policy, const char* str) {"svm_pausefilt",0x8000000a, NA, CPUID_REG_EDX, 10, 1}, =20 {"lfence+", 0x80000021, NA, CPUID_REG_EAX, 2, 1}, - {"nscb", 0x80000021, NA, CPUID_REG_EAX, 6, 1}, - {"auto-ibrs", 0x80000021, NA, CPUID_REG_EAX, 8, 1}, - {"cpuid-user-dis", 0x80000021, NA, CPUID_REG_EAX, 17, 1}, =20 {"maxhvleaf", 0x40000000, NA, CPUID_REG_EAX, 0, 8}, =20 {NULL, 0, NA, CPUID_REG_INV, 0, 0} }; + static const struct feature_name features[] =3D INIT_FEATURE_NAMES; + /* + * NB: if we switch to using a cpu_policy derived object instead of a + * libxl_cpuid_policy_list we could get rid of the featureset -> cpuid= leaf + * conversion table and use a featureset directly as we have conversio= ns + * to/from featureset and cpu_policy. + */ + static const struct { + enum { FEAT_CPUID, FEAT_MSR } type; + union { + struct { + uint32_t leaf, subleaf; + unsigned int reg; + } cpuid; + struct { + uint32_t index; + unsigned int reg; + } msr; + }; + } feature_to_policy[] =3D { +#define CPUID_ENTRY(l, s, r) \ + { .type =3D FEAT_CPUID, .cpuid.leaf =3D l, .cpuid.subleaf =3D s, .cpui= d.reg =3D r } +#define MSR_ENTRY(i, r) \ + { .type =3D FEAT_MSR, .msr.index =3D i, .msr.reg =3D r } + CPUID_ENTRY(0x00000001, NA, CPUID_REG_EDX), + CPUID_ENTRY(0x00000001, NA, CPUID_REG_ECX), + CPUID_ENTRY(0x80000001, NA, CPUID_REG_EDX), + CPUID_ENTRY(0x80000001, NA, CPUID_REG_ECX), + CPUID_ENTRY(0x0000000D, 1, CPUID_REG_EAX), + CPUID_ENTRY(0x00000007, 0, CPUID_REG_EBX), + CPUID_ENTRY(0x00000007, 0, CPUID_REG_ECX), + CPUID_ENTRY(0x80000007, NA, CPUID_REG_EDX), + CPUID_ENTRY(0x80000008, NA, CPUID_REG_EBX), + CPUID_ENTRY(0x00000007, 0, CPUID_REG_EDX), + CPUID_ENTRY(0x00000007, 1, CPUID_REG_EAX), + CPUID_ENTRY(0x80000021, NA, CPUID_REG_EAX), + CPUID_ENTRY(0x00000007, 1, CPUID_REG_EBX), + CPUID_ENTRY(0x00000007, 2, CPUID_REG_EDX), + CPUID_ENTRY(0x00000007, 1, CPUID_REG_ECX), + CPUID_ENTRY(0x00000007, 1, CPUID_REG_EDX), + MSR_ENTRY(0x10a, CPUID_REG_EAX), + MSR_ENTRY(0x10a, CPUID_REG_EDX), +#undef MSR_ENTRY +#undef CPUID_ENTRY + }; #undef NA const char *sep, *val; + char *name; const struct cpuid_flags *flag; + const struct feature_name *feat; + + BUILD_BUG_ON(ARRAY_SIZE(feature_to_policy) !=3D FEATURESET_NR_ENTRIES); =20 sep =3D strchr(str, '=3D'); if (sep =3D=3D NULL) { @@ -414,6 +308,37 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *= policy, const char* str) return cpuid_add(policy, flag, val); } =20 + /* Provide a NUL terminated feature name to the search helper. */ + name =3D strndup(str, sep - str); + if (name =3D=3D NULL) + return ERROR_NOMEM; + + feat =3D bsearch(name, features, ARRAY_SIZE(features), sizeof(features= [0]), + search_feature); + free(name); + + if (feat =3D=3D NULL) + return 2; + + switch (feature_to_policy[feat->bit / 32].type) { + case FEAT_CPUID: + { + struct cpuid_flags f; + + f.name =3D feat->name; + f.leaf =3D feature_to_policy[feat->bit / 32].cpuid.leaf; + f.subleaf =3D feature_to_policy[feat->bit / 32].cpuid.subleaf; + f.reg =3D feature_to_policy[feat->bit / 32].cpuid.reg; + f.bit =3D feat->bit % 32; + f.length =3D 1; + + return cpuid_add(policy, &f, val); + } + + case FEAT_MSR: + return 2; + } + return 2; } =20 diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index f036e56fc239..7bf587455d08 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2620,6 +2620,9 @@ skip_usbdev: case 3: errstr =3D "illegal CPUID value (must be: [0|1|x|k|s])= "; break; + case ERROR_NOMEM: + errstr =3D "out of memory"; + break; default: errstr =3D "unknown error"; break; --=20 2.41.0 From nobody Thu Nov 14 07:00:56 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=2; a=rsa-sha256; t=1689841670; cv=pass; d=zohomail.com; s=zohoarc; b=RA0yMW78SLUXBd/y5LrDQe8TJ6r4kJV+XEzraR6kC/ahr4qck5ofY6D+4msWL6ZBgF6ovUwPCc1vS2BNBJRyGQQQtP0KwlKSLkfqynJ9sRYwbgen4OKDdI2dZdV9eW+k3ubLI4sc9VQ4oaC6ys7uAg+Vu/N86btS6l8FNBIjxo0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689841670; 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=QaCpjdHP+ibZJJJugwXJB87F7i53rlocJEgAzu7noVg=; b=k9KTD4GhxkbcIy43FBpANk+Z+HTKSc0BW6GVZ25YzvbVjPHR4t94HlZiEMYDBaNDzvxvc2s1oF+EgDbmQ3wwnS/DGiW6qImkr1IC9xAWxD1UDd+o+84XzOL72D4BnG+DLSSnrye/kul3Ao3ye6brtqTTq4VN4k3OzkfmT88z8X0= 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=1 dmarc=pass fromdomain=citrix.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1689841670079413.6182198501273; Thu, 20 Jul 2023 01:27:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.566473.885341 (Exim 4.92) (envelope-from ) id 1qMP0N-000491-Pt; Thu, 20 Jul 2023 08:27:23 +0000 Received: by outflank-mailman (output) from mailman id 566473.885341; Thu, 20 Jul 2023 08:27:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0N-00048t-MC; Thu, 20 Jul 2023 08:27:23 +0000 Received: by outflank-mailman (input) for mailman id 566473; Thu, 20 Jul 2023 08:27:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qMP0M-0001O5-B3 for xen-devel@lists.xenproject.org; Thu, 20 Jul 2023 08:27:22 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3ed4a9ee-26d7-11ee-b23a-6b7b168915f2; Thu, 20 Jul 2023 10:27:21 +0200 (CEST) Received: from mail-co1nam11lp2171.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Jul 2023 04:27:20 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by SJ0PR03MB5760.namprd03.prod.outlook.com (2603:10b6:a03:2d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 08:27:18 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::38aa:4814:3c7b:78ea%5]) with mapi id 15.20.6588.031; Thu, 20 Jul 2023 08:27:18 +0000 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: 3ed4a9ee-26d7-11ee-b23a-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689841641; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=XXnoIEPy2cRhu/QaPgs1CH70iHB0p1XBTTphYXH3ckY=; b=fUqtaBg7dbb+MW1cYVfTs79b3jH+ikwnS/2rzpk6HI4bRZMpHpz/jxEZ +hxyAMYN1CYpHyg4f38UMOdKIdRNqF3Zv0UPVe7C76D3j1rmBUqmvhpb1 erABy+tKudbkkBQi35PaH4txHA7wEz66E62I8k1JpOApml0ubgP5oUuk3 g=; X-IronPort-RemoteIP: 104.47.56.171 X-IronPort-MID: 115539026 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:4UlgYa0HFF2en3nz3fbD5fdwkn2cJEfYwER7XKvMYLTBsI5bp2MDy WpKUDyCOfmCMGTzc9Anbt6/px8D7JXQyd5kTARopC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8XuDgNyo4GlD5gNkPagS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfHWd32 sA1GB00SQmOv9nm3quZZfkxr5F2RCXrFNt3VnBI6xj8VK9jareaBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxqvS6Kk1UZPLvFabI5fvSQQspYhACAr 3/u9GXlGBAKcteYzFJp91r137KSxnKjAtx6+LuQxuFJmU/Nx2IvCxQIZVeEq9qojkSRYocKQ 6AT0m90xUQoz2S7Q9+4UxCmrXqsuh8HR8EWA+A88BuKyKff/0CeHGdsZiFFQMwrsokxXzNC/ l2GhdTyHhR0raaYD3ma89+pQSiaPCEUKSoJYnYCRA5cut37+ths11TIU8ppF7OzgpvtAzbsz juWrS84wbIOkcoM0Kb99lfC696xmqX0oscOzl2/dgqYAslRPuZJu6TABYDn0Mt9 IronPort-HdrOrdr: A9a23:fL1lFKshDPKuy0WyK92XRQr37skDddV00zEX/kB9WHVpmwKj5q eTdZUgpHnJYVMqMk3I9urwW5VoLUm9yXcX2+gs1NWZLWvbUQKTRekI0WKI+UyEJ8SRzJ846U 6iScRD4R/LYGSSQfyU3OBwKbgd/OU= X-Talos-CUID: 9a23:61A2+WB6U8063gr6EzVhzWEoN/AIS1rEwU/rc1GhK0l5FZTAHA== X-Talos-MUID: =?us-ascii?q?9a23=3AY9eNzgyWYTz9ZOpmaj/DwmY1aTOaqJSxK1kfz5Q?= =?us-ascii?q?Ih8qNKxx8BD2+nTC9bbZyfw=3D=3D?= X-IronPort-AV: E=Sophos;i="6.01,218,1684814400"; d="scan'208";a="115539026" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K9lJFxO167n6DDG/X+8W77o03XjdwMfTH25MsP1ItfzF9bYR8/jxXfahRXYzZfK2ytHJmkQPP6cJNBG2TNKiUjauzrjYVVE+AXLZPP7Li7A8nAOdIbV8sdQ5TNsOnhJEaYv+DC2GfHILr8kRFJbqLS4Hc1LQlm9B9A9ZDBXLWI6BjxDL3l92SmRxzc6ev2N5wWo0BjHJoJVuQCf73HtPAeOY+u1L6exZqd+BWJJkk9kYzjBFlxCb/kLML+V5bVRp2DIcx8IqCck92g5wzhkiVo6mzGGcxtohjoz807mVlqUIBNO6mUXD1Tvptg8zHnWJtd7YAA8eAWUN56yyBiFu8g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QaCpjdHP+ibZJJJugwXJB87F7i53rlocJEgAzu7noVg=; b=m6zIfmosf83sMkJG5g3C/yFv+vC4ZMHeHu6aAIaiUEs42yeDvREBPxHl3VtSSN76X94rEOoRXxOZFKPwivRY0WmqD+3HxyCvVOHH1pjEG97PdC9e7N3x9O3FnhlDEgDPtFDeRxFId+TAigIlet0FqNmhgLp68CDQ+6Luesd0lggxnKCXd7JJSrqfDDbdkpn57OaMAUtvnQ7a8j134vbxtFjhtcZOApt6ZJUupsfXcgl0QNqJn/TzrpY2sIxJ2JPEviS3ILQBNMhaOEEcKoWM6L7I0Bf32OB3wCafo+id0EXkufVP4egpXZGMa+mFJbGXznBHlI8F23iREaydOR4/lQ== 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=QaCpjdHP+ibZJJJugwXJB87F7i53rlocJEgAzu7noVg=; b=KlNdtA4xKODJf/bo85J1PcuTSGO8ujKR1Ji31ZMG9kpmetNpGThh20ZO0V+b7mxNcmIX7DIy+otqYqaNL75Ekj33KJ0MZ5KtleFbVNE98N1GODJlc5zhz7b8ne39WA41cVmT24xn+4FwyyOixccc6wUjSyWPepCK8xg6vQvejh8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v3 6/6] libxl: add support for parsing MSR features Date: Thu, 20 Jul 2023 10:25:40 +0200 Message-ID: <20230720082540.69444-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230720082540.69444-1-roger.pau@citrix.com> References: <20230720082540.69444-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0172.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::15) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|SJ0PR03MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: 23918c70-e80c-41c6-9163-08db88fb212d X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UZ/5+VG0W5B/cQ28m9JCm6f0xj8EmIYZGhDi0dw05YQlR/kff3c2+t7pOeW3Z9ullDZwtPbhKUTjb+2tkG6zAm/YPl+pClTnA/ivNG3982dq/nt2DraTIWekQuQHLxuJi1sqWut7oNzz6msw7COmAb1Ly+TBDadqIYTg3HgXQs9z3ej+LW0qY1N16amA6tHQetYR/DmqT3rctUrP2iLAZy9FvuvFWb+4amMx7aGGskE9BwWu8a13jZIxwfMDgbA+554aK0lbv5mXoGig2n/OzOgZKx+T1BinMa1g70O+bsxMkIGZoXKkQyWS8WIVRqi+S/tuI3v8XnUz4rsycIq5VVtw8Brr+JXw1Nc1XUWkMuky9wK7V3/fyEgpQu1mDxdXYO+6kx787ku+b+4HweIfdqyGiAzb3xOdfJ3Si56wzxUr8bq2gdZjCp8Q2+O7ktubcM0efs/LeJDxCi9NV9zITWkffYkuUaQwBLTlLHYTJyaT0V77+3Aq3NSdYhRsOITjrG87aD9xkM4jqLv5lAytm8A8JUTdjRqkknKyBGf7hPZO9/aRlUmjUacDUsdtEara X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(86362001)(478600001)(83380400001)(1076003)(186003)(38100700002)(41300700001)(26005)(54906003)(6916009)(8676002)(8936002)(316002)(2906002)(4326008)(6512007)(66556008)(66946007)(6666004)(66476007)(6486002)(6506007)(82960400001)(2616005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bHk5TVdTblRZRTBqLzZQb0c1OTBxQ2hNcmxMNHVNL0NMNHhldE1zZjNsVUZj?= =?utf-8?B?empCZlF0TUpjYTVYT1Y4SnozU0RlbHZ1THhFS0ExMmlwY25pTXE0UDUvUmhE?= =?utf-8?B?VElVbitxVEhzMGlFWmxLbG1jSUIwMDBiZFozTnAvTlYyajFQMG4xSk04RC9P?= =?utf-8?B?Rk5OUVdrOThmSERiN3BMZ2VVb3ZhWUtOMlp2MXZrZW9XMkFoWGJlZEFseW96?= =?utf-8?B?TExpWWptUFRrUWpMellMbkZ5Mm02QmlLWkJONVFxdzhUSHp0M0Q2dHNIanZN?= =?utf-8?B?TEZJdWJJTDFwck5OU2VGN2wrWnh2MXZPUmZCbUl5ckFMNVhmaStieHBKRlBI?= =?utf-8?B?dEorMlVObXhOOFJrNWdiUkNaaU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FE9PQ==?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: oETtcmSLBn+41zQ06RcJyF5ymU2yCHOoEzfTWB42+3B4gJS3ezBg/q1VNN8ilWLDBGDeDuCa1Wjngb/SpzQNAGJ4gyg0W+6YnDcha4v6M8zUFRKVqRjuh129UGBM0rIysFYXSnEfdjVywqJ0/6uDIlozjMLwzRVaZtA45xS6YbIq4ndnOt3CmoRvbmQnLQnVlDPxoRdlVKnZ4kPq2WSXhTKSvBSQJZ2tJXmJzIaglA+pDH3Apnfk2erJs6Yji1SMcs6w4EuEdgREv3b3vGKieOu784kCtWfPxXl+r76+E1NUYPLTOG9jWtIJDN29KBJtCVSepWYFqB3Xi4V7WIa1Jk5ehu0M4/lc4+dgLMnjjbEhJzLQzcbhBKxeMHmbz96Fzefrl2CpVVV7EonB9D56pF6ss/5Dn8di2Tj3LbcVAykFC07gkBJE2IKG/Qqb1gqElxAbrlTkg29u1Bo+gugqnlFgqhyzF/W4elqqoj0UhE7mmC07FU5yH9OLBLkoON5claaR1G5DJvBEZLKaUMubCQTncVQbKAB4ALTCPLunZaIn508ungwuU+a4njdPZ1tiq0aEiApN1V/3yI/k8CsvYXWmmXb9edqOoLdzlsKhhlDMrVb+MvWj3QZ0m9NOenFZ2OLPqn4Mx7rsT9wlYjc0N/q40wPZXPThHXntc0ZOBYB+QZyXyjuKXxgm5Sngj9/G+B3UC0UOHizMZ3gV49HK1wywg7JEXNGpx92hCBmqWOeHTgtzY62sxwRoGvAqp0kIddMgvKx0fPcXAx2PPYi8AVagfDHPKyYXIgHJudZBSFoOykY2e5CSlWbnnFyLpP6j X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23918c70-e80c-41c6-9163-08db88fb212d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2023 08:27:18.0487 (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: m9WLJr3r12xkh5oa+1mNTP//HfQdzGYSuIRzLqqACLZDOgy9gxiYsNzB77Gy5HO7rvRTA4hmp99Hm4/LfqUIRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5760 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1689841671925100001 Introduce support for handling MSR features in libxl_cpuid_parse_config(). The MSR policies are added to the libxl_cpuid_policy like the CPUID one, which gets passed to xc_cpuid_apply_policy(). This allows existing users of libxl to provide MSR related features as key=3Dvalue pairs to libxl_cpuid_parse_config() without requiring the usage of a different API. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Anthony PERARD --- Changes since v2: - Add some braces. --- tools/libs/light/libxl_cpuid.c | 64 +++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index f8b2e45ee681..15fac03a9046 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -157,6 +157,60 @@ static int cpuid_add(libxl_cpuid_policy_list *policy, return 0; } =20 +static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t= index) +{ + unsigned int i =3D 0; + libxl_cpuid_policy_list policy =3D *pl; + + if (policy =3D=3D NULL) + policy =3D *pl =3D calloc(1, sizeof(*policy)); + + if (policy->msr !=3D NULL) { + for (i =3D 0; policy->msr[i].index !=3D XC_MSR_INPUT_UNUSED; i++) { + if (policy->msr[i].index =3D=3D index) { + return &policy->msr[i]; + } + } + } + + policy->msr =3D realloc(policy->msr, sizeof(struct xc_msr) * (i + 2)); + policy->msr[i].index =3D index; + memset(policy->msr[i].policy, 'x', ARRAY_SIZE(policy->msr[0].policy) -= 1); + policy->msr[i].policy[ARRAY_SIZE(policy->msr[0].policy) - 1] =3D '\0'; + policy->msr[i + 1].index =3D XC_MSR_INPUT_UNUSED; + + return &policy->msr[i]; +} + +static int msr_add(libxl_cpuid_policy_list *policy, uint32_t index, unsign= ed int bit, + const char *val) +{ + struct xc_msr *entry =3D msr_find_match(policy, index); + + /* Only allow options taking a character for MSRs, no values allowed. = */ + if (strlen(val) !=3D 1) + return 3; + + switch (val[0]) { + case '0': + case '1': + case 'x': + case 'k': + entry->policy[63 - bit] =3D val[0]; + break; + + case 's': + /* Translate s -> k as xc_msr doesn't support the deprecated 's'. = */ + entry->policy[63 - bit] =3D 'k'; + break; + + default: + return 3; + } + + return 0; +} + struct feature_name { const char *name; unsigned int bit; @@ -336,7 +390,15 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *= policy, const char* str) } =20 case FEAT_MSR: - return 2; + { + unsigned int bit =3D feat->bit % 32; + + if (feature_to_policy[feat->bit / 32].msr.reg =3D=3D CPUID_REG_EDX) + bit +=3D 32; + + return msr_add(policy, feature_to_policy[feat->bit / 32].msr.index, + bit, val); + } } =20 return 2; --=20 2.41.0