mtrr: fix incorrect type detection

Message ID 1528916123-30139-1-git-send-email-alex.hung@canonical.com
State Accepted
Headers show
Series
  • mtrr: fix incorrect type detection
Related show

Commit Message

Alex Hung June 13, 2018, 6:55 p.m.
From: Stan Hung <Stan_Hung@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@Dell.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Alex Hung <alex.hung@canonical.com>

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

Patch

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