Commit 06bf3b15 authored by Richard Henderson's avatar Richard Henderson Committed by Peter Maydell
Browse files

tests/tcg/aarch64: Add pauth smoke test



Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Message-id: 20190201195404.30486-3-richard.henderson@linaro.org
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent bff63fbf
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -8,10 +8,14 @@ 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
run-pauth-%: QEMU += -cpu max

TESTS:=$(AARCH64_TESTS)
+23 −0
Original line number Diff line number Diff line
#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, 0, 0, 0);
    asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));

    assert(p1 != p0);
    assert(p1 != p2);
    return 0;
}