xref: /kvmtool/x86/include/kvm/kvm-arch.h (revision dfb2e45886be41bfb276d89c8effeb34613fa264)
1 #ifndef KVM__KVM_ARCH_H
2 #define KVM__KVM_ARCH_H
3 
4 #include "kvm/interrupt.h"
5 #include "kvm/segment.h"
6 
7 #include <stdbool.h>
8 #include <linux/types.h>
9 #include <time.h>
10 
11 /*
12  * The hole includes VESA framebuffer and PCI memory.
13  */
14 #define KVM_32BIT_MAX_MEM_SIZE  (1ULL << 32)
15 #define KVM_32BIT_GAP_SIZE	(768 << 20)
16 #define KVM_32BIT_GAP_START	(KVM_32BIT_MAX_MEM_SIZE - KVM_32BIT_GAP_SIZE)
17 
18 #define KVM_MMIO_START		KVM_32BIT_GAP_START
19 
20 /* This is the address that pci_get_io_space_block() starts allocating
21  * from.  Note that this is a PCI bus address (though same on x86).
22  */
23 #define KVM_PCI_MMIO_AREA	(KVM_MMIO_START + 0x1000000)
24 
25 struct kvm {
26 	int			sys_fd;		/* For system ioctls(), i.e. /dev/kvm */
27 	int			vm_fd;		/* For VM ioctls() */
28 	timer_t			timerid;	/* Posix timer for interrupts */
29 
30 	int			nrcpus;		/* Number of cpus to run */
31 
32 	u32			mem_slots;	/* for KVM_SET_USER_MEMORY_REGION */
33 
34 	u64			ram_size;
35 	void			*ram_start;
36 
37 	bool			nmi_disabled;
38 
39 	bool			single_step;
40 
41 	u16			boot_selector;
42 	u16			boot_ip;
43 	u16			boot_sp;
44 
45 	struct interrupt_table	interrupt_table;
46 
47 	const char		*vmlinux;
48 	struct disk_image       **disks;
49 	int                     nr_disks;
50 
51 	char			*name;
52 
53 	int			vm_state;
54 };
55 
56 static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset); /* In kvm.h */
57 
58 static inline void *guest_real_to_host(struct kvm *kvm, u16 selector, u16 offset)
59 {
60 	unsigned long flat = segment_to_flat(selector, offset);
61 
62 	return guest_flat_to_host(kvm, flat);
63 }
64 
65 #endif /* KVM__KVM_ARCH_H */
66