2 * Test ARMv6-M UNDEFINED 32-bit instructions
4 * Copyright 2018 Red Hat Inc.
6 * This work is licensed under the terms of the GNU GPL, version 2
7 * or later. See the COPYING file in the top-level directory.
11 * Test that UNDEFINED 32-bit instructions fault as expected. This is an
12 * interesting test because ARMv6-M shares code with its more fully-featured
13 * siblings and it's necessary to verify that its limited instruction set is
16 * The emulator must be invoked with -semihosting so that the test case can
17 * terminate with exit code 0 on success or 1 on failure.
19 * Failures can be debugged with -d in_asm,int,exec,cpu and the
30 #define SRAM_BASE 0x20000000
31 #define SRAM_SIZE (16 * 1024)
34 * Semihosting interface on ARM T32
35 * See "Semihosting for AArch32 and AArch64 Version 2.0 Documentation" by ARM
37 #define semihosting_call bkpt 0xab
41 .word SRAM_BASE + SRAM_SIZE /* 0. SP_main */
42 .word exc_reset_thumb /* 1. Reset */
44 .word exc_hard_fault_thumb /* 3. HardFault */
46 .word 0 /* 4-10. Reserved */
48 .word 0 /* 11. SVCall */
49 .word 0 /* 12. Reserved */
50 .word 0 /* 13. Reserved */
51 .word 0 /* 14. PendSV */
52 .word 0 /* 15. SysTick */
54 .word 0 /* 16-47. External Interrupts */
58 .equ exc_reset_thumb, exc_reset + 1
59 .global exc_reset_thumb
60 /* The following 32-bit UNDEFINED instructions are tested by executing
61 * them. The HardFault exception handler should execute and return to
62 * the next test case. If no exception is raised the test fails.
65 /* Table A5-9 32-bit Thumb encoding */
66 .short 0b1110100000000000
67 .short 0b0000000000000000
69 .short 0b1110100000000000
70 .short 0b1000000000000000
72 .short 0b1111100000000000
73 .short 0b0000000000000000
75 .short 0b1111100000000000
76 .short 0b1000000000000000
78 .short 0b1111000000000000
79 .short 0b0000000000000000
82 /* Table A5-10 Branch and miscellaneous control instructions */
83 .short 0b1111011111110000
84 .short 0b1010000000000000
87 /* The following are valid 32-bit instructions that must not raise a
91 /* B4.2.3 Move to Special Register (moves to IPSR are ignored) */
96 /* B4.2.2 Move from Special Register */
101 /* A6.7.13 Branch with Link (immediate) */
107 /* A6.7.21 Data Memory Barrier */
112 /* A6.7.22 Data Synchronization Barrier */
117 /* A6.7.24 Instruction Memory Barrier */
127 not_reached: /* Failure :( */
131 /* When a HardFault occurs, return to pc+6 (test cases are 3 halfwords long) */
133 .equ exc_hard_fault_thumb, exc_hard_fault + 1
134 .global exc_hard_fault_thumb
141 * exit: Terminate emulator
142 * @r0: 0 - failure, 1 - success
148 ldr r1, ADP_Stopped_ApplicationExit
153 ADP_Stopped_ApplicationExit: