xref: /kvmtool/x86/include/kvm/kvm-arch.h (revision ae06ce7165bbb08080fcbf9bb026b16de1b3b685)
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 #define KVM_VIRTIO_MMIO_AREA	(KVM_MMIO_START + 0x2000000)
25 
26 #define VIRTIO_DEFAULT_TRANS	VIRTIO_PCI
27 
28 struct kvm_arch {
29 	u16			boot_selector;
30 	u16			boot_ip;
31 	u16			boot_sp;
32 
33 	struct interrupt_table	interrupt_table;
34 };
35 
36 static inline void *guest_flat_to_host(struct kvm *kvm, unsigned long offset); /* In kvm.h */
37 
38 static inline void *guest_real_to_host(struct kvm *kvm, u16 selector, u16 offset)
39 {
40 	unsigned long flat = segment_to_flat(selector, offset);
41 
42 	return guest_flat_to_host(kvm, flat);
43 }
44 
45 #endif /* KVM__KVM_ARCH_H */
46