From nobody Fri Nov 29 12:50:07 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=1638200149; cv=pass; d=zohomail.com; s=zohoarc; b=RqP5RBDUwbOn3xuhXgHmRrPe2Jf/LWbl2Lr0kkGw67uoqiDImlTuFBJNqKCsaVL/sMx6oOBRct9w6TvIV41MEDirYwuxBDH/sQS9EbWSHDgW4wtwfz01KVn/kAoTuSKG9xwoIBTbvsH5BZ71uO0jv5uLbbs/cadWjdeOKaFxorY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200149; 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=81CFV+SYBzukKNB1TyKMFdrip578PFrTXbUhz3TDIu4=; b=KpJxjY+GFeybNLUxOoaPjpd1j3BOUYZYVL+2y1MsVGbliCF/U4x4gLWIm1A1JregbKxfFImC8Sru1DvS+mknzu3pA4ZeVPBs1MgFRt/fo73PmOh5vpnuzOMsAIYdEEEG0GoR9vCSjiErl69yfLEDiwGLWW6GRA6UYu770JKdg/E= 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 1638200149607568.6680931358645; Mon, 29 Nov 2021 07:35:49 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234633.407182 (Exim 4.92) (envelope-from ) id 1mriga-0004Av-Pq; Mon, 29 Nov 2021 15:35:20 +0000 Received: by outflank-mailman (output) from mailman id 234633.407182; Mon, 29 Nov 2021 15:35: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 1mriga-0004Ao-Kq; Mon, 29 Nov 2021 15:35:20 +0000 Received: by outflank-mailman (input) for mailman id 234633; Mon, 29 Nov 2021 15:35:19 +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 1mrigZ-0003uH-9R for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35:19 +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 f37ff202-5129-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:35:17 +0100 (CET) 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: f37ff202-5129-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200117; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ph/X2ZwqZu0ieAmEwiGCwAGLojJcuNIfdJOJKGHvGLA=; b=Cv7BLeJf0fjIlkFUdyezehX4GqeOS+CKTFuSwQb0JAd0++IwB3BFaxA9 FljazwUSBni2J2hnJJL8v/yDWINfNLds5rsI/SaqnKddjO3akJa6KeBzi 8yAMLquUBywjP32yW+QzYJ7quIDuWHHtTrN4np4/AA4NEovUimLQ+Jybd E=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: FCqrLPBAUUqUqD8x0Ab7jEpcsbXT8FNNTM5AFyCa5dWpK1PbZKn+SC+i3qbSwvmufAMhFoYwyU 7JCRfahQDeWMrrOqvthF5DDVjqZgGHjZNpBbGSgptWNxJFfnttjrWSzLcCQf836AE47v6nXGUc AOlB8zBuizTsRnyoyKmPX5eS1FqFkk3B/6zyg041+ZlK17reMNSk8sw76q/VkWxb/ZeOablK+Q rem0IjiUnbGfr91u9x3F38+kTb86FUH84++IqSfZvzkKSqs5zGJ9s2e4DPVeluwR39g7RY9wcu qlWAW8b9U9UKJ2upcBwmBfGE X-SBRS: 5.1 X-MesageID: 60839634 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:10kzG6lYj5VJT3wv2iDYuxHo5gx9IURdPkR7XQ2eYbSJt1+Wr1Gzt xIfWmqDb/6MNmanfNt2YN6wpBsBucDWnIVkS1ZprihnHiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA187IMsdoUg7wbdg29Q52YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 PVSpc2iEwIyBZHJmscFEB1FTGJDHpQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTN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oiRw+ePfA0lVOhCNjg1bLad0b9x5k btw5pZO5lztkAcuP/aHkjtQpjaFIXE3Wqk6so0XXd3wgQ0xx1AeOZHRB0caOn1Uhwmg5qXyH gKpuQ== IronPort-HdrOrdr: A9a23:jYAlqK+95H6T19H9+81uk+FCdb1zdoMgy1knxilNoENuHfBwxv rDoB1E73LJYVYqOU3Jmbi7Sc29qBTnhOJICOgqTMqftWzd1ldAQ7sSi7cKrweQeREWs9Qtrp uIEJIOeeEYb2IK9PoSiTPQe71LoKjlgdCVbKXlvg1QpGlRGt9dBmxCe2Gm+yNNNWx77c1TLu vi2iMLnUvrRV0nKuCAQlUVVenKoNPG0LrgfB49HhYirC2Dlymh5rLWGwWRmk52aUIC/Z4StU z+1yDp7KSqtP+2jjfaym/o9pxT3P/s0MFKCsCggtUcbh/slgGrToJ8XKDqhkF5nMifrHIR1P XcqRYpOMp+r1vXY2GOuBPonzLt1T4/gkWSgGOwsD/Gm4jUVTg6A81OicZyaR3C8Xctu9l6ze Ziw3+Zn4A/N2KAoA3No/zzEz16nEu9pnQv1cQJiWZEbIcYYLhN6aQC4UJuFosaFi6S0vFoLA BXNrCe2B9qSyLZU5iA1VMfheBEH05DUStue3Jy+vB8iFNt7TREJ0hx/r1oop5PzuN7d3B+3Z W3Dk1frsA4ciYnV9MPOA4/e7rDNoW0e2O1DIuzGyWuKEhVAQOHl3bIiI9FkN1CPqZ4iqcPpA == X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="60839634" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWweiMqyZGFoe0KTPIbvfFBn3y25soiScgrZ2gTYrQUE1G4KZ8aka5eREK+fJQhYNLDJJZ4lMmh2B4TqhMPPhYsS/oxkgggmLejKbwsshQFcKfjaZ9/AwPJZkdKL1FlfiJcfmv6qLEvFvZEthrwKfYayxGvOVRHfxKHDUAjiMI0IwNboYpQPCmpmP8Azm/b62WIqsyx3GbH7xSTnqdo5mRrfN7nnKh5dPWJAEFW8DD6tMEHBxg8aMi84p/g6aOuQxdxRvuHAv6QRSIaD8pa2z3ZYpNRx3DxR3oIlAegEZSDLvi0XDmiNtAQ3vz0vGeDR/XPEKLsqwxGupzqmQLFItA== 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=81CFV+SYBzukKNB1TyKMFdrip578PFrTXbUhz3TDIu4=; b=mRahXzvniGc6Lp/J6oWiSuKRJRbjh9yrmENYPXOKV1B8/8+jCz/1awQ+woGR8SAn+MpjnuYDOiSrKzvFsvLaSTcdw983TurXwVuXsCc7t4VxIN8rK9BK7eqyMiPTcOGlkUdjnq5luAFyGHJXfWZ8ePfcp+SWBPxIUgnF3wTQfD2w/I3hpqACnkazFdLMQC4EKiRGbn8ssjtBdvl1R8xu4IY0QuPVavU+OSUPPzu/knkQK160J8LbAdGpYK66ObYjfWhKWPD0spqImUUYsw4L6VDql1iYZVbe48haw2boVEMdtg/0AHxfEKS8e/+c4XaLlzJBdXDA3Oa6qzZbD5MY1w== 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=81CFV+SYBzukKNB1TyKMFdrip578PFrTXbUhz3TDIu4=; b=PhnnU5tl++bbDdVKAbIvIEHUZuG4NAYdiRPT9j5fUTxq77YMdXqSxLx1MhoyWHCC5n9W5v45bK1EflP5rNoqMYQuAm2kVmA7x8Z2SWsngxD8M9UGxcdunTK3IWdECwCkRORp0ijJcmHaXQnfFVE1lDZ/0aI5UCupvnIUIcLY9L4= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross , Jan Beulich , Andrew Cooper Subject: [PATCH v5 01/12] libs/guest: move cpu policy related prototypes to xenguest.h Date: Mon, 29 Nov 2021 16:33:44 +0100 Message-ID: <20211129153355.60338-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR1P264CA0078.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:3f::24) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b34530db-09ce-4af1-d692-08d9b34dd4eb X-MS-TrafficTypeDiagnostic: DM5PR03MB2842: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T6OWHDQ6MxqSELy8v6zjIkJzKUpfTjRJUDlBFMVguAT9SUKPTmf4N9CsOvBxBMX7E8Vwz0bjd6/PGGfzjgWRup2kk/E4rvqjzyFOQmacT7QBndIvZZdygXpOT/qJlBDKFB37he3FUCvo4+XWtclFgp92QcZ/EVsiL8VGyF8v7yyVg5a3BbdTDTFCkHSZGvAZzKeiSke/cpT31BpyVaySk0yJn2IjBZ3nwi5l9SDdE8fbE8t+yEaAI816Zd26mFhQsjNragq4MKSnd3nG1MvoQoegW9naK8Irc+MH0HPxPW8eA9zY5booAfD9dfTO+YD2dU1TsIlEHtX7iPo9lzWPTAVMHZaIAVj4zfz+my4GwOyome/ep3SWzQCamK/YaGf/T5ER6s8cyH+EU/kTdmkhYfUoA64rAs39u3NVMD2yl/5JG7T9bxT+lwtwuYnWKzd2uA7J3S9lkEWbbEGxVzKXIwrj9WHTpyw3Lbs1TFmWrlCFRJvpH/52Z4xKkWVf63YsKJU1sg48Xe5EeQyPZbC5CE+V+uQztyqW+VbH+SMEGUdIiqSN+NsjnZoFhhJhQXqTrjPLEopk11YOR1bfhOXDJ+pz19LpDM9n7v99O1Vn/OnxCa8XbjfwCfoAgpctg1H1UxOTqjBBtGKS+UdJE5WHCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(86362001)(54906003)(8936002)(107886003)(2906002)(66946007)(6486002)(316002)(8676002)(956004)(6916009)(82960400001)(4326008)(6666004)(66476007)(66556008)(186003)(83380400001)(38100700002)(2616005)(26005)(508600001)(1076003)(36756003)(6496006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TkVHenh6cXRUT0RJQzh0QkVkUGNBSHkwREc5UGUyRStQZmZnOW9wVy8vTjFY?= =?utf-8?B?VDgzdmNHcVBKam1CN3M4S3ZWaE15SWx4UGZ5dEJIakptd1pmZDdSTmhBWDJS?= =?utf-8?B?ZzA2UTdBWnl5VzNJaW5WM2pBNWRwUnE1blp5ZTZZekt2Rkd1WDNpeWorRlRn?= =?utf-8?B?R3ZxYmtyc2VVZnhhbVhuNG95d0Q0a2FNdW54dmw3TTY2ZkRjUkRWM2FXcy9T?= =?utf-8?B?VzFCRnpEZHZmaTBOYkZVaVF0cWVDL05ValNXU3VlWFJUUUlvUENKczRJMmZK?= =?utf-8?B?WFlvUi9xZjV6dlI4eGwwckNCNnJzMXRvejNSQ21YT1B3OUtTQ3d4UlhoT1Vk?= =?utf-8?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JVVW94TkN0UG0xdHB6YlVNS0JL?= =?utf-8?Q?qXDn/6APQqFflncAOclrd1U=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b34530db-09ce-4af1-d692-08d9b34dd4eb X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:11.7029 (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: OpFF6AL3L5otYcMR+oLn/2ngNk1aRNbE34g47graF+BQpezel0XIQoLQE2w8tH98e1pez/camWMBnvqUKDD/Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2842 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200151056100001 Do this before adding any more stuff to xg_cpuid_x86.c. The placement in xenctrl.h is wrong, as they are implemented by the xenguest library. Note that xg_cpuid_x86.c needs to include xg_private.h, and in turn also fix xg_private.h to include xc_bitops.h. The bitops definition of BITS_PER_LONG needs to be changed to not be an expression, so that xxhash.h can use it in a preprocessor if directive. As a result also modify xen-cpuid and the ocaml stubs to include xenguest.h. Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Andrew Cooper --- Changes since v1: - Include xenguest.h in ocaml stubs. - Change BITS_PER_LONG definition in xc_bitops.h. --- tools/include/xenctrl.h | 55 -------------------------------- tools/include/xenguest.h | 56 +++++++++++++++++++++++++++++++++ tools/libs/ctrl/xc_bitops.h | 6 +++- tools/libs/guest/xg_cpuid_x86.c | 1 - tools/libs/guest/xg_private.h | 1 + tools/misc/xen-cpuid.c | 1 + 6 files changed, 63 insertions(+), 57 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 07b96e6671..95bd5eca67 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2528,61 +2528,6 @@ int xc_psr_get_domain_data(xc_interface *xch, uint32= _t domid, uint64_t *data); int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket, xc_psr_feat_type type, xc_psr_hw_info *hw_info); - -typedef struct xc_cpu_policy xc_cpu_policy_t; - -/* Create and free a xc_cpu_policy object. */ -xc_cpu_policy_t *xc_cpu_policy_init(void); -void xc_cpu_policy_destroy(xc_cpu_policy_t *policy); - -/* Retrieve a system policy, or get/set a domains policy. */ -int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx, - xc_cpu_policy_t *policy); -int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, - xc_cpu_policy_t *policy); -int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, - xc_cpu_policy_t *policy); - -/* Manipulate a policy via architectural representations. */ -int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *poli= cy, - xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, - xen_msr_entry_t *msrs, uint32_t *nr_msrs); -int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, - const xen_cpuid_leaf_t *leaves, - uint32_t nr); -int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy, - const xen_msr_entry_t *msrs, uint32_t nr); - -/* Compatibility calculations. */ -bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, - xc_cpu_policy_t *guest); - -int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); -int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, - uint32_t *nr_features, uint32_t *featureset); - -int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves, - uint32_t *nr_msrs); -int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid, - uint32_t nr_leaves, xen_cpuid_leaf_t *leaves, - uint32_t nr_msrs, xen_msr_entry_t *msrs, - uint32_t *err_leaf_p, uint32_t *err_subleaf_p, - uint32_t *err_msr_p); - -uint32_t xc_get_cpu_featureset_size(void); - -enum xc_static_cpu_featuremask { - XC_FEATUREMASK_KNOWN, - XC_FEATUREMASK_SPECIAL, - XC_FEATUREMASK_PV_MAX, - XC_FEATUREMASK_PV_DEF, - XC_FEATUREMASK_HVM_SHADOW_MAX, - XC_FEATUREMASK_HVM_SHADOW_DEF, - XC_FEATUREMASK_HVM_HAP_MAX, - XC_FEATUREMASK_HVM_HAP_DEF, -}; -const uint32_t *xc_get_static_cpu_featuremask(enum xc_static_cpu_featurema= sk); - #endif =20 int xc_livepatch_upload(xc_interface *xch, diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 61d0a82f48..e01f494b77 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -782,4 +782,60 @@ xen_pfn_t *xc_map_m2p(xc_interface *xch, unsigned long max_mfn, int prot, unsigned long *mfn0); + +#if defined(__i386__) || defined(__x86_64__) +typedef struct xc_cpu_policy xc_cpu_policy_t; + +/* Create and free a xc_cpu_policy object. */ +xc_cpu_policy_t *xc_cpu_policy_init(void); +void xc_cpu_policy_destroy(xc_cpu_policy_t *policy); + +/* Retrieve a system policy, or get/set a domains policy. */ +int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_idx, + xc_cpu_policy_t *policy); +int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t *policy); +int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, + xc_cpu_policy_t *policy); + +/* Manipulate a policy via architectural representations. */ +int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t *poli= cy, + xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves, + xen_msr_entry_t *msrs, uint32_t *nr_msrs); +int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, + const xen_cpuid_leaf_t *leaves, + uint32_t nr); +int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy, + const xen_msr_entry_t *msrs, uint32_t nr); + +/* Compatibility calculations. */ +bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, + xc_cpu_policy_t *guest); + +int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); +int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, + uint32_t *nr_features, uint32_t *featureset); + +int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves, + uint32_t *nr_msrs); +int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid, + uint32_t nr_leaves, xen_cpuid_leaf_t *leaves, + uint32_t nr_msrs, xen_msr_entry_t *msrs, + uint32_t *err_leaf_p, uint32_t *err_subleaf_p, + uint32_t *err_msr_p); + +uint32_t xc_get_cpu_featureset_size(void); + +enum xc_static_cpu_featuremask { + XC_FEATUREMASK_KNOWN, + XC_FEATUREMASK_SPECIAL, + XC_FEATUREMASK_PV_MAX, + XC_FEATUREMASK_PV_DEF, + XC_FEATUREMASK_HVM_SHADOW_MAX, + XC_FEATUREMASK_HVM_SHADOW_DEF, + XC_FEATUREMASK_HVM_HAP_MAX, + XC_FEATUREMASK_HVM_HAP_DEF, +}; +const uint32_t *xc_get_static_cpu_featuremask(enum xc_static_cpu_featurema= sk); +#endif /* __i386__ || __x86_64__ */ #endif /* XENGUEST_H */ diff --git a/tools/libs/ctrl/xc_bitops.h b/tools/libs/ctrl/xc_bitops.h index f0bac4a071..4a776dc3a5 100644 --- a/tools/libs/ctrl/xc_bitops.h +++ b/tools/libs/ctrl/xc_bitops.h @@ -6,7 +6,11 @@ #include #include =20 -#define BITS_PER_LONG (sizeof(unsigned long) * 8) +#ifdef __LP64__ +#define BITS_PER_LONG 64 +#else +#define BITS_PER_LONG 32 +#endif =20 #define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr) / 8] #define BITMAP_SHIFT(_nr) ((_nr) % 8) diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 198892ebdf..b9e827ce7e 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -23,7 +23,6 @@ #include #include #include "xg_private.h" -#include "xc_bitops.h" #include #include =20 diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index 28441ee13f..09e24f1227 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -27,6 +27,7 @@ #include =20 #include "xc_private.h" +#include "xc_bitops.h" #include "xenguest.h" =20 #include diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 37989e4a12..e333215dce 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -8,6 +8,7 @@ #include =20 #include +#include =20 #include =20 --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200153; cv=pass; d=zohomail.com; s=zohoarc; b=boAO8I2Qm992GNxS8V6VYFPCB59ch842Livue4OuUOxfaKLC+2FAbxQYXVDjStlDeoRnNr+l6C1P6VjRElxJEGS4Eu6eWl6AsTYcSwSrZWG9QDIqvTIsxL7OniGm0ebPxq5K+wYWUGapM1bW70gGiyzH6DO/CAH6V58+IsrgTSY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200153; 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=ocqDusQM15nBYpXPiTHX8gTIwyIJGtnISfXG9CjWvXY=; b=d9IhrG8vTcYR5l7GmkecekGuZSmRrE6JZ5YyrJYmr/vbdn8ti0AXPHXd6Pn6mvEZ5LvndtJS9yVRzFNQmR68MUm6QbeYdDNMge6Hqsn685KRbyafeB+L9rzwibwfuGYIDSLKx+8ce+WrHquzl2VyaEmifNZ6vnebg10rHXu2Sco= 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 1638200153601834.9517749105648; Mon, 29 Nov 2021 07:35:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234634.407193 (Exim 4.92) (envelope-from ) id 1mrige-0004TI-85; Mon, 29 Nov 2021 15:35:24 +0000 Received: by outflank-mailman (output) from mailman id 234634.407193; Mon, 29 Nov 2021 15:35:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrige-0004T5-3q; Mon, 29 Nov 2021 15:35:24 +0000 Received: by outflank-mailman (input) for mailman id 234634; Mon, 29 Nov 2021 15:35: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 1mrigc-0004Rj-Q5 for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35: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 f5479fb1-5129-11ec-976b-d102b41d0961; Mon, 29 Nov 2021 16:35:21 +0100 (CET) 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: f5479fb1-5129-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200121; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=KZ2QPDqHuvFKYGq4sr1LmBzyPvDF/8vgwMdQsnoM0Qs=; b=TG+TQte2pCaLX0KC94SE636X+S8IxwBJWqZFPThFbafFSBii9iiuf2X/ AIagqjCcsnNXSMXFzeg84rrtpwstu2knrp/P5GMl2GTquWRVq0c9av5mZ SA7LYIGYeN04FF3YsuVvzxwnIbZLYRyZsrK60unm2vVG28wgMajZR86WB A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: N1EAHw+08mFsOdQ1iZYPw4833oVGImLC8KRtc2Ve/J+/6rP5Q+3JOnkcjfUfRVRIlCXQtBfljn bqHKxsQV2YVL7sxVCk9Pte7n8HUCmOIKm4Zk5oS6GD2o4QvXH6Y9IKO1ZD/mNMJSlKsQwM4AoQ 2ABcyRol4szNyRaiK9AmGJ7dNe9joDaWx2AP3WFQpWV6vAcOcGeFCJkNW/hMyjIOA+3kQVNxv9 cuqgJWqWgMNfA4pDzodLJ+bX2QHDooDpr5YC1WFyI4kKQC83+1Y8N3vS2B6maq1k6or6xriTkm usvRWx2+RjBKOI61uHjIIPnu X-SBRS: 5.1 X-MesageID: 58333437 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-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T1NU5DWytuA3Jy9fB96gIm3EyQlCAjtYgidnRpzuNKd3AL3Z WCDk1SrsA9ciYhV9MLOA4we7rFNoXze2O4DIvrGyWeKEgmAQOEl3el2sR/2AmVEKZ4uKfa3q 6xFm9liQ== X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58333437" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WmuS7BIW/ZXbC65G38oreFJbP16lXADhWLCk/GzFfEW3WHZTqT4idLFLdT/Nc+HfcXVU4tYI3x8cyG9ddcSb2lvPbp1gyUkPKmAXBB8HsjtTmOHhUqVgSArgQJRgA1okPnvWqXRiPAgDN2XUz9MxpBnGBfdo+G6u5yUjN/fbEHacnLjx94t2xg424PYD4Jyqbkgg01+uA7S5oBI8bijTvN1ZzmOL1E7iL4OTtyREYBG3dnXwBfr/6EQCofbSRazD0uAhf/7uX1uaLzl4F6cVt0iPJ788GmuuM6CN0yrupeGK//+tToYvRy04PfEyNWfiJ/Tjmqr4t0MkEYqthH80Fw== 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=ocqDusQM15nBYpXPiTHX8gTIwyIJGtnISfXG9CjWvXY=; b=ZZKspgiTG6OGeJibgr94pvxdelN1Z8gtnJ1o7wJuqCvr8Fqw8Twigry0piILRcBSL/CdqxuD6TqPn79JWbZIyPtr7XP4z1znrUi0bH3a8ISXMTpQsXxM2PxB+eHQP0OjWMUR0+LDrx5oRwGkbVQfS/6gHOebqp2ytjnYTtkpbuCYADA/K0Y5UC3YnIQbLnLsM8Xw2L22snDmVbkd8eiVoyS/xqUDrlV86TJjurd5/wLlgSAEAXRqLCwK374ztFAIlElBP6XAnhiuTAkAJSZf6YEsaDAPMNYKfdhCR8ckWjm53ezXow7mp5q/Q4PGLQkS3C2T3+JKmF/a6apd5eZYrw== 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=ocqDusQM15nBYpXPiTHX8gTIwyIJGtnISfXG9CjWvXY=; b=Au3BCTSW7mB9NNzM6wPMSs4eD2pl5iWud8pZx46+HbPsIsqOUT/iLAhHW/aQFj8JWXTeatuoC4zlf+22eppRC3/35pZRMkUGm8jMhKLH65dMMDWsjUtK01EIs0U4CJ9Cn+UZ1j5UVjb+5mZU+bGsiKwjQ5JCxh9tVFhz9cLvXn0= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , Ian Jackson Subject: [PATCH v5 02/12] libx86: introduce helper to fetch cpuid leaf Date: Mon, 29 Nov 2021 16:33:45 +0100 Message-ID: <20211129153355.60338-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0146.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::9) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3d298cb-a75f-4f90-e36e-08d9b34dd7d7 X-MS-TrafficTypeDiagnostic: DM6PR03MB4764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:530; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKvds+rigo8fVhvhLJhNTbT514VpG/uKE7gwYEEXzCGXgsiKLbEtcp/VROLNV/N39U3QQ4+YMyWHqZZ+mcx7BqKWyJhlvmWs5OmJGWmSk5HKVIobNSwBbCGIYN+Q3Q4ONW3lkLE50JWbDGvs//oRLUEbmcQ7gnXdKnHTuXcB2maNkb+5zifkTGNQeOGhnMD/UBxcq8I5xpw8zR8UWIX+vE8p7A70i47kD7bKLSg//L4N4F9oLDbYS2HdeGlCGnc09cOk2W4ZZ3cwFK/rqnyCH4YhMhPVjD0ulD2tQEYnn8PxwZfQ3mh1XFXAQfosw2HTGMdp2ulGCWwEE/Anm1KZKJTdnEmys4HTOA79uxiGrqWRUewjRGqXJEek4yTzmg480JCakAAONUeAZAZjgNwEkCbgfIybCy0zeCt6rxXYRyBk2G32B/Fp6jMEiAT42GRJp0riVQDPO4IEMCf4NXVyGZaCoV7TeeuVsOYkBZNC78g0yOKhirTLUPWBYlP2Qyhp1uqftFEBOHiHfy+7gkpLJhd+85ZIfS3jvFKUo+ilmgvoRLyJeaJD5jC3yqxz2kN0tsbEnJsH4RPVcwDGLer6XayLFz7KI0n7CBOiYe6xaufJ9+CwZUxiXPNEi/ddGjlQqKpvPP64q+XHLj8hPHF72g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(4326008)(2906002)(1076003)(66476007)(6486002)(82960400001)(38100700002)(186003)(83380400001)(956004)(2616005)(316002)(6496006)(6916009)(26005)(54906003)(6666004)(36756003)(66946007)(86362001)(508600001)(8676002)(8936002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VTlE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grVVptaUpweVpMOVY0SmJBU1R4?= =?utf-8?B?d0cxMlIzZUI0eVk5Y3FnbFJKQU9oQlRhSkNyVElIU3NlTHk4UjAwVC9ETlhK?= =?utf-8?B?aVZaNHRGUHhjRTJKOE5wRUpBMUpoRVZGK3Uyd1BhRGtRbkJzV0xiRFRqMUZ0?= =?utf-8?B?cHZ6Mk1FRHpwdXozMUU3VUNaRHREemkybnpOT1V0T29nb2hXdzErSHNpaHFw?= =?utf-8?B?K2ZjTW1GQjYrT3NPV0R5a25HTlNKMXdIRCtHZXhDcFY4NXlUQVlQbzJmcG9F?= =?utf-8?B?MGRyYVB4TEVXMGZIU1NhbmpOREl4MEpMak1zT2RPSGhFWE90Uys4UU5SajBO?= =?utf-8?B?Qi9xMEY1YjhlbVliaFJqd0RUVlNWSk5UamhReW1Cb3Z1eWVURTlTeXdPTUQ1?= =?utf-8?Q?vTWGJSaS1vZ/+IAvbd0uJc4=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e3d298cb-a75f-4f90-e36e-08d9b34dd7d7 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:16.5456 (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: PT6sVp13dFMHDtAjollTDLhZ/OSnYgthJDmlsGwUpGKhOIUFIOGfyJgv4z2DmylhvWdnxYKKMHrZ+0vu3HoNMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4764 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200155792100001 Introduce a helper based on the current Xen guest_cpuid code in order to fetch a cpuid leaf from a policy. The newly introduced function in cpuid.c should not be directly called and instead the provided x86_cpuid_get_leaf macro should be used that will properly deal with const and non-const inputs. Also add a test to check that the introduced helper doesn't go over the bounds of the policy. Note the code in x86_cpuid_copy_from_buffer is not switched to use the new function because of the boundary checks against the max fields of the policy, which might not be properly set at the point where x86_cpuid_copy_from_buffer get called, for example when filling an empty policy from scratch. Suggested-by: Andrew Cooper Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v4: - Rename _x86_cpuid_get_leaf to x86_cpuid_get_leaf_const. Changes since v3: - New in this version. --- Regarding safety of the usage of array_access_nospec to obtain a pointer to an element of an array, there are already other instances of this usage, for example in viridian_time_wrmsr, so I would assume this is fine. --- tools/tests/cpu-policy/test-cpu-policy.c | 75 ++++++++++++++++++++++++ xen/arch/x86/cpuid.c | 55 +++-------------- xen/include/xen/lib/x86/cpuid.h | 19 ++++++ xen/lib/x86/cpuid.c | 52 ++++++++++++++++ 4 files changed, 153 insertions(+), 48 deletions(-) diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-pol= icy/test-cpu-policy.c index ed450a0997..3f777fc1fc 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -570,6 +570,80 @@ static void test_cpuid_out_of_range_clearing(void) } } =20 +static void test_cpuid_get_leaf_failure(void) +{ + static const struct test { + struct cpuid_policy p; + const char *name; + uint32_t leaf, subleaf; + } tests[] =3D { + /* Bound checking logic. */ + { + .name =3D "Basic max leaf >=3D array size", + .p =3D { + .basic.max_leaf =3D CPUID_GUEST_NR_BASIC, + }, + }, + { + .name =3D "Feature max leaf >=3D array size", + .p =3D { + .basic.max_leaf =3D CPUID_GUEST_NR_BASIC - 1, + .feat.max_subleaf =3D CPUID_GUEST_NR_FEAT, + }, + .leaf =3D 0x00000007, + }, + { + .name =3D "Extended max leaf >=3D array size", + .p =3D { + .extd.max_leaf =3D 0x80000000 + CPUID_GUEST_NR_EXTD, + }, + .leaf =3D 0x80000000, + }, + + { + .name =3D "Basic leaf >=3D max leaf", + .p =3D { + .basic.max_leaf =3D CPUID_GUEST_NR_BASIC - 1, + }, + .leaf =3D CPUID_GUEST_NR_BASIC, + }, + { + .name =3D "Feature leaf >=3D max leaf", + .p =3D { + .basic.max_leaf =3D CPUID_GUEST_NR_BASIC - 1, + .feat.max_subleaf =3D CPUID_GUEST_NR_FEAT - 1, + }, + .leaf =3D 0x00000007, + .subleaf =3D CPUID_GUEST_NR_FEAT, + }, + { + .name =3D "Extended leaf >=3D max leaf", + .p =3D { + .extd.max_leaf =3D 0x80000000 + CPUID_GUEST_NR_EXTD - 1, + }, + .leaf =3D 0x80000000 + CPUID_GUEST_NR_EXTD, + }, + }; + const struct cpuid_policy pc; + const struct cpuid_leaf *lc; + struct cpuid_policy p; + struct cpuid_leaf *l; + + /* Constness build test. */ + lc =3D x86_cpuid_get_leaf(&pc, 0, 0); + l =3D x86_cpuid_get_leaf(&p, 0, 0); + + printf("Testing CPUID get leaf bound checking:\n"); + + for ( size_t i =3D 0; i < ARRAY_SIZE(tests); ++i ) + { + const struct test *t =3D &tests[i]; + + if ( x86_cpuid_get_leaf(&t->p, t->leaf, t->subleaf) ) + fail(" Test %s get leaf fail\n", t->name); + } +} + static void test_is_compatible_success(void) { static struct test { @@ -685,6 +759,7 @@ int main(int argc, char **argv) test_cpuid_serialise_success(); test_cpuid_deserialise_failure(); test_cpuid_out_of_range_clearing(); + test_cpuid_get_leaf_failure(); =20 test_msr_serialise_success(); test_msr_deserialise_failure(); diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 151944f657..4db2df3b52 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -764,48 +764,16 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, switch ( leaf ) { case 0 ... CPUID_GUEST_NR_BASIC - 1: - ASSERT(p->basic.max_leaf < ARRAY_SIZE(p->basic.raw)); - if ( leaf > min_t(uint32_t, p->basic.max_leaf, - ARRAY_SIZE(p->basic.raw) - 1) ) - return; - - switch ( leaf ) - { - case 0x4: - if ( subleaf >=3D ARRAY_SIZE(p->cache.raw) ) - return; - - *res =3D array_access_nospec(p->cache.raw, subleaf); - break; - - case 0x7: - ASSERT(p->feat.max_subleaf < ARRAY_SIZE(p->feat.raw)); - if ( subleaf > min_t(uint32_t, p->feat.max_subleaf, - ARRAY_SIZE(p->feat.raw) - 1) ) - return; - - *res =3D array_access_nospec(p->feat.raw, subleaf); - break; - - case 0xb: - if ( subleaf >=3D ARRAY_SIZE(p->topo.raw) ) - return; - - *res =3D array_access_nospec(p->topo.raw, subleaf); - break; - - case XSTATE_CPUID: - if ( !p->basic.xsave || subleaf >=3D ARRAY_SIZE(p->xstate.raw)= ) - return; + case 0x80000000 ... 0x80000000 + CPUID_GUEST_NR_EXTD - 1: + { + const struct cpuid_leaf *tmp =3D x86_cpuid_get_leaf(p, leaf, suble= af); =20 - *res =3D array_access_nospec(p->xstate.raw, subleaf); - break; + if ( !tmp ) + return; =20 - default: - *res =3D array_access_nospec(p->basic.raw, leaf); - break; - } + *res =3D *tmp; break; + } =20 case 0x40000000 ... 0x400000ff: if ( is_viridian_domain(d) ) @@ -820,15 +788,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, case 0x40000100 ... 0x400001ff: return cpuid_hypervisor_leaves(v, leaf, subleaf, res); =20 - case 0x80000000 ... 0x80000000 + CPUID_GUEST_NR_EXTD - 1: - ASSERT((p->extd.max_leaf & 0xffff) < ARRAY_SIZE(p->extd.raw)); - if ( (leaf & 0xffff) > min_t(uint32_t, p->extd.max_leaf & 0xffff, - ARRAY_SIZE(p->extd.raw) - 1) ) - return; - - *res =3D array_access_nospec(p->extd.raw, leaf & 0xffff); - break; - default: return; } diff --git a/xen/include/xen/lib/x86/cpuid.h b/xen/include/xen/lib/x86/cpui= d.h index a4d254ea96..050cd4f9d1 100644 --- a/xen/include/xen/lib/x86/cpuid.h +++ b/xen/include/xen/lib/x86/cpuid.h @@ -431,6 +431,25 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *po= licy, uint32_t nr_entries, uint32_t *err_leaf, uint32_t *err_subleaf); =20 +/** + * Get a cpuid leaf from a policy object. + * + * @param policy The cpuid_policy object. + * @param leaf The leaf index. + * @param subleaf The subleaf index. + * @returns a pointer to the requested leaf or NULL in case of error. + * + * The function will perform out of bound checks. Do not call this function + * directly and instead use x86_cpuid_get_leaf that will deal with both co= nst + * and non-const policies returning a pointer with constness matching that= of + * the input. + */ +const struct cpuid_leaf *x86_cpuid_get_leaf_const(const struct cpuid_polic= y *p, + uint32_t leaf, + uint32_t subleaf); +#define x86_cpuid_get_leaf(p, l, s) \ + ((__typeof__(&(p)->basic.raw[0]))x86_cpuid_get_leaf_const(p, l, s)) + #endif /* !XEN_LIB_X86_CPUID_H */ =20 /* diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c index 8eb88314f5..924f882fc4 100644 --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -493,6 +493,58 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *p, return -ERANGE; } =20 +const struct cpuid_leaf *x86_cpuid_get_leaf_const(const struct cpuid_polic= y *p, + uint32_t leaf, + uint32_t subleaf) +{ + switch ( leaf ) + { + case 0 ... CPUID_GUEST_NR_BASIC - 1: + if ( p->basic.max_leaf >=3D ARRAY_SIZE(p->basic.raw) || + leaf > p->basic.max_leaf ) + return NULL; + + switch ( leaf ) + { + case 0x4: + if ( subleaf >=3D ARRAY_SIZE(p->cache.raw) ) + return NULL; + + return &array_access_nospec(p->cache.raw, subleaf); + + case 0x7: + if ( p->feat.max_subleaf >=3D ARRAY_SIZE(p->feat.raw) || + subleaf > p->feat.max_subleaf ) + return NULL; + + return &array_access_nospec(p->feat.raw, subleaf); + + case 0xb: + if ( subleaf >=3D ARRAY_SIZE(p->topo.raw) ) + return NULL; + + return &array_access_nospec(p->topo.raw, subleaf); + + case 0xd: + if ( !p->basic.xsave || subleaf >=3D ARRAY_SIZE(p->xstate.raw)= ) + return NULL; + + return &array_access_nospec(p->xstate.raw, subleaf); + } + + return &array_access_nospec(p->basic.raw, leaf); + + case 0x80000000 ... 0x80000000 + CPUID_GUEST_NR_EXTD - 1: + if ( (p->extd.max_leaf & 0xffff) >=3D ARRAY_SIZE(p->extd.raw) || + leaf > p->extd.max_leaf ) + return NULL; + + return &array_access_nospec(p->extd.raw, leaf & 0xffff); + } + + return NULL; +} + /* * Local variables: * mode: C --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200155; cv=pass; d=zohomail.com; s=zohoarc; b=ZZMKJOzFb2EBP/hI6uFs9Dv9XUN6UwSrXIGBiZCL6cakMjH6/I8Cm4e5JQ6gq65cOeoTCW2pm1oX6w/4AVEO1ajAjdNuiYK5XQR/TFQER6vgtr4vjwTCpRpX3I1WQ7Cu+WlBRZOupkum8JBbG8UzvGgRbUYcDNndRQ1lV5G8r4M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200155; 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=m1+vUAFlvux2wXM0/t+OqbhuL51Rq/ENxTsQGJDXxM8=; b=l20vS+uJKs7oCILZVoFvy3hm2kyEkzCL3Vy4Mn2dR/UY+opWmK/Y1qYkP4G0RdsYXCRZrpp7DH/+zlYXD9f6+L+wajAWj2vch9ugzLBTaUf1jzsQhnNOhQ90uK3XF0OySabhvD0f3rbKJzjw7i40PkZ9WhhHTnwCIKLHZmThgcM= 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 163820015494562.837794982899254; Mon, 29 Nov 2021 07:35:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234635.407204 (Exim 4.92) (envelope-from ) id 1mrigl-0004rh-IW; Mon, 29 Nov 2021 15:35:31 +0000 Received: by outflank-mailman (output) from mailman id 234635.407204; Mon, 29 Nov 2021 15:35:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrigl-0004rY-Dw; Mon, 29 Nov 2021 15:35:31 +0000 Received: by outflank-mailman (input) for mailman id 234635; Mon, 29 Nov 2021 15:35:31 +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 1mrigk-0004Rj-PB for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35:30 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fa4cd6cf-5129-11ec-976b-d102b41d0961; Mon, 29 Nov 2021 16:35:29 +0100 (CET) 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: fa4cd6cf-5129-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200129; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=yz/7WHXZdG8/P3IiQ6Qs4BL/Xb7Cfc20DDjQceoZCN8=; b=TElRmbUNJkrvbEEPYqFTIdDBLeHlsoRwgIPFXFxmw+zFCS9/W3VLVgXh QVItSOU86ng5Cr+B+BXOxDelLgxolv51CstVyHACCq5dWhS4pYvL3LClz eKdEw0gyeSkkRK479aX7IPh5caJsSR+WZTOCm5330LfMFB/4wk2KoESiH w=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: ekcI5uORet7Jwxrn6rsWpCStPe8tL2WUVcTjKREfIxZYEv1ndBhht+OlhgjUT03imn8oVkwOBL d2Zg9qZAsnrN1W0IESBFvYCKUuBOmE3cXiqwg5ex6a2gf7ltXT61XQboeQztKMrIhGEhOuWV3N aVq8zMQcIWq43T9GW0+9PKL73+kOoUW+Y5JB6ovZzvXEd8l4u95fJgdZjVzmqLayrEJfO45aAK MWYUHI8nmO7EShnV0I4IXs73OvvKRkfMonXntx3cVS5Q3lij2F3YUjm6OB5dScZdyRotnLYbbi ztmj0CZh9aOOgoRV9debsiCn X-SBRS: 5.1 X-MesageID: 58773259 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ol4skqNMrgz5AiXvrR1GkMFynXyQoLVcMsEvi/4bfWQNrUpx0DYHz DYcXmCHbPeDZ2v3LdB/ao6yp00GsZHQmtIySwto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUG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8GlodwwbgmviCKPIzGhPGo1cal/SlGb4dTjZAbuqnUDV3Llqcskr rS8/QrHWp5fFR96BcPbZav3nVO8tHQQgsxoWE7MLoUBcUng6tEyeSfwkuU2M4cHLhCanmmW0 AOfABE5o+jRotBqrImV1P7c94rwSrlwBEtXGWXf/I2aDyiC8zrx25JEXcaJYSvZCDH+9pK9a LgH1Pr7KvAGwgpH6tIuD7ZxwKsizNLzvLsGnB98FXDGYln3WLNtJn6KgZtGuqFXn+ILvAK3X gSE+8VAOKXPM8TgSQZDKA0gZ+WF9PcVhjiNsqhlfBSkvHd6rOidTEFfHxiQkygMfrJ6PbQsz folpMNLuRe0jQAnM4regy1Zn4hWwqfsj0nzWkkmPbLW IronPort-HdrOrdr: A9a23:Co9WK6sk4TzpeXhATTyT78PJ7skDG9V00zEX/kB9WHVpm6uj+f xG/c516faaslsssR0b8uxoW5PpfZq0z/dICOIqUYtKMjONhFeV X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58773259" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f55NV7oVqNkETdXKYfOD1m4cC8U4yAsYj1IHyEh4bbU/W1Bm85fm6RVM4puLQoLLU4cO3O2h4Kl2ptfz2ZGf1CMotN4WQhI47fpi9qTBmx76UQqv8cQD939iwJb1BZ9ni8dYCJTRuEJS4+lrkEfQt2eZ5ayn0G8pTnWnma1tCZv0nK32ZTVNyjG5SUmQIEHi6ZvcnXNPtKmm6UfLpnFgQ29giMcWrowfONV8v1TDsnrMp+TNImDgZ/Gogl+vc897mqc+P7vGoIk0vsWxajmgucYooCjuROn/xyPIqZSSzjutUC6u6lUMaAhG2f12aqwvImuwwzD66ld+31MSf7ZPuA== 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=m1+vUAFlvux2wXM0/t+OqbhuL51Rq/ENxTsQGJDXxM8=; b=jMTDTY9KwRBXc7Lw/GNPeO7RiG9RzZtTMKMrruVk0jF1GMQjS+3ubJfG5KJwG6L4rkhHXDhtO2d0pks3AZ/KdmbgP0V1dJRHJ5g3818koTZN9YQDuCjW5XwbKThV2mdNfjGoCUqGZqgUAc35HRMiZE1BZ3hk7DhU21atjn662C/0pAwOcWmAfonZTku3o8UyjtsTi9jbMW33Mk/x4Pb4saGIQw9K9eOWF1Y/CaOR4pSD0VcoQicKbf9fLJqX6whx91ZL2Ad9hHHfpWbMxWDTGJCXV2uivILhnDVQ2K51cTOemI4/JpVLjTzh5puL6f48EI8RynfNqdjbUra4U74hNw== 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=m1+vUAFlvux2wXM0/t+OqbhuL51Rq/ENxTsQGJDXxM8=; b=M5+JQ+ReDF0scKFpjAU4vWIAvSC2NEix+xcptabn1LFjxfyqnM/rI5iS5Fo8k7ILfTXX0sPu8EaKlmE1X6DeTOgJVMCPOmigeLf7Gb6rjxZDhZtQwUwUKg6fhiEnHPxyrSLQDvuMFHi/uRS7sbJsuMZwW3d3tjThWDuZhpZSU/c= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 03/12] libs/guest: allow fetching a specific CPUID leaf from a cpu policy Date: Mon, 29 Nov 2021 16:33:46 +0100 Message-ID: <20211129153355.60338-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0164.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::27) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bcee822-ffa2-49e9-da5a-08d9b34ddb37 X-MS-TrafficTypeDiagnostic: DM6PR03MB4764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gz68Hx/n8hChPwCR91zcbuCUt3hrJE8voptcZEWcKVAk3RKOBU/CgXD6HfD0c3sjJgg3g6RX+8Yt95bxVYQ6PxGiGANUAzYByaO/vronzUNUEIZBGKQd8EjJtLR3aw0p/ksB9ULDjx/Ht8NgRg4H1+PYlW9nzmFzjuoeKpX0odbEPO/j6ycD5cykgmaiFMNg0iaLaid9pXCPFNABzxxKhBf5VkshkiPgvz1BcDQpEOFZcUmR+SEyAzm871rCBWQ+M/w786kR0Pn0t9HpJovcQ7MS4KPithOLKonCUedcOUYcf3aExqLBBQI8UQyN0nA+9AYV5LfoqMBaZs2wfVnCfAAXSl4Vjvr+RdqP0Q+oYxGZmCRU1J7uEAetq/Yl0HLpLT2TWZPNnidJ5ha3NCWi4Qf9TN3c0H0ju6GNeB74dWUx61zu7Ypttvx/QW8JFiF0ilPk3pnAjnbQaWtGgEOYVL0wYvxiz2svUrW6DdcpdVJYUyw5MRSit4fFgkEUiPCuvggeM2Tsc367ClH/59CynrOG2tva8+oeQaw5yAJX16QsBIHtGCXouP2H9rfP3IVeQdBfelRbubDNZlCgboroYHkFUJD9/1mUSnMz3ZbBnGn+0fCvXi6OxpdAnME0aLhnBehzTTN0lGwLt+UzcCOmOw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(4326008)(2906002)(1076003)(66476007)(6486002)(82960400001)(38100700002)(186003)(83380400001)(956004)(2616005)(316002)(6496006)(6916009)(26005)(54906003)(6666004)(36756003)(66946007)(86362001)(508600001)(8676002)(8936002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bHBkOTA1QjhoV3BuQVZjM3FZVmxUT0grSzZsRmdyYlpkRXBIakFlREZtQWll?= =?utf-8?B?ZjROeEgvTk5BcmdZRGxOMUtEVzFXV3hLZ0REODNiL1NrL0NuaGJFeW0vUGRQ?= =?utf-8?B?SUp0c0hIeW9iZ3djT2xaOVFjRExIVUJqcHE2WUMxN1pxcnhpcVd5Uy81cGJQ?= =?utf-8?B?S1J4N1o3alBPTVJIMlZqc25uUllhTGVJUmVWVnkyQkhhRVY4YndVUnNxRTFj?= =?utf-8?B?RE5FWWpwRFZjNXRMcG5aZE94VWVJeDFPa1ZNYlJ6Z2NZME03TGVEUG9GTVN0?= =?utf-8?B?eDZrTkpMV2lDVEJMenF5Wng1bXZwY0hkdDd3TnVBY3g4OVFadVN0MS9JMHdi?= =?utf-8?B?TXI1ZTgvZCt6Ri9mUXc5MGJuMWJzdzVyWXk0K0NWN29uck1IVElUQlAzTlhG?= =?utf-8?B?VzZ4YjZMVVdnbFVYMWQ4Y21UdzFnamhHMjl1cGdYVEwxdkp2Sk54KzZER3BV?= =?utf-8?B?MjNTUUZTUWYwU2VmT2dUQ0xyUk1RZzZ4d3pieVJUaUE5MERDUTVaZ2JiWFFt?= =?utf-8?B?TnpKWU5TL2laaU5GODB5MUM4Q0dmYXFpZ3d4UlNEaUFqVmN6NFRiU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3RYejk1ZVZpcUFpM1hEVXV4MkdIcU8x?= =?utf-8?B?Qm9oSERET1ladUYwZWFTTWdldDA5aDFROXF0Rkg0YlZKZ3BYc1RPd0Ruamtp?= =?utf-8?B?TWJnNDUwc2E3SytiV1puSjI2MThrUE5EWklCZDMvWkpTZUtzVEVOWHBhbys1?= =?utf-8?B?ZVdLUkwwSDhaZm9RMUpiRDdIZjBOeHl1ek1RNkpzek9GOGZMWXREUklrOXVr?= =?utf-8?B?RGowVzNDSzBsd2lRWXlacElSUllJRTRmeDlrQ3lydDZOaUhEb1Y4N3QyOWRK?= =?utf-8?B?T3orUitnSjcycFJDUGhaWmpMQW80NEFGdkRZbENFWDZseHYvYzY5ZURPbUJn?= =?utf-8?B?eUdCT0NUTU5CQ3IxZzFacmlUb3E3LzJCbmxZNEthRERIeURiTlQwQVhlMTht?= =?utf-8?B?Zkdqakt3Z0Z0a3BobG5jVGhRcS9GMUNXNm9zc2NxWnh4Z2ZlaUMxK0w3bFk0?= =?utf-8?B?TzMrRnNTRUJLK1VrSTZPNFZSODFsMFVuNFBnU3R1VFVraGZhQm1TOVVuZGht?= =?utf-8?B?WnEvd3A4dFB2T2QwL0ZXcGZXUnNicFZhcTRJRmFxcjJFZVdVUWNrYzBCSFlu?= =?utf-8?B?YUoydDhFK1U3QmRoQ3gzS2VBdGlBMlVkWlFBMjhTQTNySDhwVDlxVnRmaEQ5?= =?utf-8?B?cG05cjFnWlNDWDlDRXhaZkdpRWhwelFSUmdiWnZMT0hrdW9jYWFIbTRPK0VP?= =?utf-8?Q?/IQvN/b0aLcANkcma2HbG+A=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 0bcee822-ffa2-49e9-da5a-08d9b34ddb37 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:22.2316 (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: d0PyNvdK0yvVlbi8SCWNkHJBPihDm+mK5KF32DO6IuXjCO6f897NbrmJQ/HnQta/iEATT79HC732IRpaYvMipw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4764 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200155985100003 Introduce an interface that returns a specific leaf/subleaf from a cpu policy in xen_cpuid_leaf_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Note that callers of find_leaf need to be slightly adjusted to use the new helper parameters. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Use x86_cpuid_get_leaf. Changes since v1: - Use find leaf. --- tools/include/xenguest.h | 3 +++ tools/libs/guest/xg_cpuid_x86.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index e01f494b77..0a6fd99306 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -807,6 +807,9 @@ int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cp= u_policy_t *policy, uint32_t nr); int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy, const xen_msr_entry_t *msrs, uint32_t nr); +int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *poli= cy, + uint32_t leaf, uint32_t subleaf, + xen_cpuid_leaf_t *out); =20 /* Compatibility calculations. */ bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index b9e827ce7e..7779a3e1dd 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -855,6 +855,29 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cp= u_policy_t *policy, return rc; } =20 +int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *poli= cy, + uint32_t leaf, uint32_t subleaf, + xen_cpuid_leaf_t *out) +{ + const struct cpuid_leaf *tmp; + + tmp =3D x86_cpuid_get_leaf(&policy->cpuid, leaf, subleaf); + if ( !tmp ) + { + /* Unable to find a matching leaf. */ + errno =3D ENOENT; + return -1; + } + + out->leaf =3D leaf; + out->subleaf =3D subleaf; + out->a =3D tmp->a; + out->b =3D tmp->b; + out->c =3D tmp->c; + out->d =3D tmp->d; + return 0; +} + bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, xc_cpu_policy_t *guest) { --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200164; cv=pass; d=zohomail.com; s=zohoarc; b=awGx4tVKmwRLaMIz5quKHzwfoquaY98PCXxyBhvIqhJJmCR0iKU1ykEFzjFJf3AwVQvS3rxomPgWMcupAwUmzOPHuVpuRy8LSOznzn/hI/CEtlwmj9nQwCEA61T8hKRXF6bBg4pRLtWj+TkwoLwl6bZMa6pV/u7XbfDOVCLKs1M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200164; 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=dj2zYVjV9zE+r8tX/vZbHlx8BZRHwcEypBJvmHSoHAU=; b=RwM/eXFtcjr8+7Wj4tG7gXGndIryLY9ebU/SuTats9Se6sn6l5aqpdkqzdmZFZxioe9zentRw0TzPmlE2uu8CaYkscfhU1NZgc6i1SptTf/Xxg7ForKQx1Z+gij8ojAWs3KOrKCkW0ERYLWgUyKEpyrCM8KLL17ZuylWnr2PdN4= 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 1638200164679648.343896932971; Mon, 29 Nov 2021 07:36:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234636.407215 (Exim 4.92) (envelope-from ) id 1mrigo-0005G4-UV; Mon, 29 Nov 2021 15:35:34 +0000 Received: by outflank-mailman (output) from mailman id 234636.407215; Mon, 29 Nov 2021 15:35:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrigo-0005Ft-QW; Mon, 29 Nov 2021 15:35:34 +0000 Received: by outflank-mailman (input) for mailman id 234636; Mon, 29 Nov 2021 15:35:33 +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 1mrign-0003uH-2A for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35:33 +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 fbde06f6-5129-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:35:31 +0100 (CET) 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: fbde06f6-5129-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200131; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ovizBmOd9afB85beG6l95WMGrI1FjJYBuKIsdHrpGHU=; b=IuplQhplFiKS2Hsna2ZFt+dLqrHQeYCPMS4/vxmQZYboRfzjxO2t9Ivc NF5Dx5xYXC6rQFXiwmP051KpTeCjStl8VLYvY837G796uLxjqrvq2QFfC L1671B+lp6tJsHSe8NC/Pw/Pr2joWyk/JtRIMjHpZ4kBD4QqCe2E+kvmw 4=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 2wFeSJoaWZOWTcUp84o6rzHFkHw0OHf3YnH/DTriRNjNGAYwowpCFlWxcTPVlUfTmVnMRDlFdK AdSckZyba3lo3I36NRJzJLxPPYARErfvRtFqrX9Q4EQ9FpIe5OsMXJB2KNXDFNXSzJ20vNw2Mt OoR19ld8LAMhcBDGdGItHvU9kW7DTOhNPeIFUTYCmgcYkV37I1tsGqzA+IWyOuPy0oLMJ5QbKg 9fkvcJLWR+8o0cc+PcuaTVxtnpVsJQPQkL9d7ehljTpvtuZbWxvwCgssOWW9DCKx54z6QOwbxQ x4SlebqDvsx4p/omqrfL0E3n X-SBRS: 5.1 X-MesageID: 59208280 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ETcTOKgs/2xggZFm/D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3EyQlCAjtYgidnRpzuNKd3AL3Z WCDk1SrsA9ciYhV9MLOA4we7rFNoXze2O4DIvrGyWeKEgmAQOEl3el2sR/2AmVEKZ4uKfa3q 6xFm9liQ== X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="59208280" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lljat2hlHMCcJxWYiHJeVYWXv0HGszZKq2wxSGS2h3RuNgBC1/7Qt+eeAOcYVrx9RJNyVqSfzjk3RAzUHL5B5vFYPCz8TEo9SZBMIwF8u6unntZBs4r4NhDSlh5fyHqD5lUIOl4wFDrzWm7e+cakZnA2pC1cWo3rt2Yz7Pz70VoVu/6T0fEpFkJjkp74NUqGnr+syyoVfhlMbIj1WuaM8AdKIUhI3+716xVwlGZF0g/cWmkJ8J0ddhaUby05lU1MoxWH4nBjrqTl5g9rwoJWqScHMapZ4Vky46rUN9Q25oAYdC565s2HgczDe/uS0OOvAmXvsY9S0q/e3Wv3Ftn5dQ== 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=dj2zYVjV9zE+r8tX/vZbHlx8BZRHwcEypBJvmHSoHAU=; b=moebZdfD4hlYcWKwV/PBLRVMcIj6vblKmYliPkc7G0aXmjsjoM0QfZWcKTNMGvlXx+7VxEHrpMq9XkOaAUNK8WyG3x7o/N7YUjRBnqdlQeogy9WEmV4v0QnHHEvG8sIxAQNApgAqi3xPf4NVMOz/I0n4PFOn/fVCZdaT566b0vvgDv6TD8fcLJdXA++f626c0KjtN9IJp1OB7/ekxCzuVbABVf0LkZuU2ZQ3/FdZmPU2ScgnT3iNs6NYGiUv9ELVwWNFGksghAy/8vEdJvZkUdFjG78tXrE/JDTDaqK+OywFKWKMcSMZLDegup2eaQ2OowzmBY1H9Jy/iREWqz3DAA== 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=dj2zYVjV9zE+r8tX/vZbHlx8BZRHwcEypBJvmHSoHAU=; b=toX2SEoEHaQY4jjwFstBKv2qc/gJD0T8Hzy9ElIHMNYrhNidee+DOJwDSlyUQMWeZvVZ/mbEqAaSxwNZ93YEz/KP37GPzzyM+VdKJ6xYCGz+R4sbLZhuRJGm/mizm1O5Lvd6KCvCC7X3XEBXZP11+81M7CY3AA/MCad/Y6DG+K0= From: Roger Pau Monne To: CC: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , Ian Jackson Subject: [PATCH v5 04/12] libx86: introduce helper to fetch msr entry Date: Mon, 29 Nov 2021 16:33:47 +0100 Message-ID: <20211129153355.60338-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0148.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1::11) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d423a56-6c04-4b7e-823b-08d9b34dde73 X-MS-TrafficTypeDiagnostic: DM6PR03MB4764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J/9p9Ksjcyi9rdMRyzBF+OXEpUKe2fw3sh2rnOlh0i8inC15MxbbcD3yE/rScqmCoOr98+DYvybTFE1zfI0E4QzvfKVFMFUWidYRboCgfnmCahUd59cr4bBEpt8qfLtJJ6K2gOmzrF8sXcOht+OA2wK+xjY+eNoxFv964SuoNWOri8/upBQrRlV3z0yfqmvq2jWCV44wAQsPZt05K2cn/QTRYA7N6KSp8EE9Vmbf7GQP9MQZFw7flxjeJUydH/pNxMa/mJQgthgwtTqzR7cGrurWJc6P6j5tG1Pux/Sr9EM6urN0WQuxTnCISkQ78UJsJgkcHytn/hiS1Yjkgtf749/8KdrBasbcM9jgQCqN9q6mmLsZ4OXR+wf7Yg8g5vUW4wl08EWEO4aOOmUbtOxwH2baXsCSZoBTfD7kzqHlIy1m9Th5OIv1DsTU+VSfCvaSrvmSMWYB8GbclyFREsxbwJGJUpRLnUAtUvSuwFqEbz7a+nVARkl2xMsoH+VZZal1HwiumJTscD+F3sNRTlLvlMe9h5Nm4H7MfB/s6Z3hwjPId7YoUmvb6w/xoG7Y6v+QU+pbf3EhbAHY7XUaVC/m7m84401lxo2/nBV4t8wE2i5TwGrLS+/XP2KLnPbWDuLSiJLsGcNTD4emaFQE9H5jKgGY92gs1ZZNbbphDKjtjOx58NzLrF/SOyt1TAOTPf7tTJ2kGwrNcQaW3PExNceoGw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(4326008)(2906002)(1076003)(66476007)(6486002)(82960400001)(38100700002)(186003)(83380400001)(956004)(2616005)(316002)(6496006)(6916009)(26005)(54906003)(6666004)(36756003)(66946007)(86362001)(508600001)(8676002)(8936002)(66556008)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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RXFL?= =?utf-8?B?WW4vN0tITWtWWWt0Y3UwQ0VIVld2NjZ4dWRjT09FUDJsVEp6RDUvTFp0SDUy?= =?utf-8?B?QitBUFVOTFNnbnZUT2szMklLMlVmZ1Z4bzdhWVhiZ3lTblpwOFltK2puRmVy?= =?utf-8?B?eU5JOERXMWhHM2VOSFB3WFovRFJGQ2lGRjAyL3NvTlRRSnZjenRjSlFvbDVE?= =?utf-8?B?UTRTbDI0Z2F1MHZjcUN2Y1FjeDVRMUpSQktKMFZDMnJPbUllQlpYQzY3bDVJ?= =?utf-8?B?RUgzNjdDdlZaME1CdTJGSUVjK0lRM0hoSVJEQjdTcFJIZXJ3N1FPdnFFT1Vx?= =?utf-8?B?T1Ivcm0rbDcrdlNDbC9Ib3UySkdldVp4YVlMMW9paElXL1IwR1pEamRmZnVa?= =?utf-8?B?SnNzUGNteTdyR0F1b1BZdE83ME9VZHBsWTFTTXZOZVB0bG9lYWdvaXp4MjVl?= =?utf-8?Q?cp8LtJsR5e3F1d7msE0pWwc=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 0d423a56-6c04-4b7e-823b-08d9b34dde73 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:27.6746 (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: oIHbAYWQ/T1bKQqhypyiEQ2dkL1KNfArtqv0nR4dWnIEBT6YY9iir/QGNJDdO6Zm+G4wyf3OedqTZG2/yT2sVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4764 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200166875100001 Use such helper in order to replace the code in x86_msr_copy_from_buffer. Note the introduced helper should not be directly called and instead x86_msr_get_entry should be used that will properly deal with const and non-const inputs. Note this requires making the raw fields uint64_t so that it can accommodate the maximum size of MSRs values, and in turn removing the truncation tests. Suggested-by: Andrew Cooper Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v4: - Rename _x86_msr_get_entry to x86_msr_get_entry_const. - Add newline before endif. Changes since v3: - New in this version. --- tools/tests/cpu-policy/test-cpu-policy.c | 48 +++++++++++++++++++----- xen/include/xen/lib/x86/msr.h | 20 +++++++++- xen/lib/x86/msr.c | 41 ++++++++++---------- 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-pol= icy/test-cpu-policy.c index 3f777fc1fc..686d7a886c 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -386,16 +386,6 @@ static void test_msr_deserialise_failure(void) .msr =3D { .idx =3D 0xce, .flags =3D 1 }, .rc =3D -EINVAL, }, - { - .name =3D "truncated val", - .msr =3D { .idx =3D 0xce, .val =3D ~0ull }, - .rc =3D -EOVERFLOW, - }, - { - .name =3D "truncated val", - .msr =3D { .idx =3D 0x10a, .val =3D ~0ull }, - .rc =3D -EOVERFLOW, - }, }; =20 printf("Testing MSR deserialise failure:\n"); @@ -644,6 +634,43 @@ static void test_cpuid_get_leaf_failure(void) } } =20 +static void test_msr_get_entry(void) +{ + static const struct test { + const char *name; + unsigned int idx; + bool success; + } tests[] =3D { + { + .name =3D "bad msr index", + .idx =3D -1, + }, + { + .name =3D "good msr index", + .idx =3D 0xce, + .success =3D true, + }, + }; + const struct msr_policy pc; + const uint64_t *ec; + struct msr_policy p; + uint64_t *e; + + /* Constness build test. */ + ec =3D x86_msr_get_entry(&pc, 0); + e =3D x86_msr_get_entry(&p, 0); + + printf("Testing MSR get leaf:\n"); + + for ( size_t i =3D 0; i < ARRAY_SIZE(tests); ++i ) + { + const struct test *t =3D &tests[i]; + + if ( !!x86_msr_get_entry(&pc, t->idx) !=3D t->success ) + fail(" Test %s failed\n", t->name); + } +} + static void test_is_compatible_success(void) { static struct test { @@ -763,6 +790,7 @@ int main(int argc, char **argv) =20 test_msr_serialise_success(); test_msr_deserialise_failure(); + test_msr_get_entry(); =20 test_is_compatible_success(); test_is_compatible_failure(); diff --git a/xen/include/xen/lib/x86/msr.h b/xen/include/xen/lib/x86/msr.h index 48ba4a59c0..4d84b7cf27 100644 --- a/xen/include/xen/lib/x86/msr.h +++ b/xen/include/xen/lib/x86/msr.h @@ -17,7 +17,7 @@ struct msr_policy * is dependent on real hardware support. */ union { - uint32_t raw; + uint64_t raw; struct { uint32_t :31; bool cpuid_faulting:1; @@ -32,7 +32,7 @@ struct msr_policy * fixed in hardware. */ union { - uint32_t raw; + uint64_t raw; struct { bool rdcl_no:1; bool ibrs_all:1; @@ -91,6 +91,22 @@ int x86_msr_copy_from_buffer(struct msr_policy *policy, const msr_entry_buffer_t msrs, uint32_t nr_en= tries, uint32_t *err_msr); =20 +/** + * Get a MSR entry from a policy object. + * + * @param policy The msr_policy object. + * @param idx The index. + * @returns a pointer to the requested leaf or NULL in case of error. + * + * Do not call this function directly and instead use x86_msr_get_entry th= at + * will deal with both const and non-const policies returning a pointer wi= th + * constness matching that of the input. + */ +const uint64_t *x86_msr_get_entry_const(const struct msr_policy *policy, + uint32_t idx); +#define x86_msr_get_entry(p, i) \ + ((__typeof__(&(p)->platform_info.raw))x86_msr_get_entry_const(p, i)) + #endif /* !XEN_LIB_X86_MSR_H */ =20 /* diff --git a/xen/lib/x86/msr.c b/xen/lib/x86/msr.c index 7d71e92a38..e9b337dd70 100644 --- a/xen/lib/x86/msr.c +++ b/xen/lib/x86/msr.c @@ -74,6 +74,8 @@ int x86_msr_copy_from_buffer(struct msr_policy *p, =20 for ( i =3D 0; i < nr_entries; i++ ) { + uint64_t *val; + if ( copy_from_buffer_offset(&data, msrs, i, 1) ) return -EFAULT; =20 @@ -83,31 +85,13 @@ int x86_msr_copy_from_buffer(struct msr_policy *p, goto err; } =20 - switch ( data.idx ) + val =3D x86_msr_get_entry(p, data.idx); + if ( !val ) { - /* - * Assign data.val to p->field, checking for truncation if the - * backing storage for field is smaller than uint64_t - */ -#define ASSIGN(field) \ -({ \ - if ( (typeof(p->field))data.val !=3D data.val ) \ - { \ - rc =3D -EOVERFLOW; \ - goto err; \ - } \ - p->field =3D data.val; \ -}) - - case MSR_INTEL_PLATFORM_INFO: ASSIGN(platform_info.raw); break; - case MSR_ARCH_CAPABILITIES: ASSIGN(arch_caps.raw); break; - -#undef ASSIGN - - default: rc =3D -ERANGE; goto err; } + *val =3D data.val; } =20 return 0; @@ -119,6 +103,21 @@ int x86_msr_copy_from_buffer(struct msr_policy *p, return rc; } =20 +const uint64_t *x86_msr_get_entry_const(const struct msr_policy *policy, + uint32_t idx) +{ + switch ( idx ) + { + case MSR_INTEL_PLATFORM_INFO: + return &policy->platform_info.raw; + + case MSR_ARCH_CAPABILITIES: + return &policy->arch_caps.raw; + } + + return NULL; +} + /* * Local variables: * mode: C --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200172; cv=pass; d=zohomail.com; s=zohoarc; b=bJ/tY689jJv3Zf0t1xilPZ1kCE2+E/9BQ3hrr4+ai7f6Akn4tQQ5fshAyXgrzqYSitnfDlOSyjfOapA3d+8peiybeUvvBED7wpFTgz53ZFowBgYxod1NZSuSwD4Y23U9t51PfE15Foc0xGhcpzhey2wvhN7Er2hkpx5SwULhymg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200172; 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=pYxN81WyLozHtjD5+pJmUF7N4C4RnSrAAPdZ1oW1kQ4=; b=YvhpA2JdrcMZ52MIDQpeT4N8mq5xgmOfTx9lkkrbFnkkO16tVWC1tCu0RnBG2Bqj7bI9LPd5lsFSuEci4bpVhv3g3YwQRfxUom3TK8QHlYI1p0v7Yo1ZuTytA2kMZGJxZcxhv+0xfS3vlILvypkdpl/mIUJ+srjyteyICdTbeT0= 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 1638200172237624.0950743602245; Mon, 29 Nov 2021 07:36:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234639.407231 (Exim 4.92) (envelope-from ) id 1mrigy-00062w-Ru; Mon, 29 Nov 2021 15:35:44 +0000 Received: by outflank-mailman (output) from mailman id 234639.407231; Mon, 29 Nov 2021 15:35:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrigy-00061l-Lb; Mon, 29 Nov 2021 15:35:44 +0000 Received: by outflank-mailman (input) for mailman id 234639; Mon, 29 Nov 2021 15:35:44 +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 1mrigx-0003uH-Oa for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35:43 +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 027fe5e0-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:35:42 +0100 (CET) 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: 027fe5e0-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200142; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=vJgygXMLh29agTSCf9vMlpEoMHoCQz1edDiz8YwvCI0=; b=hm8LnQ4qQvzx8HtAATk5V4LOkJ+mHDZIqHv8XbCL/ZZkX+A2gyak1ZvO aQ9SJ22fWj36MW3BTCO1tSr8CL+TjEnkSTLbpuaQavgelsgOgxD8PCki/ 2L2ucIX9fDyFz5XvuI/cCyYY+yguVTKB7eIVrmYHfljLtMa8FPBSwgAWG o=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 1ZSfBFPqGxDybh1oAi0KUXINMp+fbwVLGU4D1XqzRuVx2PL+ap3hw63KAt6l3n0ETM4OxNrEVm 9hDGUMit99a18B1rM3DD19Gb/TldzS7g5M+k0jGH2mBo/Rfsb4MfyfIFn+UhiXD66+SGZROrq3 TY9oRrZgJSFcAvG1DXi0xmAQiiLNQ0GlA6efazHSZSU2qdV6bWpwyRUMGHP20rle6VXVOMTkKZ ybE9n5Mu885U+V7bEKeTHjzty+tg/aEyrG5epL1b2ymrcpCmJdcAFyr0yO24bpBKT0Ozd1zxtn FKWcGYNsgPgxE4CnzuR7Vb2T X-SBRS: 5.1 X-MesageID: 59208295 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:ypcf+6gRs5L8MrZwcwkRyDMEX161gxcKZh0ujC45NGQN5FlHY01je htvD2GEOamJajD3fIojOYu09RhVu5OEy9I2HAM+qng2Hy0b9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29cy0IDga++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /1ivLXscDp5YJbykc4sTxBoHAZdOoBZreqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2rzwkOnTpupE36zPKOHxO4wSoDd4xCzxBvc6W5HTBa7N4Le02R9t15oWTayPO qL1bxJNRhv+QiVqO2sPEb4Vx/mMtFLHT2ZX/Qf9Sa0fvDGIkV0ZPKLWGMXRUsyHQ4NShEnwj mDJ5WPiGTkBKceSjzGC9xqEluLJ2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24ma/RNB3O 0ES4jApr6U56AqsVNaVYvGjiCfa5FhGAYMWSrBkrlHWokbJ3+qHLkcNZ2J4VYx4j/E/bw023 2+GuPDuKCM65dV5Vkmh3ruTqDqzPw0cImkDeTIIQGM53jXznG0gpkmRF4g+ScZZmvWwQGitm G7S8EDSkp1K1ZZTv5hX62wrlN5FSnLhagcurjvaUWu+hu+STN70Ptf4gbQ3ABspEWp4crVjl CVc8yR9xLpXZX1oqMBqaL9TdIxFH97fbFXhbadHRvHNDQiF9X+5Zpx36zpjPkpvOct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xAvM4Ba7G7QRHi8pV/X1wzpwF8Vmjbf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnTC/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKprzPKN MeT/002cwmM29zNxvizyxSKZ2XLzsO9y69Mwg/Upf/6UkToJh7p3FosvD30E1ws67VcKM0ld gsBJ4Y442mfvVmHp6VO91xNPdfcla9OS4kEFjiaWgPR5t3cE4klfbMkcEIDaeRCdo18Kc= X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="59208295" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WVtAsq/W7tt+DTWedUQg2OAB8Uy8YUxc/eV3bH+UfBXVFp23/2OZFj98Kj3u8DDh6CwvLYv2tbr8jHBnBxa574MKbllRhgNfJNwi2k8p4JSof4QFYkk6yfu2V3HsArqWQF5QOE0y6ZngJsGZPbIdyH/VHkDQf/40DQUoFrQk5wAD7BLiiv/LrsZ6YVv2Q3cB8ubZS1Ji1F1mY7l9LHQyT1I6NWy4CXAe4b+/B9BJRo4VB2v5ibIigdIhs0npLG06KZEwohIOsqL8FJlEXmt4T7hmdXIBFAGn3avRubyzKcICj1fkXKlKaq7BCegTP17pEBc6Jv/qGpdGWaOqhVh7vw== 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=pYxN81WyLozHtjD5+pJmUF7N4C4RnSrAAPdZ1oW1kQ4=; b=L53FYGTcnOkK1/baj7Wi4cWdM5SOBQDibhULClfwQAPivcSa5Y/PZUIQm6a2Wf79blBssPLD8iZ1qI0bvkcjWnmLpULN4TLuZaNzH9hfbUQZGIniYum4FPMnStfbh4jRmnMDtAZq92pUEbWfQzA/vXcC9BfJ0pUKx0J6j8XgOwK6+5qfjDXH5rJor/TCJ5sc7cE1D6ysN6Dz0fF11/H8KNnj4XnunzxY1Ec76vpdEJf6ytJxHU4W0A4e5uGzvQGNza8nw8TwNx4I8KRhtyofP2cp2qcc2AyTBUVCPl9U7xUIWRqvf62AzsXTr6UScabDdv0ayDaNFcmpYatb7g9NmA== 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=pYxN81WyLozHtjD5+pJmUF7N4C4RnSrAAPdZ1oW1kQ4=; b=QiLnY9101q/y+qyl/gfbEcJSpXtDKcVqdVP/i3CPp1ZzOKzRRLy+djTMSwVIGB/A32pZUc/FMmp3lg7VoKCQkbqZOYSTua1DsIg29mlk9dgTQyHg11rSEGwCx71I+0Zm05eKy0//86WBPxldaPL0oJR7Ene+AU5i9ySKitYowX0= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 05/12] libs/guest: allow fetching a specific MSR entry from a cpu policy Date: Mon, 29 Nov 2021 16:33:48 +0100 Message-ID: <20211129153355.60338-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0089.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::29) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e36462f-76bd-4459-68af-08d9b34de16b X-MS-TrafficTypeDiagnostic: DM6PR03MB4764: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vkLkgc1wTv0JeR+zUAk6pPFXRKu4Rgv5ZTA+mQDlkBnLtztFQapr1Lovu+MQOi1QX3sanzfk738gR1BABOT8USjJxM2aNh1tIj5PyCNk3wNejAMh37i5up9o8d85L93gvYy29tFLqu2IWAPF1XYsmoos7XCYL7gZDReuhbKbX36joqh9IPaZlK/XXlWPv0XKExz+v3SytPayBZmtHkP+A74ky9rUbiY9SXsEgRe5jVIa2RO7o2EZu5Q0bAon+BLcUGIgt4pyUxRvn5CGWIsh+bZ+TWHoCRWhUqorLTnw8A09ahOaD6s4lZCrZ2b2J2v4+19b+y1cgdGuMsckvWt3CBcNZ/3zkTX1nm8dg8VgQOmt2uOLMT0JvhSbLSlsrilL/34HAaP0fyybJPub9YGa3LlbpB3snyrJuh6+LL6NHw3PcJfpICtN5A6ypqOp3/U4frfEivnyg2ovFpFX3Uv0D884W1rroK/ZCoqyIfJYje4l3fBrfFqUNgEdS/K4wC//95cNWjQhvtLUewo7xdFot+z61XKKehzlM2bI3OfFTsXCf3RA5PwcfVdRnPOKVTSWOxsn6LaV96vItc8laD3CLKfjKs9B/JL9fLitkjdapGT8wscLZQHXPPnD/065CnxRktdSMpDVaviz1M1yUJql5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(4326008)(2906002)(1076003)(66476007)(6486002)(82960400001)(38100700002)(186003)(83380400001)(956004)(2616005)(316002)(6496006)(6916009)(26005)(54906003)(6666004)(36756003)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= =?utf-8?B?QWNPNlhiTW1RSEpjazdCOE40YUhsZzcvU3VhcWw2N2ZDYUNnZUd6TWZ3OVEv?= =?utf-8?B?THM5WjJyQzdnd0JrM2ZuaWdOVCsxNmgydTBHYXBuRHNLYkNFYjhxVUozWHYw?= =?utf-8?B?c29vK3JnNENxbjV5VVJZd3BBNHZNNGR4NXgwRXY0c2xEYlJnWmx0anpwME0y?= =?utf-8?B?aDN1aXFHSG1QekVGcENVWW1qbmdVVDRJSmJZb1hWbWlzeXRkZzQ1U25JQVdq?= =?utf-8?B?TVJxUll5Y0pGaW5lQlA2dFB3dmdBbHVzV0xNdk1KN1locmVXSFBHTVN0R2sz?= =?utf-8?B?azZaMGFYdVBmWkM1cHRQeDZtdzBRQmI0eExubUsybGZpS1FPQ0dMM0lMSVht?= =?utf-8?B?QkFoN0dydlVMaEdRQ0JUc0VPUXB0MHdWbnpKVVhTTE91LzNLbHdPdUNJMlNn?= =?utf-8?B?NnlSQjVxVHBCaE1RN3FyYVBuclJVOThBZGE5TWl0MExkdUZDOW4xcVZJM25C?= =?utf-8?Q?ZnhJ0QhJxgJC4+jGDolCwsw=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4e36462f-76bd-4459-68af-08d9b34de16b X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:32.7413 (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: autdN44XvNROCNLm1uPB7WxNXoLnhA98fmL/2vtKtD+FelWAxogVUSbV25vnpEQDYvOT9rBj+6fVOGcJYeO47A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB4764 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200173499100001 Introduce an interface that returns a specific MSR entry from a cpu policy in xen_msr_entry_t format. This is useful to callers can peek data from the opaque xc_cpu_policy_t type. No caller of the interface introduced on this patch. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Use x86_msr_get_entry. Changes since v1: - Introduce a helper to perform a binary search of the MSR entries array. --- tools/include/xenguest.h | 2 ++ tools/libs/guest/xg_cpuid_x86.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 0a6fd99306..2672fd043c 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -810,6 +810,8 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu= _policy_t *policy, int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *poli= cy, uint32_t leaf, uint32_t subleaf, xen_cpuid_leaf_t *out); +int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy, + uint32_t msr, xen_msr_entry_t *out); =20 /* Compatibility calculations. */ bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 7779a3e1dd..859c885c15 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -878,6 +878,26 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const x= c_cpu_policy_t *policy, return 0; } =20 +int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy, + uint32_t msr, xen_msr_entry_t *out) +{ + const uint64_t *val; + + *out =3D (xen_msr_entry_t){}; + + val =3D x86_msr_get_entry(&policy->msr, msr); + if ( !val ) + { + errno =3D ENOENT; + return -1; + } + + out->idx =3D msr; + out->val =3D *val; + + return 0; +} + bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, xc_cpu_policy_t *guest) { --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200167; cv=pass; d=zohomail.com; s=zohoarc; b=E7uQmH1iOTXvHiVAx+bKV3taPnOdKxbwoI3J62NDP1y6iK6jrfQc63LIRVZ5gRXGmzC830SroTYG6WYV7G8x8Vc7b+28DHeVr4NUfyRhSUn9CtPY9eDVpNLosSMO8XYzBMAR6/FFXfiR8P2XeR2isoDqE9MlMxTHm2uRBl0l/Fw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200167; 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=pRaYIUfkMkzZXE8d3moJMkHiUafesA///nNUwZGhtBY=; b=kOZjwxXWYrRq0w42zUB5B8ShOGkD91xv4QOZXKHZPkmslMVAHnTmAxuYjhj5M/8q05AO2hCUQhXIs9BIjIOXiX6DIreJpVSv8+eH/FQE+9/f0CEJw+aU82jXskXZ/f9oTAOfrJH/IFEm0fQqsql3WNBuDXrqr5WK2TdKZT2MBR4= 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 1638200167506883.7593219576564; Mon, 29 Nov 2021 07:36:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234638.407226 (Exim 4.92) (envelope-from ) id 1mrigy-0005xK-9w; Mon, 29 Nov 2021 15:35:44 +0000 Received: by outflank-mailman (output) from mailman id 234638.407226; Mon, 29 Nov 2021 15:35:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrigy-0005x8-6L; Mon, 29 Nov 2021 15:35:44 +0000 Received: by outflank-mailman (input) for mailman id 234638; Mon, 29 Nov 2021 15:35:42 +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 1mrigw-0004Rj-BF for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:35:42 +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 018cf07c-512a-11ec-976b-d102b41d0961; Mon, 29 Nov 2021 16:35:41 +0100 (CET) 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: 018cf07c-512a-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200142; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=LhjyiDF5LKmTNDh163h1NmBaoZfFCmFl7Wc/SQikn0I=; b=UAM7ph+FJIJSK4oXCjsPHTMMWazyJftZurjhvxReXSQxy3Pc6TSrN7cp 2NMBPMx2S2sxBPpLzDSkPV3eTruhWF9hAAbyT9svRr6a8jZRXCrQ8QloV BxADZN8DhogfeIkKYXab6ukzEbGETNk5MjE1xVy3FI7Cq7gDGe1wlRoav k=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: xHD3hhj+UiJhUNcAMyQWh+LDAKPr0F4m4CZbU+qxvnr9rkTweD99LLn8BgQ9In7wABF/Q6vFky gh5yEG45JDUKV/7omeNXXVW55fxgs2//Bqec4CAGZvvzO/nftgl48mHEuU++fxI0UmYeC3cj+A YUFEbuP3lgqjbH9GDcIqKzTlWc2C/6uLkW8+bl3RZr76Pb/pvo5hIKP9eOhpH1DHBadBMKBmxd OaqnOrj+KU5B/gwHYQmwVIICpFw7xn9arLHjxWS0iEpLOitA3inUhLvmfIaQQKG4jR7XDsi3GZ uZ14+M14+H3en7Anp+hSDotL X-SBRS: 5.1 X-MesageID: 58333467 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:sEYrqaj7KaYYKaZorcB8sEh7X161gxcKZh0ujC45NGQN5FlHY01je htvUGmPOv+LZWH1fdl1Ydi/8kgFv8OBx9ZiHgVuqC9jQSwb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29cy0IDga++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /1Mm77pciAJb5HVv/g2Wj1JNh5nMpJZreqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2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SLgZtPu6lKyuMLsAe6Q BvSqNxTOLHPM8L5Cl8BYgEia73bh/0TnzDT69UzIVn7u3ArrObWDx0KMknekjFZIZt0LJghk LUot8Mh4gCijgYnb4SdhSdO+mXQdnENXs3LbH3B7FMHXubz9mx/XA== IronPort-HdrOrdr: A9a23:3TrL6K4J4XkQ8uh1OAPXwVKBI+orL9Y04lQ7vn2ZFiY7TiXIra yTdaoguCMc6AxxZJkh8erwXJVoJkmsiaKdgLNhQItKOTOJhILGFvAF0WKP+UyDJ8S6zJ8n6U 4CSdkONDSTNykCsS+S2mDReLxBsbr3gJxAx92utUuFJTsaFZ2IhD0JbTpzfHcGITWvUvECZe WhD4d81nCdUEVSSv7+KmgOXuDFqdGOvJX6YSQeDxpizAWVlzun5JPzDhDdh34lIn9y6IZn1V KAvx3y562lvf3+4hjA11XL55ATvNf60NNMCOGFl8BQADTxjQSDYphnRtS5zX0IidDqzGxvvM jHoh8mMcg2w3TNflutqR+o4AXk2CZG0Q6q9XaoxV/Y5eDpTjMzDMRMwahDdAHC1kYmtNZglI pWwmOwrfNsfFL9tRW4w+KNewBhl0Kyr3Znu/UUlWZjXYwXb6IUhZAD/XlSDIwLEEvBmc4a+d FVfYLhDcttABGnhyizhBgr/DXsZAV9Iv6+eDlDhiTPuAIm2EyQzCMjtboidzk7hdUAoqJ/lp b525JT5cZzp/8tHNFA7dg6ML6K4xT2MGrx2UKpUBza/fI8SjnwQ6Ce2sRA2AjtQu1P8KcP X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58333467" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRKdf7KKkrxDGMwsu5FSTEHYAtfqQdnkVt065obFHAna4G2DD7WoQe6BjMdHo3KRNCko9Lq490YvTSElJwVlp2RnzF3cLgE3pElH7XhEYvmT8dDwkttrLEQxykDyLiTKcdwo3P2TBo+PYXkGFhevVSKY+O19rpfqunxtlG2wrO8oA0i6KotvbFKQ7IBdKtai89X6D0LMDf2JDVBttrcaRs3zCYQ/vDaeeiXtUWmuRIr/KqFWLHxhSAs+ULbrjrCpZ9Ue4BRCzuwfLzz9g/G94KlGaTAelYXEDyVYwJTyE3GflOEDuRUocpzY/EvKdXGaiqrUwzkHuo9SHg36i45MUQ== 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=pRaYIUfkMkzZXE8d3moJMkHiUafesA///nNUwZGhtBY=; b=BZxhq1icNMM1CoGq/O/DCn/hcTQR1pjO1jIeglGADsUqvHWg3Omi160fA+6TiucuqhwBRmNYBT8CXFD+XsMhDWS5DX1BpPAwk1JUmDwecxsptfVqS4+UeZoaT7lDFnsd69RG0GL3zZzyRbpD8BMy4/O7+64XzJovUDoAWBD74flrj7mc07H4qatuQX8XnttbhLabxEWrCHt9ulaLyVhjvE2LJX/eCw6ncGmLOiVpUd04wpDfgUtz0edtqzBJw4/LKS5fh53+br+NtBiGoIThbOuJihG9kml7ioQQoMfaCP2WFhvzYJnLAyjm7tbSm0MdV5XeaK3RC1Mm1eH1kYEg/w== 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=pRaYIUfkMkzZXE8d3moJMkHiUafesA///nNUwZGhtBY=; b=Zl3VgODgX/KHkMVJjwOWxmUPcOkM1NySylF7FVh4sQFggYd7HsiHoW02cHKvTTq9Ppgt0z+9XVc7PGL1m/KZpy74qcTJ21oPsdL436C3gP15sQfjmWeMpG6YPhupYCWIMBKbiVy18L74NfdbUIZuhsnZeAki/i7iapbh2MMYC8g= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 06/12] libs/guest: make a cpu policy compatible with older Xen versions Date: Mon, 29 Nov 2021 16:33:49 +0100 Message-ID: <20211129153355.60338-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0079.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::19) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d34d6d2-74ea-4534-dd15-08d9b34de3f4 X-MS-TrafficTypeDiagnostic: DM5PR03MB2842: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rqLlYHxjwOY6uVrO6MpidNNOA3iK1YoGdzwGYezHdQATvewCg8COK9yHDRcEH5hbY7UrRc0hIpuG3xJr1qzQ8IKCKxVduGj3yQOZWHOjSc5uswIBuEaxLG+9TKmbKRp2NslTL++p7FrgVgWNT3MdSCCBGGbJfeyOTlexb7JhlhDtfSOW3pJ/OSeF1LP7PLcG4WV0B+I1/knzPFVKeidKZ53aKw6hCmF7D5a+joLEAHwnal1cARragB11ffqYgBYJhuEw5lgXbpk2In40fP0fKG+Qq9wbTZK89CHBvnYIAb7XCs7HFB8JfN6eghf82YAzH7GVGqL98le11/Tz/a5grnOBRoRoMUmjP0Iv4eHt70CJE8K8IIErh7NzmJytmwwUNqzW0+jJKWq7+BomBYL28+TvzAmT63/wAkrZRRMokuDvH6N/31VAxltYEi29xgJJOwJuQodik6VTj0dqN48VDV3sl8W+IMlxoE8W10O7nTP+F1KF9J0UJUm43K3HLSG+p8JGTjFVb+z+kAab9TJBeL9c0fw2TNAudgZQhNwjuH9J0OjOzka3t4Uc7BYieZ0kyCMHlI8FuPk76yXOAn0aNcEGhNjEid1WYRW3YGu9+LdP0zaQ0XUz4DKW3cvU2qI03IKAtmNODhnJzD0hS5EBiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(86362001)(54906003)(8936002)(2906002)(66946007)(6486002)(316002)(8676002)(956004)(6916009)(82960400001)(4326008)(6666004)(66476007)(66556008)(186003)(83380400001)(38100700002)(2616005)(26005)(508600001)(1076003)(36756003)(6496006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?THp5d0VmT01ydXJZS0RqTUkybTVQT244UFJRdFc2c2hLZzVkcHV0cXFTby9v?= =?utf-8?B?K3hUZ0ZkZTZsd3NsZEZoSGZKTkZxSmIyckg5OWxlWkNvaE1lUHg2c2dmMm1T?= =?utf-8?B?ZjJaODB4VnhsWjQxRlpaZlp6aHJwSkM3UVRZQUhJbXUwNE9HUW9BSWFBL3NC?= =?utf-8?B?M0R3WGttWCtpODZ5M0dBQlFDUnFtcEFORFFHdlFoSUZLZFRLRVpuWXQ3bERq?= =?utf-8?B?TllkYVBDOXlua2tISmgxSkpTUFpqYkVLRldielF4RExTSlNXUGFlWUwyZm1m?= =?utf-8?B?Y0JWVCtOSjhYVXZBTTFIZlhYMFU2SHY5YTZuTWRtYmcwa0VKekN1WDZIRDJr?= =?utf-8?B?YXN4cjBBaCtZbm42aDRxM3dqVlpyaVR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7QGqXFlmmQ0FunAZxIVxfw=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5d34d6d2-74ea-4534-dd15-08d9b34de3f4 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:36.8970 (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: xrFhBO2QQDJEnBWb2kj+0W0Y94+fxmzgwMQv3ks6wVhWSfReDrXdb0v9Ybf2vZSTPrYCPOPfZ8wMZvIgHYDxmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2842 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200168212100003 Older Xen versions used to expose some CPUID bits which are no longer exposed by default. In order to keep a compatible behavior with guests migrated from versions of Xen that don't encode the CPUID data on the migration stream introduce a function that sets the same bits as older Xen versions. This is pulled out from xc_cpuid_apply_policy which already has this logic present. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Rename function to xc_cpu_policy_make_compat_4_12. Changes since v1: - Move comments and explicitly mention pre-4.13 Xen. --- tools/include/xenguest.h | 4 +++ tools/libs/guest/xg_cpuid_x86.c | 62 ++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 2672fd043c..281454dc60 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -817,6 +817,10 @@ int xc_cpu_policy_get_msr(xc_interface *xch, const xc_= cpu_policy_t *policy, bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host, xc_cpu_policy_t *guest); =20 +/* Make a policy compatible with pre-4.13 Xen versions. */ +int xc_cpu_policy_make_compat_4_12(xc_interface *xch, xc_cpu_policy_t *pol= icy, + bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 859c885c15..bcbf9576c4 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -432,6 +432,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, unsigned int i, nr_leaves, nr_msrs; xen_cpuid_leaf_t *leaves =3D NULL; struct cpuid_policy *p =3D NULL; + struct xc_cpu_policy policy =3D { }; uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; uint32_t host_featureset[FEATURESET_NR_ENTRIES] =3D {}; uint32_t len =3D ARRAY_SIZE(host_featureset); @@ -496,23 +497,9 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, =20 if ( restore ) { - /* - * Account for feature which have been disabled by default since X= en 4.13, - * so migrated-in VM's don't risk seeing features disappearing. - */ - p->basic.rdrand =3D test_bit(X86_FEATURE_RDRAND, host_featureset); - p->feat.hle =3D test_bit(X86_FEATURE_HLE, host_featureset); - p->feat.rtm =3D test_bit(X86_FEATURE_RTM, host_featureset); - - if ( di.hvm ) - { - p->feat.mpx =3D test_bit(X86_FEATURE_MPX, host_featureset); - } - - /* Clamp maximum leaves to the ones supported on 4.12. */ - p->basic.max_leaf =3D min(p->basic.max_leaf, 0xdu); - p->feat.max_subleaf =3D 0; - p->extd.max_leaf =3D min(p->extd.max_leaf, 0x8000001c); + policy.cpuid =3D *p; + xc_cpu_policy_make_compat_4_12(xch, &policy, di.hvm); + *p =3D policy.cpuid; } =20 if ( featureset ) @@ -916,3 +903,44 @@ bool xc_cpu_policy_is_compatible(xc_interface *xch, xc= _cpu_policy_t *host, =20 return false; } + +int xc_cpu_policy_make_compat_4_12(xc_interface *xch, xc_cpu_policy_t *pol= icy, + bool hvm) +{ + xc_cpu_policy_t *host; + int rc; + + host =3D xc_cpu_policy_init(); + if ( !host ) + { + errno =3D ENOMEM; + return -1; + } + + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); + if ( rc ) + { + ERROR("Failed to get host policy"); + goto out; + } + + /* + * Account for features which have been disabled by default since Xen = 4.13, + * so migrated-in VM's don't risk seeing features disappearing. + */ + policy->cpuid.basic.rdrand =3D host->cpuid.basic.rdrand; + policy->cpuid.feat.hle =3D host->cpuid.feat.hle; + policy->cpuid.feat.rtm =3D host->cpuid.feat.rtm; + + if ( hvm ) + policy->cpuid.feat.mpx =3D host->cpuid.feat.mpx; + + /* Clamp maximum leaves to the ones supported on pre-4.13. */ + policy->cpuid.basic.max_leaf =3D min(policy->cpuid.basic.max_leaf, 0xd= u); + policy->cpuid.feat.max_subleaf =3D 0; + policy->cpuid.extd.max_leaf =3D min(policy->cpuid.extd.max_leaf, 0x800= 0001c); + + out: + xc_cpu_policy_destroy(host); + return rc; +} --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200252; cv=pass; d=zohomail.com; s=zohoarc; b=BElxryI7UlC7D2RcKonLge95txTTvv0EamLLqqQDSQUFaGVav6hQNY8CakUdp/Y1tGVDgKfBnMdlhNgor0CZhyEdpLc9CRNZqpSgqzBQpPrNjoYqcjW/s48IJxcKS1tkWrdqbdJSQxUq8LiloLZKOA8q/13rLDdDI/r/PzYRsmc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200252; 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=/v1JZ3HVnYuxeDPR6w/pprUXGuHXUqzMmPa9m3/Cfl0=; b=BkJR5A2hYHIiOdsy5lYOnt56NqDI3PXucZ91NDQ1mzB/JYqfGXd4aicV1tq/cclYD4xSdBJePW7ejCm+/86ibHIjrcvO5fHkdXIdsphzkrmHV5Ep2KCExUJ9aI6AH+INcV4ObOZkTrQvPOIcl9tijDk9JkfZDVoG1OjjILzlAfs= 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 1638200251987703.7478693713784; Mon, 29 Nov 2021 07:37:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234681.407298 (Exim 4.92) (envelope-from ) id 1mriiH-0001HE-DB; Mon, 29 Nov 2021 15:37:05 +0000 Received: by outflank-mailman (output) from mailman id 234681.407298; Mon, 29 Nov 2021 15:37:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mriiH-0001Gi-1g; Mon, 29 Nov 2021 15:37:05 +0000 Received: by outflank-mailman (input) for mailman id 234681; Mon, 29 Nov 2021 15:37:03 +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 1mrihH-0003uH-Tc for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:04 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0d5a4127-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:36:01 +0100 (CET) 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: 0d5a4127-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200160; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=d9tlpzIvXcOXPpebR2FdU5F5aJVq5WGS3uJketsR6ps=; b=WFhKzMrlMRxnPxvBdZA2+Gsc4n0+e6tK3BgPzmgEsr1IofrlZG1PbBPj +lRB2MxJIj+1Gw+Y7q+90aDP9AarQHZdU6Xhg57nhhvLibXTj29W8hgsP BZTI968q9p+N8sDWKuYFlFQUGZ9gQ1JfdNykEkw9bH8uO62MhVT79DXxa c=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 3IKHmyhzOs8grf709M+ihYZLdZcTQOsp+NKmkaIgnEfuGfC+O0TaQzqlLjICYoDIAMlOQsARca zez4yWljbZwiUv+aGYVG16NgTrkOJ4BQbZM/nINaRXMecg2WgpcNhdDGblA7zLx0nw2w/q2zhw aRoQDBqTV1tB3HAPiLUxaiERrnaRqjIKCX9By7JuE2kabrd8AzZvhU913gEcZerUAo1+FDvgvM 4dQQ4asjJbe+QeBVM0DES19ojWoZ7YV6vVyvl9Ogg2opY1EqUp3QIyCipmRTQbMP1XfOaro1a0 8D+UjFuesAy0LoFUliwGUh9E X-SBRS: 5.1 X-MesageID: 58773277 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:zdH+vqkJXE7LBPkmvggQfrDo5gxjIURdPkR7XQ2eYbSJt1+Wr1Gzt xIeXTyDPquNZzehf4pxYdnn9kgP7ZaDydAxS1RsrHo3RCMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA187IMsdoUg7wbdg29Q52YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 IRA6cThURkzB/DvqukWQgNmHX1aYYQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Gpg2Z8VR6mBD yYfQTpVaz7pORF3AW9UFs1ln+aTrXfOKyIN/Tp5ooJoujOOnWSdyoPFL979atGMA8JPkS6wp G3c+H/iKgoHL9HZwj2Amlq8i+mKkS7lVYY6ELyj6uUskFCV3nYUChAdSR28u/bRok+hWfpPJ koM4C0soKMuskuxQbHAswaQ+SDe+ERGApwJTrN8uFrlJrfoDxixV2VYFm9ZdsYf6ewESDc7z GGHw/e1LGk62FGKck61+rCRpDK0HCEaK24eeCMJJTc4D8nfTJIb1UyWEIs6eEKhppisQGyrn WjWxMQrr+xL1ZZj6kmtwbzQb9tATLDtRxV92AjYV3nNAuhRNN/8PNzABbQ2AJ99wGelorup4 SBsdyu2trlm4XSxeMulGrtlIV1Rz6zZWAA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DnAghuhIK5hR7qBljYop/zH0idnrP D85zMbe+hj4XLYeW+45TPrxgnbyT4rr0TvzFeJ6EGT6fDRdXYfMY5slIhZehzW5w4Lp9dnyp 9G2Gqfqt5+EQ7AtD6V3amJazha0m6P5VYym+8aiHJSFaEEbqVKkIAZ9ERJVL8dASPB7pw9Gu UGNrCc2B9vSyLZU5nlhBgr/DT1NU5DWituA3Jy9PB96gIm30yQlCAjtYsidnRpzuN1d3AL3Z WDDk1SrsA6ciYhV9MKOA4we7rENoXze2O5DIvrGyWdKEgmAQOHl3el2sR+2AmVEKZ4u6fa3q 6xCW9liQ== X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58773277" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFULj7MRVyJGzd15HojUePQQSPwX6jtMNmS1gv60tZuZBBiQXkzBPtq0ztNGXCVXVaRSNBa/aKM5FIK07rukWR9CoMLAllbvqVuQd1BT9Wdkhj9W8mq2USkotpHQSJSWvWbf278gGtNONzhbmDFo5HoLRhw5GNl4wiLbGA09bkyoyT8sm8B1rMyTgxzn3VfsfVhxzwiGb0ys87aVKC7GtlIBAQ0RR8iafMk5sm9ciPDWuPP/cyGxz/vtwy7T7GatZdIGaESIm3sXC8Nh9Xl9PE1LQkDiOS9k9Wdu99gfdiTVjP+aH/mx0wfY4FeIhqrfJx14ppXBKv2xvC/s+bPX6g== 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=/v1JZ3HVnYuxeDPR6w/pprUXGuHXUqzMmPa9m3/Cfl0=; b=ICqptspAX7zAQ1pUuLUK9zHu2pJB3Er2WC2CaVwRUQKEOA1e2cdVdcFpS/0cjuHoPPLqozjhIYt4J4nG0D/uNMhhGBnOZJezUeqTzFYDdjoUdNkknSvaCpcL++u7AbdS47IeaTwD2Qpcpb+9/nxWsA/3ad11cVP3X7OEMwKKDlBKntoR2S5IPRNjSgZI/2xcWF8TX+tNJ/nyLsPaN6iMGf1X96R/+clvCPiNxwKbSuTGVYoNaWKaELP1WDTVG7PPP+NkKFM600xuOeN7ZkjII07oca893QpWrRtwcK0CLD9CQlF0I6CQdL1J1t4o9K8eJLDdqAs9PUhJwmp6QHemZw== 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=/v1JZ3HVnYuxeDPR6w/pprUXGuHXUqzMmPa9m3/Cfl0=; b=YHMOF8LrAxE9Kgbr9/vpZDdTEIHNhRAuyqO4k11IFuV3ofxiSuJMzCGKmVyySuJwamtZja2iqpxrG7yN4JV0RsJETbeMrAmRz6NWKopRhvJx11/Ck4MS48JRHnig64jz9fQRbP03eDuQVX2DhEaWd0qgOw7q3yYFDARTeF8lR9c= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 07/12] libs/guest: introduce helper set cpu topology in cpu policy Date: Mon, 29 Nov 2021 16:33:50 +0100 Message-ID: <20211129153355.60338-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0096.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::36) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a939fa0-2661-4d32-f541-08d9b34de651 X-MS-TrafficTypeDiagnostic: DM5PR03MB2842: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1169; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qXA/uMZUKZM02CHloLxKIUH3VU5iPgAZkoI4viK+MIIKQuuP27l8iPK1d1b/qvGxgLhcDzuiBYvuut0ze8p+b4hN6UMitcDgYOgNdt6/03Z0sGFHIL0R/cLz6pYlWv+d6/i06g+4UxmL4NYduJVyM2bU23y+IDM+azo6u967/Augk740KLmTnwkC860x74uWIQYeX2dNP8cqAejv/GMkbuHQ4snYdLtWVT4nv2I462VUAMnEb/bwzV98U6YnGFe4Jp0JBBr6iDOst7QasL29QDXoz9IlM6VfB7aOoQZR3DSDLF1TsVLYbt69vTR/Fq5x1nIl55HGY4/TjI3c7EikYxsu3ncsF/roKixHf2KR3mdJoVymvamZh2QIP1qu1W7tJj4OoQSjkFtnt7k/1rhHMi6BN7N+oqcILTGo/9H96L9HvWVaauuVSKtXX1L+qfMGtvcCdlGSCaUCDcJpFObdkn9MQJ6FgqKqsNAN77CW1/7cbAJ/9/axhUaJmDxjjniXXBeZKqAELs4w0sxsrZ3NBCaZBW983dHpya1wqGm5JW0knof0T+m77K2qgCbONgZvmmBRnmTFEVHHOk2l8Y3M0JNIsgxQN6RdRXhZgYXgvFpsOsCnKwo2l509ITrtTmYcV3DUfPfURoseAF2sKkXnAA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(86362001)(54906003)(8936002)(2906002)(66946007)(6486002)(316002)(8676002)(956004)(6916009)(82960400001)(4326008)(6666004)(66476007)(66556008)(186003)(83380400001)(38100700002)(2616005)(26005)(508600001)(1076003)(36756003)(6496006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1dGOU96Vk5PRjNWbnZyejhYcmpxTTlJNzhhTDZ5UkNyUEhnNzJsTnpIQ09q?= =?utf-8?B?KzcreHlTQ0t2U2FhNFRoTms2MzFDaVpIT3IxV2ljNlk3SGFqU2MzRXVDejJa?= =?utf-8?B?Rk1KdS9xUk1lUWZXUkM4c0w1dzZVWjZFbkFGTVdLdU1ROEwvMkZXTmJIRW16?= =?utf-8?B?VjUxWTY5TjlCaTNUSnFHYTB0aGdlWFBGWHZHT3RScUM2UGh2SzVUV2lvWGVw?= =?utf-8?B?UGt3Ty9MRGd0SzlUQVlrclZkV3o5RitvTk03anptemE4ZU9sdVA1SHdOSTIv?= =?utf-8?B?UUk5VUdmMFA1bmNpRGZUNkdlQWNVbWZhbE5mdW5xVFRYcDBlUkJ3ajVWekV0?= =?utf-8?B?cjlKZFVvUVVWK1FrS0tPdURvQWN4UjRwNVdTdWRzYWtRTndxZkUzUy9oc3Qz?= =?utf-8?B?MTRYeGdQK1dDT2F5aUhWdFpiV1k0RUZ5aWJld21EbFVkVVdhdng1T1dSaWhM?= =?utf-8?B?WkFOR2l2ZGVZNFl3VTdQeFBiU2dhTlBZWXg4NVRJY3FYcnRyRGwwUnVDZ1pZ?= =?utf-8?B?aFNtdnVQWEM5YnZ0bFMzakprSlFYd3VwVUR0YTIvdGVaTVlvbVZmVGJxZXB0?= =?utf-8?B?SmY4eE5tdk8vditBSWUzczQ5QndZTVR0Y21NRFRzQm9sbWdueE16MWlsaXZO?= =?utf-8?B?OVRGV1drL3pPRGNOeE9UajlFMzdwR0s1SGlCSWVwcXBKdnp6U0ppclI4czFh?= =?utf-8?B?bnBteUNKUDQvaGxDZ3RwQmg1b3l1NVQ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TM2K3VPUmo1eUpVVHUvOEVURTZNaUhxMW83QjA3?= =?utf-8?B?WjA0QXpkL1FQNzYwRU9UQXNIeGZLVWgrV0U3cTRwNnlLTXhkTjVERFIzQ0w3?= =?utf-8?B?RFBzYnVBcHExc1o2MWZWZDdvVENZU1lFVmRRNmZlbVBON3V3MEV6N2NXamtV?= =?utf-8?B?YzhjbVdZTWNzSmpoVzlVYlhvbGkxenZYeElZa09MMnR4NVBIQlNVeFphUytx?= =?utf-8?B?b1NsQkJOTmhVcnorUEFpMkE5WW1MMFZnUFRuWDVMd0pMb0xYTmRBeU5heXha?= =?utf-8?B?c2EvTm1ha2R4N1FSek9mUVRYbFNKOFhaMS9XcHpTSm9vNUM2d0cvZWQwWUw1?= =?utf-8?B?TElOSFVaRUZuYXVHalVaWmZIUFVZV0FrNUlVTWhmQnZtWUFwMzh5MXVDUEls?= =?utf-8?B?VlpnZ2wvaisydWROSlNvODU5OTFiQXYwTmZJSTQ1dDlYZExWOHV2V3pVYWJl?= =?utf-8?B?Qm5BS05OWGdmSXh1NXlTeE5UZFR3OG5TSnZ1c09IQzF6YjcrK3NldVdWNHNN?= =?utf-8?Q?3wl2bgh+8WrNzuzojlqIjj4=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9a939fa0-2661-4d32-f541-08d9b34de651 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:40.8556 (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: xe4RWt09A7kGhey/HlkTk97Fhvns2misQnhQDMiOe0le3MCdc5QGSB/HqlbCKmXUwABwk0VePndg6Xvvs82CaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2842 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200252801100001 This logic is pulled out from xc_cpuid_apply_policy and placed into a separate helper. Note the legacy part of the introduced function, as long term Xen will require a proper topology setter function capable of expressing a more diverse set of topologies. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- - s/xc_cpu_policy_topology/xc_cpu_policy_legacy_topology/ --- tools/include/xenguest.h | 4 + tools/libs/guest/xg_cpuid_x86.c | 186 +++++++++++++++++--------------- 2 files changed, 105 insertions(+), 85 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 281454dc60..bea02cb542 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -821,6 +821,10 @@ bool xc_cpu_policy_is_compatible(xc_interface *xch, xc= _cpu_policy_t *host, int xc_cpu_policy_make_compat_4_12(xc_interface *xch, xc_cpu_policy_t *pol= icy, bool hvm); =20 +/* Setup the legacy policy topology. */ +int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t *poli= cy, + bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index bcbf9576c4..eafc1ec7c1 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -429,13 +429,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, { int rc; xc_dominfo_t di; - unsigned int i, nr_leaves, nr_msrs; + unsigned int nr_leaves, nr_msrs; xen_cpuid_leaf_t *leaves =3D NULL; struct cpuid_policy *p =3D NULL; struct xc_cpu_policy policy =3D { }; uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - uint32_t host_featureset[FEATURESET_NR_ENTRIES] =3D {}; - uint32_t len =3D ARRAY_SIZE(host_featureset); =20 if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || di.domid !=3D domid ) @@ -458,22 +456,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, (p =3D calloc(1, sizeof(*p))) =3D=3D NULL ) goto out; =20 - /* Get the host policy. */ - rc =3D xc_get_cpu_featureset(xch, XEN_SYSCTL_cpu_featureset_host, - &len, host_featureset); - if ( rc ) - { - /* Tolerate "buffer too small", as we've got the bits we need. */ - if ( errno =3D=3D ENOBUFS ) - rc =3D 0; - else - { - PERROR("Failed to obtain host featureset"); - rc =3D -errno; - goto out; - } - } - /* Get the domain's default policy. */ nr_msrs =3D 0; rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault @@ -557,72 +539,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, } } =20 - if ( !di.hvm ) - { - /* - * On hardware without CPUID Faulting, PV guests see real topology. - * As a consequence, they also need to see the host htt/cmp fields. - */ - p->basic.htt =3D test_bit(X86_FEATURE_HTT, host_featureset); - p->extd.cmp_legacy =3D test_bit(X86_FEATURE_CMP_LEGACY, host_featu= reset); - } - else - { - /* - * Topology for HVM guests is entirely controlled by Xen. For now= , we - * hardcode APIC_ID =3D vcpu_id * 2 to give the illusion of no SMT. - */ - p->basic.htt =3D true; - p->extd.cmp_legacy =3D false; - - /* - * Leaf 1 EBX[23:16] is Maximum Logical Processors Per Package. - * Update to reflect vLAPIC_ID =3D vCPU_ID * 2, but make sure to a= void - * overflow. - */ - if ( !p->basic.lppp ) - p->basic.lppp =3D 2; - else if ( !(p->basic.lppp & 0x80) ) - p->basic.lppp *=3D 2; - - switch ( p->x86_vendor ) - { - case X86_VENDOR_INTEL: - for ( i =3D 0; (p->cache.subleaf[i].type && - i < ARRAY_SIZE(p->cache.raw)); ++i ) - { - p->cache.subleaf[i].cores_per_package =3D - (p->cache.subleaf[i].cores_per_package << 1) | 1; - p->cache.subleaf[i].threads_per_cache =3D 0; - } - break; - - case X86_VENDOR_AMD: - case X86_VENDOR_HYGON: - /* - * Leaf 0x80000008 ECX[15:12] is ApicIdCoreSize. - * Leaf 0x80000008 ECX[7:0] is NumberOfCores (minus one). - * Update to reflect vLAPIC_ID =3D vCPU_ID * 2. But avoid - * - overflow, - * - going out of sync with leaf 1 EBX[23:16], - * - incrementing ApicIdCoreSize when it's zero (which changes= the - * meaning of bits 7:0). - * - * UPDATE: I addition to avoiding overflow, some - * proprietary operating systems have trouble with - * apic_id_size values greater than 7. Limit the value to - * 7 for now. - */ - if ( p->extd.nc < 0x7f ) - { - if ( p->extd.apic_id_size !=3D 0 && p->extd.apic_id_size <= 0x7 ) - p->extd.apic_id_size++; - - p->extd.nc =3D (p->extd.nc << 1) | 1; - } - break; - } - } + policy.cpuid =3D *p; + rc =3D xc_cpu_policy_legacy_topology(xch, &policy, di.hvm); + if ( rc ) + goto out; + *p =3D policy.cpuid; =20 rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); if ( rc ) @@ -944,3 +865,98 @@ int xc_cpu_policy_make_compat_4_12(xc_interface *xch, = xc_cpu_policy_t *policy, xc_cpu_policy_destroy(host); return rc; } + +int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t *poli= cy, + bool hvm) +{ + if ( !hvm ) + { + xc_cpu_policy_t *host; + int rc; + + host =3D xc_cpu_policy_init(); + if ( !host ) + { + errno =3D ENOMEM; + return -1; + } + + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, h= ost); + if ( rc ) + { + ERROR("Failed to get host policy"); + xc_cpu_policy_destroy(host); + return rc; + } + + + /* + * On hardware without CPUID Faulting, PV guests see real topology. + * As a consequence, they also need to see the host htt/cmp fields. + */ + policy->cpuid.basic.htt =3D host->cpuid.basic.htt; + policy->cpuid.extd.cmp_legacy =3D host->cpuid.extd.cmp_legacy; + } + else + { + unsigned int i; + + /* + * Topology for HVM guests is entirely controlled by Xen. For now= , we + * hardcode APIC_ID =3D vcpu_id * 2 to give the illusion of no SMT. + */ + policy->cpuid.basic.htt =3D true; + policy->cpuid.extd.cmp_legacy =3D false; + + /* + * Leaf 1 EBX[23:16] is Maximum Logical Processors Per Package. + * Update to reflect vLAPIC_ID =3D vCPU_ID * 2, but make sure to a= void + * overflow. + */ + if ( !policy->cpuid.basic.lppp ) + policy->cpuid.basic.lppp =3D 2; + else if ( !(policy->cpuid.basic.lppp & 0x80) ) + policy->cpuid.basic.lppp *=3D 2; + + switch ( policy->cpuid.x86_vendor ) + { + case X86_VENDOR_INTEL: + for ( i =3D 0; (policy->cpuid.cache.subleaf[i].type && + i < ARRAY_SIZE(policy->cpuid.cache.raw)); ++i ) + { + policy->cpuid.cache.subleaf[i].cores_per_package =3D + (policy->cpuid.cache.subleaf[i].cores_per_package << 1) = | 1; + policy->cpuid.cache.subleaf[i].threads_per_cache =3D 0; + } + break; + + case X86_VENDOR_AMD: + case X86_VENDOR_HYGON: + /* + * Leaf 0x80000008 ECX[15:12] is ApicIdCoreSize. + * Leaf 0x80000008 ECX[7:0] is NumberOfCores (minus one). + * Update to reflect vLAPIC_ID =3D vCPU_ID * 2. But avoid + * - overflow, + * - going out of sync with leaf 1 EBX[23:16], + * - incrementing ApicIdCoreSize when it's zero (which changes= the + * meaning of bits 7:0). + * + * UPDATE: I addition to avoiding overflow, some + * proprietary operating systems have trouble with + * apic_id_size values greater than 7. Limit the value to + * 7 for now. + */ + if ( policy->cpuid.extd.nc < 0x7f ) + { + if ( policy->cpuid.extd.apic_id_size !=3D 0 && + policy->cpuid.extd.apic_id_size < 0x7 ) + policy->cpuid.extd.apic_id_size++; + + policy->cpuid.extd.nc =3D (policy->cpuid.extd.nc << 1) | 1; + } + break; + } + } + + return 0; +} --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200243; cv=pass; d=zohomail.com; s=zohoarc; b=Pj0Rz8xlzWcodxI621i0Q6eFpprSQ3yQZovrzixwqRurl41vNeyeVUy/qx+oFGgYIN9nZhXiThHGTAj2dG9T0nNmeCasXTwr2T0temvEXLUEEQiVyaPFn4SNL7YCb601lYTG1bEKQ1H2hjFUVWItPmHcpJazvERSv6YrxLR+gTw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200243; 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=j6x1WqcDI4hgAVUs2NwOsazyfVUvF37XffWCwKYbgUo=; b=N55wQRFkcjfkgKQYwYGuppeBjW8aMOf6of44A7fhR5ehOcZLFuv/oOBL7oC4SKhW/fYRWh5sOwbmKIcO5W7WU93PztQ3fkN0oR/yT2ZLT84a8Mg+bCWgCmUxrBAhw5mPZl+JPHxAId/ubc1Zj0qnjUj4DorJYDYy8KlxYwbZREQ= 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 163820024331948.246284586033426; Mon, 29 Nov 2021 07:37:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234671.407269 (Exim 4.92) (envelope-from ) id 1mriiB-0000Zu-Sq; Mon, 29 Nov 2021 15:36:59 +0000 Received: by outflank-mailman (output) from mailman id 234671.407269; Mon, 29 Nov 2021 15:36:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mriiB-0000Zn-PU; Mon, 29 Nov 2021 15:36:59 +0000 Received: by outflank-mailman (input) for mailman id 234671; Mon, 29 Nov 2021 15:36:57 +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 1mrihJ-0003uH-U1 for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:06 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0f03f85c-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:36:02 +0100 (CET) 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: 0f03f85c-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200162; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qFWoz5gDtG8uLFd4Mpr7eWgtMMa45L61vHQxGnnF2wg=; b=D4AL8OjYlWFj9tKF254CoBcwi7O8AktpcAAU2m+DpeP7O9KYvBkkuqmq KgO8qV82Xg2DkqCibI/muqCXtk1eSBTxiS2kUxX09TDEkMhM5mAWITm8E rqTi0t9mR3QxMTkDYIRp5/kVu6Yzo8qPaop3S0g+QbgsIroLXOTghoAxe Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: VSEDlewqvHiy5wEI4xnrS+jJLXaFtow6FAD9YXv6OT6fB683qlORny6IZbqSucNBH1REs+JsHQ 0IrBQ0uewPmzjsD5WUb2GAb6ppPfCS2YqHPLd3YtwY9seNNVxfC+cUBsPYcNPyhpMfMrzPNzl5 qhGD3WtoNBUs/vDvI0apRUbmIvXsL5fzOVf3muuy6+He3arbXjr6eHrQB1EiLGEqKLbowXWp4a 5IR6PrgZVzLF5TGuYVnEft+w8LsM30KNTdjMGGFoaYzujUFHGgVHfyJhr6YCMlQso84qgP0ZFh xm+Dv5NT2VcffhjCy4ACxlIK X-SBRS: 5.1 X-MesageID: 58773282 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:nfBVkaI/GqRopLgAFE+RM5IlxSXFcZb7ZxGr2PjKsXjdYENShjZRm DNJCmmFbviLZWT2KosiaoS//RkOuZHUzNYwSAplqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUZUideSc+EH140Es5yrZg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB2JvvVO6 PlV76XtYkQ4Jo3rwuJecDdXRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsF2gcsuNo/zNZ43sXB81zDJS/0hRPgvRo2XtYAHh21g3KiiG978X I0mU2BJfC7GfgVKIUUwL4ASktu30yyXnzpw9wvO+PtfD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tzc= IronPort-HdrOrdr: A9a23:r/7bVKEXFF5vzxDApLqFcpHXdLJyesId70hD6qkvc3Nom52j+/ xGws536faVslcssHFJo6HlBEDmewKhyXcV2/htAV7GZmfbUQSTXedfBOfZsl/d8mjFh5VgPM RbAtlD4b/LfCFHZK/BiWHSebZQo6j2zEnrv5al854Ed3AVV0gK1XYfNu/0KDwSeOEQbqBJa6 Z0q/A37QaISDAyVICWF3MFV+/Mq5nik4/nWwcPA1oC5BOVhT2lxbbmG1zAty1uHw9n8PMHyy zoggb57qKsv7WSzQLd7Xba69BzlMH6wtVOKcSQgow+KynqiCyveIN9Mofy8QwdkaWK0hIHgd PMqxAvM4Ba7G7QRHi8pV/X1wzpwF8Vmjbf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnTC/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKprzPKN MeT/002cwmM29zNxvizyxSKZ2XLzsO9y69Mwg/Upf/6UkToJh7p3FosvD30E1ws67VcKM0ld gsBJ4Y442mfvVmHp6VO91xNPdfcla9OS4kEFjiaWgPR5t3cE4klfbMkcEIDaeRCdo18Kc= X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58773282" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYIhBJkAwm0eyQb6vsaMoPSdhUxYhexJSjgOMqurKRyr8qy/pXoJ9n4L+6V//ay1SucEXkGkng0gr2O129t/pKCtTl0GeEtZn9ipXMOiz5RlwS6Asf3Zo3+95NHImdTj/TZ7piOwWJlCFdWpTnMBl6Vw99jCpogItJbFeSnlAo4Mc4cLzPS+Ommco3zOvlPGyZjzDoMkYRVuB0eKDdAxwRSLgv3PN8xTG+Gaw/iWOJhZlE18ktWfxwtkrtfTnQ4sveybA8QSmU0bk/jcP/EB9I1YCpa5zLGK8WZttIFHJKJzDvKSQauiT+EqXQS2PFMllFGo0uBacv4nGrEiu/vYYA== 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=j6x1WqcDI4hgAVUs2NwOsazyfVUvF37XffWCwKYbgUo=; b=jCeh0L1R6KQsC1a2YvVCA/ZOmRztdvr76rMAfI8fFE1RmtLCxgs3nrujPiEGE0RxYz+VnG0BN7FqnxfEX3I3DaAD5To6RDtMaDqk6Qpawf1Nf7l0vaxMrEEN2ah83PApdbffl37sSX77DQg4UdMCbDh4FJhLDFQB8z1cKsFm2juv0/r4lh++wdHITthCA2ioEdkOUeFvFqbYAhLleWgXgatxyw5yMyaJe3kBf3NGnXCyPrKahbNAWamFBN/6clzFhs1dFILwornXzyPE5C2T/TOedsAFZNFCbl8494jRwnWTzu2jbspqPSW5dWItMB5Vj61Fbc2ZdrLyQid7sPLC7Q== 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=j6x1WqcDI4hgAVUs2NwOsazyfVUvF37XffWCwKYbgUo=; b=l73qdabl7bv5wuopOIm2aSQs2EYCUPO+wF382bs8ZFcMJQnZgV3VhcDX6UHC3v5u81JYg7hhEhSLXEwK6Mj8qJ4d+rSdHviR+PWcivVOdigKc7cGYZKxFNsLeYwzWhuCGusZp6rQHosjlmKeVS1W9QVS/iLVoDcVGADTzMrPQVo= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 08/12] libs/guest: rework xc_cpuid_xend_policy Date: Mon, 29 Nov 2021 16:33:51 +0100 Message-ID: <20211129153355.60338-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MR2P264CA0076.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::16) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cb5af70-2766-45b9-06cb-08d9b34de967 X-MS-TrafficTypeDiagnostic: DM5PR03MB2842: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:65; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PvRsPdy5eFU3FGBEdPG2d3z5ew5+i7NSVIffFVV65VNI3DH9nBcJ82rG7KnvmGkfjnA9ANi2/tihdcwNgYnzzrv6yZS3EqmQmezF+tGyxn1otDhF47bkb/URhnJy9ppbeZkBER2f6KxETZKE5Vuitobt5d+WFQI7WG2JHuJPEW8s011LAVoJOiXcJqAmrjexfRgSPQAVqiPaA573yPr69Yx43iVGYzU+KTaxhS6s26jsJnzbjmmXmYeUF2TQJKMZ8r3wL/GBx2l1NoqfzwxmIU4047p3f6o0xLU7Dj+BjhEuXf7UcLFxzgQ2kBqbRg0TFTBbnpAhtkH+tZBBvW0l82xt6bDIA0KiT2LDcVvyoiHDL5x2X+xV1ohW3n/OcVi+mjjNSatoSh+Z/fhfrwrQk8gynNVJ1MH7f/E4izZJofZEJsa+Bx1eF3oRoyNzoKEADVze8pyJcFpyiIvKqCBYQlMxuq00HC7gHnVXUXrj7mUQAQjyxNtF5t+lliL9+TkDv8wu9hvkgnkvjclU1KG6ZeyxIai/sF+NaLAPfxIEesqsV31NmPVC5Y2zNyJEQ7xhWOH7Cq3oGssnDCSYNUXstsq+yv2cFJGckwh2Wz7PoDlhc5UtFTxE7Nh6J/ZrR0cTiBolFbgY8CtJK0OyEG0KLw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(86362001)(54906003)(8936002)(2906002)(66946007)(6486002)(316002)(8676002)(956004)(6916009)(82960400001)(4326008)(6666004)(66476007)(66556008)(186003)(83380400001)(38100700002)(2616005)(26005)(508600001)(1076003)(36756003)(6496006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N1RLTGFvSlZtYWw0OUU2eWpQMUhPNGpJWC9KcG90RVc0WWt3YnNBRHUzMW43?= =?utf-8?B?cE03K3ZpMkJjdyt6eUxSZDd1blRpM2MwOERjZlRrcFFCSWRHejJxZ1g4ekN6?= =?utf-8?B?YWpGY3R3MUhLNU1ab3lSNVc4TE5aUHp2TWViampZTXVESklFSEZiV0kzMCtL?= =?utf-8?B?WG9tcFB4eVFqaXA1REZpL0RvdUZpdlJOTVdVTS9UaFVYQ29WYm5hK1VDT2tY?= =?utf-8?B?RTVIZVd3Rmw1SDdkRnYzTW5lUlJ4Uk5hMDY0ZXJ0SS9NUWdNRmtCNmRPcmRi?= =?utf-8?B?RkoyUi9xS1dJRU1tV01sS3JsbXJ5QkRaZWhqVDdLb0NTdW5RN1BqVzFEamJy?= =?utf-8?B?eTNGVmJlOG1YalV6cEJmdHVlRE40YkQvMTRjd0JGZVd6V2xxMUhURldTQi9r?= =?utf-8?B?aHc5aTE1T2kzaWdyUC85dHpTWTRDUEtDdXZMK21vSU5YaGZuaWZVWW1hUExL?= =?utf-8?B?RHZCV0hWOUF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03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:46.0437 (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: sIHR2gF+jn97kSYPDEAYxxQ7CUS/tK7QBaxLUJ2LKPC0u4ditQ4qP+Gd1QUbGyDKQQ2TyF0gun9KV5wRnovE/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2842 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200244386100001 Rename xc_cpuid_xend_policy to xc_cpu_policy_apply_cpuid and make it public. Modify the function internally to use the new xc_cpu_policy_* set of functions. Also don't apply the passed policy to a domain directly, and instead modify the provided xc_cpu_policy_t. The caller will be responsible of applying the modified cpu policy to the domain. Note that further patches will end up removing this function, as the callers should have the necessary helpers to modify an xc_cpu_policy_t themselves. The find_leaf helper and related comparison function is also removed, as it's no longer needed to search for cpuid leafs as finding the matching leaves is now done using xc_cpu_policy_get_cpuid. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v3: - Drop find_leaf and comparison helper. --- tools/include/xenguest.h | 4 + tools/libs/guest/xg_cpuid_x86.c | 200 +++++++++++++------------------- 2 files changed, 83 insertions(+), 121 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index bea02cb542..9912116a51 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -825,6 +825,10 @@ int xc_cpu_policy_make_compat_4_12(xc_interface *xch, = xc_cpu_policy_t *policy, int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t *poli= cy, bool hvm); =20 +/* Apply an xc_xend_cpuid object to the policy. */ +int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, + const struct xc_xend_cpuid *cpuid, bool hvm); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index eafc1ec7c1..121bce1a92 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -254,144 +254,107 @@ int xc_set_domain_cpu_policy(xc_interface *xch, uin= t32_t domid, return ret; } =20 -static int compare_leaves(const void *l, const void *r) -{ - const xen_cpuid_leaf_t *lhs =3D l; - const xen_cpuid_leaf_t *rhs =3D r; - - if ( lhs->leaf !=3D rhs->leaf ) - return lhs->leaf < rhs->leaf ? -1 : 1; - - if ( lhs->subleaf !=3D rhs->subleaf ) - return lhs->subleaf < rhs->subleaf ? -1 : 1; - - return 0; -} - -static xen_cpuid_leaf_t *find_leaf( - xen_cpuid_leaf_t *leaves, unsigned int nr_leaves, - const struct xc_xend_cpuid *xend) -{ - const xen_cpuid_leaf_t key =3D { xend->leaf, xend->subleaf }; - - return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leave= s); -} - -static int xc_cpuid_xend_policy( - xc_interface *xch, uint32_t domid, const struct xc_xend_cpuid *xend) +int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, + const struct xc_xend_cpuid *cpuid, bool hvm) { int rc; - xc_dominfo_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_cpuid_leaf_t *host =3D NULL, *def =3D NULL, *cur =3D NULL; - unsigned int nr_host, nr_def, nr_cur; + xc_cpu_policy_t *host =3D NULL, *def =3D NULL; =20 - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) - { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; - goto fail; - } - - 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 fail; - } - - rc =3D -ENOMEM; - if ( (host =3D calloc(nr_leaves, sizeof(*host))) =3D=3D NULL || - (def =3D calloc(nr_leaves, sizeof(*def))) =3D=3D NULL || - (cur =3D calloc(nr_leaves, sizeof(*cur))) =3D=3D NULL ) - { - ERROR("Unable to allocate memory for %u CPUID leaves", nr_leaves); - goto fail; - } - - /* Get the domain's current policy. */ - nr_msrs =3D 0; - nr_cur =3D nr_leaves; - rc =3D get_domain_cpu_policy(xch, domid, &nr_cur, cur, &nr_msrs, NULL); - if ( rc ) + host =3D xc_cpu_policy_init(); + def =3D xc_cpu_policy_init(); + if ( !host || !def ) { - PERROR("Failed to obtain d%d current policy", domid); - rc =3D -errno; - goto fail; + PERROR("Failed to init policies"); + rc =3D -ENOMEM; + goto out; } =20 /* Get the domain type's default policy. */ - nr_msrs =3D 0; - nr_def =3D nr_leaves; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault + rc =3D xc_cpu_policy_get_system(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault : XEN_SYSCTL_cpu_policy_pv_defa= ult, - &nr_def, def, &nr_msrs, NULL); + def); if ( rc ) { - PERROR("Failed to obtain %s def policy", di.hvm ? "hvm" : "pv"); - rc =3D -errno; - goto fail; + PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); + goto out; } =20 /* Get the host policy. */ - nr_msrs =3D 0; - nr_host =3D nr_leaves; - rc =3D get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host, - &nr_host, host, &nr_msrs, NULL); + rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); if ( rc ) { PERROR("Failed to obtain host policy"); - rc =3D -errno; - goto fail; + goto out; } =20 rc =3D -EINVAL; - for ( ; xend->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++xend ) + for ( ; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid ) { - xen_cpuid_leaf_t *cur_leaf =3D find_leaf(cur, nr_cur, xend); - const xen_cpuid_leaf_t *def_leaf =3D find_leaf(def, nr_def, xend); - const xen_cpuid_leaf_t *host_leaf =3D find_leaf(host, nr_host, xen= d); + xen_cpuid_leaf_t cur_leaf; + xen_cpuid_leaf_t def_leaf; + xen_cpuid_leaf_t host_leaf; =20 - if ( cur_leaf =3D=3D NULL || def_leaf =3D=3D NULL || host_leaf =3D= =3D NULL ) + rc =3D xc_cpu_policy_get_cpuid(xch, policy, cpuid->leaf, cpuid->su= bleaf, + &cur_leaf); + if ( rc ) + { + ERROR("Failed to get current policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(xch, def, cpuid->leaf, cpuid->suble= af, + &def_leaf); + if ( rc ) + { + ERROR("Failed to get def policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } + rc =3D xc_cpu_policy_get_cpuid(xch, host, cpuid->leaf, cpuid->subl= eaf, + &host_leaf); + if ( rc ) { - ERROR("Missing leaf %#x, subleaf %#x", xend->leaf, xend->suble= af); - goto fail; + ERROR("Failed to get host policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; } =20 - for ( unsigned int i =3D 0; i < ARRAY_SIZE(xend->policy); i++ ) + for ( unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++ ) { - uint32_t *cur_reg =3D &cur_leaf->a + i; - const uint32_t *def_reg =3D &def_leaf->a + i; - const uint32_t *host_reg =3D &host_leaf->a + i; + uint32_t *cur_reg =3D &cur_leaf.a + i; + const uint32_t *def_reg =3D &def_leaf.a + i; + const uint32_t *host_reg =3D &host_leaf.a + i; =20 - if ( xend->policy[i] =3D=3D NULL ) + if ( cpuid->policy[i] =3D=3D NULL ) continue; =20 for ( unsigned int j =3D 0; j < 32; j++ ) { bool val; =20 - if ( xend->policy[i][j] =3D=3D '1' ) + switch ( cpuid->policy[i][j] ) + { + case '1': val =3D true; - else if ( xend->policy[i][j] =3D=3D '0' ) + break; + + case '0': val =3D false; - else if ( xend->policy[i][j] =3D=3D 'x' ) + break; + + case 'x': val =3D test_bit(31 - j, def_reg); - else if ( xend->policy[i][j] =3D=3D 'k' || - xend->policy[i][j] =3D=3D 's' ) + break; + + case 'k': + case 's': val =3D test_bit(31 - j, host_reg); - else - { + break; + + default: ERROR("Bad character '%c' in policy[%d] string '%s'", - xend->policy[i][j], i, xend->policy[i]); - goto fail; + cpuid->policy[i][j], i, cpuid->policy[i]); + goto out; } =20 clear_bit(31 - j, cur_reg); @@ -399,25 +362,19 @@ static int xc_cpuid_xend_policy( set_bit(31 - j, cur_reg); } } - } =20 - /* Feed the transformed currrent policy back up to Xen. */ - rc =3D xc_set_domain_cpu_policy(xch, domid, nr_cur, cur, 0, NULL, - &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 fail; + rc =3D xc_cpu_policy_update_cpuid(xch, policy, &cur_leaf, 1); + if ( rc ) + { + PERROR("Failed to set policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + goto out; + } } =20 - /* Success! */ - - fail: - free(cur); - free(def); - free(host); + out: + xc_cpu_policy_destroy(def); + xc_cpu_policy_destroy(host); =20 return rc; } @@ -425,7 +382,7 @@ static int xc_cpuid_xend_policy( 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 *cpuid) { int rc; xc_dominfo_t di; @@ -545,6 +502,10 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t = domid, bool restore, goto out; *p =3D policy.cpuid; =20 + rc =3D xc_cpu_policy_apply_cpuid(xch, &policy, cpuid, di.hvm); + if ( rc ) + goto out; + rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); if ( rc ) { @@ -562,9 +523,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t d= omid, bool restore, goto out; } =20 - if ( xend && (rc =3D xc_cpuid_xend_policy(xch, domid, xend)) ) - goto out; - rc =3D 0; =20 out: --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200190; cv=pass; d=zohomail.com; s=zohoarc; b=SiVlzPUfZMGKTDRGZ7CHnBTxfYUSoW/Z6HsDwstEF44aGUqDNO+IvoVOtCwh2nRm/WP0ZbLoXYjnEsil/S7/xzo3YBnYgqNIxS95MopXOwKdZ/qCpFjDvZ1FqM4nNFgDve8ninDJ8gWFBlm1BOIrzKWcnvTrBrZ67+4uqjXNqzw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200190; 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=6273KZmAZtXTzPVDuifwUtanJBWxIn4jC61JEnVY+80=; b=iXRbTEM0epYq0weq3HqToTC+3A4++9qd23fBH+1ooqlWqllz1XFJF3AjfqVDTb3/2mZg634R5iUsNRmYZrvkNNnJ8Su5hI4cdHv8+kq5A0cY+insZxxSOJDFD+cu/ph5GqFZ7euVwS8Ziy/nKsAAQg/wC5lC70mQAEoLvMMYHOc= 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 1638200190742133.26525210914144; Mon, 29 Nov 2021 07:36:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234652.407248 (Exim 4.92) (envelope-from ) id 1mrihL-0007d0-5h; Mon, 29 Nov 2021 15:36:07 +0000 Received: by outflank-mailman (output) from mailman id 234652.407248; Mon, 29 Nov 2021 15:36:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrihL-0007cr-2S; Mon, 29 Nov 2021 15:36:07 +0000 Received: by outflank-mailman (input) for mailman id 234652; Mon, 29 Nov 2021 15:36:05 +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 1mrihJ-0004Rj-LE for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:05 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0db9ffe2-512a-11ec-976b-d102b41d0961; Mon, 29 Nov 2021 16:36:01 +0100 (CET) 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: 0db9ffe2-512a-11ec-976b-d102b41d0961 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200161; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ikz8Od6tujePp3huh+RLSBKJ6YNbo1RzzrtmzTVzTf4=; b=BvziWVFXWOIIKqW9qVTzvflMOhQ/DLHccVXcYFCNlNEXG5Fc8j3HqydK 3WLsl45WjklsLC3JMxYWpUkoud3fGImAxfDJ/RUZlTCDTATU7Lmw4Rdob qZrME33pGj09Mwm6NvVY3NE8PsbCUqZNuSb6xnDrsJUmPImmkKTDHeoC+ 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: 0gdoAH2eX1lxhgWtP/Vv8Oih01QsfykTkrmaQRmszixCYPdx8WvdyHizpG8vqHRqHX8vgQfmsJ vgW995aeqZX+3yPgDufmKLmh+I10qOjofsogwS+vIxjT1421Blolqogdgc1Sae/v7I7EaX+LkT +P6Ua/wKkYLM7QT8tJ1Bs4dBZ/jptqELhCp3vddFBGy2L1hEQEwqnPlosbXUzgAXnWmq6eJy8f A5UdoKSNwp1XRKUrdgU+ACOsMWhxPJtiOU0NZulEhLNB9y5GisArYh00JKztKbvNdfUNp2YO+7 ILNYIJAMMu+lwXzCCTyAv6+7 X-SBRS: 5.1 X-MesageID: 58817385 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:pspsdqlsoMfLjAz0tTL6hS3o5gxiIURdPkR7XQ2eYbSJt1+Wr1Gzt xJMWzvTOv/Zajf0ft4kb4q//RwA6sPTzoJgTwU5/C4yEyMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoO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d="scan'208";a="58817385" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J945ZGFpN+SQ+3oyLKzu4tRbkq1sFSrSjmhUxiFrNGhaApOR5vGxV2hT3KRMUVe04jjVTO3rN65heSLKX1xFuJAB/jPtvOjIZd6Z2jH3X4OLLDUsmRkPbiYlMLU0JyU5BQghfyvMh+iNmpv0oHrfO9RKb3qJfQ6/NJ3w431DETD0GffE/TYKMn7XJk+nt7lAJAtBCjoJrGmvsn3FQnNsHJ0LULzl6o7RwhfhGsS2VLsUGfFxLI4u4/8JkeWPNHZ36XvKndSDDnAcMLd3h5DDyhNRy65vSvjL2zYweDxWcgvUqkZzCQj2RqgDL6Cz5H1T/7FdwHNYgV2TVngdrzEWiA== 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=6273KZmAZtXTzPVDuifwUtanJBWxIn4jC61JEnVY+80=; b=AuGgq75Yyr2L7BGZ6kpFC/HVAwdYUlPw4tkJSmDozP0o1w7AqJEO0MBCE3Ygieih3W0ESKuJ3XsKPoLTsTYS7Oym+mPjubKcBummANOiN248Uuz0zLVqdbU4QKQ+fy80cNXdE3emDsru7b8TXjJ4PkPwJET3Vz7seA9m/FA0MlKLn8kCF9gtRfQzGJe2i/Nch2kP+vHwjIpdC6R8HZnxo1WD0uglVRclQwVkF/C5Fb/6xy0ufmZDkbOyJqG6YAawq1u+nuAp3qjZXe9lGOmed7fdlLqpQ1RwSsTEhEZtUgd1A352fURB2fJdGMtGHoAdAEBAYWl744vIxAXlRZZzKA== 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=6273KZmAZtXTzPVDuifwUtanJBWxIn4jC61JEnVY+80=; b=k8uitRCBLoDPHUPtrqsMgbQVh3g/lJfBDo+oxAC/N6k7ROEBPNap+87WCx0amgnbA4IF2y5yumE5bJuczlbTg/KQMRII3Nn/CmAQP7LfHZQRowlfpvNB4T1JeF9zFsFw93ev6WhvW3RGNGlEvhIqTmkl6Mkac6zmsrXnSZAgH/c= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross Subject: [PATCH v5 09/12] libs/guest: apply a featureset into a cpu policy Date: Mon, 29 Nov 2021 16:33:52 +0100 Message-ID: <20211129153355.60338-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MRXP264CA0035.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::23) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d7a2944-fd1f-49e4-be8e-08d9b34dec97 X-MS-TrafficTypeDiagnostic: DM6PR03MB5340: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MSUS32KMWT5FO0qj1mdOqzDBaYutPhcYgm2Y0nhuT6CezqLxZ9+RrC/bH4et6sOpkGYKpgApH4t1/lDw2AzI55P+Yo7pltsv6ahBlMeVKtB27bITCTcKa8loQj+XbFyu9qRp/JGhMk72waocqpepLvFsrldmFnQDBOgipoEBCeP7HcxhCTFdc9cJyImLM2p8WpJKuFfQPUx3gElQn9LWzBqXBbXUIiLKh41z3sGpCX5kKcchFbhpMZFyKrR3vk2mg745SacwVl+ZUwbtQ326BYmxdkWDx6MI6h+9tQ9MojuLf48iRjO+uKOZlzxQneIOrj6bvxrh58U5hJ2MRekQMR+z6wFUkDNcFZ1wM0iG1ah6kyDsBfEJkumK6Jd1JNLrk8284jrWuLn5mRsuvN/h8wR+EbPD5zXlg4v/G3VmpE1fFJ0Wb45vxLyXIJvbohFGJwjWoiftjPi+BlMrjXMkIUOdSoMxyNfmRLELoDUHnHgpvFoDlTTTtJQ+KuYigiIJ0ZF3XFfQ9kzs1TeTj3UrC6zUIgIlD36tItdu2PY395N1sgJeK5NamgNERFFGj5QtzRnyejaf2leJzu3AQYt5T2E9nYDp6nEIhoxyZ9rroBgWe4ax3lFBlD3eI8H89XvxGMd5yZJwRX0CW0xcvYUhcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(82960400001)(66946007)(86362001)(1076003)(508600001)(5660300002)(8676002)(6486002)(316002)(38100700002)(6496006)(26005)(83380400001)(6916009)(66476007)(2906002)(66556008)(2616005)(956004)(8936002)(54906003)(186003)(36756003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Y282bGVmd0hDZmZvZ1docnFHQnRST2czL3pBamtReGxqcEJHSzBHK0k1amtk?= =?utf-8?B?M1BoeVpmVWwxT2ZZVmRxOTJxV203dTNPYnJTMlk5WnZWWXcvVFJlWmRwNmFM?= =?utf-8?B?WHNJVTdZZzdZYXVIQ1pValJJVTVFUFZlNk90NStxTW9rMW9CSTFl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eldoLzVaMTB1cXNmZmozTnRmOE43amZUbWhpNkpHcjZF?= =?utf-8?B?ME9Xc3dFbjhZNHNTSmpZNGxwZmhTVkUvcE15eHJ3YW0vN3NYS0wwc0tGbWs2?= =?utf-8?B?VDFiSi9tcXEyLzZ2dHNCeDdqcm54OGx1Z2RmRVNNelZrSHYvb1ZGYndUYjR2?= =?utf-8?B?Vk96VnJYR1dYNFlrYWx5dWdVTGNxa04yTzNzOHcveFduZ0ZYalJBRFZaWlM1?= =?utf-8?Q?bVTEj7D+29chR+SRtV3k9is=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 2d7a2944-fd1f-49e4-be8e-08d9b34dec97 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:51.4609 (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: 8/rggqMG58C6Tu8iDci/sCHZQ3gws0hH50VyBwTUlm+F7Kk3PDKJlRphjxWBUdniSG3bBR1Cg1lkf9PiIMbNYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB5340 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200191026100001 Pull out the code from xc_cpuid_apply_policy that applies a featureset to a cpu policy and place it on it's own standalone function that's part of the public interface. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- tools/include/xenguest.h | 5 ++ tools/libs/guest/xg_cpuid_x86.c | 95 ++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 9912116a51..8f05d8aa66 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -829,6 +829,11 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch, x= c_cpu_policy_t *policy, int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, const struct xc_xend_cpuid *cpuid, bool hvm); =20 +/* Apply a featureset to the policy. */ +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t *pol= icy, + const uint32_t *featureset, + unsigned int nr_features); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 121bce1a92..41c6e66b6f 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -443,46 +443,15 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t= domid, bool restore, =20 if ( featureset ) { - uint32_t disabled_features[FEATURESET_NR_ENTRIES], - feat[FEATURESET_NR_ENTRIES] =3D {}; - static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; - unsigned int i, b; - - /* - * The user supplied featureset may be shorter or longer than - * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-exten= d. - * Longer is fine, so long as it only padded with zeros. - */ - unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_featu= res); - - /* Check for truncated set bits. */ - rc =3D -EOPNOTSUPP; - for ( i =3D user_len; i < nr_features; ++i ) - if ( featureset[i] !=3D 0 ) - goto out; - - memcpy(feat, featureset, sizeof(*featureset) * user_len); - - /* Disable deep dependencies of disabled features. */ - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - disabled_features[i] =3D ~feat[i] & deep_features[i]; - - for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + policy.cpuid =3D *p; + rc =3D xc_cpu_policy_apply_featureset(xch, &policy, featureset, + nr_features); + if ( rc ) { - const uint32_t *dfs; - - if ( !test_bit(b, disabled_features) || - !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) - continue; - - for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) - { - feat[i] &=3D ~dfs[i]; - disabled_features[i] &=3D ~dfs[i]; - } + ERROR("Failed to apply featureset to policy"); + goto out; } - - cpuid_featureset_to_policy(feat, p); + *p =3D policy.cpuid; } else { @@ -918,3 +887,53 @@ int xc_cpu_policy_legacy_topology(xc_interface *xch, x= c_cpu_policy_t *policy, =20 return 0; } + +int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t *pol= icy, + const uint32_t *featureset, + unsigned int nr_features) +{ + uint32_t disabled_features[FEATURESET_NR_ENTRIES], + feat[FEATURESET_NR_ENTRIES] =3D {}; + static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; + unsigned int i, b; + + /* + * The user supplied featureset may be shorter or longer than + * FEATURESET_NR_ENTRIES. Shorter is fine, and we will zero-extend. + * Longer is fine, so long as it only padded with zeros. + */ + unsigned int user_len =3D min(FEATURESET_NR_ENTRIES + 0u, nr_features); + + /* Check for truncated set bits. */ + for ( i =3D user_len; i < nr_features; ++i ) + if ( featureset[i] !=3D 0 ) + { + errno =3D EOPNOTSUPP; + return -1; + } + + memcpy(feat, featureset, sizeof(*featureset) * user_len); + + /* Disable deep dependencies of disabled features. */ + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + disabled_features[i] =3D ~feat[i] & deep_features[i]; + + for ( b =3D 0; b < sizeof(disabled_features) * CHAR_BIT; ++b ) + { + const uint32_t *dfs; + + if ( !test_bit(b, disabled_features) || + !(dfs =3D x86_cpuid_lookup_deep_deps(b)) ) + continue; + + for ( i =3D 0; i < ARRAY_SIZE(disabled_features); ++i ) + { + feat[i] &=3D ~dfs[i]; + disabled_features[i] &=3D ~dfs[i]; + } + } + + cpuid_featureset_to_policy(feat, &policy->cpuid); + + return 0; +} --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200247; cv=pass; d=zohomail.com; s=zohoarc; b=ToN55e4HEpy80QJetG6k1FW7NL4Y7CeexSTjYJOkhui0sF4CNdERT/Ky3QnAhr3j02Q5Fkq7EogzOQz80VNTagWM5E4rxcKFf0jZGCryeGu7Nle6aqWtTtfsPueCuV0pPieTRClScxluAqAfXpXzFOJDXktcaL3YiKL/ZTxkBIo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200247; 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=va2yTS9NdywE+zexh1fxAUbpTOFx27IrcCDyw7x9azc=; b=E7M/s5yBCXy6iQxrLhtVRsHfAUpV8J8Xw9cHpK/1zBU8TQqLddZyYJ5/MZ9/zqcsNGn3SGH/m+dxV2p190cVgQpgFqCih/8OnTbQEBOjufYjLqyOpLTKN2nv2Aa9qo4I+aYdLqMNpYgdjUfN8nCC11nuY9GyaWcsijPklTOOUyY= 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 1638200247012916.5495387827247; Mon, 29 Nov 2021 07:37:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234673.407276 (Exim 4.92) (envelope-from ) id 1mriiC-0000da-AZ; Mon, 29 Nov 2021 15:37:00 +0000 Received: by outflank-mailman (output) from mailman id 234673.407276; Mon, 29 Nov 2021 15:37:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mriiC-0000dP-48; Mon, 29 Nov 2021 15:37:00 +0000 Received: by outflank-mailman (input) for mailman id 234673; Mon, 29 Nov 2021 15:36:58 +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 1mrihK-0003uH-U5 for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:07 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0e61b719-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:36:02 +0100 (CET) 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: 0e61b719-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200162; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=oCwcWmwz0BMSkk8m68nr1rFFDTEUeQkIP2DOHyaSqqY=; b=UOPK/amGI4bl6TigtKe2Wc82+s6K6sdCukzZtlxEdgqHnOAfJPu+efk8 XTYfdTpMAKypIoutoa7dqt80P76+7KQfVMiMjo0mJHq4DCWSdkKQ0R2DE eiGIjcAcD34La6QnC8LxOQ/XNGoBXD/H6F7X7+9K0b+H/Yog/LWXk/CkV A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: Nc6pV2ozzeJq9sLgupWxfTlxJN3B5L5GZH4JcJWV9PwBdluG4h906HYx9lA+OpjZjVItMTSrEs EI3gCLfrPSE9tYnjttdbDTJSSg0FHMx0ab34LTcAQgmfozp2BRVf3ErzYScjzRy8N2UPpLz3uA CsskYQ7YOMSMZtjzUpEE1tWklGBZ2fPeUTT6j5L9SJYkpp9onH8LdI/Pt8d/w4qYxNC1Aznz91 Ozm+rlP6+8DlFH6o80mSi9w0H3JWp8KXDtaOupDBq5lO8valL+RGwoF9fURO9NVyO3XHdQPHWb HhJP/BCJzp8t2n2afTR2/g5G X-SBRS: 5.1 X-MesageID: 58773293 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:KHAd26gDP79O6m0F4P8QqT+iX161ghcKZh0ujC45NGQN5FlHY01je htvCmnTa/6OYGrzfo13bY7k/BsB65LWzYUxHgQ4/ChnES0b9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29cy0IDga++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /1C762+TyAXD5Tjv95efxBkH3kvB4p/reqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2rzwkOnTpupE36zPKOHxO4wSoDd4xCzxBvc6W5HTBa7N4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Tm5XAooOrbABsKZxTc2jZAKLZVMZ8+x bZzscEb3AWzlx42P4vUlStT7WmNciQNXqhPWkv222M3Zt7HEm1/XKE= IronPort-HdrOrdr: A9a23:JulUNayK5kmym6oIJ+R+KrPxsOskLtp133Aq2lEZdPULSKKlfp GV88jziyWZtN9wYhEdcdDpAtjmfZq6z+8L3WBxB8bfYOCCggqVxe5ZnPLfKlHbakjDH6tmpN 1dmstFea3N5DpB/L7HCWCDer5KqrT3k9HL9JTjJjVWPHxXgslbnnZE422gYytLrWd9dP4E/M 323Ls4m9PsQwVbUu2LQl0+G8TTrdzCk5zrJTYAGh4c8QGLyRel8qTzHRS01goXF2on+8ZszU H11yjCoomzufCyzRHRk0fV8pRtgdPkjv9OHtaFhMQ5IijlziyoeINicbufuy1dmpDi1H8a1P 335zswNcV67H3cOkmzvBvWwgHllA0j7nfzoGXoyUfLkIjcfnYXGsBBjYVWfl/y8Ew7puxx16 pNwiawq4dXJQmoplW82/H4EzVR0makq3srluAey1ZFV5EFVbNXpYsDuGtIDZY7Gj7g4oxPKp guMCjl3ocVTbqmVQGdgoE2q+bcGkjbXy32DHTqg/blkAS/xxtCvgwlLM92pAZIyHtycegD2w 3+CNUcqFh5dL5hUUtMPpZyfSKJMB24ffu1ChPoHb3GLtBNB5ufke+83F0KjNvaD6DgiqFCwa j8bA== X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58773293" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+LWsFvLrUk9aNpWquLFO8l29KeecLikiaA/maBuFVJ4FsCWTLlIEnZvcUSVFYgWpSFf4dGw7bWyM60S3gZ6f8j93tDFcdnV0AMNqSQzNVoXu5lDJBopG24+tUjIGW8GBcw592DkEKWKMScnthp3Cx20XLdXGSnpnhGHHM7++bGXroCi3sqzGi14KqcowRSclzkYJk0CBKnCKBC5+IAtWW2iD72GPjWcLyM7bSurtBmR73nkmdoOKuwBFJInjgjM8O50QjXxuDY8OMxEo7g9fdC5ebPkS6R+1Hj1Fq64NiH6CPYerrIJLFxymsUEh+JMp5TZ7Bkf3n1G78/tGFU+Wg== 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=va2yTS9NdywE+zexh1fxAUbpTOFx27IrcCDyw7x9azc=; b=mTmB7GXP8Z1rbKhhdgSK9VgGmDzWbLVglXcbtXfrPVqi+bpLDSjqyu3H0s4p5WqI1pjOOFEAb79uwpKtwliuElBcYTTxH1X4sLmOVuIBtcgaQ+9F5hwdBKUDMVzaiVvww1Rgz6wYCwxLUiIAR6kZuMzDM7Abj5j1CpYkVWZ4dRyFTXpDwq+57YgAPQm/oFfCbwaUeKBu/UC49OB9PiUt4jyhZa6cjOE0VvSNnFAMAXhSWQKlKFEcueboG2jfS2MHlfFp1fqItyWEr3/wUVkAtGmk8ZXQKxP3wQCCnUaLXCNPk652hJmaX5/s8E9Zj2wyQLWbbJOVaGyiYXVKZ0IRIg== 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=va2yTS9NdywE+zexh1fxAUbpTOFx27IrcCDyw7x9azc=; b=L0595hOgURK8N5x1evwrLImUyOg5QfRuMhFCPv2jUMEKxjr5WXtJqHttnRcN4Sq/5dW5wLFJbCheYZe03oD19g1nLpx36e2ChrfiEZYhVduggGz5x/4wa0TwxRPjpDufIjtAB0AfTUEppfTlIU2HL5fiUOCTdztPi5hsFfdnxiE= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Juergen Gross , Anthony PERARD Subject: [PATCH v5 10/12] libs/{light,guest}: implement xc_cpuid_apply_policy in libxl Date: Mon, 29 Nov 2021 16:33:53 +0100 Message-ID: <20211129153355.60338-11-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MRXP264CA0030.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::18) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6d453ff-5b7f-4066-32d2-08d9b34defd7 X-MS-TrafficTypeDiagnostic: DM6PR03MB5340: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:177; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uC3OciuAXZ10rxT3FJNQ5cFSlSZ01P7QceDw1T5tMqDCFMLRiNCboFjH5V57S1eL6PmcOOswwjupPwQMxhrvrGnz6GfrlIeoYZ4IKQFF0Z3tsu765ApRbNbPgnWkF9oRjZLUtkE5xYeZzIaeZAM78R+5m6wQqKnlDDidNKECui103wJyKRSH5nCVRFdyW6fMz9OiGi8x8V2jZEZsER0icP7dHkMKdSCKy7iusmzPuaxDAPUNiseMuuR8HkYFztcoiml3OoxLsELISqk31T+RIz/QnwkME77j2MlcDR2XhksgwflPwZLJB3F5+M9+JRdfUtA06GnOmAw7+BAnHmuw9Aj/c85/Mcw3BqULpMRTxJV4pMhmqBG4fbkQz8/U5orNaOrWYlm+X4JqUEdc4PkdZoGmFT8nuEoK7N4FEfGx91qCnYgzDChczF1WS4r+0H0YqGyzDBSw8exgkgVLedartH9y0G6n2uZQ+R7unEDViaSY0JMnZUuUbEWokiFS10z4ZZNTt8z8uarft/9KnNfx/W0WYYntgjwU5GAzoMmkkp8zrT4R69uoumXiUZa5UaiGPAmVOVEgFjCJEUL8EAMPwo3JyjoPvvX8AjMJEErK16XFdcM57dhWTKHxS4YZvGOptETfsxo40OWR/KKJuQOHbw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(82960400001)(66946007)(86362001)(1076003)(508600001)(5660300002)(8676002)(107886003)(6486002)(316002)(38100700002)(6496006)(26005)(83380400001)(6916009)(66476007)(2906002)(66556008)(2616005)(956004)(8936002)(54906003)(186003)(36756003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dTFaazNpbktQVk9vdkt1a3VNYVlJczAwOWhHVnlDV25xYmpMT0Zyam10bWs3?= =?utf-8?B?SnRpNTdtMUlzdW5PR2VtRUM1TEdKbjNEV1ZoK2lhblI3akJPZDRmMEp2NDdj?= =?utf-8?B?aVhOckl3eEs3NjRKNXQvcGh4QVlMMGlBT1dPUnZ5YnBxalVPV25Nall6YW9v?= =?utf-8?B?NGpGY3dCdExSdzlWRWF3RVhIV0tQRGFBSS9wUi9CYzJMVlA4SEFnV1N4eDhr?= =?utf-8?B?ZW1CMDVncmd4amQ5QlFIZmRxNlIzNU84MjZJMmRKUUg5SHBtY0dqazlkV1FE?= =?utf-8?B?ZEdsV2NtZ2F6MlRGRzRyRnJmSUlYejBTV3h6UzJCR1MrcFBoWUYvdDVEanBR?= =?utf-8?B?QmVCQ3FVeXZRMitXb2hUdlhMV1dScHVvbFBlZUF0ZFJKdk9CTmdUdUJzZ1Ex?= =?utf-8?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o=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b6d453ff-5b7f-4066-32d2-08d9b34defd7 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:35:56.8402 (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: LHo1R7uJIa1uDLufds5/VfFUj/0FDRHGxJs00XJaARB1UwzNmV4Dzgeuv3pxBHYsb9kEc4Tf0/cp1r4eBZ6Yww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB5340 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200249244100001 With the addition of the xc_cpu_policy_* now libxl can have better control over the cpu policy, this allows removing the xc_cpuid_apply_policy function and instead coding the required bits by libxl in libxl__cpuid_legacy directly. Remove xc_cpuid_apply_policy. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Anthony PERARD --- Changes since v4: - Correctly account for PVH guests being HVM in libxl__cpuid_legacy. - PAE option is only available to HVM guests (_not_ including PVH). Changes since v2: - Use 'r' for libxc return values. - Fix comment about making a cpu policy compatible. - Use LOG*D macros. --- tools/include/xenctrl.h | 18 ----- tools/libs/guest/xg_cpuid_x86.c | 122 -------------------------------- tools/libs/light/libxl_cpuid.c | 92 ++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 146 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 95bd5eca67..745d67c970 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1829,24 +1829,6 @@ struct xc_xend_cpuid { char *policy[4]; }; =20 -/* - * Make adjustments to the CPUID settings for a domain. - * - * This path is used in two cases. First, for fresh boots of the domain, = and - * secondly for migrate-in/restore of pre-4.14 guests (where CPUID data was - * missing from the stream). The @restore parameter distinguishes these - * cases, and the generated policy must be compatible with a 4.13. - * - * 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. - */ -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); 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 41c6e66b6f..f4ed632d60 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -379,128 +379,6 @@ int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_c= pu_policy_t *policy, return rc; } =20 -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 *cpuid) -{ - int rc; - xc_dominfo_t di; - unsigned int nr_leaves, nr_msrs; - xen_cpuid_leaf_t *leaves =3D NULL; - struct cpuid_policy *p =3D NULL; - struct xc_cpu_policy policy =3D { }; - uint32_t err_leaf =3D -1, err_subleaf =3D -1, err_msr =3D -1; - - if ( xc_domain_getinfo(xch, domid, 1, &di) !=3D 1 || - di.domid !=3D domid ) - { - ERROR("Failed to obtain d%d info", domid); - rc =3D -ESRCH; - goto out; - } - - 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; - } - - rc =3D -ENOMEM; - if ( (leaves =3D calloc(nr_leaves, sizeof(*leaves))) =3D=3D NULL || - (p =3D calloc(1, sizeof(*p))) =3D=3D NULL ) - goto out; - - /* Get the domain's default policy. */ - nr_msrs =3D 0; - rc =3D get_system_cpu_policy(xch, di.hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, - &nr_leaves, leaves, &nr_msrs, NULL); - if ( rc ) - { - PERROR("Failed to obtain %s default policy", di.hvm ? "hvm" : "pv"= ); - rc =3D -errno; - goto out; - } - - rc =3D x86_cpuid_copy_from_buffer(p, leaves, nr_leaves, - &err_leaf, &err_subleaf); - if ( rc ) - { - ERROR("Failed to deserialise CPUID (err leaf %#x, subleaf %#x) (%d= =3D %s)", - err_leaf, err_subleaf, -rc, strerror(-rc)); - goto out; - } - - if ( restore ) - { - policy.cpuid =3D *p; - xc_cpu_policy_make_compat_4_12(xch, &policy, di.hvm); - *p =3D policy.cpuid; - } - - if ( featureset ) - { - policy.cpuid =3D *p; - rc =3D xc_cpu_policy_apply_featureset(xch, &policy, featureset, - nr_features); - if ( rc ) - { - ERROR("Failed to apply featureset to policy"); - goto out; - } - *p =3D policy.cpuid; - } - else - { - p->extd.itsc =3D itsc; - - if ( di.hvm ) - { - p->basic.pae =3D pae; - p->basic.vmx =3D nested_virt; - p->extd.svm =3D nested_virt; - } - } - - policy.cpuid =3D *p; - rc =3D xc_cpu_policy_legacy_topology(xch, &policy, di.hvm); - if ( rc ) - goto out; - *p =3D policy.cpuid; - - rc =3D xc_cpu_policy_apply_cpuid(xch, &policy, cpuid, di.hvm); - if ( rc ) - goto out; - - rc =3D x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves); - if ( rc ) - { - ERROR("Failed to serialise CPUID (%d =3D %s)", -rc, strerror(-rc)); - goto out; - } - - rc =3D xc_set_domain_cpu_policy(xch, domid, nr_leaves, leaves, 0, NULL, - &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; - } - - rc =3D 0; - -out: - free(p); - free(leaves); - - return rc; -} - xc_cpu_policy_t *xc_cpu_policy_init(void) { return calloc(1, sizeof(struct xc_cpu_policy)); diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 815498d4f3..07d445d9f9 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -441,9 +441,11 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, libxl_domain_build_info *info) { GC_INIT(ctx); + xc_cpu_policy_t *policy =3D NULL; + bool hvm =3D info->type !=3D LIBXL_DOMAIN_TYPE_PV; bool pae =3D true; bool itsc; - int r; + int r, rc =3D 0; =20 /* * Gross hack. Using libxl_defbool_val() here causes libvirt to crash= in @@ -454,6 +456,41 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, */ bool nested_virt =3D info->nested_hvm.val > 0; =20 + policy =3D xc_cpu_policy_init(); + if (!policy) { + LOGED(ERROR, domid, "Failed to init CPU policy"); + rc =3D ERROR_FAIL; + goto out; + } + + r =3D xc_cpu_policy_get_domain(ctx->xch, domid, policy); + if (r) { + LOGED(ERROR, domid, "Failed to fetch domain CPU policy"); + rc =3D ERROR_FAIL; + goto out; + } + + if (restore) { + /* + * Make sure the policy is compatible with pre Xen 4.13. Note that + * newer Xen versions will pass policy data on the restore stream,= so + * any adjustments done here will be superseded. + */ + r =3D xc_cpu_policy_make_compat_4_12(ctx->xch, policy, hvm); + if (r) { + LOGED(ERROR, domid, "Failed to setup compatible CPU policy"); + rc =3D ERROR_FAIL; + goto out; + } + } + + r =3D xc_cpu_policy_legacy_topology(ctx->xch, policy, hvm); + if (r) { + LOGED(ERROR, domid, "Failed to setup CPU policy topology"); + rc =3D ERROR_FAIL; + goto out; + } + /* * For PV guests, PAE is Xen-controlled (it is the 'p' that differenti= ates * the xen-3.0-x86_32 and xen-3.0-x86_32p ABIs). It is mandatory as X= en @@ -466,6 +503,13 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, */ if (info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) pae =3D libxl_defbool_val(info->u.hvm.pae); + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("pae=3D%d", pa= e)); + if (rc) { + LOGD(ERROR, domid, "Failed to set PAE CPUID flag"); + rc =3D ERROR_FAIL; + goto out; + } + =20 /* * Advertising Invariant TSC to a guest means that the TSC frequency w= on't @@ -481,14 +525,50 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domi= d, bool restore, */ itsc =3D (libxl_defbool_val(info->disable_migrate) || info->tsc_mode =3D=3D LIBXL_TSC_MODE_ALWAYS_EMULATE); + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("invtsc=3D%d",= itsc)); + if (rc) { + LOGD(ERROR, domid, "Failed to set Invariant TSC CPUID flag"); + rc =3D ERROR_FAIL; + goto out; + } =20 - r =3D xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, - pae, itsc, nested_virt, info->cpuid); - if (r) - LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy"); + /* Set Nested virt CPUID bits for HVM. */ + if (hvm) { + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("vmx=3D%d", + nested_virt)= ); + if (rc) { + LOGD(ERROR, domid, "Failed to set VMX CPUID flag"); + rc =3D ERROR_FAIL; + goto out; + } + + rc =3D libxl_cpuid_parse_config(&info->cpuid, GCSPRINTF("svm=3D%d", + nested_virt)= ); + if (rc) { + LOGD(ERROR, domid, "Failed to set SVM CPUID flag"); + rc =3D ERROR_FAIL; + goto out; + } + } + + /* Apply the bits from info->cpuid if any. */ + r =3D xc_cpu_policy_apply_cpuid(ctx->xch, policy, info->cpuid, hvm); + if (r) { + LOGEVD(ERROR, domid, -r, "Failed to apply CPUID changes"); + rc =3D ERROR_FAIL; + goto out; + } + + r =3D xc_cpu_policy_set_domain(ctx->xch, domid, policy); + if (r) { + LOGED(ERROR, domid, "Failed to set domain CPUID policy"); + rc =3D ERROR_FAIL; + } =20 + out: + xc_cpu_policy_destroy(policy); GC_FREE; - return r ? ERROR_FAIL : 0; + return rc; } =20 static const char *input_names[2] =3D { "leaf", "subleaf" }; --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200244; cv=pass; d=zohomail.com; s=zohoarc; b=QGku8PpSRvi9kDj84nV1TlWBuBoLd8xDX2iZkmr9RlXpREYrVad1dWVaHaduVoaHpK6S2XduiH83xTuQG38SJtpqSejD9HumywzwOk03n5iG6BFylrtUF1raPyoogoYW1MaDFiL9J8f+c/bD4jWziCJaVEjjMjPFt7YZoGMLL80= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200244; 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=osW8TJUcE1u0NhcxaQgNVI7DKLIgKFg45KRen2zf/Xw=; b=Znjdjv90KlNsQMvpa8Kcy1mr/Q98E+jsmgvevlF2f1n9vIlZePVdOyhWVmGYogZtkcE8Dtd/3Zjm//0iFE7KMrCh3k1F8Uf+pXvdKe18thzGSSIw2xCTBEWxevIq1TWXjNItZRt+Nn79hW1i9YdUGiGT/pnHn5i4REcrdJAh1T8= 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 1638200244175197.44424263679105; Mon, 29 Nov 2021 07:37:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234659.407259 (Exim 4.92) (envelope-from ) id 1mrii9-0000Gx-Kq; Mon, 29 Nov 2021 15:36:57 +0000 Received: by outflank-mailman (output) from mailman id 234659.407259; Mon, 29 Nov 2021 15:36:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mrii9-0000Gf-Gf; Mon, 29 Nov 2021 15:36:57 +0000 Received: by outflank-mailman (input) for mailman id 234659; Mon, 29 Nov 2021 15:36:55 +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 1mrihL-0003uH-UJ for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:08 +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 0fa4ed5c-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:36:04 +0100 (CET) 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: 0fa4ed5c-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200165; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=w+nGI4D8BYe2mv0mAWnC2fyTbsqQxVVOLXv6FnhZGaY=; b=I7r3EtMp+4C5XbriEDf5j+fuY4nO1Q8x+ZZx89TR5ujQPE43DWkezPcF dG34BbhyGgKsz3zwdJWEjIunm8+JYNRPtZNcJEjfnkNaW9uFbyOmzVhaz 5usRZbRYkRE/3ewgKrQfvYK/QYENRSeuI+G0MOlZzA0rbgZc7ZConDFZF c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: l+qnEdUAtumjhCUAk3D9Vd9FYt4sFYMWMIUEJcWo7f4jxCoo0IddUu0DKGYCUkPQPlUEqKiiSm ZDQati3Hp3aaq29TLSf8qa3q3a5I2W+DuedUecs5Y/SvDAiPQV0Vm1jqwd+qVL70o161/biCnL rDqFQAS923acnTFJ9plMDBToVWCvnYFBalnnIUXqnwbGSG/TaGoKYnLnk/AHx2sesC0Nm7SfOo olfRHdBCRuUvzsCRcMk+tex5ZEUmCAPLxe4YReOsFQVU5mulffFMOj+VYEpcFeGAdqciIXFRz4 wngB9Mq18pGWQ2vm5vaQ7Z90 X-SBRS: 5.1 X-MesageID: 58333499 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:6pV5RqwcC0bRyBNQcAN6t+fUwSrEfRIJ4+MujC+fZmUNrF6WrkUDz mQWD2iObPbZY2vxfdl1O43k9EIEuJ/cz9UxSApoqiAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnvopW1TYhSEUOZugH9IQM8aZfHAuLeNYYH1500s6wrRo2tcAbeWRWGthh /uj+6UzB3f9s9JEGjp8B3Wr8U4HU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XAA+Xt3OYfeiwgrp73gQke5/RWXSJdxXdBm++YRmMXWp3PQ2P9sNOVPIwT7Dj 1SaBhIRpO/spY4p8YaW2fDY/tnxS+YnRxhUBWjW67qyJBL2xGv7zN8SSvuMcBDcSHjwpPeoa 9JKwqyuK/YAhltL7dZxSu450aIk6tLzjLZG1QA4Tm7TZlGmB748cHmL2c5D6v9EyrND4FbkX 0uO/p9ROKmTOdOjG1kUfVJ3YuOG3PASuz/T8fVqfxmquH4ppOKKARdIIh2BqC1BN78kYooqz NAotNMS9wHi2AEhNcyLj3wM+mmBRpDav37Lan3O7FfXtzcW IronPort-HdrOrdr: A9a23:zgW96KoYZY2agqFobQG6VO8aV5uxL9V00zEX/kB9WHVpm5Oj+P xGzc526farslsssREb+OxpOMG7MBfhHPlOkPUs1NaZLXTbUQ6TQr2KgrGSpQEIdxeOlNK1kJ 0QCJSWa+eAfGSS7/yKmTVQeuxIqLLskNHK9JfjJjVWPHtXgslbnnlE422gYypLrWd9dP8E/M 323Ls5m9PsQwVcUu2LQl0+G8TTrdzCk5zrJTYAGh4c8QGLyRel8qTzHRS01goXF2on+8ZvzU H11yjCoomzufCyzRHRk0fV8pRtgdPkjv9OHtaFhMQ5IijlziyoeINicbufuy1dmpDj1H8a1P 335zswNcV67H3cOkmzvBvWwgHllA0j7nfzoGXoyEfLkIjcfnYXGsBBjYVWfl/y8Ew7puxx16 pNwiawq4dXJQmoplW92/H4EzVR0makq3srluAey1ZFV5EFVbNXpYsDuGtIDZY7Gj7g4oxPKp ghMCjl3ocUTbqmVQGagoE2q+bcG0jbXy32DXTqg/blkwS/xxtCvg8lLM92pAZ3yHtycegC2w 3+CNUbqFh5dL5gUUtMPpZzfSKJMB25ffu1ChPrHb3GLtBOB5ufke+93F0KjNvaDKDgiqFC3q j8bA== X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58333499" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jh3Fv2fN7LyzHngHBuoE7NGuIEIPg5dD/72H3gQNUfomw/6QC9WBlhzIhAhSHTuNruGs7eQ5kSKwXib6Zf+VynoXKp9++h7/wB1Y4Fi7sd9UKHxlJ0U5MFvpOevp26x6Bi8QlnqI0UP0EETVdODd/WQqr3CU2xohKKAncXzqdmHRPaVQrB1ueTDwbncTeaSt27DOmM8UlGxe10o2RoBXmI6MeAw8lRDwYXyv+Dkb+cLkpEJDHwKKPfcgldyeA2Df40pZkOKh4vSc3g699vQnYNafdfGwIS+OzmSuFsldXKVMmW3fxvW7ee0YN24sO3FRPFf0bhM1a159i6D/1i8gIg== 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=osW8TJUcE1u0NhcxaQgNVI7DKLIgKFg45KRen2zf/Xw=; b=AAbBoXBXKoMm+Z7x3o0X27htP5CaHFCYhbiu3IysHpOng61bD6u6cybDRO7kuRWZ0MRbKAQEEfKeQEtHGpqtpEQHPouIbbFhPqBjblG2x5Ql52YTjzL595rpn2zKEcpT9vzb7oBYPaTF4hHA/17BitO53V+X5biu5FthsvEZvfOBNaH6QBnawFmgXzJ5bidie2Cgvdbm+eXXNMsyrpvUqg2bnbgW3ygZh2pdzVCHF0A6BCfnEfIWWDAIFLXvjYds7Ki/ra8PQYSRl7TNl1Hit4UsgKAPb70uecf61j8kyn/M1/LQ7tS5xMowGQrCRxS7AzobQVy+X2QEwiBaEG1HMw== 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=osW8TJUcE1u0NhcxaQgNVI7DKLIgKFg45KRen2zf/Xw=; b=TO3ZNBo+3YTglm4yho6JlDJEqAzBIl5YOLdW7Ixsf/DtP77pAo9zQq4PXf3qF+MhHeSB/C2sbaEQ4Tq2qcSiiCCwf6H+rMTKE4R2SbHVti7+3FNhiv08dFiVldF71futF7DO+E/IoJvLavmq1UOG8r2B6Sxo8q5ryq3BT7ikVos= From: Roger Pau Monne To: CC: Roger Pau Monne , Ian Jackson , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v5 11/12] libs/guest: (re)move xc_cpu_policy_apply_cpuid Date: Mon, 29 Nov 2021 16:33:54 +0100 Message-ID: <20211129153355.60338-12-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MRXP264CA0034.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::22) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54774d59-5f4f-4564-9487-08d9b34df217 X-MS-TrafficTypeDiagnostic: DM6PR03MB5340: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:272; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0aL/XQUHA6SoC/Fwq2M9XQlCxdsR4knasmg/jBH3ipQzJolgcGqi+gC76Vw1b906QGdLa4iEC9zTtE1iqKN+HQ/zndh8DZvH09sbU3siiji1Juo8yY/dwIBtOBwgUlxHQRiMgJIbc2vTA/1e7YElvMZvd4506wZ4fFq3thO0M4ljohXfTOvsw7OD4GY59wJwEwrXmQ3eiV3J5nwFl90urdnaG/Dj+hpR7FsO/CIShNPennAzLmzdOnwVV+GuYIwmxdrkEbncOIiUyeycKCUml4lOt5W58HyWcm7aLEYDMWQtWcA3pTM3YpuePkNkqGyaEhTDax3SjFMzttjU7WdKcDAPZD4MliT6/WIYCXQ0zkA9FkNUQ23a3k0q9Zz2Po34E/SL1h32z955Y6Ob80tDsyWT0UFotllVjwJhUg2iaTLQ+C3SECARmQJ25R0hyASEK+182R061T8ms585xtkMd5wF+1V1OlhES8t8gDPhgmJBkHVdryUaQZS26OR19w5eUqqJgbR4Q+sBRplJaxQTBQQ8w+HhnHLcLf49/V76QEO+P4fAPAzpVxzCaDKEMi7JmTxGeths6h8k0msNXBcRUPX/IitUlla5+N/17CX4UJQ6XbOZuJApFFy3ZlzaErBdnqDFM6WEA7FP9BxKnaU+Fg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(30864003)(82960400001)(66946007)(86362001)(1076003)(508600001)(5660300002)(8676002)(6486002)(316002)(38100700002)(6496006)(26005)(83380400001)(6916009)(66476007)(2906002)(66556008)(2616005)(956004)(8936002)(54906003)(186003)(36756003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T0hGMzBpdUYwdkJBRDkyRGxWVVorUXJIVW8wd1dYMXVjQXV2K1Bhd2Y2MGRG?= =?utf-8?B?dlV6dnN0T1cxYnAzWUF0YWZta01hNFNJQjAxVFlxdGh3MHlncXdmczIxTUxX?= =?utf-8?B?VnUyVjY1bmsvMHgvZ3hOQzlwVlFwL0FlOEoyaUtXNUJvdTNwRkpyZWw0cGQ1?= =?utf-8?B?RXVVRjhWbklPM1R5bUlSSjBIeERNcW5OV09F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3lHRHR5?= =?utf-8?B?NXJJY2lFN1NyZWFRS0ZQNmtOMi9zQVZUM2FVcHVOZC8yTVNnaVlZdG1TZDh5?= =?utf-8?B?Wk5jd1pQeFl4YlVIcmVxY3cxTUpha3p2TStzL1RYUHpyM3hWYkVVaFJmTnUw?= =?utf-8?B?bHdVbWE0ek1HazREM25LN3ZtQlVUQUFGZlYxcVFMUThYdFM4Z00xVGtWQzlT?= =?utf-8?Q?SR9Q9wFnqiKPdnTELCBAiEc=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 54774d59-5f4f-4564-9487-08d9b34df217 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:36:00.7072 (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: tZPPtT6iUwXi6JSRh1WlxHIgDiFtKNmdz2vi8IAYPDvh0Ice7d//nl3hd2W2gFKR6tXXy8PmnMO8R4ncmzOmKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB5340 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200244722100002 Move the logic from xc_cpu_policy_apply_cpuid into libxl, now that the xc_cpu_policy_* helpers allow modifying a cpu policy. By moving such parsing into libxl directly we can get rid of xc_xend_cpuid, as libxl will now implement it's own private type for storing CPUID information, which currently matches xc_xend_cpuid. Note the function logic is moved as-is, but requires adapting to the libxl coding style. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Anthony PERARD --- Changes since v2: - Use LOG*D. - Pass a gc to apply_policy. - Use 'r' for libxc return values. --- tools/include/libxl.h | 6 +- tools/include/xenctrl.h | 26 ------ tools/include/xenguest.h | 4 - tools/libs/guest/xg_cpuid_x86.c | 125 -------------------------- tools/libs/light/libxl_cpuid.c | 142 ++++++++++++++++++++++++++++-- tools/libs/light/libxl_internal.h | 26 ++++++ 6 files changed, 165 insertions(+), 164 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 2bbbd21f0b..8a8032ba25 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -1420,10 +1420,10 @@ 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. + * libxl_cpuid_policy is opaque in the libxl ABI. Users of libxl may not m= ake + * assumptions about libxl__cpuid_policy. */ -typedef struct xc_xend_cpuid libxl_cpuid_policy; +typedef struct libxl__cpuid_policy libxl_cpuid_policy; typedef libxl_cpuid_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); diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 745d67c970..79169f8ace 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -1803,32 +1803,6 @@ int xc_domain_debug_control(xc_interface *xch, =20 #if defined(__i386__) || defined(__x86_64__) =20 -/* - * CPUID policy data, expressed in the legacy XEND format. - * - * Policy is an array of strings, 32 chars long: - * policy[0] =3D eax - * policy[1] =3D ebx - * policy[2] =3D ecx - * policy[3] =3D edx - * - * The format of the string is the following: - * '1' -> force to 1 - * '0' -> force to 0 - * 'x' -> we don't care (use default) - * 'k' -> pass through host value - * 's' -> legacy alias for 'k' - */ -struct xc_xend_cpuid { - union { - struct { - uint32_t leaf, subleaf; - }; - uint32_t input[2]; - }; - char *policy[4]; -}; - 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/include/xenguest.h b/tools/include/xenguest.h index 8f05d8aa66..3462d27516 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -825,10 +825,6 @@ int xc_cpu_policy_make_compat_4_12(xc_interface *xch, = xc_cpu_policy_t *policy, int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t *poli= cy, bool hvm); =20 -/* Apply an xc_xend_cpuid object to the policy. */ -int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, - const struct xc_xend_cpuid *cpuid, bool hvm); - /* Apply a featureset to the policy. */ int xc_cpu_policy_apply_featureset(xc_interface *xch, xc_cpu_policy_t *pol= icy, const uint32_t *featureset, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index f4ed632d60..7ce0a08580 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -254,131 +254,6 @@ int xc_set_domain_cpu_policy(xc_interface *xch, uint3= 2_t domid, return ret; } =20 -int xc_cpu_policy_apply_cpuid(xc_interface *xch, xc_cpu_policy_t *policy, - const struct xc_xend_cpuid *cpuid, bool hvm) -{ - int rc; - xc_cpu_policy_t *host =3D NULL, *def =3D NULL; - - host =3D xc_cpu_policy_init(); - def =3D xc_cpu_policy_init(); - if ( !host || !def ) - { - PERROR("Failed to init policies"); - rc =3D -ENOMEM; - goto out; - } - - /* Get the domain type's default policy. */ - rc =3D xc_cpu_policy_get_system(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_d= efault - : XEN_SYSCTL_cpu_policy_pv_defa= ult, - def); - if ( rc ) - { - PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv"); - goto out; - } - - /* Get the host policy. */ - rc =3D xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host, host); - if ( rc ) - { - PERROR("Failed to obtain host policy"); - goto out; - } - - rc =3D -EINVAL; - for ( ; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid ) - { - xen_cpuid_leaf_t cur_leaf; - xen_cpuid_leaf_t def_leaf; - xen_cpuid_leaf_t host_leaf; - - rc =3D xc_cpu_policy_get_cpuid(xch, policy, cpuid->leaf, cpuid->su= bleaf, - &cur_leaf); - if ( rc ) - { - ERROR("Failed to get current policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - rc =3D xc_cpu_policy_get_cpuid(xch, def, cpuid->leaf, cpuid->suble= af, - &def_leaf); - if ( rc ) - { - ERROR("Failed to get def policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - rc =3D xc_cpu_policy_get_cpuid(xch, host, cpuid->leaf, cpuid->subl= eaf, - &host_leaf); - if ( rc ) - { - ERROR("Failed to get host policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - - for ( unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++ ) - { - uint32_t *cur_reg =3D &cur_leaf.a + i; - const uint32_t *def_reg =3D &def_leaf.a + i; - const uint32_t *host_reg =3D &host_leaf.a + i; - - if ( cpuid->policy[i] =3D=3D NULL ) - continue; - - for ( unsigned int j =3D 0; j < 32; j++ ) - { - bool val; - - switch ( cpuid->policy[i][j] ) - { - case '1': - val =3D true; - break; - - case '0': - val =3D false; - break; - - case 'x': - val =3D test_bit(31 - j, def_reg); - break; - - case 'k': - case 's': - val =3D test_bit(31 - j, host_reg); - break; - - default: - ERROR("Bad character '%c' in policy[%d] string '%s'", - cpuid->policy[i][j], i, cpuid->policy[i]); - goto out; - } - - clear_bit(31 - j, cur_reg); - if ( val ) - set_bit(31 - j, cur_reg); - } - } - - rc =3D xc_cpu_policy_update_cpuid(xch, policy, &cur_leaf, 1); - if ( rc ) - { - PERROR("Failed to set policy leaf %#x subleaf %#x", - cpuid->leaf, cpuid->subleaf); - goto out; - } - } - - out: - xc_cpu_policy_destroy(def); - xc_cpu_policy_destroy(host); - - return rc; -} - xc_cpu_policy_t *xc_cpu_policy_init(void) { return calloc(1, sizeof(struct xc_cpu_policy)); diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 07d445d9f9..bf710ba196 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -309,7 +309,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *c= puid, const char* str) char *sep, *val, *endptr; int i; const struct cpuid_flags *flag; - struct xc_xend_cpuid *entry; + struct libxl__cpuid_policy *entry; unsigned long num; char flags[33], *resstr; =20 @@ -387,7 +387,7 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_li= st *cpuid, char *endptr; unsigned long value; uint32_t leaf, subleaf =3D XEN_CPUID_INPUT_UNUSED; - struct xc_xend_cpuid *entry; + struct libxl__cpuid_policy *entry; =20 /* parse the leaf number */ value =3D strtoul(str, &endptr, 0); @@ -437,6 +437,137 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_= list *cpuid, return 0; } =20 +static int apply_cpuid(libxl__gc *gc, xc_cpu_policy_t *policy, + libxl_cpuid_policy_list cpuid, bool hvm, domid_t do= mid) +{ + int r, rc =3D 0; + xc_cpu_policy_t *host =3D NULL, *def =3D NULL; + + host =3D xc_cpu_policy_init(); + def =3D xc_cpu_policy_init(); + if (!host || !def) { + LOGD(ERROR, domid, "Failed to init policies"); + rc =3D ERROR_FAIL; + goto out; + } + + /* Get the domain type's default policy. */ + r =3D xc_cpu_policy_get_system(CTX->xch, + hvm ? XEN_SYSCTL_cpu_policy_hvm_default + : XEN_SYSCTL_cpu_policy_pv_default, + def); + if (r) { + LOGED(ERROR, domid, "Failed to obtain %s def policy", + hvm ? "hvm" : "pv"); + rc =3D ERROR_FAIL; + goto out; + } + + /* Get the host policy. */ + r =3D xc_cpu_policy_get_system(CTX->xch, XEN_SYSCTL_cpu_policy_host, h= ost); + if (r) { + LOGED(ERROR, domid, "Failed to obtain host policy"); + rc =3D ERROR_FAIL; + goto out; + } + + for (; cpuid->leaf !=3D XEN_CPUID_INPUT_UNUSED; ++cpuid) { + xen_cpuid_leaf_t cur_leaf; + xen_cpuid_leaf_t def_leaf; + xen_cpuid_leaf_t host_leaf; + + r =3D xc_cpu_policy_get_cpuid(CTX->xch, policy, cpuid->leaf, + cpuid->subleaf, &cur_leaf); + if (r) { + LOGED(ERROR, domid, + "Failed to get current policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + r =3D ERROR_FAIL; + goto out; + } + r =3D xc_cpu_policy_get_cpuid(CTX->xch, def, cpuid->leaf, cpuid->s= ubleaf, + &def_leaf); + if (r) { + LOGED(ERROR, domid, + "Failed to get def policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + r =3D xc_cpu_policy_get_cpuid(CTX->xch, host, cpuid->leaf, + cpuid->subleaf, &host_leaf); + if (r) { + LOGED(ERROR, domid, + "Failed to get host policy leaf %#x subleaf %#x", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + + for (unsigned int i =3D 0; i < ARRAY_SIZE(cpuid->policy); i++) { + uint32_t *cur_reg =3D &cur_leaf.a + i; + const uint32_t *def_reg =3D &def_leaf.a + i; + const uint32_t *host_reg =3D &host_leaf.a + i; + + if (cpuid->policy[i] =3D=3D NULL) + continue; + +#define test_bit(i, r) !!(*(r) & (1u << (i))) +#define set_bit(i, r) (*(r) |=3D (1u << (i))) +#define clear_bit(i, r) (*(r) &=3D ~(1u << (i))) + for (unsigned int j =3D 0; j < 32; j++) { + bool val; + + switch (cpuid->policy[i][j]) { + case '1': + val =3D true; + break; + + case '0': + val =3D false; + break; + + case 'x': + val =3D test_bit(31 - j, def_reg); + break; + + case 'k': + case 's': + val =3D test_bit(31 - j, host_reg); + break; + + default: + LOGD(ERROR, domid, + "Bad character '%c' in policy[%d] string '%s'", + cpuid->policy[i][j], i, cpuid->policy[i]); + rc =3D ERROR_FAIL; + goto out; + } + + clear_bit(31 - j, cur_reg); + if (val) + set_bit(31 - j, cur_reg); + } +#undef clear_bit +#undef set_bit +#undef test_bit + } + + r =3D xc_cpu_policy_update_cpuid(CTX->xch, policy, &cur_leaf, 1); + if (r) { + LOGED(ERROR, domid, "Failed to set policy leaf %#x subleaf %#x= ", + cpuid->leaf, cpuid->subleaf); + rc =3D ERROR_FAIL; + goto out; + } + } + + out: + xc_cpu_policy_destroy(def); + xc_cpu_policy_destroy(host); + return rc; +} + int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore, libxl_domain_build_info *info) { @@ -552,10 +683,9 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, } =20 /* Apply the bits from info->cpuid if any. */ - r =3D xc_cpu_policy_apply_cpuid(ctx->xch, policy, info->cpuid, hvm); - if (r) { - LOGEVD(ERROR, domid, -r, "Failed to apply CPUID changes"); - rc =3D ERROR_FAIL; + rc =3D apply_cpuid(gc, policy, info->cpuid, hvm, domid); + if (rc) { + LOGD(ERROR, domid, "Failed to apply CPUID changes"); goto out; } =20 diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 0b4671318c..7ab5247329 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -2060,6 +2060,32 @@ typedef yajl_gen_status (*libxl__gen_json_callback)(= yajl_gen hand, void *); _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p); =20 +/* + * CPUID policy data, expressed in the internal libxl format. + * + * Policy is an array of strings, 32 chars long: + * policy[0] =3D eax + * policy[1] =3D ebx + * policy[2] =3D ecx + * policy[3] =3D edx + * + * The format of the string is the following: + * '1' -> force to 1 + * '0' -> force to 0 + * 'x' -> we don't care (use default) + * 'k' -> pass through host value + * 's' -> legacy alias for 'k' + */ +struct libxl__cpuid_policy { + union { + struct { + uint32_t leaf, subleaf; + }; + uint32_t input[2]; + }; + char *policy[4]; +}; + _hidden int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retor= e, libxl_domain_build_info *info); =20 --=20 2.33.0 From nobody Fri Nov 29 12:50:07 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=1638200248; cv=pass; d=zohomail.com; s=zohoarc; b=ZJ0iVP0B3G0RUH4zNKiBvVMPpltdFcOf68V+wYxT+773+s1Aiur+SsxqbXMRDWNcfmOhU6OKXLT+xO5mhc2W0wWyJQYWXywAgALZxG5P0Mxx5/ZHhCuRFO05Df8ojcZy4hOXcSsHlelSWPr9yu7bhVPU9Z5nYSEz/V2I9Ced4gE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638200248; 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=rU77IFnPQdUFFfhSMm0buGRsWwFsG5UILU9PerQjkho=; b=DrJL0LYdJetGTfgn7FB/mVc1r4fyD3qSqVWFM75vlhBnnIRTYvie6dYBSoyXN151ojNwuux85uHR4gAgiZuFc5kF+VWiEW+HbF9UD1XTWdreutd9YOL4hEokZ1/lovl1GX5nw1nYrCaXrJASzJNy5LvvlSM+WwJzLfQUyhQXwlQ= 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 1638200248729675.4592111385523; Mon, 29 Nov 2021 07:37:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234680.407292 (Exim 4.92) (envelope-from ) id 1mriiG-0001Cm-QQ; Mon, 29 Nov 2021 15:37:04 +0000 Received: by outflank-mailman (output) from mailman id 234680.407292; Mon, 29 Nov 2021 15:37:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mriiG-0001Cc-L3; Mon, 29 Nov 2021 15:37:04 +0000 Received: by outflank-mailman (input) for mailman id 234680; Mon, 29 Nov 2021 15:37:03 +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 1mrihO-0003uH-4A for xen-devel@lists.xenproject.org; Mon, 29 Nov 2021 15:36:10 +0000 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 11e70a01-512a-11ec-b941-1df2895da90e; Mon, 29 Nov 2021 16:36:08 +0100 (CET) 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: 11e70a01-512a-11ec-b941-1df2895da90e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1638200168; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=cid3XAEKeAP1zvjCEhGe8Q+Rh5AudOlwxXpnQ/D+76M=; b=D7YRZtuC9Qv1FbbJLHoPb/zijylAfpzlLlxDx/8zTMlB2e/9lCS5fAgG 4P4x/EHuiDG7RGiJXODgnpsKl2JU7C26bF06y0VOWWmt7KKjLxlG8yXB/ crHBzjayRp6B1yue9mfAG5Wwx5m1sg0kWI7FTADtLRMdbB1GhuuFVDIC1 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com IronPort-SDR: B4v6gXUxgBwGSnstuRy7V2RnsUdd63EnUBcaT1YlZWd0ghCVNdwkmqqcSUWEyj84wNwFs62BkC jcLRE5sEffUNfljy8t6nHbfws5boBRDjtQ9CItU+F8Poe8eAMDTzMXjcWGby2e7EqjBidYz7HS wFfA68q/NhpJBjI5bog/UvfOMhwaSnXPqudTqQPbC7G29kYGUVCeUT9D90Qk9U3FeDxwVwNXIy X9VrxM2EPTpSPzAjEuAvNRYirIyABnThFVrz5/I18pkkKKrnBK4EK2dSzut6NY3/MQo5gsKOIp H/a3Hd+AdE+HuxGVQ9VKFKoX X-SBRS: 5.1 X-MesageID: 58835528 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:LT3YgqPalrDi9fLvrR1ZkMFynXyQoLVcMsEvi/4bfWQNrUoq1TdSn DRLUT/XOPaMYzH0ctxxbYuw80sC7JHWzINjTgto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6bUsxNbVU8En540Egyw7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozG5ot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bRUHLP1J+jP egFnevhNPAnnUpRt9YuGbhc0q9jtcDkoKVXz1o4ESyTPUirEL5pPlKPwdJL6v9W3rZctAa7B hCP991dNenbMc/pCgdMdg8sb+DF3vAIgDjCq/8yJRyitiNw+bOGV2RUPgWN13MBfOckbtt9z LdzotMS5iy+lgEuY4SPgS1j/miRKmANDvc8vZYADY630gcmxzmuu3AH5vMaNH1XV+hxDw== IronPort-HdrOrdr: A9a23:W7YCta59Pq79uJm9iQPXwVKBI+orL9Y04lQ7vn2ZFiY7TiXIra yTdaoguCMc6AxxZJkh8erwXJVoJkmsiaKdgLNhQItKOTOJhILGFvAF0WKP+UyDJ8S6zJ8n6U 4CSdkONDSTNykCsS+S2mDReLxBsbr3gJxAx92utUuFJTsaFZ2IhD0JbTpzfHcGITWvUvECZe WhD4d81nCdUEVSSv7+KmgOXuDFqdGOvJX6YSQeDxpizAWVlzun5JPzDhDdh34lIn9y6IZn1V KAvx3y562lvf3+4hjA11XL55ATvNf60NNMCOGFl8BQADTxjQSDYphnRtS5zX0IidDqzGxvvM jHoh8mMcg2w3TNflutqR+o4AXk2CZG0Q6q9XaoxV/Y5eDpTjMzDMRMwahDdAHC1kYmtNZglI pWwmOwrfNsfFL9tRW4w+KNewBhl0Kyr3Znu/UUlWZjXYwXb6IUhZAD/XlSDIwLEEvBmc4a+d FVfYLhDcttABGnhyizhBgr/DXsZAV9Iv6+eDlDhiTPuAIm2EyQzCMjtboidzk7hdUAoqJ/lp b525JT5cZzp/8tHNFA7dg6ML6K4xT2MGrx2UKpUBza/fI8SjnwQ6Ce2sRA2AjtQu1P8KcP X-IronPort-AV: E=Sophos;i="5.87,273,1631592000"; d="scan'208";a="58835528" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Esp0zRW9PBuH+gQ/JawkliNQ3i41F/M1gUIC+BILNbUcUjAGFldyrKHn8Ojpg9Nno4/kkqqFygNFmZ5vW1Ahy0r26bvqwd5ZYJTv+a5okm6ZhcneIQ83Ii79kIwXq8+/9uShA+VxPGZeUGCuwwGnYRLLHl5UUoKXt6ii31HG2CYKZngGRGOLK7+MZaphwXZ1oeOb9ZZyULTRw5jiNwyGAkGJCVvqe4XPHXbCoClpRRU9NZ3lfr261yiM80lGgBCFJvQq3H73/T3cGR+6OGJhk7Zc/lXj5p/pn0TuMRpzlAhX46Vdq/C+nW4uETFY73MStIAyVyMwTMkZY8GI4o9paQ== 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=rU77IFnPQdUFFfhSMm0buGRsWwFsG5UILU9PerQjkho=; b=Qj41x4ZCsMHtry0+08tSRknEF+nLUTbCYQ0k/D8iP2YGUUoRHDuFpjsXO/H3quGjVaff6dMrSAGDr/RHuEIYqSxzqtfmomLJlDDOwU7ixJzX5IpzMUd42H2twbanjICrFsGnc2fUW8Hw/hiYvGQ9iVNfFHmR3wC/01cB5jzoSgI9Agx9SyTQXj/tBhAGJvup2ljEQmx+8Wj7bFxmT1jLW+GY53hRvUocbOK+QOP+yLL7EUUzyjrnVE2A3qZc0rNYKbzoP6IB2t4gmRfPsifhi1Wi1DlMmccL/5pY7DSjodmZgjVRIixXA5pGo+XZUPPycuVFr4rgOgxX9Wnx0yeLhA== 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=rU77IFnPQdUFFfhSMm0buGRsWwFsG5UILU9PerQjkho=; b=Zxm8+FrkL25l5mCu0rs2U0CsrQdWa6F4BEk3Z5gzJpL7H0ca+JduYzuuI0+nCfVZG9lI84uDmt/Sg+fSfG92YULi4DZyTRCP8G6BAdld2G/pKqluKeaGm3RNWWNIgu3+Dpr65slL3JR2wZIa80Bpa8S1w1nM7qqdVG7O0LACqwE= From: Roger Pau Monne To: CC: Jan Beulich , Ian Jackson , Wei Liu , Juergen Gross , Anthony PERARD , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 12/12] x86/CPUID: shrink max_{,sub}leaf fields according to actual leaf contents Date: Mon, 29 Nov 2021 16:33:55 +0100 Message-ID: <20211129153355.60338-13-roger.pau@citrix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211129153355.60338-1-roger.pau@citrix.com> References: <20211129153355.60338-1-roger.pau@citrix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MRXP264CA0039.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::27) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96ed219c-5b5b-4d5d-a8e5-08d9b34df463 X-MS-TrafficTypeDiagnostic: DM6PR03MB5340: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BfgNwBbbiUJEu178+H2t7awtUsqrhQq3T2yMgL3PbtqR1Fp/LUDB0YA7GuBqJIrnPv5+iMm+KZUuA4CFGHZKx+YNKV03Q4+f3i4fdzB9GYLVUMlObpEdywa0KAbej0OSsZAIkd6Of6jxXo14paj/aSXVRQOed2t8fvB4/pK7MlN4kzYvWAm4BqTefb8pkEVb/ZtymRezrnHcWTekkAa+g9ZtbpI/6udiQTpssdhDIMLwYANLhSJ0BOl3XCh4E38cVsPKqItxGLt8ayTNKFVcikBEP+Mdw+7xd0eMG+fsJVjqZ3nKKFOXv8iZoXNVYMOUbCu6AeOl0FP/SGC1XH4yhROoTVMkV7nJrIWpvtNhPKhCN05n418x1W0KzEly5U/YF3ZTT7z335JSg08V0/2+orQsKP7SWtU/ceqPN/+J0MOaikzcGtkmqvkDSuvJwRwxNM80/Ke5FFqMpGldSKWnE1bITi1wAipO4af08wowl5pI9gSjnIyIGTHhPud133B1vxpNBVIyfSm7I+KoWtka0y7cXbN4nagWBx8o+iUlVJPFK4J3VSLS0uD3N0bjrHJQmmIYsNUjbpMk4oYeb/R4f3E2lesteER9mnYlyZ+0AGZ7kC63RGSf5YtSi4SuHh7GnH8Z4Wzz1zH1tPt424aQMg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(82960400001)(66946007)(86362001)(1076003)(508600001)(5660300002)(8676002)(107886003)(6486002)(316002)(38100700002)(6496006)(26005)(83380400001)(6916009)(66476007)(2906002)(66556008)(2616005)(956004)(8936002)(54906003)(186003)(36756003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aUVnWnkxcmdKcHMwbGJWcUdxZ0tqZzlPWTdOWTNiWjc2ellWUlVLVWtaV2Jl?= =?utf-8?B?QldmUjNpRk9YUklCTXJ4Z1p1Z2lCSEVGbW0vKzNpdk5ZcHh0M21HSFk4TWhv?= =?utf-8?B?RGV1cHI0TWE1Q1UxZFpwTUNROUJiMy9UZzNlSXJZT0NUQ1R1VFdNTE9PWVp4?= =?utf-8?B?SVVTM1B4bytPVjlhLzNGaXVUOUxoeUZTalo2d09wWHd6djJwbDNaWDBXVVFi?= =?utf-8?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1NReEptdWcxQ3BpL0N3ZVRyR0QyeGltdXIv?= =?utf-8?B?cEduZG1ZT2JuUm5ZQlY2dHFnQWlwanhyZlVWcCtMZHlNY2t4Q2cwWEI2ejYv?= =?utf-8?B?dFVELzBKOWZxNGxXZnRvaTlPdGJUSmNqWkR0dFlndTBvRmhZVUV2cjJRYXhF?= =?utf-8?Q?NKguk43l83cPLLzh1pHMmwc=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 96ed219c-5b5b-4d5d-a8e5-08d9b34df463 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 15:36:04.5095 (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: BDdqEpq1BnLeJaf/c/3DOVqqgkgpZ739P2E5Q6nlHmLCg79syoxAmg3rtXquuFetNyToN4zPkrrna7htJslb/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB5340 X-OriginatorOrg: citrix.com X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1638200249730100003 From: Jan Beulich Zapping leaf data for out of range leaves is just one half of it: To avoid guests (bogusly or worse) inferring information from mere leaf presence, also shrink maximum indicators such that the respective trailing entry is not all blank (unless of course it's the initial subleaf of a leaf that's not the final one). This is also in preparation of bumping the maximum basic leaf we support, to ensure guests not getting exposed related features won't observe a change in behavior. Note that such shrinking is only done when creating a policy for a domain from scratch. Migrated in domains keep their previous policy if present untouched, and for migrated in domains not having CPUID data the crafted Xen pre-4.13 policy is not trimmed to keep a behavior compatible with those older Xen versions. Signed-off-by: Jan Beulich Signed-off-by: Roger Pau Monn=C3=A9 --- Changes since v4: - New in this version, picked up from 540d911c2813. - Only shrink policies for newly created domains. --- tools/include/xenguest.h | 3 + tools/libs/guest/xg_cpuid_x86.c | 5 ++ tools/libs/light/libxl_cpuid.c | 7 ++ tools/tests/cpu-policy/test-cpu-policy.c | 101 +++++++++++++++++++++++ xen/include/xen/lib/x86/cpuid.h | 7 ++ xen/lib/x86/cpuid.c | 39 +++++++++ 6 files changed, 162 insertions(+) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 3462d27516..e8b0d3ff16 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -830,6 +830,9 @@ int xc_cpu_policy_apply_featureset(xc_interface *xch, x= c_cpu_policy_t *policy, const uint32_t *featureset, unsigned int nr_features); =20 +/* Sanitize a policy: can change the contents of the passed policy. */ +void xc_cpu_policy_sanitize(xc_interface *xch, xc_cpu_policy_t *policy); + int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps); int xc_get_cpu_featureset(xc_interface *xch, uint32_t index, uint32_t *nr_features, uint32_t *featureset); diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 7ce0a08580..eca844b921 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -690,3 +690,8 @@ int xc_cpu_policy_apply_featureset(xc_interface *xch, x= c_cpu_policy_t *policy, =20 return 0; } + +void xc_cpu_policy_sanitize(xc_interface *xch, xc_cpu_policy_t *policy) +{ + x86_cpuid_policy_shrink_max_leaves(&policy->cpuid); +} diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index bf710ba196..5b2690a7d7 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -689,6 +689,13 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid= , bool restore, goto out; } =20 + /* + * Do not attempt any modifications if creating a policy that aims to = be + * compatible with pre-4.13 Xen versions. + */ + if (!restore) + xc_cpu_policy_sanitize(ctx->xch, policy); + r =3D xc_cpu_policy_set_domain(ctx->xch, domid, policy); if (r) { LOGED(ERROR, domid, "Failed to set domain CPUID policy"); diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-pol= icy/test-cpu-policy.c index 686d7a886c..20419a6108 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -8,10 +8,13 @@ #include =20 #include +#include #include #include #include =20 +#define XSTATE_FP_SSE (X86_XCR0_FP | X86_XCR0_SSE) + static unsigned int nr_failures; #define fail(fmt, ...) \ ({ \ @@ -671,6 +674,103 @@ static void test_msr_get_entry(void) } } =20 +static void test_cpuid_maximum_leaf_shrinking(void) +{ + static const struct test { + const char *name; + struct cpuid_policy p; + } tests[] =3D { + { + .name =3D "basic", + .p =3D { + /* Very basic information only. */ + .basic.max_leaf =3D 1, + .basic.raw_fms =3D 0xc2, + }, + }, + { + .name =3D "cache", + .p =3D { + /* Cache subleaves present. */ + .basic.max_leaf =3D 4, + .cache.subleaf[0].type =3D 1, + }, + }, + { + .name =3D "feat#0", + .p =3D { + /* Subleaf 0 only with some valid bit. */ + .basic.max_leaf =3D 7, + .feat.max_subleaf =3D 0, + .feat.fsgsbase =3D 1, + }, + }, + { + .name =3D "feat#1", + .p =3D { + /* Subleaf 1 only with some valid bit. */ + .basic.max_leaf =3D 7, + .feat.max_subleaf =3D 1, + .feat.avx_vnni =3D 1, + }, + }, + { + .name =3D "topo", + .p =3D { + /* Topology subleaves present. */ + .basic.max_leaf =3D 0xb, + .topo.subleaf[0].type =3D 1, + }, + }, + { + .name =3D "xstate", + .p =3D { + /* First subleaf always valid (and then non-zero). */ + .basic.max_leaf =3D 0xd, + .xstate.xcr0_low =3D XSTATE_FP_SSE, + }, + }, + { + .name =3D "extd", + .p =3D { + /* Commonly available information only. */ + .extd.max_leaf =3D 0x80000008, + .extd.maxphysaddr =3D 0x28, + .extd.maxlinaddr =3D 0x30, + }, + }, + }; + + printf("Testing CPUID maximum leaf shrinking:\n"); + + for ( size_t i =3D 0; i < ARRAY_SIZE(tests); ++i ) + { + const struct test *t =3D &tests[i]; + struct cpuid_policy *p =3D memdup(&t->p); + + p->basic.max_leaf =3D ARRAY_SIZE(p->basic.raw) - 1; + p->feat.max_subleaf =3D ARRAY_SIZE(p->feat.raw) - 1; + p->extd.max_leaf =3D 0x80000000 | (ARRAY_SIZE(p->extd.raw) - 1); + + x86_cpuid_policy_shrink_max_leaves(p); + + /* Check the the resulting max (sub)leaf values against expecation= s. */ + if ( p->basic.max_leaf !=3D t->p.basic.max_leaf ) + fail(" Test %s basic fail - expected %#x, got %#x\n", + t->name, t->p.basic.max_leaf, p->basic.max_leaf); + + if ( p->extd.max_leaf !=3D t->p.extd.max_leaf ) + fail(" Test %s extd fail - expected %#x, got %#x\n", + t->name, t->p.extd.max_leaf, p->extd.max_leaf); + + if ( p->feat.max_subleaf !=3D t->p.feat.max_subleaf ) + fail(" Test %s feat fail - expected %#x, got %#x\n", + t->name, t->p.feat.max_subleaf, p->feat.max_subleaf); + + free(p); + } +} + static void test_is_compatible_success(void) { static struct test { @@ -787,6 +887,7 @@ int main(int argc, char **argv) test_cpuid_deserialise_failure(); test_cpuid_out_of_range_clearing(); test_cpuid_get_leaf_failure(); + test_cpuid_maximum_leaf_shrinking(); =20 test_msr_serialise_success(); test_msr_deserialise_failure(); diff --git a/xen/include/xen/lib/x86/cpuid.h b/xen/include/xen/lib/x86/cpui= d.h index 050cd4f9d1..86cda38986 100644 --- a/xen/include/xen/lib/x86/cpuid.h +++ b/xen/include/xen/lib/x86/cpuid.h @@ -386,6 +386,13 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy = *p); */ void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p); =20 +/** + * Shrink max leaf/subleaf values such that the last respective valid entry + * isn't all blank. While permitted by the spec, such extraneous leaves m= ay + * provide undue "hints" to guests. + */ +void x86_cpuid_policy_shrink_max_leaves(struct cpuid_policy *p); + #ifdef __XEN__ #include typedef XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_leaf_buffer_t; diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c index 924f882fc4..6a943cd91b 100644 --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -236,6 +236,45 @@ void x86_cpuid_policy_clear_out_of_range_leaves(struct= cpuid_policy *p) ARRAY_SIZE(p->extd.raw) - 1); } =20 +void x86_cpuid_policy_shrink_max_leaves(struct cpuid_policy *p) +{ + unsigned int i; + + p->basic.raw[0x4] =3D p->cache.raw[0]; + + for ( i =3D p->feat.max_subleaf; i; --i ) + if ( p->feat.raw[i].a | p->feat.raw[i].b | + p->feat.raw[i].c | p->feat.raw[i].d ) + break; + p->feat.max_subleaf =3D i; + p->basic.raw[0x7] =3D p->feat.raw[i]; + + p->basic.raw[0xb] =3D p->topo.raw[0]; + + /* + * Due to the way xstate gets handled in the hypervisor (see + * recalculate_xstate()) there is (for now at least) no need to fiddle + * with the xstate subleaves (IOW we assume they're already in consist= ent + * shape, for coming from either hardware or recalculate_xstate()). + */ + p->basic.raw[0xd] =3D p->xstate.raw[0]; + + for ( i =3D p->basic.max_leaf; i; --i ) + if ( p->basic.raw[i].a | p->basic.raw[i].b | + p->basic.raw[i].c | p->basic.raw[i].d ) + break; + p->basic.max_leaf =3D i; + + for ( i =3D p->extd.max_leaf & 0xffff; i; --i ) + if ( p->extd.raw[i].a | p->extd.raw[i].b | + p->extd.raw[i].c | p->extd.raw[i].d ) + break; + if ( i | p->extd.raw[0].b | p->extd.raw[0].c | p->extd.raw[0].d ) + p->extd.max_leaf =3D 0x80000000 | i; + else + p->extd.max_leaf =3D 0; +} + const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature) { static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; --=20 2.33.0