Alex Bennée <alex.ben...@linaro.org> writes:
> This tests a bunch of registers that the kernel allows userspace to > read including the CPUID registers. > > Signed-off-by: Alex Bennée <alex.ben...@linaro.org> > --- > tests/tcg/aarch64/Makefile.target | 2 +- > tests/tcg/aarch64/sysregs.c | 99 +++++++++++++++++++++++++++++++ > 2 files changed, 100 insertions(+), 1 deletion(-) > create mode 100644 tests/tcg/aarch64/sysregs.c > > diff --git a/tests/tcg/aarch64/Makefile.target > b/tests/tcg/aarch64/Makefile.target > index 08c45b8470..cc1a7eb486 100644 > --- a/tests/tcg/aarch64/Makefile.target > +++ b/tests/tcg/aarch64/Makefile.target > @@ -7,7 +7,7 @@ VPATH += $(AARCH64_SRC) > > # we don't build any of the ARM tests > AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS)) > -AARCH64_TESTS+=fcvt > +AARCH64_TESTS+=fcvt sysregs > TESTS:=$(AARCH64_TESTS) > > fcvt: LDFLAGS+=-lm > diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c > new file mode 100644 > index 0000000000..177d1fe33b > --- /dev/null > +++ b/tests/tcg/aarch64/sysregs.c > @@ -0,0 +1,99 @@ > +/* > + * Check emulated system register access for linux-user mode. > + * > + * See: > https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt > + */ > + > +#include <asm/hwcap.h> > +#include <stdio.h> > +#include <sys/auxv.h> > +#include <signal.h> > +#include <string.h> > +#include <stdbool.h> > + <snip> > + > + /* when (getauxval(AT_HWCAP) & HWCAP_CPUID), since 4.11*/ > + if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { > + printf("CPUID registers unavailable\n"); > + return 1; > + } else { > + printf("Checking CPUID registers\n"); > + } Annoyingly this fails on qemu:debian-arm64-cross as it uses an older set of headers than my desktop cross environment: aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.3.0-16ubuntu3) 7.3.0 with the libc: Source: cross-toolchain-base (25ubuntu6) Version: 2.27-3ubuntu1cross1 Provides: libc6-arm64-dcv1 So I'm thinking an #ifndef HWCAP_CPUID and define it would be acceptable for a test case. -- Alex Bennée