From patchwork Mon Mar 25 20:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13602926 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 4F1EAC54E58 for ; Mon, 25 Mar 2024 20:45:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.697877.1089090 (Exim 4.92) (envelope-from ) id 1rorCD-0007OS-TS; Mon, 25 Mar 2024 20:45:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 697877.1089090; Mon, 25 Mar 2024 20:45:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rorCD-0007Nz-Mk; Mon, 25 Mar 2024 20:45:29 +0000 Received: by outflank-mailman (input) for mailman id 697877; Mon, 25 Mar 2024 20:45:28 +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 1rorCC-0007L7-Lw for xen-devel@lists.xenproject.org; Mon, 25 Mar 2024 20:45:28 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20601.outbound.protection.outlook.com [2a01:111:f403:2409::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 99b24552-eae8-11ee-afe3-a90da7624cb6; Mon, 25 Mar 2024 21:45:26 +0100 (CET) Received: from BL1PR13CA0185.namprd13.prod.outlook.com (2603:10b6:208:2be::10) by SA1PR12MB6702.namprd12.prod.outlook.com (2603:10b6:806:252::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Mon, 25 Mar 2024 20:45:20 +0000 Received: from BL02EPF0001A104.namprd05.prod.outlook.com (2603:10b6:208:2be:cafe::41) by BL1PR13CA0185.outlook.office365.com (2603:10b6:208:2be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.12 via Frontend Transport; Mon, 25 Mar 2024 20:45:20 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF0001A104.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 20:45:20 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:19 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 25 Mar 2024 15:45:19 -0500 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: 99b24552-eae8-11ee-afe3-a90da7624cb6 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RPQNL2DC5zxCju1KPPFw8cxGFVWlYUeb5aTIvhP2fWxK+t0bXwMvoOpsTNGvR+DrXcL7XRRDUT7qSMsV4JQta4yMLnuqrHJtgj+ob1JdZz4/bwyc0Myy6H+EntYA2YVYxXf+1FwL2U6shZlvHcQkvLoskKSK6DyEuCDdYhjlluGJL2kqqEXnwD/41isPfOT3ZTDCIUenHSkblaZEAjoFlxx2yhCagQ01ji2meI4XF2YVO8jG0R2wHJ2n1xewxn8Nfz9CoJoaiTHS7TH5x+Gq5wBslWBfN7VI0KIysRdhVlQfbpupF7vQT/QFOA4b8psJiSgY4CnbSilZCt1G0xJ97g== 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=lvOehq1EJKjZfWXBSzZg1ZZ1p5IUUk1AykmRfeyalZA=; b=hzdirreQkDkZYY+CWHIa3D0nvuZLqA00CviNj+SkLTqXcqI0kQEwoF72686F6ENpwNafW7VkCNqliwZg5nAz2iC6VX45pTy6O3mqI4HEDEc7Z9EFYx12C1qkbux3z5iwAIpgZZ+qhHwRBCTxticLwP8BsooUQWvzxnrS41OVsrIs3BjOxZQGt1U9oG+Q3pZ/V2xbQL7jR/R5uIZBDD3qGHwOQ1QJQu6qVeVQsni1SZcGEPXEvnKwyIPbjCXzSeydhMKMeYsJt/mPyktHWtw34LNO3pmnFy7OfzdX/a/aAQlyzt+vs8NR0oA2BbWPNWBthjofBnfLANtqvJrmzQPowQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lvOehq1EJKjZfWXBSzZg1ZZ1p5IUUk1AykmRfeyalZA=; b=HectG3N0H33WZo8H4mwBJ2m7nABhWdL53zg7oCVmN0pe/wh+0ayK4goy1sPl6uuF5XhGjoQrijINi2vmfBAEJkc2snlrT68sET19kcLwCDMlIhKt9pkIC6To0FaNo+7hWtGhWx6KRtRtKGalng+HVsNtmB8Az3teoH1pPDGVixM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Jason Andryuk To: CC: Jason Andryuk , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v4 1/5] Revert "xen/x86: bzImage parse kernel_alignment" Date: Mon, 25 Mar 2024 16:45:11 -0400 Message-ID: <20240325204515.250203-2-jason.andryuk@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204515.250203-1-jason.andryuk@amd.com> References: <20240325204515.250203-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A104:EE_|SA1PR12MB6702:EE_ X-MS-Office365-Filtering-Correlation-Id: ec3560fb-a2b7-4468-bfc7-08dc4d0c7c78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tiir/iKRdDYx8IkrWcWOmvWqx9tJgv4x5IVTdIwcIQfEesk0fMeULuCisMpWf6/1qbbTzn/XttJbmOh04L+gnVtKjolvpQvzc3XW0c69A5maED2soxCrIgXjTgJtkIeeijMyEZ0xg69LoV1SGFUDsAQ3D/V4kqMr098sp3jzS/XEEkvHfZxFEocwRO3lyEaKy9Mi11w9/BJfJ3wwBFYiqXNa3b3ygbjsODuVC2CWNTLU7A3Spmb+SpyiPrV9xhtQUn8etVS4sNqXTlhlfrUvSkKN6B7V20OJpBP8pDPSb4OGTY7Hj58gjefLlRfB4v5tI/ik+cEp//WVjobzXGnqoVQ2INN+RiJk2u8BGdQb759xB6gMGJvHSlhfoBffF+kwEBSYSa04sR/U5TgbBZf6DPLO4Y7kOXL7YDRMdizW3Jo/IlWSWcsmQRnzrs76wEG9C41vLrLN639nc1Cvtus1SWz52ntqIOYYpDYqO0CkcczvUu/Y64g7Su+3SASUfwvlKDTQALSc8qEefav/dH2ZbEygakbD/iBZca2iJaN5LMbeH8vg0rstqXf1tILN+GIh52KCTu13IGKKWH7vIgdZjAeHUwZSiPF4qNV/klwfJeE03LvMfEw6fDzI3t7OJ4vr6NxKYRisC5Sb+rEAIn2jl33AHI7rKxnHLWawMIovCC2PMeFbjITQ/s4hn9uFxWIAEbZZsJtgSQ0S1DZ/HVvGBRs0yDLZK+Dt+GwIA1eYcbl1m6mXUhQeRyMXdqcPvZGN X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(36860700004)(376005)(82310400014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 20:45:20.2533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec3560fb-a2b7-4468-bfc7-08dc4d0c7c78 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A104.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6702 A new ELF note will specify the alignment for a relocatable PVH kernel. ELF notes are suitable for vmlinux and other ELF files, so this Linux-specific bzImage parsing in unnecessary. This reverts commit c44cac229067faeec8f49247d1cf281723ac2d40. Signed-off-by: Jason Andryuk --- xen/arch/x86/bzimage.c | 4 +--- xen/arch/x86/hvm/dom0_build.c | 4 +--- xen/arch/x86/include/asm/bzimage.h | 2 +- xen/arch/x86/pv/dom0_build.c | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/bzimage.c b/xen/arch/x86/bzimage.c index 0f4cfc49f7..ac4fd428be 100644 --- a/xen/arch/x86/bzimage.c +++ b/xen/arch/x86/bzimage.c @@ -105,7 +105,7 @@ unsigned long __init bzimage_headroom(void *image_start, } int __init bzimage_parse(void *image_base, void **image_start, - unsigned long *image_len, unsigned int *align) + unsigned long *image_len) { struct setup_header *hdr = (struct setup_header *)(*image_start); int err = bzimage_check(hdr, *image_len); @@ -118,8 +118,6 @@ int __init bzimage_parse(void *image_base, void **image_start, { *image_start += (hdr->setup_sects + 1) * 512 + hdr->payload_offset; *image_len = hdr->payload_length; - if ( align ) - *align = hdr->kernel_alignment; } if ( elf_is_elfbinary(*image_start, *image_len) ) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index bbae8a5645..0ceda4140b 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -548,14 +548,12 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; - unsigned int align = 0; struct hvm_start_info start_info = { 0 }; struct hvm_modlist_entry mod = { 0 }; struct vcpu *v = d->vcpu[0]; int rc; - rc = bzimage_parse(image_base, &image_start, &image_len, &align); - if ( rc != 0 ) + if ( (rc = bzimage_parse(image_base, &image_start, &image_len)) != 0 ) { printk("Error trying to detect bz compressed kernel\n"); return rc; diff --git a/xen/arch/x86/include/asm/bzimage.h b/xen/arch/x86/include/asm/bzimage.h index 2e04f5cc7b..7ed69d3910 100644 --- a/xen/arch/x86/include/asm/bzimage.h +++ b/xen/arch/x86/include/asm/bzimage.h @@ -6,6 +6,6 @@ unsigned long bzimage_headroom(void *image_start, unsigned long image_length); int bzimage_parse(void *image_base, void **image_start, - unsigned long *image_len, unsigned int *align); + unsigned long *image_len); #endif /* __X86_BZIMAGE_H__ */ diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index e9fa8a9a82..d8043fa58a 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -416,7 +416,7 @@ int __init dom0_construct_pv(struct domain *d, d->max_pages = ~0U; - if ( (rc = bzimage_parse(image_base, &image_start, &image_len, NULL)) != 0 ) + if ( (rc = bzimage_parse(image_base, &image_start, &image_len)) != 0 ) return rc; if ( (rc = elf_init(&elf, image_start, image_len)) != 0 ) From patchwork Mon Mar 25 20:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13602928 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 AFEC1CD11DB for ; Mon, 25 Mar 2024 20:45:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.697880.1089124 (Exim 4.92) (envelope-from ) id 1rorCG-0008HI-NL; Mon, 25 Mar 2024 20:45:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 697880.1089124; Mon, 25 Mar 2024 20:45:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rorCG-0008H5-K0; Mon, 25 Mar 2024 20:45:32 +0000 Received: by outflank-mailman (input) for mailman id 697880; Mon, 25 Mar 2024 20:45:31 +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 1rorCE-0007LI-V2 for xen-devel@lists.xenproject.org; Mon, 25 Mar 2024 20:45:30 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20601.outbound.protection.outlook.com [2a01:111:f403:2405::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9cb74f27-eae8-11ee-a1ef-f123f15fe8a2; Mon, 25 Mar 2024 21:45:27 +0100 (CET) Received: from MW4PR03CA0341.namprd03.prod.outlook.com (2603:10b6:303:dc::16) by SN7PR12MB7201.namprd12.prod.outlook.com (2603:10b6:806:2a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 20:45:23 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:303:dc:cafe::19) by MW4PR03CA0341.outlook.office365.com (2603:10b6:303:dc::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 20:45:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 20:45:22 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:21 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 25 Mar 2024 15:45:20 -0500 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: 9cb74f27-eae8-11ee-a1ef-f123f15fe8a2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h8c9LXgrQixHW3dAYWgw/rqZ7cHqAt8cAdh31W2RurJpVS+qFY/D9EhCZbBfCBXaLgGBXdzBKanf2I8KQU8VzAM5foVb3RcZzUOrBLyqVk3EQzx8TNGKCZezzfSLIDvdVwuTu0Y2XHZ5cf1zN/TaLgS/9oc/tZmY9iiRUH2Nz0xLch1iLumBVqkNBT9QoLYkNzSMJgofYYuPdP1p5sIz49dAEYqmp++s2OZhrbG12hqbsLKlnyr1w8dDc1ITx2J5G6mqaZojpGnwwR2GDM1sTckA2+XabLSB28NY3znfb4HFLfKPPVonKXvmoytoEFlTlgAbAegcwGZIkpxnus6LqQ== 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=kpYFdzJHkuO60SpR1aTtd436m2Cbip6KFJuG8vrlzio=; b=jADnyZeSgMJbTcIXMPTsMtEgjC4VggM4IvtHgeH+4aZjpOrmL9zp9rcrOQ++TioYMv3kwhRspU61W1z9Smh9ClttRw4PBUChEev6ikwJOVGdfXjmiEa070GxnP9vKrX1ZDbN5yeDuT/KW+gpVildZ1jS5+3CTJH15JUBvWtG5z6E9Hg27mMOcwf4Vq+Y1Kpdb4rzTLbUL+L+cCy9BPsJJryN2i2UsO11EuMHnhTAX9fmSdPc10WcuAlFh6tHj3qoTdUW5EqZ281f4EGNSkBiQcVo3AptMJmJt8a8zEl8i9y7aGMniFndrepEXqpJUtxy8lUzdtM82oc19tyqLrkUHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kpYFdzJHkuO60SpR1aTtd436m2Cbip6KFJuG8vrlzio=; b=wqUjck3XdPfpxL13G3wWkzd84346G+3E9HojdQDIJjmxlNfD+NknuXUeaA6kq5wRR7qGs09vfkYtLvfXLwapSa+gmnqAFnefBiGoVi4GQeyLSwt+ivDo3xJvo/4LaV89UdZopfmq5wCkkFxv7pd0GDtarPTRHK3QmVK/jyMiCXQ= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Jason Andryuk To: CC: Jason Andryuk , Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH v4 2/5] tools/init-xenstore-domain: Replace variable MB() usage Date: Mon, 25 Mar 2024 16:45:12 -0400 Message-ID: <20240325204515.250203-3-jason.andryuk@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204515.250203-1-jason.andryuk@amd.com> References: <20240325204515.250203-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|SN7PR12MB7201:EE_ X-MS-Office365-Filtering-Correlation-Id: b6343f0d-23c3-4c4b-c6c6-08dc4d0c7dfa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fdqdb6bVXcZsQl/xfkuIAW+XN6JEY3SlFK8Lbs7nuXVmjC2L6rGQSz4u0SV4UrrAZV0ChRx44KXn0nh+0IA+8EN3QuEHDQqON6rsk5Hu3//hIRkWHYzlD7tccIQEcYETu5ruNSx751sjTsUp74ht1X4Hp6ws2g3N2gHdIM2lLq1hNJ/6mifBuqoCS5+NA3HQshKlJnktUtpevGVJEiWgWB7Gq562I1Q85jRgpVJxgG2XhjUf0qApuqDRf+X9W6UdebJgNumZ9O4i7A1ZhhLtgsm7PhDrEEIFOWJRcTE3nudFWI1nZxd4p7CZBtvQ3y0Fq2S02xILUF410ByU+CEVT7Jzg1UgaA78e2cb9F1UKTIhCJ9bx/BJBV7PZmmisz9DzdjfA30PLdeqanrC3ybAlKIg2LmKb0ARfPYCJsYQZ7zftMqLDw9vNWE/GcH4VAKKBRK+kkjJ/DlT+FW0YPXto9HmMcnio+uVYzc8DmAJUoYzkjRJnYtVZa84EqIakM6UD/HHggUro8mu+JTD+Sea0ACm1gDvcT4LsaSfNU5Gu7M8DHHiQjaskUyUrJ4gjUaSZzaZOa/2a85rYLU+xaSHaMDM1TFTND/bfve2pYe7bapkWvvPiV6pvevSPqpT+qeSLIKHN/4xeN/vAtf+p9TLrot+koj7v9DuEUwMmpevMtaRX7YgBSscS8XUY9LMiOTrOLlsbzj+4aHoAWCyq49fVP18K4BNoF1boXc8r9mwToQpu6tZNmaz+7TgQR5pH3/b X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 20:45:22.6582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6343f0d-23c3-4c4b-c6c6-08dc4d0c7dfa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7201 The local MB() & GB() macros will be replaced with a common implementation, but those only work with constant values. Introduce a static inline mb_to_bytes() in place of the MB() macro to convert the variable values. Signed-off-by: Jason Andryuk Reviewed-by: Anthony PERARD --- v4: New --- tools/helpers/init-xenstore-domain.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 1683438c5c..5405842dfe 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -20,7 +20,6 @@ #include "init-dom-json.h" #define LAPIC_BASE_ADDRESS 0xfee00000UL -#define MB(x) ((uint64_t)x << 20) #define GB(x) ((uint64_t)x << 30) static uint32_t domid = ~0; @@ -36,6 +35,11 @@ static xc_evtchn_port_or_error_t console_evtchn; static xentoollog_level minmsglevel = XTL_PROGRESS; static void *logger; +static inline uint64_t mb_to_bytes(int mem) +{ + return (uint64_t)mem << 20; +} + static struct option options[] = { { "kernel", 1, NULL, 'k' }, { "memory", 1, NULL, 'm' }, @@ -76,8 +80,8 @@ static int build(xc_interface *xch) int rv, xs_fd; struct xc_dom_image *dom = NULL; int limit_kb = (maxmem ? : memory) * 1024 + X86_HVM_NR_SPECIAL_PAGES * 4; - uint64_t mem_size = MB(memory); - uint64_t max_size = MB(maxmem ? : memory); + uint64_t mem_size = mb_to_bytes(memory); + uint64_t max_size = mb_to_bytes(maxmem ? : memory); struct e820entry e820[3]; struct xen_domctl_createdomain config = { .ssidref = SECINITSID_DOMU, From patchwork Mon Mar 25 20:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13602929 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 D1177CD11DC for ; Mon, 25 Mar 2024 20:45:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.697878.1089104 (Exim 4.92) (envelope-from ) id 1rorCF-0007nw-3e; Mon, 25 Mar 2024 20:45:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 697878.1089104; Mon, 25 Mar 2024 20:45: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 1rorCE-0007nl-Va; Mon, 25 Mar 2024 20:45:30 +0000 Received: by outflank-mailman (input) for mailman id 697878; Mon, 25 Mar 2024 20:45:29 +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 1rorCD-0007L7-LC for xen-devel@lists.xenproject.org; Mon, 25 Mar 2024 20:45:29 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20600.outbound.protection.outlook.com [2a01:111:f403:200a::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c3767aa-eae8-11ee-afe3-a90da7624cb6; Mon, 25 Mar 2024 21:45:28 +0100 (CET) Received: from MW4PR03CA0360.namprd03.prod.outlook.com (2603:10b6:303:dc::35) by IA1PR12MB6163.namprd12.prod.outlook.com (2603:10b6:208:3e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 20:45:24 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:303:dc:cafe::e4) by MW4PR03CA0360.outlook.office365.com (2603:10b6:303:dc::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Mon, 25 Mar 2024 20:45:24 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 20:45:24 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:23 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 25 Mar 2024 15:45:22 -0500 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: 9c3767aa-eae8-11ee-afe3-a90da7624cb6 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SBBBzBlv2j3OYjZ8COtt3j43bwf03MgZCe9Z5R3DdlJxPNIDIUPgPTcBtKK/6TSAZTNqjlNyLdncsLa++3N6RwGOKiuSSPL6wcJLNzs7K2sbgVbUaFmT8UhOJTI7Slk+Jy9ZEysENsmeWI0p7PHZMMNxFUevaUwdYrXCYyddzdpS1QM4Ix5/C8p2doGAyYrOMfpCs+XzGSvatwOiyBq1DcxyWizEiVQvsbKAR7lyOCfD+YsogFdik/XTHjWPABZ3fHE+xUFbqvupiNaZtqbgkgZdOIevgmV+LUOkZTBJqddWOg4W8jd4tL3Nh8AxxPmpgXJsrCnB4FMzI3f6HaVzgw== 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=NWxzGLWg8rpT9SvmC6RSHVGPVmiDtkENizt4I3Gzge8=; b=BRrWN3d2bhmCNUeq6Auyi5EtjV3WNGOP0suuivF/vwpfBrKL9k2wXeRUOggoRgPnAKG4qwKMc+f2nvlMtH6O5LuBxQXsJ4hZFFqOmav85JHNrVEQPLLjQG7E/rj5gkaq45JRVc+g0aDeZD23z/gfJp9WBty8I2HyR3iufwUu2ifRxzOknLyOEVtgN0H2TipUwFh5Colq6I8a0Mw7LKzMsy8W9TmGfJgY54kNknoCAc7uPxdQttL5kD8YOViYryhT/98vA6midR5t3GlyOBsH8Im6EYm4NYiHpvtadZJNZnukPhC9vsjlvDxPad8XMZ+Dvcm9Yq98hwG8fR/fPlYHsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NWxzGLWg8rpT9SvmC6RSHVGPVmiDtkENizt4I3Gzge8=; b=ghuyiCh0uS3ZdksSvCLq3U+CVORRt5T6EEHxHFub3UflXzXTjmqWWhRqSkqjaRhR5ARgzV3n+JFTxV1cV5VN2OI25bCmjJKRiE1Vfd4LNPRc//GeBQ+0Iur1inxk4bSrtQG/Ix+fqRz5Sq+Ndpm4nBdMf7UobELuQKghmgFVkBo= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Jason Andryuk To: CC: Jason Andryuk , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , Juergen Gross , Julien Grall Subject: [PATCH v4 3/5] tools: Move MB/GB() to common-macros.h Date: Mon, 25 Mar 2024 16:45:13 -0400 Message-ID: <20240325204515.250203-4-jason.andryuk@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204515.250203-1-jason.andryuk@amd.com> References: <20240325204515.250203-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|IA1PR12MB6163:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f85f710-2bbe-4cdc-59ae-08dc4d0c7ef0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yHULqzfyCbHZTqZTGlLgk3UeRaHEfqfRAnBAwyi59qApHIvz6+5iVoMT7UQI/Hbgb5MTBAEnCoB/EhT9xd7bv8of0RzEwloyXuESu8lI2n02ZjFF59lTdHmq4u/z543sBynLGNfJg6TqeOTW+HG36BOjrmuIlRMcggepLIGiktI5Pg58FNcHJXVXhWqiMc/ECQdR3dFNuPbwA4SumDPFoZXPoS7Pvq0500o85l7k8k3MO9kZEAoklNWRLePDo0VSVB4wvgcayygNflR5vGzKq7Afq1KsdhpSSEelJUPjZrtl3BvToZOU+3fqV8Alq/eI3gNJ4Pep9pf7DYsuNOHbT8TGYO2qOa62oqCjezSZnpWZ6TkI8omxtYQo1c3MUPKC2sqS6aqlh29l6DgHdlLPlrbcYkh9HgY+oICdRvmeQHOdODvLt/0aW9cJEa7LDMcmEMkQoKEB1jfRwLzkCq+ojD0obw/kI49pYDNOZEp4rbzYPtUFMtfsWotjpOrtrbVvYBAkYxPiJqT2ZegYP17fOmMyN+whR+wiKDmVI+9CWKLitfdStb6UtRJTS7Z1rMA9qwTkawnqw0rrocbWx5TT29DUUWm9FM5sl5JC606Clc351TmrMpuO5taM9xDLi/n/dGVN6Vo1I7N/TIQ5NoO+ZU6BsU3psjHd1FHgYWCzFzeleVf6kMdkBXNDcKHMZnLUUpYc105JEW+RlzAq6o794owjs/V4Mc5WO60OjKivwVPkITEpcWqu4doVT96R9VQH X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 20:45:24.2676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f85f710-2bbe-4cdc-59ae-08dc4d0c7ef0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6163 Consolidate to a single set of common macros for tools. MB() will gain another use in libelf, so this movement makes it available. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v4: New --- tools/firmware/hvmloader/util.h | 3 --- tools/helpers/init-xenstore-domain.c | 1 - tools/include/xen-tools/common-macros.h | 4 ++++ tools/libs/light/libxl_internal.h | 4 ---- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 87be213dec..14078bde1e 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -38,9 +38,6 @@ void __bug(const char *file, int line) __attribute__((noreturn)); #define BUG() __bug(__FILE__, __LINE__) #define BUG_ON(p) do { if (p) BUG(); } while (0) -#define MB(mb) (mb##ULL << 20) -#define GB(gb) (gb##ULL << 30) - static inline int test_bit(unsigned int b, const void *p) { return !!(((const uint8_t *)p)[b>>3] & (1u<<(b&7))); diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 5405842dfe..f38ba8d6b5 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -20,7 +20,6 @@ #include "init-dom-json.h" #define LAPIC_BASE_ADDRESS 0xfee00000UL -#define GB(x) ((uint64_t)x << 30) static uint32_t domid = ~0; static char *kernel; diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-tools/common-macros.h index 81fba2e9f5..07aed92684 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -91,6 +91,10 @@ #define __AC(X, Y) (X ## Y) #define _AC(X, Y) __AC(X, Y) +/* Size macros. */ +#define MB(_mb) (_AC(_mb, ULL) << 20) +#define GB(_gb) (_AC(_gb, ULL) << 30) + #define get_unaligned_t(type, ptr) ({ \ const struct { type x; } __packed *ptr_ = (typeof(ptr_))(ptr); \ ptr_->x; \ diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_internal.h index 094d0df9b1..803dbc1a03 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -126,10 +126,6 @@ #define PVSHIM_BASENAME "xen-shim" #define PVSHIM_CMDLINE "pv-shim console=xen,pv" -/* Size macros. */ -#define MB(_mb) (_AC(_mb, ULL) << 20) -#define GB(_gb) (_AC(_gb, ULL) << 30) - #define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d)) #define LIBXL__LOGGING_ENABLED From patchwork Mon Mar 25 20:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13602931 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 9ACBDCD1280 for ; Mon, 25 Mar 2024 20:45:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.697879.1089109 (Exim 4.92) (envelope-from ) id 1rorCF-0007rW-Eq; Mon, 25 Mar 2024 20:45:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 697879.1089109; Mon, 25 Mar 2024 20:45: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 1rorCF-0007rA-9O; Mon, 25 Mar 2024 20:45:31 +0000 Received: by outflank-mailman (input) for mailman id 697879; Mon, 25 Mar 2024 20:45:30 +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 1rorCE-0007L7-LC for xen-devel@lists.xenproject.org; Mon, 25 Mar 2024 20:45:30 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20600.outbound.protection.outlook.com [2a01:111:f403:2408::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9cab45cf-eae8-11ee-afe3-a90da7624cb6; Mon, 25 Mar 2024 21:45:28 +0100 (CET) Received: from BL1PR13CA0138.namprd13.prod.outlook.com (2603:10b6:208:2bb::23) by LV3PR12MB9234.namprd12.prod.outlook.com (2603:10b6:408:1a0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Mon, 25 Mar 2024 20:45:26 +0000 Received: from BL02EPF0001A102.namprd05.prod.outlook.com (2603:10b6:208:2bb:cafe::c0) by BL1PR13CA0138.outlook.office365.com (2603:10b6:208:2bb::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.12 via Frontend Transport; Mon, 25 Mar 2024 20:45:26 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF0001A102.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 20:45:25 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:24 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 25 Mar 2024 15:45:24 -0500 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: 9cab45cf-eae8-11ee-afe3-a90da7624cb6 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YW42aADAmMPGR9Pgh+6NlXpd9cbDaA85hex+5vgSzKweK9BCz1eTsuXosmSAvJrrYwP1Zq8XO2IK23QNYE4lmWOyK7mePeeAHFeof0Fw6FmuMJKWq8P42tZ3OHJX+Qmbe3NOAm7zdDndHXD3431AIhcuZyJph13jFcXz8aTkllm7ekPZ7tn83ZjWiGmA1jvJy39DN0OEA1zAqf9DmmKvQG0NlAINrY0NdQQW/yLSMAY4nNu3MHbZ7Nwg20iE5MzYRqdXqXJeOdrXD3qTnLiW+7KGSB5fI2Dg4B8NIL2AYlQmRpIo+MSKH3iv5nO4MI81Ul7gVKy+1YCUcZtMhs0x5w== 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=ePBeoHAZ89v7gvk2hxDlL5ktUBtUjVi0i6hIkMIc1ds=; b=QbLf5G0PUPeOiVT1J2cPAVppwzzd5tvUgfXEtvydoKiOh3UZZWcfU5Qp6K8IFBNSePVHAH8GyKVOMsyD+2+UolHP/JFMIzTHa8v7yKSWwLcezabmeIKV9OsHPWl18NP+P59mbhHoEJ6Bf859se14hrr/3W8nHIXWUaKgkUTXDd/OmioBv+Oo4ce8SbVpn9N/mT6PpvZQyzNJD9GpSsec40VNJCBi8n/jNYJCpBxnvLuUcJw4HP4oi9jIGRUDvBBVSakKWIVLow0aKnlIzyY5Jf+uFva6n8eT+u4tyydZhuv+VP4c6HTBaIZNfnkNkiYf96sE1Dc+9NDAb+NVQ99JBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ePBeoHAZ89v7gvk2hxDlL5ktUBtUjVi0i6hIkMIc1ds=; b=5O4lp8aseLPPRGcci8B3nEEhF4JCRp7wPezA5Og/K+H+PyEQx+e9nnztU6JdSZo9jClhC04cvRYPNYt5fVB2JOQFoQYOux7Qoai+OT3F58lURXlb+cH21znZD8KqT7BnmYm+acFp7TTcFPYhFBPCkiSJTIDYUYfwN9E69CFlLxs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Jason Andryuk To: CC: Jason Andryuk , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" Subject: [PATCH v4 4/5] libelf: Expand ELF note printing Date: Mon, 25 Mar 2024 16:45:14 -0400 Message-ID: <20240325204515.250203-5-jason.andryuk@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204515.250203-1-jason.andryuk@amd.com> References: <20240325204515.250203-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A102:EE_|LV3PR12MB9234:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ba94830-f9ca-4a6a-3df1-08dc4d0c7fa9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f5BqoaUWWbLZO3K2yNThcgZZ/IENu0PLQ6N8rz3FkhjaGMcOXXp6eIryWbLRe5EVXKik/VeYaAgiErVukDpOSOeDfV9uJCTGzNYEUrR6J2D1puHsgzoiusmJmQ5Y+78/O5HpoFKhVlHg69uhCdYVDEuO9wMGNZx27r8yCUQKcklOM5qMO8U4EAPhYMS8oXVfPFFm1ZoKr3UroSXKiTwTSKjKWd0i4zclJ5BG2M5zwYCIVasNOIeRIE8hD8zmsJKhclZxEmvI0d7VmlyX2GTdu6lLxZbwdzAtD2mlEoLQUS7MBlCfwRFWW4qiTftD2/J9yumyUrANspuqcjI9XuV+MgovYvj0D0HXXoj52+ewiq8JsG2djv60sPXN3LTN6LE9fYh6DJaw0mVCqY2Jf+ojgGuL3IPGptH9L0yvpxzVVh+1kjJs5LPKWeuec0GnzvmdWz2k61U53/rzQHf8uOchf0zR6i3AJLtoR3L+51GtIGh2V2eUymp+ks4T7xKaLi6xSK5KQJiJu/XYAsgTEzLMJS9ftdwV7hEYnR+E8SwQDGvLdFFLkLwkFJAI+WeKLE+99qIq34dZZvhqnuV++qSlvmnoua7Cy13niPAixe5KE58P7Wc8m3SRXTTAfQujxV00D240CK9SqyDwOfeEagPWbhOJ/k6AKXejeslorZWEwHPkktCzSjkTNQmbjuiLZizA1ALuATPncsu1+As7qUG7Nc3E2niTrL6lIt4XkzV9qwirE4LD9ePhCeNZtkHjRjDW X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 20:45:25.6043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ba94830-f9ca-4a6a-3df1-08dc4d0c7fa9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A102.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9234 The XEN_ELFNOTE_L1_MFN_VALID is an array of pairs of values, but it is printed as: (XEN) ELF: note: L1_MFN_VALID = 0 This is a limitation of only printing either string or numeric values. Switch from the boolean to an enum which allows more flexibility in printing the values. Introduce ELFNOTE_NAME to only print the name without a value like: (XEN) ELF: note: L1_MFN_VALID Details can optionally be printed for specific notes. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v3: Remove fatal size check Don't print values - just the name for presence v4: Use switch Always print newline for ELFNOTE_NAME --- xen/common/libelf/libelf-dominfo.c | 60 ++++++++++++++++++------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c index a13a5e4db6..e7b44d238b 100644 --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -101,26 +101,30 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, /* *INDENT-OFF* */ static const struct { const char *name; - bool str; + enum { + ELFNOTE_INT, + ELFNOTE_STRING, + ELFNOTE_NAME, + } type; } note_desc[] = { - [XEN_ELFNOTE_ENTRY] = { "ENTRY", 0}, - [XEN_ELFNOTE_HYPERCALL_PAGE] = { "HYPERCALL_PAGE", 0}, - [XEN_ELFNOTE_VIRT_BASE] = { "VIRT_BASE", 0}, - [XEN_ELFNOTE_INIT_P2M] = { "INIT_P2M", 0}, - [XEN_ELFNOTE_PADDR_OFFSET] = { "PADDR_OFFSET", 0}, - [XEN_ELFNOTE_HV_START_LOW] = { "HV_START_LOW", 0}, - [XEN_ELFNOTE_XEN_VERSION] = { "XEN_VERSION", 1}, - [XEN_ELFNOTE_GUEST_OS] = { "GUEST_OS", 1}, - [XEN_ELFNOTE_GUEST_VERSION] = { "GUEST_VERSION", 1}, - [XEN_ELFNOTE_LOADER] = { "LOADER", 1}, - [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1}, - [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1}, - [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", 0}, - [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1}, - [XEN_ELFNOTE_L1_MFN_VALID] = { "L1_MFN_VALID", false }, - [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", 0 }, - [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", 0 }, - [XEN_ELFNOTE_PHYS32_ENTRY] = { "PHYS32_ENTRY", 0 }, + [XEN_ELFNOTE_ENTRY] = { "ENTRY", ELFNOTE_INT }, + [XEN_ELFNOTE_HYPERCALL_PAGE] = { "HYPERCALL_PAGE", ELFNOTE_INT }, + [XEN_ELFNOTE_VIRT_BASE] = { "VIRT_BASE", ELFNOTE_INT }, + [XEN_ELFNOTE_INIT_P2M] = { "INIT_P2M", ELFNOTE_INT }, + [XEN_ELFNOTE_PADDR_OFFSET] = { "PADDR_OFFSET", ELFNOTE_INT }, + [XEN_ELFNOTE_HV_START_LOW] = { "HV_START_LOW", ELFNOTE_INT }, + [XEN_ELFNOTE_XEN_VERSION] = { "XEN_VERSION", ELFNOTE_STRING }, + [XEN_ELFNOTE_GUEST_OS] = { "GUEST_OS", ELFNOTE_STRING }, + [XEN_ELFNOTE_GUEST_VERSION] = { "GUEST_VERSION", ELFNOTE_STRING }, + [XEN_ELFNOTE_LOADER] = { "LOADER", ELFNOTE_STRING }, + [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", ELFNOTE_STRING }, + [XEN_ELFNOTE_FEATURES] = { "FEATURES", ELFNOTE_STRING }, + [XEN_ELFNOTE_SUPPORTED_FEATURES] = { "SUPPORTED_FEATURES", ELFNOTE_INT }, + [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", ELFNOTE_STRING }, + [XEN_ELFNOTE_L1_MFN_VALID] = { "L1_MFN_VALID", ELFNOTE_NAME }, + [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", ELFNOTE_INT }, + [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", ELFNOTE_INT }, + [XEN_ELFNOTE_PHYS32_ENTRY] = { "PHYS32_ENTRY", ELFNOTE_INT }, }; /* *INDENT-ON* */ @@ -136,8 +140,9 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, return 0; } - if ( note_desc[type].str ) + switch ( note_desc[type].type ) { + case ELFNOTE_STRING : str = elf_strval(elf, elf_note_desc(elf, note)); if (str == NULL) /* elf_strval will mark elf broken if it fails so no need to log */ @@ -145,13 +150,18 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, elf_msg(elf, "ELF: note: %s = \"%s\"\n", note_desc[type].name, str); parms->elf_notes[type].type = XEN_ENT_STR; parms->elf_notes[type].data.str = str; - } - else - { + break; + + case ELFNOTE_INT: val = elf_note_numeric(elf, note); elf_msg(elf, "ELF: note: %s = %#" PRIx64 "\n", note_desc[type].name, val); parms->elf_notes[type].type = XEN_ENT_LONG; parms->elf_notes[type].data.num = val; + break; + + case ELFNOTE_NAME: + elf_msg(elf, "ELF: note: %s", note_desc[type].name); + break; } parms->elf_notes[type].name = note_desc[type].name; @@ -218,6 +228,10 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, parms->phys_entry = val; break; } + + if ( note_desc[type].type == ELFNOTE_NAME) + elf_msg(elf, "\n"); + return 0; } From patchwork Mon Mar 25 20:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13602927 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 7DCCEC54E64 for ; Mon, 25 Mar 2024 20:45:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.697881.1089134 (Exim 4.92) (envelope-from ) id 1rorCJ-00008C-1O; Mon, 25 Mar 2024 20:45:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 697881.1089134; Mon, 25 Mar 2024 20:45:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rorCI-00007u-U9; Mon, 25 Mar 2024 20:45:34 +0000 Received: by outflank-mailman (input) for mailman id 697881; Mon, 25 Mar 2024 20:45: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 1rorCH-0007LI-3l for xen-devel@lists.xenproject.org; Mon, 25 Mar 2024 20:45:33 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20601.outbound.protection.outlook.com [2a01:111:f403:2408::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9e7e685b-eae8-11ee-a1ef-f123f15fe8a2; Mon, 25 Mar 2024 21:45:31 +0100 (CET) Received: from BL1PR13CA0146.namprd13.prod.outlook.com (2603:10b6:208:2bb::31) by DS0PR12MB8072.namprd12.prod.outlook.com (2603:10b6:8:dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 20:45:27 +0000 Received: from BL02EPF0001A102.namprd05.prod.outlook.com (2603:10b6:208:2bb:cafe::b) by BL1PR13CA0146.outlook.office365.com (2603:10b6:208:2bb::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.12 via Frontend Transport; Mon, 25 Mar 2024 20:45:27 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF0001A102.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Mon, 25 Mar 2024 20:45:27 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:26 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Mar 2024 15:45:27 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 25 Mar 2024 15:45:26 -0500 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: 9e7e685b-eae8-11ee-a1ef-f123f15fe8a2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBGv2hcspRiQHthjVTJTgY1Zo38ZLY70+o5naEC3vguv2fi6CQ+ME7sm1NXMmCxjoXzevypECaD2/5AUh30UNw4JUnkoWwBiKywssBoyBobIakMEWgwWX3Uw76zFEjIR7OUY6p69SzO9Cpf7QgLkQpXO3+4ZwE12tpfoIDPC7uX1HBL5oJlfVPmWhHbpYNjIbR39KriS69Z67uGzKm0k4ckPw1MR7KqJIDIY8gpHjx2bpz2Dl6gu9MbL4uDnSTLJZcBGzilToX6q1wNPTL0I1CIaNu1fMxEzKya+1PNv0HhtxynUOH4zoRRHqj7J2UGfLrblSEJX/uZdJh/kGsenEw== 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=5jacF0UMoGSb9RVAfT7Engwk4ViDuVVXCvP4NVs29k4=; b=JBjYaa3ekfLgK2vCQuVsmzl8cQis7dnRuYMGSG3wqe1Pw17Taz+wg/5udvp9nh+eLjeTT6j0ZVWZlLAN0bJKIinyQzvPcUdxhSK+RUGEK0J/sWJZM10NcAFd45mNdiLMhhvpxrkVwcLL6ySjE78eDZ+lDPPU7P9DkXyBxkYfxFA2wDFltp/2z7uelk+99Cu2NTiPh+rt2fCbb05cvOdDr4FDHYArLbJIHKxcgqM9Wv7ydtrZOYFX7ScSFpxxK31rinE3z4FNY1ORCVUyaVcE9GfE2OKOwglIA4RrctwbjuR57NYrRxJpB/GO6rTHeKG0g2FzFyscS8nY7l9ThZwSNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5jacF0UMoGSb9RVAfT7Engwk4ViDuVVXCvP4NVs29k4=; b=TrVGA/rnCSgDkDZIBcHkccCCFsDjqOaVcK0anDpmTEykpDJftdmpkLtNPpO/2xebyI5BNR305DrnSYxuvOhOdMChU19wWIt/KbpS2PAQbs8HO+s3mK6Cz9+zoPCrYYL4skkyMZaNS9Dqvv2vE+LaEiTk4R/+rCLavAKfnO2lNQU= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Jason Andryuk To: CC: Jason Andryuk , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , George Dunlap , Julien Grall , Stefano Stabellini Subject: [PATCH v4 5/5] x86/PVH: Support relocatable dom0 kernels Date: Mon, 25 Mar 2024 16:45:15 -0400 Message-ID: <20240325204515.250203-6-jason.andryuk@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325204515.250203-1-jason.andryuk@amd.com> References: <20240325204515.250203-1-jason.andryuk@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A102:EE_|DS0PR12MB8072:EE_ X-MS-Office365-Filtering-Correlation-Id: 267fe8e6-2916-4351-93dd-08dc4d0c80e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 46O/zpqTVIwGdxJ1STSHiFPium+6F+9V7jNn86RY55y5zc99JOXPBaP1L+W45inlSxQiJwVSfhyfThJ/lwYrWLZ+iVpwdaqOXcmpN5oKCuRC5x2ub9ynD50R2taxoOEoUcQfH38IQ1xRSUDdBwaW3z901gsCJHPMimfbtzDEMCnJ9PTnQu6oYuEwa37h8e/pwH5exlTolMcRmijU0A/33G0N35CPddpzD4WWAidtFNI9+gESXbzV3s9YbMowMgu+jyH29ePi32xSzC3zAuicN0fNVdty6647JRh7hqAreBoDFzVk+/sDLZYMhxtH29cHZqAIVjeIGmiaK5szJ9OyCSXzqBaYyw3kPYuSHdUTkAr7XewCv1eN9dBsqKD0RStpxCzQv/HO6kWfUPohlK2VOcpGCrwmd7dU7MfsIH3d2yzLBp2a4CTSo7vKD/zINCpxTZjZ39F4W8s5ewf6EqTRfBQ9H9aBZ3TXeBhlRJRy4j85CkiaGnk9kvHzdquxctKmSRYlqSmOdK+fAgyQhqqJ9S6v1HQEbNa5/SbO/VnjuZoZT/wqSy2TASg4C0DWq5M/UUwSjRAFF9zFDcjGo9K90kXg1LH+7QrdeViGce16WXz/Skr/2uDJhT/E7gNW9Rjn24cSebLiYmuumgg9WCEH+3C06J4tk4AB+qskgUgXBwI95hbfYwdk6Aw5aezgykd6ghA8nykkUri07y0WUncJgM+WV8ovxmUXe8Dom7n2EYZyZvKWR4/Y1KHn96gFxgre X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(376005)(82310400014)(36860700004)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 20:45:27.6512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 267fe8e6-2916-4351-93dd-08dc4d0c80e1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A102.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8072 Xen tries to load a PVH dom0 kernel at the fixed guest physical address from the elf headers. For Linux, this defaults to 0x1000000 (16MB), but it can be configured. Unfortunately there exist firmwares that have reserved regions at this address, so Xen fails to load the dom0 kernel since it's not RAM. The PVH entry code is not relocatable - it loads from absolute addresses, which fail when the kernel is loaded at a different address. With a suitably modified kernel, a reloctable entry point is possible. Add XEN_ELFNOTE_PHYS32_RELOC which specifies optional minimum, maximum and alignment needed for the kernel. The presence of the NOTE indicates the kernel supports a relocatable entry path. Change the loading to check for an acceptable load address. If the kernel is relocatable, support finding an alternate load address. The primary motivation for an explicit align field is that Linux has a configurable CONFIG_PHYSICAL_ALIGN field. This value is present in the bzImage setup header, but not the ELF program headers p_align, which report 2MB even when CONFIG_PHYSICAL_ALIGN is greater. Since a kernel is only considered relocatable if the PHYS32_RELOC elf note is present, the alignment contraints can just be specified within the note instead of searching for an alignment value via a heuristic. libelf-private.h includes common-macros.h to satisfy the fuzzer build. Link: https://gitlab.com/xen-project/xen/-/issues/180 Signed-off-by: Jason Andryuk --- ELF Note printing looks like: (XEN) ELF: note: PHYS32_RELOC = max: 0xffffffff min: 0x1000000 align: 0x200000 v2: Use elfnote for min, max & align - use 64bit values. Print original and relocated memory addresses Use check_and_adjust_load_address() name Return relocated base instead of offset Use PAGE_ALIGN Don't load above max_phys (expected to be 4GB in kernel elf note) Use single line comments Exit check_load_address loop earlier Add __init to find_kernel_memory() v3: Remove kernel_start/end page rounding Change loop comment to rely on a sorted memory map. Reorder E820_RAM check first Use %p for dest_base Use PRIpaddr Use 32bit phys_min/max/align Consolidate to if ( x || y ) continue Use max_t Add parms->phys_reloc Use common "%pd kernel: " prefix for messages Re-order phys_entry assignment Print range ends inclusively Remove extra "Unable to load kernel" message s/PVH_RELOCATION/PHYS32_RELOC/ Make PHYS32_RELOC contents optional Use 2MB default alignment Update ELF Note comment Update XEN_ELFNOTE_MAX v4: Cast dest_base to uintptr_t Use local start variable Mention e820 requiring adjacent entries merged Remove extra whitespace Re-word elfnote comment & mention x86 Use ELFNOTE_NAME Return -ENOSPC Use ! instead of == 0 Check kend - 1 to avoid off by one libelf: Use MB/GB() to define the size. Use ARCH_PHYS_* defines --- xen/arch/x86/hvm/dom0_build.c | 94 ++++++++++++++++++++++++++++++ xen/common/libelf/libelf-dominfo.c | 37 ++++++++++++ xen/common/libelf/libelf-private.h | 1 + xen/include/public/elfnote.h | 19 +++++- xen/include/xen/libelf.h | 4 ++ 5 files changed, 154 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 0ceda4140b..d925fc7417 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -537,6 +537,97 @@ static paddr_t __init find_memory( return INVALID_PADDR; } +static bool __init check_load_address( + const struct domain *d, const struct elf_binary *elf) +{ + paddr_t kernel_start = (uintptr_t)elf->dest_base; + paddr_t kernel_end = kernel_start + elf->dest_size; + unsigned int i; + + /* Relies on a sorted memory map with adjacent entries merged. */ + for ( i = 0; i < d->arch.nr_e820; i++ ) + { + paddr_t start = d->arch.e820[i].addr; + paddr_t end = start + d->arch.e820[i].size; + + if ( start >= kernel_end ) + return false; + + if ( d->arch.e820[i].type == E820_RAM && + start <= kernel_start && + end >= kernel_end ) + return true; + } + + return false; +} + +/* Find an e820 RAM region that fits the kernel at a suitable alignment. */ +static paddr_t __init find_kernel_memory( + const struct domain *d, struct elf_binary *elf, + const struct elf_dom_parms *parms) +{ + paddr_t kernel_size = elf->dest_size; + unsigned int i; + + for ( i = 0; i < d->arch.nr_e820; i++ ) + { + paddr_t start = d->arch.e820[i].addr; + paddr_t end = start + d->arch.e820[i].size; + paddr_t kstart, kend; + + if ( d->arch.e820[i].type != E820_RAM || + d->arch.e820[i].size < kernel_size ) + continue; + + kstart = ROUNDUP(start, parms->phys_align); + kstart = max_t(paddr_t, kstart, parms->phys_min); + kend = kstart + kernel_size; + + if ( kend - 1 > parms->phys_max ) + return 0; + + if ( kend <= end ) + return kstart; + } + + return 0; +} + +/* Check the kernel load address, and adjust if necessary and possible. */ +static bool __init check_and_adjust_load_address( + const struct domain *d, struct elf_binary *elf, struct elf_dom_parms *parms) +{ + paddr_t reloc_base; + + if ( check_load_address(d, elf) ) + return true; + + if ( !parms->phys_reloc ) + { + printk("%pd kernel: Address conflict and not relocatable\n", d); + return false; + } + + reloc_base = find_kernel_memory(d, elf, parms); + if ( !reloc_base ) + { + printk("%pd kernel: Failed find a load address\n", d); + return false; + } + + if ( opt_dom0_verbose ) + printk("%pd kernel: Moving [%p, %p] -> [%"PRIpaddr", %"PRIpaddr"]\n", d, + elf->dest_base, elf->dest_base + elf->dest_size - 1, + reloc_base, reloc_base + elf->dest_size - 1); + + parms->phys_entry = reloc_base + + (parms->phys_entry - (uintptr_t)elf->dest_base); + elf->dest_base = (char *)reloc_base; + + return true; +} + static int __init pvh_load_kernel(struct domain *d, const module_t *image, unsigned long image_headroom, module_t *initrd, void *image_base, @@ -585,6 +676,9 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, elf.dest_base = (void *)(parms.virt_kstart - parms.virt_base); elf.dest_size = parms.virt_kend - parms.virt_kstart; + if ( !check_and_adjust_load_address(d, &elf, &parms) ) + return -ENOSPC; + elf_set_vcpu(&elf, v); rc = elf_load_binary(&elf); if ( rc < 0 ) diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c index e7b44d238b..b47d540023 100644 --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -17,6 +17,16 @@ #include "libelf-private.h" +#if defined(__i386__) || defined(__x86_64__) +#define ARCH_PHYS_MIN_DEFAULT 0; +#define ARCH_PHYS_MAX_DEFAULT (GB(4) - 1); +#define ARCH_PHYS_ALIGN_DEFAULT MB(2); +#else +#define ARCH_PHYS_MIN_DEFAULT 0; +#define ARCH_PHYS_MAX_DEFAULT 0; +#define ARCH_PHYS_ALIGN_DEFAULT 0; +#endif + /* ------------------------------------------------------------------------ */ /* xen features */ @@ -125,6 +135,7 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, [XEN_ELFNOTE_SUSPEND_CANCEL] = { "SUSPEND_CANCEL", ELFNOTE_INT }, [XEN_ELFNOTE_MOD_START_PFN] = { "MOD_START_PFN", ELFNOTE_INT }, [XEN_ELFNOTE_PHYS32_ENTRY] = { "PHYS32_ENTRY", ELFNOTE_INT }, + [XEN_ELFNOTE_PHYS32_RELOC] = { "PHYS32_RELOC", ELFNOTE_NAME }, }; /* *INDENT-ON* */ @@ -132,6 +143,7 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, uint64_t val = 0; unsigned int i; unsigned type = elf_uval(elf, note, type); + unsigned descsz = elf_uval(elf, note, descsz); if ( (type >= sizeof(note_desc) / sizeof(note_desc[0])) || (note_desc[type].name == NULL) ) @@ -227,6 +239,27 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf, case XEN_ELFNOTE_PHYS32_ENTRY: parms->phys_entry = val; break; + + case XEN_ELFNOTE_PHYS32_RELOC: + parms->phys_reloc = true; + + if ( descsz >= 4 ) + { + parms->phys_max = elf_note_numeric_array(elf, note, 4, 0); + elf_msg(elf, " = max: %#"PRIx32, parms->phys_max); + } + if ( descsz >= 8 ) + { + parms->phys_min = elf_note_numeric_array(elf, note, 4, 1); + elf_msg(elf, " min: %#"PRIx32, parms->phys_min); + } + if ( descsz >= 12 ) + { + parms->phys_align = elf_note_numeric_array(elf, note, 4, 2); + elf_msg(elf, " align: %#"PRIx32, parms->phys_align); + } + + break; } if ( note_desc[type].type == ELFNOTE_NAME) @@ -542,6 +575,10 @@ elf_errorstatus elf_xen_parse(struct elf_binary *elf, parms->p2m_base = UNSET_ADDR; parms->elf_paddr_offset = UNSET_ADDR; parms->phys_entry = UNSET_ADDR32; + parms->phys_min = ARCH_PHYS_MIN_DEFAULT; + parms->phys_max = ARCH_PHYS_MAX_DEFAULT; + parms->phys_align = ARCH_PHYS_ALIGN_DEFAULT; + parms->phys_reloc = false; /* Find and parse elf notes. */ count = elf_phdr_count(elf); diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-private.h index 47db679966..98cac65bc5 100644 --- a/xen/common/libelf/libelf-private.h +++ b/xen/common/libelf/libelf-private.h @@ -71,6 +71,7 @@ #endif #include #include +#include #ifndef FUZZ_NO_LIBXC #include "xenctrl.h" diff --git a/xen/include/public/elfnote.h b/xen/include/public/elfnote.h index 8bf54d035b..ed87d5575d 100644 --- a/xen/include/public/elfnote.h +++ b/xen/include/public/elfnote.h @@ -194,10 +194,27 @@ */ #define XEN_ELFNOTE_PHYS32_ENTRY 18 +/* + * Physical loading constraints for PVH kernels + * + * The presence of this note indicates the kernel supports relocating itself. + * + * The note may include up to three 32bit values to place constraints on the + * guest physical loading addresses and alignment for a PVH kernel. Values + * are read in the following order: + * - a maximum address for the entire image to be loaded below (default + * 0xffffffff) + * - a minimum address for the start of the image (default 0) + * - a required start alignment (default 0x200000) + * + * This note is only valid for x86 binaries. + */ +#define XEN_ELFNOTE_PHYS32_RELOC 19 + /* * The number of the highest elfnote defined. */ -#define XEN_ELFNOTE_MAX XEN_ELFNOTE_PHYS32_ENTRY +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_PHYS32_RELOC /* * System information exported through crash notes. diff --git a/xen/include/xen/libelf.h b/xen/include/xen/libelf.h index 1c77e3df31..777c5008ca 100644 --- a/xen/include/xen/libelf.h +++ b/xen/include/xen/libelf.h @@ -434,10 +434,14 @@ struct elf_dom_parms { uint32_t f_supported[XENFEAT_NR_SUBMAPS]; uint32_t f_required[XENFEAT_NR_SUBMAPS]; uint32_t phys_entry; + uint32_t phys_min; + uint32_t phys_max; + uint32_t phys_align; /* calculated */ uint64_t virt_kstart; uint64_t virt_kend; + bool phys_reloc; }; static inline void elf_xen_feature_set(int nr, uint32_t * addr)