diff options
Diffstat (limited to 'crosvm_plugin')
-rw-r--r-- | crosvm_plugin/crosvm.h | 19 | ||||
-rw-r--r-- | crosvm_plugin/src/lib.rs | 39 |
2 files changed, 57 insertions, 1 deletions
diff --git a/crosvm_plugin/crosvm.h b/crosvm_plugin/crosvm.h index ef7759d..db824b9 100644 --- a/crosvm_plugin/crosvm.h +++ b/crosvm_plugin/crosvm.h @@ -47,7 +47,7 @@ extern "C" { * do not indicate anything about what version of crosvm is running. */ #define CROSVM_API_MAJOR 0 -#define CROSVM_API_MINOR 20 +#define CROSVM_API_MINOR 21 #define CROSVM_API_PATCH 0 enum crosvm_address_space { @@ -115,6 +115,14 @@ int crosvm_check_extension(struct crosvm*, uint32_t __extension, bool *has_extension); /* + * Enable an extended capability for the VM. Currently |__flags| and + * |__args| must be zero. No values for |__capability| are supported, + * so all calls will fail. + */ +int crosvm_enable_capability(struct crosvm*, uint32_t __capability, + uint32_t __flags, uint64_t __args[4]); + +/* * Queries x86 cpuid features which are supported by the hardware and * kvm. */ @@ -633,6 +641,15 @@ int crosvm_vcpu_set_msrs(struct crosvm_vcpu*, uint32_t __msr_count, int crosvm_vcpu_set_cpuid(struct crosvm_vcpu*, uint32_t __cpuid_count, const struct kvm_cpuid_entry2 *__cpuid_entries); +/* + * Enable an extended capability for a vcpu. Currently |__flags| and + * |__args| must be zero. The only permitted values for |__capability| + * are KVM_CAP_HYPERV_SYNIC or KVM_CAP_HYPERV_SYNIC2, though the latter + * also depends on kernel support. + */ +int crosvm_vcpu_enable_capability(struct crosvm_vcpu*, uint32_t __capability, + uint32_t __flags, uint64_t __args[4]); + /* Gets state of LAPIC of the VCPU. */ int crosvm_vcpu_get_lapic_state(struct crosvm_vcpu *, struct kvm_lapic_state *__lapic_state); diff --git a/crosvm_plugin/src/lib.rs b/crosvm_plugin/src/lib.rs index 13b3d9f..8695d41 100644 --- a/crosvm_plugin/src/lib.rs +++ b/crosvm_plugin/src/lib.rs @@ -166,6 +166,8 @@ pub enum Stat { DestroyConnection, GetShutdownEventFd, CheckExtentsion, + EnableVmCapability, + EnableVcpuCapability, GetSupportedCpuid, GetEmulatedCpuid, GetHypervCpuid, @@ -1289,6 +1291,13 @@ impl crosvm_vcpu { self.vcpu_transaction(&r)?; Ok(()) } + + fn enable_capability(&mut self, capability: u32) -> result::Result<(), c_int> { + let mut r = VcpuRequest::new(); + r.mut_enable_capability().capability = capability; + self.vcpu_transaction(&r)?; + Ok(()) + } } // crosvm API signals success as 0 and errors as negative values @@ -1371,6 +1380,17 @@ pub unsafe extern "C" fn crosvm_check_extension( } #[no_mangle] +pub unsafe extern "C" fn crosvm_enable_capability( + _self_: *mut crosvm, + _capability: u32, + _flags: u32, + _args: *const u64, +) -> c_int { + let _u = record(Stat::EnableVmCapability); + -EINVAL +} + +#[no_mangle] pub unsafe extern "C" fn crosvm_get_supported_cpuid( this: *mut crosvm, entry_count: u32, @@ -1896,6 +1916,25 @@ pub unsafe extern "C" fn crosvm_vcpu_set_cpuid( } #[no_mangle] +pub unsafe extern "C" fn crosvm_vcpu_enable_capability( + this: *mut crosvm_vcpu, + capability: u32, + flags: u32, + args: *const u64, +) -> c_int { + let _u = record(Stat::EnableVcpuCapability); + let this = &mut *this; + let args = slice::from_raw_parts(args, 4); + + if flags != 0 || args.iter().any(|v| *v != 0) { + return -EINVAL; + } + + let ret = this.enable_capability(capability); + to_crosvm_rc(ret) +} + +#[no_mangle] pub unsafe extern "C" fn crosvm_vcpu_get_lapic_state( this: *mut crosvm_vcpu, state: *mut kvm_lapic_state, |