src/flashrom: allow nested regions
parent
5ed3f4cf89
commit
a6cd353a3e
@ -0,0 +1,45 @@
|
||||
From 5af5c5418f5335ab1c843f8ab6eb148d413d32a6 Mon Sep 17 00:00:00 2001
|
||||
From: Adam Joseph <adam@westernsemico.com>
|
||||
Date: Tue, 18 Oct 2022 15:47:41 -0700
|
||||
Subject: [PATCH 2/2] layout.c: allow nested regions
|
||||
|
||||
Many BIOSes have nested regions. For example, AGESA for KGPE-D16
|
||||
expects a BIOS region covering essentially the whole chip, which is
|
||||
used by SMM to protect the critical parts of the flash chip. This
|
||||
means that `flashrom --fmap` won't work with those images.
|
||||
|
||||
Let's adjust the overlapping-regions check to allow nested regions,
|
||||
where one region completely contains another region.
|
||||
---
|
||||
layout.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/layout.c b/layout.c
|
||||
index e688f79..072ab5f 100644
|
||||
--- a/layout.c
|
||||
+++ b/layout.c
|
||||
@@ -245,7 +245,7 @@ int process_include_args(struct flashrom_layout *l, const struct layout_include_
|
||||
return 0;
|
||||
}
|
||||
|
||||
-/* returns boolean 1 if any regions overlap, 0 otherwise */
|
||||
+/* returns boolean 1 if any regions overlap and neither fully contains the other, 0 otherwise */
|
||||
int included_regions_overlap(const struct flashrom_layout *const l)
|
||||
{
|
||||
const struct romentry *lhs = NULL;
|
||||
@@ -266,6 +266,12 @@ int included_regions_overlap(const struct flashrom_layout *const l)
|
||||
if (lhs->end < rhs->start)
|
||||
continue;
|
||||
|
||||
+ if (lhs->start <= rhs->start && lhs->end >= rhs->end)
|
||||
+ continue;
|
||||
+
|
||||
+ if (rhs->start <= lhs->start && rhs->end >= lhs->end)
|
||||
+ continue;
|
||||
+
|
||||
msg_gdbg("Regions %s [0x%08x-0x%08x] and %s [0x%08x-0x%08x] overlap\n",
|
||||
lhs->name, lhs->start, lhs->end, rhs->name, rhs->start, rhs->end);
|
||||
overlap_detected = 1;
|
||||
--
|
||||
2.37.2
|
||||
|
Loading…
Reference in New Issue