Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1627439rdb; Tue, 20 Feb 2024 01:54:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWDXgKFrfjQudIA/bdfzTAjyvQ6MNsJ5lkYtQA9JY+XuprYRAvyzpPJE8rSU7l0HHArfxMiBI85/BY02a5WeEZ1135kGkwDf2VOXXZk+g== X-Google-Smtp-Source: AGHT+IF2CSQi7S2/WPyt7fpZhYSxIvhj16T6W/9gFdW2IkISznoFkoX1T9kxiKLwFkb8VxsTjXvC X-Received: by 2002:a05:6a00:9a9:b0:6e3:f58f:c3f9 with SMTP id u41-20020a056a0009a900b006e3f58fc3f9mr11092552pfg.15.1708422861487; Tue, 20 Feb 2024 01:54:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708422861; cv=pass; d=google.com; s=arc-20160816; b=uLPiqPLUb2lgVKmQsm4z+oLYXW9OGS2+s0DpNS5g/eNp4Y8TJrTsyBre7FZyJBWlAX Qfrw1zAynb2hYB4sdgFGSqr+CAlC8L3bUwzpofW468mGtynpj8Z69xBTtZaxAU7QrUPU xsU6bRQUpFGThHBo4Dilw+A+kPYrhKAg9H3Hk+LlKbtgyrmLpLAzvp7r/Zo2PSv3VeBu d04qUVZ6DWYZlpH5/CWOl7ljURrp+oqmSXFlA4zexp3GM2lRvAmQPsFPghpClzOSKKHx St6+RStWMiPPLsJ5UlriAu7vHE2qCe6bh3K+DxQjQZRA5O3qm4bc5FnfMMjp2Iw3PDxT /FhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=i8jiGU5Y4DK9B1paZxEQwCwNvYVeU3Yr8C644LPcKGs=; fh=xy+9uUVudSVwCY4BTFCOqaJf4T2/t2trLSGJ7zbmEb0=; b=SrGLvLNcrBphISX/PDOYazO4CweW6cno6BRuih5Cz1V9EeGXQ0VHCjvoAzf1ih5aO9 qgBq3SxNnOaZmP0eSTdlaX0DBeJp0zDUZwqzLyKoyjxNky+5UK2i10Ap2X8VOCoTflsc dCdSRmd4QnUO2c7JdOSvWckI///I4979/iecy+IMHsszwzE7XHlRSBEivAQkDB9fnW54 p+zzGQorxC1f9S4w4HW9fulgl+jyD6+WDTqxmvVYJBHs4T77mfL8kKbPLk2Lke3h4fKD xXtyXwNfshZvN+upt9bairoXSmsVbnhv2tUrmK8AxVl0BB7P1e6LSGep8ulaSpd3B8KO S7NQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-72749-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v18-20020aa78512000000b006e13ce606c6si5871534pfn.110.2024.02.20.01.54.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 01:54:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72749-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-72749-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 35F9E285748 for ; Tue, 20 Feb 2024 09:54:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3764F612D7; Tue, 20 Feb 2024 09:53:08 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA29D612CB for ; Tue, 20 Feb 2024 09:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708422787; cv=none; b=qkP5596y3zqj6k8+3bBGbMEfgjnPmzvAdku4l4N5Zr5/KN8bsv7sRdjrcMbcV/U/Jv8qk5EMxELU42M9zbQ+7KXAzqscOUXzXy3kLkxV30vPhWLfPYE9Wf286szK9XQR85raIwO7Cz7+rBNjcTRuQPbJwvRNESNT9EO3ytZ2XC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708422787; c=relaxed/simple; bh=EqZc8nDomBp+9zFhAQ4weco20HpKIImPlI4qOduJTAg=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=A8KYyO6x8/ci4HxRkuGhZUSUew3tWDoaCz5kcJixtPvdubo1YrTGjIDDa9RA+NNv4vxK/IRP25h79LszYVZ2vckA78IbfGk9UykpkcsDecJ1GCcROxUhp0AjdsL6yjPty9BI6jqGpJfi/iw0b8xylYXCy0GUk5scYFDNiCoKuyw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TfF6M2GjYz1Q8rx; Tue, 20 Feb 2024 17:51:23 +0800 (CST) Received: from dggpemd100004.china.huawei.com (unknown [7.185.36.20]) by mail.maildlp.com (Postfix) with ESMTPS id 5B556140154; Tue, 20 Feb 2024 17:53:01 +0800 (CST) Received: from [10.67.109.211] (10.67.109.211) by dggpemd100004.china.huawei.com (7.185.36.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 20 Feb 2024 17:53:01 +0800 Message-ID: <38c09a4b-69cc-4dc5-8a68-e5f5597613ac@huawei.com> Date: Tue, 20 Feb 2024 17:53:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next] arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION To: Arnd Bergmann , , CC: Russell King , Andrew Davis , Andrew Morton , "Kirill A. Shutemov" , Geert Uytterhoeven , Jonathan Corbet , Mike Rapoport , Eric DeVolder , Rob Herring , Thomas Gleixner , Linus Walleij References: <20240220081527.23408-1-liuyuntao12@huawei.com> <1342759e-b967-4ec4-98d5-48146f81f695@app.fastmail.com> From: "liuyuntao (F)" In-Reply-To: <1342759e-b967-4ec4-98d5-48146f81f695@app.fastmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemd100004.china.huawei.com (7.185.36.20) 在 2024/2/20 16:40, Arnd Bergmann 写道: > On Tue, Feb 20, 2024, at 09:15, Yuntao Liu wrote: >> diff --git a/arch/arm/boot/compressed/vmlinux.lds.S >> b/arch/arm/boot/compressed/vmlinux.lds.S >> index 3fcb3e62dc56..da21244aa892 100644 >> --- a/arch/arm/boot/compressed/vmlinux.lds.S >> +++ b/arch/arm/boot/compressed/vmlinux.lds.S >> @@ -89,7 +89,7 @@ SECTIONS >> * The EFI stub always executes from RAM, and runs strictly before >> the >> * decompressor, so we can make an exception for its r/w data, and >> keep it >> */ >> - *(.data.efistub .bss.efistub) >> + *(.data.* .bss.*) >> __pecoff_data_end = .; >> >> /* > > This doesn't seem right to me, or maybe I misunderstand what > the original version does. Have you tested with both > CONFIG_EFI_STUB on and off, and booting with and without > UEFI? Yes, I have tested with CONFIG_EFI_STUB on and off, and booting with UEFI on a single-board computer, and it boots well. > > If I read this right, you would move all .data and .bss > into the stub here, not just the parts we actually want? In the file "drivers/firmware/efi/libstub/Makefile", it is written: --- # # ARM discards the .data section because it disallows r/w data in the # decompressor. So move our .data to .data.efistub and .bss to .bss.efistub, # which are preserved explicitly by the decompressor linker script. # STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \ --rename-section .bss=.bss.efistub,load,alloc --- I think that .data.efistub represents the entire .data section, the same applies to .bss as well, so i move all .data and .bss into the stub here. > >> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S >> index bd9127c4b451..de373c6c2ae8 100644 >> --- a/arch/arm/kernel/vmlinux.lds.S >> +++ b/arch/arm/kernel/vmlinux.lds.S >> @@ -74,7 +74,7 @@ SECTIONS >> . = ALIGN(4); >> __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { >> __start___ex_table = .; >> - ARM_MMU_KEEP(*(__ex_table)) >> + ARM_MMU_KEEP(KEEP(*(__ex_table))) >> __stop___ex_table = .; >> } >> >> @@ -116,7 +116,7 @@ SECTIONS >> #endif >> .init.pv_table : { >> __pv_table_begin = .; >> - *(.pv_table) >> + KEEP(*(.pv_table)) >> __pv_table_end = .; >> } > > I guess this prevents discarding any function that has a reference > from pv_table or ex_table, even if there are no other references, > right? Indeed so, if not keep ex_table, the compilation process will result in an error: no __ex_table in file: vmlinux Failed to sort kernel tables and if not keep pv_table, It can be compiled successfully, but the QEMU boots will fail. > > I don't know how to solve this other than forcing all the > uaccess and virt_to_phys functions to be out of line > helpers. For uaccess, there are probably very few functions > that need this, so it should make little difference. > > You might want to try changing CONFIG_ARM_PATCH_PHYS_VIRT > into a method that just always adds an offset from C code > instead of the boot time patching. That way the code would > be a bit less efficient but you might be able to get > a larger size reduction by dropping additional unused code. > > Maybe test your patch both with and without > ARM_PATCH_PHYS_VIRT to see what the best-case impact would > be. > This is a very good idea, I will give it a try. > Arnd