* [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries
@ 2026-07-14 9:19 Hsin-Te Yuan
2026-07-16 7:44 ` Tzung-Bi Shih
0 siblings, 1 reply; 4+ messages in thread
From: Hsin-Te Yuan @ 2026-07-14 9:19 UTC (permalink / raw)
To: Tzung-Bi Shih, Brian Norris, Julius Werner
Cc: chrome-platform, linux-kernel, Yidi Lin, Hsin-Te Yuan
From: Yidi Lin <yidilin@google.com>
On ARM64 platforms, certain reserved memory regions (like those used
by pKVM) are marked with the 'no-map' property. This indicates that
the host kernel is forbidden from creating a structural mapping for
these regions.
The coreboot table may describe CBMEM entries that overlap with or are
entirely contained within these no-map regions. Attempting to populate
these entries as devices and subsequently remapping them can lead to
system crashes or security violations.
Refine the coreboot table population logic to verify that each CBMEM
entry resides in 'Known Good' memory before creating a device. An
entry is only considered safe if it is entirely System RAM or entirely
standard Reserved memory (tagged with IORES_DESC_RESERVED).
This dual-check ensures that:
1. ARM64 no-map regions are correctly filtered out (as they are
neither System RAM nor tagged with the x86 reserved descriptor).
2. Standard reserved regions on x86 Chromebooks remain supported.
3. Mixed regions containing holes are safely skipped.
Signed-off-by: Yidi Lin <yidilin@google.com>
Signed-off-by: Hsin-Te Yuan <yuanhsinte@chromium.org>
---
drivers/firmware/google/coreboot_table.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index e63933ff6747..f7357ed047e4 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -13,8 +13,10 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/device-id/coreboot.h>
+#include <linux/mm.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -123,7 +125,7 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
ptr_end = ptr + len;
ptr_entry = ptr + header->header_bytes;
- for (i = 0; i < header->table_entries; i++) {
+ for (i = 0; i < header->table_entries; i++, ptr_entry += entry->size) {
if (ptr_entry + sizeof(*entry) > ptr_end)
return -EINVAL;
entry = ptr_entry;
@@ -147,6 +149,23 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
switch (device->entry.tag) {
case LB_TAG_CBMEM_ENTRY:
+ /*
+ * Skip entries that are not exclusively System RAM or
+ * Reserved memory.
+ * On ARM, no-map reserved regions are not System RAM.
+ * On x86, CBMEM often resides in IORES_DESC_RESERVED regions.
+ */
+ if (region_intersects(device->cbmem_entry.address,
+ device->cbmem_entry.entry_size,
+ IORESOURCE_SYSTEM_RAM,
+ IORES_DESC_NONE) != REGION_INTERSECTS &&
+ region_intersects(device->cbmem_entry.address,
+ device->cbmem_entry.entry_size,
+ IORESOURCE_MEM,
+ IORES_DESC_RESERVED) != REGION_INTERSECTS) {
+ kfree(device);
+ continue;
+ }
dev_set_name(&device->dev, "cbmem-%08x",
device->cbmem_entry.id);
break;
@@ -155,8 +174,6 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
break;
}
- ptr_entry += entry->size;
-
ret = device_register(&device->dev);
if (ret) {
dev_warn(dev, "failed to register coreboot device: %d\n", ret);
---
base-commit: 3b029c035b34bbc693405ddf759f0e9b920c27f1
change-id: 20260714-coreboot-41aca4c383bc
Best regards,
--
Hsin-Te Yuan <yuanhsinte@chromium.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries
2026-07-14 9:19 [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries Hsin-Te Yuan
@ 2026-07-16 7:44 ` Tzung-Bi Shih
2026-07-17 7:23 ` Hsin-Te Yuan
0 siblings, 1 reply; 4+ messages in thread
From: Tzung-Bi Shih @ 2026-07-16 7:44 UTC (permalink / raw)
To: Hsin-Te Yuan
Cc: Brian Norris, Julius Werner, chrome-platform, linux-kernel,
Yidi Lin
On Tue, Jul 14, 2026 at 09:19:18AM +0000, Hsin-Te Yuan wrote:
> @@ -147,6 +149,23 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
>
> switch (device->entry.tag) {
> case LB_TAG_CBMEM_ENTRY:
> + /*
> + * Skip entries that are not exclusively System RAM or
> + * Reserved memory.
> + * On ARM, no-map reserved regions are not System RAM.
> + * On x86, CBMEM often resides in IORES_DESC_RESERVED regions.
> + */
> + if (region_intersects(device->cbmem_entry.address,
> + device->cbmem_entry.entry_size,
> + IORESOURCE_SYSTEM_RAM,
> + IORES_DESC_NONE) != REGION_INTERSECTS &&
> + region_intersects(device->cbmem_entry.address,
> + device->cbmem_entry.entry_size,
> + IORESOURCE_MEM,
> + IORES_DESC_RESERVED) != REGION_INTERSECTS) {
Per comments of region_intersects():
Note that REGION_INTERSECTS is also returned in the case when the
specified region overlaps RAM and undefined memory holes.
Won't the check falsely be bypassed if the region overlaps SYSTEM_RAM
and `no-map` memory?
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries
2026-07-16 7:44 ` Tzung-Bi Shih
@ 2026-07-17 7:23 ` Hsin-Te Yuan
2026-07-17 7:59 ` Tzung-Bi Shih
0 siblings, 1 reply; 4+ messages in thread
From: Hsin-Te Yuan @ 2026-07-17 7:23 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: Hsin-Te Yuan, Brian Norris, Julius Werner, chrome-platform,
linux-kernel, Yidi Lin
On Thu, Jul 16, 2026 at 3:44 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> On Tue, Jul 14, 2026 at 09:19:18AM +0000, Hsin-Te Yuan wrote:
> > @@ -147,6 +149,23 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
> >
> > switch (device->entry.tag) {
> > case LB_TAG_CBMEM_ENTRY:
> > + /*
> > + * Skip entries that are not exclusively System RAM or
> > + * Reserved memory.
> > + * On ARM, no-map reserved regions are not System RAM.
> > + * On x86, CBMEM often resides in IORES_DESC_RESERVED regions.
> > + */
> > + if (region_intersects(device->cbmem_entry.address,
> > + device->cbmem_entry.entry_size,
> > + IORESOURCE_SYSTEM_RAM,
> > + IORES_DESC_NONE) != REGION_INTERSECTS &&
> > + region_intersects(device->cbmem_entry.address,
> > + device->cbmem_entry.entry_size,
> > + IORESOURCE_MEM,
> > + IORES_DESC_RESERVED) != REGION_INTERSECTS) {
>
> Per comments of region_intersects():
> Note that REGION_INTERSECTS is also returned in the case when the
> specified region overlaps RAM and undefined memory holes.
>
> Won't the check falsely be bypassed if the region overlaps SYSTEM_RAM
> and `no-map` memory?
Just discussed this with Yidi Lin.
It seems that 'no-map' region will be marked as IORESOURCE_MEM instead
of undefined memory holes
(See arch/arm64/kernel/setup.c:request_standard_resources). If a cbmem
entry contains a real memory
hole, it is likely a coreboot bug.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries
2026-07-17 7:23 ` Hsin-Te Yuan
@ 2026-07-17 7:59 ` Tzung-Bi Shih
0 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2026-07-17 7:59 UTC (permalink / raw)
To: Hsin-Te Yuan
Cc: Brian Norris, Julius Werner, chrome-platform, linux-kernel,
Yidi Lin
On Fri, Jul 17, 2026 at 03:23:30PM +0800, Hsin-Te Yuan wrote:
> On Thu, Jul 16, 2026 at 3:44 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
> >
> > On Tue, Jul 14, 2026 at 09:19:18AM +0000, Hsin-Te Yuan wrote:
> > > @@ -147,6 +149,23 @@ static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_
> > >
> > > switch (device->entry.tag) {
> > > case LB_TAG_CBMEM_ENTRY:
> > > + /*
> > > + * Skip entries that are not exclusively System RAM or
> > > + * Reserved memory.
> > > + * On ARM, no-map reserved regions are not System RAM.
To be specific,
On ARM, no-map reserved regions are IORESOURCE_MEM.
> > > + * On x86, CBMEM often resides in IORES_DESC_RESERVED regions.
> > > + */
> > > + if (region_intersects(device->cbmem_entry.address,
> > > + device->cbmem_entry.entry_size,
> > > + IORESOURCE_SYSTEM_RAM,
> > > + IORES_DESC_NONE) != REGION_INTERSECTS &&
> > > + region_intersects(device->cbmem_entry.address,
> > > + device->cbmem_entry.entry_size,
> > > + IORESOURCE_MEM,
> > > + IORES_DESC_RESERVED) != REGION_INTERSECTS) {
> >
> > Per comments of region_intersects():
> > Note that REGION_INTERSECTS is also returned in the case when the
> > specified region overlaps RAM and undefined memory holes.
> >
> > Won't the check falsely be bypassed if the region overlaps SYSTEM_RAM
> > and `no-map` memory?
>
> Just discussed this with Yidi Lin.
> It seems that 'no-map' region will be marked as IORESOURCE_MEM instead
> of undefined memory holes
> (See arch/arm64/kernel/setup.c:request_standard_resources). If a cbmem
> entry contains a real memory
> hole, it is likely a coreboot bug.
I see.
Please rephrase the commit message and code comment to be clear. E.g.:
1. On ARM64, no-map regions are filtered out as they are IORESOURCE_MEM
(See arch/arm64/kernel/setup.c:request_standard_resources).
2. On X86, standard reserved regions (IORES_DESC_RESERVED) ...
3. Mixed regions containing holes are safely skipped.
Remove it as this is inaccurate (the patch can't skip holes).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-17 7:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 9:19 [PATCH] firmware: google: coreboot_table: skip no-map CBMEM entries Hsin-Te Yuan
2026-07-16 7:44 ` Tzung-Bi Shih
2026-07-17 7:23 ` Hsin-Te Yuan
2026-07-17 7:59 ` Tzung-Bi Shih
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.