lcd-domains-arch.h 2.4 KB
Newer Older
1 2 3
#ifndef LCD_VMX_H
#define LCD_VMX_H

4
#include <asm/vmx.h>
5 6 7
#include <linux/spinlock.h>

struct lcd_vmx_vmcs_config {
8 9 10
	int size;
	int order;
	u32 revision_id;
11 12 13 14 15
	u32 pin_based_exec_controls;
	u32 primary_proc_based_exec_controls;
	u32 secondary_proc_based_exec_controls;
	u32 vmexit_controls;
	u32 vmentry_controls;
16 17 18 19 20 21 22 23 24 25 26 27 28
};

struct lcd_vmx_vmcs {
	u32 revision_id;
	u32 abort;
	char data[0];
};

struct lcd_vmx_capability {
	u32 ept;
	u32 vpid;
};

29
int lcd_vmx_autoload_msrs[] = {
30
	/* NONE */
31 32
};
#define LCD_VMX_NUM_AUTOLOAD_MSRS 0
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

enum lcd_vmx_reg {
	LCD_VMX_REGS_RAX = 0,
	LCD_VMX_REGS_RCX = 1,
	LCD_VMX_REGS_RDX = 2,
	LCD_VMX_REGS_RBX = 3,
	LCD_VMX_REGS_RSP = 4,
	LCD_VMX_REGS_RBP = 5,
	LCD_VMX_REGS_RSI = 6,
	LCD_VMX_REGS_RDI = 7,
	LCD_VMX_REGS_R8 = 8,
	LCD_VMX_REGS_R9 = 9,
	LCD_VMX_REGS_R10 = 10,
	LCD_VMX_REGS_R11 = 11,
	LCD_VMX_REGS_R12 = 12,
	LCD_VMX_REGS_R13 = 13,
	LCD_VMX_REGS_R14 = 14,
	LCD_VMX_REGS_R15 = 15,
	LCD_VMX_REGS_RIP,
	LCD_VMX_NUM_REGS
};

55 56 57 58
#define LCD_VMX_CS_SELECTOR 1
#define LCD_VMX_FS_SELECTOR 2
#define LCD_VMX_GS_SELECTOR 3

59
struct lcd_vmx_ept {
60 61 62 63
	spinlock_t lock;
	unsigned long root_hpa;
	unsigned long vmcs_ptr;
	bool access_dirty_enabled;
64 65 66 67 68
};

struct lcd_vmx {
	int cpu;
	int launched;
69 70
	int vpid;
	struct lcd_vmx_vmcs *vmcs;
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	struct lcd_vmx_ept ept;
	struct desc_struct *gdt;

	u8  fail;
	u64 exit_reason;
	u64 exit_qualification;
	u32 idt_vectoring_info;
	u32 exit_intr_info;
	u32 error_code;
	u32 vec_no;
	u64 host_rsp;
	u64 regs[LCD_VMX_NUM_REGS];
	u64 cr2;
	int shutdown;
	int ret_code;

	struct msr_autoload {
88
#if LCD_VMX_NUM_AUTOLOAD_MSRS > 0
89 90
		struct vmx_msr_entry guest[LCD_VMX_NUM_AUTOLOAD_MSRS];
		struct vmx_msr_entry host[LCD_VMX_NUM_AUTOLOAD_MSRS];
91 92 93 94
#else
		struct vmx_msr_entry *guest;
		struct vmx_msr_entry *host;
#endif
95 96 97
	} msr_autoload;
};

98 99 100 101
/**
 * Initializes the arch-dependent code for LCD (detects required
 * features, turns on VMX on *all* cpu's).
 */
102
int lcd_vmx_init(void);
103 104 105 106 107 108
/**
 * Turns off VMX on *all* cpu's and tears down arch-dependent code.
 * 
 * Important: All LCDs should be destroyed before calling this
 * routine (otherwise, memory will leak).
 */
109
void lcd_vmx_exit(void);
110 111 112 113
/**
 * Creates the arch-dependent part of an LCD, and initializes 
 * the settings and most register values.
 */
114
struct lcd_vmx *lcd_vmx_create(void);
115 116 117 118 119
/**
 * Tears down arch-dep part of LCD. (If LCD is launched on
 * some cpu, it will become inactive.)
 */
void lcd_vmx_destroy(struct lcd_vmx *vcpu);
120

121
#endif  /* LCD_VMX_H */