Skip to content

Commit bd39ef8

Browse files
marxinAmanieu
authored andcommitted
Ignore XSTATE_BV when comparing XTEST XsaveArea
1 parent 3408a8c commit bd39ef8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/core_arch/src/x86/xsave.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ mod tests {
187187
impl PartialEq<XsaveArea> for XsaveArea {
188188
fn eq(&self, other: &XsaveArea) -> bool {
189189
for i in 0..self.data.len() {
190-
if self.data[i] != other.data[i] {
190+
// Ignore XSTATE_BV (state-component bitmap) that occupies the first byte of the XSAVE Header
191+
// (at offset 512 bytes from the start). The value may change, for more information see the following chapter:
192+
// 13.7 OPERATION OF XSAVE - Intel® 64 and IA-32 Architectures Software Developer’s Manual.
193+
if i != 512 && self.data[i] != other.data[i] {
191194
return false;
192195
}
193196
}

crates/core_arch/src/x86_64/xsave.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ mod tests {
151151
impl PartialEq<XsaveArea> for XsaveArea {
152152
fn eq(&self, other: &XsaveArea) -> bool {
153153
for i in 0..self.data.len() {
154-
if self.data[i] != other.data[i] {
154+
// Ignore XSTATE_BV (state-component bitmap) that occupies the first byte of the XSAVE Header
155+
// (at offset 512 bytes from the start). The value may change, for more information see the following chapter:
156+
// 13.7 OPERATION OF XSAVE - Intel® 64 and IA-32 Architectures Software Developer’s Manual.
157+
if i != 512 && self.data[i] != other.data[i] {
155158
return false;
156159
}
157160
}

0 commit comments

Comments
 (0)