UPSTREAM: vboot: Disallow separate verstage after romstage, try to clarify logic

No board has ever tried to combine CONFIG_SEPARATE_VERSTAGE with
CONFIG_VBOOT_STARTS_IN_ROMSTAGE. There are probably many reasons why
this wouldn't work (e.g. x86 CAR migration logic currently always
assumes verstage code to run pre-migration). It would also not really
make sense: the reason we use separate verstages is to decrease
bootblock size (mitigating the boot speed cost of slow boot ROM SPI
drivers) and to allow the SRAM-saving RETURN_FROM_VERSTAGE trick,
neither of which would apply to the after-romstage case. It is better to
just forbid that case explicitly and give programmers more guarantees
about what the verstage is (e.g. now the assumption that it runs pre-RAM
is always valid).

Since Kconfig dependencies aren't always guaranteed in the face of
'select' statements, also add some explicit compile-time assertions to
the vboot code. We can simplify some of the loader logic which now no
longer needs to provide for the forbidden case. In addition, also try to
make some of the loader logic more readable by writing it in a more
functional style that allows us to put more assertions about which cases
should be unreachable in there, which will hopefully make it more robust
and fail-fast with future changes (e.g. addition of new stages).

Change-Id: Ibf115ba8ac3238bb9f87cafbfde236cd4f555d11
Original-Change-Id: Iaf60040af4eff711d9b80ee0e5950ce05958b3aa
Original-Reviewed-on: https://review.coreboot.org/18983
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Original-Tested-by: build bot (Jenkins)
Original-Commit-Id: 73d042bd90
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/462013
This commit is contained in:
Julius Werner 2017-03-17 16:54:48 -07:00 committed by chrome-bot
commit 4c9d9eda02
3 changed files with 50 additions and 47 deletions

View file

@ -153,7 +153,10 @@
STR(Verstage exceeded its allotted size! (sz))); \
INCLUDE "verstage/lib/program.ld"
#define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) VERSTAGE(addr, size)
#define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) \
_ = ASSERT(IS_ENABLED(CONFIG_RETURN_FROM_VERSTAGE) == 1, \
"Must set RETURN_FROM_VERSTAGE to overlap romstage."); \
VERSTAGE(addr, size)
#else
#define VERSTAGE(addr, sz) \
REGION(verstage, addr, sz, 1)