driver/intel/fsp2_0: Disable NULL deref code when calling FSP

FSP needs interrupts disable so also disable generating exceptions
around debug registers.

Change-Id: Ia49dde68d45b71e231aaf32a0e6fd847f0e06146
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64426
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Uwe Poeche <uwe.poeche@siemens.com>
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c
index 4f95462..d6778b0 100644
--- a/src/drivers/intel/fsp2_0/memory_init.c
+++ b/src/drivers/intel/fsp2_0/memory_init.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
-#include <security/vboot/antirollback.h>
+#include <arch/null_breakpoint.h>
 #include <arch/symbols.h>
 #include <assert.h>
 #include <cbfs.h>
@@ -11,17 +11,18 @@
 #include <fsp/api.h>
 #include <fsp/util.h>
 #include <memrange.h>
+#include <mode_switch.h>
 #include <mrc_cache.h>
 #include <program_loading.h>
 #include <romstage_handoff.h>
+#include <security/tpm/tspi.h>
+#include <security/vboot/antirollback.h>
+#include <security/vboot/vboot_common.h>
 #include <string.h>
 #include <symbols.h>
 #include <timestamp.h>
-#include <security/vboot/vboot_common.h>
-#include <security/tpm/tspi.h>
-#include <vb2_api.h>
 #include <types.h>
-#include <mode_switch.h>
+#include <vb2_api.h>
 
 static uint8_t temp_ram[CONFIG_FSP_TEMP_RAM_SIZE] __aligned(sizeof(uint64_t));
 
@@ -293,6 +294,8 @@
 	fsp_raminit = (void *)(uintptr_t)(hdr->image_base + hdr->fsp_memory_init_entry_offset);
 	fsp_debug_before_memory_init(fsp_raminit, upd, &fspm_upd);
 
+	/* FSP disables the interrupt handler so remove debug exceptions temporarily  */
+	null_breakpoint_disable();
 	post_code(POST_FSP_MEMORY_INIT);
 	timestamp_add_now(TS_FSP_MEMORY_INIT_START);
 	if (ENV_X86_64 && CONFIG(PLATFORM_USES_FSP2_X86_32))
@@ -301,6 +304,7 @@
 						  (uintptr_t)fsp_get_hob_list_ptr());
 	else
 		status = fsp_raminit(&fspm_upd, fsp_get_hob_list_ptr());
+	null_breakpoint_init();
 
 	post_code(POST_FSP_MEMORY_EXIT);
 	timestamp_add_now(TS_FSP_MEMORY_INIT_END);