x86: support AVX10.1
cover x86: support AVX10.1
AVX10.1 is just a re-branding of certain AVX512 (sub)features, i.e. adds no new instructions. Therefore it's mostly relaxation that needs doing, plus dealing with the 256-bit-only case that AVX512 itself does not allow for. Luckily an unnecessary restriction on the mask register insns was taken out again, simplifying the actual emulator adjustments quite a bit.
While it probably can be rebased ahead, the series in this form depends on the previously submitted
[PATCH 0/4] x86emul: support further AVX extensions [PATCH v4 0/8] x86emul: misc additions
[PATCH v4 0/3] x86/CPUID: leaf pruning
I've tried to be very careful in rebasing ahead of AMX and KeyLocker patches I've been carrying, but almost all testing I've done is with all of those collectively in place.
1: x86/CPUID: enable AVX10 leaf
2: x86emul/test: rename "cp"
3: x86emul: introduce a struct cpu_policy * local in x86_emulate() 4: x86emul: support AVX10.1
5: x86emul/test: use simd_check_avx512*() in main()
6: x86emul/test: drop cpu_has_avx512vl
7: x86emul: AVX10.1 testing
8: x86emul/test: engage AVX512VL via command line option
Jan
PATCH 1/8 x86/CPUID: enable AVX10 leaf
This requires bumping the number of basic leaves we support. Apart from this the logic is modeled as closely as possible after that of leaf 7 handling.
---
The gen-cpuid.py adjustment is merely the minimum needed. It's not really clear to me whether someone turning off e.g. AVX512BW might then also validly expect AVX10 to be turned off.
Spec version 2 leaves unclear what the xstate components are which would need enabling for AVX10/256. recalculate_{xstate,misc}() are therefore conservative for now.
Do we want to synthesize AVX10 in the policy when all necessary AVX512* features are available, thus allowing migration from an AVX10 host to a suitable non-AVX10 one?
tools/misc/xen-cpuid.c +1 -1
@@ -230,7 +230,7 @@ static const char *const str_7d1[32] = [14] = "prefetchi", [15] = "user-msr", - [18] = "cet-sss", + [18] = "cet-sss", [19] = "avx10", }; static const char *const str_7d2[32] =
xen/arch/x86/cpu-policy.c +16 -1
@@ -221,7 +221,7 @@ static void recalculate_xstate(struct cp xstate_sizes[X86_XCR0_BNDCSR_POS]); } -if ( p->feat.avx512f ) +if ( p->feat.avx512f || (p->feat.avx10 && p->avx10.vsz512) ) { xstates |=X86_XCR0_OPMASK |X86_XCR0_ZMM |X86_XCR0_HI_ZMM ; xstate_size = max(xstate_size,
@@ -283,6 +283,16 @@ static void recalculate_misc(struct cpu_ p->basic.raw[0xc ] =EMPTY_LEAF ; +zero_leaves (p->basic.raw,0xe ,0x23 ); + + p->avx10.raw[0 ].b &=0x000700ff ; + p->avx10.raw[0 ].c = p->avx10.raw[0 ].d =0 ; +if ( !p->feat.avx10 || !p->avx10.version || !p->avx10.vsz512 ) + { + p->feat.avx10 = false; +memset (p->avx10.raw,0 ,sizeof (p->avx10.raw)); + } + p->extd.e1d &= ~CPUID_COMMON_1D_FEATURES ;/* Most of Power/RAS hidden from guests. */
@@ -800,6 +810,7 @@ void recalculate_cpuid_policy(struct dom p->basic.max_leaf =min (p->basic.max_leaf, max->basic.max_leaf); p->feat.max_subleaf =min (p->feat.max_subleaf, max->feat.max_subleaf); + p->avx10.max_subleaf =min (p->avx10.max_subleaf, max->avx10.max_subleaf); p->extd.max_leaf = 0x80000000U | min(p->extd.max_leaf & 0xffff, ((p->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON))
@@ -854,6 +865,8 @@ void recalculate_cpuid_policy(struct domif ( p->basic.max_leaf <XSTATE_CPUID )__clear_bit (X86_FEATURE_XSAVE , fs); +if ( p->basic.max_leaf <0x24 ) +__clear_bit (X86_FEATURE_AVX10 , fs);sanitise_featureset (fs);
@@ -967,6 +980,8 @@ static void __init __maybe_unused build_ sizeof(raw_cpu_policy.feat.raw));BUILD_BUG_ON (sizeof (raw_cpu_policy.xstate) !=sizeof (raw_cpu_policy.xstate.raw)); +BUILD_BUG_ON (sizeof (raw_cpu_policy.avx10) != +sizeof (raw_cpu_policy.avx10.raw));BUILD_BUG_ON (sizeof (raw_cpu_policy.extd) !=sizeof (raw_cpu_policy.extd.raw)); }
xen/arch/x86/cpuid.c +9 -0
@@ -87,6 +87,15 @@ void guest_cpuid(const struct vcpu *v, u *res =array_access_nospec (p->xstate.raw, subleaf);break ; +case 0x24 : +ASSERT (p->avx10.max_subleaf <ARRAY_SIZE (p->avx10.raw)); +if ( subleaf >min_t (uint32_t, p->avx10.max_subleaf, +ARRAY_SIZE (p->avx10.raw) -1 ) ) +return ; + + *res =array_access_nospec (p->avx10.raw, subleaf); +break ; +default : *res =array_access_nospec (p->basic.raw, leaf);break ;
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -321,6 +321,7 @@ XEN_CPUFEATURE(AVX_VNNI_INT16, 15*32 XEN_CPUFEATURE(PREFETCHI, 15*32+14) /*A PREFETCHIT{0,1} Instructions */ XEN_CPUFEATURE(USER_MSR, 15*32+15) /*s U{RD,WR}MSR Instructions */ XEN_CPUFEATURE(CET_SSS, 15*32+18) /* CET Supervisor Shadow Stacks safe to use */ +XEN_CPUFEATURE (AVX10 ,15 *32 +19 )/* AVX10 Converged Vector ISA */ /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */XEN_CPUFEATURE (RDCL_NO ,16 *32 +0 )/*A No Rogue Data Cache Load (Meltdown) */
xen/include/xen/lib/x86/cpu-policy.h +15 -1
@@ -85,11 +85,12 @@ unsigned int x86_cpuid_lookup_vendor(uin*/ const char *x86_cpuid_vendor_to_str (unsigned int vendor); -#define CPUID_GUEST_NR_BASIC (0xdu + 1) +#define CPUID_GUEST_NR_BASIC (0x24u + 1)#define CPUID_GUEST_NR_CACHE (5u + 1)#define CPUID_GUEST_NR_FEAT (2u + 1)#define CPUID_GUEST_NR_TOPO (1u + 1)#define CPUID_GUEST_NR_XSTATE (62u + 1) +#define CPUID_GUEST_NR_AVX10 (0u + 1)#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)#define CPUID_GUEST_NR_EXTD_AMD (0x21u + 1)#define CPUID_GUEST_NR_EXTD MAX(CPUID_GUEST_NR_EXTD_INTEL, \
@@ -255,6 +256,19 @@ struct cpu_policy } comp[CPUID_GUEST_NR_XSTATE ]; } xstate; +/* Structured AVX10 information leaf: 0x000000024[xx] */ +union { +struct cpuid_leaf raw[CPUID_GUEST_NR_AVX10 ]; +struct { +/* Subleaf 0. */ +uint32_t max_subleaf; + uint32_t version:8, :8; +bool vsz128:1 , vsz256:1 , vsz512:1 ; + uint32_t :13; + uint32_t /* c */:32, /* d */:32; + }; + } avx10; +/* Extended leaves: 0x800000xx */ union {struct cpuid_leaf raw[CPUID_GUEST_NR_EXTD ];
xen/lib/x86/cpuid.c +31 -0
@@ -123,6 +123,7 @@ void x86_cpu_policy_fill_native(struct cswitch ( i ) {case 0x4 :case 0x7 :case 0xb :case 0xd : +case 0x24 :/* Multi-invocation leaves. Deferred. */ continue ; }
@@ -216,6 +217,15 @@ void x86_cpu_policy_fill_native(struct c } } +if ( p->basic.max_leaf >=0x24 ) + { +cpuid_count_leaf (0x24 ,0 , &p->avx10.raw[0 ]); + +for ( i =1 ; i <=MIN (p->avx10.max_subleaf, +ARRAY_SIZE (p->avx10.raw) -1 ); ++i ) +cpuid_count_leaf (0x24 , i, &p->avx10.raw[i]); + } +/* Extended leaves. */ cpuid_leaf (0x80000000U , &p->extd.raw[0 ]); for ( i = 1; i <= MIN(p->extd.max_leaf & 0xffffU,
@@ -285,6 +295,9 @@ void x86_cpu_policy_clear_out_of_range_l ARRAY_SIZE(p->xstate.raw) - 1); } +if ( p->basic.max_leaf <0x24 ) +memset (p->avx10.raw,0 ,sizeof (p->avx10.raw)); + zero_leaves(p->extd.raw, ((p->extd.max_leaf >> 16) == 0x8000 ? (p->extd.max_leaf & 0xffff) + 1 : 0),
@@ -297,6 +310,8 @@ void __init x86_cpu_policy_bound_max_leamin_t (uint32_t, p->basic.max_leaf,ARRAY_SIZE (p->basic.raw) -1 ); p->feat.max_subleaf =min_t (uint32_t, p->feat.max_subleaf,ARRAY_SIZE (p->feat.raw) -1 ); + p->avx10.max_subleaf = +min_t (uint32_t, p->avx10.max_subleaf,ARRAY_SIZE (p->avx10.raw) -1 ); p->extd.max_leaf =0x80000000U |min_t (uint32_t, p->extd.max_leaf &0xffff ,ARRAY_SIZE (p->extd.raw) -1 ); }
@@ -324,6 +339,8 @@ void x86_cpu_policy_shrink_max_leaves(st*/ p->basic.raw[0xd ] = p->xstate.raw[0 ]; + p->basic.raw[0x24 ] = p->avx10.raw[0 ]; +for ( i = p->basic.max_leaf; i; --i )if ( p->basic.raw[i].a | p->basic.raw[i].b | p->basic.raw[i].c | p->basic.raw[i].d )
@@ -457,6 +474,13 @@ int x86_cpuid_copy_to_buffer(const strucbreak ; } +case 0x24 : +for ( subleaf =0 ; + subleaf <=MIN (p->avx10.max_subleaf, +ARRAY_SIZE (p->avx10.raw) -1 ); ++subleaf ) +COPY_LEAF (leaf, subleaf, &p->avx10.raw[subleaf]); +break ; +default :COPY_LEAF (leaf,XEN_CPUID_NO_SUBLEAF , &p->basic.raw[leaf]);break ;
@@ -549,6 +573,13 @@ int x86_cpuid_copy_from_buffer(struct cparray_access_nospec (p->xstate.raw, data.subleaf) = l;break ; +case 0x24 : +if ( data.subleaf >=ARRAY_SIZE (p->avx10.raw) ) + goto out_of_range; + +array_access_nospec (p->avx10.raw, data.subleaf) = l; +break ; +default :if ( data.subleaf !=XEN_CPUID_NO_SUBLEAF ) goto out_of_range;
xen/lib/x86/policy.c +8 -0
@@ -21,6 +21,14 @@ int x86_cpu_policies_are_compatible(consif ( guest->feat.max_subleaf > host->feat.max_subleaf )FAIL_CPUID (7 ,0 ); +if ( guest->avx10.version > host->avx10.version || + (guest->avx10.vsz512 + ? !host->avx10.vsz512 + : guest->avx10.vsz256 + ? !host->avx10.vsz256 + : guest->avx10.vsz128 && !host->avx10.vsz128 ) ) +FAIL_CPUID (0x24 ,0 ); +if ( guest->extd.max_leaf > host->extd.max_leaf )FAIL_CPUID (0x80000000U ,NA );
xen/tools/gen-cpuid.py +1 -1
@@ -286,7 +286,7 @@ def crunch_numbers(state): # enabled. Certain later extensions, acting on 256-bit vectors of # integers, better depend on AVX2 than AVX. AVX2: [AVX512F, VAES, VPCLMULQDQ, AVX_VNNI, AVX_IFMA, AVX_VNNI_INT8, - AVX_VNNI_INT16, SHA512, SM4], + AVX_VNNI_INT16, SHA512, SM4, AVX10], # AVX512F is taken to mean hardware support for 512bit registers # (which in practice depends on the EVEX prefix to encode) as well
PATCH 2/8 x86emul/test: rename "cp"
In reply to Jan BeulichIn preparation of introducing a const struct cpu_policy * local in x86_emulate(), rename that global variable to something more suitable:
"cp" is our commonly used name for function parameters or local variables of type struct cpu_policy *, and the present name of the global could hence have interfered already.
tools/fuzz/x86_instruction_emulator/fuzz-emul.c +1 -1
@@ -899,7 +899,7 @@ int LLVMFuzzerTestOneInput(const uint8_tint rc;/* Not part of the initializer, for old gcc to cope. */ - ctxt.cpu_policy = &cp; + ctxt.cpu_policy = &cpu_policy;/* Reset all global state variables */ memset (&input,0 ,sizeof (input));
tools/tests/x86_emulator/test_x86_emulator.c +12 -11
@@ -888,7 +888,8 @@ static void zap_fpsel(unsigned int *env, env[3 ] &= ~0xffff ; } -if ( cp.x86_vendor !=X86_VENDOR_AMD && cp.x86_vendor !=X86_VENDOR_HYGON ) +if ( cpu_policy.x86_vendor !=X86_VENDOR_AMD && + cpu_policy.x86_vendor !=X86_VENDOR_HYGON )return ;if ( is_32bit )
@@ -1022,7 +1023,7 @@ int main(int argc, char **argv) ctxt.regs = ®s; ctxt.force_writeback =0 ; - ctxt.cpu_policy = &cp; + ctxt.cpu_policy = &cpu_policy; ctxt.lma =sizeof (void *) ==8 ; ctxt.addr_size =8 *sizeof (void *); ctxt.sp_size =8 *sizeof (void *);
@@ -1540,7 +1541,7 @@ int main(int argc, char **argv) regs.edx = (unsigned long )res; res[0 ] =0x00004444 ; res[1 ] =0x8888cccc ; - i = cp.extd.nscb; cp.extd.nscb = true;/* for AMD */ + i = cpu_policy.extd.nscb; cpu_policy.extd.nscb = true;/* for AMD */ rc =x86_emulate (&ctxt, &emulops); if ( (rc != X86EMUL_OKAY) || (regs.eip != (unsigned long)&instr[5]) ||
@@ -1549,7 +1550,7 @@ int main(int argc, char **argv) goto fail;printf ("okay\n" ); - cp.extd.nscb = i; + cpu_policy.extd.nscb = i; emulops.write_segment =NULL ;printf ("%-40s" ,"Testing rdmsrlist..." );
@@ -1803,11 +1804,11 @@ int main(int argc, char **argv) goto fail;printf ("okay\n" ); - vendor_native = cp.x86_vendor; -for ( cp.x86_vendor =X86_VENDOR_AMD ; ; ) + vendor_native = cpu_policy.x86_vendor; +for ( cpu_policy.x86_vendor =X86_VENDOR_AMD ; ; ) { -unsigned int v = cp.x86_vendor ==X86_VENDOR_INTEL ; -const char *vendor = cp.x86_vendor ==X86_VENDOR_INTEL ?"Intel" :"AMD" ; +unsigned int v = cpu_policy.x86_vendor ==X86_VENDOR_INTEL ; +const char *vendor = cpu_policy.x86_vendor ==X86_VENDOR_INTEL ?"Intel" :"AMD" ;uint64_t *stk = (void *)res +MMAP_SZ -16 ; regs.rcx =2 ;
@@ -1843,11 +1844,11 @@ int main(int argc, char **argv) printf("okay\n"); } -if ( cp.x86_vendor ==X86_VENDOR_INTEL ) +if ( cpu_policy.x86_vendor ==X86_VENDOR_INTEL )break ; - cp.x86_vendor =X86_VENDOR_INTEL ; + cpu_policy.x86_vendor =X86_VENDOR_INTEL ; } - cp.x86_vendor = vendor_native; + cpu_policy.x86_vendor = vendor_native;#endif /* x86-64 */ printf ("%-40s" ,"Testing shld $1,%ecx,(%edx)..." );
tools/tests/x86_emulator/x86-emulate.c +13 -13
@@ -25,7 +25,7 @@#endif uint32_t mxcsr_mask =0x0000ffbf ; -struct cpu_policy cp; +struct cpu_policy cpu_policy; static char fpu_save_area[0x4000] __attribute__((__aligned__((64))));static bool use_xsave;
@@ -75,24 +75,24 @@ bool emul_test_init(void)unsigned long sp; -x86_cpu_policy_fill_native (&cp); -x86_cpu_policy_bound_max_leaves (&cp); +x86_cpu_policy_fill_native (&cpu_policy); +x86_cpu_policy_bound_max_leaves (&cpu_policy);/* * The emulator doesn't use these instructions, so can always emulate * them. */ - cp.basic.movbe = true; - cp.feat.invpcid = true; - cp.feat.adx = true; - cp.feat.avx512pf = cp.feat.avx512f; - cp.feat.rdpid = true; - cp.feat.lkgs = true; - cp.feat.wrmsrns = true; - cp.feat.msrlist = true; - cp.extd.clzero = true; + cpu_policy.basic.movbe = true; + cpu_policy.feat.invpcid = true; + cpu_policy.feat.adx = true; + cpu_policy.feat.avx512pf = cpu_policy.feat.avx512f; + cpu_policy.feat.rdpid = true; + cpu_policy.feat.lkgs = true; + cpu_policy.feat.wrmsrns = true; + cpu_policy.feat.msrlist = true; + cpu_policy.extd.clzero = true; -x86_cpu_policy_shrink_max_leaves (&cp); +x86_cpu_policy_shrink_max_leaves (&cpu_policy);if ( cpu_has_xsave ) {
tools/tests/x86_emulator/x86-emulate.h +63 -63
144 lines not on this page · raw message
PATCH 3/8 x86emul: introduce a struct cpu_policy * local in x86_emulate()
In reply to Jan BeulichWhile of little effect right here, future patches (AVX10, AMX, KeyLocker) will benefit more significantly.
xen/arch/x86/x86_emulate/x86_emulate.c +2 -1
@@ -1232,6 +1232,7 @@ x86_emulate( {/* Shadow copy of register state. Committed on successful emulation. */ struct cpu_user_regs _regs = *ctxt->regs; +const struct cpu_policy *cp = ctxt->cpu_policy;struct x86_emulate_state state;int rc;uint8_t b, d, *opc =NULL ;
@@ -3101,7 +3102,7 @@ x86_emulate(* in fact risking to make guest OSes vulnerable to the equivalent of * XSA-7 (CVE-2012-0217). */ -generate_exception_if (ctxt->cpuid->x86_vendor ==X86_VENDOR_INTEL && +generate_exception_if (cp->x86_vendor ==X86_VENDOR_INTEL && op_bytes ==8 && !is_canonical_address (_regs.rcx),X86_EXC_GP ,0 );#endif
PATCH 4/8 x86emul: support AVX10.1
In reply to Jan BeulichThis requires relaxing various pre-existing AVX512* checks, as AVX10.1 covers all AVX512* except except PF, ER, 4FMAPS, 4VNNIW, and VP2INTERSECT. Yet potentially with only less than 512-bit vector width, while otoh guaranteeing more narrow widths being available when wider are (i.e. unlike AVX512VL being an add-on feature on top of AVX512F).
Note that visa_check(), replacing host_and_vcpu_must_have() uses, checks only the guest capability: We wouldn't expose AVX512* (nor AVX10) without the hardware supporting it. Similarly in vlen_check() the original host_and_vcpu_must_have() is reduced to the equivalent of just vcpu_must_have(). This also simplifies (resulting) code in the test and fuzzing harnesses, as there the XCR0 checks that are part of cpu_has_avx512* are only needed in local code, not in the emulator itself (where respective checking occurs elsewhere anyway, utilizing emul_test_read_xcr()).
While in most cases the changes to x86_emulate() are entirely mechanical, for opmask insns earlier unconditional AVX512F checks are converted into "else" clauses to existing if/else-if ones.
To be certain that no uses remain, also drop respective cpu_has_avx512* (except in the test harness) and vcpu_has_avx512*().
---
Probably avx512_vlen_check() should have the avx512_ prefix dropped, now that it also covers AVX10. But if so that wants to be either a prereq or a follow-on patch.
visa_check() won't cover AVX10.2 and higher, but probably we will want independent checking logic for that anyway.
Spec version 2 still leaves unclear what the xstate components are which would need enabling for AVX10/256. x86emul_get_fpu() is therefore untouched for now.
Since it'll be reducing code size, we may want to further convert host_and_vcpu_must_have() to just vcpu_must_have() where appropriate (should be [almost?] everywhere).
xen/arch/x86/include/asm/cpufeature.h +0 -13
@@ -132,30 +132,19 @@ static inline bool boot_cpu_has(unsigned#define cpu_has_pqe boot_cpu_has(X86_FEATURE_PQE)#define cpu_has_fpu_sel (!boot_cpu_has(X86_FEATURE_NO_FPU_SEL))#define cpu_has_mpx boot_cpu_has(X86_FEATURE_MPX) -#define cpu_has_avx512f boot_cpu_has(X86_FEATURE_AVX512F) -#define cpu_has_avx512dq boot_cpu_has(X86_FEATURE_AVX512DQ)#define cpu_has_rdseed boot_cpu_has(X86_FEATURE_RDSEED)#define cpu_has_smap boot_cpu_has(X86_FEATURE_SMAP) -#define cpu_has_avx512_ifma boot_cpu_has(X86_FEATURE_AVX512_IFMA)#define cpu_has_clflushopt boot_cpu_has(X86_FEATURE_CLFLUSHOPT)#define cpu_has_clwb boot_cpu_has(X86_FEATURE_CLWB)#define cpu_has_avx512er boot_cpu_has(X86_FEATURE_AVX512ER) -#define cpu_has_avx512cd boot_cpu_has(X86_FEATURE_AVX512CD)#define cpu_has_proc_trace boot_cpu_has(X86_FEATURE_PROC_TRACE)#define cpu_has_sha boot_cpu_has(X86_FEATURE_SHA) -#define cpu_has_avx512bw boot_cpu_has(X86_FEATURE_AVX512BW) -#define cpu_has_avx512vl boot_cpu_has(X86_FEATURE_AVX512VL)/* CPUID level 0x00000007:0.ecx */ -#define cpu_has_avx512_vbmi boot_cpu_has(X86_FEATURE_AVX512_VBMI)#define cpu_has_pku boot_cpu_has(X86_FEATURE_PKU) -#define cpu_has_avx512_vbmi2 boot_cpu_has(X86_FEATURE_AVX512_VBMI2)#define cpu_has_gfni boot_cpu_has(X86_FEATURE_GFNI)#define cpu_has_vaes boot_cpu_has(X86_FEATURE_VAES)#define cpu_has_vpclmulqdq boot_cpu_has(X86_FEATURE_VPCLMULQDQ) -#define cpu_has_avx512_vnni boot_cpu_has(X86_FEATURE_AVX512_VNNI) -#define cpu_has_avx512_bitalg boot_cpu_has(X86_FEATURE_AVX512_BITALG) -#define cpu_has_avx512_vpopcntdq boot_cpu_has(X86_FEATURE_AVX512_VPOPCNTDQ)#define cpu_has_rdpid boot_cpu_has(X86_FEATURE_RDPID)#define cpu_has_movdiri boot_cpu_has(X86_FEATURE_MOVDIRI)#define cpu_has_movdir64b boot_cpu_has(X86_FEATURE_MOVDIR64B)
@@ -180,7 +169,6 @@ static inline bool boot_cpu_has(unsigned#define cpu_has_rtm_always_abort boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)#define cpu_has_tsx_force_abort boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)#define cpu_has_serialize boot_cpu_has(X86_FEATURE_SERIALIZE) -#define cpu_has_avx512_fp16 boot_cpu_has(X86_FEATURE_AVX512_FP16)#define cpu_has_arch_caps boot_cpu_has(X86_FEATURE_ARCH_CAPS)/* CPUID level 0x00000007:1.eax */
@@ -188,7 +176,6 @@ static inline bool boot_cpu_has(unsigned#define cpu_has_sm3 boot_cpu_has(X86_FEATURE_SM3)#define cpu_has_sm4 boot_cpu_has(X86_FEATURE_SM4)#define cpu_has_avx_vnni boot_cpu_has(X86_FEATURE_AVX_VNNI) -#define cpu_has_avx512_bf16 boot_cpu_has(X86_FEATURE_AVX512_BF16)#define cpu_has_cmpccxadd boot_cpu_has(X86_FEATURE_CMPCCXADD)#define cpu_has_avx_ifma boot_cpu_has(X86_FEATURE_AVX_IFMA)
xen/arch/x86/x86_emulate/private.h +0 -13
@@ -558,28 +558,17 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_invpcid () (ctxt->cpuid->feat.invpcid)#define vcpu_has_rtm () (ctxt->cpuid->feat.rtm)#define vcpu_has_mpx () (ctxt->cpuid->feat.mpx) -#define vcpu_has_avx512f () (ctxt->cpuid->feat.avx512f) -#define vcpu_has_avx512dq () (ctxt->cpuid->feat.avx512dq)#define vcpu_has_rdseed () (ctxt->cpuid->feat.rdseed)#define vcpu_has_adx () (ctxt->cpuid->feat.adx)#define vcpu_has_smap () (ctxt->cpuid->feat.smap) -#define vcpu_has_avx512_ifma () (ctxt->cpuid->feat.avx512_ifma)#define vcpu_has_clflushopt () (ctxt->cpuid->feat.clflushopt)#define vcpu_has_clwb () (ctxt->cpuid->feat.clwb)#define vcpu_has_avx512pf () (ctxt->cpuid->feat.avx512pf)#define vcpu_has_avx512er () (ctxt->cpuid->feat.avx512er) -#define vcpu_has_avx512cd () (ctxt->cpuid->feat.avx512cd)#define vcpu_has_sha () (ctxt->cpuid->feat.sha) -#define vcpu_has_avx512bw () (ctxt->cpuid->feat.avx512bw) -#define vcpu_has_avx512vl () (ctxt->cpuid->feat.avx512vl) -#define vcpu_has_avx512_vbmi () (ctxt->cpuid->feat.avx512_vbmi) -#define vcpu_has_avx512_vbmi2 () (ctxt->cpuid->feat.avx512_vbmi2)#define vcpu_has_gfni () (ctxt->cpuid->feat.gfni)#define vcpu_has_vaes () (ctxt->cpuid->feat.vaes)#define vcpu_has_vpclmulqdq () (ctxt->cpuid->feat.vpclmulqdq) -#define vcpu_has_avx512_vnni () (ctxt->cpuid->feat.avx512_vnni) -#define vcpu_has_avx512_bitalg () (ctxt->cpuid->feat.avx512_bitalg) -#define vcpu_has_avx512_vpopcntdq () (ctxt->cpuid->feat.avx512_vpopcntdq)#define vcpu_has_rdpid () (ctxt->cpuid->feat.rdpid)#define vcpu_has_movdiri () (ctxt->cpuid->feat.movdiri)#define vcpu_has_movdir64b () (ctxt->cpuid->feat.movdir64b)
@@ -589,12 +578,10 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_avx512_vp2intersect () (ctxt->cpuid->feat.avx512_vp2intersect)#define vcpu_has_serialize () (ctxt->cpuid->feat.serialize)#define vcpu_has_tsxldtrk () (ctxt->cpuid->feat.tsxldtrk) -#define vcpu_has_avx512_fp16 () (ctxt->cpuid->feat.avx512_fp16)#define vcpu_has_sha512 () (ctxt->cpuid->feat.sha512)#define vcpu_has_sm3 () (ctxt->cpuid->feat.sm3)#define vcpu_has_sm4 () (ctxt->cpuid->feat.sm4)#define vcpu_has_avx_vnni () (ctxt->cpuid->feat.avx_vnni) -#define vcpu_has_avx512_bf16 () (ctxt->cpuid->feat.avx512_bf16)#define vcpu_has_cmpccxadd () (ctxt->cpuid->feat.cmpccxadd)#define vcpu_has_lkgs () (ctxt->cpuid->feat.lkgs)#define vcpu_has_wrmsrns () (ctxt->cpuid->feat.wrmsrns)
xen/arch/x86/x86_emulate/x86_emulate.c +161 -130
888 lines not on this page · raw message
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -321,7 +321,7 @@ XEN_CPUFEATURE(AVX_VNNI_INT16, 15*32 XEN_CPUFEATURE(PREFETCHI, 15*32+14) /*A PREFETCHIT{0,1} Instructions */ XEN_CPUFEATURE(USER_MSR, 15*32+15) /*s U{RD,WR}MSR Instructions */ XEN_CPUFEATURE(CET_SSS, 15*32+18) /* CET Supervisor Shadow Stacks safe to use */ -XEN_CPUFEATURE (AVX10 ,15 *32 +19 )/* AVX10 Converged Vector ISA */ +XEN_CPUFEATURE (AVX10 ,15 *32 +19 )/*a AVX10 Converged Vector ISA */ /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */XEN_CPUFEATURE (RDCL_NO ,16 *32 +0 )/*A No Rogue Data Cache Load (Meltdown) */
PATCH 5/8 x86emul/test: use simd_check_avx512*() in main()
In reply to Jan BeulichIn preparation for having these also cover AVX10, use the helper functions in preference of open-coded cpu_has_avx512* for those features that AVX10 includes. Introduce a couple further helper functions where they weren't previously needed.
Note that this way simd_check_avx512f_sha_vl() gains an AVX512F check (which is likely benign) and simd_check_avx512bw_gf_vl() gains an AVX512BW check (which was clearly missing).
tools/tests/x86_emulator/test_x86_emulator.c +42 -32
@@ -173,6 +173,11 @@ static bool simd_check_avx512vbmi_vl(voireturn cpu_has_avx512_vbmi && cpu_has_avx512vl; } +static bool simd_check_avx512vbmi2 (void ) +{ +return cpu_has_avx512_vbmi2; +} +static bool simd_check_sse4_sha (void ) {return cpu_has_sha && cpu_has_sse4_2;
@@ -185,7 +190,7 @@ static bool simd_check_avx_sha(void)static bool simd_check_avx512f_sha_vl (void ) { -return cpu_has_sha && cpu_has_avx512vl; +return cpu_has_sha &&simd_check_avx512f_vl (); }static bool simd_check_avx2_vaes (void )
@@ -195,13 +200,13 @@ static bool simd_check_avx2_vaes(void)static bool simd_check_avx512bw_vaes (void ) { -return cpu_has_aesni && cpu_has_vaes && cpu_has_avx512bw; +return cpu_has_aesni && cpu_has_vaes &&simd_check_avx512bw (); }static bool simd_check_avx512bw_vaes_vl (void ) {return cpu_has_aesni && cpu_has_vaes && - cpu_has_avx512bw && cpu_has_avx512vl; +simd_check_avx512bw_vl (); }static bool simd_check_avx2_vpclmulqdq (void )
@@ -211,22 +216,22 @@ static bool simd_check_avx2_vpclmulqdq(vstatic bool simd_check_avx512bw_vpclmulqdq (void ) { -return cpu_has_vpclmulqdq && cpu_has_avx512bw; +return cpu_has_vpclmulqdq &&simd_check_avx512bw (); }static bool simd_check_avx512bw_vpclmulqdq_vl (void ) { -return cpu_has_vpclmulqdq && cpu_has_avx512bw && cpu_has_avx512vl; +return cpu_has_vpclmulqdq &&simd_check_avx512bw_vl (); }static bool simd_check_avx512vbmi2_vpclmulqdq (void ) { -return cpu_has_avx512_vbmi2 &&simd_check_avx512bw_vpclmulqdq (); +return simd_check_avx512vbmi2 () &&simd_check_avx512bw_vpclmulqdq (); }static bool simd_check_avx512vbmi2_vpclmulqdq_vl (void ) { -return cpu_has_avx512_vbmi2 &&simd_check_avx512bw_vpclmulqdq_vl (); +return simd_check_avx512vbmi2 () &&simd_check_avx512bw_vpclmulqdq_vl (); }static bool simd_check_sse2_gf (void )
@@ -241,12 +246,17 @@ static bool simd_check_avx2_gf(void)static bool simd_check_avx512bw_gf (void ) { -return cpu_has_gfni && cpu_has_avx512bw; +return cpu_has_gfni &&simd_check_avx512bw (); }static bool simd_check_avx512bw_gf_vl (void ) { -return cpu_has_gfni && cpu_has_avx512vl; +return cpu_has_gfni &&simd_check_avx512bw_vl (); +} + +static bool simd_check_avx512vnni (void ) +{ +return cpu_has_avx512_vnni; }static bool simd_check_avx512fp16 (void )
@@ -3116,7 +3126,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovq %xmm1,32(%edx)..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovq_to_mem);
@@ -3140,7 +3150,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovq 32(%edx),%xmm0..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovq_from_mem);
@@ -3263,7 +3273,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovdqu32 %zmm2,(%ecx){%k1}..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vmovdqu32_to_mem);
@@ -3293,7 +3303,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovdqu32 64(%edx),%zmm2{%k2}..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vmovdqu32_from_mem);
@@ -3318,7 +3328,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovdqu16 %zmm3,(%ecx){%k1}..." ); -if ( stack_exec && cpu_has_avx512bw ) +if ( stack_exec &&simd_check_avx512bw () ) {decl_insn (vmovdqu16_to_mem);
@@ -3350,7 +3360,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovdqu16 64(%edx),%zmm3{%k2}..." ); -if ( stack_exec && cpu_has_avx512bw ) +if ( stack_exec &&simd_check_avx512bw () ) {decl_insn (vmovdqu16_from_mem);
@@ -3478,7 +3488,7 @@ int main(int argc, char **argv)printf ("%-40s" ,"Testing vmovsd %xmm5,16(%ecx){%k3}..." );memset (res,0x88 ,128 );memset (res +20 ,0x77 ,8 ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vmovsd_masked_to_mem);
@@ -3513,7 +3523,7 @@ int main(int argc, char **argv) }printf ("%-40s" ,"Testing vmovaps (%edx),%zmm7{%k3}{z}..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vmovaps_masked_from_mem);
@@ -3696,7 +3706,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovd %xmm3,32(%ecx)..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovd_to_mem);
@@ -3721,7 +3731,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovd 32(%ecx),%xmm4..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovd_from_mem);
@@ -3911,7 +3921,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovd %xmm2,%ebx..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovd_to_reg);
@@ -3937,7 +3947,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovd %ebx,%xmm1..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovd_from_reg);
@@ -4039,7 +4049,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing {evex} vmovq %xmm11,32(%ecx)..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovq_to_mem2);
@@ -4129,7 +4139,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovq %xmm22,%rbx..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovq_to_reg);
@@ -4322,7 +4332,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovntdqa 64(%ecx),%zmm4..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vmovntdqa);
@@ -4918,7 +4928,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vcvtph2ps 32(%ecx),%zmm7{%k4}..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (evex_vcvtph2ps);decl_insn (evex_vcvtps2ph);
@@ -4961,7 +4971,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vfixupimmpd $0,8(%edx){1to8},%zmm3,%zmm4..." ); -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vfixupimmpd); static const struct {
@@ -5000,7 +5010,7 @@ int main(int argc, char **argv)printf ("%-40s" ,"Testing vfpclasspsz $0x46,64(%edx),%k2..." ); -if ( stack_exec && cpu_has_avx512dq ) +if ( stack_exec &&simd_check_avx512dq () ) {decl_insn (vfpclassps);
@@ -5032,7 +5042,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vfpclassphz $0x46,128(%ecx),%k3..." ); -if ( stack_exec && cpu_has_avx512_fp16 ) +if ( stack_exec &&simd_check_avx512fp16 () ) {decl_insn (vfpclassph);
@@ -5075,7 +5085,7 @@ int main(int argc, char **argv)* on the mapping boundaries) that elements controlled by clear mask * bits don't get accessed. */ -if ( stack_exec && cpu_has_avx512f ) +if ( stack_exec &&simd_check_avx512f () ) {decl_insn (vpcompressd);decl_insn (vpcompressq);
@@ -5177,7 +5187,7 @@ int main(int argc, char **argv) }#if __GNUC__ >7 /* can't check for __AVX512VBMI2__ here */ -if ( stack_exec && cpu_has_avx512_vbmi2 ) +if ( stack_exec &&simd_check_avx512vbmi2 () ) {decl_insn (vpcompressb);decl_insn (vpcompressw);
@@ -5440,7 +5450,7 @@ int main(int argc, char **argv) }printf ("%-40s" ,"Testing vpdpwssd (%ecx),%{y,z}mmA,%{y,z}mmB..." ); -if ( stack_exec && cpu_has_avx512_vnni && cpu_has_avx_vnni ) +if ( stack_exec &&simd_check_avx512vnni () && cpu_has_avx_vnni ) {/* Do the same operation two ways and compare the results. */ decl_insn (vpdpwssd_vex1);
@@ -5495,7 +5505,7 @@ int main(int argc, char **argv)printf ("skipped\n" );printf ("%-40s" ,"Testing vmovsh 8(%ecx),%xmm5..." ); -if ( stack_exec && cpu_has_avx512_fp16 ) +if ( stack_exec &&simd_check_avx512fp16 () ) {decl_insn (vmovsh_from_mem);decl_insn (vmovw_to_gpr);
PATCH 6/8 x86emul/test: drop cpu_has_avx512vl
In reply to Jan BeulichAVX512VL not being a standalone feature anyway, but always needing to be combined with some other AVX512*, replace uses of cpu_has_avx512vl by just the feature bit check.
tools/tests/x86_emulator/evex-disp8.c +2 -1
@@ -1031,7 +1031,8 @@ static void test_group(const struct test {for ( j =0 ; j < nr_vl; ++j ) { -if ( vl[0 ] ==VL_512 && vl[j] !=VL_512 && !cpu_has_avx512vl ) +if ( vl[0 ] ==VL_512 && vl[j] !=VL_512 && + !cpu_policy.feat.avx512vl )continue ; switch ( tests[i].esz )
tools/tests/x86_emulator/test_x86_emulator.c +5 -5
@@ -132,7 +132,7 @@ static bool simd_check_avx512f(void)static bool simd_check_avx512f_vl (void ) { -return cpu_has_avx512f && cpu_has_avx512vl; +return cpu_has_avx512f && cpu_policy.feat.avx512vl; }#define simd_check_avx512vl_sg simd_check_avx512f_vl
@@ -144,7 +144,7 @@ static bool simd_check_avx512dq(void)static bool simd_check_avx512dq_vl (void ) { -return cpu_has_avx512dq && cpu_has_avx512vl; +return cpu_has_avx512dq && cpu_policy.feat.avx512vl; }static bool simd_check_avx512er (void )
@@ -160,7 +160,7 @@ static bool simd_check_avx512bw(void)static bool simd_check_avx512bw_vl (void ) { -return cpu_has_avx512bw && cpu_has_avx512vl; +return cpu_has_avx512bw && cpu_policy.feat.avx512vl; }static bool simd_check_avx512vbmi (void )
@@ -170,7 +170,7 @@ static bool simd_check_avx512vbmi(void)static bool simd_check_avx512vbmi_vl (void ) { -return cpu_has_avx512_vbmi && cpu_has_avx512vl; +return cpu_has_avx512_vbmi && cpu_policy.feat.avx512vl; }static bool simd_check_avx512vbmi2 (void )
@@ -266,7 +266,7 @@ static bool simd_check_avx512fp16(void)static bool simd_check_avx512fp16_vl (void ) { -return cpu_has_avx512_fp16 && cpu_has_avx512vl; +return cpu_has_avx512_fp16 && cpu_policy.feat.avx512vl; }static void simd_set_regs (struct cpu_user_regs *regs)
tools/tests/x86_emulator/x86-emulate.h +0 -1
@@ -160,7 +160,6 @@ void wrpkru(unsigned int val);#define cpu_has_avx512cd (cpu_policy.feat.avx512cd && xcr0_mask(0xe6))#define cpu_has_sha cpu_policy.feat.sha#define cpu_has_avx512bw (cpu_policy.feat.avx512bw && xcr0_mask(0xe6)) -#define cpu_has_avx512vl (cpu_policy.feat.avx512vl && xcr0_mask(0xe6))#define cpu_has_avx512_vbmi (cpu_policy.feat.avx512_vbmi && xcr0_mask(0xe6))#define cpu_has_avx512_vbmi2 (cpu_policy.feat.avx512_vbmi2 && xcr0_mask(0xe6))#define cpu_has_gfni cpu_policy.feat.gfni
PATCH 7/8 x86emul: AVX10.1 testing
In reply to Jan BeulichRe-use respective AVX512 tests, by suitably adjusting the predicate functions. This leaves test names ("Testing ... NN-bit code sequence") somewhat misleading, but I think we can live with that.
Note that the AVX512{BW,DQ} opmask tests cannot be run as-is for the AVX10/256 case, as they include 512-bit vector <-> opmask insn tests.
Sadly until a newer SDE version (matching ISE 050 or newer) is available, one workaround is necessary to be able to run the test harness on SDE 9.27.0.
---
SDE: -gnr / -gnr256
---
TBD: For AVX10.1/256 need to somehow guarantee that the generated blobs
really don't use 512-bit insns (it's uncertain whether passing -mprefer-vector-width= is enough). Right now according to my testing on SDE this is all fine. May need to probe for support of the new -mno-evex512 compiler option.
The AVX512{BW,DQ} opmask tests could of course be cloned (i.e. rebuilt another time with -mavx512vl passed) accordingly, but the coverage gain wouldbe pretty marginal (plus there would again be issues with SDE 9.27.0).
tools/tests/x86_emulator/evex-disp8.c +40 -4
@@ -1032,7 +1032,11 @@ static void test_group(const struct testfor ( j =0 ; j < nr_vl; ++j ) {if ( vl[0 ] ==VL_512 && vl[j] !=VL_512 && - !cpu_policy.feat.avx512vl ) + !cpu_policy.feat.avx512vl && !cpu_policy.feat.avx10 ) +continue ; + +if ( vl[j] ==VL_512 && !cpu_policy.feat.avx512f && + !cpu_policy.avx10.vsz512 )continue ; switch ( tests[i].esz )
@@ -1083,6 +1087,27 @@ static void test_group(const struct test } } +/* AVX512 (sub)features implied by AVX10. */ +#define avx10_has_avx512f true +#define avx10_has_avx512bw true +#define avx10_has_avx512cd true +#define avx10_has_avx512dq true +#define avx10_has_avx512_bf16 true +#define avx10_has_avx512_bitalg true +#define avx10_has_avx512_fp16 true +#define avx10_has_avx512_ifma true +#define avx10_has_avx512_vbmi true +#define avx10_has_avx512_vbmi2 true +#define avx10_has_avx512_vnni true +#define avx10_has_avx512_vpopcntdq true + +/* AVX512 sub-features /not/ implied by AVX10. */ +#define avx10_has_avx512er false +#define avx10_has_avx512pf false +#define avx10_has_avx512_4fmaps false +#define avx10_has_avx512_4vnniw false +#define avx10_has_avx512_vp2intersect false +void evex_disp8_test (void *instr,struct x86_emulate_ctxt *ctxt,const struct x86_emulate_ops *ops) {
@@ -1090,8 +1115,8 @@ void evex_disp8_test(void *instr, struct emulops.read = read; emulops.write = write; -#define RUN (feat, vl) do { \ - if ( cpu_has_##feat ) \ +#define run (cond, feat, vl) do { \ + if ( cond ) \ { \ printf("%-40s", "Testing " #feat "/" #vl " disp8 handling..."); \ test_group(feat ## _ ## vl, ARRAY_SIZE(feat ## _ ## vl), \
@@ -1100,6 +1125,12 @@ void evex_disp8_test(void *instr, struct } \ } while ( false ) +#define RUN (feat, vl) \ + run(cpu_has_ ## feat || \ + (cpu_has_avx10_1 && cpu_policy.avx10.vsz256 && avx10_has_ ## feat && \ + (ARRAY_SIZE(vl_ ## vl) > 1 || &vl_ ## vl[0] != &vl_512[0])), \ + feat, vl) +RUN (avx512f, all);RUN (avx512f,128 );RUN (avx512f, no128);
@@ -1127,10 +1158,15 @@ void evex_disp8_test(void *instr, structRUN (avx512_fp16, all);RUN (avx512_fp16,128 ); -if ( cpu_has_avx512f ) +#undef RUN + +if ( cpu_has_avx512f || cpu_has_avx10_1 ) { +#define RUN (feat, vl) run(cpu_has_ ## feat, feat, vl)RUN (gfni, all);RUN (vaes, all);RUN (vpclmulqdq, all); +#undef RUN } +#undef run }
tools/tests/x86_emulator/testcase.mk +21 -1
@@ -4,7 +4,27 @@ include $(XEN_ROOT)/tools/Rules.mk $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) -CFLAGS += -fno-builtin -g0 $($(TESTCASE)-cflags) +ifneq ($(filter -mavx512%,$($(TESTCASE)-cflags)),) + +cflags-vsz64 := +cflags-vsz32 := -mprefer-vector-width=256 +cflags-vsz16 := -mprefer-vector-width=128 +# Scalar tests don't set VEC_SIZE (and VEC_MAX is used by S/G ones only) +cflags-vsz := -mprefer-vector-width=128 + +ifneq ($(filter -DVEC_SIZE=%,$($(TESTCASE)-cflags)),) +CFLAGS-VSZ := $(cflags-vsz$(patsubst -DVEC_SIZE=%,%,$(filter -DVEC_SIZE=%,$($(TESTCASE)-cflags)))) +else +CFLAGS-VSZ := $(cflags-vsz$(patsubst -DVEC_MAX=%,%,$(filter -DVEC_MAX=%,$($(TESTCASE)-cflags)))) +endif + +else + +CFLAGS-VSZ := + +endif + +CFLAGS += -fno-builtin -g0 $($(TESTCASE)-cflags) $(CFLAGS-VSZ) LDFLAGS_DIRECT += $(shell { $(LD) -v --warn-rwx-segments; } >/dev/null 2>&1 && echo --no-warn-rwx-segments)
tools/tests/x86_emulator/test_x86_emulator.c +117 -49
321 lines not on this page · raw message
tools/tests/x86_emulator/x86-emulate.c +1 -1
@@ -243,7 +243,7 @@ int emul_test_get_fpu(break ;case X86EMUL_FPU_opmask:case X86EMUL_FPU_zmm: -if ( cpu_has_avx512f ) +if ( cpu_has_avx512f || cpu_has_avx10_1 )break ;default :return X86EMUL_UNHANDLEABLE ;
tools/tests/x86_emulator/x86-emulate.h +6 -0
@@ -185,6 +185,12 @@ void wrpkru(unsigned int val);#define cpu_has_avx_vnni_int8 (cpu_policy.feat.avx_vnni_int8 && xcr0_mask(6))#define cpu_has_avx_ne_convert (cpu_policy.feat.avx_ne_convert && xcr0_mask(6))#define cpu_has_avx_vnni_int16 (cpu_policy.feat.avx_vnni_int16 && xcr0_mask(6)) +/* TBD: Is bit 6 (ZMM_Hi256) really needed here? */ +#define cpu_has_avx10_1 (cpu_policy.feat.avx10 && xcr0_mask(0xe6)) +#define cpu_has_avx10_1_256 (cpu_has_avx10_1 && \ + (cpu_policy.avx10.vsz256 || \ + cpu_policy.avx10.vsz512)) +#define cpu_has_avx10_1_512 (cpu_has_avx10_1 && cpu_policy.avx10.vsz512)#define cpu_has_xgetbv1 (cpu_has_xsave && cpu_policy.xstate.xgetbv1)
xen/arch/x86/x86_emulate/x86_emulate.c +8 -0
@@ -1396,6 +1396,14 @@ x86_emulate( stb[2 ] = cp->feat.avx512bw || cp->feat.avx10 ?0xf8 /* L0.NP.W1 - kmovq */ :0x78 /* L0.NP.W0 - kmovw */ ; +#ifndef __XEN__ +/* +* SDE 9.27.0 is following ISE 049, where 64-bit opmask insns were +* valid only with vsz512. +*/ +if ( cp->feat.avx10 && !cp->avx10.vsz512 ) + stb[2 ] =0xf9 /* L0.66.W1 - kmovd */ ; +#endif stb[3 ] =0x91 ; stb[4 ] = evex.opmsk <<3 ; insn_bytes =5 ;
PATCH 8/8 x86emul/test: engage AVX512VL via command line option
In reply to Jan BeulichNow that we have machinery in testcase.mk to set vector length dependent flags for AVX512 tests, let's avoid using a pragma to enable AVX512VL insns for the compiler. This way, correct settings are in place from the very beginning of compilation.
No change to the generated test blobs, and hence no functional change.
tools/tests/x86_emulator/simd.h +0 -4
@@ -215,10 +215,6 @@ DECL_OCTET(half);# define __builtin_ia32_shuf_i32x4_512_mask __builtin_ia32_shuf_i32x4_mask# define __builtin_ia32_shuf_i64x2_512_mask __builtin_ia32_shuf_i64x2_mask -# if VEC_SIZE > ELEM_SIZE && (defined(VEC_MAX) ? VEC_MAX : VEC_SIZE) < 64 -# pragma GCC target ( "avx512vl" ) -# endif -# define REN (insn, old, new) \ asm ( ".macro v" #insn #old " o:vararg \n\t" \ "v" #insn #new " \\o \n\t" \
tools/tests/x86_emulator/testcase.mk +2 -2
@@ -7,8 +7,8 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDD ifneq ($(filter -mavx512%,$($(TESTCASE)-cflags)),) cflags-vsz64 := -cflags-vsz32 := -mprefer-vector-width=256 -cflags-vsz16 := -mprefer-vector-width=128 +cflags-vsz32 := -mavx512vl -mprefer-vector-width=256 +cflags-vsz16 := -mavx512vl -mprefer-vector-width=128 # Scalar tests don't set VEC_SIZE (and VEC_MAX is used by S/G ones only) cflags-vsz := -mprefer-vector-width=128