arm: testsuite: improve detection of CMSE hardware.

The test for CMSE support being available in hardware currently
relies on the compiler not optimizing away a secure gateway operation.
But even that is suspect, because the SG instruction is just a NOP
on armv8-m implementations that do not support the security extension.

Replace the existing test with a new one that reads and checks
the appropriate hardware feature register (memory mapped).  This has
to be run from secure mode, but that shouldn't matter, because if we
can't do that we can't really test the CMSE extensions anyway.  We
retain the SG instruction to ensure the test can't pass accidentally
if run on pre-armv8-m devices.

gcc/testsuite:
	* lib/target-supports.exp (check_effective_target_arm_cmse_hw):
	New function.

(cherry picked from commit 79fb2700bd)
This commit is contained in:
Richard Earnshaw 2021-06-18 17:13:04 +01:00
parent 931d1c208a
commit e5b56e8058

View File

@ -4861,6 +4861,23 @@ proc check_effective_target_arm_cmse_ok {} {
} "-mcmse"];
}
# Return 1 if the target supports executing CMSE instructions, 0
# otherwise. Cache the result.
proc check_effective_target_arm_cmse_hw { } {
return [check_runtime arm_cmse_hw_available {
int main (void)
{
unsigned id_pfr1;
asm ("ldr\t%0, =0xe000ed44\n" \
"ldr\t%0, [%0]\n" \
"sg" : "=l" (id_pfr1));
/* Exit with code 0 iff security extension is available. */
return !(id_pfr1 & 0xf0);
}
} "-mcmse"]
}
# Return 1 if the target supports executing MVE instructions, 0
# otherwise.