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 24F31D374B9 for ; Fri, 5 Dec 2025 23:08:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1179573.1503028 (Exim 4.92) (envelope-from ) id 1vRetz-0004BC-2z; Fri, 05 Dec 2025 23:07:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1179573.1503028; Fri, 05 Dec 2025 23:07:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vRetz-0004B5-03; Fri, 05 Dec 2025 23:07:51 +0000 Received: by outflank-mailman (input) for mailman id 1179573; Fri, 05 Dec 2025 23:07:50 +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 1vRety-0004Az-Fa for xen-devel@lists.xenproject.org; Fri, 05 Dec 2025 23:07:50 +0000 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazlp17011000f.outbound.protection.outlook.com [2a01:111:f403:c100::f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36e75bf2-d22f-11f0-9d1b-b5c5bf9af7f9; Sat, 06 Dec 2025 00:07:48 +0100 (CET) Received: from PH7P220CA0048.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::19) by IA1PR12MB7637.namprd12.prod.outlook.com (2603:10b6:208:427::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.12; Fri, 5 Dec 2025 23:07:43 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::9d) by PH7P220CA0048.outlook.office365.com (2603:10b6:510:32b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9388.12 via Frontend Transport; Fri, 5 Dec 2025 23:07:40 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9388.8 via Frontend Transport; Fri, 5 Dec 2025 23:07:43 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Fri, 5 Dec 2025 17:07:42 -0600 Received: from satlexmb08.amd.com (10.181.42.217) 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.39; Fri, 5 Dec 2025 17:07:42 -0600 Received: from [172.25.33.6] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Fri, 5 Dec 2025 15:07:40 -0800 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: 36e75bf2-d22f-11f0-9d1b-b5c5bf9af7f9 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o1kNtrE9Ry1MufJMCOieMbjTgqAQ7cmTQdOgOvXcvW7R47YQCZF5jVfg9akX+iv5yxFsze1PZtVXzkAP982JSktl5z7CmBT789BiLEEazdyJyomvlitx5k39rzqKrnUaMeriu/2kQhBlAHkAdI4+SNGOZrAhKhvj8u6BLRYB1RzKlqiiNzxCOvySZUaXM+26GtcMppKNHAxlFtckuCIYia//GB7+o0VbdqRyHSehsEQVBX8na+FwCbw/VXjRzoY5kMfjg5OlvQV+upXkYgx5Wkq5MA/KxBXcSpnGAwVrJ4ay+/Wx4g0rBLwH+sPUJDZ1FOgWjzNOeU+2Su9TB3pSFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Y6ebwCXfNCS8VnV0ChFq0YkAFKWUMyn5VuP4hjbvdS0=; b=auiE+CNSzDc6tgHjqZy2+fOKrSVZvLRsaw1NHAxSCsmUugTPOkTSzzGgu3TQ+H3CqWHnOPs+1cmUrFNhZlfpkEciy/dmn+Mi5NPHsaZnSa07O2qgheTfetys7hB7ZHK4Fy1Y7+IZwGBxXYp79KlKH1Qx7KN3e6CKeR9ZqxrcgWAqbyfXKVAB93oFI4Fuf1H9i5G89QELIVBvE4wDhSyMGhrZ+sW/dm7Vi32w6gOIKflmukmLkxxAGeKjKE6DhDeXgzTe6upAS1U88YrOOj7OznK1X2adSM19CgQUpfP+VzUyA6LcaghjupYjwhVMufiuJkQPHS56rVz6Vllscjwj3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com 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=Y6ebwCXfNCS8VnV0ChFq0YkAFKWUMyn5VuP4hjbvdS0=; b=jmf5XKzCX5LZ+PhxWK5lcg7UIh5Sn9bZcleGwPyeSJ5VOHQWHr5/+5TvRZOGxP/7F79bfJYPsaACb53i5a9bgGgWa49EuxzYsSgrQZyWedyCGvFFg0xCZa9ZqOPK0N/+zrLn5ZdZGDXgV/BHujpdtAT0AtPSja2A5Iqw7cMNouE= 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=satlexmb07.amd.com; pr=C Message-ID: <4202e2be-1428-4a3e-b0e5-2a65fa7383fb@amd.com> Date: Fri, 5 Dec 2025 18:07:35 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RFC: xen/x86: Enable --gc-sections To: Andrew Cooper , CC: Jan Beulich , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , "Michal Orzel" , Julien Grall , "Stefano Stabellini" , Grygorii Strashko References: <20251205222813.277164-1-jason.andryuk@amd.com> <8dce8443-5a97-42c4-b867-27b83415b3d1@citrix.com> Content-Language: en-US From: Jason Andryuk In-Reply-To: <8dce8443-5a97-42c4-b867-27b83415b3d1@citrix.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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: CY4PEPF0000E9D0:EE_|IA1PR12MB7637:EE_ X-MS-Office365-Filtering-Correlation-Id: 4359e4b8-5a34-4902-8660-08de3453187c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014; X-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M0pEaEZpZnlWK2dNbERtMytKVXJWK3dhOWFlNGFVMTRNdjJXeVFxNmczaHBX?= =?utf-8?B?cEp1cnBUTXNlM25hTVBGNkE5cXpkM2NuM3BFdytxT0xYME5EMitWb1VSZmQr?= =?utf-8?B?a2gwTEpHckt0V0c4MUtiemd5V08vd1dWR1EyR09FTzRib3dtcWRwbE0rTHBy?= =?utf-8?B?OVdXR3E2c3JGYitMSjFKVEMyVXJrVWxtQ3E2ZjZYSkYyNW5MRlpkMUZ1aDha?= =?utf-8?B?R1pEVkJ0ZWJwZGRTeWtkWks2cFVtTks0T1liQkdhWURzL1h1M0VBUk5ITEJD?= =?utf-8?B?U0FFL3ViSFJmcmxhN2J0TFR3VDNtWEhJRitJdHJXZ2dkM3huNiszTFBxOUVP?= =?utf-8?Q?mc7E=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2025 23:07:43.0071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4359e4b8-5a34-4902-8660-08de3453187c 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7637 On 2025-12-05 17:40, Andrew Cooper wrote: > On 05/12/2025 10:28 pm, Jason Andryuk wrote: >> When linking to create xen-syms, add --gc-sections to garbage collect >> unused stuff. Relies on CONFIG_CC_SPLIT_SECTIONS >> >> We need to add KEEP() to the linker script in assorted places to retain >> appropriate data - especially the arrays created therein. >> >> Something is off though. In a test where memory_add() is unreachable, >> it is still included. I'm not sure, but I am wondering if it's the >> alternatives somehow keeping a reference to it. > > Yes, .altinstructions contains relocations against the origin patch > site, which will cause it to appear to be referenced. The same will be > happening with a bunch of other sections. > > Hmm.  We are surely not the first people to encounter this. I didn't find any magic in Linux, but I didn't look too hard. >> Signed-off-by: Jason Andryuk >> --- >> With --print-gc-sections on defconfig: >> ld: removing unused section '.text.__bitmap_full' in file 'prelink.o' >> ld: removing unused section '.text.__bitmap_xor' in file 'prelink.o' >> ld: removing unused section '.text.__bitmap_set' in file 'prelink.o' >> ld: removing unused section '.text.__bitmap_clear' in file 'prelink.o' >> ld: removing unused section '.text.bitmap_find_free_region' in file 'prelink.o' >> ld: removing unused section '.text.bitmap_release_region' in file 'prelink.o' >> ld: removing unused section '.text.domain_has_ioreq_server' in file 'prelink.o' >> ld: removing unused section '.text.compat_kexec_op' in file 'prelink.o' >> ld: removing unused section '.text.in_atomic' in file 'prelink.o' >> ld: removing unused section '.text.radix_tree_next_hole' in file 'prelink.o' >> ld: removing unused section '.text.radix_tree_prev_hole' in file 'prelink.o' >> ld: removing unused section '.text.radix_tree_gang_lookup_slot' in file 'prelink.o' >> ld: removing unused section '.text._nrspin_trylock' in file 'prelink.o' >> ld: removing unused section '.text.xen_compile_host' in file 'prelink.o' >> ld: removing unused section '.text.vscnprintf' in file 'prelink.o' >> ld: removing unused section '.text.wake_up_one' in file 'prelink.o' >> ld: removing unused section '.text.xmem_pool_get_used_size' in file 'prelink.o' >> ld: removing unused section '.text.xmem_pool_get_total_size' in file 'prelink.o' >> ld: removing unused section '.text.xmem_pool_maxalloc' in file 'prelink.o' >> ld: removing unused section '.text.xlat_start_info' in file 'prelink.o' >> ld: removing unused section '.text.elf_sym_by_name' in file 'prelink.o' >> ld: removing unused section '.text.elf_sym_by_index' in file 'prelink.o' >> ld: removing unused section '.text.elf_get_ptr' in file 'prelink.o' >> ld: removing unused section '.text.elf_lookup_addr' in file 'prelink.o' >> ld: removing unused section '.text.serial_vuart_info' in file 'prelink.o' >> ld: removing unused section '.text.pci_find_next_cap' in file 'prelink.o' >> ld: removing unused section '.text.free_hvm_irq_dpci' in file 'prelink.o' >> ld: removing unused section '.text.mce_barrier_init' in file 'prelink.o' >> ld: removing unused section '.text.mce_barrier_dec' in file 'prelink.o' >> ld: removing unused section '.text.mce_barrier' in file 'prelink.o' >> ld: removing unused section '.text.apei_read_mce' in file 'prelink.o' >> ld: removing unused section '.text.apei_check_mce' in file 'prelink.o' >> ld: removing unused section '.text.apei_clear_mce' in file 'prelink.o' >> ld: removing unused section '.text.efi_halt_system' in file 'prelink.o' >> ld: removing unused section '.text.get_vvmcs_virtual_safe' in file 'prelink.o' >> ld: removing unused section '.text.get_vvmcs_real_safe' in file 'prelink.o' >> ld: removing unused section '.text.set_vvmcs_real' in file 'prelink.o' >> ld: removing unused section '.text.set_vvmcs_virtual_safe' in file 'prelink.o' >> ld: removing unused section '.text.set_vvmcs_real_safe' in file 'prelink.o' >> ld: removing unused section '.text.domain_set_alloc_bitsize' in file 'prelink.o' >> ld: removing unused section '.text.watchdog_enabled' in file 'prelink.o' >> ld: removing unused section '.text.unset_nmi_callback' in file 'prelink.o' >> ld: removing unused section '.text.sha2_256_init' in file 'prelink.o' >> ld: removing unused section '.text.xxh64_copy_state' in file 'prelink.o' >> ld: removing unused section '.text.xxh64' in file 'prelink.o' >> ld: removing unused section '.discard' in file 'prelink.o' >> ld: removing unused section '.rodata.xen_compile_host.str1.1' in file 'prelink.o' >> ld: removing unused section '.rodata.elf_lookup_addr.str1.1' in file 'prelink.o' >> ld: removing unused section '.rodata.apei_read_mce.str1.8' in file 'prelink.o' >> ld: removing unused section '.rodata.efi_halt_system.str1.8' in file 'prelink.o' >> ld: removing unused section '.rodata.play_dead.str1.1' in file 'prelink.o' >> ld: removing unused section '.data.rel.ro.local.fetch_type_names' in file 'prelink.o' > > This is for your safety stripped-down build, I'm guessing? This is actually Xen staging. > It's certainly a good start. > >> diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S >> index 527872a6db..e3ad58f688 100644 >> --- a/xen/arch/x86/xen.lds.S >> +++ b/xen/arch/x86/xen.lds.S >> @@ -98,7 +98,7 @@ SECTIONS >> #endif >> *(.text.__x86_indirect_thunk_*) >> >> - *(.fixup) >> + KEEP(*(.fixup)) > > Why do we need to KEEP() this?  The references here are the other way > around to most examples. I thought I saw it dropped when trying to get this working, but it does seem to work by removing the KEEP(). Thanks for taking a look. This implicitly relies on LIVEPATCH to select CC_SPLIT_SECTIONS. To be standalone, X86 can just select CC_SPLIT_SECTIONS unless we want to make it optional. Regards, Jason