Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patches: Add backports for new ld.lld issue in Android
These have been sent upstream but are unlikely to end up in Android super quickly due to these branches being released branches. Link: ClangBuiltLinux/linux#1949 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
- Loading branch information
1 parent
9a6a28c
commit 79de888
Showing
15 changed files
with
1,112 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
patches/android-4.14/0001-x86-mm-Simplify-RESERVE_BRK.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
From 3e84500d881d306f8ff3b00b14e916ca0cb55238 Mon Sep 17 00:00:00 2001 | ||
From: Josh Poimboeuf <jpoimboe@redhat.com> | ||
Date: Fri, 6 May 2022 14:14:32 +0200 | ||
Subject: [PATCH 4.14 1/2] x86/mm: Simplify RESERVE_BRK() | ||
|
||
commit a1e2c031ec3949b8c039b739c0b5bf9c30007b00 upstream. | ||
|
||
RESERVE_BRK() reserves data in the .brk_reservation section. The data | ||
is initialized to zero, like BSS, so the macro specifies 'nobits' to | ||
prevent the data from taking up space in the vmlinux binary. The only | ||
way to get the compiler to do that (without putting the variable in .bss | ||
proper) is to use inline asm. | ||
|
||
The macro also has a hack which encloses the inline asm in a discarded | ||
function, which allows the size to be passed (global inline asm doesn't | ||
allow inputs). | ||
|
||
Remove the need for the discarded function hack by just stringifying the | ||
size rather than supplying it as an input to the inline asm. | ||
|
||
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> | ||
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> | ||
Signed-off-by: Borislav Petkov <bp@suse.de> | ||
Reviewed-by: Borislav Petkov <bp@suse.de> | ||
Link: https://lore.kernel.org/r/20220506121631.133110232@infradead.org | ||
[nathan: Fix conflict due to lack of 2b6ff7dea670 and 33def8498fdd] | ||
Signed-off-by: Nathan Chancellor <nathan@kernel.org> | ||
--- | ||
arch/x86/include/asm/setup.h | 30 +++++++++++------------------- | ||
1 file changed, 11 insertions(+), 19 deletions(-) | ||
|
||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h | ||
index ae13bc974416..e1110e2ebc9e 100644 | ||
--- a/arch/x86/include/asm/setup.h | ||
+++ b/arch/x86/include/asm/setup.h | ||
@@ -91,27 +91,19 @@ extern unsigned long _brk_end; | ||
void *extend_brk(size_t size, size_t align); | ||
|
||
/* | ||
- * Reserve space in the brk section. The name must be unique within | ||
- * the file, and somewhat descriptive. The size is in bytes. Must be | ||
- * used at file scope. | ||
+ * Reserve space in the brk section. The name must be unique within the file, | ||
+ * and somewhat descriptive. The size is in bytes. | ||
* | ||
- * (This uses a temp function to wrap the asm so we can pass it the | ||
- * size parameter; otherwise we wouldn't be able to. We can't use a | ||
- * "section" attribute on a normal variable because it always ends up | ||
- * being @progbits, which ends up allocating space in the vmlinux | ||
- * executable.) | ||
+ * The allocation is done using inline asm (rather than using a section | ||
+ * attribute on a normal variable) in order to allow the use of @nobits, so | ||
+ * that it doesn't take up any space in the vmlinux file. | ||
*/ | ||
-#define RESERVE_BRK(name,sz) \ | ||
- static void __section(.discard.text) __used notrace \ | ||
- __brk_reservation_fn_##name##__(void) { \ | ||
- asm volatile ( \ | ||
- ".pushsection .brk_reservation,\"aw\",@nobits;" \ | ||
- ".brk." #name ":" \ | ||
- " 1:.skip %c0;" \ | ||
- " .size .brk." #name ", . - 1b;" \ | ||
- " .popsection" \ | ||
- : : "i" (sz)); \ | ||
- } | ||
+#define RESERVE_BRK(name, size) \ | ||
+ asm(".pushsection .brk_reservation,\"aw\",@nobits\n\t" \ | ||
+ ".brk." #name ":\n\t" \ | ||
+ ".skip " __stringify(size) "\n\t" \ | ||
+ ".size .brk." #name ", " __stringify(size) "\n\t" \ | ||
+ ".popsection\n\t") | ||
|
||
/* Helper for reserving space for arrays of things */ | ||
#define RESERVE_BRK_ARRAY(type, name, entries) \ | ||
|
||
base-commit: 89d93e9d9f32df4b2d7f4ff3bff645f0c7acad35 | ||
-- | ||
2.42.0 | ||
|
135 changes: 135 additions & 0 deletions
135
patches/android-4.14/0002-x86-mm-Fix-RESERVE_BRK-for-older-binutils.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
From 9be27be873349f37d7ecd5d4864aed00114d8911 Mon Sep 17 00:00:00 2001 | ||
From: Josh Poimboeuf <jpoimboe@kernel.org> | ||
Date: Thu, 9 Jun 2022 00:17:32 -0700 | ||
Subject: [PATCH 4.14 2/2] x86/mm: Fix RESERVE_BRK() for older binutils | ||
|
||
commit e32683c6f7d22ba624e0bfc58b02cf3348bdca63 upstream. | ||
|
||
With binutils 2.26, RESERVE_BRK() causes a build failure: | ||
|
||
/tmp/ccnGOKZ5.s: Assembler messages: | ||
/tmp/ccnGOKZ5.s:98: Error: missing ')' | ||
/tmp/ccnGOKZ5.s:98: Error: missing ')' | ||
/tmp/ccnGOKZ5.s:98: Error: missing ')' | ||
/tmp/ccnGOKZ5.s:98: Error: junk at end of line, first unrecognized | ||
character is `U' | ||
|
||
The problem is this line: | ||
|
||
RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE) | ||
|
||
Specifically, the INIT_PGT_BUF_SIZE macro which (via PAGE_SIZE's use | ||
_AC()) has a "1UL", which makes older versions of the assembler unhappy. | ||
Unfortunately the _AC() macro doesn't work for inline asm. | ||
|
||
Inline asm was only needed here to convince the toolchain to add the | ||
STT_NOBITS flag. However, if a C variable is placed in a section whose | ||
name is prefixed with ".bss", GCC and Clang automatically set | ||
STT_NOBITS. In fact, ".bss..page_aligned" already relies on this trick. | ||
|
||
So fix the build failure (and simplify the macro) by allocating the | ||
variable in C. | ||
|
||
Also, add NOLOAD to the ".brk" output section clause in the linker | ||
script. This is a failsafe in case the ".bss" prefix magic trick ever | ||
stops working somehow. If there's a section type mismatch, the GNU | ||
linker will force the ".brk" output section to be STT_NOBITS. The LLVM | ||
linker will fail with a "section type mismatch" error. | ||
|
||
Note this also changes the name of the variable from .brk.##name to | ||
__brk_##name. The variable names aren't actually used anywhere, so it's | ||
harmless. | ||
|
||
Fixes: a1e2c031ec39 ("x86/mm: Simplify RESERVE_BRK()") | ||
Reported-by: Joe Damato <jdamato@fastly.com> | ||
Reported-by: Byungchul Park <byungchul.park@lge.com> | ||
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> | ||
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> | ||
Tested-by: Joe Damato <jdamato@fastly.com> | ||
Link: https://lore.kernel.org/r/22d07a44c80d8e8e1e82b9a806ddc8c6bbb2606e.1654759036.git.jpoimboe@kernel.org | ||
[nathan: Fix conflict due to lack of 360db4ace311 and resolve silent | ||
conflict with 360db4ace3117] | ||
Signed-off-by: Nathan Chancellor <nathan@kernel.org> | ||
--- | ||
arch/x86/include/asm/setup.h | 38 +++++++++++++++++++---------------- | ||
arch/x86/kernel/vmlinux.lds.S | 4 ++-- | ||
2 files changed, 23 insertions(+), 19 deletions(-) | ||
|
||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h | ||
index e1110e2ebc9e..e0e6aad9cd51 100644 | ||
--- a/arch/x86/include/asm/setup.h | ||
+++ b/arch/x86/include/asm/setup.h | ||
@@ -91,19 +91,16 @@ extern unsigned long _brk_end; | ||
void *extend_brk(size_t size, size_t align); | ||
|
||
/* | ||
- * Reserve space in the brk section. The name must be unique within the file, | ||
- * and somewhat descriptive. The size is in bytes. | ||
+ * Reserve space in the .brk section, which is a block of memory from which the | ||
+ * caller is allowed to allocate very early (before even memblock is available) | ||
+ * by calling extend_brk(). All allocated memory will be eventually converted | ||
+ * to memblock. Any leftover unallocated memory will be freed. | ||
* | ||
- * The allocation is done using inline asm (rather than using a section | ||
- * attribute on a normal variable) in order to allow the use of @nobits, so | ||
- * that it doesn't take up any space in the vmlinux file. | ||
+ * The size is in bytes. | ||
*/ | ||
-#define RESERVE_BRK(name, size) \ | ||
- asm(".pushsection .brk_reservation,\"aw\",@nobits\n\t" \ | ||
- ".brk." #name ":\n\t" \ | ||
- ".skip " __stringify(size) "\n\t" \ | ||
- ".size .brk." #name ", " __stringify(size) "\n\t" \ | ||
- ".popsection\n\t") | ||
+#define RESERVE_BRK(name, size) \ | ||
+ __section(.bss..brk) __aligned(1) __used \ | ||
+ static char __brk_##name[size] | ||
|
||
/* Helper for reserving space for arrays of things */ | ||
#define RESERVE_BRK_ARRAY(type, name, entries) \ | ||
@@ -121,12 +118,19 @@ asmlinkage void __init x86_64_start_reservations(char *real_mode_data); | ||
|
||
#endif /* __i386__ */ | ||
#endif /* _SETUP */ | ||
-#else | ||
-#define RESERVE_BRK(name,sz) \ | ||
- .pushsection .brk_reservation,"aw",@nobits; \ | ||
-.brk.name: \ | ||
-1: .skip sz; \ | ||
- .size .brk.name,.-1b; \ | ||
+ | ||
+#else /* __ASSEMBLY */ | ||
+ | ||
+.macro __RESERVE_BRK name, size | ||
+ .pushsection .bss..brk, "aw" | ||
+SYM_DATA_START(__brk_\name) | ||
+ .skip \size | ||
+SYM_DATA_END(__brk_\name) | ||
.popsection | ||
+.endm | ||
+ | ||
+#define RESERVE_BRK(name, size) __RESERVE_BRK name, size | ||
+ | ||
#endif /* __ASSEMBLY__ */ | ||
+ | ||
#endif /* _ASM_X86_SETUP_H */ | ||
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S | ||
index d3dc8bc6b3ad..9f1e4fe643b5 100644 | ||
--- a/arch/x86/kernel/vmlinux.lds.S | ||
+++ b/arch/x86/kernel/vmlinux.lds.S | ||
@@ -359,10 +359,10 @@ SECTIONS | ||
} | ||
|
||
. = ALIGN(PAGE_SIZE); | ||
- .brk : AT(ADDR(.brk) - LOAD_OFFSET) { | ||
+ .brk (NOLOAD) : AT(ADDR(.brk) - LOAD_OFFSET) { | ||
__brk_base = .; | ||
. += 64 * 1024; /* 64k alignment slop space */ | ||
- *(.brk_reservation) /* areas brk users have reserved */ | ||
+ *(.bss..brk) /* areas brk users have reserved */ | ||
__brk_limit = .; | ||
} | ||
|
||
-- | ||
2.42.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0001-x86-mm-Simplify-RESERVE_BRK.patch | ||
0002-x86-mm-Fix-RESERVE_BRK-for-older-binutils.patch |
79 changes: 79 additions & 0 deletions
79
patches/android-4.19/0001-x86-mm-Simplify-RESERVE_BRK.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
From a210bdbea666487df5665a541554374bdfa9833a Mon Sep 17 00:00:00 2001 | ||
From: Josh Poimboeuf <jpoimboe@redhat.com> | ||
Date: Fri, 6 May 2022 14:14:32 +0200 | ||
Subject: [PATCH 4.19 1/2] x86/mm: Simplify RESERVE_BRK() | ||
|
||
commit a1e2c031ec3949b8c039b739c0b5bf9c30007b00 upstream. | ||
|
||
RESERVE_BRK() reserves data in the .brk_reservation section. The data | ||
is initialized to zero, like BSS, so the macro specifies 'nobits' to | ||
prevent the data from taking up space in the vmlinux binary. The only | ||
way to get the compiler to do that (without putting the variable in .bss | ||
proper) is to use inline asm. | ||
|
||
The macro also has a hack which encloses the inline asm in a discarded | ||
function, which allows the size to be passed (global inline asm doesn't | ||
allow inputs). | ||
|
||
Remove the need for the discarded function hack by just stringifying the | ||
size rather than supplying it as an input to the inline asm. | ||
|
||
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> | ||
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> | ||
Signed-off-by: Borislav Petkov <bp@suse.de> | ||
Reviewed-by: Borislav Petkov <bp@suse.de> | ||
Link: https://lore.kernel.org/r/20220506121631.133110232@infradead.org | ||
[nathan: Fix conflict due to lack of 2b6ff7dea670 and 33def8498fdd] | ||
Signed-off-by: Nathan Chancellor <nathan@kernel.org> | ||
--- | ||
arch/x86/include/asm/setup.h | 30 +++++++++++------------------- | ||
1 file changed, 11 insertions(+), 19 deletions(-) | ||
|
||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h | ||
index ae13bc974416..e1110e2ebc9e 100644 | ||
--- a/arch/x86/include/asm/setup.h | ||
+++ b/arch/x86/include/asm/setup.h | ||
@@ -91,27 +91,19 @@ extern unsigned long _brk_end; | ||
void *extend_brk(size_t size, size_t align); | ||
|
||
/* | ||
- * Reserve space in the brk section. The name must be unique within | ||
- * the file, and somewhat descriptive. The size is in bytes. Must be | ||
- * used at file scope. | ||
+ * Reserve space in the brk section. The name must be unique within the file, | ||
+ * and somewhat descriptive. The size is in bytes. | ||
* | ||
- * (This uses a temp function to wrap the asm so we can pass it the | ||
- * size parameter; otherwise we wouldn't be able to. We can't use a | ||
- * "section" attribute on a normal variable because it always ends up | ||
- * being @progbits, which ends up allocating space in the vmlinux | ||
- * executable.) | ||
+ * The allocation is done using inline asm (rather than using a section | ||
+ * attribute on a normal variable) in order to allow the use of @nobits, so | ||
+ * that it doesn't take up any space in the vmlinux file. | ||
*/ | ||
-#define RESERVE_BRK(name,sz) \ | ||
- static void __section(.discard.text) __used notrace \ | ||
- __brk_reservation_fn_##name##__(void) { \ | ||
- asm volatile ( \ | ||
- ".pushsection .brk_reservation,\"aw\",@nobits;" \ | ||
- ".brk." #name ":" \ | ||
- " 1:.skip %c0;" \ | ||
- " .size .brk." #name ", . - 1b;" \ | ||
- " .popsection" \ | ||
- : : "i" (sz)); \ | ||
- } | ||
+#define RESERVE_BRK(name, size) \ | ||
+ asm(".pushsection .brk_reservation,\"aw\",@nobits\n\t" \ | ||
+ ".brk." #name ":\n\t" \ | ||
+ ".skip " __stringify(size) "\n\t" \ | ||
+ ".size .brk." #name ", " __stringify(size) "\n\t" \ | ||
+ ".popsection\n\t") | ||
|
||
/* Helper for reserving space for arrays of things */ | ||
#define RESERVE_BRK_ARRAY(type, name, entries) \ | ||
|
||
base-commit: 4a82dfcb8b4d07331d1db05a36f7d87013787e9e | ||
-- | ||
2.42.0 | ||
|
Oops, something went wrong.