From c469580e6c9b83172ba58e8305c6e5c11acfe186 Mon Sep 17 00:00:00 2001 From: Matt Delco Date: Tue, 4 Feb 2020 16:01:55 -0800 Subject: crosvm: support kvm's hyper-v cpuid ioctl Kvm can emulate the hyper-v paravirt interface. Newer versions of kvm can advertise the features they support via an ioctl() that reports the cpuid leafs for this interface. This change adds some support for the ioctl() and plumbs it through the plugin interface so that plugins can determine the level of support available in kvm. BUG=b:144746965 TEST=Ran build_test on kernel that supports the ioctl. Added temporary code to print the cpuid leafs and verified that the output is as expected. Instrumented failure as expected from older kernels and verified that results still passed. Change-Id: I6cd7dade1793e4edb52b331d5b960685541f7ba3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2037919 Tested-by: Matt Delco Tested-by: kokoro Reviewed-by: Daniel Verkamp Commit-Queue: Matt Delco --- src/plugin/vcpu.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/plugin/vcpu.rs') diff --git a/src/plugin/vcpu.rs b/src/plugin/vcpu.rs index c623bda..6bae9c4 100644 --- a/src/plugin/vcpu.rs +++ b/src/plugin/vcpu.rs @@ -595,6 +595,17 @@ impl PluginVcpu { response.mut_set_state(); let set_state = request.get_set_state(); set_vcpu_state(vcpu, set_state.set, set_state.get_state()) + } else if request.has_get_hyperv_cpuid() { + let cpuid_response = &mut response.mut_get_hyperv_cpuid().entries; + match vcpu.get_hyperv_cpuid() { + Ok(mut cpuid) => { + for entry in cpuid.mut_entries_slice() { + cpuid_response.push(cpuid_kvm_to_proto(entry)); + } + Ok(()) + } + Err(e) => Err(e), + } } else if request.has_get_msrs() { let entry_data = &mut response.mut_get_msrs().entry_data; let entry_indices = &request.get_get_msrs().entry_indices; -- cgit 1.4.1