Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2142f8

Browse files
committedFeb 10, 2025·
Add the keylocker intrinsics
1 parent 9779b18 commit c2142f8

File tree

7 files changed

+543
-22
lines changed

7 files changed

+543
-22
lines changed
 

‎crates/core_arch/missing-x86.md

-21
Original file line numberDiff line numberDiff line change
@@ -137,27 +137,6 @@
137137
</p></details>
138138

139139

140-
<details><summary>["KEYLOCKER"]</summary><p>
141-
142-
* [ ] [`_mm_aesdec128kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesdec128kl_u8)
143-
* [ ] [`_mm_aesdec256kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesdec256kl_u8)
144-
* [ ] [`_mm_aesenc128kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesenc128kl_u8)
145-
* [ ] [`_mm_aesenc256kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesenc256kl_u8)
146-
* [ ] [`_mm_encodekey128_u32`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_encodekey128_u32)
147-
* [ ] [`_mm_encodekey256_u32`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_encodekey256_u32)
148-
* [ ] [`_mm_loadiwkey`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_loadiwkey)
149-
</p></details>
150-
151-
152-
<details><summary>["KEYLOCKER_WIDE"]</summary><p>
153-
154-
* [ ] [`_mm_aesdecwide128kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesdecwide128kl_u8)
155-
* [ ] [`_mm_aesdecwide256kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesdecwide256kl_u8)
156-
* [ ] [`_mm_aesencwide128kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesencwide128kl_u8)
157-
* [ ] [`_mm_aesencwide256kl_u8`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_aesencwide256kl_u8)
158-
</p></details>
159-
160-
161140
<details><summary>["MONITOR"]</summary><p>
162141

163142
* [ ] [`_mm_monitor`](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_monitor)

‎crates/core_arch/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
asm_experimental_arch,
3939
sha512_sm_x86,
4040
x86_amx_intrinsics,
41-
f16
41+
f16,
42+
keylocker_x86
4243
)]
4344
#![cfg_attr(test, feature(test, abi_vectorcall, stdarch_internal))]
4445
#![deny(clippy::missing_inline_in_public_items)]

‎crates/core_arch/src/x86/kl.rs

+526
Large diffs are not rendered by default.

‎crates/core_arch/src/x86/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,7 @@ pub use self::avxneconvert::*;
750750
mod avx512fp16;
751751
#[unstable(feature = "stdarch_x86_avx512_f16", issue = "127213")]
752752
pub use self::avx512fp16::*;
753+
754+
mod kl;
755+
#[unstable(feature = "keylocker_x86", issue = "134813")]
756+
pub use self::kl::*;

‎crates/stdarch-test/src/disassembly.rs

+5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ fn parse(output: &str) -> HashSet<Function> {
185185
_ => {}
186186
};
187187
}
188+
188189
instructions.push(parts.join(" "));
190+
if matches!(&**instructions.last().unwrap(), "ret" | "retq") {
191+
cached_header = None;
192+
break;
193+
}
189194
}
190195
let function = Function {
191196
name: symbol,

‎crates/stdarch-test/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
119119
// it from the slightly more restrictive 22 instructions below.
120120
"cpuid" => 30,
121121

122+
// These require 8 loads and stores, so it _just_ overflows the limit
123+
"aesencwide128kl" | "aesencwide256kl" | "aesdecwide128kl" | "aesdecwide256kl" => 24,
124+
122125
// Apparently, on Windows, LLVM generates a bunch of
123126
// saves/restores of xmm registers around these instructions,
124127
// which exceeds the limit of 20 below. As it seems dictated by

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

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ fn verify_all_signatures() {
201201
"_xrstors",
202202
"_xsaves64",
203203
"_xrstors64",
204+
"_mm_loadiwkey",
204205
// RDRAND
205206
"_rdrand16_step",
206207
"_rdrand32_step",
@@ -448,6 +449,8 @@ fn check_target_features(rust: &Function, intel: &Intrinsic) -> Result<(), Strin
448449
// it "avx512ifma".
449450
"avx512ifma52" => String::from("avx512ifma"),
450451
"xss" => String::from("xsaves"),
452+
"keylocker" => String::from("kl"),
453+
"keylockerwide" => String::from("widekl"),
451454
_ => cpuid,
452455
};
453456

0 commit comments

Comments
 (0)
Please sign in to comment.