Skip to contentSkip to conversation

target/arm: add ARMv6-M UNDEFINED 32-bit instruction test

RFC In review Stefan Hajnoczi 2 participants 2 messages Nov 29, 2018 – Feb 28, 2019

lore
Share & tools
lore
#0 lore raw

RFC v3 1/1 target/arm: add ARMv6-M UNDEFINED 32-bit instruction test

Test that 32-bit instructions declared UNDEFINED in the ARMv6-M Reference Manual really do raise an exception. Also test that the 6 32-bit instructions defined in the ARMv6-M Reference Manual do not raise an exception.

The Intel HEX (.hex) file is included to save people the trouble of installing a cross-compiler toolchain.

To run the test (make sure qemu-system-arm is in your $PATH):

  $ cd tests/tcg/arm
  $ make run-test-armv6m-undef

Based-on: <[email protected]>

---
Note that this patch depends on "[PATCH] microbit: do not rely on -kernel option", which in turn depends on "[PATCH v3] tests/microbit-test: Check nRF51 UART functionality". I'd still appreciate review because I have yet to figure out a clean way to integrate this qemu-system-arm test into make check-tcg (which only supports linux-user targets!).

---
 tests/tcg/arm/Makefile              |  26 +++++
 tests/tcg/arm/test-armv6m-undef.S   | 154 ++++++++++++++++++++++++++++
 tests/tcg/arm/test-armv6m-undef.hex |  22 ++++
 tests/tcg/arm/test-armv6m-undef.ld  |  21 ++++
 4 files changed, 223 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile
 create mode 100644 tests/tcg/arm/test-armv6m-undef.S
 create mode 100644 tests/tcg/arm/test-armv6m-undef.hex
 create mode 100644 tests/tcg/arm/test-armv6m-undef.ld
tests/tcg/arm/Makefile new file +26 -0
new file mode 100644
index 0000000000..6923129b84
@@ -0,0 +1,26 @@
+-include ../../../config-host.mak
+
+CROSS = arm-linux-gnu-
+CC = $(CROSS)gcc
+OBJCOPY = $(CROSS)objcopy
+
+SIM = ../../../arm-softmmu/qemu-system-arm
+
+SOURCES = $(wildcard $(SRC_PATH)/tests/tcg/arm/*.S)
+BINARIES = $(patsubst %.S,%.hex,$(SOURCES))
+
+.PHONY: clean
+
+all: $(BINARIES)
+
+clean:
+	rm -f $(BINARIES) *.o
+
+%.o: %.S %.ld
+	$(CC) -nostdlib -Wl,--build-id=none -x assembler-with-cpp -T $(patsubst %.S,%.ld,$<) -x assembler-with-cpp -o $@ $<
+
+%.hex: %.o
+	$(OBJCOPY) -O ihex $< $@
+
+run-test-armv6m-undef: test-armv6m-undef.hex
+	$(SIM) -semihosting -M microbit -device loader,file=$<
tests/tcg/arm/test-armv6m-undef.S new file +154 -0

154 lines not on this page · raw message

tests/tcg/arm/test-armv6m-undef.hex new file +22 -0
new file mode 100644
index 0000000000..6a32548e3c
@@ -0,0 +1,22 @@
+:1000000000400020C1000000000000001D010000B1
+:1000100000000000000000000000000000000000E0
+:1000200000000000000000000000000000000000D0
+:1000300000000000000000000000000000000000C0
+:1000400000000000000000000000000000000000B0
+:1000500000000000000000000000000000000000A0
+:100060000000000000000000000000000000000090
+:100070000000000000000000000000000000000080
+:100080000000000000000000000000000000000070
+:100090000000000000000000000000000000000060
+:1000A0000000000000000000000000000000000050
+:1000B0000000000000000000000000000000000040
+:1000C00000E8000028E000E8008025E000F80000DB
+:1000D00022E000F800801FE000F000001CE0F0F7D4
+:1000E00000A019E080F3058800E015E0EFF305803B
+:1000F00000E011E000F000F800E00DE0BFF35F8FDA
+:1001000000E009E0BFF34F8F00E005E0BFF36F8F21
+:1001100000E001E0012005E0002003E00698063041
+:10012000069070470021012800D101491820ABBE7C
+:0401300026000200A3
+:04000003000000C138
+:00000001FF
tests/tcg/arm/test-armv6m-undef.ld new file +21 -0
new file mode 100644
index 0000000000..43dbbf17d5
@@ -0,0 +1,21 @@
+ENTRY(exc_reset_thumb)
+
+SECTIONS
+{
+    . = 0x0;
+    .text : {
+        *(.text)
+    }
+    .data : {
+        *(.data)
+    }
+    .rodata : {
+        *(.rodata)
+    }
+    .bss : {
+        *(.bss)
+    }
+    /DISCARD/ : {
+        *(.ARM.attributes)
+    }
+}
Signature · 1 line
2.19.1
#1 lore raw
Quoted 8 lines · Stefan Hajnoczi

Test that 32-bit instructions declared UNDEFINED in the ARMv6-M Reference Manual really do raise an exception. Also test that the 6 32-bit instructions defined in the ARMv6-M Reference Manual do not raise an exception.

The Intel HEX (.hex) file is included to save people the trouble of installing a cross-compiler toolchain.

Quoted 7 lines

To run the test (make sure qemu-system-arm is in your $PATH):

  $ cd tests/tcg/arm
  $ make run-test-armv6m-undef

Based-on: <[email protected]>

I'm snarfing this into my testing/enable-system-tcg-tests-v2 as I need a few more example system tests ;-)

--
Alex Bennée