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