Commit a3774fd5 authored by Jordan Yates's avatar Jordan Yates Committed by Stephanos Ioannidis
Browse files

arch: option to generate simplified error codes



Add an option to generate simplified error codes instead of more
specific architecture specific error codes. Enable this by default in
tests to make exception tests more generic across hardware.

Fixes #54053.

Signed-off-by: default avatarJordan Yates <jordan.yates@data61.csiro.au>
parent 817e41f9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -501,6 +501,18 @@ config EXTRA_EXCEPTION_INFO
	  register state, when a fault occurs. This information can be useful
	  to collect for post-mortem analysis and debug of issues.

config SIMPLIFIED_EXCEPTION_CODES
	bool "Convert arch specific exception codes to K_ERR_CPU_EXCEPTION"
	default y if ZTEST
	help
	  The same piece of faulty code (NULL dereference, etc) can result in
	  a multitude of potential exception codes at the CPU level, depending
	  upon whether addresses exist, an MPU is configured, the particular
	  implementation of the CPU or any number of other reasons. Enabling
	  this option collapses all the architecture specific exception codes
	  down to the generic K_ERR_CPU_EXCEPTION, which makes testing code
	  much more portable.

endmenu # Interrupt configuration

config INIT_ARCH_HW_AT_BOOT
+15 −1
Original line number Diff line number Diff line
@@ -194,8 +194,12 @@ bool z_arm_fault_undef_instruction(z_arch_esf_t *esf)
	/* Print fault information */
	LOG_ERR("***** UNDEFINED INSTRUCTION ABORT *****");

	uint32_t reason = IS_ENABLED(CONFIG_SIMPLIFIED_EXCEPTION_CODES) ?
			  K_ERR_CPU_EXCEPTION :
			  K_ERR_ARM_UNDEFINED_INSTRUCTION;

	/* Invoke kernel fatal exception handler */
	z_arm_fatal_error(K_ERR_ARM_UNDEFINED_INSTRUCTION, esf);
	z_arm_fatal_error(reason, esf);

	/* All undefined instructions are treated as fatal for now */
	return true;
@@ -223,6 +227,11 @@ bool z_arm_fault_prefetch(z_arch_esf_t *esf)
		reason = dump_fault(fs, ifar);
	}

	/* Simplify exception codes if requested */
	if (IS_ENABLED(CONFIG_SIMPLIFIED_EXCEPTION_CODES) && (reason >= K_ERR_ARCH_START)) {
		reason = K_ERR_CPU_EXCEPTION;
	}

	/* Invoke kernel fatal exception handler */
	z_arm_fatal_error(reason, esf);

@@ -290,6 +299,11 @@ bool z_arm_fault_data(z_arch_esf_t *esf)
		reason = dump_fault(fs, dfar);
	}

	/* Simplify exception codes if requested */
	if (IS_ENABLED(CONFIG_SIMPLIFIED_EXCEPTION_CODES) && (reason >= K_ERR_ARCH_START)) {
		reason = K_ERR_CPU_EXCEPTION;
	}

	/* Invoke kernel fatal exception handler */
	z_arm_fatal_error(reason, esf);

+4 −0
Original line number Diff line number Diff line
@@ -1124,6 +1124,10 @@ void z_arm_fault(uint32_t msp, uint32_t psp, uint32_t exc_return,
		esf_copy.basic.xpsr &= ~(IPSR_ISR_Msk);
	}

	if (IS_ENABLED(CONFIG_SIMPLIFIED_EXCEPTION_CODES) && (reason >= K_ERR_ARCH_START)) {
		reason = K_ERR_CPU_EXCEPTION;
	}

	z_arm_fatal_error(reason, &esf_copy);
}