summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2019-03-18 15:26:48 +0200
committerPatrick Georgi <pgeorgi@google.com>2019-03-27 08:26:16 +0000
commitf5cf60f25b8c77e0c90094e3326c5bc0e37cb383 (patch)
tree63967d01ebab0c1cdb41c58d4c52fea1d45616a4 /src/lib
parent12724d6ad6fd6ab0ca8ea5d258c0ca7cce807441 (diff)
downloadcoreboot-f5cf60f25b8c77e0c90094e3326c5bc0e37cb383.tar.xz
Move calls to quick_ram_check() before CBMEM init
After raminit completes, do a read-modify-write test just below CBMEM top address. If test fails, die(). Change-Id: I33d4153a5ce0908b8889517394afb46f1ca28f92 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31978 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/imd_cbmem.c5
-rw-r--r--src/lib/ramtest.c10
2 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index c458e5e3b1..1a67ad5be1 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -18,6 +18,7 @@
#include <console/console.h>
#include <cbmem.h>
#include <imd.h>
+#include <lib.h>
#include <stdlib.h>
#include <arch/early_variables.h>
@@ -119,6 +120,10 @@ static void cbmem_top_init_once(void)
return;
cbmem_top_init();
+
+ /* The test is only effective on X86 and when address hits UC memory. */
+ if (ENV_X86)
+ quick_ram_check_or_die((uintptr_t)cbmem_top() - sizeof(u32));
}
void cbmem_initialize_empty_id_size(u32 id, u64 size)
diff --git a/src/lib/ramtest.c b/src/lib/ramtest.c
index eb58c30fe5..489ca28d59 100644
--- a/src/lib/ramtest.c
+++ b/src/lib/ramtest.c
@@ -171,7 +171,10 @@ int ram_check_noprint_nodie(unsigned long start, unsigned long stop)
return failures;
}
-static void __quick_ram_check(uintptr_t dst)
+/* Assumption is 32-bit addressable UC memory at dst. This also executes
+ * on S3 resume path so target memory must be restored.
+ */
+void quick_ram_check_or_die(uintptr_t dst)
{
int fail = 0;
u32 backup;
@@ -200,8 +203,3 @@ static void __quick_ram_check(uintptr_t dst)
}
phys_memory_barrier();
}
-
-void quick_ram_check(void)
-{
- __quick_ram_check(0x100000);
-}