Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63555 )
Change subject: cpu/x86/mtrr.c: Allow for multiple TEMP MTRR ranges ......................................................................
cpu/x86/mtrr.c: Allow for multiple TEMP MTRR ranges
Temporary MTRR setup usually cover the memory mapped flash. On recent Intel hardware the mapping is not coherent. It uses an external window for parts of the BIOS region that exceed 16M. To cover both those regions it is necessary to not reset the temporary MTRR setup on each invocation of this function.
Change-Id: I23442bd2ab7602e4c5cbd37d187a31413cf27ecc Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/cpu/x86/mtrr/mtrr.c 1 file changed, 15 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/63555/1
diff --git a/src/cpu/x86/mtrr/mtrr.c b/src/cpu/x86/mtrr/mtrr.c index 89cac7f..f4cd72a 100644 --- a/src/cpu/x86/mtrr/mtrr.c +++ b/src/cpu/x86/mtrr/mtrr.c @@ -865,24 +865,28 @@ const struct range_entry *r; const struct memranges *orig; struct var_mtrr_solution sol; - struct memranges addr_space; + static struct memranges addr_space; + static first = true; const int above4gb = 1; /* Cover above 4GiB by default. */ int address_bits;
/* Make a copy of the original address space and tweak it with the * provided range. */ - memranges_init_empty(&addr_space, NULL, 0); - orig = get_physical_address_space(); - memranges_each_entry(r, orig) { - unsigned long tag = range_entry_tag(r); + if (first) { + memranges_init_empty(&addr_space, NULL, 0); + orig = get_physical_address_space(); + memranges_each_entry(r, orig) { + unsigned long tag = range_entry_tag(r);
- /* Remove any write combining MTRRs from the temporary - * solution as it just fragments the address space. */ - if (tag == MTRR_TYPE_WRCOMB) - tag = MTRR_TYPE_UNCACHEABLE; + /* Remove any write combining MTRRs from the temporary + * solution as it just fragments the address space. */ + if (tag == MTRR_TYPE_WRCOMB) + tag = MTRR_TYPE_UNCACHEABLE;
- memranges_insert(&addr_space, range_entry_base(r), - range_entry_size(r), tag); + memranges_insert(&addr_space, range_entry_base(r), + range_entry_size(r), tag); + } + first = false; }
/* Place new range into the address space. */