[PATCH] mtrr: fix incorrect type detection

Alex Hung alex.hung at canonical.com
Wed Jun 13 18:55:23 UTC 2018


From: Stan Hung <Stan_Hung at Dell.com>

cache_types() in mtrr.c trying to parse the memory range covered by MTRR.
If match, the "end" of the range will move to the the start of MTRR.

mtrr.c #234
  end = entry->start;

Ex:
  Memory 0x0000 ~ 0xFFFF
  MTRR   0x1000 ~ 0xFFFF WB
  MTRR   0x0000 ~ 0x0FFF WB

  In original flow, if we put this memory range into cache_types function.
  The first round check will update the range to 0x0000 ~ 0x1000
  Then it won't hit the 0x0000 ~ 0x0FFF MTRR and set the DEFAULT flag to
  identify the usage of default MTRR.

Signed-off-by: Stan Hung <Stan_Hung at Dell.com>
Acked-by: Colin Ian King <colin.king at canonical.com>
Acked-by: Alex Hung <alex.hung at canonical.com>

---
 src/bios/mtrr/mtrr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
index 50c8df9d..ecd6204e 100644
--- a/src/bios/mtrr/mtrr.c
+++ b/src/bios/mtrr/mtrr.c
@@ -231,7 +231,7 @@ restart:
 		entry = fwts_list_data(struct mtrr_entry*, item);
 
 		if (entry->end >= end && entry->start < end) {
-			end = entry->start;
+			end = (entry->start == 0) ? 0 : (entry->start - 1);
 			if (end < start)
 				end = start;
 			else
-- 
2.17.0.windows.1




More information about the fwts-devel mailing list