Skip to content

Commit 25441e6

Browse files
dianpopaacatangiu
authored andcommitted
kvm_sys: remove unused code...
* arm related code * unused ioctls * misplaced code * syscall_defines crate Signed-off-by: Diana Popa <[email protected]>
1 parent d3aeac0 commit 25441e6

File tree

11 files changed

+12
-7595
lines changed

11 files changed

+12
-7595
lines changed

kvm/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ impl CpuId {
685685
mod tests {
686686
use super::*;
687687

688+
//as per https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/fpu/internal.h
689+
pub const KVM_FPU_CWD: usize = 0x37f;
690+
pub const KVM_FPU_MXCSR: usize = 0x1f80;
691+
688692
//kvm system related function tests
689693
#[test]
690694
fn new() {

kvm_sys/src/arm/bindings.rs

Lines changed: 0 additions & 6010 deletions
This file was deleted.

kvm_sys/src/lib.rs

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,154 +9,54 @@
99
#[macro_use]
1010
extern crate sys_util;
1111

12-
// Somehow this one gets missed by bindgen
13-
pub const KVM_EXIT_IO_OUT: ::std::os::raw::c_uint = 1;
14-
15-
// Each of the below modules defines ioctls specific to their platform.
12+
// Each of the below modules defines ioctls specific to their platform (currently, x86 and x86_64).
1613

1714
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
1815
pub mod x86 {
19-
// generated with bindgen /usr/include/linux/kvm.h --no-unstable-rust --constified-enum '*' --with-derive-default
16+
// generated with:
17+
// bindgen include/uapi/linux/kvm.h -o bindings.rs
18+
// --no-rustfmt-bindings
19+
// --with-derive-default
20+
// -- -Iinclude -Iarch/x86/include/
2021
pub mod bindings;
2122
pub use bindings::*;
2223

23-
//as per https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/fpu/internal.h
24-
pub const KVM_FPU_CWD: usize = 0x37f;
25-
pub const KVM_FPU_MXCSR: usize = 0x1f80;
26-
27-
ioctl_iowr_nr!(KVM_GET_MSR_INDEX_LIST, KVMIO, 0x02, kvm_msr_list);
2824
ioctl_iowr_nr!(KVM_GET_SUPPORTED_CPUID, KVMIO, 0x05, kvm_cpuid2);
29-
ioctl_iowr_nr!(KVM_GET_EMULATED_CPUID, KVMIO, 0x09, kvm_cpuid2);
30-
ioctl_iow_nr!(KVM_SET_MEMORY_ALIAS, KVMIO, 0x43, kvm_memory_alias);
31-
ioctl_iow_nr!(KVM_XEN_HVM_CONFIG, KVMIO, 0x7a, kvm_xen_hvm_config);
32-
ioctl_ior_nr!(KVM_GET_PIT2, KVMIO, 0x9f, kvm_pit_state2);
33-
ioctl_iow_nr!(KVM_SET_PIT2, KVMIO, 0xa0, kvm_pit_state2);
3425
ioctl_iowr_nr!(KVM_GET_MSRS, KVMIO, 0x88, kvm_msrs);
3526
ioctl_iow_nr!(KVM_SET_MSRS, KVMIO, 0x89, kvm_msrs);
36-
ioctl_iow_nr!(KVM_SET_CPUID, KVMIO, 0x8a, kvm_cpuid);
3727
ioctl_ior_nr!(KVM_GET_LAPIC, KVMIO, 0x8e, kvm_lapic_state);
3828
ioctl_iow_nr!(KVM_SET_LAPIC, KVMIO, 0x8f, kvm_lapic_state);
3929
ioctl_iow_nr!(KVM_SET_CPUID2, KVMIO, 0x90, kvm_cpuid2);
30+
// we do use KVM_SET_CPUID2, however KVM_GET_CPUID2 is never used
31+
// should be used to unit test the SET!!!
4032
ioctl_iowr_nr!(KVM_GET_CPUID2, KVMIO, 0x91, kvm_cpuid2);
41-
ioctl_iow_nr!(KVM_X86_SETUP_MCE, KVMIO, 0x9c, __u64);
42-
ioctl_ior_nr!(KVM_X86_GET_MCE_CAP_SUPPORTED, KVMIO, 0x9d, __u64);
43-
ioctl_iow_nr!(KVM_X86_SET_MCE, KVMIO, 0x9e, kvm_x86_mce);
44-
ioctl_ior_nr!(KVM_GET_VCPU_EVENTS, KVMIO, 0x9f, kvm_vcpu_events);
45-
ioctl_iow_nr!(KVM_SET_VCPU_EVENTS, KVMIO, 0xa0, kvm_vcpu_events);
46-
ioctl_ior_nr!(KVM_GET_DEBUGREGS, KVMIO, 0xa1, kvm_debugregs);
47-
ioctl_iow_nr!(KVM_SET_DEBUGREGS, KVMIO, 0xa2, kvm_debugregs);
48-
ioctl_ior_nr!(KVM_GET_XSAVE, KVMIO, 0xa4, kvm_xsave);
49-
ioctl_iow_nr!(KVM_SET_XSAVE, KVMIO, 0xa5, kvm_xsave);
50-
ioctl_ior_nr!(KVM_GET_XCRS, KVMIO, 0xa6, kvm_xcrs);
51-
ioctl_iowr_nr!(KVM_SET_XCRS, KVMIO, 0xa7, kvm_xcrs);
52-
}
53-
54-
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
55-
pub mod arm {
56-
// generated with bindgen <arm sysroot>/usr/include/linux/kvm.h --no-unstable-rust --constified-enum '*' --with-derive-default -- -I<arm sysroot>/usr/include
57-
pub mod bindings;
58-
pub use bindings::*;
59-
60-
ioctl_iow_nr!(KVM_ARM_SET_DEVICE_ADDR, KVMIO, 0xab, kvm_arm_device_addr);
61-
ioctl_iow_nr!(KVM_ARM_VCPU_INIT, KVMIO, 0xae, kvm_vcpu_init);
62-
ioctl_ior_nr!(KVM_ARM_PREFERRED_TARGET, KVMIO, 0xaf, kvm_vcpu_init);
6333
}
6434

6535
// These ioctls are commonly defined on all/multiple platforms.
6636
ioctl_io_nr!(KVM_GET_API_VERSION, KVMIO, 0x00);
6737
ioctl_io_nr!(KVM_CREATE_VM, KVMIO, 0x01);
6838
ioctl_io_nr!(KVM_CHECK_EXTENSION, KVMIO, 0x03);
6939
ioctl_io_nr!(KVM_GET_VCPU_MMAP_SIZE, KVMIO, 0x04);
70-
ioctl_iow_nr!(KVM_SET_MEMORY_REGION, KVMIO, 0x40, kvm_memory_region);
7140
ioctl_io_nr!(KVM_CREATE_VCPU, KVMIO, 0x41);
72-
ioctl_iow_nr!(KVM_GET_DIRTY_LOG, KVMIO, 0x42, kvm_dirty_log);
73-
ioctl_io_nr!(KVM_SET_NR_MMU_PAGES, KVMIO, 0x44);
74-
ioctl_io_nr!(KVM_GET_NR_MMU_PAGES, KVMIO, 0x45);
7541
ioctl_iow_nr!(
7642
KVM_SET_USER_MEMORY_REGION,
7743
KVMIO,
7844
0x46,
7945
kvm_userspace_memory_region
8046
);
8147
ioctl_io_nr!(KVM_SET_TSS_ADDR, KVMIO, 0x47);
82-
ioctl_iow_nr!(KVM_SET_IDENTITY_MAP_ADDR, KVMIO, 0x48, __u64);
8348
ioctl_io_nr!(KVM_CREATE_IRQCHIP, KVMIO, 0x60);
84-
ioctl_iow_nr!(KVM_IRQ_LINE, KVMIO, 0x61, kvm_irq_level);
85-
ioctl_iowr_nr!(KVM_GET_IRQCHIP, KVMIO, 0x62, kvm_irqchip);
86-
ioctl_ior_nr!(KVM_SET_IRQCHIP, KVMIO, 0x63, kvm_irqchip);
87-
ioctl_io_nr!(KVM_CREATE_PIT, KVMIO, 0x64);
88-
ioctl_iowr_nr!(KVM_IRQ_LINE_STATUS, KVMIO, 0x67, kvm_irq_level);
89-
ioctl_iow_nr!(
90-
KVM_REGISTER_COALESCED_MMIO,
91-
KVMIO,
92-
0x67,
93-
kvm_coalesced_mmio_zone
94-
);
95-
ioctl_iow_nr!(
96-
KVM_UNREGISTER_COALESCED_MMIO,
97-
KVMIO,
98-
0x68,
99-
kvm_coalesced_mmio_zone
100-
);
101-
ioctl_ior_nr!(KVM_ASSIGN_PCI_DEVICE, KVMIO, 0x69, kvm_assigned_pci_dev);
102-
ioctl_iow_nr!(KVM_ASSIGN_DEV_IRQ, KVMIO, 0x70, kvm_assigned_irq);
103-
ioctl_io_nr!(KVM_REINJECT_CONTROL, KVMIO, 0x71);
104-
ioctl_iow_nr!(KVM_DEASSIGN_PCI_DEVICE, KVMIO, 0x72, kvm_assigned_pci_dev);
105-
ioctl_iow_nr!(KVM_ASSIGN_SET_MSIX_NR, KVMIO, 0x73, kvm_assigned_msix_nr);
106-
ioctl_iow_nr!(
107-
KVM_ASSIGN_SET_MSIX_ENTRY,
108-
KVMIO,
109-
0x74,
110-
kvm_assigned_msix_entry
111-
);
112-
ioctl_iow_nr!(KVM_DEASSIGN_DEV_IRQ, KVMIO, 0x75, kvm_assigned_irq);
11349
ioctl_iow_nr!(KVM_IRQFD, KVMIO, 0x76, kvm_irqfd);
11450
ioctl_iow_nr!(KVM_CREATE_PIT2, KVMIO, 0x77, kvm_pit_config);
115-
ioctl_io_nr!(KVM_SET_BOOT_CPU_ID, KVMIO, 0x78);
11651
ioctl_iow_nr!(KVM_IOEVENTFD, KVMIO, 0x79, kvm_ioeventfd);
117-
ioctl_iow_nr!(KVM_SET_CLOCK, KVMIO, 0x7b, kvm_clock_data);
118-
ioctl_ior_nr!(KVM_GET_CLOCK, KVMIO, 0x7c, kvm_clock_data);
119-
ioctl_io_nr!(KVM_SET_TSC_KHZ, KVMIO, 0xa2);
120-
ioctl_io_nr!(KVM_GET_TSC_KHZ, KVMIO, 0xa3);
121-
ioctl_iow_nr!(KVM_ASSIGN_SET_INTX_MASK, KVMIO, 0xa4, kvm_assigned_pci_dev);
122-
ioctl_iow_nr!(KVM_SIGNAL_MSI, KVMIO, 0xa5, kvm_msi);
123-
ioctl_iowr_nr!(KVM_CREATE_DEVICE, KVMIO, 0xe0, kvm_create_device);
124-
ioctl_iow_nr!(KVM_SET_DEVICE_ATTR, KVMIO, 0xe1, kvm_device_attr);
125-
ioctl_iow_nr!(KVM_GET_DEVICE_ATTR, KVMIO, 0xe2, kvm_device_attr);
126-
ioctl_iow_nr!(KVM_HAS_DEVICE_ATTR, KVMIO, 0xe3, kvm_device_attr);
12752
ioctl_io_nr!(KVM_RUN, KVMIO, 0x80);
128-
// The following two ioctls are commonly defined but specifically excluded
129-
// from arm platforms.
130-
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
13153
ioctl_ior_nr!(KVM_GET_REGS, KVMIO, 0x81, kvm_regs);
132-
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
13354
ioctl_iow_nr!(KVM_SET_REGS, KVMIO, 0x82, kvm_regs);
13455
ioctl_ior_nr!(KVM_GET_SREGS, KVMIO, 0x83, kvm_sregs);
13556
ioctl_iow_nr!(KVM_SET_SREGS, KVMIO, 0x84, kvm_sregs);
136-
ioctl_iowr_nr!(KVM_TRANSLATE, KVMIO, 0x85, kvm_translation);
137-
ioctl_iow_nr!(KVM_INTERRUPT, KVMIO, 0x86, kvm_interrupt);
138-
ioctl_iow_nr!(KVM_SET_SIGNAL_MASK, KVMIO, 0x8b, kvm_signal_mask);
13957
ioctl_ior_nr!(KVM_GET_FPU, KVMIO, 0x8c, kvm_fpu);
14058
ioctl_iow_nr!(KVM_SET_FPU, KVMIO, 0x8d, kvm_fpu);
141-
ioctl_iowr_nr!(KVM_TPR_ACCESS_REPORTING, KVMIO, 0x92, kvm_tpr_access_ctl);
142-
ioctl_iow_nr!(KVM_SET_VAPIC_ADDR, KVMIO, 0x93, kvm_vapic_addr);
143-
ioctl_ior_nr!(KVM_GET_MP_STATE, KVMIO, 0x98, kvm_mp_state);
144-
ioctl_iow_nr!(KVM_SET_MP_STATE, KVMIO, 0x99, kvm_mp_state);
145-
ioctl_io_nr!(KVM_NMI, KVMIO, 0x9a);
146-
ioctl_iow_nr!(KVM_SET_GUEST_DEBUG, KVMIO, 0x9b, kvm_guest_debug);
147-
ioctl_iow_nr!(KVM_ENABLE_CAP, KVMIO, 0xa3, kvm_enable_cap);
148-
ioctl_iow_nr!(KVM_DIRTY_TLB, KVMIO, 0xaa, kvm_dirty_tlb);
149-
ioctl_iow_nr!(KVM_GET_ONE_REG, KVMIO, 0xab, kvm_one_reg);
150-
ioctl_iow_nr!(KVM_SET_ONE_REG, KVMIO, 0xac, kvm_one_reg);
151-
ioctl_io_nr!(KVM_KVMCLOCK_CTRL, KVMIO, 0xad);
152-
ioctl_iowr_nr!(KVM_GET_REG_LIST, KVMIO, 0xb0, kvm_reg_list);
153-
ioctl_io_nr!(KVM_SMI, KVMIO, 0xb7);
15459

15560
// Along with the common ioctls, we reexport the ioctls of the current
15661
// platform.
157-
158-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
15962
pub use x86::*;
160-
161-
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
162-
pub use arm::*;

sys_util/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ authors = ["The Chromium OS Authors"]
66
[dependencies]
77
libc = ">=0.2.39"
88

9-
syscall_defines = { path = "../syscall_defines" }
109
memory_model = { path = "../memory_model"}
1110

12-
[build-dependencies]
13-
gcc = "=0.3.54"

sys_util/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
extern crate libc;
88
extern crate memory_model;
9-
extern crate syscall_defines;
109

1110
#[macro_use]
1211
pub mod ioctl;

syscall_defines/Cargo.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

syscall_defines/src/lib.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)