From e9aca99dd54eadbdb3e907d5ec5ccf2ca232fd3a Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Sat, 21 Sep 2024 14:25:20 +0200 Subject: [PATCH] Ignore XSTATE_BV when comparing XTEST XsaveArea --- crates/core_arch/src/x86/xsave.rs | 5 ++++- crates/core_arch/src/x86_64/xsave.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/core_arch/src/x86/xsave.rs b/crates/core_arch/src/x86/xsave.rs index 3d92145b8f..d555760133 100644 --- a/crates/core_arch/src/x86/xsave.rs +++ b/crates/core_arch/src/x86/xsave.rs @@ -187,7 +187,10 @@ mod tests { impl PartialEq for XsaveArea { fn eq(&self, other: &XsaveArea) -> bool { for i in 0..self.data.len() { - if self.data[i] != other.data[i] { + // Ignore XSTATE_BV (state-component bitmap) that occupies the first byte of the XSAVE Header + // (at offset 512 bytes from the start). The value may change, for more information see the following chapter: + // 13.7 OPERATION OF XSAVE - Intel® 64 and IA-32 Architectures Software Developer’s Manual. + if i != 512 && self.data[i] != other.data[i] { return false; } } diff --git a/crates/core_arch/src/x86_64/xsave.rs b/crates/core_arch/src/x86_64/xsave.rs index 2447029624..569054c431 100644 --- a/crates/core_arch/src/x86_64/xsave.rs +++ b/crates/core_arch/src/x86_64/xsave.rs @@ -151,7 +151,10 @@ mod tests { impl PartialEq for XsaveArea { fn eq(&self, other: &XsaveArea) -> bool { for i in 0..self.data.len() { - if self.data[i] != other.data[i] { + // Ignore XSTATE_BV (state-component bitmap) that occupies the first byte of the XSAVE Header + // (at offset 512 bytes from the start). The value may change, for more information see the following chapter: + // 13.7 OPERATION OF XSAVE - Intel® 64 and IA-32 Architectures Software Developer’s Manual. + if i != 512 && self.data[i] != other.data[i] { return false; } }