From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Joe Damato <jdamato@fastly.com>,
Byungchul Park <byungchul.park@lge.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 5.4 40/74] x86/mm: Fix RESERVE_BRK() for older binutils
Date: Mon, 6 Nov 2023 14:04:00 +0100 [thread overview]
Message-ID: <20231106130303.136739845@linuxfoundation.org> (raw)
In-Reply-To: <20231106130301.687882731@linuxfoundation.org>
5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <jpoimboe@kernel.org>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/include/asm/setup.h | 38 +++++++++++++++++++++-----------------
arch/x86/kernel/vmlinux.lds.S | 4 ++--
2 files changed, 23 insertions(+), 19 deletions(-)
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -94,19 +94,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) \
@@ -124,12 +121,19 @@ asmlinkage void __init x86_64_start_rese
#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 */
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -380,10 +380,10 @@ SECTIONS
__end_of_kernel_reserve = .;
. = 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 = .;
}
next prev parent reply other threads:[~2023-11-06 13:21 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 13:03 [PATCH 5.4 00/74] 5.4.260-rc1 review Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 01/74] mtd: rawnand: marvell: Ensure program page operations are successful Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 02/74] selftests/ftrace: Add new test case which checks non unique symbol Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 03/74] mcb: Return actual parsed size when reading chameleon table Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 04/74] mcb-lpc: Reallocate memory region to avoid memory overlapping Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 05/74] virtio_balloon: Fix endless deflation and inflation on arm64 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 06/74] virtio-mmio: fix memory leak of vm_dev Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 07/74] r8169: fix the KCSAN reported data-race in rtl_tx while reading TxDescArray[entry].opts1 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 08/74] r8169: fix the KCSAN reported data race in rtl_rx while reading desc->opts1 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 09/74] treewide: Spelling fix in comment Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 10/74] igb: Fix potential memory leak in igb_add_ethtool_nfc_entry Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 11/74] neighbour: fix various data-races Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 12/74] igc: Fix ambiguity in the ethtool advertising Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 13/74] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 14/74] r8152: Increase USB control msg timeout to 5000ms as per spec Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 15/74] r8152: Run the unload routine if we have errors during probe Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 16/74] r8152: Cancel hw_phy_work if we have an error in probe Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 17/74] tcp: fix wrong RTO timeout when received SACK reneging Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 18/74] gtp: uapi: fix GTPA_MAX Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 19/74] gtp: fix fragmentation needed check with gso Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 20/74] iio: exynos-adc: request second interupt only when touchscreen mode is used Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 21/74] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 22/74] i2c: muxes: i2c-mux-gpmux: " Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 23/74] i2c: muxes: i2c-demux-pinctrl: " Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 24/74] i2c: stm32f7: Fix PEC handling in case of SMBUS transfers Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 25/74] i2c: aspeed: Fix i2c bus hang in slave read Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 26/74] nvmem: imx: correct nregs for i.MX6ULL Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 27/74] nvmem: imx: correct nregs for i.MX6SLL Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 28/74] nvmem: imx: correct nregs for i.MX6UL Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 29/74] perf/core: Fix potential NULL deref Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 30/74] clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 31/74] i40e: Fix wrong check for I40E_TXR_FLAGS_WB_ON_ITR Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 32/74] x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 33/74] drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 34/74] arm64: fix a concurrency issue in emulation_proc_handler() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 35/74] kobject: Fix slab-out-of-bounds in fill_kobj_path() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 36/74] smbdirect: missing rc checks while waiting for rdma events Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 37/74] f2fs: fix to do sanity check on inode type during garbage collection Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 38/74] nfsd: lock_rename() needs both directories to live on the same fs Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 5.4 39/74] x86/mm: Simplify RESERVE_BRK() Greg Kroah-Hartman
2023-11-06 13:04 ` Greg Kroah-Hartman [this message]
2023-11-06 13:04 ` [PATCH 5.4 41/74] ext4: add two helper functions extent_logical_end() and pa_logical_end() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 42/74] ext4: avoid overlapping preallocations due to overflow Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 43/74] ext4: fix BUG in ext4_mb_new_inode_pa() " Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 44/74] driver: platform: Add helper for safer setting of driver_override Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 45/74] rpmsg: Constify local variable in field store macro Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 46/74] rpmsg: Fix kfree() of static memory on setting driver_override Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 47/74] rpmsg: Fix calling device_lock() on non-initialized device Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 48/74] rpmsg: glink: Release driver_override Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 49/74] rpmsg: Fix possible refcount leak in rpmsg_register_device_override() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 50/74] x86: Fix .brk attribute in linker script Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 51/74] Input: i8042 - add Fujitsu Lifebook E5411 to i8042 quirk table Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 52/74] irqchip/stm32-exti: add missing DT IRQ flag translation Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 53/74] dmaengine: ste_dma40: Fix PM disable depth imbalance in d40_probe Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 54/74] Input: synaptics-rmi4 - handle reset delay when using SMBus trsnsport Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 55/74] fbdev: atyfb: only use ioremap_uc() on i386 and ia64 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 56/74] spi: npcm-fiu: Fix UMA reads when dummy.nbytes == 0 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 57/74] netfilter: nfnetlink_log: silence bogus compiler warning Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 58/74] ASoC: rt5650: fix the wrong result of key button Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 59/74] fbdev: uvesafb: Call cn_del_callback() at the end of uvesafb_exit() Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 60/74] scsi: mpt3sas: Fix in error path Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 61/74] platform/x86: asus-wmi: Change ASUS_WMI_BRN_DOWN code from 0x20 to 0x2e Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 62/74] platform/mellanox: mlxbf-tmfifo: Fix a warning message Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 63/74] net: chelsio: cxgb4: add an error code check in t4_load_phy_fw Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 64/74] ata: ahci: fix enum constants for gcc-13 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 65/74] remove the sx8 block driver Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 66/74] nvmet-tcp: move send/recv error handling in the send/recv methods instead of call-sites Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 67/74] nvmet-tcp: Fix a possible UAF in queue intialization setup Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 68/74] Revert "ARM: dts: Move am33xx and am43xx mmc nodes to sdhci-omap driver" Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 69/74] PCI: Prevent xHCI driver from claiming AMD VanGogh USB3 DRD device Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 70/74] usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 71/74] tty: 8250: Remove UC-257 and UC-431 Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 72/74] tty: 8250: Add support for additional Brainboxes UC cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 73/74] tty: 8250: Add support for Brainboxes UP cards Greg Kroah-Hartman
2023-11-06 13:04 ` [PATCH 5.4 74/74] tty: 8250: Add support for Intashield IS-100 Greg Kroah-Hartman
2023-11-06 17:32 ` [PATCH 5.4 00/74] 5.4.260-rc1 review Florian Fainelli
2023-11-07 11:42 ` Jon Hunter
2023-11-07 15:31 ` Harshit Mogalapalli
2023-11-07 15:51 ` Shuah Khan
2023-11-07 18:26 ` Naresh Kamboju
2023-11-07 18:53 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231106130303.136739845@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=byungchul.park@lge.com \
--cc=jdamato@fastly.com \
--cc=jpoimboe@kernel.org \
--cc=nathan@kernel.org \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).