QEMU likes to have an MTRR set up, just like real machines. Add an MTRR which covers the total RAM size.
This does nothing on machines without MTRRs. Signed-off-by: Simon Glass <[email protected]> --- Changes in v2: - Add new patch to set an MTRR for the RAM in QEMU arch/x86/cpu/qemu/dram.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c index 62a301c0fd3..efacc7b3457 100644 --- a/arch/x86/cpu/qemu/dram.c +++ b/arch/x86/cpu/qemu/dram.c @@ -4,7 +4,9 @@ */ #include <init.h> +#include <spl.h> #include <asm/global_data.h> +#include <asm/mtrr.h> #include <asm/post.h> #include <asm/arch/qemu.h> #include <linux/sizes.h> @@ -40,10 +42,23 @@ u64 qemu_get_high_memory_size(void) int dram_init(void) { + int ret; + gd->ram_size = qemu_get_low_memory_size(); gd->ram_size += qemu_get_high_memory_size(); post_code(POST_DRAM); + if (xpl_phase() == PHASE_BOARD_F) { + ret = mtrr_add_request(MTRR_TYPE_WRBACK, 0, gd->ram_size); + if (ret != -ENOSYS) { + if (ret) + return log_msg_ret("mta", ret); + ret = mtrr_commit(false); + if (ret) + return log_msg_ret("mtc", ret); + } + } + return 0; } -- 2.43.0

