From 8cdfd4cb2497f7feed08faf6609b6bd741773aa8 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 20 Apr 2023 13:25:13 +0200 Subject: soc/amd/common/cpu/noncar/early_cache: use get_top_of_mem_below_4gb Use get_top_of_mem_below_4gb instead of open-coding the functionality. Signed-off-by: Felix Held Change-Id: Icc9e5ad8954c6203fc4762aa976bba7e8ea16159 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74615 Tested-by: build bot (Jenkins) Reviewed-by: Jason Glenesk --- src/soc/amd/common/block/cpu/noncar/early_cache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/soc/amd/common/block/cpu/noncar/early_cache.c b/src/soc/amd/common/block/cpu/noncar/early_cache.c index 4bba172ed0de..2ff87601150b 100644 --- a/src/soc/amd/common/block/cpu/noncar/early_cache.c +++ b/src/soc/amd/common/block/cpu/noncar/early_cache.c @@ -20,7 +20,6 @@ */ void early_cache_setup(void) { - msr_t top_mem; msr_t sys_cfg; msr_t mtrr_def_type; msr_t fixed_mtrr_ram; @@ -34,7 +33,6 @@ void early_cache_setup(void) var_mtrr_context_init(&mtrr_ctx.ctx); mtrr_ctx.ctx.max_var_mtrrs = MIN(MAX_VAR_MTRR_USE, mtrr_ctx.ctx.max_var_mtrrs); - top_mem = rdmsr(TOP_MEM); /* Enable RdDram and WrDram attributes in fixed MTRRs. */ sys_cfg = rdmsr(SYSCFG_MSR); sys_cfg.lo |= SYSCFG_MSR_MtrrFixDramModEn; @@ -61,7 +59,8 @@ void early_cache_setup(void) wrmsr(SYSCFG_MSR, sys_cfg); - var_mtrr_set(&mtrr_ctx.ctx, 0, ALIGN_DOWN(top_mem.lo, 8 * MiB), MTRR_TYPE_WRBACK); + var_mtrr_set(&mtrr_ctx.ctx, 0, ALIGN_DOWN(get_top_of_mem_below_4gb(), 8 * MiB), + MTRR_TYPE_WRBACK); /* Always mark the 16 MByte right below the 4 GB boundary as WRPROT */ var_mtrr_set(&mtrr_ctx.ctx, FLASH_BELOW_4GB_MAPPING_REGION_BASE, FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT); -- cgit v1.2.3