public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, David Hildenbrand <david@redhat.com>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Oscar Salvador <osalvador@suse.de>,
	Jianyong Wu <Jianyong.Wu@arm.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Vineet Gupta <vgupta@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Eric Biederman <ebiederm@xmission.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Shahab Vahedi <shahab@synopsys.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15 06/83] mm/memory_hotplug: handle memblock_add_node() failures in add_memory_resource()
Date: Mon, 18 Dec 2023 14:51:27 +0100	[thread overview]
Message-ID: <20231218135050.029727472@linuxfoundation.org> (raw)
In-Reply-To: <20231218135049.738602288@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand <david@redhat.com>

[ Upstream commit 53d38316ab2017a7c0d733765b521700aa357ec9 ]

Patch series "mm/memory_hotplug: full support for add_memory_driver_managed() with CONFIG_ARCH_KEEP_MEMBLOCK", v2.

Architectures that require CONFIG_ARCH_KEEP_MEMBLOCK=y, such as arm64,
don't cleanly support add_memory_driver_managed() yet.  Most
prominently, kexec_file can still end up placing kexec images on such
driver-managed memory, resulting in undesired behavior, for example,
having kexec images located on memory not part of the firmware-provided
memory map.

Teaching kexec to not place images on driver-managed memory is
especially relevant for virtio-mem.  Details can be found in commit
7b7b27214bba ("mm/memory_hotplug: introduce
add_memory_driver_managed()").

Extend memblock with a new flag and set it from memory hotplug code when
applicable.  This is required to fully support virtio-mem on arm64,
making also kexec_file behave like on x86-64.

This patch (of 2):

If memblock_add_node() fails, we're most probably running out of memory.
While this is unlikely to happen, it can happen and having memory added
without a memblock can be problematic for architectures that use
memblock to detect valid memory.  Let's fail in a nice way instead of
silently ignoring the error.

Link: https://lkml.kernel.org/r/20211004093605.5830-1-david@redhat.com
Link: https://lkml.kernel.org/r/20211004093605.5830-2-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Jianyong Wu <Jianyong.Wu@arm.com>
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Shahab Vahedi <shahab@synopsys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Stable-dep-of: c7206e7bd214 ("MIPS: Loongson64: Handle more memory types passed from firmware")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/memory_hotplug.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index bf611c55fc66b..bc52a9d201ea6 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1384,8 +1384,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 
 	mem_hotplug_begin();
 
-	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
-		memblock_add_node(start, size, nid);
+	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
+		ret = memblock_add_node(start, size, nid);
+		if (ret)
+			goto error_mem_hotplug_end;
+	}
 
 	ret = __try_online_node(nid, false);
 	if (ret < 0)
@@ -1458,6 +1461,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 		rollback_node_hotadd(nid);
 	if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
 		memblock_remove(start, size);
+error_mem_hotplug_end:
 	mem_hotplug_done();
 	return ret;
 }
-- 
2.43.0




  parent reply	other threads:[~2023-12-18 14:12 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 13:51 [PATCH 5.15 00/83] 5.15.144-rc1 review Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 01/83] perf/x86/uncore: Dont WARN_ON_ONCE() for a broken discovery table Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 02/83] r8152: add USB device driver for config selection Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 03/83] r8152: add vendor/device ID pair for D-Link DUB-E250 Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 04/83] r8152: add vendor/device ID pair for ASUS USB-C2500 Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 05/83] netfilter: nf_tables: fix exist matching on bigendian arches Greg Kroah-Hartman
2023-12-18 13:51 ` Greg Kroah-Hartman [this message]
2023-12-18 13:51 ` [PATCH 5.15 07/83] memblock: allow to specify flags with memblock_add_node() Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 08/83] MIPS: Loongson64: Handle more memory types passed from firmware Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 09/83] ksmbd: fix memory leak in smb2_lock() Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 10/83] afs: Fix refcount underflow from error handling race Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 11/83] HID: lenovo: Restrict detection of patched firmware only to USB cptkbd Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 12/83] net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 13/83] qca_debug: Prevent crash on TX ring changes Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 14/83] qca_debug: Fix ethtool -G iface tx behavior Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 15/83] qca_spi: Fix reset behavior Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 16/83] atm: solos-pci: Fix potential deadlock on &cli_queue_lock Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 17/83] atm: solos-pci: Fix potential deadlock on &tx_queue_lock Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 18/83] net: vlan: introduce skb_vlan_eth_hdr() Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 19/83] net: fec: correct queue selection Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 20/83] octeontx2-af: fix a use-after-free in rvu_nix_register_reporters Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 21/83] octeontx2-pf: Fix promisc mcam entry action Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 22/83] octeontx2-af: Update RSS algorithm index Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 23/83] atm: Fix Use-After-Free in do_vcc_ioctl Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 24/83] net/rose: Fix Use-After-Free in rose_ioctl Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 25/83] qed: Fix a potential use-after-free in qed_cxt_tables_alloc Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 26/83] net: Remove acked SYN flag from packet in the transmit queue correctly Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 27/83] net: ena: Destroy correct number of xdp queues upon failure Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 28/83] net: ena: Fix xdp drops handling due to multibuf packets Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 29/83] net: ena: Fix XDP redirection error Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 30/83] stmmac: dwmac-loongson: Make sure MDIO is initialized before use Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 31/83] sign-file: Fix incorrect return values check Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 32/83] vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space() Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 33/83] dpaa2-switch: fix size of the dma_unmap Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 34/83] net: stmmac: use dev_err_probe() for reporting mdio bus registration failure Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 35/83] net: stmmac: Handle disabled MDIO busses from devicetree Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 36/83] appletalk: Fix Use-After-Free in atalk_ioctl Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 37/83] net: atlantic: fix double free in ring reinit logic Greg Kroah-Hartman
2023-12-18 13:51 ` [PATCH 5.15 38/83] cred: switch to using atomic_long_t Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 39/83] fuse: dax: set fc->dax to NULL in fuse_dax_conn_free() Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 40/83] ALSA: hda/hdmi: add force-connect quirk for NUC5CPYB Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 41/83] ALSA: hda/hdmi: add force-connect quirks for ASUSTeK Z170 variants Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 42/83] ALSA: hda/realtek: Apply mute LED quirk for HP15-db Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 43/83] Revert "PCI: acpiphp: Reassign resources on bridge if necessary" Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 44/83] PCI: loongson: Limit MRRS to 256 Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 45/83] drm/mediatek: Add spinlock for setting vblank event in atomic_begin Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 46/83] usb: aqc111: check packet for fixup for true limit Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 47/83] stmmac: dwmac-loongson: Add architecture dependency Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 48/83] blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!" Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 49/83] blk-cgroup: bypass blkcg_deactivate_policy after destroying Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 50/83] bcache: avoid oversize memory allocation by small stripe_size Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 51/83] bcache: remove redundant assignment to variable cur_idx Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 52/83] bcache: add code comments for bch_btree_node_get() and __bch_btree_node_alloc() Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 53/83] bcache: avoid NULL checking to c->root in run_cache_set() Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 54/83] platform/x86: intel_telemetry: Fix kernel doc descriptions Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 55/83] HID: glorious: fix Glorious Model I HID report Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 56/83] HID: add ALWAYS_POLL quirk for Apple kb Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 57/83] HID: hid-asus: reset the backlight brightness level on resume Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 58/83] HID: multitouch: Add quirk for HONOR GLO-GXXX touchpad Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 59/83] asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 60/83] net: usb: qmi_wwan: claim interface 4 for ZTE MF290 Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 61/83] HID: hid-asus: add const to read-only outgoing usb buffer Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 62/83] perf: Fix perf_event_validate_size() lockdep splat Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 63/83] btrfs: do not allow non subvolume root targets for snapshot Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 64/83] soundwire: stream: fix NULL pointer dereference for multi_link Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 65/83] ext4: prevent the normalized size from exceeding EXT_MAX_BLOCKS Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 66/83] arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 67/83] team: Fix use-after-free when an option instance allocation fails Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 68/83] drm/amdgpu/sdma5.2: add begin/end_use ring callbacks Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 69/83] ring-buffer: Fix memory leak of free page Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 70/83] tracing: Update snapshot buffer on resize if it is allocated Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 71/83] ring-buffer: Do not update before stamp when switching sub-buffers Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 72/83] ring-buffer: Have saved event hold the entire event Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 73/83] ring-buffer: Fix writing to the buffer with max_data_size Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 74/83] ring-buffer: Fix a race in rb_time_cmpxchg() for 32 bit archs Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 75/83] ring-buffer: Do not try to put back write_stamp Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 76/83] USB: gadget: core: adjust uevent timing on gadget unbind Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 77/83] RDMA/irdma: Prevent zero-length STAG registration Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 78/83] powerpc/ftrace: Create a dummy stackframe to fix stack unwind Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 79/83] powerpc/ftrace: Fix stack teardown in ftrace_no_trace Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 80/83] ksmbd: Mark as BROKEN in the 5.15.y kernel Greg Kroah-Hartman
2023-12-18 15:54   ` Namjae Jeon
2023-12-19  7:47     ` Greg Kroah-Hartman
2023-12-19 11:20       ` Namjae Jeon
2023-12-18 13:52 ` [PATCH 5.15 81/83] r8152: avoid to change cfg for all devices Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 82/83] r8152: remove rtl_vendor_mode function Greg Kroah-Hartman
2023-12-18 13:52 ` [PATCH 5.15 83/83] r8152: fix the autosuspend doesnt work Greg Kroah-Hartman
2023-12-18 18:48 ` [PATCH 5.15 00/83] 5.15.144-rc1 review SeongJae Park
2023-12-19  0:00 ` Shuah Khan
2023-12-19  1:05 ` Kelsey Steele
2023-12-19  6:19 ` Harshit Mogalapalli
2023-12-19  9:05 ` Naresh Kamboju
2023-12-19 11:30 ` Jon Hunter
2023-12-19 19:22 ` Allen
2023-12-19 21:43 ` Florian Fainelli
2023-12-20  1:36 ` Ron Economos

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=20231218135050.029727472@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Jianyong.Wu@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=borntraeger@de.ibm.com \
    --cc=chenhuacai@kernel.org \
    --cc=david@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=geert@linux-m68k.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --cc=patches@lists.linux.dev \
    --cc=rppt@kernel.org \
    --cc=sashal@kernel.org \
    --cc=shahab@synopsys.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=vgupta@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