[Qemu-devel] [PATCH 6/6] tests/tcg/aarch64: Add pauth smoke tests

Richard Henderson posted 6 patches 6 years, 9 months ago
Maintainers: Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>, Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[Qemu-devel] [PATCH 6/6] tests/tcg/aarch64: Add pauth smoke tests
Posted by Richard Henderson 6 years, 9 months ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/aarch64/pauth-1.c       | 23 +++++++++++++++++++++++
 tests/tcg/aarch64/Makefile.target |  7 ++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 tests/tcg/aarch64/pauth-1.c

diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c
new file mode 100644
index 0000000000..9bd8d28ede
--- /dev/null
+++ b/tests/tcg/aarch64/pauth-1.c
@@ -0,0 +1,23 @@
+#include <assert.h>
+#include <sys/prctl.h>
+
+asm(".arch armv8.4-a");
+
+#ifndef PR_PAC_RESET_KEYS
+#define PR_PAC_RESET_KEYS  54
+#define PR_PAC_APDAKEY     (1 << 2)
+#endif
+
+int main()
+{
+    int x;
+    void *p0 = &x, *p1, *p2;
+
+    asm volatile("pacdza %0" : "=r"(p1) : "0"(p0));
+    prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY);
+    asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));
+
+    assert(p1 != p0);
+    assert(p1 != p2);
+    return 0;
+}
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 08c45b8470..e80d07276c 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -8,10 +8,15 @@ VPATH 		+= $(AARCH64_SRC)
 # we don't build any of the ARM tests
 AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
 AARCH64_TESTS+=fcvt
-TESTS:=$(AARCH64_TESTS)
 
 fcvt: LDFLAGS+=-lm
 
 run-fcvt: fcvt
 	$(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)")
 	$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
+
+AARCH64_TESTS += pauth-1
+pauth-%: CFLAGS += -O -g
+run-pauth-%: QEMU += -cpu max
+
+TESTS:=$(AARCH64_TESTS)
-- 
2.17.2


Re: [Qemu-devel] [PATCH 6/6] tests/tcg/aarch64: Add pauth smoke tests
Posted by Alex Bennée 6 years, 9 months ago
Richard Henderson <richard.henderson@linaro.org> writes:

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  tests/tcg/aarch64/pauth-1.c       | 23 +++++++++++++++++++++++
>  tests/tcg/aarch64/Makefile.target |  7 ++++++-
>  2 files changed, 29 insertions(+), 1 deletion(-)
>  create mode 100644 tests/tcg/aarch64/pauth-1.c
>
> diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c
> new file mode 100644
> index 0000000000..9bd8d28ede
> --- /dev/null
> +++ b/tests/tcg/aarch64/pauth-1.c
> @@ -0,0 +1,23 @@
> +#include <assert.h>
> +#include <sys/prctl.h>
> +
> +asm(".arch armv8.4-a");
> +
> +#ifndef PR_PAC_RESET_KEYS
> +#define PR_PAC_RESET_KEYS  54
> +#define PR_PAC_APDAKEY     (1 << 2)
> +#endif
> +
> +int main()
> +{
> +    int x;
> +    void *p0 = &x, *p1, *p2;
> +
> +    asm volatile("pacdza %0" : "=r"(p1) : "0"(p0));
> +    prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY);
> +    asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));
> +
> +    assert(p1 != p0);
> +    assert(p1 != p2);
> +    return 0;
> +}
> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
> index 08c45b8470..e80d07276c 100644
> --- a/tests/tcg/aarch64/Makefile.target
> +++ b/tests/tcg/aarch64/Makefile.target
> @@ -8,10 +8,15 @@ VPATH 		+= $(AARCH64_SRC)
>  # we don't build any of the ARM tests
>  AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
>  AARCH64_TESTS+=fcvt
> -TESTS:=$(AARCH64_TESTS)
>
>  fcvt: LDFLAGS+=-lm
>
>  run-fcvt: fcvt
>  	$(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)")
>  	$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
> +
> +AARCH64_TESTS += pauth-1
> +pauth-%: CFLAGS += -O -g

We build all tests with:

  CFLAGS+=-Wall -O0 -g -fno-strict-aliasing

mainly because the first thing you want to do when they fail is run them
through gdb to see what went wrong. Do you actually need optimisation on
for the build to work? Everything else looks good though:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> +run-pauth-%: QEMU += -cpu max
> +
> +TESTS:=$(AARCH64_TESTS)


--
Alex Bennée

Re: [Qemu-devel] [PATCH 6/6] tests/tcg/aarch64: Add pauth smoke tests
Posted by Richard Henderson 6 years, 9 months ago
On 1/28/19 3:06 AM, Alex Bennée wrote:
> We build all tests with:
> 
>   CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
> 
> mainly because the first thing you want to do when they fail is run them
> through gdb to see what went wrong. Do you actually need optimisation on
> for the build to work? Everything else looks good though:

I needed optimization for the MemTag test to work, and I copied that.
I'll remove it.


r~