summary refs log tree commit diff
path: root/kvm/src/lib.rs
diff options
context:
space:
mode:
authorSonny Rao <sonnyrao@chromium.org>2018-03-27 16:30:51 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-03 12:50:39 -0700
commita7fae252b05b617fd27f58b9bba8122d18154ccb (patch)
treedda93c135a6df228f813e02003925b839a0be87c /kvm/src/lib.rs
parent2ffa0cbe5bb41beea81fd2d14a7f781747bb955e (diff)
downloadcrosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar.gz
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar.bz2
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar.lz
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar.xz
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.tar.zst
crosvm-a7fae252b05b617fd27f58b9bba8122d18154ccb.zip
crosvm: aarch64: get kernel's preferred target type for vcpus
This fixes an issue on kevin where if we start on a little core, the
kernel doesn't like the generic ARMv8 target cpu type for some reason.  To
fix this we must query the preferred type from the vm device first and
supply that to the vcpu init ioctl.

We need to change the signature of the configure_vcpu method to pass
in the vm object even though we aren't using it on x86.

BUG=chromium:797868
TEST=./build_test passes on all architectures
TEST=crosvm runs on kevin

Change-Id: I460cb9db62a8805bb88f838956aa4f1c69183961
Reviewed-on: https://chromium-review.googlesource.com/982996
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'kvm/src/lib.rs')
-rw-r--r--kvm/src/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index a76c018..5f321f2 100644
--- a/kvm/src/lib.rs
+++ b/kvm/src/lib.rs
@@ -718,6 +718,21 @@ impl Vm {
             errno_result()
         }
     }
+
+    /// This queries the kernel for the preferred target CPU type.
+    #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
+    pub fn arm_preferred_target(&self, kvi: &mut kvm_vcpu_init) -> Result<()> {
+        // The ioctl is safe because we allocated the struct and we know the
+        // kernel will write exactly the size of the struct.
+        let ret = unsafe {
+            ioctl_with_mut_ref(self, KVM_ARM_PREFERRED_TARGET(), kvi)
+        };
+        if ret < 0 {
+            return errno_result();
+        }
+        Ok(())
+    }
+
 }
 
 impl AsRawFd for Vm {