From 6fc12540fc8031740e93ba05bf307a00ee158088 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Sat, 14 May 2022 10:40:24 +0200 Subject: [PATCH] arch/x86/null_breakpoint: Remove handler before jumping to payload If a payload did any NULL dereferencing it would be broken and jump back to coreboot code. This fixes the SeaBIOS, FILO and possibly other payloads too. Fixes: 3f01cd14533f ("arch/x86: Add support for catching null dereferences through debug regs") TESTED on qemu/i440fx. Change-Id: I80f69b71f4d0fab3126e4b9f8c8dc7737b372174 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/64345 Reviewed-by: Robert Zieba Reviewed-by: Stefan Ott Reviewed-by: Paul Menzel Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- src/arch/x86/null_breakpoint.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/arch/x86/null_breakpoint.c b/src/arch/x86/null_breakpoint.c index 8b21a77cdc..dbb54aee2a 100644 --- a/src/arch/x86/null_breakpoint.c +++ b/src/arch/x86/null_breakpoint.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include #include +#include #include #include @@ -55,3 +56,12 @@ void null_breakpoint_init(void) create_deref_breakpoint(); create_instruction_breakpoint(); } + +static void null_breakpoint_disable(void *unused) +{ + breakpoint_remove(null_fetch_bp); + breakpoint_remove(null_deref_bp); +} + +BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, null_breakpoint_disable, NULL); +BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, null_breakpoint_disable, NULL);