Skip to content

Commit

Permalink
Merge pull request #275 from rust-osdev/flags-breaking
Browse files Browse the repository at this point in the history
Rename XCr0 and CR4 flags
  • Loading branch information
josephlr authored Aug 2, 2021
2 parents b56649d + b8acbda commit f8a3d70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/registers/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ bitflags! {
///
/// Also enables access to the PKRU register (via the `RDPKRU`/`WRPKRU`
/// instructions) to set user-mode protection key access controls.
const PROTECTION_KEY_USER = 1 << 22;
/// Alias for [`PROTECTION_KEY_USER`](Cr4Flags::PROTECTION_KEY_USER)
#[deprecated(since = "0.14.5", note = "use `PROTECTION_KEY_USER` instead")]
const PROTECTION_KEY = 1 << 22;
/// Enables Control-flow Enforcement Technology (CET)
///
Expand Down
17 changes: 10 additions & 7 deletions src/registers/xcontrol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ bitflags! {
/// Enables using MXCSR and the XMM registers
/// with `XSAVE`/`XRSTOR`.
///
/// Must be set if [`YMM`](XCr0Flags::YMM) is set.
const SSE = 1<<1;
/// Enables AVX instructions and using the upper halves of the YMM registers
/// Must be set if [`AVX`](XCr0Flags::AVX) is set.
const SSE = 1 << 1;
/// Enables AVX instructions and using the upper halves of the AVX registers
/// with `XSAVE`/`XRSTOR`.
const AVX = 1 << 2;
/// Alias for [`AVX`](XCr0Flags::AVX)
#[deprecated(since = "0.14.5", note = "use `AVX` instead")]
const YMM = 1<<2;
/// Enables MPX instructions and using the BND0-BND3 bound registers
/// with `XSAVE`/`XRSTOR` (Intel Only).
Expand Down Expand Up @@ -95,10 +98,10 @@ mod x86_64 {
let new_value = reserved | flags.bits();

assert!(flags.contains(XCr0Flags::X87), "The X87 flag must be set");
if flags.contains(XCr0Flags::YMM) {
if flags.contains(XCr0Flags::AVX) {
assert!(
flags.contains(XCr0Flags::SSE),
"AVX/YMM cannot be enabled without enabling SSE"
"AVX cannot be enabled without enabling SSE"
);
}
let mpx = XCr0Flags::BNDREG | XCr0Flags::BNDCSR;
Expand All @@ -111,8 +114,8 @@ mod x86_64 {
let avx512 = XCr0Flags::OPMASK | XCr0Flags::ZMM_HI256 | XCr0Flags::HI16_ZMM;
if flags.intersects(avx512) {
assert!(
flags.contains(XCr0Flags::YMM),
"AVX-512 cannot be enabled without enabling AVX/YMM"
flags.contains(XCr0Flags::AVX),
"AVX-512 cannot be enabled without enabling AVX"
);
assert!(
flags.contains(avx512),
Expand Down

0 comments on commit f8a3d70

Please sign in to comment.