RFC: Testing exceptions in tests/tcg/aarch64
cover RFC: Testing exceptions in tests/tcg/aarch64
In order to test the granule protection system meaningfully, we need to verify that certain memory accesses cause the correct exceptions. AFAIK, we do have system tests which boot kernels using GPC, but no finer grained tests for specific GPC behaviour.
So I've added the following example test of GPC. It uses a new vector table which can replace the one in boot.S with one which will record and ignore certain types of exception (data aborts and GPC exceptions).
The test itself (gpc-test.c) is not quite ready for submission yet, but I would like feedback on the mechanism used for verifying exceptions. (For example, if we do in fact have an existing way of testing exceptions.)
Once a mechanism for testing is in place, adding some more features (for example FEAT_RME_GPC3) should be relatively easy.
---
Jim MacArthur (3):
boot.S: Allocate minimal space for granule protection tables altvec.S: Alternative vector table for aarch64 testing gpc-test.c: Basic test for granule protection check.
tests/tcg/aarch64/Makefile.softmmu-target | 7 +- tests/tcg/aarch64/system/altvec.S | 129 ++++++++++++++++++++++++++++++ tests/tcg/aarch64/system/boot.S | 10 +++ tests/tcg/aarch64/system/gpc-test.c | 125 +++++++++++++++++++++++++++++ 4 files changed, 270 insertions(+), 1 deletion(-)
---
base-commit: ee7eb612be8f8886d48c1d0c1f1c65e495138f83
change-id: 20260508-jmac-gpctest-a7fa6aa90c78
Best regards,
Signature · 1 line
Jim MacArthur <[email protected]>
PATCH 1/3 boot.S: Allocate minimal space for granule protection tables
Allocates the minimum required space for granule protection tables, 8 bytes for stage 0 and 512KB for stage 1.
--- tests/tcg/aarch64/system/boot.S | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/tcg/aarch64/system/boot.S +10 -0
@@ -404,6 +404,16 @@ ttb_stage2: .space 4096, 0 .align 12 + .global realms_gpt0 + /* GPT stage 0 table */ +realms_gpt0: + .space 4096, 0 + .align 17 + .global realms_gpt1 + /* GPT stage 1 table, initialised to all 0xFF (full access) */ +realms_gpt1: + .space 524288, 0xFF + .align 12 system_stack: .space 4096, 0 system_stack_end:
Signature · 1 line
2.43.0
PATCH 2/3 altvec.S: Alternative vector table for aarch64 testing
In reply to Jim MacArthurSets up a potential replacement vector table which will record and ignore certain types of exception. Indicative values are recorded in 'exception_log'. Most exception types are handled in the same way as the table in boot.S.
--- tests/tcg/aarch64/Makefile.softmmu-target | 2 +- tests/tcg/aarch64/system/altvec.S | 129 ++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-)
tests/tcg/aarch64/Makefile.softmmu-target +1 -1
@@ -8,7 +8,7 @@ AARCH64_SYSTEM_SRC=$(AARCH64_SRC)/system VPATH+=$(AARCH64_SYSTEM_SRC) # These objects provide the basic boot code and helper functions for all tests -CRT_OBJS=boot.o +CRT_OBJS=boot.o altvec.o AARCH64_TEST_C_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c) AARCH64_TEST_S_SRCS=$(AARCH64_SYSTEM_SRC)/mte.S
tests/tcg/aarch64/system/altvec.S new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/3 gpc-test.c: Basic test for granule protection check.
In reply to Jim MacArthur* Sets up granule protection tablers
* Installs the alternative vector table
* Enables GPC
* Performs memory accesses in the protected region to check for allowed and disallowed reads.
--- tests/tcg/aarch64/Makefile.softmmu-target | 5 ++ tests/tcg/aarch64/system/gpc-test.c | 125 ++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+)
tests/tcg/aarch64/Makefile.softmmu-target +5 -0
@@ -71,6 +71,11 @@ QEMU_EL2_MACHINE=-machine virt,virtualization=on,gic-version=2 -cpu cortex-a57 - QEMU_EL2_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output,arg="2" run-vtimer: QEMU_OPTS=$(QEMU_EL2_MACHINE) $(QEMU_EL2_BASE_ARGS) -kernel +# gpc-test needs EL3 and RME +QEMU_EL3_MACHINE=-machine virt,virtualization=on,secure=on,gic-version=3 -cpu max,x-rme=on +QEMU_EL3_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output,arg="3" +run-gpc-test: QEMU_OPTS=$(QEMU_EL3_MACHINE) $(QEMU_EL3_BASE_ARGS) -kernel + # Simple Record/Replay Test .PHONY: memory-record run-memory-record: memory-record memory
tests/tcg/aarch64/system/gpc-test.c new file +125 -0
125 lines not on this page · raw message
Signature · 1 line
2.43.0