Skip to content
Snippets Groups Projects
Commit 488b8b24 authored by Duncan Laurie's avatar Duncan Laurie Committed by Simon Glass
Browse files

x86: Fix MTRR clear to detect which MTRR to use


Coreboot was always using MTRR 7 for the write-protect
cache entry that covers the ROM and U-boot was removing it.
However with 4GB configs we need more MTRRs for the BIOS
and so the WP MTRR needs to move.  Instead coreboot will
always use the last available MTRR that is normally set
aside for OS use and U-boot can clear it before the OS.

Signed-off-by: default avatarDuncan Laurie <dlaurie@chromium.org>
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent 300081aa
No related branches found
No related tags found
No related merge requests found
...@@ -94,6 +94,8 @@ void setup_pcat_compatibility() ...@@ -94,6 +94,8 @@ void setup_pcat_compatibility()
{ {
} }
#define MTRR_TYPE_WP 5
#define MTRRcap_MSR 0xfe
#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg)) #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1) #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
...@@ -101,11 +103,20 @@ int board_final_cleanup(void) ...@@ -101,11 +103,20 @@ int board_final_cleanup(void)
{ {
/* Un-cache the ROM so the kernel has one /* Un-cache the ROM so the kernel has one
* more MTRR available. * more MTRR available.
*
* Coreboot should have assigned this to the
* top available variable MTRR.
*/ */
disable_caches(); u8 top_mtrr = (native_read_msr(MTRRcap_MSR) & 0xff) - 1;
wrmsrl(MTRRphysBase_MSR(7), 0); u8 top_type = native_read_msr(MTRRphysBase_MSR(top_mtrr)) & 0xff;
wrmsrl(MTRRphysMask_MSR(7), 0);
enable_caches(); /* Make sure this MTRR is the correct Write-Protected type */
if (top_type == MTRR_TYPE_WP) {
disable_caches();
wrmsrl(MTRRphysBase_MSR(top_mtrr), 0);
wrmsrl(MTRRphysMask_MSR(top_mtrr), 0);
enable_caches();
}
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment