lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 09 Mar 2024 09:20:15 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Yuntao Liu" <liuyuntao12@...wei.com>,
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
 "Ard Biesheuvel" <ardb@...nel.org>, "Fangrui Song" <maskray@...gle.com>
Cc: "Russell King" <linux@...linux.org.uk>, "Andrew Davis" <afd@...com>,
 "Andrew Morton" <akpm@...ux-foundation.org>,
 "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 "Geert Uytterhoeven" <geert+renesas@...der.be>,
 "Jonathan Corbet" <corbet@....net>, "Mike Rapoport" <rppt@...nel.org>,
 "Rob Herring" <robh@...nel.org>, "Thomas Gleixner" <tglx@...utronix.de>,
 "Linus Walleij" <linus.walleij@...aro.org>, llvm@...ts.linux.dev
Subject: Re: [PATCH-next v2] arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION

On Sat, Mar 9, 2024, at 07:14, liuyuntao (F) wrote:
> On 2024/3/8 21:15, Arnd Bergmann wrote:
>> On Thu, Mar 7, 2024, at 16:12, Yuntao Liu wrote:
>
> Thanks for the tests, CONFIG_LD_DEAD_CODE_DATA_ELIMINATION and 
> CONFIG_TRIM_UNUSED_KSYMS do indeed result in a significant improvement.
> I found that arm32 still doesn't support CONFIG_LTO_CLANG. I've done 
> some work on it, but without success. I'd like to learn more about the 
> CONFIG_LTO_CLANG patch. Do you have any relevant links?

I did not try to get it to boot and gave up when I did not see
any size improvement. I think there were previous attempts to
do it elsewhere, which I did not try to find.

The patch below makes it build, but it still requires disabling
CONFIG_THUMB2_KERNEL, which totally defeats the purpose of shrinking
the kernel as it adds some 40% size overhead in the vmlinux.
There are probably also runtime bugs that get introduced by this.

     Arnd

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index de78ceb821df..7ebfda4839e8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2,6 +2,8 @@
 config ARM
 	bool
 	default y
+	select ARCH_SUPPORTS_LTO_CLANG
+	select ARCH_SUPPORTS_LTO_CLANG_THIN
 	select ARCH_32BIT_OFF_T
 	select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE if HAVE_KRETPROBES && FRAME_POINTER && !ARM_UNWIND
 	select ARCH_HAS_BINFMT_FLAT
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 726ecabcef09..f2ddce451ab9 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -9,6 +9,8 @@ OBJS		=
 
 HEAD	= head.o
 OBJS	+= misc.o decompress.o
+CFLAGS_REMOVE_misc.o += $(CC_FLAGS_LTO)
+CFLAGS_REMOVE_decompress.o += $(CC_FLAGS_LTO)
 ifeq ($(CONFIG_DEBUG_UNCOMPRESS),y)
 OBJS	+= debug.o
 AFLAGS_head.o += -DDEBUG
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index d19d140a10c7..aee9e13023a8 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -38,15 +38,14 @@ EXPORT_SYMBOL(arm_heavy_mb);
 static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
 {
 	unsigned long to = FLUSH_ALIAS_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
-	const int zero = 0;
 
 	set_top_pte(to, pfn_pte(pfn, PAGE_KERNEL));
 
-	asm(	"mcrr	p15, 0, %1, %0, c14\n"
-	"	mcr	p15, 0, %2, c7, c10, 4"
+	asm("mcrr	p15, 0, %1, %0, c14"
 	    :
-	    : "r" (to), "r" (to + PAGE_SIZE - 1), "r" (zero)
+	    : "r" (to), "r" (to + PAGE_SIZE - 1)
 	    : "cc");
+	dsb();
 }
 
 static void flush_icache_alias(unsigned long pfn, unsigned long vaddr, unsigned long len)
@@ -68,11 +67,11 @@ void flush_cache_mm(struct mm_struct *mm)
 	}
 
 	if (cache_is_vipt_aliasing()) {
-		asm(	"mcr	p15, 0, %0, c7, c14, 0\n"
-		"	mcr	p15, 0, %0, c7, c10, 4"
+		asm("mcr	p15, 0, %0, c7, c14, 0"
 		    :
 		    : "r" (0)
 		    : "cc");
+		dsb();
 	}
 }
 
@@ -84,11 +83,11 @@ void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
 	}
 
 	if (cache_is_vipt_aliasing()) {
-		asm(	"mcr	p15, 0, %0, c7, c14, 0\n"
-		"	mcr	p15, 0, %0, c7, c10, 4"
+		asm("mcr	p15, 0, %0, c7, c14, 0"
 		    :
 		    : "r" (0)
 		    : "cc");
+		dsb();
 	}
 
 	if (vma->vm_flags & VM_EXEC)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ