i386: Add avx512 state to reginfo_t
PATCH v2 1/1 i386: Add avx512 state to reginfo_t
The state expected for a given test must be specifically requested with the --xfeatures=mask command-line argument. This is recorded with the saved state so that it is obvious if the apprentice is given a different argument. Any features beyond what are present on the running cpu will read as zero.
---
More fiddling. This puts an --xfeature=mask argument on the command line that must agree the test case being tested. This requires somewhat deeper knowledge of the cpu than I would otherwise like, but I cannot disconnect this knowledge with that required for writing the test in the first place.
Usual values for mask are 3 (SSE), 7 (AVX), 0xe7 (AVX512), and well documented in the "Managing state using the XSAVE feature set" chapter of the Intel architecture manual.
Thoughts?
r~
--- risu_reginfo_i386.h | 14 +++ risu_reginfo_i386.c | 228 ++++++++++++++++++++++++++++++++++++++++++-- test_i386.S | 39 ++++++++ 3 files changed, 273 insertions(+), 8 deletions(-)
risu_reginfo_i386.h +14 -0
@@ -12,6 +12,10 @@#ifndef RISU_REGINFO_I386_H #define RISU_REGINFO_I386_H +struct avx512_reg { +uint64_t q[8 ]; +}; +/* * This is the data structure we pass over the socket. * It is a simplified and reduced subset of what can
@@ -19,7 +23,17 @@*/ struct reginfo {uint32_t faulting_insn; +uint32_t mxcsr; +uint64_t xfeatures; +gregset_t gregs; + +#ifdef __x86_64__ +struct avx512_reg vregs[32 ]; +#else +struct avx512_reg vregs[8 ]; +#endif +uint64_t kregs[8 ]; };/*
risu_reginfo_i386.c +220 -8
292 lines not on this page · raw message
test_i386.S +39 -0
@@ -12,6 +12,37 @@ /* A trivial test image for x86 */ /* Initialise the registers to avoid spurious mismatches */ + +#ifdef __x86_64__ +#define BASE %rax + lea 2f(%rip), BASE +#else +#define BASE %eax + call 1f +1: pop BASE + add $2f-1b, BASE +#endif + + movdqa 0(BASE), %xmm0 + movdqa 1*16(BASE), %xmm1 + movdqa 2*16(BASE), %xmm2 + movdqa 3*16(BASE), %xmm3 + movdqa 4*16(BASE), %xmm4 + movdqa 5*16(BASE), %xmm5 + movdqa 6*16(BASE), %xmm6 + movdqa 7*16(BASE), %xmm7 + +#ifdef __x86_64__ + movdqa 8*16(BASE), %xmm8 + movdqa 9*16(BASE), %xmm9 + movdqa 10*16(BASE), %xmm10 + movdqa 11*16(BASE), %xmm11 + movdqa 12*16(BASE), %xmm12 + movdqa 13*16(BASE), %xmm13 + movdqa 14*16(BASE), %xmm14 + movdqa 15*16(BASE), %xmm15 +#endif + xor %eax, %eax sahf /* init eflags */
@@ -39,3 +70,11 @@ /* exit test */ ud1 %ecx, %eax + + .p2align 16 +2: + .set i, 0 + .rept 256 + .byte i + .set i, i + 1 + .endr
Signature · 1 line
2.17.1
Looks fine to me. I suppose if I had written it, I would have included more comments and/or #define's to make some bits more obvious (all the magic constants look a bit scary until you read the Intel manual), but nevermind that.
I guess the other remaining part now is extending risugen to actually generate the test blobs.
-Jan
Quoted 23 lines · Richard Henderson
The state expected for a given test must be specifically requested with the --xfeatures=mask command-line argument. This is recorded with the saved state so that it is obvious if the apprentice is given a different argument. Any features beyond what are present on the running cpu will read as zero.
Signed-off-by Richard Henderson <[email protected]>---
More fiddling. This puts an --xfeature=mask argument on the command line that must agree the test case being tested. This requires somewhat deeper knowledge of the cpu than I would otherwise like, but I cannot disconnect this knowledge with that required for writing the test in the first place.
Usual values for mask are 3 (SSE), 7 (AVX),
0xe7(AVX512), and well documented in the "Managing state using the XSAVE feature set" chapter of the Intel architecture manual.Thoughts?
r~
Quoted 4 lines · Jan Bobek
Looks fine to me. I suppose if I had written it, I would have included more comments and/or #define's to make some bits more obvious (all the magic constants look a bit scary until you read the Intel manual), but nevermind that.
You're right that it absolutely cries for comments and constants. I usually don't know how to write those until I know what I am doing. In this case I really hadn't figured out what I wanted to do -- perhaps obvious for sending two different patches inside a couple of hours.
Quoted 2 lines
I guess the other remaining part now is extending risugen to actually generate the test blobs.
Yes. I gave that a read and think that you should need only simple extensions to the current infrastructure.
r~