From patchwork Wed Aug 23 13:47:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13362574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35F34EE4993 for ; Wed, 23 Aug 2023 13:47:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.589255.921101 (Exim 4.92) (envelope-from ) id 1qYoCx-0005aQ-Uc; Wed, 23 Aug 2023 13:47:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 589255.921101; Wed, 23 Aug 2023 13:47:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qYoCx-0005aJ-RD; Wed, 23 Aug 2023 13:47:39 +0000 Received: by outflank-mailman (input) for mailman id 589255; Wed, 23 Aug 2023 13:47:38 +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 1qYoCw-0005F5-Iq for xen-devel@lists.xenproject.org; Wed, 23 Aug 2023 13:47:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2071.outbound.protection.outlook.com [40.107.7.71]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9eca1ff9-41bb-11ee-8783-cb3800f73035; Wed, 23 Aug 2023 15:47:37 +0200 (CEST) Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by AS8PR04MB8357.eurprd04.prod.outlook.com (2603:10a6:20b:3f1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Wed, 23 Aug 2023 13:47:07 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::f749:b27f:2187:6654]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::f749:b27f:2187:6654%5]) with mapi id 15.20.6699.025; Wed, 23 Aug 2023 13:47:07 +0000 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: 9eca1ff9-41bb-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mhFIuCCn14JoP471XYPI40x07aBjXBtR91iNRCasHiuFjfvPb350rHyHpSaaTWKPCVuKm3qWewH2xW9HKGCAKgeu1/UcXLS3FHr9zazrjTZFs9PXMNfztyF85qGVG4Hnkb4rolfVugbjwN/dRzH6bvV8Cnch7CvMhZ2nUpUiUu3VsqaIChK6RSeXAptw8mvK/oBGGBvfzRiKtgy+JLP9XbxfEkbKXhHgd6+AG9FK/skza0tYmv95x9l27a9hMGkK0TOLA9hHNa4Ks/meINTykeLUd7wdpLVvYYuXD6latgPRARIm3CmWcjA6F6n7O4bs4FrQ/4+WKXmhSdNQ+8FeUw== 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=CIxt7hMLQ6hhZMWbOHJvcK1Rpe3xiwvE+0oqWF42BV4=; b=eYBb/s1xYJNvfQMW080hqyIZRMSihFE+Pw6vDYsDtq1wYyyLEcHUA7kHNm5HUho9woNL4TOC6DyBsL49tBW+c9/oQ47NJgXrti4Z8R8XYTIXdnYYzX4TfOYI8LS5uzHVGOBg2/fhu/5Z1y9GA3/GfowaZao974xuHJVwfw4KqVZ+8561unkkdnI/WRDhiDHQ07J/4rVSZ2VEI9GkwyyX4fBb5WFaQV6Ug6P0r0M6t1vDYylaz3YFqnj18kadwBWGjEMxLTj6rtNKo/JKb3g4132ppi5lLFYmQn6Qaa0kSt+/zaDGz+wXlbp7hQNkWFnp2AzslvmQDAS3eBKzanJ7nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CIxt7hMLQ6hhZMWbOHJvcK1Rpe3xiwvE+0oqWF42BV4=; b=rikvLaJqI4tO7wjaVatmwhV52UdvlgwA7QDwQCoEkD4buWOsCCcyn6aKbmToYOk2V4brxL0MYOk9Ap1Zi53HHX8oYpqYi3sPvhRoZFLwMbjyme8dsjOD8/UYjYCXd+5jig3sMv4G4dsWTR2wPjzqxBBxC5uTtwUUUJ0wAb1DJCponbZeQdnWFsj1QwG9lHzBUjLvMaRRpkE4qMiZXJ6cuhkCfmxC5p09Beh4JOhbwl6DH/DpoFWNpZ3hpPn0lV9W7Mzqi5WyxCi/Ouuh12bbKGJjmd6+3Z/a1x/OilhtXDY+zVYqVWbS21yg2l318+vU6TmLEA3ANY9leUtwyWjhqw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <91bb3d4e-46e6-c210-2610-c4771996adfb@suse.com> Date: Wed, 23 Aug 2023 15:47:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Anthony Perard , Wei Liu , Juergen Gross , Jason Andryuk , Andrew Cooper From: Jan Beulich Subject: [PATCH] libxc: remove / adjust xc_get_cpufreq_para()'s BUILD_BUG_ON()s X-ClientProxiedBy: FR0P281CA0079.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::19) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|AS8PR04MB8357:EE_ X-MS-Office365-Filtering-Correlation-Id: 058a2fc3-1ea0-4548-0a35-08dba3df7125 X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DoVq2gD7VZvnCXdfF/fWkIW1yFd7wMBUd2U4uKyvCTI+hyjSAoieEn2xl2RCEDJ80z15N18AYvMPTu8CauePebwv5tGNPWqXOHsV36MXINfmXqNuG81WfNpp8CjZEZI5+PDXTAjhXEyPbl6SKqsHCpKNlviBh9F277/eeWQ70z3S8JDpbr5n/Ce6PTjTXR96Oti0Yx6Rdz3/XDvkKmU6gMPIlyelUDufzNI8so2EqHEU5pqbvlPWveu9v74m8Lm+R9DVUjccoNmhQTG1nAlFJ1+tr/87N5hRCwWfl8cRVDR1noHZ97IybM0CDzUxu911db8yPAxQqpPOX/CcuAZPann/R/O+7ZZZ8D8t3EM64zb2O+vR4dg8tZ9nRZisSHxQ+h/mlOdPFHTV8ngmd5JGhhUCIIrF0ihMVUyfzL8VwvlUIQwGzdXjipwFhGKECDyChsAPusUH5KfA8f/Ab4b336BhT3q2wNgWyZ15cz9Z98KPVHYSu4KO1n4tjEMKlL6vJ1Q0iK/Fsv14O8aYkA2YWyg364q7YoiQdsvZ5oNi29/Mclo+/m/QOni2Mj9GGKOX502kyEOUo1QYY+jIx2PocZA8lAcqaw0MfoY2iXzcHiyvufxMLnLfAJHKqlhBeqJNHKyEYxjelc6igwyri5VzLA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(376002)(346002)(366004)(39860400002)(1800799009)(186009)(451199024)(54906003)(6916009)(66476007)(66946007)(6512007)(66556008)(316002)(8676002)(8936002)(2616005)(4326008)(36756003)(41300700001)(478600001)(38100700002)(6506007)(6486002)(83380400001)(2906002)(31686004)(31696002)(86362001)(5660300002)(26005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Yt5FqoXrxBxiYOrxA5ksh7e4SX6f?= =?utf-8?q?UxfITiXahM6y5/gv3AqIbOLJNvtcKzx1OgyKDMspQbktT7JSxJG0ws5/jXngn5ftt?= =?utf-8?q?wQQxCYj+r59D1EXGlSZY/JZN6pD+q+SyAzBlF982vk91lhYPzqNKjS0MCxDRi5gyP?= =?utf-8?q?nlUlNEzRFwutU/gh7OdHC0ZN3xi3uz2EDrJxZvlcB3AyX2Z0CgnXMiIyVMOtFBnTZ?= =?utf-8?q?ynnPUFlW1GSAQZGlDDflN5XHxn/Kdfi0b5AGu7fobzwWkUxY6i+g45zcik1J69/F5?= =?utf-8?q?dRUfIhMhVhROSmdETukKcfJwrX9/Gj+md9nP7ITQUNjId71YLfAWv9JRNL9rcnsUn?= =?utf-8?q?bJFVqBYIc94KnH6sP6epu6udHIhjqKsvzd+DqeFQM1I+2gft/7d87pVRA+9lK2cbW?= =?utf-8?q?VYT8Z3B59VtCtS2uqlze+UGK/XDocCeAVKMi1YjheHNhwqhFX+Wcl8E8R5C9X6TWc?= =?utf-8?q?wNqrhzxhyePHI575QBGKEUMki4Qo3FTm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T1IwKmPe34wfLsV7YHNh/wv0f?= =?utf-8?q?dJru2iTmFaBVsof/KRAGZx2EJdZrDlU781DOoux8W50J7bG3lOtmgrIoAcen9F+dm?= =?utf-8?q?i7yYctV/4IOqwwqne9WSZqr3A6MXCkAA7btDfUk4bWVuxdrdQcv8p/vV+UxjPfwzV?= =?utf-8?q?YNezxUmfNTXD?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 058a2fc3-1ea0-4548-0a35-08dba3df7125 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2023 13:47:07.5914 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jsvuyTUQ5LG8ZAMIiwDamyMofcpRkZoJBz6fUE9oF1E2I1i9/XdYrwVjUYf95B9bBSpxtpZ3eL3SXzVGgZBeYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8357 The full structures cannot match in layout, as soon as a 32-bit tool stack build comes into play. But it also doesn't need to; the part of the layouts that needs to match is merely the union that we memcpy() from the sysctl structure to the xc one. Keep (in adjusted form) only the relevant ones. Since the whole block needs touching anyway, move it closer to the respective memcpy() and use a wrapper macro to limit verbosity. Fixes: 2381dfab083f ("xen/sysctl: Nest cpufreq scaling options") Reported-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross Reviewed-by: Jason Andryuk --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -248,45 +248,6 @@ int xc_get_cpufreq_para(xc_interface *xc sys_para->freq_num = user_para->freq_num; sys_para->gov_num = user_para->gov_num; - /* Sanity check struct layout */ - BUILD_BUG_ON(sizeof(*user_para) != sizeof(*sys_para)); - BUILD_BUG_ON(offsetof(typeof(*user_para), cpu_num) != - offsetof(typeof(*sys_para), cpu_num)); - BUILD_BUG_ON(offsetof(typeof(*user_para), freq_num) != - offsetof(typeof(*sys_para), freq_num)); - BUILD_BUG_ON(offsetof(typeof(*user_para), gov_num) != - offsetof(typeof(*sys_para), gov_num)); - BUILD_BUG_ON(offsetof(typeof(*user_para), affected_cpus) != - offsetof(typeof(*sys_para), affected_cpus)); - BUILD_BUG_ON(offsetof(typeof(*user_para), scaling_available_frequencies) != - offsetof(typeof(*sys_para), scaling_available_frequencies)); - BUILD_BUG_ON(offsetof(typeof(*user_para), scaling_available_governors) != - offsetof(typeof(*sys_para), scaling_available_governors)); - BUILD_BUG_ON(offsetof(typeof(*user_para), scaling_driver) != - offsetof(typeof(*sys_para), scaling_driver)); - BUILD_BUG_ON(offsetof(typeof(*user_para), cpuinfo_cur_freq) != - offsetof(typeof(*sys_para), cpuinfo_cur_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), cpuinfo_max_freq) != - offsetof(typeof(*sys_para), cpuinfo_max_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), cpuinfo_min_freq) != - offsetof(typeof(*sys_para), cpuinfo_min_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.scaling_cur_freq) != - offsetof(typeof(*sys_para), u.s.scaling_cur_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.scaling_governor) != - offsetof(typeof(*sys_para), u.s.scaling_governor)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.scaling_max_freq) != - offsetof(typeof(*sys_para), u.s.scaling_max_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.scaling_min_freq) != - offsetof(typeof(*sys_para), u.s.scaling_min_freq)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.u.userspace) != - offsetof(typeof(*sys_para), u.s.u.userspace)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.s.u.ondemand) != - offsetof(typeof(*sys_para), u.s.u.ondemand)); - BUILD_BUG_ON(offsetof(typeof(*user_para), u.cppc_para) != - offsetof(typeof(*sys_para), u.cppc_para)); - BUILD_BUG_ON(offsetof(typeof(*user_para), turbo_enabled) != - offsetof(typeof(*sys_para), turbo_enabled)); - ret = xc_sysctl(xch, &sysctl); if ( ret ) { @@ -316,6 +277,22 @@ int xc_get_cpufreq_para(xc_interface *xc BUILD_BUG_ON(sizeof(((struct xc_get_cpufreq_para *)0)->u) != sizeof(((struct xen_get_cpufreq_para *)0)->u)); + /* Sanity check layout of the union subject to memcpy() below. */ + BUILD_BUG_ON(sizeof(user_para->u) != sizeof(sys_para->u)); +#define CHK_FIELD(fld) \ + BUILD_BUG_ON(offsetof(typeof(user_para->u), fld) != \ + offsetof(typeof(sys_para->u), fld)) + + CHK_FIELD(s.scaling_cur_freq); + CHK_FIELD(s.scaling_governor); + CHK_FIELD(s.scaling_max_freq); + CHK_FIELD(s.scaling_min_freq); + CHK_FIELD(s.u.userspace); + CHK_FIELD(s.u.ondemand); + CHK_FIELD(cppc_para); + +#undef CHK_FIELD + memcpy(&user_para->u, &sys_para->u, sizeof(sys_para->u)); }