From e563815e059ef5881a42e6f8b37094783771d5a7 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sun, 9 Dec 2018 10:48:59 +0100 Subject: arch/x86/boot: Jump to payload in protected mode * On ARCH_RAMSTAGE_X86_64 jump to the payload in protected mode. * Add a helper function to jump to arbitrary code in protected mode, similar to the real mode call handler. * Doesn't affect existing x86_32 code. * Add a macro to cast pointer to uint32_t that dies if it would overflow on conversion Tested on QEMU Q35 using SeaBIOS as payload. Tested on Lenovo T410 with additional x86_64 patches. Change-Id: I6552ac30f1b6205e08e16d251328e01ce3fbfd14 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/30118 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/include/assert.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/include/assert.h') diff --git a/src/include/assert.h b/src/include/assert.h index 262b8cc761..944c67768a 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -80,4 +80,15 @@ extern void _dead_code_assertion_failed(void) __attribute__((noreturn)); *(type *)(uintptr_t)0; \ }) +#ifdef __x86_64__ +#define pointer_to_uint32_safe(x) ({ \ + if ((uintptr_t)(x) > 0xffffffffUL) \ + die("Cast from pointer to uint32_t overflows"); \ + (uint32_t)(uintptr_t)(x); \ +}) +#else +#define pointer_to_uint32_safe(x) ({ \ + (uint32_t)(uintptr_t)(x); \ +}) +#endif #endif // __ASSERT_H__ -- cgit v1.2.3