AGESA boards: Fix regressions with LATE_CBMEM_INIT

Some configurations of AGESA boards fail to boot after commit
  61be360 AGESA: Fix UMA calculations

Implementation of cbmem_find() for ENV_ROMSTAGE expects
that CBMEM has already been initialized. In the case of
LATE_CBMEM_INIT boards, this is not the case and cbmem_top()
returned NULL prior to the offending commmit.

By definition LATE_CBMEM_INIT does not have known cbmem_top()
in ENV_ROMSTAGE except for possible ACPI S3 resume path.

Change-Id: Icb8f44661d479e5ad43b123600305dcbc3ce11e1
Signed-off-by: Kyösti Mälkki <>
Tested-by: build bot (Jenkins) <>
Reviewed-by: Paul Menzel <>
Reviewed-by: Martin Roth <>
Reviewed-by: Aaron Durbin <>
diff --git a/src/arch/x86/cbmem.c b/src/arch/x86/cbmem.c
index 57ed83b..6a353bd 100644
--- a/src/arch/x86/cbmem.c
+++ b/src/arch/x86/cbmem.c
@@ -45,6 +45,10 @@
 /* Top of CBMEM is at highest usable DRAM address below 4GiB. */
 uintptr_t __attribute__((weak)) restore_cbmem_top(void)
+		if (!acpi_is_wakeup_s3())
+			return 0;
 	return restore_top_of_low_cacheable();