x86: support AVX10
v4 cover x86: support AVX10
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. Luckily the 256-bit-only case and an unnecessary restriction on the mask register insns was taken out again, simplifying the actual emulator adjustments quite a bit.
AVX10.2 is adding quite a few new insns, support for which is roughly added chapter-wise as the spec has them (perhaps not in the order of the chapters there).
While it probably could be re-based ahead, the series in this form depends on the previously submitted "[PATCH v5 0/3] x86/CPUID: leaf pruning" and parts of whatever is left of "[PATCH v9 00/10] x86emul:
misc additions".
I've tried to be very careful in rebasing ahead of other emulator patches I've been carrying, but almost all testing I've done is with all of those collectively in place.
01: x86/CPUID: enable AVX10 leaf
02: x86emul: support SIMD MOVRS
03: x86emul: support AVX10.2 forms of SM4 insns 04: x86emul: support AVX10.1
05: x86emul/test: use simd_check_avx512*() in main() 06: x86emul/test: drop cpu_has_avx512vl
07: x86emul: AVX10.1 testing
08: x86emul/test: engage AVX512VL via command line option 09: x86/CPUID: enable AVX10.2 sub-leaf
10: x86emul: support AVX10.2 scalar compare insns 11: x86emul: support AVX10.2 partial copy insns 12: x86emul: support AVX10.2 media insns
13: x86emul: support AVX10.2 minmax insns
14: x86emul: support AVX10.2 BFloat16 insns
15: x86emul: support AVX10.2 saturating convert insns 16: x86emul: support other AVX10.2 convert insns
Jan
PATCH v4 1/16 x86emul: support SIMD MOVRS
As we ignore cachability aspects of insns, they're treated like simple VMOVs.
---
SDE: -dmr
---
v4: Correct main switch case labels to reference Map5. Switch to using
fallthrough pseudo-keyword. Move ahead in series, switching feature dependency to plain AVX10.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +16 -2
@@ -720,6 +720,13 @@ static const struct test vpclmulqdq_all[ INSN(pclmulqdq, 66, 0f3a, 44, vl, q_nb, vl) }; +static const struct test movrs_all[] = { +INSN (movrsb, f2, map5,6f , vl, b, vl), +INSN (movrsd, f3, map5,6f , vl, d_nb, vl), +INSN (movrsq, f3, map5,6f , vl, q_nb, vl), +INSN (movrsw, f2, map5,6f , vl, w, vl), +}; +static const unsigned char vl_all[] = {VL_512 ,VL_128 ,VL_256 };static const unsigned char vl_128[] = {VL_128 };static const unsigned char vl_no128[] = {VL_512 ,VL_256 };
@@ -1071,8 +1078,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), \
@@ -1081,6 +1088,8 @@ void evex_disp8_test(void *instr, struct } \ } while ( false ) +#define RUN (feat, vl) run(cpu_has_ ## feat, feat, vl) +RUN (avx512f, all);RUN (avx512f,128 );RUN (avx512f, no128);
@@ -1111,4 +1120,9 @@ void evex_disp8_test(void *instr, structRUN (vaes, all);RUN (vpclmulqdq, all); } + +if ( cpu_has_avx10 ) + { +run (ctxt->addr_size ==64 && cpu_has_movrs, movrs, all); + } }
tools/tests/x86_emulator/predicates.c +2 -0
@@ -2124,6 +2124,8 @@ static const struct evex { { { 0x5f }, 2, T, R, pfx_no, W0, Ln }, /* vmaxph */ { { 0x5f }, 2, T, R, pfx_f3, W0, LIG }, /* vmaxsh */ { { 0x6e }, 2, T, R, pfx_66, WIG, L0 }, /* vmovw */ + { { 0x6f }, 2, T, R, pfx_f3, Wn, Ln }, /* vmovrs{d,q} */ + { { 0x6f }, 2, T, R, pfx_f2, Wn, Ln }, /* vmovrs{b,w} */ { { 0x78 }, 2, T, R, pfx_no, W0, Ln }, /* vcvttph2udq */ { { 0x78 }, 2, T, R, pfx_66, W0, Ln }, /* vcvttph2uqq */ { { 0x78 }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttsh2usi */
tools/tests/x86_emulator/x86-emulate.h +2 -0
@@ -209,12 +209,14 @@ void wrpkru(unsigned int val); xcr0_mask(0xe6))#define cpu_has_cmpccxadd cpu_policy.feat.cmpccxadd#define cpu_has_avx_ifma (cpu_policy.feat.avx_ifma && xcr0_mask(6)) +#define cpu_has_movrs cpu_policy.feat.movrs#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)) +#define cpu_has_avx10 (cpu_policy.feat.avx10 && xcr0_mask(0xe6))#define cpu_has_xgetbv1 (cpu_has_xsave && cpu_policy.xstate.xgetbv1)
xen/arch/x86/x86_emulate/private.h +2 -0
@@ -622,6 +622,8 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_avx_vnni_int16 () (ctxt->cpuid->feat.avx_vnni_int16)#define vcpu_has_user_msr () (ctxt->cpuid->feat.user_msr) +#define vcpu_has_avx10 () (ctxt->cpuid->feat.avx10) +#define vcpu_must_have (feat) \ generate_exception_if(!vcpu_has_##feat(), X86_EXC_UD)
xen/arch/x86/x86_emulate/x86_emulate.c +11 -0
@@ -7880,6 +7880,17 @@ x86_emulate( op_bytes =8 << evex.lr; goto simd_zmm; +case X86EMUL_OPC_EVEX_F2 (5 ,0x6f ):/* vmovrs{b,w} mem,[xyz]mm{k} */ + elem_bytes =1 << evex.w; + fallthrough; +case X86EMUL_OPC_EVEX_F3 (5 ,0x6f ):/* vmovrs{d,q} mem,[xyz]mm{k} */ +generate_exception_if (ea.type !=OP_MEM || evex.brs,X86_EXC_UD ); +vcpu_must_have (avx10); +vcpu_must_have (movrs); +avx512_vlen_check (false); + op_bytes =16 << evex.lr; + goto simd_zmm; +case X86EMUL_OPC_EVEX_66 (5 ,0x78 ):/* vcvttph2uqq xmm/mem,[xyz]mm{k} */ case X86EMUL_OPC_EVEX_66 (5 ,0x79 ):/* vcvtph2uqq xmm/mem,[xyz]mm{k} */ case X86EMUL_OPC_EVEX_66 (5 ,0x7a ):/* vcvttph2qq xmm/mem,[xyz]mm{k} */
PATCH v4 2/16 x86emul: support AVX10 forms of SM4 insns
In reply to Jan BeulichSimply clone the VEX-encoded handling to cover the EVEX forms.
---
SDE: -dmr / -future
---
v4: Address v3 TODO. Move ahead in series, switching feature dependency to
plain AVX10. Add call to avx512_vlen_check().
v3: New.
tools/tests/x86_emulator/evex-disp8.c +6 -0
@@ -727,6 +727,11 @@ static const struct test movrs_all[] = { INSN(movrsw, f2, map5, 6f, vl, w, vl), }; +static const struct test sm4_all[] = { + INSN(sm4key4, f3, 0f38, da, vl, d_nb, vl), + INSN(sm4rnds4, f2, 0f38, da, vl, d_nb, vl), +}; +static const unsigned char vl_all[] = {VL_512 ,VL_128 ,VL_256 };static const unsigned char vl_128[] = {VL_128 };static const unsigned char vl_no128[] = {VL_512 ,VL_256 };
@@ -1124,5 +1129,6 @@ void evex_disp8_test(void *instr, structif ( cpu_has_avx10 ) {run (ctxt->addr_size ==64 && cpu_has_movrs, movrs, all); +run (cpu_has_sm4, sm4, all); } }
tools/tests/x86_emulator/predicates.c +2 -0
@@ -2025,6 +2025,8 @@ static const struct evex { { { 0xcc }, 2, T, R, pfx_66, Wn, L2 }, /* vrsqrt28p{s,d} */ { { 0xcd }, 2, T, R, pfx_66, Wn, LIG }, /* vrsqrt28s{s,d} */ { { 0xcf }, 2, T, R, pfx_66, W0, Ln }, /* vgf2p8mulb */ + { { 0xda }, 2, T, R, pfx_f3, W0, Ln }, /* vsm4key4 */ + { { 0xda }, 2, T, R, pfx_f2, W0, Ln }, /* vsm4rnds4 */ { { 0xdc }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenc */ { { 0xdd }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenclast */ { { 0xde }, 2, T, R, pfx_66, WIG, Ln }, /* vaesdec */
xen/arch/x86/x86_emulate/decode.c +1 -1
@@ -438,7 +438,7 @@ static const struct ext0f38_table { [0xd3] = { .simd_size = simd_other }, [0xd6] = { .simd_size = simd_other, .d8s = d8s_vl }, [0xd7] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, - [0xda] = { .simd_size = simd_other }, + [0xda] = { .simd_size = simd_other, .d8s = d8s_vl }, [0xdb] = { .simd_size = simd_packed_int, .two_op = 1 }, [0xdc ... 0xdf] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0xe0 ... 0xef] = { .to_mem = 1 },
xen/arch/x86/x86_emulate/x86_emulate.c +9 -0
@@ -6819,6 +6819,15 @@ x86_emulate( op_bytes =16 << vex.l; goto simd_0f_ymm; +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0xda ):/* vsm4key4 [xyz]mm/mem,[xyz]mm,[xyz]mm */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0xda ):/* vsm4rnds4 [xyz]mm/mem,[xyz]mm,[xyz]mm */ +vcpu_must_have (avx10); +vcpu_must_have (sm4); +generate_exception_if (evex.w || evex.brs || evex.opmsk,X86_EXC_UD ); +avx512_vlen_check (false); + op_bytes =16 << evex.lr; + goto simd_zmm; +case X86EMUL_OPC_VEX_66 (0x0f38 ,0xdc ):/* vaesenc {x,y}mm/mem,{x,y}mm,{x,y}mm */ case X86EMUL_OPC_VEX_66 (0x0f38 ,0xdd ):/* vaesenclast {x,y}mm/mem,{x,y}mm,{x,y}mm */ case X86EMUL_OPC_VEX_66 (0x0f38 ,0xde ):/* vaesdec {x,y}mm/mem,{x,y}mm,{x,y}mm */
PATCH v4 3/16 x86emul: support AVX10.1
In reply to Jan BeulichThis requires relaxing various pre-existing AVX512* checks, as AVX10.1 covers all AVX512* except PF, ER, 4FMAPS, 4VNNIW (support for all of which was removed meanwhile anyway), and VP2INTERSECT. At the same time all vector widths are always supported.
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 avx512_vlen_check() the original host_and_vcpu_must_have() is reduced 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).
---
v4: Switch to using fallthrough pseudo-keyword. Drop new _vlen_check()
helper again. Re-base.
v3: Add ChangeLog entry.
v2: Drop use of vsz128 field. Re-base, in particular over dropping of
Xeon Phi support.
CHANGELOG.md +1 -0
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog mitigate (by rate-limiting) the system wide impact of an HVM guest misusing atomic instructions. - Support for CPIO microcode in discrete multiboot modules. + - Support for AVX10.1. (Experimental) - On Arm: - Support for guest suspend and resume to/from RAM via vPSCI.
xen/arch/x86/include/asm/cpufeature.h +0 -13
@@ -200,29 +200,18 @@ 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_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)
@@ -248,7 +237,6 @@ static inline bool boot_cpu_has(unsigned#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_hybrid boot_cpu_has(X86_FEATURE_HYBRID) -#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 */
@@ -256,7 +244,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_fred boot_cpu_has(X86_FEATURE_FRED)#define cpu_has_lkgs boot_cpu_has(X86_FEATURE_LKGS)
xen/arch/x86/x86_emulate/private.h +0 -13
@@ -577,26 +577,15 @@ 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_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)
@@ -604,12 +593,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 +127 -116
840 lines not on this page · raw message
xen/arch/x86/xstate.c +1 -1
@@ -814,7 +814,7 @@ static void __init noinline xstate_checkif ( cpu_has_mpx )check_new_xstate (&s,X86_XCR0_BNDCSR |X86_XCR0_BNDREGS ); -if ( cpu_has_avx512f ) +if (boot_cpu_has (X86_FEATURE_AVX512F ) ||boot_cpu_has (X86_FEATURE_AVX10 ) )check_new_xstate (&s,X86_XCR0_HI_ZMM |X86_XCR0_ZMM |X86_XCR0_OPMASK );/*
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -366,7 +366,7 @@ XEN_CPUFEATURE(PREFETCHI, 15*32 XEN_CPUFEATURE(USER_MSR, 15*32+15) /*s U{RD,WR}MSR Instructions */ XEN_CPUFEATURE(UIRET_UIF, 15*32+17) /* UIRET updates UIF */ 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 */XEN_CPUFEATURE (SLSM ,15 *32 +24 )/* Static Lockstep Mode */ /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
Re: [PATCH v4 03/16] x86emul: support AVX10.1
Quoted 47 lines · Jan Beulich
This requires relaxing various pre-existing AVX512* checks, as AVX10.1 covers all AVX512* except PF, ER, 4FMAPS, 4VNNIW (support for all of which was removed meanwhile anyway), and VP2INTERSECT. At the same time all vector widths are always supported.
Note that
visa_check(), replacinghost_and_vcpu_must_have()uses, checks only the guest capability: We wouldn't expose AVX512* (nor AVX10) without the hardware supporting it. Similarly inavx512_vlen_check()the originalhost_and_vcpu_must_have()is reduced justvcpu_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, utilizingemul_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*().
Signed-off-by Jan Beulich <[email protected]>---
Probablyavx512_vlen_check()should have theavx512_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 justvcpu_must_have()where appropriate (should be [almost?] everywhere).
---
v4: Switch to using fallthrough pseudo-keyword. Drop new_vlen_check()
helper again. Re-base.
v3: Add ChangeLog entry.
v2: Drop use of vsz128 field. Re-base, in particular over dropping of
Xeon Phi support.
CHANGELOG.md The format is based on [Keep a Changelog · line 19
Quoted 4 lines
CHANGELOG.md +1
-0@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog mitigate (by rate-limiting) the system wide impact of an HVM guest misusing atomic instructions. - Support for CPIO microcode in discrete multiboot modules. + - Support for AVX10.1. (Experimental)
What should be done else to have not experimental support of AVX10.1?
Thanks.
~ Oleksii
Re: [PATCH v4 03/16] x86emul: support AVX10.1
Quoted 47 lines · Oleksii Kurochko
Quoted 44 lines · Jan Beulich
This requires relaxing various pre-existing AVX512* checks, as AVX10.1 covers all AVX512* except PF, ER, 4FMAPS, 4VNNIW (support for all of which was removed meanwhile anyway), and VP2INTERSECT. At the same time all vector widths are always supported.
Note that
visa_check(), replacinghost_and_vcpu_must_have()uses, checks only the guest capability: We wouldn't expose AVX512* (nor AVX10) without the hardware supporting it. Similarly inavx512_vlen_check()the originalhost_and_vcpu_must_have()is reduced justvcpu_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, utilizingemul_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*().
Signed-off-by Jan Beulich <[email protected]>---
Probablyavx512_vlen_check()should have theavx512_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 justvcpu_must_have()where appropriate (should be [almost?] everywhere).
---
v4: Switch to using fallthrough pseudo-keyword. Drop new_vlen_check()
helper again. Re-base.
v3: Add ChangeLog entry.
v2: Drop use of vsz128 field. Re-base, in particular over dropping of
Xeon Phi support.
Quoted 9 lines
CHANGELOG.md The format is based on [Keep a Changelog · line 19
Quoted 7 lines
CHANGELOG.md +1
-0@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog mitigate (by rate-limiting) the system wide impact of an HVM guest misusing atomic instructions. - Support for CPIO microcode in discrete multiboot modules. + - Support for AVX10.1. (Experimental)
Thanks.
Quoted 1 line
What should be done else to have not experimental support of AVX10.1?
Someone to actually try it out on real hardware. All my testing was with Intel's SDE.
Jan
PATCH v4 4/16 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).
---
v2: Re-base over dropping of Xeon Phi support.
tools/tests/x86_emulator/test_x86_emulator.c +42 -32
@@ -167,6 +167,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;
@@ -179,7 +184,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 )
@@ -189,13 +194,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 )
@@ -205,22 +210,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 )
@@ -235,12 +240,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 )
@@ -3192,7 +3202,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);
@@ -3216,7 +3226,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);
@@ -3339,7 +3349,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);
@@ -3369,7 +3379,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);
@@ -3394,7 +3404,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);
@@ -3426,7 +3436,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);
@@ -3554,7 +3564,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);
@@ -3589,7 +3599,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);
@@ -3772,7 +3782,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);
@@ -3797,7 +3807,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);
@@ -3987,7 +3997,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);
@@ -4013,7 +4023,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);
@@ -4115,7 +4125,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);
@@ -4205,7 +4215,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);
@@ -4398,7 +4408,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);
@@ -4994,7 +5004,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);
@@ -5037,7 +5047,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 {
@@ -5076,7 +5086,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);
@@ -5108,7 +5118,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);
@@ -5151,7 +5161,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);
@@ -5253,7 +5263,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);
@@ -5441,7 +5451,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);
@@ -5496,7 +5506,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 v4 5/16 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.
---
v2: Re-base over dropping of Xeon Phi support.
tools/tests/x86_emulator/evex-disp8.c +2 -1
@@ -1025,7 +1025,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
@@ -131,7 +131,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
@@ -143,7 +143,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_avx512bw (void )
@@ -154,7 +154,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 )
@@ -164,7 +164,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 )
@@ -260,7 +260,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 -2
@@ -179,8 +179,6 @@ void wrpkru(unsigned int val);#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 && \
PATCH v4 6/16 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.
---
SDE: -gnr / -gnr256
---
TBD: The testcase.mk change was for AVX10.1/256. It may, however, be
worthwhile to keep it.
TBD: May want to have separate AVX10 test blobs built, utilizing all of
the implied AVX512 sub-features.
The AVX512{BW,DQ} opmask tests could of course be cloned (i.e. rebuilt another time with -mavx512vl passed) accordingly, but the coverage gain would be pretty marginal.
---
v4: Drop use of vsz<N> fields. Series re-ordering adjustments. Drop stale
Phi leftovers. Re-base.
v2: Drop SDE 9.27.0 workaround. Re-base over dropping of Xeon Phi
support.
tools/tests/x86_emulator/evex-disp8.c +25 -3
@@ -1026,7 +1026,7 @@ 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 ; switch ( tests[i].esz )
@@ -1077,6 +1077,24 @@ static void test_group(const struct test } } +/* AVX512 (sub)features implied by AVX10. */ +#define avx10_has_avx512f cpu_has_avx10 +#define avx10_has_avx512bw cpu_has_avx10 +#define avx10_has_avx512cd cpu_has_avx10 +#define avx10_has_avx512dq cpu_has_avx10 +#define avx10_has_avx512_bf16 cpu_has_avx10 +#define avx10_has_avx512_bitalg cpu_has_avx10 +#define avx10_has_avx512_fp16 cpu_has_avx10 +#define avx10_has_avx512_ifma cpu_has_avx10 +#define avx10_has_avx512_vbmi cpu_has_avx10 +#define avx10_has_avx512_vbmi2 cpu_has_avx10 +#define avx10_has_avx512_vnni cpu_has_avx10 +#define avx10_has_avx512_vpopcntdq cpu_has_avx10 + +/* AVX512 sub-feature(s) /not/ implied by AVX10. */ +#define avx10_has_avx512_vp2intersect false +#define avx10_has_avx512_bmm false +void evex_disp8_test (void *instr,struct x86_emulate_ctxt *ctxt,const struct x86_emulate_ops *ops) {
@@ -1094,7 +1112,7 @@ void evex_disp8_test(void *instr, struct } \ } while ( false ) -#define RUN (feat, vl) run(cpu_has_ ## feat, feat, vl) +#define RUN (feat, vl) run(cpu_has_ ## feat || avx10_has_ ## feat, feat, vl)RUN (avx512f, all);RUN (avx512f,128 );
@@ -1120,11 +1138,15 @@ void evex_disp8_test(void *instr, structRUN (avx512_bmm, all);RUN (avx512_bmm, no128); -if ( cpu_has_avx512f ) +#undef RUN + +if ( cpu_has_avx512f || cpu_has_avx10 ) { +#define RUN (feat, vl) run(cpu_has_ ## feat, feat, vl)RUN (gfni, all);RUN (vaes, all);RUN (vpclmulqdq, all); +#undef RUN }if ( cpu_has_avx10 )
tools/tests/x86_emulator/testcase.mk +16 -0
@@ -7,6 +7,22 @@ $(call cc-options-add,CFLAGS,CC,$(EMBEDD CFLAGS += -ffreestanding -nostdinc -I$(XEN_ROOT)/tools/firmware/include CFLAGS += -fno-stack-protector -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 += $(cflags-vsz$(patsubst -DVEC_SIZE=%,%,$(filter -DVEC_SIZE=%,$($(TESTCASE)-cflags)))) +else +CFLAGS += $(cflags-vsz$(patsubst -DVEC_MAX=%,%,$(filter -DVEC_MAX=%,$($(TESTCASE)-cflags)))) +endif + +endif + LDFLAGS_DIRECT += $(shell { $(LD) -v --warn-rwx-segments; } >/dev/null 2>&1 && echo --no-warn-rwx-segments) .PHONY: all
tools/tests/x86_emulator/test_x86_emulator.c +87 -35
203 lines not on this page · raw message
tools/tests/x86_emulator/x86-emulate.c +1 -1
@@ -244,7 +244,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 )break ;default :return X86EMUL_UNHANDLEABLE ;
PATCH v4 7/16 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
@@ -10,8 +10,8 @@ CFLAGS += -fno-stack-protector -g0 $($(T 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
PATCH v4 8/16 x86/CPUID: enable AVX10.2 sub-leaf
In reply to Jan BeulichThe logic is modeled as closely as possible after that of leaf 7 sub-leaf handling.
---
While the "AVX10" infix is necessary everywhere, the "avx10" prefix on the bitfield name is redundant with the containing structure's field name (see "x86emul: support AVX10.2 media insns" for how this looks like in actual use). Do we want to special-case this in gen-cpuid.py?
---
v4: New.
tools/libs/light/libxl_cpuid.c +1 -0
@@ -343,6 +343,7 @@ int libxl_cpuid_parse_config(libxl_cpuidMSR_ENTRY (0x10a ,CPUID_REG_EAX ),MSR_ENTRY (0x10a ,CPUID_REG_EDX ),CPUID_ENTRY (0x80000021 ,NA ,CPUID_REG_ECX ), +CPUID_ENTRY (0x00000024 ,1 ,CPUID_REG_ECX ), #undef MSR_ENTRY#undef CPUID_ENTRY };
tools/misc/xen-cpuid.c +1 -0
@@ -38,6 +38,7 @@ static const struct { { "MSR_ARCH_CAPS.lo", "m10Al" }, { "MSR_ARCH_CAPS.hi", "m10Ah" }, { "CPUID 0x80000021.ecx", "e21c" }, + { "CPUID 0x00000024:1.ecx", "24c1" }, };#define COL_ALIGN "24"
xen/arch/x86/cpu/common.c +11 -0
@@ -547,6 +547,17 @@ void identify_cpu(struct cpuinfo_x86 *c) &c->x86_capability[FEATURESET_Da1], &tmp, &tmp, &tmp); +if (cpu_has (c,X86_FEATURE_AVX10 ) && c->cpuid_level >=0x24 ) { +uint32_t max_subleaf; + +cpuid_count (0x24 ,0 , &max_subleaf, &tmp, &tmp, &tmp); +if (max_subleaf >=1 ) +cpuid_count (0x24 ,1 , + &tmp, &tmp, + &c->x86_capability[FEATURESET_24c1], + &tmp); + } +if (test_bit (X86_FEATURE_ARCH_CAPS , c->x86_capability)) { val =rdmsr (MSR_ARCH_CAPABILITIES ); c->x86_capability[FEATURESET_m10Al] = val;
xen/arch/x86/cpu-policy.c +3 -0
@@ -277,6 +277,9 @@ static void recalculate_misc(struct cpu_ p->avx10.raw[0 ].b &=0x000700ff ; p->avx10.raw[0 ].c =0 ; p->avx10.raw[0 ].d =0 ; + p->avx10.raw[1 ].a =0 ; + p->avx10.raw[1 ].b =0 ; + p->avx10.raw[1 ].d =0 ;if ( !p->feat.avx10 || !p->avx10.version || !p->avx10.vsz512 || !p->avx10.vsz256 || !p->avx10.vsz128 ) {
xen/include/public/arch-x86/cpufeatureset.h +3 -0
@@ -409,6 +409,9 @@ XEN_CPUFEATURE(ITS_NO, 16*32 XEN_CPUFEATURE(TSA_SQ_NO, 18*32+ 1) /*A No Store Queue Transitive Scheduler Attacks */XEN_CPUFEATURE (TSA_L1_NO ,18 *32 +2 )/*A No L1D Transitive Scheduler Attacks */ +/* Intel-defined CPU features, CPUID level 0x00000024:1.ecx, word 19 */ +XEN_CPUFEATURE(AVX10_V1_AUX, 19*32+ 2) /* AVX10 V1 Auxiliary Instructions */ +#endif /* XEN_CPUFEATURE */ /* Clean up from a default include. Close the enum (for C). */
xen/include/xen/lib/x86/cpu-policy.h +10 -1
@@ -23,6 +23,7 @@#define FEATURESET_m10Al 16/* 0x0000010a.eax */ #define FEATURESET_m10Ah 17/* 0x0000010a.edx */ #define FEATURESET_e21c 18/* 0x80000021.ecx */ +#define FEATURESET_24c1 19/* 0x00000024:1.ecx */ struct cpuid_leaf {
@@ -64,7 +65,7 @@ const char *x86_cpuid_vendor_to_str(unsi#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_AVX10 (1u + 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, \
@@ -275,6 +276,14 @@ struct cpu_policy bool vsz128:1, vsz256:1, vsz512:1; uint32_t :13; uint32_t /* c */:32, /* d */:32; + +/* Subleaf 1. */ + uint32_t /* a */:32, /* b */:32; +union { +uint32_t _24c1; + struct { DECL_BITFIELD(24c1); }; + }; + uint32_t /* d */:32; }; } avx10;
xen/arch/x86/lib/cpu-policy/cpuid.c +2 -0
@@ -82,6 +82,7 @@ void x86_cpu_policy_to_featureset( fs[FEATURESET_m10Al] = p->arch_caps.lo; fs[FEATURESET_m10Ah] = p->arch_caps.hi; fs[FEATURESET_e21c] = p->extd.e21c; + fs[FEATURESET_24c1] = p->avx10._24c1; } void x86_cpu_featureset_to_policy(
@@ -106,6 +107,7 @@ void x86_cpu_featureset_to_policy( p->arch_caps.lo = fs[FEATURESET_m10Al]; p->arch_caps.hi = fs[FEATURESET_m10Ah]; p->extd.e21c = fs[FEATURESET_e21c]; + p->avx10._24c1 = fs[FEATURESET_24c1]; }void x86_cpu_policy_recalc_synth (struct cpu_policy *p)
xen/tools/gen-cpuid.py +3 -0
@@ -310,6 +310,9 @@ def crunch_numbers(state): AVX512BW: [AVX512_VBMI, AVX512_VBMI2, AVX512_BITALG, AVX512_BF16, AVX512_FP16, AVX512_BMM], + # AVX10 discrete features. + AVX10: [AVX10_V1_AUX], + # Extensions with VEX/EVEX encodings keyed to a separate feature # flag are made dependents of their respective legacy feature. PCLMULQDQ: [VPCLMULQDQ],
PATCH v4 9/16 x86emul: support AVX10.2 scalar compare insns
In reply to Jan BeulichSimply clone code from their V{,U}COMIS{S,D,H} counterparts.
While there drop a redundant EVEX.W check from V{,U}COMISH handling.
---
SDE: -dmr / -future
---
v4: Update encodings to latest spec version. Series re-ordering
adjustments.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +11 -0
@@ -81,6 +81,7 @@ enum esz { ESZ_w, ESZ_bw, ESZ_fp16, +#define ESZ_bf16 ESZ_fp16 };#ifndef __i386__
@@ -720,6 +721,14 @@ static const struct test vpclmulqdq_all[ INSN(pclmulqdq, 66, 0f3a, 44, vl, q_nb, vl) }; +static const struct test avx10_2_all[] = { +INSN (comisbf16,66 , map5,2f , el, bf16, el), +INSN_SFP (comx,0f ,2f ), +INSN (comxsh, f3, map5,2f , el, fp16, el), +INSN_SFP (ucomx,0f ,2e ), +INSN (ucomxsh, f3, map5,2e , el, fp16, el), +}; +static const struct test movrs_all[] = {INSN (movrsb, f2, map5,6f , vl, b, vl),INSN (movrsd, f3, map5,6f , vl, d_nb, vl),
@@ -1154,4 +1163,6 @@ void evex_disp8_test(void *instr, structrun (ctxt->addr_size ==64 && cpu_has_movrs, movrs, all);run (cpu_has_sm4, sm4, all); } + +run (cpu_has_avx10_2, avx10_2, all); }
tools/tests/x86_emulator/predicates.c +7 -0
@@ -1682,8 +1682,12 @@ static const struct evex { { { 0x2d }, 2, T, R, pfx_f2, Wn, LIG }, /* vcvtsd2si */ { { 0x2e }, 2, T, R, pfx_no, W0, LIG }, /* vucomiss */ { { 0x2e }, 2, T, R, pfx_66, W1, LIG }, /* vucomisd */ + { { 0x2e }, 2, T, R, pfx_f2, W1, LIG }, /* vucomxsd */ + { { 0x2e }, 2, T, R, pfx_f3, W0, LIG }, /* vucomxss */ { { 0x2f }, 2, T, R, pfx_no, W0, LIG }, /* vcomiss */ { { 0x2f }, 2, T, R, pfx_66, W1, LIG }, /* vcomisd */ + { { 0x2f }, 2, T, R, pfx_f2, W1, LIG }, /* vcomxsd */ + { { 0x2f }, 2, T, R, pfx_f3, W0, LIG }, /* vcomxss */ { { 0x51 }, 2, T, R, pfx_no, W0, Ln }, /* vsqrtps */ { { 0x51 }, 2, T, R, pfx_66, W1, Ln }, /* vsqrtpd */ { { 0x51 }, 2, T, R, pfx_f3, W0, LIG }, /* vsqrtss */
@@ -2102,7 +2106,10 @@ static const struct evex { { { 0x2c }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttsh2si */ { { 0x2d }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvtsh2si */ { { 0x2e }, 2, T, R, pfx_no, W0, LIG }, /* vucomish */ + { { 0x2e }, 2, T, R, pfx_f3, W0, LIG }, /* vucomxsh */ { { 0x2f }, 2, T, R, pfx_no, W0, LIG }, /* vcomish */ + { { 0x2f }, 2, T, R, pfx_66, W0, LIG }, /* vcomisbf16 */ + { { 0x2f }, 2, T, R, pfx_f3, W0, LIG }, /* vcomxsh */ { { 0x51 }, 2, T, R, pfx_no, W0, Ln }, /* vsqrtph */ { { 0x51 }, 2, T, R, pfx_f3, W0, LIG }, /* vsqrtsh */ { { 0x58 }, 2, T, R, pfx_no, W0, Ln }, /* vaddph */
tools/tests/x86_emulator/x86-emulate.h +2 -0
@@ -215,6 +215,8 @@ void wrpkru(unsigned int val);#define cpu_has_avx_vnni_int16 (cpu_policy.feat.avx_vnni_int16 && \ xcr0_mask(6))#define cpu_has_avx10 (cpu_policy.feat.avx10 && xcr0_mask(0xe6)) +#define cpu_has_avx10_2 (cpu_policy.avx10.version >= 2 && \ + xcr0_mask(0xe6))#define cpu_has_xgetbv1 (cpu_has_xsave && cpu_policy.xstate.xgetbv1)
xen/arch/x86/x86_emulate/decode.c +2 -3
@@ -1515,9 +1515,8 @@ int x86emul_decode(struct x86_emulate_st s->fp16 = true;break ; -case 0x2e :case 0x2f :/* v{,u}comish */ -if ( !s->evex.pfx ) - s->fp16 = true; +case 0x2e :case 0x2f :/* v{,u}com{i,x}sh, vcomisbf16 */ + s->fp16 = true; s->simd_size = simd_none;break ;
xen/arch/x86/x86_emulate/private.h +4 -4
@@ -318,7 +318,7 @@ struct x86_emulate_state {bool lock_prefix;bool not_64bit;/* Instruction not available in 64bit. */ bool fpu_ctrl;/* Instruction is an FPU control one. */ -bool fp16;/* Instruction has half-precision FP source operand. */ +bool fp16;/* Instruction has half-precision FP or BF16 source. */ opcode_desc_t desc;union vex vex;union evex evex;
@@ -609,10 +609,10 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_avx_vnni_int16 () (ctxt->cpuid->feat.avx_vnni_int16)#define vcpu_has_user_msr () (ctxt->cpuid->feat.user_msr) -#define vcpu_has_avx10 () (ctxt->cpuid->feat.avx10) +#define vcpu_has_avx10 (minor) (ctxt->cpuid->avx10.version >= (minor)) -#define vcpu_must_have (feat) \ - generate_exception_if(!vcpu_has_##feat(), X86_EXC_UD) +#define vcpu_must_have (feat, ...) \ + generate_exception_if(!vcpu_has_##feat(__VA_ARGS__), X86_EXC_UD)#ifdef __XEN__/*
xen/arch/x86/x86_emulate/x86_emulate.c +14 -3
@@ -3825,7 +3825,6 @@ x86_emulate(case X86EMUL_OPC_EVEX (5 ,0x2e ):/* vucomish xmm/m16,xmm */ case X86EMUL_OPC_EVEX (5 ,0x2f ):/* vcomish xmm/m16,xmm */ visa_check (_fp16); -generate_exception_if (evex.w,X86_EXC_UD );/* fall through */ CASE_SIMD_PACKED_FP(_EVEX, 0x0f, 0x2e): /* vucomis{s,d} xmm/mem,xmm */ CASE_SIMD_PACKED_FP(_EVEX, 0x0f, 0x2f): /* vcomis{s,d} xmm/mem,xmm */
@@ -3834,6 +3833,7 @@ x86_emulate( evex.w != evex.pfx), X86_EXC_UD);visa_check (f); + vcomi_evex:if ( !evex.brs )avx512_vlen_check (true);get_fpu (X86EMUL_FPU_zmm);
@@ -3842,6 +3842,17 @@ x86_emulate( op_bytes =2 << (!state->fp16 + evex.w); goto vcomi; + CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2e): /* vucomxs{s,d} xmm/mem,xmm */ + CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2f): /* vcomxs{s,d} xmm/mem,xmm */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x2e ):/* vucomxsh xmm/m16,xmm */ +case X86EMUL_OPC_EVEX_66 (5 ,0x2f ):/* vcomisbf16 xmm/m16,xmm */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x2f ):/* vcomxsh xmm/m16,xmm */ +generate_exception_if ((evex.reg !=0xf || !evex.RX || evex.opmsk || + evex.w != (evex.pfx == vex_f2)), +X86_EXC_UD ); +vcpu_must_have (avx10,2 ); + goto vcomi_evex; +#endif case X86EMUL_OPC (0x0f ,0x30 ):/* wrmsr */
@@ -6831,7 +6842,7 @@ x86_emulate(case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0xda ):/* vsm4key4 [xyz]mm/mem,[xyz]mm,[xyz]mm */ case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0xda ):/* vsm4rnds4 [xyz]mm/mem,[xyz]mm,[xyz]mm */ -vcpu_must_have (avx10); +vcpu_must_have (avx10,1 );vcpu_must_have (sm4);generate_exception_if (evex.w || evex.brs || evex.opmsk,X86_EXC_UD );avx512_vlen_check (false);
@@ -7905,7 +7916,7 @@ x86_emulate( fallthrough;case X86EMUL_OPC_EVEX_F3 (5 ,0x6f ):/* vmovrs{d,q} mem,[xyz]mm{k} */ generate_exception_if (ea.type !=OP_MEM || evex.brs,X86_EXC_UD ); -vcpu_must_have (avx10); +vcpu_must_have (avx10,1 );vcpu_must_have (movrs);avx512_vlen_check (false); op_bytes =16 << evex.lr;
PATCH v4 10/16 x86emul: support AVX10.2 partial copy insns
In reply to Jan BeulichExtend existing VMOV{Q,W} logic accordingly.
---
SDE: -dmr / -future
---
v4: Series re-ordering adjustments.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +8 -0
@@ -729,6 +729,13 @@ static const struct test avx10_2_all[] = INSN(ucomxsh, f3, map5, 2e, el, fp16, el), }; +static const struct test avx10_2_128[] = { +INSN (movd, f3,0f ,7e , el, d, el), +INSN (movd,66 ,0f , d6, el, d, el), +INSN (movw, f3, map5,6e , el, fp16, el), +INSN (movw, f3, map5,7e , el, fp16, el), +}; +static const struct test movrs_all[] = {INSN (movrsb, f2, map5,6f , vl, b, vl),INSN (movrsd, f3, map5,6f , vl, d_nb, vl),
@@ -1165,4 +1172,5 @@ void evex_disp8_test(void *instr, struct }run (cpu_has_avx10_2, avx10_2, all); +run (cpu_has_avx10_2, avx10_2,128 ); }
tools/tests/x86_emulator/predicates.c +4 -2
@@ -1782,7 +1782,7 @@ static const struct evex { { { 0x7b }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvtusi2ss */ { { 0x7b }, 2, T, R, pfx_f2, Wn, LIG }, /* vcvtusi2sd */ { { 0x7e }, 2, T, W, pfx_66, Wn, L0 }, /* vmov{d,q} */ - { { 0x7e }, 2, T, R, pfx_f3, W1, L0 }, /* vmovq */ + { { 0x7e }, 2, T, R, pfx_f3, Wn, L0 }, /* vmov{d,q} */ { { 0x7f }, 2, T, W, pfx_66, Wn, Ln }, /* vmovdqa{32,64} */ { { 0x7f }, 2, T, W, pfx_f3, Wn, Ln }, /* vmovdqu{32,64} */ { { 0x7f }, 2, T, W, pfx_f2, Wn, Ln }, /* vmovdqu{8,16} */
@@ -1799,7 +1799,7 @@ static const struct evex { { { 0xd3 }, 2, T, R, pfx_66, W1, Ln }, /* vpsrlq */ { { 0xd4 }, 2, T, R, pfx_66, W1, Ln }, /* vpaddq */ { { 0xd5 }, 2, T, R, pfx_66, WIG, Ln }, /* vpmullw */ - { { 0xd6 }, 2, T, W, pfx_66, W1, L0 }, /* vmovq */ + { { 0xd6 }, 2, T, W, pfx_66, Wn, L0 }, /* vmov{d,q} */ { { 0xd8 }, 2, T, R, pfx_66, WIG, Ln }, /* vpsubusb */ { { 0xd9 }, 2, T, R, pfx_66, WIG, Ln }, /* vpsubusw */ { { 0xda }, 2, T, R, pfx_66, WIG, Ln }, /* vpminub */
@@ -2133,6 +2133,7 @@ static const struct evex { { { 0x5f }, 2, T, R, pfx_no, W0, Ln }, /* vmaxph */ { { 0x5f }, 2, T, R, pfx_f3, W0, LIG }, /* vmaxsh */ { { 0x6e }, 2, T, R, pfx_66, WIG, L0 }, /* vmovw */ + { { 0x6e }, 2, T, R, pfx_f3, W0, L0 }, /* vmovw */ { { 0x6f }, 2, T, R, pfx_f3, Wn, Ln }, /* vmovrs{d,q} */ { { 0x6f }, 2, T, R, pfx_f2, Wn, Ln }, /* vmovrs{b,w} */ { { 0x78 }, 2, T, R, pfx_no, W0, Ln }, /* vcvttph2udq */
@@ -2153,6 +2154,7 @@ static const struct evex { { { 0x7d }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtw2ph */ { { 0x7d }, 2, T, R, pfx_f2, W0, Ln }, /* vcvtuwph */ { { 0x7e }, 2, T, W, pfx_66, WIG, L0 }, /* vmovw */ + { { 0x7e }, 2, T, W, pfx_f3, W0, L0 }, /* vmovw */ }, evex_map6[] = { { { 0x13 }, 2, T, R, pfx_66, W0, Ln }, /* vcvtph2psx */ { { 0x13 }, 2, T, R, pfx_no, W0, LIG }, /* vcvtsh2ss */
xen/arch/x86/x86_emulate/decode.c +7 -7
@@ -293,7 +293,7 @@ static const struct twobyte_table { [0xd0] = { DstImplicit|SrcMem|ModRM, simd_other }, [0xd1 ... 0xd3] = { DstImplicit|SrcMem|ModRM, simd_128, 4 }, [0xd4 ... 0xd5] = { DstImplicit|SrcMem|ModRM, simd_packed_int, d8s_vl }, - [0xd6] = { DstMem|SrcImplicit|ModRM|Mov, simd_other, 3 }, + [0xd6] = { DstMem|SrcImplicit|ModRM|Mov, simd_other, d8s_dq }, [0xd7] = { DstReg|SrcImplicit|ModRM|Mov }, [0xd8 ... 0xdf] = { DstImplicit|SrcMem|ModRM, simd_packed_int, d8s_vl }, [0xe0] = { DstImplicit|SrcMem|ModRM, simd_packed_int, d8s_vl },
@@ -803,7 +803,7 @@ decode_twobyte(struct x86_emulate_stateif ( s->vex.pfx == vex_f3 )/* movq xmm/m64,xmm */ {case X86EMUL_OPC_VEX_F3 (0 ,0x7e ):/* vmovq xmm/m64,xmm */ -case X86EMUL_OPC_EVEX_F3 (0 ,0x7e ):/* vmovq xmm/m64,xmm */ +case X86EMUL_OPC_EVEX_F3 (0 ,0x7e ):/* vmov{d,q} xmm/mem,xmm */ s->desc = DstImplicit | SrcMem | TwoOp; s->simd_size = simd_other;/* Avoid the s->desc clobbering of TwoOp below. */
@@ -1416,7 +1416,7 @@ int x86emul_decode(struct x86_emulate_stbreak ;case 0x7e :/* vmovq xmm/m64,xmm needs special casing */ -if ( disp8scale ==2 && s->evex.pfx == vex_f3 ) +if ( disp8scale ==2 && s->evex.pfx == vex_f3 && s->evex.w ) disp8scale =3 ;break ;
@@ -1525,13 +1525,13 @@ int x86emul_decode(struct x86_emulate_st s->fp16 = true;break ; -case 0x6e :/* vmovw r/m16, xmm */ +case 0x6e :/* vmovw r/x/m16, xmm */ d = (d & ~SrcMask) | SrcMem16;/* fall through */ -case 0x7e :/* vmovw xmm, r/m16 */ +case 0x7e :/* vmovw xmm, r/x/m16 */ + s->fp16 = true;if ( s->evex.pfx == vex_66 ) - s->fp16 = true; - s->simd_size = simd_none; + s->simd_size = simd_none;break ;case 0x78 :case 0x79 :/* vcvt{,t}ph2u{d,q}q, vcvt{,t}sh2usi */
xen/arch/x86/x86_emulate/x86_emulate.c +10 -6
@@ -4938,13 +4938,17 @@ x86_emulate( op_bytes =8 ; goto simd_0f_int; -case X86EMUL_OPC_EVEX_F3 (0x0f ,0x7e ):/* vmovq xmm/m64,xmm */ -case X86EMUL_OPC_EVEX_66 (0x0f ,0xd6 ):/* vmovq xmm,xmm/m64 */ -generate_exception_if (evex.lr || !evex.w || evex.opmsk || evex.brs, -X86_EXC_UD ); -visa_check (f); +case X86EMUL_OPC_EVEX_F3 (0x0f ,0x7e ):/* vmov{d,q} xmm/mem,xmm */ +case X86EMUL_OPC_EVEX_66 (0x0f ,0xd6 ):/* vmov{d,q} xmm,xmm/mem */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x6e ):/* vmovw xmm/m16,xmm */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x7e ):/* vmovw xmm,xmm/m16 */ +generate_exception_if (evex.lr || evex.opmsk || evex.brs,X86_EXC_UD ); +if ( evex.w ) +visa_check (f); +else +vcpu_must_have (avx10,2 ); d |= TwoOp; - op_bytes =8 ; + op_bytes =2 << (!state->fp16 + evex.w); goto simd_zmm;#endif /* !X86EMUL_NO_SIMD */
PATCH v4 11/16 x86emul: support AVX10.2 media insns
In reply to Jan BeulichThese are all very similar to various existing insns.
---
SDE: -dmr / -future
---
In evex-disp8.c, should we separately have avx10_v1_aux_all[]? If so, all the convert insns would also need moving/copying there.
---
v4: Series re-ordering adjustments. Update to spec version 6.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +14 -0
@@ -725,6 +725,20 @@ static const struct test avx10_2_all[] =INSN (comisbf16,66 , map5,2f , el, bf16, el),INSN_SFP (comx,0f ,2f ),INSN (comxsh, f3, map5,2f , el, fp16, el), + INSN(dpphps, , 0f38, 52, vl, d, vl), + INSN(mpsadbw, f3, 0f3a, 42, vl, d_nb, vl), + INSN(pdpbssd, f2, 0f38, 50, vl, d, vl), + INSN(pdpbssds, f2, 0f38, 51, vl, d, vl), + INSN(pdpbsud, f3, 0f38, 50, vl, d, vl), + INSN(pdpbsuds, f3, 0f38, 51, vl, d, vl), + INSN(pdpbuud, , 0f38, 50, vl, d, vl), + INSN(pdpbuuds, , 0f38, 51, vl, d, vl), + INSN(pdpwsud, f3, 0f38, d2, vl, d, vl), + INSN(pdpwsuds, f3, 0f38, d3, vl, d, vl), + INSN(pdpwusd, 66, 0f38, d2, vl, d, vl), + INSN(pdpwusds, 66, 0f38, d3, vl, d, vl), + INSN(pdpwuud, , 0f38, d2, vl, d, vl), + INSN(pdpwuuds, , 0f38, d3, vl, d, vl),INSN_SFP (ucomx,0f ,2e ), INSN(ucomxsh, f3, map5, 2e, el, fp16, el), };
tools/tests/x86_emulator/predicates.c +14 -0
@@ -1927,8 +1927,15 @@ static const struct evex { { { 0x4d }, 2, T, R, pfx_66, Wn, LIG }, /* vrcp14s{s,d} */ { { 0x4e }, 2, T, R, pfx_66, Wn, Ln }, /* vrsqrt14p{s,d} */ { { 0x4f }, 2, T, R, pfx_66, Wn, LIG }, /* vrsqrt14s{s,d} */ + { { 0x50 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpbuud */ { { 0x50 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpbusd */ + { { 0x50 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpbsud */ + { { 0x50 }, 2, T, R, pfx_f2, W0, Ln }, /* vpdpbssd */ + { { 0x51 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpbuuds */ { { 0x51 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpbusds */ + { { 0x51 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpbsuds */ + { { 0x51 }, 2, T, R, pfx_f2, W0, Ln }, /* vpdpbssds */ + { { 0x52 }, 2, T, R, pfx_no, W0, Ln }, /* vdpphps */ { { 0x52 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwssd */ { { 0x52 }, 2, T, R, pfx_f3, W0, Ln }, /* vdpbf16ps */ { { 0x52 }, 2, T, R, pfx_f2, W0, L2 }, /* vp4dpwssd */
@@ -2029,6 +2036,12 @@ static const struct evex { { { 0xcc }, 2, T, R, pfx_66, Wn, L2 }, /* vrsqrt28p{s,d} */ { { 0xcd }, 2, T, R, pfx_66, Wn, LIG }, /* vrsqrt28s{s,d} */ { { 0xcf }, 2, T, R, pfx_66, W0, Ln }, /* vgf2p8mulb */ + { { 0xd2 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuud */ + { { 0xd2 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusd */ + { { 0xd2 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsud */ + { { 0xd3 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuuds */ + { { 0xd3 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusds */ + { { 0xd3 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsuds */ { { 0xda }, 2, T, R, pfx_f3, W0, Ln }, /* vsm4key4 */ { { 0xda }, 2, T, R, pfx_f2, W0, Ln }, /* vsm4rnds4 */ { { 0xdc }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenc */
@@ -2075,6 +2088,7 @@ static const struct evex { { { 0x3e }, 3, T, R, pfx_66, Wn, Ln }, /* vpcmpu{b,w} */ { { 0x3f }, 3, T, R, pfx_66, Wn, Ln }, /* vpcmp{b,w} */ { { 0x42 }, 3, T, R, pfx_66, W0, Ln }, /* vdbpsadbw */ + { { 0x42 }, 3, T, R, pfx_f3, W0, Ln }, /* vmpsadbw */ { { 0x43 }, 3, T, R, pfx_66, Wn, L1|L2 }, /* vshufi{32x4,64x2} */ { { 0x44 }, 3, T, R, pfx_66, WIG, Ln }, /* vpclmulqdq */ { { 0x50 }, 3, T, R, pfx_66, Wn, Ln }, /* vrangep{s,d} */
xen/arch/x86/x86_emulate/decode.c +2 -2
@@ -434,8 +434,8 @@ static const struct ext0f38_table { [0xcb] = { .simd_size = simd_other, .d8s = d8s_vl }, [0xcc ... 0xcd] = { .simd_size = simd_other, .two_op = 1, .d8s = d8s_vl }, [0xcf] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, - [0xd2] = { .simd_size = simd_other }, - [0xd3] = { .simd_size = simd_other }, + [0xd2] = { .simd_size = simd_other, .d8s = d8s_vl }, + [0xd3] = { .simd_size = simd_other, .d8s = d8s_vl }, [0xd6] = { .simd_size = simd_other, .d8s = d8s_vl }, [0xd7] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0xda] = { .simd_size = simd_other, .d8s = d8s_vl },
xen/arch/x86/x86_emulate/x86_emulate.c +32 -0
@@ -6169,6 +6169,30 @@ x86_emulate(avx512_vlen_check (true); goto simd_zmm; +case X86EMUL_OPC_EVEX (0x0f38 ,0x50 ):/* vpdpbuud [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0x50 ):/* vpdpbsud [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x50 ):/* vpdpbssd [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX (0x0f38 ,0x51 ):/* vpdpbuuds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0x51 ):/* vpdpbsuds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x51 ):/* vpdpbssds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX (0x0f38 ,0xd2 ):/* vpdpwuud [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0xd2 ):/* vpdpwusd [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0xd2 ):/* vpdpwsud [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX (0x0f38 ,0xd3 ):/* vpdpwuuds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0xd3 ):/* vpdpwusds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0xd3 ):/* vpdpwsuds [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +generate_exception_if (evex.w,X86_EXC_UD ); +if ( !cp->avx10.avx10_v1_aux ) +vcpu_must_have (avx10,2 ); + op_bytes =16 << evex.lr; + goto avx512f_no_sae; + +case X86EMUL_OPC_EVEX (0x0f38 ,0x52 ):/* vdpphps [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +generate_exception_if (evex.w,X86_EXC_UD ); +vcpu_must_have (avx10,2 ); + op_bytes =16 << evex.lr; + goto avx512f_no_sae; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x8f ):/* vpshufbitqmb [xyz]mm/mem,[xyz]mm,k{k} */ generate_exception_if (evex.w || !evex.r || !evex.R || evex.z,X86_EXC_UD );/* fall through */
@@ -7635,6 +7659,14 @@ x86_emulate(visa_check (bw); goto opmask_shift_imm; +case X86EMUL_OPC_EVEX_F3 (0x0f3a ,0x42 ):/* vmpsadbw $imm8,[xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +generate_exception_if (evex.w || evex.brs,X86_EXC_UD ); +vcpu_must_have (avx10,2 ); +avx512_vlen_check (false); + op_bytes =16 << evex.lr; + fault_suppression = false; + goto simd_imm8_zmm; +case X86EMUL_OPC_66 (0x0f3a ,0x44 ):/* pclmulqdq $imm8,xmm/m128,xmm */ case X86EMUL_OPC_VEX_66 (0x0f3a ,0x44 ):/* vpclmulqdq $imm8,{x,y}mm/mem,{x,y}mm,{x,y}mm */ host_and_vcpu_must_have (pclmulqdq);
PATCH v4 12/16 x86emul: support AVX10.2 minmax insns
In reply to Jan BeulichWhile they use new major opcodes, they are still pretty similar to various existing insns.
---
SDE: -dmr / -future
---
v4: Update to spec version 3. Switch to using fallthrough pseudo-
keyword.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +5 -0
@@ -726,6 +726,11 @@ static const struct test avx10_2_all[] =INSN_SFP (comx,0f ,2f ),INSN (comxsh, f3, map5,2f , el, fp16, el), INSN(dpphps, , 0f38, 52, vl, d, vl), + INSN(minmax, 66, 0f3a, 52, vl, sd, vl), + INSN(minmax, 66, 0f3a, 53, el, sd, el), + INSN(minmaxbf16, f2, 0f3a, 52, vl, bf16, vl), + INSN(minmaxph, , 0f3a, 52, vl, fp16, vl), + INSN(minmaxsh, , 0f3a, 53, el, fp16, el), INSN(mpsadbw, f3, 0f3a, 42, vl, d_nb, vl), INSN(pdpbssd, f2, 0f38, 50, vl, d, vl), INSN(pdpbssds, f2, 0f38, 51, vl, d, vl),
tools/tests/x86_emulator/predicates.c +5 -0
@@ -2093,6 +2093,11 @@ static const struct evex { { { 0x44 }, 3, T, R, pfx_66, WIG, Ln }, /* vpclmulqdq */ { { 0x50 }, 3, T, R, pfx_66, Wn, Ln }, /* vrangep{s,d} */ { { 0x51 }, 3, T, R, pfx_66, Wn, LIG }, /* vranges{s,d} */ + { { 0x52 }, 3, T, R, pfx_no, W0, Ln }, /* vminmaxph */ + { { 0x52 }, 3, T, R, pfx_66, Wn, Ln }, /* vminmaxp{s,d} */ + { { 0x52 }, 3, T, R, pfx_f2, W0, Ln }, /* vminmaxbf16 */ + { { 0x53 }, 3, T, R, pfx_no, W0, LIG }, /* vminmaxsh */ + { { 0x53 }, 3, T, R, pfx_66, Wn, LIG }, /* vminmaxs{s,d} */ { { 0x54 }, 3, T, R, pfx_66, Wn, Ln }, /* vfixupimmp{s,d} */ { { 0x55 }, 3, T, R, pfx_66, Wn, LIG }, /* vfixumpimms{s,d} */ { { 0x56 }, 3, T, R, pfx_no, W0, Ln }, /* vreduceph */
xen/arch/x86/x86_emulate/decode.c +8 -0
@@ -500,6 +500,8 @@ static const struct ext0f3a_table { [0x4c] = { .simd_size = simd_packed_int, .four_op = 1 }, [0x50] = { .simd_size = simd_packed_fp, .d8s = d8s_vl }, [0x51] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, + [0x52] = { .simd_size = simd_packed_fp, .d8s = d8s_vl }, + [0x53] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x54] = { .simd_size = simd_packed_fp, .d8s = d8s_vl }, [0x55] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x56] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl },
@@ -1468,6 +1470,7 @@ int x86emul_decode(struct x86_emulate_stcase 0x0a :/* vrndscalesh */ case 0x26 :/* vfpclassph */ case 0x27 :/* vfpclasssh */ +case 0x53 :/* vminmaxsh */ case 0x56 :/* vgetmantph */ case 0x57 :/* vgetmantsh */ case 0x66 :/* vreduceph */
@@ -1476,6 +1479,11 @@ int x86emul_decode(struct x86_emulate_st s->fp16 = true;break ; +case 0x52 :/* vminmax{ph,bf16} */ +if ( !s->evex.pfx || s->evex.pfx == vex_f2 ) + s->fp16 = true; +break ; +case 0xc2 :/* vpcmp{p,s}h */ if ( !(s->evex.pfx &VEX_PREFIX_DOUBLE_MASK ) ) s->fp16 = true;
xen/arch/x86/x86_emulate/x86_emulate.c +15 -0
@@ -7697,6 +7697,21 @@ x86_emulate(generate_exception_if (vex.w,X86_EXC_UD ); goto simd_0f_int_imm8; +case X86EMUL_OPC_EVEX_F2 (0x0f3a ,0x52 ):/* vminmaxbf16 $imm8,[xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +generate_exception_if (ea.type !=OP_MEM && evex.brs,X86_EXC_UD ); + op_bytes =16 << evex.lr; + fallthrough; +case X86EMUL_OPC_EVEX (0x0f3a ,0x52 ):/* vminmaxph $imm8,[xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX (0x0f3a ,0x53 ):/* vminmaxsh $imm,xmm/m16,xmm,xmm,xmm{k} */ +generate_exception_if (vex.w,X86_EXC_UD ); + fallthrough; +case X86EMUL_OPC_EVEX_66 (0x0f3a ,0x52 ):/* vminmaxp{s,d} $imm8,[xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ +case X86EMUL_OPC_EVEX_66 (0x0f3a ,0x53 ):/* vminmaxs{s,d} $imm8,xmm/mem,xmm,xmm{k} */ +vcpu_must_have (avx10,2 ); +if ( ea.type !=OP_REG || !evex.brs ) +avx512_vlen_check (b &1 ); + goto simd_imm8_zmm; +case X86EMUL_OPC_VEX_66 (0x0f3a ,0x5c ):/* vfmaddsubps {x,y}mm,{x,y}mm/mem,{x,y}mm,{x,y}mm */ /* vfmaddsubps {x,y}mm/mem,{x,y}mm,{x,y}mm,{x,y}mm */ case X86EMUL_OPC_VEX_66 (0x0f3a ,0x5d ):/* vfmaddsubpd {x,y}mm,{x,y}mm/mem,{x,y}mm,{x,y}mm */
PATCH v4 13/16 x86emul: support AVX10.2 BFloat16 insns
In reply to Jan BeulichThese are all very similar to various existing insns. VGETEXPPBF16, not living in the expected place, benefits from the respective twobyte_table[] entry already having Mov (aka TwoOp).
---
SDE: -dmr / -future
---
v4: Update to spec version 3. Switch to using fallthrough pseudo-
keyword.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +28 -0
@@ -722,15 +722,36 @@ static const struct test vpclmulqdq_all[ };static const struct test avx10_2_all[] = { +INSN (addbf16,66 , map5,58 , vl, bf16, vl), + INSN(cmpbf16, f2, 0f3a, c2, vl, bf16, vl),INSN (comisbf16,66 , map5,2f , el, bf16, el),INSN_SFP (comx,0f ,2f ),INSN (comxsh, f3, map5,2f , el, fp16, el), +INSN (divbf16,66 , map5,5e , vl, bf16, vl), INSN(dpphps, , 0f38, 52, vl, d, vl), + INSN(fmadd132bf16, , map6, 98, vl, bf16, vl), + INSN(fmadd213bf16, , map6, a8, vl, bf16, vl), + INSN(fmadd231bf16, , map6, b8, vl, bf16, vl), + INSN(fmsub132bf16, , map6, 9a, vl, bf16, vl), + INSN(fmsub213bf16, , map6, aa, vl, bf16, vl), + INSN(fmsub231bf16, , map6, ba, vl, bf16, vl), + INSN(fnmadd132bf16, , map6, 9c, vl, bf16, vl), + INSN(fnmadd213bf16, , map6, ac, vl, bf16, vl), + INSN(fnmadd231bf16, , map6, bc, vl, bf16, vl), + INSN(fnmsub132bf16, , map6, 9e, vl, bf16, vl), + INSN(fnmsub213bf16, , map6, ae, vl, bf16, vl), + INSN(fnmsub231bf16, , map6, be, vl, bf16, vl), + INSN(fpclassbf16, f2, 0f3a, 66, vl, bf16, vl), + INSN(getexpbf16, , map6, 42, vl, bf16, vl), + INSN(getmantbf16, f2, 0f3a, 26, vl, bf16, vl), +INSN (maxbf16,66 , map5,5f , vl, bf16, vl), +INSN (minbf16,66 , map5,5d , vl, bf16, vl), INSN(minmax, 66, 0f3a, 52, vl, sd, vl), INSN(minmax, 66, 0f3a, 53, el, sd, el), INSN(minmaxbf16, f2, 0f3a, 52, vl, bf16, vl), INSN(minmaxph, , 0f3a, 52, vl, fp16, vl), INSN(minmaxsh, , 0f3a, 53, el, fp16, el), +INSN (mulbf16,66 , map5,59 , vl, bf16, vl), INSN(mpsadbw, f3, 0f3a, 42, vl, d_nb, vl), INSN(pdpbssd, f2, 0f38, 50, vl, d, vl), INSN(pdpbssds, f2, 0f38, 51, vl, d, vl),
@@ -744,6 +765,13 @@ static const struct test avx10_2_all[] = INSN(pdpwusds, 66, 0f38, d3, vl, d, vl), INSN(pdpwuud, , 0f38, d2, vl, d, vl), INSN(pdpwuuds, , 0f38, d3, vl, d, vl), + INSN(rcpph, , map6, 4c, vl, bf16, vl), + INSN(reducebf16, f2, 0f3a, 56, vl, bf16, vl), + INSN(rndscalebf16, f2, 0f3a, 08, vl, bf16, vl), + INSN(rsqrtph, , map6, 4e, vl, bf16, vl), + INSN(scalefbf16, , map6, 2c, vl, bf16, vl), +INSN (sqrtbf16,66 , map5,51 , vl, bf16, vl), + INSN(subbf16, 66, map5, 5c, vl, bf16, vl),INSN_SFP (ucomx,0f ,2e ), INSN(ucomxsh, f3, map5, 2e, el, fp16, el), };
tools/tests/x86_emulator/predicates.c +16 -0
@@ -2056,6 +2056,7 @@ static const struct evex { { { 0x05 }, 3, T, R, pfx_66, W1, Ln }, /* vpermilpd */ { { 0x08 }, 3, T, R, pfx_no, W0, Ln }, /* vrndscaleph */ { { 0x08 }, 3, T, R, pfx_66, W0, Ln }, /* vrndscaleps */ + { { 0x08 }, 3, T, R, pfx_f2, W0, Ln }, /* vrndscalebf16 */ { { 0x09 }, 3, T, R, pfx_66, W1, Ln }, /* vrndscalepd */ { { 0x0a }, 3, T, R, pfx_no, W0, LIG }, /* vrndscalesh */ { { 0x0a }, 3, T, R, pfx_66, W0, LIG }, /* vrndscaless */
@@ -2079,6 +2080,7 @@ static const struct evex { { { 0x25 }, 3, T, R, pfx_66, Wn, Ln }, /* vpternlog{d,q} */ { { 0x26 }, 3, T, R, pfx_no, W0, Ln }, /* vgetmantph */ { { 0x26 }, 3, T, R, pfx_66, Wn, Ln }, /* vgetmantp{s,d} */ + { { 0x26 }, 3, T, R, pfx_f2, W0, Ln }, /* vgetmantbf16 */ { { 0x27 }, 3, T, R, pfx_no, W0, LIG }, /* vgetmantsh */ { { 0x27 }, 3, T, R, pfx_66, Wn, LIG }, /* vgetmants{s,d} */ { { 0x38 }, 3, T, R, pfx_66, Wn, L1|L2 }, /* vinserti{32x4,64x2} */
@@ -2102,10 +2104,12 @@ static const struct evex { { { 0x55 }, 3, T, R, pfx_66, Wn, LIG }, /* vfixumpimms{s,d} */ { { 0x56 }, 3, T, R, pfx_no, W0, Ln }, /* vreduceph */ { { 0x56 }, 3, T, R, pfx_66, Wn, Ln }, /* vreducep{s,d} */ + { { 0x56 }, 3, T, R, pfx_f2, W0, Ln }, /* vreducebf16 */ { { 0x57 }, 3, T, R, pfx_no, W0, LIG }, /* vreducesh */ { { 0x57 }, 3, T, R, pfx_66, Wn, LIG }, /* vreduces{s,d} */ { { 0x66 }, 3, T, R, pfx_no, W0, Ln }, /* vfpclassph */ { { 0x66 }, 3, T, R, pfx_66, Wn, Ln }, /* vfpclassp{s,d} */ + { { 0x66 }, 3, T, R, pfx_f2, W0, Ln }, /* vfpclassbf16 */ { { 0x67 }, 3, T, R, pfx_no, W0, LIG }, /* vfpclasssh */ { { 0x67 }, 3, T, R, pfx_66, Wn, LIG }, /* vfpclasss{s,d} */ { { 0x70 }, 3, T, R, pfx_66, W1, Ln }, /* vshldw */
@@ -2114,6 +2118,7 @@ static const struct evex { { { 0x73 }, 3, T, R, pfx_66, Wn, Ln }, /* vshrd{d,q} */ { { 0xc2 }, 3, T, R, pfx_no, W0, Ln }, /* vcmpph */ { { 0xc2 }, 3, T, R, pfx_f3, W0, LIG }, /* vcmpsh */ + { { 0xc2 }, 3, T, R, pfx_f2, W0, Ln }, /* vcmpbf16 */ { { 0xce }, 3, T, R, pfx_66, W1, Ln }, /* vgf2p8affineqb */ { { 0xcf }, 3, T, R, pfx_66, W1, Ln }, /* vgf2p8affineinvqb */ }, evex_map5[] = {
@@ -2130,10 +2135,13 @@ static const struct evex { { { 0x2f }, 2, T, R, pfx_66, W0, LIG }, /* vcomisbf16 */ { { 0x2f }, 2, T, R, pfx_f3, W0, LIG }, /* vcomxsh */ { { 0x51 }, 2, T, R, pfx_no, W0, Ln }, /* vsqrtph */ + { { 0x51 }, 2, T, R, pfx_66, W0, Ln }, /* vsqrtbf16 */ { { 0x51 }, 2, T, R, pfx_f3, W0, LIG }, /* vsqrtsh */ { { 0x58 }, 2, T, R, pfx_no, W0, Ln }, /* vaddph */ + { { 0x58 }, 2, T, R, pfx_66, W0, Ln }, /* vaddbf16 */ { { 0x58 }, 2, T, R, pfx_f3, W0, LIG }, /* vaddsh */ { { 0x59 }, 2, T, R, pfx_no, W0, Ln }, /* vmulph */ + { { 0x59 }, 2, T, R, pfx_66, W0, Ln }, /* vmulbf16 */ { { 0x59 }, 2, T, R, pfx_f3, W0, LIG }, /* vmulsh */ { { 0x5a }, 2, T, R, pfx_no, W0, Ln }, /* vcvtph2pd */ { { 0x5a }, 2, T, R, pfx_66, W1, Ln }, /* vcvtpd2ph */
@@ -2144,12 +2152,16 @@ static const struct evex { { { 0x5b }, 2, T, R, pfx_66, W0, Ln }, /* vcvtph2dq */ { { 0x5b }, 2, T, R, pfx_f3, W0, Ln }, /* vcvttph2dq */ { { 0x5c }, 2, T, R, pfx_no, W0, Ln }, /* vsubph */ + { { 0x5c }, 2, T, R, pfx_66, W0, Ln }, /* vsubbf16 */ { { 0x5c }, 2, T, R, pfx_f3, W0, LIG }, /* vsubsh */ { { 0x5d }, 2, T, R, pfx_no, W0, Ln }, /* vminph */ + { { 0x5d }, 2, T, R, pfx_66, W0, Ln }, /* vminbf16 */ { { 0x5d }, 2, T, R, pfx_f3, W0, LIG }, /* vminsh */ { { 0x5e }, 2, T, R, pfx_no, W0, Ln }, /* vdivph */ + { { 0x5e }, 2, T, R, pfx_66, W0, Ln }, /* vdivbf16 */ { { 0x5e }, 2, T, R, pfx_f3, W0, LIG }, /* vdivsh */ { { 0x5f }, 2, T, R, pfx_no, W0, Ln }, /* vmaxph */ + { { 0x5f }, 2, T, R, pfx_66, W0, Ln }, /* vmaxbf16 */ { { 0x5f }, 2, T, R, pfx_f3, W0, LIG }, /* vmaxsh */ { { 0x6e }, 2, T, R, pfx_66, WIG, L0 }, /* vmovw */ { { 0x6e }, 2, T, R, pfx_f3, W0, L0 }, /* vmovw */
@@ -2177,12 +2189,16 @@ static const struct evex { }, evex_map6[] = { { { 0x13 }, 2, T, R, pfx_66, W0, Ln }, /* vcvtph2psx */ { { 0x13 }, 2, T, R, pfx_no, W0, LIG }, /* vcvtsh2ss */ + { { 0x2c }, 2, T, R, pfx_no, W0, Ln }, /* vscalefbf16 */ { { 0x2c }, 2, T, R, pfx_66, W0, Ln }, /* vscalefph */ { { 0x2d }, 2, T, R, pfx_66, W0, LIG }, /* vscalefsh */ + { { 0x42 }, 2, T, R, pfx_no, W0, Ln }, /* vgetexpbf16 */ { { 0x42 }, 2, T, R, pfx_66, W0, Ln }, /* vgetexpph */ { { 0x43 }, 2, T, R, pfx_66, W0, LIG }, /* vgetexpsh */ + { { 0x4c }, 2, T, R, pfx_no, W0, Ln }, /* vrcpbf16 */ { { 0x4c }, 2, T, R, pfx_66, W0, Ln }, /* vrcpph */ { { 0x4d }, 2, T, R, pfx_66, W0, LIG }, /* vrcpsh */ + { { 0x4e }, 2, T, R, pfx_no, W0, Ln }, /* vrsqrtbf16 */ { { 0x4e }, 2, T, R, pfx_66, W0, Ln }, /* vrsqrtph */ { { 0x4f }, 2, T, R, pfx_66, W0, LIG }, /* vrsqrtsh */ { { 0x56 }, 2, T, R, pfx_f3, W0, Ln }, /* vfmaddcph */
xen/arch/x86/x86_emulate/decode.c +37 -14
100 lines not on this page · raw message
xen/arch/x86/x86_emulate/x86_emulate.c +44 -0
56 lines not on this page · raw message
PATCH v4 14/16 x86emul: support AVX10.2 saturating convert insns
In reply to Jan BeulichWhile the to-byte ones are somewhat different from what has been there (yet then nicely regular from an operands perspective), the others are pretty similar to various existing insns.
---
Spec rev 002 says VCVTTNEBF162I{,U}BS, yet that's going to change to VCVTTBF162I{,U}BS.
---
SDE: -dmr / -future
---
v4: Update to spec version 3. Switch to using fallthrough pseudo-
keyword. Series re-ordering adjustments.
v3: New.
tools/tests/x86_emulator/evex-disp8.c +24 -0
@@ -727,6 +727,30 @@ static const struct test avx10_2_all[] =INSN (comisbf16,66 , map5,2f , el, bf16, el),INSN_SFP (comx,0f ,2f ),INSN (comxsh, f3, map5,2f , el, fp16, el), +INSN (cvtbf162ibs, f2, map5,69 , vl, bf16, vl), +INSN (cvtbf162iubs, f2, map5,6b , vl, bf16, vl), + INSN(cvtph2ibs, , map5, 69, vl, fp16, vl), + INSN(cvtph2iubs, , map5, 6b, vl, fp16, vl), +INSN (cvtps2ibs,66 , map5,69 , vl, d, vl), +INSN (cvtps2iubs,66 , map5,6b , vl, d, vl), +INSN (cvttbf162ibs, f2, map5,68 , vl, bf16, vl), + INSN(cvttbf162iubs, f2, map5, 6a, vl, bf16, vl), + INSN(cvttpd2dqs, , map5, 6d, vl, q, vl), +INSN (cvttpd2qqs,66 , map5,6d , vl, q, vl), + INSN(cvttpd2udqs, , map5, 6c, vl, q, vl), + INSN(cvttpd2uqqs, 66, map5, 6c, vl, q, vl), + INSN(cvttph2ibs, , map5, 68, vl, fp16, vl), + INSN(cvttph2iubs, , map5, 6a, vl, fp16, vl), + INSN(cvttps2dqs, , map5, 6d, vl, d, vl), +INSN (cvttps2ibs,66 , map5,68 , vl, d, vl), + INSN(cvttps2iubs, 66, map5, 6a, vl, d, vl), +INSN (cvttps2qqs,66 , map5,6d , vl_2, d, vl), + INSN(cvttps2udqs, , map5, 6c, vl, d, vl), + INSN(cvttps2uqqs, 66, map5, 6c, vl_2, d, vl), +INSN (cvttsd2sis, f2, map5,6d , el, q, el), + INSN(cvttsd2usis, f2, map5, 6c, el, q, el), +INSN (cvttss2sis, f3, map5,6d , el, d, el), + INSN(cvttss2usis, f3, map5, 6c, el, d, el),INSN (divbf16,66 , map5,5e , vl, bf16, vl), INSN(dpphps, , 0f38, 52, vl, d, vl), INSN(fmadd132bf16, , map6, 98, vl, bf16, vl),
tools/tests/x86_emulator/predicates.c +20 -0
@@ -2163,6 +2163,26 @@ static const struct evex { { { 0x5f }, 2, T, R, pfx_no, W0, Ln }, /* vmaxph */ { { 0x5f }, 2, T, R, pfx_66, W0, Ln }, /* vmaxbf16 */ { { 0x5f }, 2, T, R, pfx_f3, W0, LIG }, /* vmaxsh */ + { { 0x68 }, 2, T, R, pfx_no, W0, Ln }, /* vcvttph2ibs */ + { { 0x68 }, 2, T, R, pfx_66, W0, Ln }, /* vcvttps2ibs */ + { { 0x68 }, 2, T, R, pfx_f2, W0, Ln }, /* vcvttbf162ibs */ + { { 0x69 }, 2, T, R, pfx_no, W0, Ln }, /* vcvtph2ibs */ + { { 0x69 }, 2, T, R, pfx_66, W0, Ln }, /* vcvtps2ibs */ + { { 0x69 }, 2, T, R, pfx_f2, W0, Ln }, /* vcvtbf162ibs */ + { { 0x6a }, 2, T, R, pfx_no, W0, Ln }, /* vcvttph2iubs */ + { { 0x6a }, 2, T, R, pfx_66, W0, Ln }, /* vcvttps2iubs */ + { { 0x6a }, 2, T, R, pfx_f2, W0, Ln }, /* vcvttbf162iubs */ + { { 0x6b }, 2, T, R, pfx_no, W0, Ln }, /* vcvtph2iubs */ + { { 0x6b }, 2, T, R, pfx_66, W0, Ln }, /* vcvtps2iubs */ + { { 0x6b }, 2, T, R, pfx_f2, W0, Ln }, /* vcvtbf162iubs */ + { { 0x6c }, 2, T, R, pfx_no, Wn, Ln }, /* vcvttp{s,d}2udqs */ + { { 0x6c }, 2, T, R, pfx_66, Wn, Ln }, /* vcvttp{s,d}2uqqs */ + { { 0x6c }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttss2usis */ + { { 0x6c }, 2, T, R, pfx_f2, Wn, LIG }, /* vcvttsd2usis */ + { { 0x6d }, 2, T, R, pfx_no, Wn, Ln }, /* vcvttp{s,d}2dqs */ + { { 0x6d }, 2, T, R, pfx_66, Wn, Ln }, /* vcvttp{s,d}2qqs */ + { { 0x6d }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttss2sis */ + { { 0x6d }, 2, T, R, pfx_f2, Wn, LIG }, /* vcvttsd2sis */ { { 0x6e }, 2, T, R, pfx_66, WIG, L0 }, /* vmovw */ { { 0x6e }, 2, T, R, pfx_f3, W0, L0 }, /* vmovw */ { { 0x6f }, 2, T, R, pfx_f3, Wn, Ln }, /* vmovrs{d,q} */
xen/arch/x86/x86_emulate/decode.c +21 -0
@@ -1541,6 +1541,19 @@ int x86emul_decode(struct x86_emulate_st s->fp16 = true;break ; +case 0x68 :/* vcvtt{ph,ps,bf16}2ibs */ +case 0x69 :/* vcvt{ph,ps,nebf16}2ibs */ +case 0x6a :/* vcvtt{ph,ps,bf16}2iubs */ +case 0x6b :/* vcvt{ph,ps,nebf16}2iubs */ +if ( !s->evex.pfx || s->evex.pfx == vex_f2 ) + s->fp16 = true; + fallthrough; +case 0x6c :/* vcvttp{s,d}2u{d,q}qs, vcvtts{s,d}2usis */ +case 0x6d :/* vcvttp{s,d}2{d,q}qs, vcvtts{s,d}2sis */ + d |= TwoOp; + s->simd_size = simd_other; +break ; +case 0x6e :/* vmovw r/x/m16, xmm */ d = (d & ~SrcMask) | SrcMem16;/* fall through */
@@ -1606,6 +1619,14 @@ int x86emul_decode(struct x86_emulate_st --disp8scale;break ; +case 0x6c :/* vcvttps2uqqs and vcvts{s,d}2usi need special casing */ +case 0x6d :/* vcvttps2qqs and vcvts{s,d}2si need special casing */ +if ( s->evex.pfx == vex_66 && !s->evex.w && !s->evex.brs ) + --disp8scale; +else if ( s->evex.pfx &VEX_PREFIX_SCALAR_MASK ) + disp8scale = s->evex.pfx &VEX_PREFIX_DOUBLE_MASK ?3 :2 ; +break ; +case 0x7a :case 0x7b :/* vcvt{,t}ph2qq need special casing */ if ( s->evex.pfx == vex_66 && !s->evex.brs ) disp8scale = s->evex.brs ?1 :2 + s->evex.lr;
xen/arch/x86/x86_emulate/x86_emulate.c +49 -0
55 lines not on this page · raw message
PATCH v4 15/16 x86emul: support other AVX10.2 convert insns
In reply to Jan BeulichDespite most of them being about conversion to BF8/HF8, they are still somewhat similar to various existing convert insns.
---
SDE: -dmr / -future
---
v4: Update to spec version 3. Switch to using fallthrough pseudo-keyword.
Series re-ordering adjustments. Update to spec version 6. Add ChangeLog entry.
v3: New.
CHANGELOG.md +1 -1
@@ -16,7 +16,7 @@ The format is based on [Keep a Changelog mitigate (by rate-limiting) the system wide impact of an HVM guest misusing atomic instructions. - Support for CPIO microcode in discrete multiboot modules. - - Support for AVX10.1. (Experimental) + - Support for AVX10.2. (Experimental) - On Arm: - Support for guest suspend and resume to/from RAM via vPSCI.
tools/tests/x86_emulator/evex-disp8.c +14 -0
@@ -727,8 +727,22 @@ static const struct test avx10_2_all[] =INSN (comisbf16,66 , map5,2f , el, bf16, el),INSN_SFP (comx,0f ,2f ),INSN (comxsh, f3, map5,2f , el, fp16, el), + INSN(cvt2ph2bf8, f2, 0f38, 74, vl, fp16, vl), +INSN (cvt2ph2bf8s, f2, map5,74 , vl, fp16, vl), +INSN (cvt2ph2hf8, f2, map5,18 , vl, fp16, vl), +INSN (cvt2ph2hf8s, f2, map5,1b , vl, fp16, vl), + INSN(cvt2ps2phx, 66, 0f38, 67, vl, d, vl), + INSN(cvtbiasph2bf8, , 0f38, 74, vl, fp16, vl), + INSN(cvtbiasph2bf8s, , map5, 74, vl, fp16, vl), + INSN(cvtbiasph2hf8, , map5, 18, vl, fp16, vl), + INSN(cvtbiasph2hf8s, , map5, 1b, vl, fp16, vl), +INSN (cvthf82ph, f2, map5,1e , vl_2, b, vl),INSN (cvtbf162ibs, f2, map5,69 , vl, bf16, vl),INSN (cvtbf162iubs, f2, map5,6b , vl, bf16, vl), + INSN(cvtph2bf8, f3, 0f38, 74, vl, fp16, vl), +INSN (cvtph2bf8s, f3, map5,74 , vl, fp16, vl), +INSN (cvtph2hf8, f3, map5,18 , vl, fp16, vl), +INSN (cvtph2hf8s, f3, map5,1b , vl, fp16, vl), INSN(cvtph2ibs, , map5, 69, vl, fp16, vl), INSN(cvtph2iubs, , map5, 6b, vl, fp16, vl), INSN(cvtps2ibs, 66, map5, 69, vl, d, vl),
tools/tests/x86_emulator/predicates.c +14 -0
@@ -1952,6 +1952,7 @@ static const struct evex { { { 0x64 }, 2, T, R, pfx_66, Wn, Ln }, /* vpblendm{d,q} */ { { 0x65 }, 2, T, R, pfx_66, Wn, Ln }, /* vblendmp{s,d} */ { { 0x66 }, 2, T, R, pfx_66, Wn, Ln }, /* vpblendm{b,w} */ + { { 0x67 }, 2, T, R, pfx_66, W0, Ln }, /* vcvt2ps2phx */ { { 0x68 }, 2, T, R, pfx_f2, Wn, Ln }, /* vp2intersect{d,q} */ { { 0x70 }, 2, T, R, pfx_66, W1, Ln }, /* vpshldvw */ { { 0x71 }, 2, T, R, pfx_66, Wn, Ln }, /* vpshldv{d,q} */
@@ -1959,6 +1960,9 @@ static const struct evex { { { 0x72 }, 2, T, R, pfx_f3, W1, Ln }, /* vcvtneps2bf16 */ { { 0x72 }, 2, T, R, pfx_f2, W1, Ln }, /* vcvtne2ps2bf16 */ { { 0x73 }, 2, T, R, pfx_66, Wn, Ln }, /* vpshrdv{d,q} */ + { { 0x74 }, 2, T, R, pfx_no, W0, Ln }, /* vcvtbiasph2bf8 */ + { { 0x74 }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtph2bf8 */ + { { 0x74 }, 2, T, R, pfx_f2, W0, Ln }, /* vcvt2ph2bf8 */ { { 0x75 }, 2, T, R, pfx_66, Wn, Ln }, /* vpermi2{b,w} */ { { 0x76 }, 2, T, R, pfx_66, Wn, Ln }, /* vpermi2{d,q} */ { { 0x77 }, 2, T, R, pfx_66, Wn, Ln }, /* vpermi2p{s,d} */
@@ -2124,8 +2128,15 @@ static const struct evex { }, evex_map5[] = { { { 0x10 }, 2, T, R, pfx_f3, W0, LIG }, /* vmovsh */ { { 0x11 }, 2, T, W, pfx_f3, W0, LIG }, /* vmovsh */ + { { 0x18 }, 2, T, R, pfx_no, W0, Ln }, /* vcvtbiasph2hf8 */ + { { 0x18 }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtph2hf8 */ + { { 0x18 }, 2, T, R, pfx_f2, W0, Ln }, /* vcvt2ph2hf8 */ + { { 0x1b }, 2, T, R, pfx_no, W0, Ln }, /* vcvtbiasph2hf8s */ + { { 0x1b }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtph2hf8s */ + { { 0x1b }, 2, T, R, pfx_f2, W0, Ln }, /* vcvt2ph2hf8s */ { { 0x1d }, 2, T, R, pfx_66, W0, Ln }, /* vcvtps2phx */ { { 0x1d }, 2, T, R, pfx_no, W0, LIG }, /* vcvtss2sh */ + { { 0x1e }, 2, T, R, pfx_f2, W0, Ln }, /* cvthf82ph */ { { 0x2a }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvtsi2sh */ { { 0x2c }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttsh2si */ { { 0x2d }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvtsh2si */
@@ -2187,6 +2198,9 @@ static const struct evex { { { 0x6e }, 2, T, R, pfx_f3, W0, L0 }, /* vmovw */ { { 0x6f }, 2, T, R, pfx_f3, Wn, Ln }, /* vmovrs{d,q} */ { { 0x6f }, 2, T, R, pfx_f2, Wn, Ln }, /* vmovrs{b,w} */ + { { 0x74 }, 2, T, R, pfx_no, W0, Ln }, /* vcvtbiasph2bf8s */ + { { 0x74 }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtph2bf8s */ + { { 0x74 }, 2, T, R, pfx_f2, W0, Ln }, /* vcvt2ph2bf8s */ { { 0x78 }, 2, T, R, pfx_no, W0, Ln }, /* vcvttph2udq */ { { 0x78 }, 2, T, R, pfx_66, W0, Ln }, /* vcvttph2uqq */ { { 0x78 }, 2, T, R, pfx_f3, Wn, LIG }, /* vcvttsh2usi */
xen/arch/x86/x86_emulate/decode.c +28 -0
@@ -378,8 +378,10 @@ static const struct ext0f38_table { [0x62] = { .simd_size = simd_packed_int, .two_op = 1, .d8s = d8s_bw }, [0x63] = { .simd_size = simd_packed_int, .to_mem = 1, .two_op = 1, .d8s = d8s_bw }, [0x64 ... 0x66] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, + [0x67] = { .simd_size = simd_other, .d8s = d8s_vl }, [0x68] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x70 ... 0x73] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, + [0x74] = { .simd_size = simd_other, .d8s = d8s_vl }, [0x75 ... 0x76] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x77] = { .simd_size = simd_packed_fp, .d8s = d8s_vl }, [0x78] = { .simd_size = simd_other, .two_op = 1 },
@@ -1439,6 +1441,15 @@ int x86emul_decode(struct x86_emulate_st s->simd_size = ext0f38_table[b].simd_size;if (evex_encoded () ) { +switch ( b ) + { +case 0x74 :/* cvt{bias,ne,ne2}ph2bf8 */ + s->fp16 = true; +if ( s->evex.pfx != vex_f2 ) + d |= TwoOp; +break ; + } +/* * VPMOVUS* are identical to VPMOVS* Disp8-scaling-wise, but * their attributes don't match those of the vex_66 encoded
@@ -1586,6 +1597,23 @@ int x86emul_decode(struct x86_emulate_stswitch ( b ) { +case 0x18 :/* vcvt{bias,ne,ne2}ph2hf8 */ +case 0x1b :/* vcvt{bias,ne,ne2}ph2hf8s */ +case 0x74 :/* vcvt{bias,ne,ne2}ph2bf8s */ + s->fp16 = true; + d = DstReg | SrcMem; +if ( s->evex.pfx != vex_f2 ) + d |= TwoOp; + s->simd_size = simd_other; + disp8scale = s->evex.brs ?1 :4 + s->evex.lr; +break ; + +case 0x1e :/* vcvthf82ph */ + d = DstReg | SrcMem | TwoOp; + s->simd_size = simd_other; + disp8scale =3 + s->evex.lr; +break ; +case 0x78 :case 0x79 :/* vcvt{,t}ph2u{d,q}q need special casing */
xen/arch/x86/x86_emulate/x86_emulate.c +33 -0
@@ -6243,6 +6243,30 @@ x86_emulate( } goto simd_zmm; +case X86EMUL_OPC_EVEX (0x0f38 ,0x74 ):/* vcvtbiasph2bf8 [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0x74 ):/* vcvtph2bf8 [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x74 ):/* vcvt2ph2bf8 [xyz]mm,[xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX (5 ,0x18 ):/* vcvtbiasph2hf8 [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x18 ):/* vcvtph2hf8 [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F2 (5 ,0x18 ):/* vcvt2ph2hf8 [xyz]mm,[xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX (5 ,0x1b ):/* vcvtbiasph2hf8s [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x1b ):/* vcvtph2hf8s [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F2 (5 ,0x1b ):/* vcvt2ph2hf8s [xyz]mm,[xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX (5 ,0x74 ):/* vcvtbiasph2bf8s [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F3 (5 ,0x74 ):/* vcvtph2bf8s [xyz]mm,[xyz]mm/mem{k} */ +case X86EMUL_OPC_EVEX_F2 (5 ,0x74 ):/* vcvt2ph2bf8s [xyz]mm,[xyz]mm,[xyz]mm/mem{k} */ +generate_exception_if (ea.type !=OP_MEM && evex.brs,X86_EXC_UD ); + fault_suppression = false; + fallthrough; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x67 ):/* vcvt2ps2phx [xyz]mm,[xyz]mm,[xyz]mm/mem{k} */ +generate_exception_if (evex.w,X86_EXC_UD ); +if ( !cp->avx10.avx10_v1_aux ) +vcpu_must_have (avx10,2 ); +if ( ea.type !=OP_REG || !evex.brs ) +avx512_vlen_check (false); + op_bytes =16 << evex.lr; + goto simd_zmm; +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x68 ):/* vp2intersect{d,q} [xyz]mm/mem,[xyz]mm,k+1 */ host_and_vcpu_must_have (avx512_vp2intersect);generate_exception_if (evex.opmsk || !evex.r || !evex.R,X86_EXC_UD );
@@ -7946,6 +7970,15 @@ x86_emulate(generate_exception_if (evex.w,X86_EXC_UD ); goto avx512f_all_fp; +case X86EMUL_OPC_EVEX_F2 (5 ,0x1e ):/* vcvthf82ph [xyz]mm,[xyz]mm/mem{k} */ +generate_exception_if (evex.w || evex.brs,X86_EXC_UD ); +if ( !cp->avx10.avx10_v1_aux ) +vcpu_must_have (avx10,2 ); +if ( ea.type !=OP_REG || !evex.brs ) +avx512_vlen_check (false); + op_bytes =8 << evex.lr; + goto simd_zmm; +case X86EMUL_OPC_EVEX_66 (5 ,0x51 ):/* vsqrtbf16 [xyz]mm/mem,[xyz]mm{k} */ case X86EMUL_OPC_EVEX_66 (5 ,0x58 ):/* vaddbf16 [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */ case X86EMUL_OPC_EVEX_66 (5 ,0x59 ):/* vmulbf16 [xyz]mm/mem,[xyz]mm,[xyz]mm{k} */
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -410,7 +410,7 @@ XEN_CPUFEATURE(TSA_SQ_NO, 18*32XEN_CPUFEATURE (TSA_L1_NO ,18 *32 +2 )/*A No L1D Transitive Scheduler Attacks */ /* Intel-defined CPU features, CPUID level 0x00000024:1.ecx, word 19 */ -XEN_CPUFEATURE(AVX10_V1_AUX, 19*32+ 2) /* AVX10 V1 Auxiliary Instructions */ +XEN_CPUFEATURE(AVX10_V1_AUX, 19*32+ 2) /*a AVX10 V1 Auxiliary Instructions */#endif /* XEN_CPUFEATURE */
Re: [PATCH v4 15/16] x86emul: support other AVX10.2 convert insns
Quoted 14 lines · Jan Beulich
Despite most of them being about conversion to BF8/HF8, they are still somewhat similar to various existing convert insns.
Signed-off-by Jan Beulich <[email protected]>---
SDE: -dmr / -future
---
v4: Update to spec version 3. Switch to using fallthrough pseudo-keyword.
Series re-ordering adjustments. Update to spec version 6. Add ChangeLog entry.
v3: New.
CHANGELOG.md The format is based on [Keep a Changelog · line 19
Quoted 5 lines
CHANGELOG.md +1
-1@@ -16,7 +16,7 @@ The format is based on [Keep a Changelog mitigate (by rate-limiting) the system wide impact of an HVM guest misusing atomic instructions. - Support for CPIO microcode in discrete multiboot modules. - - Support for AVX10.1. (Experimental) + - Support for AVX10.2. (Experimental)
Thanks.
~ Oleksii
PATCH v4 1/1 x86/CPUID: enable AVX10 leaf
In reply to Jan BeulichThis 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.
Do we want to synthesize AVX10 in the (max?) policies when all necessary AVX512* features are available, thus allowing migration from an AVX10 host to a suitable non-AVX10 one?
The prior vsz<N> bits are now defined as reserved-at-1: No idea yet how to represent this properly.
How a toolstack side equivalent (if any) of the init_dom0_cpuid_policy() change would look like is entirely unclear to me. How much should we take from the max policy, and how much should we permit/require the user to specify (and how would the latter look like)?
While, as per a comment next to the call site of recalculate_cpuid_policy(), recalculate_*() are supposed to go away when x86_cpu_policies_are_compatible() is complete, some of the checking done in recalculate_misc() really wouldn't below there. We'd need another "is self-consistent" checking function.
---
v4: Drop all traces of AVX10/256. Add max_subleaf check to
x86_cpu_policies_are_compatible(). Add/adjust vsz<N> checks in recalculate_misc(). In the max policies, synthesize AVX512* when AVX10 is available.
v3: Re-base.
v2: Add logic to init_dom0_cpuid_policy(). Drop vsz128 field. Re-base.
xen/arch/x86/cpu-policy.c +58 -1
@@ -211,7 +211,7 @@ static void recalculate_xstate(struct cpif ( p->feat.mpx ) xstates |=X86_XCR0_BNDREGS |X86_XCR0_BNDCSR ; -if ( p->feat.avx512f ) +if ( p->feat.avx512f || p->feat.avx10 ) xstates |=X86_XCR0_OPMASK |X86_XCR0_ZMM |X86_XCR0_HI_ZMM ;if ( p->feat.pku )
@@ -272,6 +272,18 @@ 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 =0 ; + p->avx10.raw[0 ].d =0 ; +if ( !p->feat.avx10 || !p->avx10.version || + !p->avx10.vsz512 || !p->avx10.vsz256 || !p->avx10.vsz128 ) + { + 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. */
@@ -400,6 +412,7 @@ static void __init guest_common_max_leav { p->basic.max_leaf =ARRAY_SIZE (p->basic.raw) -1 ; p->feat.max_subleaf =ARRAY_SIZE (p->feat.raw) -1 ; + p->avx10.max_subleaf =ARRAY_SIZE (p->avx10.raw) -1 ; p->extd.max_leaf =0x80000000U +ARRAY_SIZE (p->extd.raw) -1 ; }
@@ -408,6 +421,7 @@ static void __init guest_common_default_ { p->basic.max_leaf = host_cpu_policy.basic.max_leaf; p->feat.max_subleaf = host_cpu_policy.feat.max_subleaf; + p->avx10.max_subleaf = host_cpu_policy.avx10.max_subleaf; p->extd.max_leaf = host_cpu_policy.extd.max_leaf; }
@@ -503,6 +517,28 @@ static void __init guest_common_max_feat* function correctly when migrated here, even if ERMS isn't available. */ __set_bit (X86_FEATURE_ERMS , fs); + +/* +* AVX10 is merely a re-declaration of a combination of AVX512 features. +* Synthesize the latter from the former, when available. Doing it the +* other way around would also require synthesizing the AVX10 CPUID leaf. +*/ +if (test_bit (X86_FEATURE_AVX10 , fs) ) + { +__set_bit (X86_FEATURE_AVX512F , fs); +__set_bit (X86_FEATURE_AVX512VL , fs); +__set_bit (X86_FEATURE_AVX512BW , fs); +__set_bit (X86_FEATURE_AVX512DQ , fs); +__set_bit (X86_FEATURE_AVX512_BF16 , fs); +__set_bit (X86_FEATURE_AVX512_FP16 , fs); +__set_bit (X86_FEATURE_AVX512CD , fs); +__set_bit (X86_FEATURE_AVX512_BITALG , fs); +__set_bit (X86_FEATURE_AVX512_IFMA , fs); +__set_bit (X86_FEATURE_AVX512_VBMI , fs); +__set_bit (X86_FEATURE_AVX512_VBMI2 , fs); +__set_bit (X86_FEATURE_AVX512_VNNI , fs); +__set_bit (X86_FEATURE_AVX512_VPOPCNTDQ , fs); + } }static void __init guest_common_default_feature_adjustments (uint32_t *fs)
@@ -966,6 +1002,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))
@@ -1012,6 +1049,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);
@@ -1081,9 +1120,18 @@ void __init init_dom0_cpuid_policy(struc/* Apply dom0-cpuid= command line settings, if provided. */ if ( dom0_cpuid_cmdline ) { +const struct cpu_policy *max =is_pv_domain (d) + ? (IS_ENABLED (CONFIG_PV ) ? &pv_max_cpu_policy :NULL ) + : (IS_ENABLED (CONFIG_HVM ) ? &hvm_max_cpu_policy :NULL );uint32_t fs[FSCAPINTS ];unsigned int i; +if ( !max ) + { +ASSERT_UNREACHABLE (); +return ; + } +x86_cpu_policy_to_featureset (p, fs);for ( i =0 ; i <ARRAY_SIZE (fs); ++i )
@@ -1093,6 +1141,13 @@ void __init init_dom0_cpuid_policy(struc }x86_cpu_featureset_to_policy (fs, p); + +/* +* Default-off features with their own leaves need those leaves +* re-populated from the max policy. +*/ +if ( p->feat.avx10 ) + p->avx10 = max->avx10; }/*
@@ -1125,6 +1180,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
@@ -226,6 +226,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/arch/x86/lib/cpu-policy/copy-to-buffer.c +7 -0
@@ -123,6 +123,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 ;
xen/arch/x86/lib/cpu-policy/copy-from-buffer.c +7 -0
@@ -108,6 +108,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/arch/x86/lib/cpu-policy/cpuid.c +17 -0
@@ -125,6 +125,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 ; }
@@ -218,6 +219,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,
@@ -287,6 +297,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),
@@ -299,6 +312,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 ); }
@@ -326,6 +341,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 )
xen/arch/x86/lib/cpu-policy/policy.c +4 -0
@@ -24,6 +24,10 @@ 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.max_subleaf > host->avx10.max_subleaf ) +FAIL_CPUID (0x24 ,0 ); +if ( guest->extd.max_leaf > host->extd.max_leaf )FAIL_CPUID (0x80000000U ,NA );
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -366,6 +366,7 @@ XEN_CPUFEATURE(PREFETCHI, 15*32 XEN_CPUFEATURE(USER_MSR, 15*32+15) /*s U{RD,WR}MSR Instructions */ XEN_CPUFEATURE(UIRET_UIF, 15*32+17) /* UIRET updates UIF */ 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 (SLSM ,15 *32 +24 )/* Static Lockstep Mode */ /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
xen/include/xen/lib/x86/cpu-policy.h +15 -1
@@ -59,11 +59,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, \
@@ -264,6 +265,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/tools/gen-cpuid.py +1 -1
@@ -294,7 +294,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
Re: [PATCH v4 00.9/16] x86/CPUID: enable AVX10 leaf
Le 09/04/2026 à 17:18, Jan Beulich a écrit :
Quoted 10 lines
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.
Signed-off-by Jan Beulich <[email protected]>---
Thegen-cpuid.pyadjustment 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.
AFAIUI, AVX512BW is a dependency of AVX10, as AVX10 implies that the former is available.
Quoted 4 lines
Do we want to synthesize AVX10 in the (max?) policies when all necessary AVX512* features are available, thus allowing migration from an AVX10 host to a suitable non-AVX10 one?
I guess we want, there is not really a reason to not allow it.
Some software may check for AVX10 only, and not check for individual AVX512 bits.
Quoted 24 lines
The prior vsz<N> bits are now defined as reserved-at-1: No idea yet how to represent this properly.
How a toolstack side equivalent (if any) of the
init_dom0_cpuid_policy()change would look like is entirely unclear to me. How much should we take from the max policy, and how much should we permit/require the user to specify (and how would the latter look like)?While, as per a comment next to the call site of
recalculate_cpuid_policy(), recalculate_*() are supposed to go away whenx86_cpu_policies_are_compatible()is complete, some of the checking done inrecalculate_misc()really wouldn't below there. We'd need another "is self-consistent" checking function.
---
v4: Drop all traces of AVX10/256. Addmax_subleafcheck to
x86_cpu_policies_are_compatible(). Add/adjust vsz<N> checks inrecalculate_misc(). In the max policies, synthesize AVX512* when AVX10 is available.
v3: Re-base.
v2: Add logic toinit_dom0_cpuid_policy(). Drop vsz128 field. Re-base.
xen/arch/x86/cpu-policy.c static void recalculate_xstate(struct cp · line 214
Quoted 5 lines
xen/arch/x86/cpu-policy.c +1
-1@@ -211,7 +211,7 @@ static void recalculate_xstate(struct cpif ( p->feat.mpx ) xstates |=X86_XCR0_BNDREGS |X86_XCR0_BNDCSR ; -if ( p->feat.avx512f ) +if ( p->feat.avx512f || p->feat.avx10 )
In principle, the avx10 check is redundant as avx512f must be set if avx10 is set.
Quoted 187 lines
xen/arch/x86/cpu-policy.c +57
-0xstates |=X86_XCR0_OPMASK |X86_XCR0_ZMM |X86_XCR0_HI_ZMM ;if ( p->feat.pku )@@ -272,6 +272,18 @@ 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 =0 ; + p->avx10.raw[0 ].d =0 ; +if ( !p->feat.avx10 || !p->avx10.version || + !p->avx10.vsz512 || !p->avx10.vsz256 || !p->avx10.vsz128 ) + { + 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. */ @@ -400,6 +412,7 @@ static void __init guest_common_max_leav { p->basic.max_leaf =ARRAY_SIZE (p->basic.raw) -1 ; p->feat.max_subleaf =ARRAY_SIZE (p->feat.raw) -1 ; + p->avx10.max_subleaf =ARRAY_SIZE (p->avx10.raw) -1 ; p->extd.max_leaf =0x80000000U +ARRAY_SIZE (p->extd.raw) -1 ; }@@ -408,6 +421,7 @@ static void __init guest_common_default_ { p->basic.max_leaf = host_cpu_policy.basic.max_leaf; p->feat.max_subleaf = host_cpu_policy.feat.max_subleaf; + p->avx10.max_subleaf = host_cpu_policy.avx10.max_subleaf; p->extd.max_leaf = host_cpu_policy.extd.max_leaf; }@@ -503,6 +517,28 @@ static void __init guest_common_max_feat* function correctly when migrated here, even if ERMS isn't available. */ __set_bit (X86_FEATURE_ERMS , fs); + +/* +* AVX10 is merely a re-declaration of a combination of AVX512 features. +* Synthesize the latter from the former, when available. Doing it the +* other way around would also require synthesizing the AVX10 CPUID leaf. +*/ +if (test_bit (X86_FEATURE_AVX10 , fs) ) + { +__set_bit (X86_FEATURE_AVX512F , fs); +__set_bit (X86_FEATURE_AVX512VL , fs); +__set_bit (X86_FEATURE_AVX512BW , fs); +__set_bit (X86_FEATURE_AVX512DQ , fs); +__set_bit (X86_FEATURE_AVX512_BF16 , fs); +__set_bit (X86_FEATURE_AVX512_FP16 , fs); +__set_bit (X86_FEATURE_AVX512CD , fs); +__set_bit (X86_FEATURE_AVX512_BITALG , fs); +__set_bit (X86_FEATURE_AVX512_IFMA , fs); +__set_bit (X86_FEATURE_AVX512_VBMI , fs); +__set_bit (X86_FEATURE_AVX512_VBMI2 , fs); +__set_bit (X86_FEATURE_AVX512_VNNI , fs); +__set_bit (X86_FEATURE_AVX512_VPOPCNTDQ , fs); + } }static void __init guest_common_default_feature_adjustments (uint32_t *fs)@@ -966,6 +1002,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))@@ -1012,6 +1049,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);@@ -1081,9 +1120,18 @@ void __init init_dom0_cpuid_policy(struc/* Apply dom0-cpuid= command line settings, if provided. */ if ( dom0_cpuid_cmdline ) { +const struct cpu_policy *max =is_pv_domain (d) + ? (IS_ENABLED (CONFIG_PV ) ? &pv_max_cpu_policy :NULL ) + : (IS_ENABLED (CONFIG_HVM ) ? &hvm_max_cpu_policy :NULL );uint32_t fs[FSCAPINTS ];unsigned int i; +if ( !max ) + { +ASSERT_UNREACHABLE (); +return ; + } +x86_cpu_policy_to_featureset (p, fs);for ( i =0 ; i <ARRAY_SIZE (fs); ++i )@@ -1093,6 +1141,13 @@ void __init init_dom0_cpuid_policy(struc }x86_cpu_featureset_to_policy (fs, p); + +/* +* Default-off features with their own leaves need those leaves +* re-populated from the max policy. +*/ +if ( p->feat.avx10 ) + p->avx10 = max->avx10; }/* @@ -1125,6 +1180,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@@ -226,6 +226,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/arch/x86/lib/cpu-policy/copy-to-buffer.c +7
-0@@ -123,6 +123,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 ;xen/arch/x86/lib/cpu-policy/copy-from-buffer.c +7
-0@@ -108,6 +108,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/arch/x86/lib/cpu-policy/cpuid.c +1
-0@@ -125,6 +125,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 ; }
xen/arch/x86/lib/cpu-policy/cpuid.c void x86_cpu_policy_fill_native(struct c · line 228
Quoted 10 lines
xen/arch/x86/lib/cpu-policy/cpuid.c +7
-0@@ -218,6 +219,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]);
Do we need to split the 0 iteration out ? I guess we can just start from i = 0 instead.
Quoted 59 lines
xen/arch/x86/lib/cpu-policy/cpuid.c +9
-0+ } +/* Extended leaves. */ cpuid_leaf (0x80000000U , &p->extd.raw[0 ]); for ( i = 1; i <= MIN(p->extd.max_leaf & 0xffffU,@@ -287,6 +297,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),@@ -299,6 +312,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 ); }@@ -326,6 +341,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 )xen/arch/x86/lib/cpu-policy/policy.c +4
-0@@ -24,6 +24,10 @@ 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.max_subleaf > host->avx10.max_subleaf ) +FAIL_CPUID (0x24 ,0 ); +if ( guest->extd.max_leaf > host->extd.max_leaf )FAIL_CPUID (0x80000000U ,NA );xen/include/public/arch-x86/cpufeatureset.h +1
-0@@ -366,6 +366,7 @@ XEN_CPUFEATURE(PREFETCHI, 15*32 XEN_CPUFEATURE(USER_MSR, 15*32+15) /*s U{RD,WR}MSR Instructions */ XEN_CPUFEATURE(UIRET_UIF, 15*32+17) /* UIRET updates UIF */ 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 (SLSM ,15 *32 +24 )/* Static Lockstep Mode */ /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
xen/include/xen/lib/x86/cpu-policy.h unsigned int x86_cpuid_lookup_vendor(uin · line 67
Quoted 10 lines
xen/include/xen/lib/x86/cpu-policy.h +2
-1@@ -59,11 +59,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)
Intel specification now defines AVX10.2 which has a additional leaf (even though the whole leaf is currently marked as "reserved").
Quoted 26 lines
xen/include/xen/lib/x86/cpu-policy.h +13
-0#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, \@@ -264,6 +265,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/tools/gen-cpuid.py def crunch_numbers(state): · line 298
Quoted 6 lines
xen/tools/gen-cpuid.py +1
-1@@ -294,7 +294,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],
I think we can instead make AVX10 a dependency on AVX512. Especially since
Quoted 1 line
Any processor that enumerates support for Intel AVX10 will also
enumerate support for Intel AVX, Intel AVX2, and Intel AVX-512 (see Table 16-2).
with AVX-512 depending on AVX2.
Quoted 4 lines
# AVX512F is taken to mean hardware support for 512bit registers # (which in practice depends on the EVEX prefix to encode) as well
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Re: [PATCH v4 00.9/16] x86/CPUID: enable AVX10 leaf
Quoted 5 lines · Teddy Astie
Le 09/04/2026 à 17:18, Jan Beulich a écrit :
Quoted 4 lines
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.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Jan Beulich <[email protected]>---
Thegen-cpuid.pyadjustment 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.AFAIUI, AVX512BW is a dependency of AVX10, as AVX10 implies that the former is available.
I'm not convinced it is a "dependency". My understanding is that while Intel may say that all their AVX10 hardware is expected to set all the respective AVX512* bits as well, the spec says e.g. "Intel® AVX-512 instruction families included in Intel® AVX10.1 are shown in Table 3.2." Where "instruction families" doesn't say anything about CPUID bits. So from an abstract spec pov someone wanting to use e.g. VMOVDQU8 will want to check for AVX10 || AVX512BW.
Quoted 8 lines
Quoted 3 lines
Do we want to synthesize AVX10 in the (max?) policies when all necessary AVX512* features are available, thus allowing migration from an AVX10 host to a suitable non-AVX10 one?
I guess we want, there is not really a reason to not allow it.
Some software may check for AVX10 only, and not check for individual AVX512 bits.
As per above, such software may be slightly flawed. Synthesizing the AVX10 feature bit also means synthesizing the AVX10 leaf then, for example. This may be somewhat of an issue for migration; I didn't thoroughly think this through yet.
Quoted 11 lines
xen/arch/x86/cpu-policy.c static void recalculate_xstate(struct cp · line 214
Quoted 8 lines
xen/arch/x86/cpu-policy.c +1
-1@@ -211,7 +211,7 @@ static void recalculate_xstate(struct cpif ( p->feat.mpx ) xstates |=X86_XCR0_BNDREGS |X86_XCR0_BNDCSR ; -if ( p->feat.avx512f ) +if ( p->feat.avx512f || p->feat.avx10 )In principle, the avx10 check is redundant as avx512f must be set if avx10 is set.
I don't think so; see above discussion of AVX512BW.
Quoted 14 lines
Quoted 14 lines
xen/arch/x86/lib/cpu-policy/cpuid.c +1
-0@@ -125,6 +125,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 ; }@@ -218,6 +219,15 @@ void x86_cpu_policy_fill_native(struct c } }
Quoted 10 lines
xen/arch/x86/lib/cpu-policy/cpuid.c void x86_cpu_policy_fill_native(struct c · line 228
Quoted 7 lines
xen/arch/x86/lib/cpu-policy/cpuid.c +7
-0+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]);Do we need to split the 0 iteration out ? I guess we can just start from i = 0 instead.
Well, strictly formally p->avx10.max_subleaf is uninitialized on the first loop iteration. Hence comparing against it isn't a good idea. (In practice the field taking whatever value will let i == 0 pass, but still.)
What's more important though: I want to keep this in sync with what we to elsewhere in the function.
Quoted 6 lines
Quoted 6 lines
xen/include/xen/lib/x86/cpu-policy.h +0
-0@@ -59,11 +59,12 @@ unsigned int x86_cpuid_lookup_vendor(uin*/ const char *x86_cpuid_vendor_to_str (unsigned int vendor);
Quoted 10 lines
xen/include/xen/lib/x86/cpu-policy.h unsigned int x86_cpuid_lookup_vendor(uin · line 67
Quoted 7 lines
xen/include/xen/lib/x86/cpu-policy.h +2
-1-#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)Intel specification now defines AVX10.2 which has a additional leaf (even though the whole leaf is currently marked as "reserved").
See "x86/CPUID: enable AVX10.2 sub-leaf" later in the series. The first part aims at supporting just AVX10.1.
Quoted 12 lines
xen/tools/gen-cpuid.py def crunch_numbers(state): · line 298
Quoted 9 lines
xen/tools/gen-cpuid.py +1
-1@@ -294,7 +294,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],I think we can instead make AVX10 a dependency on AVX512. Especially since
Quoted 5 lines
Quoted 1 line
Any processor that enumerates support for Intel AVX10 will also
enumerate support for Intel AVX, Intel AVX2, and Intel AVX-512 (see Table 16-2).
with AVX-512 depending on AVX2.
That's the very statement I refer to at the top. Intel may say this for themselves, but the spec - according to my reading - doesn't mandate this.
Jan
Quoted 10 lines · Jan Beulich
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. Luckily the 256-bit-only case and an unnecessary restriction on the mask register insns was taken out again, simplifying the actual emulator adjustments quite a bit.
AVX10.2 is adding quite a few new insns, support for which is roughly added chapter-wise as the spec has them (perhaps not in the order of the chapters there).
Quoted 8 lines
While it probably could be re-based ahead, the series in this form depends on the previously submitted "[PATCH v5 0/3] x86/CPUID: leaf pruning" and parts of whatever is left of "[PATCH v9 00/10] x86emul:
misc additions".I've tried to be very careful in rebasing ahead of other emulator patches I've been carrying, but almost all testing I've done is with all of those collectively in place.
As you may have noticed, I screwed up the numbering. Hence ...
Quoted 1 line
01: x86/CPUID: enable AVX10 leaf
... this is 00.9, and everything else is off-by-1 (and there's no 16/16). I'm sorry for that.
Jan
Quoted 17 lines
02: x86emul: support SIMD MOVRS
03: x86emul: support AVX10.2 forms of SM4 insns 04: x86emul: support AVX10.1
05: x86emul/test: use simd_check_avx512*() inmain()06: x86emul/test: dropcpu_has_avx512vl
07: x86emul: AVX10.1 testing
08: x86emul/test: engage AVX512VL via command line option 09: x86/CPUID: enable AVX10.2 sub-leaf
10: x86emul: support AVX10.2 scalar compare insns 11: x86emul: support AVX10.2 partial copy insns 12: x86emul: support AVX10.2 media insns
13: x86emul: support AVX10.2 minmax insns
14: x86emul: support AVX10.2 BFloat16 insns
15: x86emul: support AVX10.2 saturating convert insns 16: x86emul: support other AVX10.2 convert insnsJan