From nobody Tue Apr 7 12:52:06 2026 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A845F3BE164 for ; Fri, 13 Mar 2026 16:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773418047; cv=none; b=MgspDsJbS3fJ18NU0+peuIn4DziFLLGa8vD3pZhzdbM5g65P8kGNI3Bfrrl6DENCwH80RugZTLDCpRw+5MM2AfKi2S0Clplb9iLo85k9FTt2QZLvDAKxV2tjKkaST+2taMXs8ZRQysz9Clhdl/vJXHG1REma+1VJNuYqXVaTjEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773418047; c=relaxed/simple; bh=ECkQNb3eCzal3WAJjRaDEW34t/R2ONA0tGGbLwPNcHY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ASwN9SNkDK2jNuj2RNZ825ogNfSw+qtUYgCeeyOkgB+iqfvU7vrunAcXpHY/k64svr8ceu0qU6YTS/iTlDIdegn08hDN4GD8MvP0ZjDDaDnbqCesqteMkhHc6MVTBmL/NrN/qp/hLJkD+pZz0rE794zP6IbhF4L+WBrZV6u2yRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=LpBoY2SE; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LpBoY2SE" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-b7cf4a975d2so318463566b.2 for ; Fri, 13 Mar 2026 09:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1773418044; x=1774022844; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6IuFt080J2Skvkbg1SWMG28SkMd4vofTIXNDcp/JD4o=; b=LpBoY2SEy8o39lQ4A4d2lVbk/q9d8HnWULUohXpuqBcAvlC+UMYBtuLbZVAxrrROFw yI0bddsqBrHWr6ymkG/xicHopsZmr3Ba3B1VIQpht+Jcf3p3k5zv3XQxjpXlaRU0/t+X xmK3sj7jTnqBcdH4CDxVt2WPQ4lGgayG2rN20= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773418044; x=1774022844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6IuFt080J2Skvkbg1SWMG28SkMd4vofTIXNDcp/JD4o=; b=Fl0GDkhbnMfDSzBY6GT1ECiFFTS+4+OMDTUPEaQ1rAQ9mS2IBjocd2Zhx8nMPSJI4x 9OWA5cE7F28m5DJZ3SaXgwmNtt/cFJ3uty2hfWN8ZeFE9cz0UU2Q4BM5pYlaWb9geTq+ tIFlnweLXOxNB+783mb9xoeNjO8h4RHLgPfHYuZxNs99axKCtPMkCzB7F5vpFCR1nBJz 7GP8CqO9hGHgiqwfAEgyR8ys+1o0TJUpISvfw8GAUKlzwjVdr7Supr5nu7EuQdoHCLC2 SV93cOanBH5+ei1wT7saA3PyITDVgkdnIZbptCn3vI9yYM6d1F2alWDsiWsJB3mzjdY6 WOjg== X-Forwarded-Encrypted: i=1; AJvYcCXPd3AKYDfy9sBK08WhdsYhArGsSNQxHyUQniB/iuuj3PHmgok0L/7nmiIyZq8KhE+Vs8Lt+c92nGyhNK4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw51hF3nhJ+t3xJmADecuPl/1hl94ijdGw3LeTqya2KIZVtSCEe QbXo3GpVZPnwe9PwKX7eqbFZ/1+8fba44oRhnb6Z69ITzlVaUwuDpMFxaDVK/7jmwQ== X-Gm-Gg: ATEYQzyOkTMpKzcsWZb7TlWEioDw2AWIEnUjI2P6BCHVTjb28OVg9TbK80vjgSMlAEu AmyJoV+YcOKLnBAmucX3rTQeuggrG39HLACi8eBZNGav+nR8gBwiNY5Baijjouc+4jPnU8SQUwd uySH2+MymNEHxO9faIP/Vmi/6pX8vTpi6l2DJGhZI2rung1f+/V5LWYZFBRmB3UTW/MBnklhd25 Tcm/QiqLAiOX4ZR3KCFcef2cSt+G1zSXu8v28K1C7JeyGnwOz1pPPuVfqwcgrjhz3iC2lfI46Zq McI0xqz6R9+IxB9q+11KQG08avbKBKoihTJn9wyf7hrn7HA0yYEJvnVI3Y4HpnjujSp954Px2Ya U9NhtfyIXj9lIiJHtyuC8NM1OpSjaQUz8gxiANnQWUzKfmODfAUuvOBefxi2ZNWc6FYE+7yKpI0 oGWx4G9TPMx+qOg5HVbmYoLw0L/yoiGeJ2KwjYk0yzoe8QVvK/mCxFG9n5S29QqHKtaph75WACp cIWNU3iUNoC X-Received: by 2002:a17:906:7953:b0:b97:73ae:e1f with SMTP id a640c23a62f3a-b9773ae1114mr133921566b.34.1773418043836; Fri, 13 Mar 2026 09:07:23 -0700 (PDT) Received: from jaz-virt.c.googlers.com.com (131.44.147.34.bc.googleusercontent.com. [34.147.44.131]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b976cba6ec4sm62749266b.5.2026.03.13.09.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 09:07:23 -0700 (PDT) From: Grzegorz Jaszczyk X-Google-Original-From: Grzegorz Jaszczyk To: tglx@linutronix.de, robh@kernel.org Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, saravanak@google.com, dmaluka@chromium.org, bgrzesik@google.com, jaszczyk@google.com, ilpo.jarvinen@linux.intel.com, usamaarif642@gmail.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, tnowicki@google.com, mazurekm@google.com, vineethrp@google.com, rppt@kernel.org, agordeev@linux.ibm.com, dyoung@redhat.com, myrrhperiwinkle@qtmlabs.xyz, guoweikang.kernel@gmail.com, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org, joel.granados@kernel.org, sourabhjain@linux.ibm.com Subject: [PATCH v4 2/2] x86/e820: reserve corresponding to DT reserved-memory nomap region Date: Fri, 13 Mar 2026 16:03:47 +0000 Message-ID: <20260313160347.2843005-3-jaszczyk@google.com> X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog In-Reply-To: <20260313160347.2843005-1-jaszczyk@google.com> References: <20260313160347.2843005-1-jaszczyk@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The DT reserved-memory nomap region shouldn't be mapped and registered as an IORESOURCE_SYSTEM_RAM resource. On the x86 platform the resource tree map is built based on e820 entries (via e820__reserve_resources()). Consequently memblock reservation originating from DT are not taken into account by x86 resource management unless they are explicitly injected into e820 table. Injecting the corresponding no-map into e820 table as 'E820_TYPE_RESERVED', ensures that the x86 architecture builds an accurate resource tree. This aligns x86 with how other architectures (like arm64 in request_standard_resources() during resource tree creation) protect DT no-map region. Adding a corresponding e820 entry also allows other parts of x86 early kernel initialization to rely on it. E.g. e820__setup_pci_gap based on the gap in the e820 memory table picks space and passes to the PCI subsystem. Without adding corresponding e820 reserved entry, DT reserved memory nomap region could conflict with such region assigned later to PCI subsystem. Additionally updating e820_table in this stage of the x86 setup seems safe since it is performed before mentioned e820__reserve_resources and e820__setup_pci_gap and there are also other functions, which updates e820 table on the later stage of early x86 setup such as early_quirks() and efi_arch_mem_reserve() (used by efi_esrt_init). Signed-off-by: Grzegorz Jaszczyk --- arch/x86/include/asm/e820/api.h | 1 + arch/x86/kernel/e820.c | 20 ++++++++++++++++++++ arch/x86/kernel/setup.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/ap= i.h index bbe0c8de976c..9568d88e8df8 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -27,6 +27,7 @@ extern unsigned long e820__end_of_low_ram_pfn(void); =20 extern u64 e820__memblock_alloc_reserved(u64 size, u64 align); extern void e820__memblock_setup(void); +extern void e820__reserve_nomap_region(void); =20 extern void e820__finish_early_params(void); extern void e820__reserve_resources(void); diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 2a9992758933..6f8a65dba7c7 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1374,3 +1374,23 @@ __init void e820__memblock_setup(void) =20 memblock_dump_all(); } + +void __init e820__reserve_nomap_region(void) +{ + struct memblock_region *region; + bool updated =3D false; + + for_each_mem_region(region) { + if (memblock_is_nomap(region)) { + /* + * Add corresponding e820 region and let + * e820__update_table sanitize e820 map + */ + e820__range_add(region->base, region->size, E820_TYPE_RESERVED); + updated =3D true; + } + } + + if (updated) + e820__update_table_print(); +} diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index cf6c93f8be1a..cbbc7abdabef 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1078,6 +1078,8 @@ void __init setup_arch(char **cmdline_p) =20 x86_flattree_get_config(); =20 + e820__reserve_nomap_region(); + /* * Needs to run after memblock setup because it needs the physical * memory size. --=20 2.53.0.851.ga537e3e6e9-goog