-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkvm-structs.h
More file actions
45 lines (38 loc) · 901 Bytes
/
Copy pathkvm-structs.h
File metadata and controls
45 lines (38 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef KVM_STRUCTS
#define KVM_STRUCTS
#include <stddef.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>
#define MAX_VCPUFD 20
#define KVM_DEVICE "/dev/kvm"
struct kvm_ctx {
struct kvm_userspace_memory_region guest_memory_region;
void * mmio_region_addr;
size_t mmio_size;
size_t um_size;
int cpufd[MAX_VCPUFD];
int kvmfd;
int vmfd;
};
#define CR4_PAE (1U << 5)
#define EFER_LME (1U << 8)
#define EFER_LMA (1U << 10)
/* CR0 bits */
#define CR0_PE (1U << 0)
#define CR0_MP (1U << 1)
#define CR0_ET (1U << 4)
#define CR0_NE (1U << 5)
#define CR0_WP (1U << 16)
#define CR0_AM (1U << 18)
#define CR0_PG (1U << 31)
/* Page Table Flags */
#define PTE_PRESENT (1ULL << 0)
#define PTE_RW (1ULL << 1)
#define PTE_USER (1ULL << 2)
#define PTE_PAGE_SIZE 0x1000
#endif