x86 xstate area / AMX+XFD / ACE
v4 cover x86 xstate area / AMX+XFD / ACE
While this re-posting is long overdue, this series now sitting on top of the APX one doing so didn't make sense without first posting that dependency. Still, this is already lagging behind again - ACEv2 support is missing for now.
01: x86/xstate: re-size save area when CPUID policy changes 02: x86/xstate: drop xstate_offsets[] and xstate_sizes[] 03: x86/xstate: replace xsave_cntxt_size and drop XCNTXT_MASK 04: x86/xstate: avoid accounting for unsupported components 05: x86: use xvmalloc() for extended context buffer allocations 06: x86/CPUID: enable AMX leaves
07: x86: XFD enabling
08: x86emul: introduce X86EMUL_FPU_{tilecfg,tile}
09: x86emul: support TILERELEASE
10: x86emul: support {LD,ST}TILECFG
11: x86emul: support TILEZERO
12: x86/HVM: respect AMX tile dimensions for emulation caching 13: x86emul: support TILELOADD{,T1} and TILESTORE
14: x86emul: support tile multiplication insns
15: x86emul: test AMX insns
16: x86emul: support APX forms of {LD,ST}TILECFG
17: x86emul: support APX forms of TILE{LOADD{,T1},STORED} 18: x86: permit guests to use AMX and XFD
19: x86/CPUID: TMUL subleaf 1
20: x86emul: support AMX-MOVRS(-only) insns
21: x86emul: support AMX-FP8 insns
22: x86emul: support AMX-AVX512 insns with GPR operand 23: x86emul: support AMX-AVX512 insns with immediate operand 24: x86/CPUID: enable ACE
25: x86emul: enable tile management insns for ACE
26: x86emul: enable tile data movement insns for ACE 27: x86emul: enable block scale register insns for ACE 28: x86emul: enable outer product insns for ACE
Jan
PATCH v4 1/28 x86/xstate: re-size save area when CPUID policy changes
vCPU-s get maximum size areas allocated initially. Hidden (and in particular default-off) features may allow for a smaller size area to suffice.
---
v4: Re-base.
v2: Use 1ul instead of 1ull. Re-base.
---
This could be further shrunk if we used XSAVEC / if we really used XSAVES, as then we don't need to also cover the holes. But since we currently use neither of the two in reality, this would require more work than just adding the alternative size calculation here.
Seeing that both vcpu_init_fpu() and cpu_policy_updated() are called from arch_vcpu_create(), I'm not sure we really need this two-stage approach - the slightly longer period of time during which v->arch.xsave_area would remain NULL doesn't look all that problematic. But since xstate_alloc_save_area() gets called for idle vCPU-s, it has to stay anyway in some form, so the extra code churn may not be worth it.
Instead of cpu_policy_xcr0_max(), cpu_policy_xstates() may be the interface to use here. But it remains to be determined whether the xcr0_accum field is meant to be inclusive of XSS (in which case it would better be renamed) or exclusive. Right now there's no difference as we don't support any XSS-controlled features.
xen/arch/x86/domain.c +18 -9
@@ -290,13 +290,17 @@ void update_guest_memory_policy(struct v* Called during vcpu construction, and each time the toolstack changes the * CPU policy configuration for the domain. */ -static void cpu_policy_updated (struct vcpu *v) +static int __must_check cpu_policy_updated (struct vcpu *v) { -if (is_hvm_vcpu (v) ) +int rc =xstate_update_save_area (v); + +if ( !rc &&is_hvm_vcpu (v) )hvm_cpuid_policy_changed (v); + +return rc; } -void domain_cpu_policy_changed (struct domain *d) +int domain_cpu_policy_changed (struct domain *d) {const struct cpu_policy *p = d->arch.cpu_policy;struct vcpu *v;
@@ -454,17 +458,22 @@ void domain_cpu_policy_changed(struct do/* Nested doesn't have the necessary processing, yet. */ if (nestedhvm_enabled (d) && (p->feat.user_msr || p->feat.msr_imm) ) -return /*-EINVAL*/ ; +return -EINVAL ; for_each_vcpu ( d, v ) { -cpu_policy_updated (v); +int rc =cpu_policy_updated (v); + +if ( rc ) +return rc;/* If PMU version is zero then the guest doesn't have VPMU */ if ( boot_cpu_data.vendor ==X86_VENDOR_INTEL && p->basic.pmu_version ==0 )vpmu_destroy (v); } + +return 0 ; }unsigned int arch_domain_struct_memflags (void )
@@ -562,7 +571,7 @@ int arch_vcpu_create(struct vcpu *v) {vpmu_initialise (v); -cpu_policy_updated (v); + rc =cpu_policy_updated (v); }return rc;
@@ -936,11 +945,11 @@ int arch_domain_create(struct domain *d,*/ d->arch.x87_fip_width = cpu_has_fpu_sel ?0 :8 ; -domain_cpu_policy_changed (d); - d->arch.msr_relaxed = config->arch.misc_flags &XEN_X86_MSR_RELAXED ; -return 0 ; + rc =domain_cpu_policy_changed (d); +if ( !rc ) +return 0 ; fail: d->is_dying = DOMDYING_dead;
xen/arch/x86/domctl.c +1 -1
@@ -87,7 +87,7 @@ static int update_domain_cpu_policy(strurecalculate_cpuid_policy (d);/* Recalculate relevant dom/vcpu state now the policy has changed. */ -domain_cpu_policy_changed (d); + ret =domain_cpu_policy_changed (d); out:/* Free whichever struct is not installed in struct domain. */
xen/arch/x86/include/asm/domain.h +1 -1
@@ -692,7 +692,7 @@ struct guest_memory_policyvoid update_guest_memory_policy (struct vcpu *v,struct guest_memory_policy *policy); -void domain_cpu_policy_changed (struct domain *d); +int __must_check domain_cpu_policy_changed (struct domain *d);bool update_secondary_system_time (struct vcpu *v,struct vcpu_time_info *u);
xen/arch/x86/include/asm/xstate.h +1 -0
@@ -109,6 +109,7 @@ void compress_xsave_states(struct vcpu */* extended state init and cleanup functions */ void xstate_free_save_area (struct vcpu *v);int xstate_alloc_save_area (struct vcpu *v); +int xstate_update_save_area (struct vcpu *v);void xstate_init (struct cpuinfo_x86 *c);unsigned int xstate_uncompressed_size (uint64_t xcr0);unsigned int xstate_compressed_size (uint64_t xstates);
xen/arch/x86/xstate.c +34 -0
@@ -575,6 +575,40 @@ int xstate_alloc_save_area(struct vcpu *return 0 ; } +int xstate_update_save_area (struct vcpu *v) +{ +unsigned int i, size, old; +struct xsave_struct *save_area; +uint64_t xcr0_max =cpu_policy_xcr0_max (v->domain->arch.cpuid); + +ASSERT (!is_idle_vcpu (v)); + +if ( !cpu_has_xsave ) +return 0 ; + +if ( v->arch.xcr0_accum & ~xcr0_max ) +return -EBUSY ; + +for ( size = old =XSTATE_AREA_MIN_SIZE , i =2 ; i < xstate_features; ++i ) + { +if ( xcr0_max & (1ul << i) ) + size =max (size, xstate_offsets[i] + xstate_sizes[i]); +if ( v->arch.xcr0_accum & (1ul << i) ) + old =max (old, xstate_offsets[i] + xstate_sizes[i]); + } + + save_area = _xvrealloc(v->arch.xsave_area, size, __alignof(*save_area)); +if ( !save_area ) +return -ENOMEM ; + +ASSERT (old <= size); +memset ((void *)save_area + old,0 , size - old); + + v->arch.xsave_area = save_area; + +return 0 ; +} +void xstate_free_save_area (struct vcpu *v) {XVFREE (v->arch.xsave_area);
PATCH v4 2/28 x86/xstate: drop xstate_offsets[] and xstate_sizes[]
In reply to Jan BeulichThey're redundant with respective fields from the raw CPUID policy; no need to keep two copies of the same data.
---
v4: Re-base.
xen/arch/x86/include/asm/xstate.h +3 -2
@@ -45,8 +45,9 @@ extern uint32_t mxcsr_mask;extern u64 xfeature_mask;extern u64 xstate_align; -extern unsigned int *xstate_offsets; -extern unsigned int *xstate_sizes; + +#define xstate_offset (n) (raw_cpu_policy.xstate.comp[n].offset) +#define xstate_size (n) (raw_cpu_policy.xstate.comp[n].size)/* extended state save area */ struct __attribute__((aligned (64 )))xsave_struct
xen/arch/x86/xstate.c +18 -36
111 lines not on this page · raw message
PATCH v4 3/28 x86/xstate: replace xsave_cntxt_size and drop XCNTXT_MASK
In reply to Jan BeulichXCNTXT_MASK is effectively embedded in recalculate_xstate(), and xsave_cntxt_size is redundant with the host CPUID policy's xstate.max_size field.
Use the host CPUID policy as input (requiring it to be calculated early enough), thus allowing e.g. "cpuid=no-avx512f" to also result in avoiding allocation of space for ZMM and mask register state.
Also drop a stale part of an adjacent comment.
Further where respective code is being touched anyway, also replace XSTATE_CPUID by 0xd.
---
Andrew voiced objection to the use of the host policy here, yet without indicating what else to use instead. Perhaps that concern is taken care of by "x86/cpu-policy: set up host policy earlier"?
---
v4: Re-base.
xen/arch/x86/include/asm/xstate.h +0 -4
@@ -31,10 +31,6 @@ extern uint32_t mxcsr_mask;#define XSTATE_AREA_MIN_SIZE (FXSAVE_SIZE + XSAVE_HDR_SIZE)#define XSTATE_FP_SSE (X86_XCR0_X87 | X86_XCR0_SSE) -#define XCNTXT_MASK (X86_XCR0_X87 | X86_XCR0_SSE | X86_XCR0_YMM | \ - X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM | \ - X86_XCR0_BNDREGS | X86_XCR0_BNDCSR | X86_XCR0_PKRU | \ - X86_XCR0_TILE_CFG | X86_XCR0_TILE_DATA | X86_XCR0_APX)#define XSTATE_ALL (~(1ULL << 63))#define XSTATE_XSAVES_ONLY 0
xen/arch/x86/xstate.c +22 -28
76 lines not on this page · raw message
PATCH v4 4/28 x86/xstate: avoid accounting for unsupported components
In reply to Jan BeulichThere's no point in including unsupported components in the size calculations of xstate_{alloc,update}_save_area().
xen/arch/x86/xstate.c +6 -0
@@ -521,8 +521,12 @@ int xstate_alloc_save_area(struct vcpu *unsigned int i;for ( size =0 , i =2 ; i < xstate_features; ++i ) + { +if ( !(xfeature_mask & (1ul << i)) ) +continue ;if ( size <xstate_size (i) ) size =xstate_size (i); + } size +=XSTATE_AREA_MIN_SIZE ; }
@@ -574,6 +578,8 @@ int xstate_update_save_area(struct vcpufor ( size = old =XSTATE_AREA_MIN_SIZE , i =2 ; i < xstate_features; ++i ) { +if ( !(xfeature_mask & (1ul << i)) ) +continue ;if ( xcr0_max & (1ul << i) ) size =max (size,xstate_offset (i) +xstate_size (i));if ( v->arch.xcr0_accum & (1ul << i) )
PATCH v4 5/28 x86: use xvmalloc() for extended context buffer allocations
In reply to Jan BeulichThis is in preparation for the buffer sizes exceeding a page's worth of space, as will happen with AMX as well as Architectural LBR.
---
v4: Re-base.
v2: New.
---
TBD: Really I'd like to see x*alloc_bytes() go away, but as per the feedback on "assorted replacement of x[mz]alloc_bytes()" this looks to be controversial.
xen/arch/x86/domctl.c +11 -10
@@ -21,6 +21,7 @@#include <xen/trace.h> #include <xen/types.h> #include <xen/vm_event.h> +#include <xen/xvmalloc.h> #include <asm/acpi.h> #include <asm/cpu-policy.h>
@@ -463,7 +464,7 @@ long arch_do_domctl( goto sethvmcontext_out; ret = -ENOMEM ; -if ( (c.data =xmalloc_bytes (c.size)) ==NULL ) +if ( (c.data =xvmalloc_array (uint8_t, c.size)) ==NULL ) goto sethvmcontext_out; ret = -EFAULT ;
@@ -479,7 +480,7 @@ long arch_do_domctl(domain_unpause (d); sethvmcontext_out: -xfree (c.data); +xvfree (c.data);break ; }
@@ -509,7 +510,7 @@ long arch_do_domctl(/* Allocate our own marshalling buffer */ ret = -ENOMEM ; -if ( (c.data =xmalloc_bytes (c.size)) ==NULL ) +if ( (c.data =xvmalloc_array (uint8_t, c.size)) ==NULL ) goto gethvmcontext_out;domain_pause (d);
@@ -522,7 +523,7 @@ long arch_do_domctl( gethvmcontext_out: copyback = true; -xfree (c.data); +xvfree (c.data);break ; }
@@ -1001,7 +1002,7 @@ long arch_do_domctl(if ( !ret && size >PV_XSAVE_HDR_SIZE ) {unsigned int xsave_size = size -PV_XSAVE_HDR_SIZE ; -void *xsave_area =xmalloc_bytes (xsave_size); +void *xsave_area =xvmalloc_array (uint8_t, xsave_size);if ( !xsave_area ) {
@@ -1015,7 +1016,7 @@ long arch_do_domctl(if (copy_to_guest_offset (evc->buffer, offset, xsave_area, xsave_size) ) ret = -EFAULT ; -xfree (xsave_area); +xvfree (xsave_area); }vcpu_unpause (v);
@@ -1035,7 +1036,7 @@ long arch_do_domctl( evc->size > PV_XSAVE_SIZE(xfeature_mask) ) goto vcpuextstate_out; - receive_buf =xmalloc_bytes (evc->size); + receive_buf =xvmalloc_array (uint8_t, evc->size);if ( !receive_buf ) { ret = -ENOMEM ;
@@ -1045,7 +1046,7 @@ long arch_do_domctl( offset, evc->size) ) { ret = -EFAULT ; -xfree (receive_buf); +xvfree (receive_buf); goto vcpuextstate_out; }
@@ -1063,7 +1064,7 @@ long arch_do_domctl( ret =0 ;if ( ret ) { -xfree (receive_buf); +xvfree (receive_buf); goto vcpuextstate_out; }
@@ -1090,7 +1091,7 @@ long arch_do_domctl(vcpu_unpause (v); } -xfree (receive_buf); +xvfree (receive_buf); }#undef PV_XSAVE_HDR_SIZE
xen/arch/x86/hvm/save.c +3 -2
@@ -12,6 +12,7 @@#include <xen/guest_access.h> #include <xen/softirq.h> #include <xen/version.h> +#include <xen/xvmalloc.h> #include <public/hvm/save.h>
@@ -146,7 +147,7 @@ int hvm_save_one(struct domain *d, unsigelse v = d->vcpu[instance]; ctxt.size = hvm_sr_handlers[typecode].size; - ctxt.data =xmalloc_bytes (ctxt.size); + ctxt.data =xvmalloc_array (uint8_t, ctxt.size);if ( !ctxt.data )return -ENOMEM ;
@@ -192,7 +193,7 @@ int hvm_save_one(struct domain *d, unsigelse domain_unpause (d); -xfree (ctxt.data); +xvfree (ctxt.data);return rv; }
PATCH v4 6/28 x86/CPUID: enable AMX leaves
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 checks in x86_cpu_policies_are_compatible() may be more strict than they ultimately need to be, but I'd rather start being on the safe side.
---
The explicit amx_int8 etc feature checks in two places aren't really nice, as they would need amending with each new feature. Using just amx_tile there, otoh, doesn't look to be enough to qualify the tmul leaf.
It's not clear to me in how far libxl_cpuid.c would want extending: It doesn't look to offer a way to override the maximum subleaf of leaf 7. In fact I can't seem to be able to spot a max extended leaf override mechanism either.
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 require the user to specify (and how would the latter look like)? We did discuss default- enabling sub-features (i.e. AMX-* here when AMX-TILE is enabled), but besides there still not being logic for this that also doesn't easily extend to entire feature-dependent leaves.
---
v4: Add missing checks in x86_cpu_policy_fill_native() and
recalculate_cpuid_policy(). Add logic to init_dom0_cpuid_policy(). Add AMX-FP16 and AMX-COMPLEX. Also check tmul leaf in build_assertions(). Only cover palette 1 in struct cpu_policy. Address Misra concerns. Re-base.
v2: New.
tools/tests/cpu-policy/test-cpu-policy.c +103 -0
@@ -200,6 +200,40 @@ static void test_cpuid_serialise_success }, .nr_leaves = 4 + 0xd + 1 + 1, }, + +/* Leaf 0x1d serialisation stops at max_palette. */ + { + .name = "empty leaf 0x1d", + .p = { + .basic.max_leaf = 0x1d, + }, + .nr_leaves = 4 + 0x1d + 1, + }, + { + .name = "partial leaf 0x1d", + .p = { + .basic.max_leaf = 0x1d, + .tile.max_palette = 1, + }, + .nr_leaves = 4 + 0x1d + 1 + 1, + }, + + /* Leaf 0x1e serialisation stops at 0. */ + { + .name = "empty leaf 0x1e", + .p = { + .basic.max_leaf = 0x1e, + }, + .nr_leaves = 4 + 0x1e + 1, + }, + { + .name = "partial leaf 0x1e", + .p = { + .basic.max_leaf = 0x1e, + .tmul.maxk = 16, + }, + .nr_leaves = 4 + 0x1e + 1, + }, }; printf("Testing CPUID serialise success:\n");
@@ -338,6 +372,14 @@ static void test_cpuid_deserialise_failu .leaf = { .leaf = 0xd, .subleaf = CPUID_GUEST_NR_XSTATE }, }, { + .name = "OoB tile leaf", + .leaf = { .leaf = 0x1d, .subleaf = CPUID_GUEST_NR_PALETTE }, + }, + { + .name = "OoB tmul leaf", + .leaf = { .leaf = 0x1e, .subleaf = CPUID_GUEST_NR_TMUL }, + }, + { .name = "OoB extd leaf", .leaf = { .leaf = 0x80000000 | CPUID_GUEST_NR_EXTD }, },
@@ -444,6 +486,8 @@ static void test_cpuid_out_of_range_clea .topo.raw[0].a = 0xc2, .xstate.raw[0].a = 0xc2, .xstate.raw[1].a = 0xc2, + .tile.raw[0].a = 0xc2, + .tmul.raw[0].a = 0xc2, }, }, {
@@ -459,6 +503,8 @@ static void test_cpuid_out_of_range_clea .topo.raw[0].a = 0xc2, .xstate.raw[0].a = 0xc2, .xstate.raw[1].a = 0xc2, + .tile.raw[0].a = 0xc2, + .tmul.raw[0].a = 0xc2, }, }, {
@@ -473,6 +519,8 @@ static void test_cpuid_out_of_range_clea .topo.raw[0].a = 0xc2, .xstate.raw[0].a = 0xc2, .xstate.raw[1].a = 0xc2, + .tile.raw[0].a = 0xc2, + .tmul.raw[0].a = 0xc2, }, }, {
@@ -486,6 +534,8 @@ static void test_cpuid_out_of_range_clea .topo.raw[1].b = 0xc2, .xstate.raw[0].a = 0xc2, .xstate.raw[1].a = 0xc2, + .tile.raw[0].a = 0xc2, + .tmul.raw[0].a = 0xc2, }, }, {
@@ -500,6 +550,8 @@ static void test_cpuid_out_of_range_clea .xstate.raw[2].b = 0xc2, .xstate.raw[3].b = 0xc2, + .tile.raw[0].a = 0xc2, + .tmul.raw[0].a = 0xc2, }, }, {
@@ -542,6 +594,34 @@ static void test_cpuid_out_of_range_clea }, }, { + .name = "tile no palette", + .nr_markers = 0, + .p = { +/* First two subleaves invalid as a pair. Others cleared. */ + .basic.max_leaf = 0x1d, + .xstate.xcr0_low = XSTATE_FP_SSE, + + .tile.raw[0].a = 0xc2, + .tile.raw[1].b = 0xc2, + .tmul.raw[0].a = 0xc2, + }, + }, + { + .name = "tile palette 1", + .nr_markers = 1, + .p = { +/* First two subleaves valid as a pair. Others cleared. */ + .basic.max_leaf = 0x1d, + .feat.amx_tile = 1, + .xstate.xcr0_low =XSTATE_FP_SSE |X86_XCR0_TILE_CFG | + X86_XCR0_TILE_DATA, + .tile.raw[0].a = 1, + .tile.raw[1].b = 0xc2, + + .tmul.raw[0].a = 0xc2, + }, + }, + { .name = "extd", .nr_markers = 1, .p = {
@@ -636,6 +716,24 @@ static void test_cpuid_maximum_leaf_shri }, }, { + .name = "tile", + .p = { + /* Subleaf 1 only with some valid value. */ + .basic.max_leaf = 0x1d, + .tile.raw[0].a = 1, + .tile.raw[1].a = 1024, + }, + }, + { + .name = "tmul", + .p = { + /* Subleaf 0 only with some valid values. */ + .basic.max_leaf = 0x1e, + .tmul.maxk = 16, + .tmul.maxn = 16, + }, + }, + { .name = "extd", .p = { /* Commonly available information only. */
@@ -655,6 +753,7 @@ static void test_cpuid_maximum_leaf_shri p->basic.max_leaf =ARRAY_SIZE (p->basic.raw) -1 ; p->feat.max_subleaf =ARRAY_SIZE (p->feat.raw) -1 ; + p->tile.max_palette =ARRAY_SIZE (p->tile.raw) -1 ; p->extd.max_leaf =0x80000000 | (ARRAY_SIZE (p->extd.raw) -1 );x86_cpu_policy_shrink_max_leaves (p);
@@ -672,6 +771,10 @@ static void test_cpuid_maximum_leaf_shrifail (" Test %s feat fail - expected %#x, got %#x\n" , t->name, t->p.feat.max_subleaf, p->feat.max_subleaf); +if ( p->tile.max_palette != t->p.tile.max_palette ) +fail (" Test %s tile fail - expected %#x, got %#x\n" , + t->name, t->p.tile.max_palette, p->tile.max_palette); +free (p); } }
xen/arch/x86/cpu-policy.c +47 -1
132 lines not on this page · raw message
xen/arch/x86/cpuid.c +16 -0
@@ -226,6 +226,22 @@ void guest_cpuid(const struct vcpu *v, u *res =array_access_nospec (p->xstate.raw, subleaf);break ; +case 0x1d : +ASSERT (p->tile.max_palette <ARRAY_SIZE (p->tile.raw)); +if ( subleaf >min_t (uint32_t, p->tile.max_palette, +ARRAY_SIZE (p->tile.raw) -1 ) ) +return ; + + *res =array_access_nospec (p->tile.raw, subleaf); +break ; + +case 0x1e : +if ( subleaf >=ARRAY_SIZE (p->tmul.raw) ) +return ; + + *res =array_access_nospec (p->tmul.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,
xen/arch/x86/lib/cpu-policy/copy-to-buffer.c +13 -0
@@ -123,6 +123,19 @@ int x86_cpuid_copy_to_buffer(const strucbreak ; } +case 0x1d : +for ( subleaf =0 ; + subleaf <=MIN (p->tile.max_palette, +ARRAY_SIZE (p->tile.raw) -1 ); ++subleaf ) +COPY_LEAF (leaf, subleaf, &p->tile.raw[subleaf]); +break ; + +case 0x1e : +for ( subleaf =0 ; + subleaf <=ARRAY_SIZE (p->tmul.raw) -1 ; ++subleaf ) +COPY_LEAF (leaf, subleaf, &p->tmul.raw[subleaf]); +break ; +case 0x24 : for ( subleaf = 0; subleaf <= MIN(p->avx10.max_subleaf,
xen/arch/x86/lib/cpu-policy/copy-from-buffer.c +14 -0
@@ -108,6 +108,20 @@ int x86_cpuid_copy_from_buffer(struct cparray_access_nospec (p->xstate.raw, data.subleaf) = l;break ; +case 0x1d : +if ( data.subleaf >=ARRAY_SIZE (p->tile.raw) ) + goto out_of_range; + +array_access_nospec (p->tile.raw, data.subleaf) = l; +break ; + +case 0x1e : +if ( data.subleaf >=ARRAY_SIZE (p->tmul.raw) ) + goto out_of_range; + +array_access_nospec (p->tmul.raw, data.subleaf) = l; +break ; +case 0x24 :if ( data.subleaf >=ARRAY_SIZE (p->avx10.raw) ) goto out_of_range;
xen/arch/x86/lib/cpu-policy/cpuid.c +44 -1
75 lines not on this page · raw message
xen/arch/x86/lib/cpu-policy/policy.c +24 -0
@@ -24,6 +24,30 @@ int x86_cpu_policies_are_compatible(consif ( guest->feat.max_subleaf > host->feat.max_subleaf )FAIL_CPUID (7 ,0 ); +if ( (guest->feat.amx_tile && !guest->tile.max_palette) || + guest->tile.max_palette > host->tile.max_palette ) +FAIL_CPUID (0x1d ,0 ); + +if ( guest->tile.max_palette >=1 ) + { + const typeof(guest->tile.palette1) *gt = &guest->tile.palette1, + *ht = &host->tile.palette1; + +if ( gt->tot_bytes != ht->tot_bytes || + gt->bytes_per_tile != ht->bytes_per_tile || + gt->bytes_per_row != ht->bytes_per_row || + !gt->num_regs || gt->num_regs > ht->num_regs || + !gt->max_rows || gt->max_rows > ht->max_rows ) +FAIL_CPUID (0x1d ,1 ); + } + +if ( ((guest->feat.amx_int8 || guest->feat.amx_bf16 || + guest->feat.amx_fp16 || guest->feat.amx_complex) && + (!guest->tmul.maxk || !guest->tmul.maxn)) || + guest->tmul.maxk > host->tmul.maxk || + guest->tmul.maxn > host->tmul.maxn ) +FAIL_CPUID (0x1e ,0 ); +if ( guest->avx10.version > host->avx10.version || guest->avx10.max_subleaf > host->avx10.max_subleaf )FAIL_CPUID (0x24 ,0 );
xen/arch/x86/lib/cpu-policy/private.h +4 -0
@@ -15,13 +15,17 @@#else +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> #include <stddef.h> #include <string.h> +#define ASSERT assert +#include <xen/asm/msr-index.h> +#include <xen/asm/x86-defns.h> #include <xen/asm/x86-vendors.h> #include <xen-tools/common-macros.h>
xen/include/xen/lib/x86/cpu-policy.h +31 -0
@@ -66,6 +66,8 @@ 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_PALETTE (1u + 1) +#define CPUID_GUEST_NR_TMUL (0u + 1)#define CPUID_GUEST_NR_AVX10 (1u + 1)#define CPUID_GUEST_NR_APX (0u + 1)#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
@@ -268,6 +270,35 @@ struct cpu_policy } comp[CPUID_GUEST_NR_XSTATE ]; } xstate; +/* Structured tile information leaf: 0x00000001d[xx] */ +union { +struct cpuid_leaf raw[CPUID_GUEST_NR_PALETTE ]; +struct { +/* Subleaf 0. */ +uint32_t max_palette; + uint32_t /* b */:32, /* c */:32, /* d */:32; + +/* Palette (subleaf) 1. */ +struct { +uint16_t tot_bytes, bytes_per_tile; +uint16_t bytes_per_row, num_regs; + uint16_t max_rows, :16; + uint32_t /* d */:32; + } palette1; + }; + } tile; + +/* Structured tmul information leaf: 0x00000001e[xx] */ +union { +struct cpuid_leaf raw[CPUID_GUEST_NR_TMUL ]; +struct { +/* Subleaf 0. */ + uint32_t /* a */:32; + uint32_t maxk:8, maxn:16, :8; + uint32_t /* c */:32, /* d */:32; + }; + } tmul; +/* Structured AVX10 information leaf: 0x000000024[xx] */ union {struct cpuid_leaf raw[CPUID_GUEST_NR_AVX10 ];
PATCH v4 7/28 x86: XFD enabling
In reply to Jan BeulichJust like for XCR0 we generally want to run with the guest settings of the involved MSRs while in Xen. Hence saving/restoring of guest values needs to only happen during context switch.
Due to the way XFD_ERR is updated by the hardware when #NM is intercepted, we need to keep XFD_ERR intercepted as well when #NM is. This way (like for PV) we can properly determine whether a particular instance of #NM was due to a new bit in the MSR having become set, or because of lazy-FPU handling.
---
v4: Properly add the two MSRs to all four lists of MSRs to migrate
(instead of just one of them). Move XFD_ERR handling to *_[gs]et_reg(), adjusting it for VMX. Also fiddle with do_device_not_available() and vmx_vmexit_handler(). Don't write XFD_ERR from paravirt_ctxt_switch_to(). Clear XFD_ERR in vmx_save_guest_msrs(). Tie XFD_ERR interception to that of #NM. Use wrmsrns(). Re-base.
v3: New.
---
I wasn't sure whether we want to have AMX depend on XFD. Purely from a spec pov the two are independent features (without XFD one simply wouldn't have a way to disable it for the purpose of lazy allocation of state saving space).
TBD: Formally #NM injection in do_device_not_available() may need to use
struct x86_event's data field, yet it's not quite clear to me whether that's really necessary there.
xen/arch/x86/cpu-policy.c +3 -0
@@ -241,6 +241,9 @@ static void recalculate_xstate(struct cp p->xstate.xss_high = (xstates &XSTATE_XSAVES_ONLY ) >>32 ; } +if ( p->xstate.xfd ) + ecx_mask |=XSTATE_XFD ; +/* Subleafs 2+ */ xstates &= ~XSTATE_FP_SSE ;BUILD_BUG_ON (ARRAY_SIZE (p->xstate.comp) <63 );
xen/arch/x86/domain.c +6 -0
@@ -2036,6 +2036,12 @@ void cf_check paravirt_ctxt_switch_to(stif ( cpu_has_msr_tsc_aux )wrmsr_tsc_aux (v->arch.msrs->tsc_aux); + +if ( v->domain->arch.cpuid->xstate.xfd ) + { +wrmsrns (MSR_XFD , v->arch.msrs->xfd); +/* XFD_ERR is kept at zero at all times when Xen is "owning" the MSR. */ + } }static void _update_runstate_area (struct vcpu *v)
xen/arch/x86/domctl.c +4 -0
@@ -1153,6 +1153,8 @@ long arch_do_domctl(static const uint32_t msrs_to_send[] = {MSR_SPEC_CTRL ,MSR_INTEL_MISC_FEATURES_ENABLES , +MSR_XFD , +MSR_XFD_ERR ,MSR_TSC_AUX ,MSR_AMD64_DR0_ADDRESS_MASK ,MSR_AMD64_DR1_ADDRESS_MASK ,
@@ -1250,6 +1252,8 @@ long arch_do_domctl( {case MSR_SPEC_CTRL :case MSR_INTEL_MISC_FEATURES_ENABLES : +case MSR_XFD : +case MSR_XFD_ERR :case MSR_TSC_AUX :case MSR_AMD64_DR0_ADDRESS_MASK : case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK:
xen/arch/x86/hvm/hvm.c +4 -0
@@ -1396,6 +1396,8 @@ static const uint32_t msrs_to_send[] = {MSR_USER_MSR_CTL ,MSR_SPEC_CTRL ,MSR_INTEL_MISC_FEATURES_ENABLES , +MSR_XFD , +MSR_XFD_ERR ,MSR_PKRS ,MSR_IA32_BNDCFGS , MSR_IA32_XSS,
@@ -1551,6 +1553,8 @@ static int cf_check hvm_load_cpu_msrs(stcase MSR_USER_MSR_CTL :case MSR_SPEC_CTRL :case MSR_INTEL_MISC_FEATURES_ENABLES : +case MSR_XFD : +case MSR_XFD_ERR :case MSR_PKRS :case MSR_IA32_BNDCFGS :case MSR_IA32_XSS :
xen/arch/x86/hvm/vmx/vmcs.c +6 -0
@@ -1210,6 +1210,12 @@ static int construct_vmcs(struct vcpu *vif ( (vmexit_ctl &VM_EXIT_CLEAR_BNDCFGS ) && (vmentry_ctl &VM_ENTRY_LOAD_BNDCFGS ) )vmx_clear_msr_intercept (v,MSR_IA32_BNDCFGS ,VMX_MSR_RW ); + +if ( d->arch.cpuid->xstate.xfd ) + { +vmx_clear_msr_intercept (v,MSR_XFD ,VMX_MSR_RW ); +vmx_clear_msr_intercept (v,MSR_XFD_ERR ,VMX_MSR_RW ); + } }/* I/O access bitmap. */
xen/arch/x86/hvm/vmx/vmx.c +27 -0
@@ -729,6 +729,14 @@ static void vmx_save_guest_msrs(struct v*/ v->arch.hvm.vmx.shadow_gs =read_gs_shadow (); +if ( v->domain->arch.cpuid->xstate.xfd ) + { + msrs->xfd =rdmsr (MSR_XFD ); + msrs->xfd_err =rdmsr (MSR_XFD_ERR ); +if ( msrs->xfd_err ) +wrmsrns (MSR_XFD_ERR ,0 ); + } +#ifdef CONFIG_VMTRACE if ( v->arch.hvm.vmx.ipt_active ) {
@@ -754,6 +762,13 @@ static void vmx_restore_guest_msrs(strucif ( cpu_has_msr_tsc_aux )wrmsr_tsc_aux (msrs->tsc_aux); +if ( v->domain->arch.cpuid->xstate.xfd ) + { +wrmsrns (MSR_XFD , msrs->xfd); +if ( msrs->xfd_err ) +wrmsrns (MSR_XFD_ERR , msrs->xfd_err); + } +#ifdef CONFIG_VMTRACE if ( v->arch.hvm.vmx.ipt_active ) {
@@ -2780,6 +2795,12 @@ static uint64_t cf_check vmx_get_reg(strcase MSR_PKRS :return (v == curr) ?rdpkrs () : msrs->pkrs; +case MSR_XFD_ERR : +if ( v != curr ) +return msrs->xfd_err; + val =rdmsr (MSR_XFD_ERR ); +return val; +case MSR_SHADOW_GS_BASE :if ( v != curr )return v->arch.hvm.vmx.shadow_gs;
@@ -2840,6 +2861,12 @@ static void cf_check vmx_set_reg(structif ( v == curr )wrpkrs (val);return ; + +case MSR_XFD_ERR : + msrs->xfd_err = val; +if ( v == curr ) +wrmsrns (MSR_XFD_ERR , val); +return ; }/* Logic which maybe requires remote VMCS acquisition. */
xen/arch/x86/include/asm/guest-msr.h +6 -0
@@ -64,6 +64,12 @@ struct vcpu_msrs }; } misc_features_enables; +/* 0x000001c4 - MSR_XFD */ +uint64_t xfd; + +/* 0x000001c5 - MSR_XFD_ERR */ +uint64_t xfd_err; +#ifdef CONFIG_VMTRACE /* * 0x00000560 ... 57x - MSR_RTIT_*
xen/arch/x86/include/asm/msr-index.h +4 -0
@@ -124,6 +124,10 @@#define MSR_TEMPERATURE_TARGET 0x000001a2#define MSR_PACKAGE_THERM_STATUS 0x000001b1 +/* Bits within these two MSRs share positions with XCR0. */ +#define MSR_XFD 0x000001c4 +#define MSR_XFD_ERR 0x000001c5 +#define MSR_FRED_RSP_SL0 0x000001cc#define MSR_FRED_RSP_SL1 0x000001cd#define MSR_FRED_RSP_SL2 0x000001ce
xen/arch/x86/include/asm/xstate.h +2 -0
@@ -38,9 +38,11 @@ extern uint32_t mxcsr_mask;#define XSTATE_XSS (1U << 0)#define XSTATE_ALIGN64 (1U << 1) +#define XSTATE_XFD (1U << 2)extern u64 xfeature_mask;extern u64 xstate_align; +extern uint64_t xfd_mask;#define xstate_offset (n) (raw_cpu_policy.xstate.comp[n].offset)#define xstate_size (n) (raw_cpu_policy.xstate.comp[n].size)
xen/arch/x86/msr.c +26 -0
@@ -220,6 +220,17 @@ int guest_rdmsr(struct vcpu *v, uint32_t *val = msrs->misc_features_enables.raw;break ; +case MSR_XFD : +if ( !cp->xstate.xfd ) + goto gp_fault; + *val = v == curr &&is_hvm_domain (d) ?rdmsr (msr) : msrs->xfd; +break ; + +case MSR_XFD_ERR : +if ( !cp->xstate.xfd ) + goto gp_fault; + goto get_reg; +case MSR_P5_MC_ADDR :case MSR_P5_MC_TYPE : case MSR_IA32_MCG_CAP ... MSR_IA32_MCG_CTL: /* 0x179 -> 0x17b */
@@ -549,6 +560,21 @@ int guest_wrmsr(struct vcpu *v, uint32_tbreak ; } +case MSR_XFD : +if ( !cp->xstate.xfd || + (val & ~(cpu_policy_xstates (cp) & xfd_mask)) ) + goto gp_fault; +if ( v == curr ) +wrmsrns (msr, val); + msrs->xfd = val; +break ; + +case MSR_XFD_ERR : +if ( !cp->xstate.xfd || + (val & ~(cpu_policy_xstates (cp) & xfd_mask)) ) + goto gp_fault; + goto set_reg; + case MSR_IA32_MCG_CAP ... MSR_IA32_MCG_CTL: /* 0x179 -> 0x17b */ case MSR_IA32_MCx_CTL2(0) ... MSR_IA32_MCx_CTL2(31): /* 0x280 -> 0x29f */ case MSR_IA32_MCx_CTL(0) ... MSR_IA32_MCx_MISC(31): /* 0x400 -> 0x47f */
xen/arch/x86/pv/emulate.c +7 -0
@@ -102,6 +102,9 @@ uint64_t pv_get_reg(struct vcpu *v, unsicase MSR_SPEC_CTRL :return msrs->spec_ctrl.raw; +case MSR_XFD_ERR : +return msrs->xfd_err; +default :printk (XENLOG_G_ERR "%s(%pv, 0x%08x) Bad register\n" , __func__, v, reg);
@@ -123,6 +126,10 @@ void pv_set_reg(struct vcpu *v, unsigned msrs->spec_ctrl.raw = val;break ; +case MSR_XFD_ERR : + msrs->xfd_err = val; +break ; +default :printk (XENLOG_G_ERR "%s(%pv, 0x%08x, 0x%016" PRIx64") Bad register\n" , __func__, v, reg, val);
xen/arch/x86/traps.c +17 -0
@@ -36,6 +36,7 @@#include <asm/flushtlb.h> #include <asm/fsgsbase.h> #include <asm/gdbsx.h> +#include <asm/guest-msr.h> #include <asm/i387.h> #include <asm/io.h> #include <asm/irq-vectors.h>
@@ -2019,6 +2020,22 @@ void asmlinkage do_device_not_available( }#ifdef CONFIG_PV +if ( curr->arch.msrs->xfd ) + { +uint64_t xfd_err =rdmsr (MSR_XFD_ERR ); + +if ( xfd_err ) + { + curr->arch.msrs->xfd_err |= xfd_err; + +/* Bits in XFD_ERR are sticky; clear the MSR right away. */ +wrmsrns (MSR_XFD_ERR ,0 ); + +pv_inject_hw_exception (X86_EXC_NM ,X86_EVENT_NO_EC ); +return ; + } + } +if ( !(curr->arch.pv.ctrlreg[0 ] &X86_CR0_TS ) ) {ASSERT_UNREACHABLE ();
xen/arch/x86/xstate.c +9 -0
@@ -30,6 +30,10 @@u64 __read_mostly xfeature_mask;u64 __read_mostly xstate_align; + +/* Mask of XSAVE/XRSTOR features supporting XFD. */ +uint64_t __ro_after_init xfd_mask; +static unsigned int __read_mostly xstate_features;uint32_t __read_mostly mxcsr_mask =0x0000ffbf ;
@@ -114,6 +118,11 @@ static int setup_xstate_features(bool bs__set_bit (leaf, &xstate_align); else BUG_ON(!(ecx & XSTATE_ALIGN64) != !test_bit(leaf, &xstate_align)); + +if ( bsp && (ecx &XSTATE_XFD ) ) +__set_bit (leaf, &xfd_mask); +else +BUG_ON (!(ecx &XSTATE_XFD ) != !test_bit (leaf, &xfd_mask)); }return 0 ;
xen/include/xen/lib/x86/cpu-policy.h +1 -1
@@ -265,7 +265,7 @@ struct cpu_policy/* Per-component common state. Valid for i >= 2. */ struct xstate_component {uint32_t size, offset; -bool xss:1 , align:1 ; +bool xss:1 , align:1 , xfd:1 ;uint32_t _res_d; } comp[CPUID_GUEST_NR_XSTATE ]; } xstate;
xen/tools/gen-cpuid.py +1 -1
@@ -259,7 +259,7 @@ def crunch_numbers(state): # are instructions built on top of base XSAVE, while others are new # instruction groups which are specified to require XSAVE for state # management. - XSAVE: [XSAVEOPT, XSAVEC, XGETBV1, XSAVES, + XSAVE: [XSAVEOPT, XSAVEC, XGETBV1, XSAVES, XFD, AVX, MPX, PKU, AMX_TILE, APX_F, LWP], # AVX is taken to mean hardware support for 256bit registers (which in
PATCH v4 8/28 x86emul: introduce X86EMUL_FPU_{tilecfg,tile}
In reply to Jan BeulichThese will be used by AMX insns. They're not sensitive to CR0.TS, but instead some are sensitive to XFD.
---
v4: Use X86_EXC_*. Re-base.
v3: Separate X86EMUL_FPU_tilecfg. Use XFD alternative logic instead of
checking CR0.TS.
v2: New.
xen/arch/x86/x86_emulate/x86_emulate.c +47 -7
@@ -425,6 +425,14 @@ int x86emul_get_fpu(return X86EMUL_UNHANDLEABLE ;break ; +case X86EMUL_FPU_tilecfg: +case X86EMUL_FPU_tile: +ASSERT (mode_64bit ()); +if ( !(state->xcr0 &X86_XCR0_TILE_CFG ) || + !(state->xcr0 &X86_XCR0_TILE_DATA ) ) +return X86EMUL_UNHANDLEABLE ; +break ; +default :break ; }
@@ -434,6 +442,7 @@ int x86emul_get_fpu(if ( rc ==X86EMUL_OKAY ) {unsigned long cr0; +uint64_t xcr0_needed =0 ;fail_if (type == X86EMUL_FPU_fpu && !ops->put_fpu);
@@ -458,15 +467,46 @@ int x86emul_get_fpu(/* Should be unreachable if VEX decoding is working correctly. */ ASSERT ((cr0 &X86_CR0_PE ) && !(ctxt->regs->eflags &X86_EFLAGS_VM )); } -if ( cr0 &X86_CR0_EM ) + +switch ( type ) + { +default : +if ( cr0 &X86_CR0_EM ) + { +generate_exception_if (type == X86EMUL_FPU_fpu,X86_EXC_NM ); +generate_exception_if (type == X86EMUL_FPU_mmx,X86_EXC_UD ); +generate_exception_if (type == X86EMUL_FPU_xmm,X86_EXC_UD ); + } +generate_exception_if ((cr0 &X86_CR0_TS ) && + (type != X86EMUL_FPU_wait || + (cr0 &X86_CR0_MP )), +X86_EXC_NM ); +break ; + +case X86EMUL_FPU_tilecfg: +break ; + +case X86EMUL_FPU_tile: + xcr0_needed =X86_XCR0_TILE_DATA ; +break ; + } + +if ( xcr0_needed && ctxt->cpuid->xstate.xfd ) { -generate_exception_if (type == X86EMUL_FPU_fpu,X86_EXC_NM ); -generate_exception_if (type == X86EMUL_FPU_mmx,X86_EXC_UD ); -generate_exception_if (type == X86EMUL_FPU_xmm,X86_EXC_UD ); +uint64_t xfd; + +fail_if (!ops->read_msr); + rc = ops->read_msr (MSR_XFD , &xfd, ctxt); +if ( rc ==X86EMUL_OKAY && (xfd & xcr0_needed) ) + { +fail_if (!ops->write_msr); + rc = ops->read_msr (MSR_XFD_ERR , &xfd, ctxt); +if ( rc ==X86EMUL_OKAY ) + rc = ops->write_msr (MSR_XFD_ERR , xfd | xcr0_needed, ctxt, + false); +generate_exception_if (rc ==X86EMUL_OKAY ,X86_EXC_NM ); + } } -generate_exception_if ((cr0 &X86_CR0_TS ) && - (type != X86EMUL_FPU_wait || (cr0 &X86_CR0_MP )), -X86_EXC_NM ); } done:
xen/arch/x86/x86_emulate/x86_emulate.h +2 -0
@@ -85,6 +85,8 @@ enum x86_emulate_fpu_type { X86EMUL_FPU_ymm,/* AVX/XOP instruction set (%ymm0-%ymm7/15) */ X86EMUL_FPU_opmask,/* AVX512 opmask instruction set (%k0-%k7) */ X86EMUL_FPU_zmm,/* AVX512 instruction set (%zmm0-%zmm7/31) */ + X86EMUL_FPU_tilecfg,/* AMX configuration (tilecfg) */ + X86EMUL_FPU_tile,/* AMX instruction set (%tmm0-%tmmN) */ /* This sentinel will never be passed to ->get_fpu(). */ X86EMUL_FPU_none };
PATCH v4 9/28 x86emul: support TILERELEASE
In reply to Jan BeulichThis is relatively straightforward, and hence best suited to introduce a few other general pieces.
Testing of this will be added once a sensible test can be put together, i.e. when support for other insns is also there.
---
v4: Use X86_EXC_*. Re-base.
v2: New.
tools/tests/x86_emulator/predicates.c +1 -0
@@ -1343,6 +1343,7 @@ static const struct vex { { { 0x45 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsrlv{d,q} */ { { 0x46 }, 2, T, R, pfx_66, W0, Ln }, /* vpsravd */ { { 0x47 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsllv{d,q} */ + { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ { { 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 */
tools/tests/x86_emulator/x86-emulate.c +4 -0
@@ -227,6 +227,10 @@ int emul_test_get_fpu(break ;default :return X86EMUL_UNHANDLEABLE ; + +case X86EMUL_FPU_tilecfg: +case X86EMUL_FPU_tile: +return cpu_has_amx_tile ?X86EMUL_OKAY :X86EMUL_UNHANDLEABLE ; }return X86EMUL_OKAY ; }
xen/arch/x86/x86_emulate/private.h +1 -0
@@ -604,6 +604,7 @@ 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_amx_tile () (ctxt->cpuid->feat.amx_tile)#define vcpu_has_sha512 () (ctxt->cpuid->feat.sha512)#define vcpu_has_sm3 () (ctxt->cpuid->feat.sm3)#define vcpu_has_sm4 () (ctxt->cpuid->feat.sm4)
xen/arch/x86/x86_emulate/decode.c +1 -0
@@ -363,6 +363,7 @@ static const struct ext0f38_table { [0x43] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x44] = { .simd_size = simd_packed_int, .two_op = 1, .d8s = d8s_vl }, [0x45 ... 0x47] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, + [0x49] = { .simd_size = simd_other, .two_op = 1 }, [0x4c] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x4d] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x4e] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl },
xen/arch/x86/x86_emulate/x86_emulate.c +18 -0
@@ -6548,6 +6548,24 @@ x86_emulate(generate_exception_if (vex.l,X86_EXC_UD ); goto simd_0f_avx; +case X86EMUL_OPC_VEX (0x0f38 ,0x49 ): +generate_exception_if (!mode_64bit () || vex.l || vex.w,X86_EXC_UD ); +if ( ea.type ==OP_REG ) + { +switch ( modrm ) + { +case 0xc0 :/* tilerelease */ +vcpu_must_have (amx_tile); +get_fpu (X86EMUL_FPU_tilecfg); + op_bytes =1 ;/* fake */ + goto simd_0f_common; + +default : + goto unrecognized_insn; + } + } + goto unimplemented_insn; +case X86EMUL_OPC_VEX (0x0f38 ,0x50 ):/* vpdpbuud [xy]mm/mem,[xy]mm,[xy]mm */ case X86EMUL_OPC_VEX_F3 (0x0f38 ,0x50 ):/* vpdpbsud [xy]mm/mem,[xy]mm,[xy]mm */ case X86EMUL_OPC_VEX_F2 (0x0f38 ,0x50 ):/* vpdpbssd [xy]mm/mem,[xy]mm,[xy]mm */
PATCH v4 10/28 x86emul: support {LD,ST}TILECFG
In reply to Jan BeulichWhile ver 043 of the ISA extensions doc also specifies xcr0_supports_palette() returning false as one of the #GP(0) reasons for LDTILECFG, the earlier #UD / #GP conditions look to make this fully dead.
---
v4: Prevent double read for LDTILECFG. Use X86_EXC_*. Re-base.
v3: Rebase over struct x86_tilecfg introduction.
v2: New.
---
SDE: -spr or -gnr
tools/tests/x86_emulator/predicates.c +2 -0
@@ -1343,6 +1343,8 @@ static const struct vex { { { 0x45 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsrlv{d,q} */ { { 0x46 }, 2, T, R, pfx_66, W0, Ln }, /* vpsravd */ { { 0x47 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsllv{d,q} */ + { { 0x49, 0x00 }, 2, F, R, pfx_no, W0, L0 }, /* ldtilecfg */ + { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ { { 0x50 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpbuud */ { { 0x50 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpbusd */
tools/tests/x86_emulator/test_x86_emulator.c +73 -0
85 lines not on this page · raw message
tools/tests/x86_emulator/x86-emulate.h +14 -0
@@ -83,6 +83,17 @@#define is_canonical_address (x) (((int64_t)(x) >> 47) == ((int64_t)(x) >> 63)) +static inline void *memchr_inv (const void *s,int c,size_t n) +{ +const unsigned char *p = s; + +while ( n-- ) +if ( (unsigned char )c != *p++ ) +return (void *)(p -1 ); + +return NULL ; +} +static inline void *place_ret (void *ptr) { *(uint8_t *)ptr =0xc3 ;
@@ -210,6 +221,9 @@ void wrpkru(unsigned int val);#define cpu_has_serialize cpu_policy.feat.serialize#define cpu_has_avx512_fp16 (cpu_policy.feat.avx512_fp16 && \ xcr0_mask(0xe6)) +#define cpu_has_amx_tile (cpu_policy.feat.amx_tile && \ + xcr0_mask(X86_XCR0_TILE_CFG | \ + X86_XCR0_TILE_DATA))#define cpu_has_sha512 (cpu_policy.feat.sha512 && xcr0_mask(6))#define cpu_has_sm3 (cpu_policy.feat.sm3 && xcr0_mask(6))#define cpu_has_sm4 (cpu_policy.feat.sm4 && xcr0_mask(6))
xen/arch/x86/include/asm/x86-types.h +10 -0
@@ -74,4 +74,14 @@ struct segment_register { uint64_t base; }; +/* +* TILECFG register +*/ +struct x86_tilecfg { +uint8_t palette, start_row; +uint8_t res[14 ]; +uint16_t colsb[16 ]; +uint8_t rows[16 ]; +}; +#endif /* X86_X86_TYPES_H */
xen/arch/x86/x86_emulate/decode.c +4 -0
@@ -1267,6 +1267,10 @@ decode_0f38(struct x86_emulate_state *s, s->simd_size = simd_packed_fp;break ; +case X86EMUL_OPC_VEX_66 (0 ,0x49 ):/* sttilecfg */ + s->desc = DstMem | SrcImplicit | Mov; +break ; +case X86EMUL_OPC_EVEX_66 (0 ,0x7a ):/* vpbroadcastb */ case X86EMUL_OPC_EVEX_66 (0 ,0x7b ):/* vpbroadcastw */ case X86EMUL_OPC_EVEX_66 (0 ,0x7c ):/* vpbroadcast{d,q} */
xen/arch/x86/x86_emulate/private.h +2 -0
@@ -18,6 +18,7 @@# include <asm/endbr.h> # include <asm/msr-index.h> # include <asm/stubs.h> +# include <asm/x86-types.h> # include <asm/x86-vendors.h> # include <asm/x86_emulate.h>
@@ -372,6 +373,7 @@ typedef union {uint64_t __attribute__ ((aligned (16 ))) xmm[2 ];uint64_t __attribute__ ((aligned (32 ))) ymm[4 ];uint64_t __attribute__ ((aligned (64 ))) zmm[8 ]; +struct x86_tilecfg tilecfg;uint32_t data32[16 ]; } mmval_t;
xen/arch/x86/x86_emulate/x86_emulate.c +75 -1
88 lines not on this page · raw message
PATCH v4 11/28 x86emul: support TILEZERO
In reply to Jan BeulichThis is relatively straightforward, and hence best suited to introduce a few other wider use pieces.
Testing of this will be added once a sensible test can be put together, i.e. when support for at least TILELOADD (to allow loading non-zero values in the first place) is also there.
---
v4: Use X86_EXC_*. Fold tiles_configured() into tile_valid(). Re-base.
v3: New.
tools/tests/x86_emulator/predicates.c +1 -0
@@ -1346,6 +1346,7 @@ static const struct vex { { { 0x49, 0x00 }, 2, F, R, pfx_no, W0, L0 }, /* ldtilecfg */ { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ + { { 0x49, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tilezero */ { { 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 */
xen/arch/x86/x86_emulate/x86_emulate.c +51 -0
65 lines not on this page · raw message
PATCH v4 12/28 x86/HVM: respect AMX tile dimensions for emulation caching
In reply to Jan BeulichBoth caches may need higher capacity, and the upper bound needs to be determined dynamically based on CPUID policy (for AMX'es TILELOAD / TILESTORE at least). For now we need to use the maximum policy there, until vCPU creation happens after CPUID setup.
---
v4: New.
---
TBD: With hvmemul_cache_init() now becoming CPUID policy dependent, we
could of course take the opportunity and also reduce overhead when AVX512 (and maybe even AVX) is unavailable (in the future: to the guest); AVX10/256 may in particular become of interest here.
xen/arch/x86/hvm/emulate.c +26 -0
@@ -20,6 +20,7 @@#include <xen/xvmalloc.h> #include <asm/altp2m.h> +#include <asm/cpu-policy.h> #include <asm/event.h> #include <asm/i387.h> #include <asm/xstate.h>
@@ -3064,9 +3065,34 @@ int hvmemul_cache_init(struct vcpu *v)*/ unsigned int nents =16 *2 * (CONFIG_PAGING_LEVELS +1 );unsigned int i, max_bytes =64 ; +/* +* NB: Want to use guest policy here, once that gets established ahead +* of vCPU creation. +*/ +const struct cpu_policy *p = &hvm_max_cpu_policy;struct hvmemul_cache *cache;/* +* AMX load/store insns can access up to max_rows independent linear +* addresses, up to bytes_per_row in size. Each such linear range can +* again span a page boundary. +*/ +if ( p->tile.max_palette >=1 ) + { +unsigned int tents = (p->tile.palette1.bytes_per_row / +sizeof (cache->ents->data)) +1 ; + + tents = (tents +2 *CONFIG_PAGING_LEVELS ) * + p->tile.palette1.max_rows; + +if ( tents > nents ) + nents = tents; + +if ( p->tile.palette1.bytes_per_row > max_bytes ) + max_bytes = p->tile.palette1.bytes_per_row; + } + +/* * Account for each insn byte individually, both for simplicity and to * leave some slack space. */
PATCH v4 13/28 x86emul: support TILELOADD{,T1} and TILESTORED
In reply to Jan BeulichIn order to be flexible about future growth of tile dimensions, use a separately allocated scratch buffer to read/write individual rows of a tile.
Note that the separate write_tilecfg() function is needed because LDTILECFG wouldn't serve the purpose: It clears various state, unlike XRSTOR / XRSTORC. To keep things simple, the test harness variant of it leverages the state save/restore around library calls. To be sure the actual data gets restored (and not init state put in place), an extra override for the XSTATE_BV field is introduced.
---
v4: Correct store de-duplication faulting behavior. Reject non-memory
forms of the encodings. Correct invoke_stub() constraint. Use X86_EXC_*. Re-base, in particular also over the earlier CPUID adjustment.
v3: New.
---
TBD: ISA extensions document 043 doesn't clarify either way whether
duplicate stores to the same (linear) memory ranges may get squashed by TILESTORED just like is documented for AVX-512 scatters. Similar behavior was informally confirmed.
tools/include/xen-tools/common-macros.h +7 -0
@@ -76,6 +76,13 @@#define MASK_EXTR (v, m) (((v) & (m)) / ((m) & -(m)))#define MASK_INSR (v, m) (((v) * ((m) & -(m))) & (m)) +/* Base-2 logarithm */ +#define __L2 (x) (((x) & 0x00000002U) ? 1 : 0) +#define __L4 (x) (((x) & 0x0000000cU) ? ( 2 + __L2( (x) >> 2)) : __L2( x)) +#define __L8 (x) (((x) & 0x000000f0U) ? ( 4 + __L4( (x) >> 4)) : __L4( x)) +#define __L16 (x) (((x) & 0x0000ff00U) ? ( 8 + __L8( (x) >> 8)) : __L8( x)) +#define ilog2 (x) (((x) & 0xffff0000U) ? (16 + __L16((x) >> 16)) : __L16(x)) +#ifndef __must_check#define __must_check __attribute__((__warn_unused_result__))#endif
tools/tests/x86_emulator/predicates.c +3 -0
@@ -1347,6 +1347,9 @@ static const struct vex { { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ { { 0x49, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tilezero */ + { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ + { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ + { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */ { { 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 */
tools/tests/x86_emulator/x86-emulate.c +37 -0
@@ -8,6 +8,8 @@ struct cpu_policy cpu_policy; static char fpu_save_area[0x4000] __attribute__((__aligned__((64))));static bool use_xsave; +/* This will be OR-ed into xstate_bv prior to restoring state. */ +static uint64_t xstate_bv_or_mask;/* * Re-use the area above also as scratch space for the emulator itself.
@@ -33,13 +35,19 @@ void emul_restore_fpu_state(void) {/* Older gcc can't deal with "m" array inputs; make them outputs instead. */ if ( use_xsave ) + { + *(uint64_t *)&fpu_save_area[0x200 ] |= xstate_bv_or_mask; + xstate_bv_or_mask =0 ; asmvolatile ("xrstor %[ptr]" : [ptr]"+m" (fpu_save_area) :"a" (~0ul ),"d" (~0ul ) ); + }else asmvolatile ("fxrstor %0" :"+m" (fpu_save_area) ); } +static void *tile_row; +bool emul_test_init (void ) {union {
@@ -101,6 +109,17 @@ bool emul_test_init(void)if ( fxs->mxcsr_mask ) mxcsr_mask = fxs->mxcsr_mask; +if ( cpu_policy.tile.max_palette >=1 ) + { +unsigned int max_bytes = cpu_policy.tile.palette1.bytes_per_row; + +if ( !cpu_policy.xstate.comp[ilog2 (X86_XCR0_TILE_CFG )].offset ) + max_bytes =0 ; + +if ( !max_bytes || !(tile_row =malloc (max_bytes)) ) + cpu_policy.feat.amx_tile = false; + } +/* * Mark the entire stack executable so that the stub executions * don't fault
@@ -255,4 +274,22 @@ void wrpkru(unsigned int val) pkru = val; } +static void *get_tile_row_buf (void ) +{ +return tile_row; +} + +static void write_tilecfg (const struct x86_tilecfg *tilecfg) +{ +/* +* Leverage the fact that the wrapper (saves and) restores all extended +* state around the actual library call. Invoke the wrapper explicitly to +* make sure the compiler won't inline the call. +*/ + xstate_bv_or_mask =X86_XCR0_TILE_CFG ; +__wrap_memcpy ((fpu_save_area + + cpu_policy.xstate.comp[ilog2 (X86_XCR0_TILE_CFG )].offset), + tilecfg,sizeof (*tilecfg)); +} +#include "x86_emulate/x86_emulate.c"
xen/arch/x86/include/asm/cpufeature.h +1 -0
@@ -208,6 +208,7 @@ static inline bool boot_cpu_has(unsigned#define cpu_has_rtm_always_abort boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)#define cpu_has_tsx_force_abort boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)#define cpu_has_hybrid boot_cpu_has(X86_FEATURE_HYBRID) +#define cpu_has_amx_tile boot_cpu_has(X86_FEATURE_AMX_TILE)#define cpu_has_arch_caps boot_cpu_has(X86_FEATURE_ARCH_CAPS)/* CPUID level 0x00000007:1.eax */
xen/arch/x86/include/asm/xstate.h +2 -0
@@ -94,6 +94,8 @@ uint64_t get_xcr0(void);void set_msr_xss (u64 xss);uint64_t get_msr_xss (void );uint64_t read_bndcfgu (void ); +struct x86_tilecfg ; +void write_tilecfg (const struct x86_tilecfg *tilecfg);void xsave (struct vcpu *v,uint64_t mask);void xrstor (struct vcpu *v,uint64_t mask);void xstate_set_init (uint64_t mask);
xen/arch/x86/x86_emulate/decode.c +2 -0
@@ -364,6 +364,7 @@ static const struct ext0f38_table { [0x44] = { .simd_size = simd_packed_int, .two_op = 1, .d8s = d8s_vl }, [0x45 ... 0x47] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x49] = { .simd_size = simd_other, .two_op = 1 }, + [0x4b] = { .simd_size = simd_other, .two_op = 1, .vsib = 1 }, [0x4c] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x4d] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x4e] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl },
@@ -1268,6 +1269,7 @@ decode_0f38(struct x86_emulate_state *s,break ;case X86EMUL_OPC_VEX_66 (0 ,0x49 ):/* sttilecfg */ +case X86EMUL_OPC_VEX_F3 (0 ,0x4b ):/* tilestored */ s->desc = DstMem | SrcImplicit | Mov;break ;
xen/arch/x86/x86_emulate/x86_emulate.c +184 -0
196 lines not on this page · raw message
xen/arch/x86/xstate.c +32 -0
@@ -16,6 +16,7 @@#include <asm/i387.h> #include <asm/msr.h> #include <asm/processor.h> +#include <asm/x86-types.h> #include <asm/xstate.h> /*
@@ -1082,6 +1083,37 @@ uint64_t read_bndcfgu(void)return xstate->xsave_hdr.xstate_bv &X86_XCR0_BNDCSR ? bndcsr->bndcfgu :0 ; } +void write_tilecfg (const struct x86_tilecfg *tilecfg) +{ +unsigned long cr0 =read_cr0 (); +struct xsave_struct *xstate + = idle_vcpu[smp_processor_id ()]->arch.xsave_area; + +ASSERT (cpu_has_amx_tile); +clts (); + +memset (&xstate->xsave_hdr,0 ,sizeof (xstate->xsave_hdr)); + xstate->xsave_hdr.xstate_bv =X86_XCR0_TILE_CFG ; + +if ( cpu_has_xsavec ) + { + xstate->xsave_hdr.xcomp_bv =XSTATE_COMPACTION_ENABLED | +X86_XCR0_TILE_CFG ; + +memcpy (xstate +1 , tilecfg,sizeof (*tilecfg)); + } +else +memcpy ((void *)xstate +xstate_offset (ilog2 (X86_XCR0_TILE_CFG )), + tilecfg,sizeof (*tilecfg)); + + asmvolatile (".byte 0x0f,0xae,0x2f\n" /* xrstor */ + ::"m" (*xstate),"D" (xstate), +"a" (X86_XCR0_TILE_CFG ),"d" (0 ) ); + +if ( cr0 &X86_CR0_TS ) +write_cr0 (cr0); +} +void xstate_set_init (uint64_t mask) {unsigned long cr0 =read_cr0 ();
PATCH v4 14/28 x86emul: support tile multiplication insns
In reply to Jan BeulichSince these don't allow for memory operands, the main thing to do here is to check the large set of #UD conditions.
---
v4: AMX-FP16 and AMX-COMPLEX. Comment out yet another redundant #UD
check. Drop (wrong) use of "unimplemented_insn". Use X86_EXC_*. Re-base.
v3: New.
tools/tests/x86_emulator/predicates.c +8 -0
@@ -1363,6 +1363,14 @@ static const struct vex { { { 0x58 }, 2, T, R, pfx_66, W0, Ln }, /* vpbroadcastd */ { { 0x59 }, 2, T, R, pfx_66, W0, Ln }, /* vpbroadcastq */ { { 0x5a }, 2, F, R, pfx_66, W0, L1 }, /* vbroadcasti128 */ + { { 0x5c, 0xc0 }, 2, F, N, pfx_f3, W0, L0 }, /* tdpbf16ps */ + { { 0x5c, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tdpfp16ps */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tdpbuud */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_66, W0, L0 }, /* tdpbusd */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_f3, W0, L0 }, /* tdpbsud */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tdpbssd */ + { { 0x6c, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tcmmrlfp16ps */ + { { 0x6c, 0xc0 }, 2, F, N, pfx_66, W0, L0 }, /* tcmmimfp16ps */ { { 0x72 }, 2, T, R, pfx_f3, W0, Ln }, /* vcvtneps2bf16 */ { { 0x78 }, 2, T, R, pfx_66, W0, Ln }, /* vpbroadcastb */ { { 0x79 }, 2, T, R, pfx_66, W0, Ln }, /* vpbroadcastw */
xen/arch/x86/x86_emulate/decode.c +3 -0
@@ -377,11 +377,14 @@ static const struct ext0f38_table { [0x59] = { .simd_size = simd_other, .two_op = 1, .d8s = 3 }, [0x5a] = { .simd_size = simd_128, .two_op = 1, .d8s = 4 }, [0x5b] = { .simd_size = simd_256, .two_op = 1, .d8s = d8s_vl_by_2 }, + [0x5c] = { .simd_size = simd_other }, + [0x5e] = { .simd_size = simd_other }, [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 }, + [0x6c] = { .simd_size = simd_other }, [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 },
xen/arch/x86/x86_emulate/private.h +4 -0
@@ -606,7 +606,9 @@ 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_amx_bf16 () (ctxt->cpuid->feat.amx_bf16)#define vcpu_has_amx_tile () (ctxt->cpuid->feat.amx_tile) +#define vcpu_has_amx_int8 () (ctxt->cpuid->feat.amx_int8)#define vcpu_has_sha512 () (ctxt->cpuid->feat.sha512)#define vcpu_has_sm3 () (ctxt->cpuid->feat.sm3)#define vcpu_has_sm4 () (ctxt->cpuid->feat.sm4)
@@ -614,12 +616,14 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_cmpccxadd () (ctxt->cpuid->feat.cmpccxadd)#define vcpu_has_lkgs () (ctxt->cpuid->feat.lkgs)#define vcpu_has_wrmsrns () (ctxt->cpuid->feat.wrmsrns) +#define vcpu_has_amx_fp16 () (ctxt->cpuid->feat.amx_fp16)#define vcpu_has_avx_ifma () (ctxt->cpuid->feat.avx_ifma)#define vcpu_has_msrlist () (ctxt->cpuid->feat.msrlist)#define vcpu_has_movrs () (ctxt->cpuid->feat.movrs)#define vcpu_has_msr_imm () (ctxt->cpuid->feat.msr_imm)#define vcpu_has_avx_vnni_int8 () (ctxt->cpuid->feat.avx_vnni_int8)#define vcpu_has_avx_ne_convert () (ctxt->cpuid->feat.avx_ne_convert) +#define vcpu_has_amx_complex () (ctxt->cpuid->feat.amx_complex)#define vcpu_has_avx_vnni_int16 () (ctxt->cpuid->feat.avx_vnni_int16)#define vcpu_has_user_msr () (ctxt->cpuid->feat.user_msr)
xen/arch/x86/x86_emulate/x86_emulate.c +65 -0
71 lines not on this page · raw message
PATCH v4 15/28 x86emul: test AMX insns
In reply to Jan BeulichCarry out some basic matrix operations on 2x2, 3x3, and 4x4 matrixes.
To include a use of a non-square matrix, also transpose ones of said square formats via linearization and multiplication by the respective transposition permutation matrix. To generate the latter, introduce a small helper tool. This is mainly to avoid creating / populating a rather large matrix (up to 16x16) in a stack variable.
While integer base types as well as bfloat16 overlaying their corresponding wider result types can be dealt with by choosing an appropriate data layout (elem_t), fp16 needs some special precautions (including skipping of the transpose test).
Note that at least on Linux using insns requiring the TILEDATA component to be enabled requires OS-level enabling. Since this makes it desirable to include unistd.h (in order to avoid manually declaring syscall()), the read() and write() hook functions need renaming.
---
RFC: Something will need doing for the fuzzer as well wrt the OS-level
enabling requirement (and perhaps already in an earlier patch, i.e. as soon as the first TILEDATA-dependent insn is added). With XCR0 having the TILEDATA bit set already ahead of that enabling (in turn required by the spec, i.e. needing to have the same value as the TILECFG bit), the core emulator's use of get_fpu(X86EMUL_FPU_tile) isn't sufficient in that case. Yet I don't see us add Linux- specific code there. Doing the setup in emul_test_init() would be an option, albeit that would be much earlier than needed for the purposes here.
RFC: For now an assumption in amx_check_tile() is that on OSes other
than Linux no special OS-level enabling is necessary. Tests will simply fail wherever that assumption is wrong.
---
v4: AMX-FP16. Drop mistakenly leftover "set -x". Handle MSR_XFD in
read_msr(). Introduce amx_check_tile(). Clean generated test harness files. Re-base.
v3: New.
---
SDE: -spr or (incl FP16) -gnr
tools/tests/x86_emulator/Makefile +39 -1
@@ -30,6 +30,12 @@ SHA := sse4-sha avx-sha avx512f-sha GF := sse2-gf avx2-gf avx512bw-gf TESTCASES := blowfish $(SIMD) $(FMA) $(SG) $(AES) $(CLMUL) $(SHA) $(GF) +MATRIX := amx-bf16 amx-int8 amx-fp16 + +ifeq ($(XEN_COMPILE_ARCH),x86_64) +TESTCASES += $(MATRIX) +endif + OPMASK := avx512f avx512dq avx512bw ifeq ($(origin XEN_COMPILE_ARCH),override)
@@ -98,6 +104,16 @@ avx512f-opmask-vecs := 2 avx512dq-opmask-vecs := 1 2 avx512bw-opmask-vecs := 4 8 +amx-bf16-dims := 2 3 4 +amx-bf16-ints := +amx-bf16-flts := -2 +amx-int8-dims := 2 3 4 +amx-int8-ints := 1 +amx-int8-flts := +amx-fp16-dims := 2 3 4 +amx-fp16-ints := +amx-fp16-flts := 2 + # Suppress building by default of the harness if the compiler can't deal # with some of the extensions used. Don't alter the "run" target dependencies # though, as this target needs to be specified manually, and things may work
@@ -175,6 +191,18 @@ define opmask-defs $(1)-opmask-cflags := $(foreach vec,$($(1)-opmask-vecs), "-D_$(vec) -m$(1) -DSIZE=$(vec)") $(1)-opmask-cflags-x86_64 := $(foreach vec,$($(1)-opmask-vecs), "-D_$(vec) -mapxf -m$(1) -DSIZE=$(vec)") endef +amx-cflags-common = $(CFLAGS_xeninclude) -Os -DN=$(1) -DTPM_H=tpm-$(1)x$(1).h +define matrix-defs +$(1).h: $(foreach dim,$($(1)-dims),tpm-$(dim)x$(dim).h) +$(1)-cflags := +$(1)-cflags-x86_64 := \ + $(foreach dim,$($(1)-dims), \ + $(foreach flt,$($(1)-flts), \ + "-D_$(dim)x$(dim) -DFLOAT_SIZE=$(flt) $(call amx-cflags-common,$(dim))") \ + $(foreach int,$($(1)-ints), \ + "-Ds_$(dim)x$(dim) -DINT_SIZE=$(int) $(call amx-cflags-common,$(dim))" \ + "-Du_$(dim)x$(dim) -DUINT_SIZE=$(int) $(call amx-cflags-common,$(dim))")) +endef $(foreach flavor,$(SIMD) $(FMA),$(eval $(call simd-defs,$(flavor)))) $(foreach flavor,$(SG),$(eval $(call simd-sg-defs,$(flavor))))
@@ -183,6 +211,7 @@ $(foreach flavor,$(CLMUL),$(eval $(call $(foreach flavor,$(SHA),$(eval $(call simd-sha-defs,$(flavor)))) $(foreach flavor,$(GF),$(eval $(call simd-gf-defs,$(flavor)))) $(foreach flavor,$(OPMASK),$(eval $(call opmask-defs,$(flavor)))) +$(foreach flavor,$(MATRIX),$(eval $(call matrix-defs,$(flavor)))) first-string = $(shell for s in $(1); do echo "$$s"; break; done)
@@ -256,6 +285,9 @@ $(addsuffix .h,$(SIMD) $(FMA) $(SG) $(AE xop.h avx512f.h avx512fp16.h: simd-fma.c +$(addsuffix .c,$(MATRIX)): + ln -sf matrix.c $@ + endif # 32-bit override OBJS := x86-emulate.o cpuid.o test_x86_emulator.o evex-disp8.o predicates.o wrappers.o
@@ -270,7 +302,7 @@ $(TARGET): $(OBJS) .PHONY: clean clean: - rm -rf $(TARGET) *.o *~ core *.bin blowfish.s x86_emulate + rm -rf $(TARGET) *.o *~ core *.bin blowfish.s mktpm tpm-*.h x86_emulate rm -rf $(addsuffix .h,$(TESTCASES)) $(addsuffix -opmask.h,$(OPMASK)) rm -rf $(addsuffix .c,$(filter-out blowfish,$(TESTCASES)))
@@ -324,6 +356,12 @@ $(filter x86_emulate/%.o,$(OBJS)): x86_e x86-emulate.o: x86_emulate/x86_emulate.c x86-emulate.o x86_emulate/%.o: HOSTCFLAGS += -D__XEN_TOOLS__ +tpm-%.h: mktpm Makefile + ./$< $(subst x,$(space),$*) >$@ + +mktpm: mktpm.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ $< + # In order for our custom .type assembler directives to reliably land after # gcc's, we need to keep it from re-ordering top-level constructs. $(call cc-option-add,HOSTCFLAGS-toplevel,HOSTCC,-fno-toplevel-reorder)
tools/tests/x86_emulator/matrix.c new file +252 -0
252 lines not on this page · raw message
tools/tests/x86_emulator/mktpm.c new file +41 -0
41 lines not on this page · raw message
tools/tests/x86_emulator/test_x86_emulator.c +109 -4
157 lines not on this page · raw message
PATCH v4 16/28 x86emul: support APX forms of {LD,ST}TILECFG
In reply to Jan BeulichBesides adding table entries and case labels, re-existing handling can be re-used. The only special aspect once again is dealing with the 512-bit memory operands in EVEX Disp8 testing.
---
v4: New.
tools/tests/x86_emulator/evex-disp8.c +14 -0
@@ -1192,6 +1192,12 @@ static const struct test popcnt[] = { INSN(popcntw, 66, map4, 88, el, w, no), }; +static const struct test amx_tile[] = { +/* Element size is set arbitrarily here. See test_one(). */ + INSN(ldtilecfg, , 0f38, 49, el, b, no), + INSN(sttilecfg, 66, 0f38, 49, el, b, no), +}; +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 };
@@ -1452,6 +1458,13 @@ static void test_one(const struct test * { asmvolatile ("kxnorw %k1, %k1, %k1" ); asmvolatile ("vxorps %xmm4, %xmm4, %xmm4" ); + +/* +* {LD,ST}TILECFG's operand size of 512 bits doesn't match up with +* EVEX.L'L being 0. +*/ +if ( test->spc == SPC_0f38 && test->opc ==0x49 ) + vsz =64 ; } else {
@@ -1796,6 +1809,7 @@ void evex_disp8_test(void *instr, struct }while ( false )RUN (adx); +RUN (amx_tile);RUN (avx512f);RUN (avx512dq);RUN (avx512bw);
tools/tests/x86_emulator/predicates.c +2 -0
@@ -1937,6 +1937,8 @@ static const struct evex { { { 0x45 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsrlv{d,q} */ { { 0x46 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsrav{d,q} */ { { 0x47 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsllv{d,q} */ + { { 0x49, 0x00 }, 2, F, R, pfx_no, W0, L0 }, /* ldtilecfg */ + { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x4c }, 2, T, R, pfx_66, Wn, Ln }, /* vrcp14p{s,d} */ { { 0x4d }, 2, T, R, pfx_66, Wn, LIG }, /* vrcp14s{s,d} */ { { 0x4e }, 2, T, R, pfx_66, Wn, Ln }, /* vrsqrt14p{s,d} */
tools/tests/x86_emulator/test_x86_emulator.c +39 -0
@@ -6218,6 +6218,45 @@ int main(int argc, char **argv)else printf ("skipped\n" ); +if ( stack_exec && cpu_has_amx_tile && cpu_has_apx_f ) + { +static const struct x86_tilecfg tilecfg_apx = { + .palette =1 , + .colsb = {2 ,3 ,4 ,5 }, + .rows = {5 ,4 ,3 ,2 }, + }; +decl_insn (ldtilecfg_apx); +decl_insn (sttilecfg_apx); + +printf ("%-40s" ,"Testing ldtilecfg (%r26)..." ); + + asm volatile ( put_insn(ldtilecfg_apx, +/* ldtilecfg (%%r26) */ + ".byte 0x62, 0xda, 0x7c, 0x08, 0x49, 0x02") ); + +set_insn (ldtilecfg_apx); +load_egpr (26 , (unsigned long )&tilecfg_apx); + rc =x86_emulate (&ctxt, &emulops); +if ( rc !=X86EMUL_OKAY || !check_eip (ldtilecfg_apx) ) + goto fail; +printf ("pending\n" ); + +printf ("%-40s" ,"Testing sttilecfg -4(%r25)..." ); + + asm volatile ( put_insn(sttilecfg_apx, +/* sttilecfg -4(%%r25) */ + ".byte 0x62, 0xda, 0x7d, 0x08, 0x49, 0x41, 0xfc") ); + +memset (res, ~0 ,72 ); +set_insn (sttilecfg_apx); +load_egpr (25 , (unsigned long )(res +2 )); + rc =x86_emulate (&ctxt, &emulops); +if ( rc !=X86EMUL_OKAY || !check_eip (sttilecfg_apx) || + ~res[0 ] || ~res[17 ] ||memcmp (res +1 , &tilecfg_apx,64 ) ) + goto fail; +printf ("okay\n" ); + } +printf ("%-40s" ,"Testing vzeroupper (compat)..." );if ( cpu_has_avx ) {
xen/arch/x86/x86_emulate/decode.c +4 -0
@@ -1271,6 +1271,9 @@ decode_0f38(struct x86_emulate_state *s, s->simd_size = simd_packed_fp;break ; +case X86EMUL_OPC_EVEX_66 (0 ,0x49 ):/* sttilecfg */ + s->promoted_evex = true; + fallthrough;case X86EMUL_OPC_VEX_66 (0 ,0x49 ):/* sttilecfg */ case X86EMUL_OPC_VEX_F3 (0 ,0x4b ):/* tilestored */ s->desc = DstMem | SrcImplicit | Mov;
@@ -1308,6 +1311,7 @@ decode_0f38(struct x86_emulate_state *s,case X86EMUL_OPC_VEX_F2 (0 ,0xf7 ):/* shrx */ break ; +case X86EMUL_OPC_EVEX (0 ,0x49 ):/* ldtilecfg */ case X86EMUL_OPC_EVEX_66(0, 0xe0) ...X86EMUL_OPC_EVEX_66 (0 ,0xef ):/* cmp<cc>xadd */ case X86EMUL_OPC_EVEX (0 ,0xf2 ):/* andn */
xen/arch/x86/x86_emulate/x86_emulate.c +9 -0
@@ -6650,10 +6650,16 @@ x86_emulate(generate_exception_if (vex.l,X86_EXC_UD ); goto simd_0f_avx; +case X86EMUL_OPC_EVEX (0x0f38 ,0x49 ): +generate_exception_if (evex.lr || evex.brs || evex.opmsk,X86_EXC_UD ); + fallthrough;case X86EMUL_OPC_VEX (0x0f38 ,0x49 ):generate_exception_if (!mode_64bit () || vex.l || vex.w,X86_EXC_UD );if ( ea.type ==OP_REG ) { +if (evex_encoded () ) + goto unrecognized_insn; +switch ( modrm ) {case 0xc0 :/* tilerelease */
@@ -6725,6 +6731,9 @@ x86_emulate( } goto unrecognized_insn; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x49 ): +generate_exception_if (evex.lr || evex.brs || evex.opmsk,X86_EXC_UD ); + fallthrough;case X86EMUL_OPC_VEX_66 (0x0f38 ,0x49 ):generate_exception_if (!mode_64bit () || vex.l || vex.w,X86_EXC_UD );if ( ea.type ==OP_REG )
PATCH v4 17/28 x86emul: support APX forms of TILE{LOADD{,T1},STORED}
In reply to Jan BeulichWhile, like elsewhere, pre-existing code can largely be re-used, EVEX Disp8 testing requires some special care: .
Note that the calculation of ->sib_index can be left as is, as long as all SIBMEM insns don't use EVEX.vvvv (and hence EVEX.V4 is required to be set).
---
TBD: How to reasonably test AMX+APX isn't entirely clear yet. Simply
re-compiling matrix.c with -mapfx is unlikely to produce good uses of eGPR-s. Yet fiddling with intermediate assembly isn't quite nice either, and even then there's no guarantee that we'd end up with any useful uses of eGPR-s.
---
v4: New.
tools/tests/x86_emulator/evex-disp8.c +30 -2
@@ -1196,6 +1196,10 @@ static const struct test amx_tile[] = {/* Element size is set arbitrarily here. See test_one(). */ INSN(ldtilecfg, , 0f38, 49, el, b, no), INSN(sttilecfg, 66, 0f38, 49, el, b, no), +/* Element size assumes a 1x1 matrix here. See test_one(). */ + INSN(tileloadd, f2, 0f38, 4b, el, d, no), + INSN(tileloaddt1, 66, 0f38, 4b, el, d, no), + INSN(tilestored, f3, 0f38, 4b, el, d, no), };static const unsigned char vl_all[] = {VL_512 ,VL_128 ,VL_256 };
@@ -1316,6 +1320,7 @@ static void test_one(const struct test *int rc;bool sg =strstr (test->mnemonic,"gather" ) ||strstr (test->mnemonic,"scatter" ); +bool tile = false;unsigned int imm = test->spc == SPC_0f3a || (test->spc == SPC_0f && (imm0f[test->opc >>4 ] & (1 << (test->opc &0xf ))));
@@ -1437,8 +1442,8 @@ static void test_one(const struct test * }/* -* Note: SIB addressing is used here, such that S/G insns can be handled -* without extra conditionals. +* Note: SIB addressing is used here, such that S/G and SIBMEM insns can +* be handled without extra conditionals. */ instr[0 ] =0x62 ; again:
@@ -1465,6 +1470,24 @@ static void test_one(const struct test **/ if ( test->spc == SPC_0f38 && test->opc ==0x49 ) vsz =64 ; + +/* +* Tile loads/stores require a valid tile configuration. Set up a 1x1 +* tile for %tmm0. +*/ +if ( test->spc == SPC_0f38 && test->opc ==0x4b ) + { +static const struct x86_tilecfg tilecfg = { + .palette =1 , + .colsb[0 ] =4 , + .rows[0 ] =1 , + }; + +/* ldtilecfg (%rax) */ + asmvolatile (".byte 0xc4, 0xe2, 0x78, 0x49, 0x00" + ::"a" (&tilecfg),"m" (tilecfg) ); + tile = true; + } }else {
@@ -1554,7 +1577,12 @@ static void test_one(const struct test **/ if ( test->spc != SPC_map4 || (test->opc |0xf ) !=0x4f || test->pfx >PFX_66 || (evex.bcst && evex.opmsk) ) + { +/* Issue TILERELEASE if we fiddled with tiles. */ +if ( tile ) + asmvolatile (".byte 0xc4, 0xe2, 0x78, 0x49, 0xc0" );return ; + } evex.bcst = !evex.bcst;if ( !evex.bcst )
tools/tests/x86_emulator/predicates.c +3 -0
@@ -1939,6 +1939,9 @@ static const struct evex { { { 0x47 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsllv{d,q} */ { { 0x49, 0x00 }, 2, F, R, pfx_no, W0, L0 }, /* ldtilecfg */ { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ + { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ + { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ + { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */ { { 0x4c }, 2, T, R, pfx_66, Wn, Ln }, /* vrcp14p{s,d} */ { { 0x4d }, 2, T, R, pfx_66, Wn, LIG }, /* vrcp14s{s,d} */ { { 0x4e }, 2, T, R, pfx_66, Wn, Ln }, /* vrsqrt14p{s,d} */
xen/arch/x86/x86_emulate/decode.c +3 -0
@@ -1272,6 +1272,7 @@ decode_0f38(struct x86_emulate_state *s,break ;case X86EMUL_OPC_EVEX_66 (0 ,0x49 ):/* sttilecfg */ +case X86EMUL_OPC_EVEX_F3 (0 ,0x4b ):/* tilestored */ s->promoted_evex = true; fallthrough;case X86EMUL_OPC_VEX_66 (0 ,0x49 ):/* sttilecfg */
@@ -1312,6 +1313,8 @@ decode_0f38(struct x86_emulate_state *s,break ;case X86EMUL_OPC_EVEX (0 ,0x49 ):/* ldtilecfg */ +case X86EMUL_OPC_EVEX_66 (0 ,0x4b ):/* tileloaddt1 */ +case X86EMUL_OPC_EVEX_F2 (0 ,0x4b ):/* tileloadd */ case X86EMUL_OPC_EVEX_66(0, 0xe0) ...X86EMUL_OPC_EVEX_66 (0 ,0xef ):/* cmp<cc>xadd */ case X86EMUL_OPC_EVEX (0 ,0xf2 ):/* andn */
xen/arch/x86/x86_emulate/x86_emulate.c +8 -2
@@ -6771,6 +6771,12 @@ x86_emulate( } goto unrecognized_insn; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x4b ):/* tileloaddt1 mem,tmm */ +case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0x4b ):/* tilestored tmm,mem */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x4b ):/* tileloadd mem,tmm */ +generate_exception_if (evex.lr || evex.brs || evex.opmsk || !evex.RX, +X86_EXC_UD ); + fallthrough;case X86EMUL_OPC_VEX_66 (0x0f38 ,0x4b ):/* tileloaddt1 mem,tmm */ case X86EMUL_OPC_VEX_F3 (0x0f38 ,0x4b ):/* tilestored tmm,mem */ case X86EMUL_OPC_VEX_F2 (0x0f38 ,0x4b ):/* tileloadd mem,tmm */
@@ -6795,7 +6801,7 @@ x86_emulate(/* Calculate stride. */ if ( state->sib_index !=4 ) - ea.val =truncate_ea (*decode_gpr (ctxt->regs,NULL , + ea.val =truncate_ea (*decode_gpr (ctxt->regs, &state->egpr, state->sib_index) << state->sib_scale);
@@ -6847,7 +6853,7 @@ x86_emulate( opc[1 ] = modrm &0x3f ; opc[2 ] =0x20 ;place_ret (&opc[3 ]); -copy_VEX (opc, vex, false); +copy_VEX (opc, vex, state->promoted_evex); do { if ( row >= n )
PATCH v4 18/28 x86: permit guests to use AMX and XFD
In reply to Jan BeulichThese features are marked experimental (for only limited testing having been done so far) and opt-in for guests.
---
v4: AMX-FP16 and AMX-COMPLEX. Re-base.
v3: New.
CHANGELOG.md +1 -0
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog - Support for AVX10.2. (Experimental) - Support for AVX10-V2-AUX. (Experimental) - Support for APX. (Experimental) + - Support for AMX and XFD. (Experimental) ### Removed - On Arm:
SUPPORT.md +4 -0
@@ -91,6 +91,10 @@ For the Cortex A77 r0p0 - r1p0, see Erra Status: Experimental +### x86 AMX and XFD + + Status: Experimental + ### IOMMU Status, AMD IOMMU: Supported
xen/include/public/arch-x86/cpufeatureset.h +6 -6
@@ -182,7 +182,7 @@ XEN_CPUFEATURE(XSAVEOPT, 4*32+ 0) / XEN_CPUFEATURE(XSAVEC, 4*32+ 1) /*A XSAVEC/XRSTORC instructions */ XEN_CPUFEATURE(XGETBV1, 4*32+ 2) /*A XGETBV with %ecx=1 */ XEN_CPUFEATURE(XSAVES, 4*32+ 3) /*S XSAVES/XRSTORS instructions */ -XEN_CPUFEATURE (XFD ,4 *32 +4 )/* MSR_XFD{,_ERR} (eXtended Feature Disable) */ +XEN_CPUFEATURE (XFD ,4 *32 +4 )/*a MSR_XFD{,_ERR} (eXtended Feature Disable) */ /* Intel-defined CPU features, CPUID level 0x00000007:0.ebx, word 5 */XEN_CPUFEATURE (FSGSBASE ,5 *32 +0 )/*A {RD,WR}{FS,GS}BASE instructions */
@@ -287,10 +287,10 @@ XEN_CPUFEATURE(TSXLDTRK, 9*32+16) / XEN_CPUFEATURE(PCONFIG, 9*32+18) /* PCONFIG instruction */ XEN_CPUFEATURE(ARCH_LBR, 9*32+19) /* Architectural Last Branch Record */ XEN_CPUFEATURE(CET_IBT, 9*32+20) /* CET - Indirect Branch Tracking */ -XEN_CPUFEATURE(AMX_BF16, 9*32+22) /* AMX BFloat16 instruction */ +XEN_CPUFEATURE(AMX_BF16, 9*32+22) /*a AMX BFloat16 instruction */ XEN_CPUFEATURE(AVX512_FP16, 9*32+23) /*A AVX512 FP16 instructions */ -XEN_CPUFEATURE(AMX_TILE, 9*32+24) /* AMX Tile architecture */ -XEN_CPUFEATURE(AMX_INT8, 9*32+25) /* AMX 8-bit integer instructions */ +XEN_CPUFEATURE(AMX_TILE, 9*32+24) /*a AMX Tile architecture */ +XEN_CPUFEATURE(AMX_INT8, 9*32+25) /*a AMX 8-bit integer instructions */ XEN_CPUFEATURE(IBRSB, 9*32+26) /*A IBRS and IBPB support (used by Intel) */ XEN_CPUFEATURE(STIBP, 9*32+27) /*A STIBP */XEN_CPUFEATURE (L1D_FLUSH ,9 *32 +28 )/*S MSR_FLUSH_CMD and L1D flush. */
@@ -314,7 +314,7 @@ XEN_CPUFEATURE(FRED, 10*32+17) / XEN_CPUFEATURE(LKGS, 10*32+18) /* Load Kernel GS instruction */ XEN_CPUFEATURE(WRMSRNS, 10*32+19) /*S WRMSR Non-Serialising */ XEN_CPUFEATURE(NMI_SRC, 10*32+20) /* NMI-Source Reporting */ -XEN_CPUFEATURE(AMX_FP16, 10*32+21) /* AMX FP16 instruction */ +XEN_CPUFEATURE(AMX_FP16, 10*32+21) /*a AMX FP16 instruction */ XEN_CPUFEATURE(AVX_IFMA, 10*32+23) /*A AVX-IFMA Instructions */ XEN_CPUFEATURE(LAM, 10*32+26) /* Linear Address Masking */XEN_CPUFEATURE (MSRLIST ,10 *32 +27 )/*s {RD,WR}MSRLIST instructions */
@@ -359,7 +359,7 @@ XEN_CPUFEATURE(MSR_IMM, 14*32/* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */ XEN_CPUFEATURE(AVX_VNNI_INT8, 15*32+ 4) /*A AVX-VNNI-INT8 Instructions */ XEN_CPUFEATURE(AVX_NE_CONVERT, 15*32+ 5) /*A AVX-NE-CONVERT Instructions */ -XEN_CPUFEATURE(AMX_COMPLEX, 15*32+ 8) /* AMX Complex Instructions */ +XEN_CPUFEATURE(AMX_COMPLEX, 15*32+ 8) /*a AMX Complex Instructions */ XEN_CPUFEATURE(AVX_VNNI_INT16, 15*32+10) /*A AVX-VNNI-INT16 Instructions */ XEN_CPUFEATURE(UTMR, 15*32+13) /* User Timer */XEN_CPUFEATURE (PREFETCHI ,15 *32 +14 )/*A PREFETCHIT{0,1} Instructions */
PATCH v4 19/28 x86/CPUID: TMUL subleaf 1
In reply to Jan BeulichEAX holds yet another set of feature bits. Sadly some duplicate pre- existing bits in the feature subleaves.
Note that the dependency on just AVX512F (and not AVX10) is sufficient, as long as we synthesize AVX512* when we find AVX10 available.
---
RFC: The handling of the duplicated bits is minimal so far. Where / how
the syncing between both instances should happen is tbd. The naming of the duplicate bits is also subject to better suggestions.
---
v4: New.
tools/libs/light/libxl_cpuid.c +1 -0
@@ -345,6 +345,7 @@ int libxl_cpuid_parse_config(libxl_cpuidCPUID_ENTRY (0x80000021 ,NA ,CPUID_REG_ECX ),CPUID_ENTRY (0x00000024 ,1 ,CPUID_REG_ECX ),CPUID_ENTRY (0x00000029 ,0 ,CPUID_REG_EBX ), +CPUID_ENTRY (0x0000001e ,1 ,CPUID_REG_EAX ), #undef MSR_ENTRY#undef CPUID_ENTRY };
tools/misc/xen-cpuid.c +1 -0
@@ -40,6 +40,7 @@ static const struct { { "CPUID 0x80000021.ecx", "e21c" }, { "CPUID 0x00000024:1.ecx", "24c1" }, { "CPUID 0x00000029:0.ebx", "29b0" }, + { "CPUID 0x0000001e:1.eax", "1Ea1" }, };#define COL_ALIGN "24"
tools/tests/cpu-policy/test-cpu-policy.c +3 -2
@@ -218,7 +218,7 @@ static void test_cpuid_serialise_success .nr_leaves = 4 + 0x1d + 1 + 1, }, -/* Leaf 0x1e serialisation stops at 0. */ +/* Leaf 0x1e serialisation stops at max_subleaf. */ { .name = "empty leaf 0x1e", .p = {
@@ -230,9 +230,10 @@ static void test_cpuid_serialise_success .name = "partial leaf 0x1e", .p = { .basic.max_leaf = 0x1e, + .tmul.max_subleaf = 1, .tmul.maxk = 16, }, - .nr_leaves = 4 + 0x1e + 1, + .nr_leaves = 4 + 0x1e + 1 + 1, }, };
xen/arch/x86/cpu/common.c +10 -0
@@ -594,6 +594,16 @@ void identify_cpu(struct cpuinfo_x86 *c) &c->x86_capability[FEATURESET_Da1], &tmp, &tmp, &tmp); +if (cpu_has (c,X86_FEATURE_AMX_TILE ) && c->cpuid_level >=0x1e ) { +uint32_t max_subleaf; + +cpuid_count (0x1e ,0 , &max_subleaf, &tmp, &tmp, &tmp); +if (max_subleaf >=1 ) +cpuid_count (0x1e ,1 , + &c->x86_capability[FEATURESET_1Ea1], + &tmp, &tmp, &tmp); + } +if (cpu_has (c,X86_FEATURE_AVX10 ) && c->cpuid_level >=0x24 ) {uint32_t max_subleaf;
xen/arch/x86/cpu-policy.c +4 -0
@@ -282,6 +282,10 @@ static void recalculate_tile(struct cpu_ p->tmul.raw[0 ].b &=0x00ffffff ; p->tmul.raw[0 ].c =0 , p->tmul.raw[0 ].d =0 ; + + p->tmul.raw[1 ].b =0 ; + p->tmul.raw[1 ].c =0 ; + p->tmul.raw[1 ].d =0 ; }/*
xen/arch/x86/lib/cpu-policy/copy-to-buffer.c +2 -1
@@ -132,7 +132,8 @@ int x86_cpuid_copy_to_buffer(const struccase 0x1e :for ( subleaf =0 ; - subleaf <=ARRAY_SIZE (p->tmul.raw) -1 ; ++subleaf ) + subleaf <=MIN (p->tmul.max_subleaf, +ARRAY_SIZE (p->tmul.raw) -1 ); ++subleaf )COPY_LEAF (leaf, subleaf, &p->tmul.raw[subleaf]);break ;
xen/arch/x86/lib/cpu-policy/cpuid.c +21 -2
@@ -84,6 +84,7 @@ void x86_cpu_policy_to_featureset( fs[FEATURESET_e21c] = p->extd.e21c; fs[FEATURESET_24c1] = p->avx10._24c1; fs[FEATURESET_29b0] = p->apx._29b0; + fs[FEATURESET_1Ea1] = p->tmul._1Ea1; } void x86_cpu_featureset_to_policy(
@@ -110,6 +111,7 @@ void x86_cpu_featureset_to_policy( p->extd.e21c = fs[FEATURESET_e21c]; p->avx10._24c1 = fs[FEATURESET_24c1]; p->apx._29b0 = fs[FEATURESET_29b0]; + p->tmul._1Ea1 = fs[FEATURESET_1Ea1]; }void x86_cpu_policy_recalc_synth (struct cpu_policy *p)
@@ -233,8 +235,14 @@ void x86_cpu_policy_fill_native(struct c }if ( p->basic.max_leaf >=0x1e ) + {cpuid_count_leaf (0x1e ,0 , &p->tmul.raw[0 ]); +for ( i =1 ; i <=MIN (p->tmul.max_subleaf, +ARRAY_SIZE (p->tmul.raw) -1 ); ++i ) +cpuid_count_leaf (0x1e , i, &p->tmul.raw[i]); + } +if ( p->basic.max_leaf >=0x24 ) {cpuid_count_leaf (0x24 ,0 , &p->avx10.raw[0 ]);
@@ -333,8 +341,12 @@ void x86_cpu_policy_clear_out_of_range_lif ( p->basic.max_leaf <0x1e || !p->tile.max_palette || (!p->feat.amx_int8 && !p->feat.amx_bf16 && - !p->feat.amx_fp16 && !p->feat.amx_complex) ) + !p->feat.amx_fp16 && !p->feat.amx_complex && + !p->tmul._1Ea1) )memset (p->tmul.raw,0 ,sizeof (p->tmul.raw)); +else +zero_leaves (p->tmul.raw, p->tmul.max_subleaf +1 , +ARRAY_SIZE (p->tmul.raw) -1 );if ( p->basic.max_leaf <0x24 )memset (p->avx10.raw,0 ,sizeof (p->avx10.raw));
@@ -356,6 +368,8 @@ void __init x86_cpu_policy_bound_max_leamin_t (uint32_t, p->feat.max_subleaf,ARRAY_SIZE (p->feat.raw) -1 ); p->tile.max_palette =min_t (uint32_t, p->tile.max_palette,ARRAY_SIZE (p->tile.raw) -1 ); + p->tmul.max_subleaf = +min_t (uint32_t, p->tmul.max_subleaf,ARRAY_SIZE (p->tmul.raw) -1 ); p->avx10.max_subleaf =min_t (uint32_t, p->avx10.max_subleaf,ARRAY_SIZE (p->avx10.raw) -1 ); p->apx.max_subleaf =
@@ -400,7 +414,12 @@ void x86_cpu_policy_shrink_max_leaves(st } p->basic.raw[0x1d ] = p->tile.raw[0 ]; - p->basic.raw[0x1e ] = p->tmul.raw[0 ]; +for ( i = p->tmul.max_subleaf; i; --i ) +if ( p->tmul.raw[i].a | p->tmul.raw[i].b | + p->tmul.raw[i].c | p->tmul.raw[i].d ) +break ; + p->tmul.max_subleaf = i; + p->basic.raw[0x1e ] = p->tmul.raw[i]; p->basic.raw[0x24 ] = p->avx10.raw[0 ];
xen/arch/x86/lib/cpu-policy/policy.c +4 -2
@@ -41,8 +41,10 @@ int x86_cpu_policies_are_compatible(consFAIL_CPUID (0x1d ,1 ); } -if ( ((guest->feat.amx_int8 || guest->feat.amx_bf16 || - guest->feat.amx_fp16 || guest->feat.amx_complex) && +if ( guest->tmul.max_subleaf > host->tmul.max_subleaf || + ((guest->feat.amx_int8 || guest->feat.amx_bf16 || + guest->feat.amx_fp16 || guest->feat.amx_complex || + guest->tmul._1Ea1) && (!guest->tmul.maxk || !guest->tmul.maxn)) || guest->tmul.maxk > host->tmul.maxk || guest->tmul.maxn > host->tmul.maxn )
xen/include/public/arch-x86/cpufeatureset.h +9 -0
@@ -419,6 +419,15 @@ XEN_CPUFEATURE(AVX10_V2_AUX, 19*32/* Intel-defined CPU features, CPUID level 0x00000029:0.ebx, word 20 */ XEN_CPUFEATURE (APX_NCI_NDD_NF ,20 *32 +0 )/*a APX NCI/NDD/NF instruction forms */ +/* Intel-defined CPU features, CPUID level 0x0000001e:1.eax, word 21 */ +XEN_CPUFEATURE(AMX__INT8, 21*32+ 0) /*a AMX-INT8 Instructions */ +XEN_CPUFEATURE(AMX__BF16, 21*32+ 1) /*a AMX-BF16 Instructions */ +XEN_CPUFEATURE(AMX__COMPLEX, 21*32+ 2) /*a AMX-COMPLEX Instructions */ +XEN_CPUFEATURE(AMX__FP16, 21*32+ 3) /*a AMX-FP16 Instructions */ +XEN_CPUFEATURE(AMX_FP8, 21*32+ 4) /* AMX-FP8 Instructions */ +XEN_CPUFEATURE(AMX_AVX512, 21*32+ 7) /* AMX-AVX512 Instructions */ +XEN_CPUFEATURE(AMX_MOVRS, 21*32+ 8) /* AMX-MOVRS Instructions */ +#endif /* XEN_CPUFEATURE */ /* Clean up from a default include. Close the enum (for C). */
xen/include/xen/lib/x86/cpu-policy.h +10 -2
@@ -25,6 +25,7 @@#define FEATURESET_e21c 18/* 0x80000021.ecx */ #define FEATURESET_24c1 19/* 0x00000024:1.ecx */ #define FEATURESET_29b0 20/* 0x00000029:0.ebx */ +#define FEATURESET_1Ea1 21/* 0x0000001e:1.eax */ struct cpuid_leaf {
@@ -67,7 +68,7 @@ const char *x86_cpuid_vendor_to_str(unsi#define CPUID_GUEST_NR_TOPO (1u + 1)#define CPUID_GUEST_NR_XSTATE (62u + 1)#define CPUID_GUEST_NR_PALETTE (1u + 1) -#define CPUID_GUEST_NR_TMUL (0u + 1) +#define CPUID_GUEST_NR_TMUL (1u + 1)#define CPUID_GUEST_NR_AVX10 (1u + 1)#define CPUID_GUEST_NR_APX (0u + 1)#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
@@ -293,9 +294,16 @@ struct cpu_policystruct cpuid_leaf raw[CPUID_GUEST_NR_TMUL ];struct {/* Subleaf 0. */ - uint32_t /* a */:32; +uint32_t max_subleaf; uint32_t maxk:8, maxn:16, :8; uint32_t /* c */:32, /* d */:32; + +/* Subleaf 1. */ +union { +uint32_t _1Ea1; + struct { DECL_BITFIELD(1Ea1); }; + }; + uint32_t /* b */:32, /* c */:32, /* d */:32; }; } tmul;
xen/tools/gen-cpuid.py +4 -2
@@ -302,7 +302,8 @@ def crunch_numbers(state): # AVX512 features are built on top of AVX512F AVX512F: [AVX512DQ, AVX512_IFMA, AVX512PF, AVX512ER, AVX512CD, AVX512BW, AVX512VL, AVX512_4VNNIW, AVX512_4FMAPS, - AVX512_VNNI, AVX512_VPOPCNTDQ, AVX512_VP2INTERSECT], + AVX512_VNNI, AVX512_VPOPCNTDQ, AVX512_VP2INTERSECT, + AMX_AVX512], # AVX512 extensions acting on vectors of bytes/words are made # dependents of AVX512BW (as to requiring wider than 16-bit mask
@@ -354,7 +355,8 @@ def crunch_numbers(state): # AMX-TILE means hardware support for tile registers and general non- # computational instructions. All further AMX features are built on top # of AMX-TILE. - AMX_TILE: [AMX_BF16, AMX_INT8, AMX_FP16, AMX_COMPLEX], + AMX_TILE: [AMX_BF16, AMX_INT8, AMX_FP16, AMX_COMPLEX, AMX_FP8, + AMX_AVX512, AMX_MOVRS], # APX discrete features. APX_F: [APX_NCI_NDD_NF],
PATCH v4 20/28 x86emul: support AMX-MOVRS(-only) insns
In reply to Jan BeulichThey're direct counterparts of TILELOADD{,T1}, so existing code can relatively easily be re-used.
---
v4: New.
tools/tests/x86_emulator/evex-disp8.c +8 -1
@@ -1202,6 +1202,12 @@ static const struct test amx_tile[] = { INSN(tilestored, f3, 0f38, 4b, el, d, no), }; +static const struct test amx_movrs[] = { +/* Element size assumes a 1x1 matrix here. See test_one(). */ + INSN(tileloaddrs, f2, 0f38, 4a, el, d, no), + INSN(tileloaddrst1, 66, 0f38, 4a, el, d, no), +}; +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 };
@@ -1475,7 +1481,7 @@ static void test_one(const struct test ** Tile loads/stores require a valid tile configuration. Set up a 1x1 * tile for %tmm0. */ -if ( test->spc == SPC_0f38 && test->opc ==0x4b ) +if ( test->spc == SPC_0f38 && (test->opc |1 ) ==0x4b ) {static const struct x86_tilecfg tilecfg = { .palette =1 ,
@@ -1837,6 +1843,7 @@ void evex_disp8_test(void *instr, struct }while ( false )RUN (adx); +RUN (amx_movrs);RUN (amx_tile);RUN (avx512f);RUN (avx512dq);
tools/tests/x86_emulator/predicates.c +4 -0
@@ -1347,6 +1347,8 @@ static const struct vex { { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ { { 0x49, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tilezero */ + { { 0x4a, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddrst1 */ + { { 0x4a, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloaddrs */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */
@@ -1939,6 +1941,8 @@ static const struct evex { { { 0x47 }, 2, T, R, pfx_66, Wn, Ln }, /* vpsllv{d,q} */ { { 0x49, 0x00 }, 2, F, R, pfx_no, W0, L0 }, /* ldtilecfg */ { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ + { { 0x4a, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddrst1 */ + { { 0x4a, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloaddrs */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */
tools/tests/x86_emulator/x86-emulate.h +4 -0
@@ -249,6 +249,10 @@ void wrpkru(unsigned int val);#define cpu_has_xgetbv1 (cpu_has_xsave && cpu_policy.xstate.xgetbv1) +#define cpu_has_amx_movrs (cpu_policy.tmul.amx_movrs && \ + xcr0_mask(X86_XCR0_TILE_CFG | \ + X86_XCR0_TILE_DATA)) +#define cpu_has_3dnow_ext cpu_policy.extd._3dnowext#define cpu_has_lzcnt cpu_policy.extd.abm#define cpu_has_sse4a cpu_policy.extd.sse4a
xen/arch/x86/x86_emulate/decode.c +3 -1
@@ -364,7 +364,7 @@ static const struct ext0f38_table { [0x44] = { .simd_size = simd_packed_int, .two_op = 1, .d8s = d8s_vl }, [0x45 ... 0x47] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x49] = { .simd_size = simd_other, .two_op = 1 }, - [0x4b] = { .simd_size = simd_other, .two_op = 1, .vsib = 1 }, + [0x4a ... 0x4b] = { .simd_size = simd_other, .two_op = 1, .vsib = 1 }, [0x4c] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x4d] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x4e] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl },
@@ -1313,6 +1313,8 @@ decode_0f38(struct x86_emulate_state *s,break ;case X86EMUL_OPC_EVEX (0 ,0x49 ):/* ldtilecfg */ +case X86EMUL_OPC_EVEX_66 (0 ,0x4a ):/* tileloaddrst1 */ +case X86EMUL_OPC_EVEX_F2 (0 ,0x4a ):/* tileloaddrs */ case X86EMUL_OPC_EVEX_66 (0 ,0x4b ):/* tileloaddt1 */ case X86EMUL_OPC_EVEX_F2 (0 ,0x4b ):/* tileloadd */ case X86EMUL_OPC_EVEX_66(0, 0xe0) ...
xen/arch/x86/x86_emulate/private.h +2 -0
@@ -627,6 +627,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_amx_movrs () (ctxt->cpuid->tmul.amx_movrs) +#define vcpu_has_avx10 (minor) (ctxt->cpuid->avx10.version >= (minor))#define vcpu_has_avx10_2_aux () (ctxt->cpuid->avx10.avx10_v2_aux)
xen/arch/x86/x86_emulate/x86_emulate.c +11 -0
@@ -6771,6 +6771,16 @@ x86_emulate( } goto unrecognized_insn; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x4a ):/* tileloaddrst1 mem,tmm */ +case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x4a ):/* tileloaddrs mem,tmm */ +generate_exception_if ((evex.lr || evex.brs || evex.opmsk || !evex.RX), +X86_EXC_UD ); + fallthrough; +case X86EMUL_OPC_VEX_66 (0x0f38 ,0x4a ):/* tileloaddrst1 mem,tmm */ +case X86EMUL_OPC_VEX_F2 (0x0f38 ,0x4a ):/* tileloaddrs mem,tmm */ +vcpu_must_have (amx_movrs); + goto tile_load_store; +case X86EMUL_OPC_EVEX_66 (0x0f38 ,0x4b ):/* tileloaddt1 mem,tmm */ case X86EMUL_OPC_EVEX_F3 (0x0f38 ,0x4b ):/* tilestored tmm,mem */ case X86EMUL_OPC_EVEX_F2 (0x0f38 ,0x4b ):/* tileloadd mem,tmm */
@@ -6780,6 +6790,7 @@ x86_emulate(case X86EMUL_OPC_VEX_66 (0x0f38 ,0x4b ):/* tileloaddt1 mem,tmm */ case X86EMUL_OPC_VEX_F3 (0x0f38 ,0x4b ):/* tilestored tmm,mem */ case X86EMUL_OPC_VEX_F2 (0x0f38 ,0x4b ):/* tileloadd mem,tmm */ + tile_load_store: {struct x86_tilecfg *cfg = &mmvalp->tilecfg;unsigned int row, iter;
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -426,7 +426,7 @@ XEN_CPUFEATURE(AMX__COMPLEX, 21*32 XEN_CPUFEATURE(AMX__FP16, 21*32+ 3) /*a AMX-FP16 Instructions */ XEN_CPUFEATURE(AMX_FP8, 21*32+ 4) /* AMX-FP8 Instructions */ XEN_CPUFEATURE(AMX_AVX512, 21*32+ 7) /* AMX-AVX512 Instructions */ -XEN_CPUFEATURE(AMX_MOVRS, 21*32+ 8) /* AMX-MOVRS Instructions */ +XEN_CPUFEATURE(AMX_MOVRS, 21*32+ 8) /*a AMX-MOVRS Instructions */#endif /* XEN_CPUFEATURE */
PATCH v4 21/28 x86emul: support AMX-FP8 insns
In reply to Jan BeulichThey can simply be wired into existing handling, and this feature can then (optionally) be exposed to guests right away.
---
v4: New.
tools/tests/x86_emulator/predicates.c +6 -1
@@ -1522,6 +1522,11 @@ static const struct vex { { { 0xde }, 3, T, R, pfx_66, W0, L0 }, /* vsm3rnds2 */ { { 0xdf }, 3, T, R, pfx_66, WIG, Ln }, /* vaeskeygenassist */ { { 0xf0 }, 3, T, R, pfx_f2, Wn, L0 }, /* rorx */ +}, vex_map5[] = { + { { 0xfd, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tdpbf8ps */ + { { 0xfd, 0xc0 }, 2, F, N, pfx_66, W0, L0 }, /* tdphf8ps */ + { { 0xfd, 0xc0 }, 2, F, N, pfx_f3, W0, L0 }, /* tdphbf8ps */ + { { 0xfd, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tdpbhf8ps */ }, vex_map7[] = { { { 0xf6, 0xc0 }, 6, F, N, pfx_f3, W0, L0 }, /* wrmsrns */ { { 0xf6, 0xc0 }, 6, F, N, pfx_f2, W0, L0 }, /* rdmsr */
@@ -1537,7 +1542,7 @@ static const struct { { vex_0f38, ARRAY_SIZE(vex_0f38) }, { vex_0f3a, ARRAY_SIZE(vex_0f3a) }, { NULL, 0 }, /* map 4 */ - { NULL, 0 }, /* map 5 */ + { vex_map5, ARRAY_SIZE(vex_map5) }, { NULL, 0 }, /* map 6 */ { vex_map7, ARRAY_SIZE(vex_map7) }, };
xen/arch/x86/x86_emulate/decode.c +22 -7
@@ -1532,6 +1532,23 @@ decode_map4(struct x86_emulate_state *s,return rc; } +static int +decode_map5 (struct x86_emulate_state *s, +struct x86_emulate_ctxt *ctxt, +const struct x86_emulate_ops *ops) +{ +int rc =X86EMUL_OKAY ; + +switch ( ctxt->opcode &0xff ) + { +case 0xfd : + s->simd_size = simd_other; +break ; + } + +return rc; +} +#define ad_bytes (s->ad_bytes)/* for truncate_ea() */ int x86emul_decode(struct x86_emulate_state *s,
@@ -1886,12 +1903,6 @@ int x86emul_decode(struct x86_emulate_stbreak ;case evex_map5: -if ( !evex_encoded () ) - { -default : - rc =X86EMUL_UNRECOGNIZED ; - goto done; - } opcode |=MASK_INSR (5 ,X86EMUL_OPC_EXT_MASK );/* * Re-use twobyte_table[] here, for the similarity of
@@ -1906,6 +1917,7 @@ int x86emul_decode(struct x86_emulate_stcase evex_map6:if ( !evex_encoded () ) { +default : rc =X86EMUL_UNRECOGNIZED ; goto done; }
@@ -2171,7 +2183,7 @@ int x86emul_decode(struct x86_emulate_stswitch ( b ) {default : -if ( s->evex.pfx != vex_f2 ) +if (evex_encoded () && s->evex.pfx != vex_f2 ) s->fp16 = true;break ;
@@ -2677,6 +2689,9 @@ int x86emul_decode(struct x86_emulate_stbreak ;case ext_map5: + rc =decode_map5 (s, ctxt, ops); +break ; +case ext_map6:case ext_map7:case ext_8f09:
xen/arch/x86/x86_emulate/private.h +1 -0
@@ -627,6 +627,7 @@ 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_amx_fp8 () (ctxt->cpuid->tmul.amx_fp8)#define vcpu_has_amx_movrs () (ctxt->cpuid->tmul.amx_movrs)#define vcpu_has_avx10 (minor) (ctxt->cpuid->avx10.version >= (minor))
xen/arch/x86/x86_emulate/x86_emulate.c +13 -1
@@ -7011,7 +7011,7 @@ x86_emulate(case X86EMUL_OPC_VEX (0x0f38 ,0x6c ):/* tcmmrlfp16ps tmm,tmm,tmm */ case X86EMUL_OPC_VEX_66 (0x0f38 ,0x6c ):/* tcmmimfp16ps tmm,tmm,tmm */ { -unsigned int vreg = vex.reg ^0xf ; +unsigned int vreg;if ( ea.type !=OP_REG ) goto unrecognized_insn;
@@ -7024,6 +7024,8 @@ x86_emulate(vcpu_must_have (amx_bf16); elsevcpu_must_have (amx_fp16 ); + tmul: + vreg = vex.reg ^0xf ;generate_exception_if (modrm_reg == modrm_rm,X86_EXC_UD );generate_exception_if (modrm_reg == vreg,X86_EXC_UD );generate_exception_if (modrm_rm == vreg,X86_EXC_UD );
@@ -9189,6 +9191,16 @@ x86_emulate(avx512_vlen_check (true); goto simd_zmm; +case X86EMUL_OPC_VEX (5 ,0xfd ):/* tdpbf8ps tmm,tmm,tmm */ +case X86EMUL_OPC_VEX_66 (5 ,0xfd ):/* tdphf8ps tmm,tmm,tmm */ +case X86EMUL_OPC_VEX_F3 (5 ,0xfd ):/* tdphbf8ps tmm,tmm,tmm */ +case X86EMUL_OPC_VEX_F2 (5 ,0xfd ):/* tdpbhf8ps tmm,tmm,tmm */ +if ( ea.type !=OP_REG ) + goto unrecognized_insn; +generate_exception_if (!mode_64bit () || vex.l || vex.w,X86_EXC_UD ); +vcpu_must_have (amx_fp8); + goto tmul; +case X86EMUL_OPC_EVEX_66 (6 ,0x4c ):/* vrcpph [xyz]mm/mem,[xyz]mm{k} */ case X86EMUL_OPC_EVEX_66 (6 ,0x4e ):/* vrsqrtph [xyz]mm/mem,[xyz]mm{k} */ visa_check (_fp16);
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -424,7 +424,7 @@ XEN_CPUFEATURE(AMX__INT8, 21*32 XEN_CPUFEATURE(AMX__BF16, 21*32+ 1) /*a AMX-BF16 Instructions */ XEN_CPUFEATURE(AMX__COMPLEX, 21*32+ 2) /*a AMX-COMPLEX Instructions */ XEN_CPUFEATURE(AMX__FP16, 21*32+ 3) /*a AMX-FP16 Instructions */ -XEN_CPUFEATURE(AMX_FP8, 21*32+ 4) /* AMX-FP8 Instructions */ +XEN_CPUFEATURE(AMX_FP8, 21*32+ 4) /*a AMX-FP8 Instructions */ XEN_CPUFEATURE(AMX_AVX512, 21*32+ 7) /* AMX-AVX512 Instructions */XEN_CPUFEATURE (AMX_MOVRS ,21 *32 +8 )/*a AMX-MOVRS Instructions */
PATCH v4 22/28 x86emul: support AMX-AVX512 insns with GPR operand
In reply to Jan BeulichSince both tile and zmm state are accessed by these insns, this requires introducing a new enumerator to pass into get_fpu().
As of ISE 056 the APX interaction is unclear; EVEX.V' is supposed to be set as per the respective exception type, yet the bit needs to be clear to be able to access eGPR-s. Respective handling is therefore guesswork for now.
---
v4: New.
tools/tests/x86_emulator/predicates.c +6 -0
@@ -1948,6 +1948,8 @@ static const struct evex { { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddrst1 */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloaddrs */ + { { 0x4a, 0xc0 }, 2, F, N, pfx_66, W0, L2 }, /* tilemovrow */ + { { 0x4a, 0xc0 }, 2, F, N, pfx_f3, W0, L2 }, /* tcvtrowd2ps */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */
@@ -1982,6 +1984,10 @@ static const struct evex { { { 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} */ + { { 0x6d, 0xc0 }, 2, F, N, pfx_no, W0, L2 }, /* tcvtrowps2phh */ + { { 0x6d, 0xc0 }, 2, F, N, pfx_66, W0, L2 }, /* tcvtrowps2phl */ + { { 0x6d, 0xc0 }, 2, F, N, pfx_f3, W0, L2 }, /* tcvtrowps2bf16l */ + { { 0x6d, 0xc0 }, 2, F, N, pfx_f2, W0, L2 }, /* tcvtrowps2bf16h */ { { 0x70 }, 2, T, R, pfx_66, W1, Ln }, /* vpshldvw */ { { 0x71 }, 2, T, R, pfx_66, Wn, Ln }, /* vpshldv{d,q} */ { { 0x72 }, 2, T, R, pfx_66, W1, Ln }, /* vpshrdvw */
tools/tests/x86_emulator/x86-emulate.c +4 -0
@@ -247,6 +247,10 @@ int emul_test_get_fpu(default :return X86EMUL_UNHANDLEABLE ; +case X86EMUL_FPU_zmm_tile: +if ( !cpu_has_amx_avx512 ) +return X86EMUL_UNHANDLEABLE ; + fallthrough;case X86EMUL_FPU_tilecfg:case X86EMUL_FPU_tile:return cpu_has_amx_tile ?X86EMUL_OKAY :X86EMUL_UNHANDLEABLE ;
tools/tests/x86_emulator/x86-emulate.h +3 -0
@@ -249,6 +249,9 @@ void wrpkru(unsigned int val);#define cpu_has_xgetbv1 (cpu_has_xsave && cpu_policy.xstate.xgetbv1) +#define cpu_has_amx_avx512 (cpu_policy.tmul.amx_avx512 && \ + xcr0_mask(X86_XCR0_TILE_CFG | \ + X86_XCR0_TILE_DATA))#define cpu_has_amx_movrs (cpu_policy.tmul.amx_movrs && \ xcr0_mask(X86_XCR0_TILE_CFG | \ X86_XCR0_TILE_DATA))
xen/arch/x86/x86_emulate/decode.c +12 -3
@@ -384,7 +384,7 @@ static const struct ext0f38_table { [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 }, - [0x6c] = { .simd_size = simd_other }, + [0x6c ... 0x6d] = { .simd_size = simd_other }, [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 },
@@ -1312,8 +1312,15 @@ decode_0f38(struct x86_emulate_state *s,case X86EMUL_OPC_VEX_F2 (0 ,0xf7 ):/* shrx */ break ; +case X86EMUL_OPC_EVEX_66 (0 ,0x4a ):/* tileloaddrst1 / tilemovrow */ +if ( s->modrm_mod ==3 ) + { +case X86EMUL_OPC_EVEX_F3 (0 ,0x4a ):/* tcvtrowd2ps */ + s->desc &= ~Mov; +break ; + } + fallthrough;case X86EMUL_OPC_EVEX (0 ,0x49 ):/* ldtilecfg */ -case X86EMUL_OPC_EVEX_66 (0 ,0x4a ):/* tileloaddrst1 */ case X86EMUL_OPC_EVEX_F2 (0 ,0x4a ):/* tileloaddrs */ case X86EMUL_OPC_EVEX_66 (0 ,0x4b ):/* tileloaddt1 */ case X86EMUL_OPC_EVEX_F2 (0 ,0x4b ):/* tileloadd */
@@ -2101,7 +2108,9 @@ int x86emul_decode(struct x86_emulate_st {generate_exception_if (evex_encoded () && !s->evex.u,X86_EXC_UD ); - d |= vSIB; + +if ( b !=0x4a || s->modrm_mod !=3 ) + d |= vSIB; } s->simd_size = ext0f38_table[b].simd_size;if (evex_encoded () )
xen/arch/x86/x86_emulate/private.h +1 -0
@@ -628,6 +628,7 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_user_msr () (ctxt->cpuid->feat.user_msr)#define vcpu_has_amx_fp8 () (ctxt->cpuid->tmul.amx_fp8) +#define vcpu_has_amx_avx512 () (ctxt->cpuid->tmul.amx_avx512)#define vcpu_has_amx_movrs () (ctxt->cpuid->tmul.amx_movrs)#define vcpu_has_avx10 (minor) (ctxt->cpuid->avx10.version >= (minor))
xen/arch/x86/x86_emulate/x86_emulate.c +55 -0
79 lines not on this page · raw message
xen/arch/x86/x86_emulate/x86_emulate.h +1 -0
@@ -87,6 +87,7 @@ enum x86_emulate_fpu_type { X86EMUL_FPU_zmm,/* AVX512 instruction set (%zmm0-%zmm7/31) */ X86EMUL_FPU_tilecfg,/* AMX configuration (tilecfg) */ X86EMUL_FPU_tile,/* AMX instruction set (%tmm0-%tmmN) */ + X86EMUL_FPU_zmm_tile,/* AMX and AVX512/AVX10 instruction sets */ /* This sentinel will never be passed to ->get_fpu(). */ X86EMUL_FPU_none };
PATCH v4 23/28 x86emul: support AMX-AVX512 insns with immediate operand
In reply to Jan BeulichDue to their similarity with the GPR forms the code used there can simply re-use most of the code there.
---
v4: New.
tools/tests/x86_emulator/predicates.c +6 -0
@@ -2107,6 +2107,10 @@ static const struct evex { { { 0x03 }, 3, T, R, pfx_66, Wn, Ln }, /* valign{d,q} */ { { 0x04 }, 3, T, R, pfx_66, W0, Ln }, /* vpermilps */ { { 0x05 }, 3, T, R, pfx_66, W1, Ln }, /* vpermilpd */ + { { 0x07, 0xc0 }, 3, F, N, pfx_no, W0, L2 }, /* tcvtrowps2phh */ + { { 0x07, 0xc0 }, 3, F, N, pfx_66, W0, L2 }, /* tilemovrow */ + { { 0x07, 0xc0 }, 3, F, N, pfx_f3, W0, L2 }, /* tcvtrowd2ps */ + { { 0x07, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* tcvtrowps2bf16h */ { { 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 */
@@ -2170,6 +2174,8 @@ static const struct evex { { { 0x71 }, 3, T, R, pfx_66, Wn, Ln }, /* vshld{d,q} */ { { 0x72 }, 3, T, R, pfx_66, W1, Ln }, /* vshrdw */ { { 0x73 }, 3, T, R, pfx_66, Wn, Ln }, /* vshrd{d,q} */ + { { 0x77, 0xc0 }, 3, F, N, pfx_f3, W0, L2 }, /* tcvtrowps2bf16l */ + { { 0x77, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* tcvtrowps2phl */ { { 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 */
xen/arch/x86/x86_emulate/decode.c +2 -0
@@ -470,6 +470,7 @@ static const struct ext0f3a_table { [0x03] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x04 ... 0x05] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x06] = { .simd_size = simd_packed_fp }, + [0x07] = { .simd_size = simd_other, .two_op = 1 }, [0x08 ... 0x09] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x0a ... 0x0b] = { .simd_size = simd_scalar_opc, .d8s = d8s_dq }, [0x0c ... 0x0d] = { .simd_size = simd_packed_fp },
@@ -523,6 +524,7 @@ static const struct ext0f3a_table { [0x6c ... 0x6d] = { .simd_size = simd_packed_fp, .four_op = 1 }, [0x6e ... 0x6f] = { .simd_size = simd_scalar_opc, .four_op = 1 }, [0x70 ... 0x73] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, + [0x77] = { .simd_size = simd_other, .two_op = 1 }, [0x78 ... 0x79] = { .simd_size = simd_packed_fp, .four_op = 1 }, [0x7a ... 0x7b] = { .simd_size = simd_scalar_opc, .four_op = 1 }, [0x7c ... 0x7d] = { .simd_size = simd_packed_fp, .four_op = 1 },
xen/arch/x86/x86_emulate/x86_emulate.c +23 -2
@@ -6977,6 +6977,7 @@ x86_emulate( (!evex.RX && !(state->xcr0 & X86_XCR0_APX))), X86_EXC_UD); + tilemov:get_fpu (X86EMUL_FPU_zmm_tile);sttilecfg (&mmvalp->tilecfg);
@@ -6986,6 +6987,10 @@ x86_emulate(generate_exception_if (mmvalp->tilecfg.colsb[modrm_rm] &3 ,X86_EXC_UD ); +/* +* Note: For the immediate forms this decodes %rax, but the value isn't +* going to be used by the insn below anyway. +*/ ea.reg =decode_evex_gpr (evex.reg | (evex.RX <<4 ), &_regs, &state->egpr, ctxt);
@@ -6995,8 +7000,10 @@ x86_emulate( evex.reg =0xf ; evex.RX =1 ; opc[1 ] = modrm; - insn_bytes =EVEX_PFX_BYTES +2 ; -place_ret (&opc[2 ]); + opc[2 ] = imm1; + i = ((ctxt->opcode &X86EMUL_OPC_EXT_MASK ) ==X86EMUL_OPC (0x0f3a ,0 )); + insn_bytes =EVEX_PFX_BYTES +2 + i; +place_ret (&opc[2 + i]);copy_EVEX (opc, evex); invoke_stub("", "", "=g" (dummy) : "a" (*ea.reg));
@@ -8288,6 +8295,20 @@ x86_emulate( fault_suppression = false; goto avx512f_imm8_no_sae; +case X86EMUL_OPC_EVEX (0x0f3a ,0x07 ):/* tcvtrowps2phh $imm8,tmm,zmm */ +case X86EMUL_OPC_EVEX_66 (0x0f3a ,0x07 ):/* tilemovrow $imm8,tmm,zmm */ +case X86EMUL_OPC_EVEX_F3 (0x0f3a ,0x07 ):/* tcvtrowd2ps $imm8,tmm,zmm */ +case X86EMUL_OPC_EVEX_F2 (0x0f3a ,0x07 ):/* tcvtrowps2bf16h $imm8,tmm,zmm */ +case X86EMUL_OPC_EVEX_F3 (0x0f3a ,0x77 ):/* tcvtrowps2bf16l $imm8,tmm,zmm */ +case X86EMUL_OPC_EVEX_F2 (0x0f3a ,0x77 ):/* tcvtrowps2phl $imm8,tmm,zmm */ +if ( ea.type !=OP_REG ) + goto unrecognized_insn; +vcpu_must_have (amx_avx512); +generate_exception_if ((evex.w || evex.brs || evex.opmsk || + evex.lr !=2 || evex.reg !=0xf || !evex.RX), +X86_EXC_UD ); + goto tilemov; +case X86EMUL_OPC_66 (0x0f3a ,0x08 ):/* roundps $imm8,xmm/m128,xmm */ case X86EMUL_OPC_66 (0x0f3a ,0x09 ):/* roundpd $imm8,xmm/m128,xmm */ case X86EMUL_OPC_66 (0x0f3a ,0x0a ):/* roundss $imm8,xmm/m128,xmm */
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -425,7 +425,7 @@ XEN_CPUFEATURE(AMX__BF16, 21*32 XEN_CPUFEATURE(AMX__COMPLEX, 21*32+ 2) /*a AMX-COMPLEX Instructions */ XEN_CPUFEATURE(AMX__FP16, 21*32+ 3) /*a AMX-FP16 Instructions */ XEN_CPUFEATURE(AMX_FP8, 21*32+ 4) /*a AMX-FP8 Instructions */ -XEN_CPUFEATURE(AMX_AVX512, 21*32+ 7) /* AMX-AVX512 Instructions */ +XEN_CPUFEATURE(AMX_AVX512, 21*32+ 7) /*a AMX-AVX512 Instructions */ XEN_CPUFEATURE(AMX_MOVRS, 21*32+ 8) /*a AMX-MOVRS Instructions */#endif /* XEN_CPUFEATURE */
PATCH v4 24/28 x86/CPUID: enable ACE
In reply to Jan Beulich..., keeping it unavailable to guests of course.
Also include the little bit of XCR0 handling adjustment which is needed.
---
v4: New.
tools/tests/cpu-policy/test-cpu-policy.c +22 -0
@@ -623,6 +623,19 @@ static void test_cpuid_out_of_range_clea }, }, { + .name = "tile palette 2", + .nr_markers = 1, + .p = { +/* First and third subleaves valid as a pair. Others cleared. */ + .basic.max_leaf = 0x1d, + .feat.ace = 1, + .xstate.xcr0_low =XSTATE_FP_SSE |X86_XCR0_TILE_CFG | + X86_XCR0_TILE_DATA | X86_XCR0_BSR, + .tile.raw[0].a = 2, + .tile.raw[2].b = 0xc2, + }, + }, + { .name = "extd", .nr_markers = 1, .p = {
@@ -726,6 +739,15 @@ static void test_cpuid_maximum_leaf_shri }, }, { + .name = "ace v1", + .p = { +/* Subleaf 2 only with some valid value. */ + .basic.max_leaf = 0x1d, + .tile.raw[0].a = 2, + .tile.raw[2].a = 1, + }, + }, + { .name = "tmul", .p = {/* Subleaf 0 only with some valid values. */
xen/arch/x86/cpu-policy.c +16 -5
@@ -217,7 +217,9 @@ static void recalculate_xstate(struct cpif ( p->feat.pku ) xstates |=X86_XCR0_PKRU ; -if ( p->feat.amx_tile ) +if ( p->feat.ace ) + xstates |=X86_XCR0_TILE_CFG |X86_XCR0_TILE_DATA |X86_XCR0_BSR ; +else if ( p->feat.amx_tile ) xstates |=X86_XCR0_TILE_CFG |X86_XCR0_TILE_DATA ;if ( p->feat.apx_f )
@@ -262,9 +264,11 @@ static void recalculate_xstate(struct cpstatic void recalculate_tile (struct cpu_policy *p) {if ( !p->feat.amx_tile ) +memset (&p->tmul,0 ,sizeof (p->tmul)); + +if ( !p->feat.amx_tile && !p->feat.ace ) {memset (&p->tile,0 ,sizeof (p->tile)); -memset (&p->tmul,0 ,sizeof (p->tmul));return ; }
@@ -278,6 +282,14 @@ static void recalculate_tile(struct cpu_ p->tile.raw[1 ].d =0 ; } +if ( p->tile.max_palette >=2 ) + { + p->tile.raw[1 ].a &=0x000000ff ; + p->tile.raw[1 ].b =0 ; + p->tile.raw[1 ].c =0 ; + p->tile.raw[1 ].d =0 ; + } + p->tmul.raw[0 ].a =0 ; p->tmul.raw[0 ].b &=0x00ffffff ; p->tmul.raw[0].c = 0,
@@ -1245,11 +1257,10 @@ void __init init_dom0_cpuid_policy(struc* Default-off features with their own leaves need those leaves * re-populated from the max policy. */ -if ( p->feat.amx_tile ) - { +if ( p->feat.amx_tile || p->feat.ace ) p->tile = max->tile; +if ( p->feat.amx_tile ) p->tmul = max->tmul; - }if ( p->feat.avx10 ) p->avx10 = max->avx10;if ( p->feat.apx_f )
xen/arch/x86/include/asm/x86-defns.h +2 -1
@@ -110,13 +110,14 @@#define X86_XCR0_TILE_CFG (_AC(1, ULL) << 17)#define X86_XCR0_TILE_DATA (_AC(1, ULL) << 18)#define X86_XCR0_APX (_AC(1, ULL) << 19) +#define X86_XCR0_BSR (_AC(1, ULL) << 20)#define X86_XCR0_LWP (_AC(1, ULL) << 62)#define X86_XCR0_STATES \ (X86_XCR0_X87 | X86_XCR0_SSE | X86_XCR0_YMM | X86_XCR0_BNDREGS | \ X86_XCR0_BNDCSR | X86_XCR0_OPMASK | X86_XCR0_ZMM | \ X86_XCR0_HI_ZMM | X86_XCR0_PKRU | X86_XCR0_TILE_CFG | \ - X86_XCR0_TILE_DATA | X86_XCR0_APX | \ + X86_XCR0_TILE_DATA | X86_XCR0_APX | X86_XCR0_BSR | \ X86_XCR0_LWP)#define X86_XSS_STATES \
xen/arch/x86/lib/cpu-policy/cpuid.c +1 -1
@@ -409,7 +409,7 @@ void x86_cpu_policy_shrink_max_leaves(st p->tile.max_palette = i; else { -ASSERT (!p->feat.amx_tile); +ASSERT (!p->feat.amx_tile && !p->feat.ace);zero_leaves (p->tile.raw,0 ,0 ); } p->basic.raw[0x1d ] = p->tile.raw[0 ];
xen/arch/x86/lib/cpu-policy/policy.c +5 -0
@@ -25,6 +25,7 @@ int x86_cpu_policies_are_compatible(consFAIL_CPUID (7 ,0 );if ( (guest->feat.amx_tile && !guest->tile.max_palette) || + (guest->feat.ace && guest->tile.max_palette <2 ) || guest->tile.max_palette > host->tile.max_palette )FAIL_CPUID (0x1d ,0 );
@@ -41,6 +42,10 @@ int x86_cpu_policies_are_compatible(consFAIL_CPUID (0x1d ,1 ); } +if ( guest->tile.max_palette >=2 && + guest->tile.ace.version > host->tile.ace.version ) +FAIL_CPUID (0x1d ,2 ); + if ( guest->tmul.max_subleaf > host->tmul.max_subleaf || ((guest->feat.amx_int8 || guest->feat.amx_bf16 || guest->feat.amx_fp16 || guest->feat.amx_complex ||
xen/arch/x86/x86_emulate/decode.c +2 -1
@@ -1603,7 +1603,8 @@ int x86emul_decode(struct x86_emulate_st* environments. */ if ( !mode_64bit () ) - s->xcr0 &= ~(X86_XCR0_TILE_CFG |X86_XCR0_TILE_DATA |X86_XCR0_APX ); + s->xcr0 &= ~(X86_XCR0_TILE_CFG |X86_XCR0_TILE_DATA |X86_XCR0_APX | +X86_XCR0_BSR ); }/* Prefix bytes. */
xen/arch/x86/xstate.c +8 -1
@@ -642,6 +642,10 @@ static bool valid_xcr0(uint64_t xcr0)if ( !(xcr0 &X86_XCR0_TILE_CFG ) != !(xcr0 &X86_XCR0_TILE_DATA ) )return false; +/* BSR requires TILE{CFG,DATA} to also be set. */ +if ( (xcr0 &X86_XCR0_BSR ) && !(xcr0 &X86_XCR0_TILE_CFG ) ) +return false; +return true; }
@@ -877,7 +881,10 @@ static void __init noinline xstate_checkif ( cpu_has_xsaves &&boot_cpu_has (X86_FEATURE_ARCH_LBR ) )check_new_xstate (&s,X86_XSS_LBR ); -if (boot_cpu_has (X86_FEATURE_AMX_TILE ) ) +if (boot_cpu_has (X86_FEATURE_ACE ) ) +check_new_xstate (&s, +X86_XCR0_TILE_DATA |X86_XCR0_TILE_CFG |X86_XCR0_BSR ); +else if (boot_cpu_has (X86_FEATURE_AMX_TILE ) )check_new_xstate (&s,X86_XCR0_TILE_DATA |X86_XCR0_TILE_CFG );if ( cpu_has_apx_f )
xen/include/public/arch-x86/cpufeatureset.h +1 -0
@@ -355,6 +355,7 @@ XEN_CPUFEATURE(UC_LOCK_DIS, 13*32/* Intel-defined CPU features, CPUID level 0x00000007:1.ecx, word 14 */ XEN_CPUFEATURE(MSR_IMM, 14*32+ 5) /*s RDMSR/WRMSRNS with immediate operand */ +XEN_CPUFEATURE (ACE ,14 *32 +11 )/* AI Compute Extensions */ /* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */XEN_CPUFEATURE (AVX_VNNI_INT8 ,15 *32 +4 )/*A AVX-VNNI-INT8 Instructions */
xen/include/xen/lib/x86/cpu-policy.h +9 -1
@@ -67,7 +67,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_PALETTE (1u + 1) +#define CPUID_GUEST_NR_PALETTE (2u + 1)#define CPUID_GUEST_NR_TMUL (1u + 1)#define CPUID_GUEST_NR_AVX10 (1u + 1)#define CPUID_GUEST_NR_APX (0u + 1)
@@ -286,6 +286,14 @@ struct cpu_policy uint16_t max_rows, :16; uint32_t /* d */:32; } palette1; + +/* Palette (subleaf) 2 (ACE). */ +struct { + uint32_t version:8, :24; + uint32_t /* b */:32; + uint32_t /* c */:32; + uint32_t /* d */:32; + } ace; }; } tile;
xen/tools/gen-cpuid.py +2 -0
@@ -314,6 +314,8 @@ def crunch_numbers(state): # AVX10 discrete features. AVX10: [AVX10_BMM, AVX10_V1_AUX, AVX10_V2_AUX], + AVX10_V2_AUX: [ACE], + # Extensions with VEX/EVEX encodings keyed to a separate feature # flag are made dependents of their respective legacy feature. PCLMULQDQ: [VPCLMULQDQ],
PATCH v4 25/28 x86emul: enable tile management insns for ACE
In reply to Jan BeulichThese are being re-used from AMX, just that with ACE (alone) palette 1 isn't usable, while palette 2 cannot be used with AMX (alone).
While there also introduce the other two X86EMUL_FPU_*ace*, even if only X86EMUL_FPU_acecfg is needed right here.
---
SDE: ???
---
v4: New.
tools/tests/x86_emulator/evex-disp8.c +7 -0
@@ -1202,6 +1202,12 @@ static const struct test amx_tile[] = { INSN(tilestored, f3, 0f38, 4b, el, d, no), }; +static const struct test ace[] = { +/* Element size is set arbitrarily here. See test_one(). */ + INSN(ldtilecfg, , 0f38, 49, el, b, no), + INSN(sttilecfg, 66, 0f38, 49, el, b, no), +}; +static const struct test amx_movrs[] = {/* Element size assumes a 1x1 matrix here. See test_one(). */ INSN(tileloaddrs, f2, 0f38, 4a, el, d, no),
@@ -1842,6 +1848,7 @@ void evex_disp8_test(void *instr, struct } \ }while ( false ) +RUN (ace);RUN (adx);RUN (amx_movrs);RUN (amx_tile);
tools/tests/x86_emulator/x86-emulate.h +4 -0
@@ -233,6 +233,10 @@ void wrpkru(unsigned int val);#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_ace (cpu_policy.feat.ace && \ + xcr0_mask(X86_XCR0_TILE_CFG | \ + X86_XCR0_TILE_DATA | \ + X86_XCR0_BSR))#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 && \
xen/arch/x86/x86_emulate/private.h +1 -0
@@ -621,6 +621,7 @@ amd_like(const struct x86_emulate_ctxt *#define vcpu_has_msrlist () (ctxt->cpuid->feat.msrlist)#define vcpu_has_movrs () (ctxt->cpuid->feat.movrs)#define vcpu_has_msr_imm () (ctxt->cpuid->feat.msr_imm) +#define vcpu_has_ace () (ctxt->cpuid->feat.ace)#define vcpu_has_avx_vnni_int8 () (ctxt->cpuid->feat.avx_vnni_int8)#define vcpu_has_avx_ne_convert () (ctxt->cpuid->feat.avx_ne_convert)#define vcpu_has_amx_complex () (ctxt->cpuid->feat.amx_complex)
xen/arch/x86/x86_emulate/x86_emulate.c +42 -6
132 lines not on this page · raw message
xen/arch/x86/x86_emulate/x86_emulate.h +3 -0
@@ -88,6 +88,9 @@ enum x86_emulate_fpu_type { X86EMUL_FPU_tilecfg,/* AMX configuration (tilecfg) */ X86EMUL_FPU_tile,/* AMX instruction set (%tmm0-%tmmN) */ X86EMUL_FPU_zmm_tile,/* AMX and AVX512/AVX10 instruction sets */ + X86EMUL_FPU_acecfg,/* ACE configuration (tilecfg) */ + X86EMUL_FPU_ace,/* ACE instruction set (%tmm0-%tmmN, %bsr0) */ + X86EMUL_FPU_zmm_ace,/* ACE plus %zmmN */ /* This sentinel will never be passed to ->get_fpu(). */ X86EMUL_FPU_none };
PATCH v4 26/28 x86emul: enable tile data movement insns for ACE
In reply to Jan BeulichMost of these are being re-used from AMX, only TILEMOVCOL and TILEMOVROW moving to tile are new.
---
SDE: ???
---
While all ACE-E<n> right now merely say "#UD if TILES_CONFIGURED == 0", that's reportedly be incorrect. A requirement for the new insns (enabled here and/or by later patches) is that the selected palette be palette 2. By implication for the original AMX insns this then also means that they need to have palette 1 in use. Except for the few which are available with either palette.
---
v4: New.
tools/tests/x86_emulator/predicates.c +4 -2
@@ -1948,11 +1948,12 @@ static const struct evex { { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddrst1 */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloaddrs */ - { { 0x4a, 0xc0 }, 2, F, N, pfx_66, W0, L2 }, /* tilemovrow */ + { { 0x4a, 0xc0 }, 2, F, N, pfx_66, Wn, L2 }, /* tilemovrow */ { { 0x4a, 0xc0 }, 2, F, N, pfx_f3, W0, L2 }, /* tcvtrowd2ps */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */ { { 0x4b, VSIB(0) }, 3, F, W, pfx_f3, W0, L0 }, /* tilestored */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloadd */ + { { 0x4b, 0xc0 }, 2, F, N, pfx_66, W1, L2 }, /* tilemovcol */ { { 0x4c }, 2, T, R, pfx_66, Wn, Ln }, /* vrcp14p{s,d} */ { { 0x4d }, 2, T, R, pfx_66, Wn, LIG }, /* vrcp14s{s,d} */ { { 0x4e }, 2, T, R, pfx_66, Wn, Ln }, /* vrsqrt14p{s,d} */
@@ -2108,7 +2109,7 @@ static const struct evex { { { 0x04 }, 3, T, R, pfx_66, W0, Ln }, /* vpermilps */ { { 0x05 }, 3, T, R, pfx_66, W1, Ln }, /* vpermilpd */ { { 0x07, 0xc0 }, 3, F, N, pfx_no, W0, L2 }, /* tcvtrowps2phh */ - { { 0x07, 0xc0 }, 3, F, N, pfx_66, W0, L2 }, /* tilemovrow */ + { { 0x07, 0xc0 }, 3, F, N, pfx_66, Wn, L2 }, /* tilemovrow */ { { 0x07, 0xc0 }, 3, F, N, pfx_f3, W0, L2 }, /* tcvtrowd2ps */ { { 0x07, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* tcvtrowps2bf16h */ { { 0x08 }, 3, T, R, pfx_no, W0, Ln }, /* vrndscaleph */
@@ -2140,6 +2141,7 @@ static const struct evex { { { 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} */ + { { 0x2f, 0xc0 }, 3, F, N, pfx_66, W1, L2 }, /* tilemovcol */ { { 0x38 }, 3, T, R, pfx_66, Wn, L1|L2 }, /* vinserti{32x4,64x2} */ { { 0x39 }, 3, T, W, pfx_66, Wn, L1|L2 }, /* vextracti{32x4,64x2} */ { { 0x3a }, 3, T, R, pfx_66, Wn, L2 }, /* vinserti{32x8,64x4} */
xen/arch/x86/x86_emulate/decode.c +3 -2
@@ -493,6 +493,7 @@ static const struct ext0f3a_table { [0x25] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x26] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl }, [0x27] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, + [0x2f] = { .simd_size = simd_other, .two_op = 1 }, [0x30 ... 0x33] = { .simd_size = simd_other, .two_op = 1 }, [0x38] = { .simd_size = simd_128, .d8s = 4 }, [0x3a] = { .simd_size = simd_256, .d8s = d8s_vl_by_2 },
@@ -1315,6 +1316,7 @@ decode_0f38(struct x86_emulate_state *s,break ;case X86EMUL_OPC_EVEX_66 (0 ,0x4a ):/* tileloaddrst1 / tilemovrow */ +case X86EMUL_OPC_EVEX_66 (0 ,0x4b ):/* tileloaddt1 / tilemovcol */ if ( s->modrm_mod ==3 ) {case X86EMUL_OPC_EVEX_F3 (0 ,0x4a ):/* tcvtrowd2ps */
@@ -1324,7 +1326,6 @@ decode_0f38(struct x86_emulate_state *s, fallthrough;case X86EMUL_OPC_EVEX (0 ,0x49 ):/* ldtilecfg */ case X86EMUL_OPC_EVEX_F2 (0 ,0x4a ):/* tileloaddrs */ -case X86EMUL_OPC_EVEX_66 (0 ,0x4b ):/* tileloaddt1 */ case X86EMUL_OPC_EVEX_F2 (0 ,0x4b ):/* tileloadd */ case X86EMUL_OPC_EVEX_66(0, 0xe0) ...X86EMUL_OPC_EVEX_66 (0 ,0xef ):/* cmp<cc>xadd */
@@ -2112,7 +2113,7 @@ int x86emul_decode(struct x86_emulate_stgenerate_exception_if (evex_encoded () && !s->evex.u,X86_EXC_UD ); -if ( b !=0x4a || s->modrm_mod !=3 ) +if ( (b |1 ) !=0x4b || s->modrm_mod !=3 ) d |= vSIB; } s->simd_size = ext0f38_table[b].simd_size;
xen/arch/x86/x86_emulate/x86_emulate.c +61 -13
117 lines not on this page · raw message
PATCH v4 27/28 x86emul: enable block scale register insns for ACE
In reply to Jan BeulichBSRINIT is an encoding sibling of TILEZERO and hence the code there merely needs EVEX.W handling to be adjusted. BSRMOV* are at an entirely new code point, with EVEX.W controlling the direction of the move.
---
SDE: ???
---
v4: New.
tools/tests/x86_emulator/evex-disp8.c +6 -0
@@ -1203,6 +1203,12 @@ static const struct test amx_tile[] = { };static const struct test ace[] = { +/* Element sizes are arbitrary here, for test_one() to set W correctly. */ + INSN(bsrmovf, , map6, 95, vl, q_nb, vl), +INSN (bsrmovh, f2, map6,95 , vl, d_nb, vl), +INSN (bsrmovh, f2, map6,95 , vl, q_nb, vl), +INSN (bsrmovl, f3, map6,95 , vl, d_nb, vl), +INSN (bsrmovl, f3, map6,95 , vl, q_nb, vl),/* Element size is set arbitrarily here. See test_one(). */ INSN(ldtilecfg, , 0f38, 49, el, b, no), INSN(sttilecfg, 66, 0f38, 49, el, b, no),
tools/tests/x86_emulator/predicates.c +6 -0
@@ -1347,6 +1347,7 @@ static const struct vex { { { 0x49, 0x00 }, 2, F, W, pfx_66, W0, L0 }, /* sttilecfg */ { { 0x49, 0xc0 }, 2, F, N, pfx_no, W0, L0 }, /* tilerelease */ { { 0x49, 0xc0 }, 2, F, N, pfx_f2, W0, L0 }, /* tilezero */ + { { 0x49, 0xc0 }, 2, F, N, pfx_f2, W1, L0 }, /* bsrinit */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddrst1 */ { { 0x4a, VSIB(0) }, 3, F, R, pfx_f2, W0, L0 }, /* tileloaddrs */ { { 0x4b, VSIB(0) }, 3, F, R, pfx_66, W0, L0 }, /* tileloaddt1 */
@@ -2567,6 +2568,11 @@ static const struct evex { { { 0x80 }, 2, T, R, pfx_no, W0, L1 | L2 }, /* vbmacor16x16x16 */ { { 0x80 }, 2, T, R, pfx_no, W1, L1 | L2 }, /* vbmacxor16x16x16 */ { { 0x81 }, 2, T, R, pfx_no, W0, Ln }, /* vbitrev */ + { { 0x95 }, 2, F, R, pfx_no, W1, L2 }, /* bsrmovf */ + { { 0x95 }, 2, F, W, pfx_f3, W0, L2 }, /* bsrmovl */ + { { 0x95 }, 2, F, R, pfx_f3, W1, L2 }, /* bsrmovl */ + { { 0x95 }, 2, F, W, pfx_f2, W0, L2 }, /* bsrmovh */ + { { 0x95 }, 2, F, R, pfx_f2, W1, L2 }, /* bsrmovh */ { { 0x96 }, 2, T, R, pfx_66, W0, Ln }, /* vfmaddsub132ph */ { { 0x97 }, 2, T, R, pfx_66, W0, Ln }, /* vfmsubadd132ph */ { { 0x98 }, 2, T, R, pfx_66, W0, Ln }, /* vfmadd132ph */
xen/arch/x86/x86_emulate/decode.c +24 -0
@@ -406,6 +406,7 @@ static const struct ext0f38_table { [0x8e] = { .simd_size = simd_packed_int, .to_mem = 1 }, [0x8f] = { .simd_size = simd_packed_int, .d8s = d8s_vl }, [0x90 ... 0x93] = { .simd_size = simd_other, .vsib = 1, .d8s = d8s_dq }, + [0x95] = { .simd_size = simd_other, .d8s = d8s_vl }, [0x96 ... 0x98] = { .simd_size = simd_packed_fp, .d8s = d8s_vl }, [0x99] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq }, [0x9a] = { .simd_size = simd_packed_fp, .d8s = d8s_vl },
@@ -1559,6 +1560,26 @@ decode_map5(struct x86_emulate_state *s,return rc; } +static int +decode_map6 (struct x86_emulate_state *s, +struct x86_emulate_ctxt *ctxt, +const struct x86_emulate_ops *ops) +{ +int rc =X86EMUL_OKAY ; + +switch ( ctxt->opcode &0xff ) + { +case 0x95 :/* bsrmov{f,h,l} */ +if ( !s->evex.w ) + s->desc = DstMem | SrcReg; +if ( s->evex.pfx ) + s->desc |= TwoOp; +break ; + } + +return rc; +} +#define ad_bytes (s->ad_bytes)/* for truncate_ea() */ int x86emul_decode(struct x86_emulate_state *s,
@@ -2706,6 +2727,9 @@ int x86emul_decode(struct x86_emulate_stbreak ;case ext_map6: + rc =decode_map6 (s, ctxt, ops); +break ; +case ext_map7:case ext_8f09:case ext_8f0a:
xen/arch/x86/x86_emulate/x86_emulate.c +53 -7
77 lines not on this page · raw message
PATCH v4 28/28 x86emul: enable outer product insns for ACE
In reply to Jan BeulichWhile they're different from TMUL ones in terms of operands used, they similarly don't access memory. Hence there's little difference for our purposes, and the logic ends up being pretty similar.
---
SDE: ???
---
v4: New.
CHANGELOG.md +1 -0
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog - Support for AVX10-V2-AUX. (Experimental) - Support for APX. (Experimental) - Support for AMX and XFD. (Experimental) + - Support for ACE. (Experimental) ### Removed - On Arm:
tools/tests/x86_emulator/predicates.c +10 -0
@@ -1979,6 +1979,11 @@ static const struct evex { { { 0x59 }, 2, T, R, pfx_66, Wn, Ln }, /* vbroadcast32x2 / vpbroadcastq */ { { 0x5a }, 2, F, R, pfx_66, Wn, L1|L2 }, /* vbroadcasti{32x4,64x2} */ { { 0x5b }, 2, F, R, pfx_66, Wn, L2 }, /* vbroadcasti{32x8,64x4} */ + { { 0x5c, 0xc0 }, 2, F, N, pfx_f3, W0, L2 }, /* top2bf16ps */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_no, W0, L2 }, /* top4buud */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_66, W0, L2 }, /* top4busd */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_f3, W0, L2 }, /* top4bsud */ + { { 0x5e, 0xc0 }, 2, F, N, pfx_f2, W0, L2 }, /* top4bssd */ { { 0x62 }, 2, T, R, pfx_66, Wn, Ln }, /* vpexpand{b,w} */ { { 0x63 }, 2, T, W, pfx_66, Wn, Ln }, /* vpcompress{b,w} */ { { 0x64 }, 2, T, R, pfx_66, Wn, Ln }, /* vpblendm{d,q} */
@@ -2179,6 +2184,11 @@ static const struct evex { { { 0x73 }, 3, T, R, pfx_66, Wn, Ln }, /* vshrd{d,q} */ { { 0x77, 0xc0 }, 3, F, N, pfx_f3, W0, L2 }, /* tcvtrowps2bf16l */ { { 0x77, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* tcvtrowps2phl */ + { { 0x8d, 0xc0 }, 3, F, N, pfx_no, W0, L2 }, /* top4mxbf8ps */ + { { 0x8d, 0xc0 }, 3, F, N, pfx_66, W0, L2 }, /* top4mxhf8ps */ + { { 0x8d, 0xc0 }, 3, F, N, pfx_f3, W0, L2 }, /* top4mxhbf8ps */ + { { 0x8d, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* top4mxbhf8ps */ + { { 0x8f, 0xc0 }, 3, F, N, pfx_f2, W0, L2 }, /* top4mxbssps */ { { 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 */
xen/arch/x86/x86_emulate/decode.c +2 -0
@@ -531,6 +531,8 @@ static const struct ext0f3a_table { [0x7a ... 0x7b] = { .simd_size = simd_scalar_opc, .four_op = 1 }, [0x7c ... 0x7d] = { .simd_size = simd_packed_fp, .four_op = 1 }, [0x7e ... 0x7f] = { .simd_size = simd_scalar_opc, .four_op = 1 }, + [0x8d] = { .simd_size = simd_other }, + [0x8f] = { .simd_size = simd_other }, [0xc2] = { .simd_size = simd_any_fp, .d8s = d8s_vl }, [0xcc] = { .simd_size = simd_other }, [0xce ... 0xcf] = { .simd_size = simd_packed_int, .d8s = d8s_vl },
xen/arch/x86/x86_emulate/x86_emulate.c +47 -0
59 lines not on this page · raw message
xen/include/public/arch-x86/cpufeatureset.h +1 -1
@@ -355,7 +355,7 @@ XEN_CPUFEATURE(UC_LOCK_DIS, 13*32/* Intel-defined CPU features, CPUID level 0x00000007:1.ecx, word 14 */ XEN_CPUFEATURE(MSR_IMM, 14*32+ 5) /*s RDMSR/WRMSRNS with immediate operand */ -XEN_CPUFEATURE (ACE ,14 *32 +11 )/* AI Compute Extensions */ +XEN_CPUFEATURE (ACE ,14 *32 +11 )/*a AI Compute Extensions */ /* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */XEN_CPUFEATURE (AVX_VNNI_INT8 ,15 *32 +4 )/*A AVX-VNNI-INT8 Instructions */