Skip to content

Commit f8a3d70

Browse files
authored
Merge pull request #275 from rust-osdev/flags-breaking
Rename XCr0 and CR4 flags
2 parents b56649d + b8acbda commit f8a3d70

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/registers/control.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ bitflags! {
143143
///
144144
/// Also enables access to the PKRU register (via the `RDPKRU`/`WRPKRU`
145145
/// instructions) to set user-mode protection key access controls.
146+
const PROTECTION_KEY_USER = 1 << 22;
147+
/// Alias for [`PROTECTION_KEY_USER`](Cr4Flags::PROTECTION_KEY_USER)
148+
#[deprecated(since = "0.14.5", note = "use `PROTECTION_KEY_USER` instead")]
146149
const PROTECTION_KEY = 1 << 22;
147150
/// Enables Control-flow Enforcement Technology (CET)
148151
///

src/registers/xcontrol.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ bitflags! {
1919
/// Enables using MXCSR and the XMM registers
2020
/// with `XSAVE`/`XRSTOR`.
2121
///
22-
/// Must be set if [`YMM`](XCr0Flags::YMM) is set.
23-
const SSE = 1<<1;
24-
/// Enables AVX instructions and using the upper halves of the YMM registers
22+
/// Must be set if [`AVX`](XCr0Flags::AVX) is set.
23+
const SSE = 1 << 1;
24+
/// Enables AVX instructions and using the upper halves of the AVX registers
2525
/// with `XSAVE`/`XRSTOR`.
26+
const AVX = 1 << 2;
27+
/// Alias for [`AVX`](XCr0Flags::AVX)
28+
#[deprecated(since = "0.14.5", note = "use `AVX` instead")]
2629
const YMM = 1<<2;
2730
/// Enables MPX instructions and using the BND0-BND3 bound registers
2831
/// with `XSAVE`/`XRSTOR` (Intel Only).
@@ -95,10 +98,10 @@ mod x86_64 {
9598
let new_value = reserved | flags.bits();
9699

97100
assert!(flags.contains(XCr0Flags::X87), "The X87 flag must be set");
98-
if flags.contains(XCr0Flags::YMM) {
101+
if flags.contains(XCr0Flags::AVX) {
99102
assert!(
100103
flags.contains(XCr0Flags::SSE),
101-
"AVX/YMM cannot be enabled without enabling SSE"
104+
"AVX cannot be enabled without enabling SSE"
102105
);
103106
}
104107
let mpx = XCr0Flags::BNDREG | XCr0Flags::BNDCSR;
@@ -111,8 +114,8 @@ mod x86_64 {
111114
let avx512 = XCr0Flags::OPMASK | XCr0Flags::ZMM_HI256 | XCr0Flags::HI16_ZMM;
112115
if flags.intersects(avx512) {
113116
assert!(
114-
flags.contains(XCr0Flags::YMM),
115-
"AVX-512 cannot be enabled without enabling AVX/YMM"
117+
flags.contains(XCr0Flags::AVX),
118+
"AVX-512 cannot be enabled without enabling AVX"
116119
);
117120
assert!(
118121
flags.contains(avx512),

0 commit comments

Comments
 (0)