Skip to content

Commit d5ba463

Browse files
sayantnAmanieu
authored andcommitted
Added support for AMD verification
Added a custom cpuid file for sde, which enables SSE4a, XOP, TBM and VP2INTERSECT. Fixed `xsave` tests
1 parent 3405a62 commit d5ba463

File tree

8 files changed

+90
-73
lines changed

8 files changed

+90
-73
lines changed

ci/docker/x86_64-unknown-linux-gnu-emulated/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1010

1111
RUN wget https://downloadmirror.intel.com/813591/sde-external-9.33.0-2024-01-07-lin.tar.xz
1212
RUN tar -xJf sde-external-9.33.0-2024-01-07-lin.tar.xz
13-
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/sde-external-9.33.0-2024-01-07-lin/sde64 -future -rtm-mode full -tsx --"
13+
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/sde-external-9.33.0-2024-01-07-lin/sde64 \
14+
-cpuid-in /checkout/ci/docker/x86_64-unknown-linux-gnu-emulated/cpuid.def \
15+
-rtm-mode full -tsx --"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright (C) 2017-2023 Intel Corporation.
2+
#
3+
# This software and the related documents are Intel copyrighted materials, and your
4+
# use of them is governed by the express license under which they were provided to
5+
# you ("License"). Unless the License provides otherwise, you may not use, modify,
6+
# copy, publish, distribute, disclose or transmit this software or the related
7+
# documents without Intel's prior written permission.
8+
#
9+
# This software and the related documents are provided as is, with no express or
10+
# implied warranties, other than those that are expressly stated in the License.
11+
#
12+
# CPUID_VERSION = 1.0
13+
# Input => Output
14+
# EAX ECX => EAX EBX ECX EDX
15+
00000000 ******** => 00000024 68747541 444d4163 69746e65
16+
00000001 ******** => 000806f0 00100800 7ffaf3ff bfebfbff
17+
00000002 ******** => 76035a01 00f0b6ff 00000000 00c10000
18+
00000003 ******** => 00000000 00000000 00000000 00000000
19+
00000004 00000000 => 7c004121 01c0003f 0000003f 00000000 #Deterministic Cache
20+
00000004 00000001 => 7c004122 01c0003f 0000003f 00000000
21+
00000004 00000002 => 7c004143 03c0003f 000003ff 00000000
22+
00000004 00000003 => 7c0fc163 0280003f 0000dfff 00000004
23+
00000004 00000004 => 00000000 00000000 00000000 00000000
24+
00000005 ******** => 00000040 00000040 00000003 00042120 #MONITOR/MWAIT
25+
00000006 ******** => 00000077 00000002 00000001 00000000 #Thermal and Power
26+
00000007 00000000 => 00000001 f3bfbfbf bac05ffe 03d54130 #Extended Features
27+
00000007 00000001 => 18ee00bf 00000002 00000000 1d29cd3e
28+
00000008 ******** => 00000000 00000000 00000000 00000000
29+
00000009 ******** => 00000000 00000000 00000000 00000000 #Direct Cache
30+
0000000a ******** => 07300403 00000000 00000000 00000603
31+
0000000b 00000000 => 00000001 00000002 00000100 00000000 #Extended Topology
32+
0000000b 00000001 => 00000004 00000002 00000201 00000000
33+
0000000c ******** => 00000000 00000000 00000000 00000000
34+
0000000d 00000000 => 000e02e7 00002b00 00002b00 00000000 #xcr0
35+
0000000d 00000001 => 0000001f 00000240 00000100 00000000
36+
0000000d 00000002 => 00000100 00000240 00000000 00000000
37+
0000000d 00000005 => 00000040 00000440 00000000 00000000 #zmasks
38+
0000000d 00000006 => 00000200 00000480 00000000 00000000 #zmmh
39+
0000000d 00000007 => 00000400 00000680 00000000 00000000 #zmm
40+
0000000d 00000011 => 00000040 00000ac0 00000002 00000000 #tileconfig
41+
0000000d 00000012 => 00002000 00000b00 00000006 00000000 #tiles
42+
0000000d 00000013 => 00000080 000003c0 00000000 00000000 #APX
43+
00000014 00000000 => 00000000 00000010 00000000 00000000 #ptwrite
44+
00000019 ******** => 00000000 00000005 00000000 00000000 #Key Locker
45+
0000001d 00000000 => 00000001 00000000 00000000 00000000 #AMX Tile
46+
0000001d 00000001 => 04002000 00080040 00000010 00000000 #AMX Palette1
47+
0000001e ******** => 00000000 00004010 00000000 00000000 #AMX Tmul
48+
00000024 ******** => 00000000 00070001 00000000 00000000 #AVX10
49+
80000000 ******** => 80000008 00000000 00000000 00000000
50+
80000001 ******** => 00000000 00000000 00200961 2c100000
51+
80000002 ******** => 00000000 00000000 00000000 00000000
52+
80000003 ******** => 00000000 00000000 00000000 00000000
53+
80000004 ******** => 00000000 00000000 00000000 00000000
54+
80000005 ******** => 00000000 00000000 00000000 00000000
55+
80000006 ******** => 00000000 00000000 01006040 00000000
56+
80000007 ******** => 00000000 00000000 00000000 00000100
57+
80000008 ******** => 00003028 00000200 00000200 00000000
58+
59+
# This file was copied from intel-sde/misc/cpuid/future/cpuid.def, and modified to
60+
# use "AuthenticAMD" as the vendor and the support for `XOP`, `SSE4a`, `TBM` and
61+
# `AVX512_VP2INTERSECT` was added in the CPUID.

crates/core_arch/src/x86/fxsr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod tests {
101101

102102
#[simd_test(enable = "fxsr")]
103103
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
104-
unsafe fn fxsave() {
104+
unsafe fn test_fxsave() {
105105
let mut a = FxsaveArea::new();
106106
let mut b = FxsaveArea::new();
107107

crates/core_arch/src/x86/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,11 @@ mod bmi2;
798798
#[stable(feature = "simd_x86", since = "1.27.0")]
799799
pub use self::bmi2::*;
800800

801-
#[cfg(not(stdarch_intel_sde))]
802801
mod sse4a;
803-
#[cfg(not(stdarch_intel_sde))]
804802
#[stable(feature = "simd_x86", since = "1.27.0")]
805803
pub use self::sse4a::*;
806804

807-
#[cfg(not(stdarch_intel_sde))]
808805
mod tbm;
809-
#[cfg(not(stdarch_intel_sde))]
810806
#[stable(feature = "simd_x86", since = "1.27.0")]
811807
pub use self::tbm::*;
812808

crates/core_arch/src/x86/xsave.rs

+10-29
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,14 @@ mod tests {
208208
}
209209
}
210210

211-
// FIXME: https://github.com/rust-lang/stdarch/issues/209
212-
/*
211+
// We cannot test for `_xsave`, `xrstor`, `_xsetbv`, `_xsaveopt`, `_xsaves`, `_xrstors` as they
212+
// are privileged instructions and will need access to kernel mode to execute and test them.
213+
// see https://github.com/rust-lang/stdarch/issues/209
214+
215+
#[cfg_attr(stdarch_intel_sde, ignore)]
213216
#[simd_test(enable = "xsave")]
214217
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
215-
unsafe fn xsave() {
218+
unsafe fn test_xsave() {
216219
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
217220
let mut a = XsaveArea::new();
218221
let mut b = XsaveArea::new();
@@ -222,27 +225,21 @@ mod tests {
222225
_xsave(b.ptr(), m);
223226
assert_eq!(a, b);
224227
}
225-
*/
226228

227229
#[simd_test(enable = "xsave")]
228230
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
229-
unsafe fn xgetbv_xsetbv() {
231+
unsafe fn test_xgetbv() {
230232
let xcr_n: u32 = _XCR_XFEATURE_ENABLED_MASK;
231233

232234
let xcr: u64 = _xgetbv(xcr_n);
233-
// FIXME: XSETBV is a privileged instruction we should only test this
234-
// when running in privileged mode:
235-
//
236-
// _xsetbv(xcr_n, xcr);
237235
let xcr_cpy: u64 = _xgetbv(xcr_n);
238236
assert_eq!(xcr, xcr_cpy);
239237
}
240238

241-
// FIXME: https://github.com/rust-lang/stdarch/issues/209
242-
/*
239+
#[cfg_attr(stdarch_intel_sde, ignore)]
243240
#[simd_test(enable = "xsave,xsaveopt")]
244241
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
245-
unsafe fn xsaveopt() {
242+
unsafe fn test_xsaveopt() {
246243
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
247244
let mut a = XsaveArea::new();
248245
let mut b = XsaveArea::new();
@@ -252,11 +249,10 @@ mod tests {
252249
_xsaveopt(b.ptr(), m);
253250
assert_eq!(a, b);
254251
}
255-
*/
256252

257253
#[simd_test(enable = "xsave,xsavec")]
258254
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
259-
unsafe fn xsavec() {
255+
unsafe fn test_xsavec() {
260256
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
261257
let mut a = XsaveArea::new();
262258
let mut b = XsaveArea::new();
@@ -266,19 +262,4 @@ mod tests {
266262
_xsavec(b.ptr(), m);
267263
assert_eq!(a, b);
268264
}
269-
270-
// FIXME: https://github.com/rust-lang/stdarch/issues/209
271-
/*
272-
#[simd_test(enable = "xsave,xsaves")]
273-
unsafe fn xsaves() {
274-
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
275-
let mut a = XsaveArea::new();
276-
let mut b = XsaveArea::new();
277-
278-
_xsaves(a.ptr(), m);
279-
_xrstors(a.ptr(), m);
280-
_xsaves(b.ptr(), m);
281-
assert_eq!(a, b);
282-
}
283-
*/
284265
}

crates/core_arch/src/x86_64/fxsr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod tests {
101101

102102
#[simd_test(enable = "fxsr")]
103103
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
104-
unsafe fn fxsave64() {
104+
unsafe fn test_fxsave64() {
105105
let mut a = FxsaveArea::new();
106106
let mut b = FxsaveArea::new();
107107

crates/core_arch/src/x86_64/xsave.rs

+9-23
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,12 @@ pub unsafe fn _xrstors64(mem_addr: *const u8, rs_mask: u64) {
124124
xrstors64(mem_addr, (rs_mask >> 32) as u32, rs_mask as u32);
125125
}
126126

127-
// FIXME: https://github.com/rust-lang/stdarch/issues/209
128-
// All these tests fail with Intel SDE.
129-
130127
#[cfg(test)]
131128
mod tests {
132129
use crate::core_arch::x86_64::xsave;
133130
use std::fmt;
134131
use stdarch_test::simd_test;
135132

136-
// FIXME: https://github.com/rust-lang/stdarch/issues/209
137133
#[repr(align(64))]
138134
struct XsaveArea {
139135
// max size for 256-bit registers is 800 bytes:
@@ -176,10 +172,14 @@ mod tests {
176172
}
177173
}
178174

179-
/*
175+
// We cannot test `_xsave64`, `_xrstor64`, `_xsaveopt64`, `_xsaves64` and `_xrstors64` directly
176+
// as they are privileged instructions and will need access to the kernel to run and test them.
177+
// See https://github.com/rust-lang/stdarch/issues/209
178+
179+
#[cfg_attr(stdarch_intel_sde, ignore)]
180180
#[simd_test(enable = "xsave")]
181181
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
182-
unsafe fn xsave64() {
182+
unsafe fn test_xsave64() {
183183
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
184184
let mut a = XsaveArea::new();
185185
let mut b = XsaveArea::new();
@@ -190,9 +190,10 @@ mod tests {
190190
assert_eq!(a, b);
191191
}
192192

193+
#[cfg_attr(stdarch_intel_sde, ignore)]
193194
#[simd_test(enable = "xsave,xsaveopt")]
194195
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
195-
unsafe fn xsaveopt64() {
196+
unsafe fn test_xsaveopt64() {
196197
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
197198
let mut a = XsaveArea::new();
198199
let mut b = XsaveArea::new();
@@ -202,11 +203,10 @@ mod tests {
202203
xsave::_xsaveopt64(b.ptr(), m);
203204
assert_eq!(a, b);
204205
}
205-
*/
206206

207207
#[simd_test(enable = "xsave,xsavec")]
208208
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
209-
unsafe fn xsavec64() {
209+
unsafe fn test_xsavec64() {
210210
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
211211
let mut a = XsaveArea::new();
212212
let mut b = XsaveArea::new();
@@ -216,18 +216,4 @@ mod tests {
216216
xsave::_xsavec64(b.ptr(), m);
217217
assert_eq!(a, b);
218218
}
219-
/*
220-
#[simd_test(enable = "xsave,xsaves")]
221-
#[cfg_attr(miri, ignore)] // Register saving/restoring is not supported in Miri
222-
unsafe fn xsaves64() {
223-
let m = 0xFFFFFFFFFFFFFFFF_u64; //< all registers
224-
let mut a = XsaveArea::new();
225-
let mut b = XsaveArea::new();
226-
227-
xsave::_xsaves64(a.ptr(), m);
228-
xsave::_xrstors64(a.ptr(), m);
229-
xsave::_xsaves64(b.ptr(), m);
230-
assert_eq!(a, b);
231-
}
232-
*/
233219
}

crates/stdarch-verify/tests/x86-intel.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,12 @@ fn verify_all_signatures() {
189189
"__cpuid_count",
190190
"__cpuid",
191191
"__get_cpuid_max",
192-
// Priviledged
193-
"_xsave",
194-
"_xrstor",
192+
// Privileged, see https://github.com/rust-lang/stdarch/issues/209
195193
"_xsetbv",
196-
"_xgetbv",
197-
"_xsaveopt",
198-
"_xsavec",
199194
"_xsaves",
200195
"_xrstors",
201-
"_xsave64",
202-
"_xrstor64",
203-
"_xsaveopt64",
204-
"_xsavec64",
205196
"_xsaves64",
206197
"_xrstors64",
207-
"_fxsave",
208-
"_fxrstor",
209-
"_fxsave64",
210-
"_fxrstor64",
211198
// TSC
212199
"_rdtsc",
213200
"__rdtscp",
@@ -251,6 +238,10 @@ fn verify_all_signatures() {
251238
// Has tests with different name
252239
"_mm_min_epi8",
253240
"_mm_min_epi32",
241+
"_xrstor",
242+
"_xrstor64",
243+
"_fxrstor",
244+
"_fxrstor64",
254245
// Needs `f16` to test
255246
"_mm_cvtps_ph",
256247
"_mm256_cvtps_ph",

0 commit comments

Comments
 (0)