All of lore.kernel.org
 help / color / mirror / Atom feed
From: <rs@ti.com>
To: <robertcnelson@gmail.com>, <ayush@beagleboard.org>,
	<Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,
	<trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,
	<ilias.apalodimas@linaro.org>
Cc: <u-boot@lists.denx.de>
Subject: [PATCHv4 4/6] efi_selftest_memory: check for duplicates first
Date: Mon, 20 Apr 2026 14:25:18 -0500	[thread overview]
Message-ID: <20260420192520.1444749-5-rs@ti.com> (raw)
In-Reply-To: <20260420192520.1444749-1-rs@ti.com>

From: Randolph Sapp <rs@ti.com>

Check for duplicate memory mappings before reporting any incorrect
attributes. Could be that second allocation has the correct type while
the first doesn't. Knowing there is a duplicate in this scenario is
more helpful than just reporting the first mismatch.

Signed-off-by: Randolph Sapp <rs@ti.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 lib/efi_selftest/efi_selftest_memory.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lib/efi_selftest/efi_selftest_memory.c b/lib/efi_selftest/efi_selftest_memory.c
index 4d32a280061..7320964c129 100644
--- a/lib/efi_selftest/efi_selftest_memory.c
+++ b/lib/efi_selftest/efi_selftest_memory.c
@@ -60,7 +60,7 @@ static int find_in_memory_map(efi_uintn_t map_size,
 			      u64 addr, int memory_type)
 {
 	efi_uintn_t i;
-	bool found = false;
+	struct efi_mem_desc *match = NULL;
 
 	for (i = 0; map_size; ++i, map_size -= desc_size) {
 		struct efi_mem_desc *entry = &memory_map[i];
@@ -72,24 +72,23 @@ static int find_in_memory_map(efi_uintn_t map_size,
 
 		if (addr >= entry->physical_start &&
 		    addr < entry->physical_start +
-			    (entry->num_pages << EFI_PAGE_SHIFT)) {
-			if (found) {
+				    (entry->num_pages << EFI_PAGE_SHIFT)) {
+			if (match) {
 				efi_st_error("Duplicate memory map entry\n");
 				return EFI_ST_FAILURE;
 			}
-			found = true;
-			if (memory_type != entry->type) {
-				efi_st_error
-					("Wrong memory type %d, expected %d\n",
-					 entry->type, memory_type);
-				return EFI_ST_FAILURE;
-			}
+			match = entry;
 		}
 	}
-	if (!found) {
+	if (!match) {
 		efi_st_error("Missing memory map entry\n");
 		return EFI_ST_FAILURE;
 	}
+	if (memory_type != match->type) {
+		efi_st_error("Wrong memory type %d, expected %d\n", match->type,
+			     memory_type);
+		return EFI_ST_FAILURE;
+	}
 	return EFI_ST_SUCCESS;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-04-20 19:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 19:25 [PATCHv4 0/6] various memory related fixups rs
2026-04-20 19:25 ` [PATCHv4 1/6] lmb: allocation flags macro documentation rs
2026-04-21 20:38   ` Simon Glass
2026-04-20 19:25 ` [PATCHv4 2/6] boot_fdt_add_mem_rsv_regions: free old dtb reservations rs
2026-04-21 20:40   ` Simon Glass
2026-04-21 22:14     ` Randolph Sapp
2026-04-21 22:54       ` Simon Glass
2026-04-21 22:55         ` Randolph Sapp
2026-04-20 19:25 ` [PATCHv4 3/6] efi_dt_fixup: use fdtdec_get_bool rs
2026-04-20 19:25 ` rs [this message]
2026-04-20 19:25 ` [PATCHv4 5/6] efi_mem_sort: use list_for_each_entry_safe instead rs
2026-04-20 19:25 ` [PATCHv4 6/6] memory: reserve from start_addr_sp to initial_relocaddr rs
2026-04-21 20:42   ` Simon Glass

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=20260420192520.1444749-5-rs@ti.com \
    --to=rs@ti.com \
    --cc=Erik.Welsh@octavosystems.com \
    --cc=afd@ti.com \
    --cc=anshuld@ti.com \
    --cc=ayush@beagleboard.org \
    --cc=bb@ti.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=robertcnelson@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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 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.