From 10668e6387dc1d0764314cb6dea237516aa9c140 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 16 May 2018 11:06:27 -0700 Subject: [PATCH] kvm: fix test for getting and setting xcrs The extension condition was reversed, also SSE is not enabled by default in guest VCPU, so limit the test to setting the FP bit. BUG=b:79692549 TEST=cargo test -p kvm Change-Id: I2959fe7dfff79703777d6254deae817fea892b00 Signed-off-by: Dmitry Torokhov Reviewed-on: https://chromium-review.googlesource.com/1062645 Reviewed-by: Zach Reizner --- kvm/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index 2fdac4354d..adac9fb9ed 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -1587,7 +1587,7 @@ mod tests { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn xcrs() { let kvm = Kvm::new().unwrap(); - if kvm.check_extension(Cap::Xcrs) { + if !kvm.check_extension(Cap::Xcrs) { return; } @@ -1595,10 +1595,7 @@ mod tests { let vm = Vm::new(&kvm, gm).unwrap(); let vcpu = Vcpu::new(0, &kvm, &vm).unwrap(); let mut xcrs = vcpu.get_xcrs().unwrap(); - xcrs.nr_xcrs = 1; - xcrs.flags = 0; - // We assume anything we run on has SSE (bit 1). FP bit (bit 0) must always be set. - xcrs.xcrs[0].value |= 3; + xcrs.xcrs[0].value = 1; vcpu.set_xcrs(&xcrs).unwrap(); let xcrs2 = vcpu.get_xcrs().unwrap(); assert_eq!(xcrs.xcrs[0].value, xcrs2.xcrs[0].value);