[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 19/21] tests/tcg/arm: account for pauth randomnes
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v4 19/21] tests/tcg/arm: account for pauth randomness |
Date: |
Tue, 12 Mar 2019 15:59:45 +0000 |
Pointer authentication isn't guaranteed to always detect a clash
between different keys. Take this into account in the test by running
several times and checking the percentage hit rate of the test.
Cc: Richard Henderson <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
---
tests/tcg/aarch64/pauth-1.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c
index ae6dc05c2b..a3c1443cd0 100644
--- a/tests/tcg/aarch64/pauth-1.c
+++ b/tests/tcg/aarch64/pauth-1.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <sys/prctl.h>
+#include <stdio.h>
asm(".arch armv8.4-a");
@@ -8,16 +9,29 @@ asm(".arch armv8.4-a");
#define PR_PAC_APDAKEY (1 << 2)
#endif
+#define TESTS 1000
+
int main()
{
- int x;
+ int x, i, count = 0;
void *p0 = &x, *p1, *p2;
+ float perc;
+
+ for (i = 0; i < TESTS; i++) {
+ asm volatile("pacdza %0" : "=r"(p1) : "0"(p0));
+ prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0);
+ asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));
- asm volatile("pacdza %0" : "=r"(p1) : "0"(p0));
- prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0);
- asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));
+ if (p1 != p0) {
+ count++;
+ }
+ if (p1 != p2) {
+ count++;
+ }
+ }
- assert(p1 != p0);
- assert(p1 != p2);
+ perc = (float) count / (float) (TESTS * 2);
+ printf("Ptr Check: %0.2f%%", perc * 100.0);
+ assert(perc > 0.95);
return 0;
}
--
2.20.1
- [Qemu-devel] [PATCH v4 01/21] tests/tcg: add softmmu awareness to Makefile, (continued)
- [Qemu-devel] [PATCH v4 01/21] tests/tcg: add softmmu awareness to Makefile, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 12/21] tests/tcg: split cris tests into bare and libc directories, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 13/21] tests/tcg/cris: comment out the ccs test, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 04/21] tests/tcg: split run-test into user and system variants, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 05/21] tests/tcg: add gdb runner variant, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 21/21] .travis.yml: add softmmu check-tcg tests, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 20/21] .travis.yml: separate softfloat from check-tcg, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 18/21] tests/tcg/i386: add memory test to exercise softmmu, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 15/21] tests/tcg: enable cris base user-mode tests, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 14/21] tests/tcg/cris: align mul operations, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 19/21] tests/tcg/arm: account for pauth randomness,
Alex Bennée <=
- [Qemu-devel] [PATCH v4 16/21] tests/tcg: provide a minilib for system tests, Alex Bennée, 2019/03/12
- [Qemu-devel] [PATCH v4 17/21] tests/tcg/i386: add system mode Hello World test, Alex Bennée, 2019/03/12