]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/x86/include/asm/vcpu.h
x86: Remove guest registers parameter from vcpu_reset
[jailhouse.git] / hypervisor / arch / x86 / include / asm / vcpu.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Valentine Sinitsyn, 2014
5  *
6  * Authors:
7  *  Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #ifndef _JAILHOUSE_ASM_VCPU_H
14 #define _JAILHOUSE_ASM_VCPU_H
15
16 #include <jailhouse/entry.h>
17 #include <jailhouse/cell-config.h>
18 #include <jailhouse/paging.h>
19 #include <jailhouse/types.h>
20 #include <asm/cell.h>
21 #include <asm/percpu.h>
22 #include <asm/processor.h>
23
24 #define X86_CR0_HOST_STATE \
25         (X86_CR0_PG | X86_CR0_WP | X86_CR0_NE | X86_CR0_ET | X86_CR0_TS | \
26          X86_CR0_MP | X86_CR0_PE)
27 #define X86_CR4_HOST_STATE      X86_CR4_PAE
28
29 struct vcpu_io_bitmap {
30         u8 *data;
31         u32 size;
32 };
33
34 struct vcpu_execution_state {
35         u64 efer;
36         u64 rflags;
37         u16 cs;
38         u64 rip;
39 };
40
41 struct vcpu_io_intercept {
42         u16 port;
43         unsigned int size;
44         bool in;
45         unsigned int inst_len;
46         bool rep_or_str;
47 };
48
49 struct vcpu_mmio_intercept {
50         u64 phys_addr;
51         bool is_write;
52 };
53
54 int vcpu_vendor_init(void);
55
56 int vcpu_cell_init(struct cell *cell);
57 int vcpu_vendor_cell_init(struct cell *cell);
58
59 int vcpu_map_memory_region(struct cell *cell,
60                            const struct jailhouse_memory *mem);
61 int vcpu_unmap_memory_region(struct cell *cell,
62                              const struct jailhouse_memory *mem);
63 void vcpu_cell_exit(struct cell *cell);
64 void vcpu_vendor_cell_exit(struct cell *cell);
65
66 int vcpu_init(struct per_cpu *cpu_data);
67 void vcpu_exit(struct per_cpu *cpu_data);
68
69 void __attribute__((noreturn)) vcpu_activate_vmm(struct per_cpu *cpu_data);
70 void __attribute__((noreturn))
71 vcpu_deactivate_vmm(union registers *guest_regs);
72
73 void vcpu_handle_exit(struct per_cpu *cpu_data);
74
75 void vcpu_park(void);
76
77 void vcpu_nmi_handler(void);
78
79 void vcpu_tlb_flush(void);
80
81 /*
82  * vcpu_map_inst() and vcpu_get_inst_bytes() contract:
83  *
84  * On input, *size gives the number of bytes to get.
85  * On output, *size is the number of bytes available.
86  *
87  * If the function fails (returns NULL), *size is undefined.
88  */
89
90 const u8 *vcpu_map_inst(const struct guest_paging_structures *pg_structs,
91                         unsigned long pc, unsigned int *size);
92
93 const u8 *vcpu_get_inst_bytes(const struct guest_paging_structures *pg_structs,
94                               unsigned long pc, unsigned int *size);
95
96 void vcpu_skip_emulated_instruction(unsigned int inst_len);
97
98 void vcpu_vendor_get_cell_io_bitmap(struct cell *cell,
99                                     struct vcpu_io_bitmap *out);
100
101 void vcpu_vendor_get_execution_state(struct vcpu_execution_state *x_state);
102 void vcpu_vendor_get_io_intercept(struct vcpu_io_intercept *io);
103 void vcpu_vendor_get_mmio_intercept(struct vcpu_mmio_intercept *mmio);
104
105 bool vcpu_get_guest_paging_structs(struct guest_paging_structures *pg_structs);
106
107 void vcpu_vendor_set_guest_pat(unsigned long val);
108
109 void vcpu_handle_hypercall(union registers *guest_regs);
110
111 bool vcpu_handle_io_access(union registers *guest_regs);
112 bool vcpu_handle_mmio_access(union registers *guest_regs);
113
114 bool vcpu_handle_msr_read(union registers *guest_regs);
115 bool vcpu_handle_msr_write(union registers *guest_regs);
116
117 bool vcpu_handle_xsetbv(union registers *guest_regs);
118
119 void vcpu_reset(void);
120
121 #endif