summaryrefslogtreecommitdiff
path: root/src/cpu/x86
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2022-04-11 18:58:09 +0200
committerArthur Heymans <arthur@aheymans.xyz>2022-06-01 09:48:37 +0000
commit4ed22601369d074425a43d2077ff84ab4b328d51 (patch)
tree886d490b87d436c76f67765ebe63948f0bde870a /src/cpu/x86
parentd99a311a8a2517672395498a67d6b870a8f172b8 (diff)
cpu/x86/mtrr: Allow for multiple TEMP MTRR ranges
Temporary MTRR setup usually covers 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. This now allows up to 10 temporary memory ranges. TESTED: Qemu with multiple MTRR temporary MTRR ranges sets up a valid and optimized temporary MTRR solution. Change-Id: I23442bd2ab7602e4c5cbd37d187a31413cf27ecc Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63555 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src/cpu/x86')
-rw-r--r--src/cpu/x86/mtrr/mtrr.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/cpu/x86/mtrr/mtrr.c b/src/cpu/x86/mtrr/mtrr.c
index d8903b89e0..d1098d988f 100644
--- a/src/cpu/x86/mtrr/mtrr.c
+++ b/src/cpu/x86/mtrr/mtrr.c
@@ -9,6 +9,7 @@
*/
#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#include <bootstate.h>
#include <commonlib/helpers.h>
@@ -873,6 +874,28 @@ void mtrr_use_temp_range(uintptr_t begin, size_t size, int type)
struct memranges addr_space;
const int above4gb = 1; /* Cover above 4GiB by default. */
int address_bits;
+ static struct temp_range {
+ uintptr_t begin;
+ size_t size;
+ int type;
+ } temp_ranges[10];
+
+ if (size == 0)
+ return;
+
+ int i;
+ for (i = 0; i < ARRAY_SIZE(temp_ranges); i++) {
+ if (temp_ranges[i].size == 0) {
+ temp_ranges[i].begin = begin;
+ temp_ranges[i].size = size;
+ temp_ranges[i].type = type;
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(temp_ranges)) {
+ printk(BIOS_ERR, "Out of temporary ranges for MTRR use\n");
+ return;
+ }
/* Make a copy of the original address space and tweak it with the
* provided range. */
@@ -891,7 +914,11 @@ void mtrr_use_temp_range(uintptr_t begin, size_t size, int type)
}
/* Place new range into the address space. */
- memranges_insert(&addr_space, begin, size, type);
+ for (i = 0; i < ARRAY_SIZE(temp_ranges); i++) {
+ if (temp_ranges[i].size != 0)
+ memranges_insert(&addr_space, temp_ranges[i].begin,
+ temp_ranges[i].size, temp_ranges[i].type);
+ }
print_physical_address_space(&addr_space, "TEMPORARY");