diff options
Diffstat (limited to 'arch/x86/include/asm/kvm_emulate.h')
| -rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 0b2729bf207..51cfd730ac5 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
| @@ -51,8 +51,10 @@ struct x86_emulate_ctxt; | |||
| 51 | #define X86EMUL_UNHANDLEABLE 1 | 51 | #define X86EMUL_UNHANDLEABLE 1 |
| 52 | /* Terminate emulation but return success to the caller. */ | 52 | /* Terminate emulation but return success to the caller. */ |
| 53 | #define X86EMUL_PROPAGATE_FAULT 2 /* propagate a generated fault to guest */ | 53 | #define X86EMUL_PROPAGATE_FAULT 2 /* propagate a generated fault to guest */ |
| 54 | #define X86EMUL_RETRY_INSTR 2 /* retry the instruction for some reason */ | 54 | #define X86EMUL_RETRY_INSTR 3 /* retry the instruction for some reason */ |
| 55 | #define X86EMUL_CMPXCHG_FAILED 2 /* cmpxchg did not see expected value */ | 55 | #define X86EMUL_CMPXCHG_FAILED 4 /* cmpxchg did not see expected value */ |
| 56 | #define X86EMUL_IO_NEEDED 5 /* IO is needed to complete emulation */ | ||
| 57 | |||
| 56 | struct x86_emulate_ops { | 58 | struct x86_emulate_ops { |
| 57 | /* | 59 | /* |
| 58 | * read_std: Read bytes of standard (non-emulated/special) memory. | 60 | * read_std: Read bytes of standard (non-emulated/special) memory. |
| @@ -92,6 +94,7 @@ struct x86_emulate_ops { | |||
| 92 | int (*read_emulated)(unsigned long addr, | 94 | int (*read_emulated)(unsigned long addr, |
| 93 | void *val, | 95 | void *val, |
| 94 | unsigned int bytes, | 96 | unsigned int bytes, |
| 97 | unsigned int *error, | ||
| 95 | struct kvm_vcpu *vcpu); | 98 | struct kvm_vcpu *vcpu); |
| 96 | 99 | ||
| 97 | /* | 100 | /* |
| @@ -104,6 +107,7 @@ struct x86_emulate_ops { | |||
| 104 | int (*write_emulated)(unsigned long addr, | 107 | int (*write_emulated)(unsigned long addr, |
| 105 | const void *val, | 108 | const void *val, |
| 106 | unsigned int bytes, | 109 | unsigned int bytes, |
| 110 | unsigned int *error, | ||
| 107 | struct kvm_vcpu *vcpu); | 111 | struct kvm_vcpu *vcpu); |
| 108 | 112 | ||
| 109 | /* | 113 | /* |
| @@ -118,6 +122,7 @@ struct x86_emulate_ops { | |||
| 118 | const void *old, | 122 | const void *old, |
| 119 | const void *new, | 123 | const void *new, |
| 120 | unsigned int bytes, | 124 | unsigned int bytes, |
| 125 | unsigned int *error, | ||
| 121 | struct kvm_vcpu *vcpu); | 126 | struct kvm_vcpu *vcpu); |
| 122 | 127 | ||
| 123 | int (*pio_in_emulated)(int size, unsigned short port, void *val, | 128 | int (*pio_in_emulated)(int size, unsigned short port, void *val, |
| @@ -132,18 +137,26 @@ struct x86_emulate_ops { | |||
| 132 | int seg, struct kvm_vcpu *vcpu); | 137 | int seg, struct kvm_vcpu *vcpu); |
| 133 | u16 (*get_segment_selector)(int seg, struct kvm_vcpu *vcpu); | 138 | u16 (*get_segment_selector)(int seg, struct kvm_vcpu *vcpu); |
| 134 | void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu); | 139 | void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu); |
| 140 | unsigned long (*get_cached_segment_base)(int seg, struct kvm_vcpu *vcpu); | ||
| 135 | void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu); | 141 | void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu); |
| 136 | ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu); | 142 | ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu); |
| 137 | void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); | 143 | int (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); |
| 138 | int (*cpl)(struct kvm_vcpu *vcpu); | 144 | int (*cpl)(struct kvm_vcpu *vcpu); |
| 139 | void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); | 145 | int (*get_dr)(int dr, unsigned long *dest, struct kvm_vcpu *vcpu); |
| 146 | int (*set_dr)(int dr, unsigned long value, struct kvm_vcpu *vcpu); | ||
| 147 | int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data); | ||
| 148 | int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata); | ||
| 140 | }; | 149 | }; |
| 141 | 150 | ||
| 142 | /* Type, address-of, and value of an instruction's operand. */ | 151 | /* Type, address-of, and value of an instruction's operand. */ |
| 143 | struct operand { | 152 | struct operand { |
| 144 | enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type; | 153 | enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type; |
| 145 | unsigned int bytes; | 154 | unsigned int bytes; |
| 146 | unsigned long val, orig_val, *ptr; | 155 | unsigned long orig_val, *ptr; |
| 156 | union { | ||
| 157 | unsigned long val; | ||
| 158 | char valptr[sizeof(unsigned long) + 2]; | ||
| 159 | }; | ||
| 147 | }; | 160 | }; |
| 148 | 161 | ||
| 149 | struct fetch_cache { | 162 | struct fetch_cache { |
| @@ -186,6 +199,7 @@ struct decode_cache { | |||
| 186 | unsigned long modrm_val; | 199 | unsigned long modrm_val; |
| 187 | struct fetch_cache fetch; | 200 | struct fetch_cache fetch; |
| 188 | struct read_cache io_read; | 201 | struct read_cache io_read; |
| 202 | struct read_cache mem_read; | ||
| 189 | }; | 203 | }; |
| 190 | 204 | ||
| 191 | struct x86_emulate_ctxt { | 205 | struct x86_emulate_ctxt { |
| @@ -202,6 +216,12 @@ struct x86_emulate_ctxt { | |||
| 202 | int interruptibility; | 216 | int interruptibility; |
| 203 | 217 | ||
| 204 | bool restart; /* restart string instruction after writeback */ | 218 | bool restart; /* restart string instruction after writeback */ |
| 219 | |||
| 220 | int exception; /* exception that happens during emulation or -1 */ | ||
| 221 | u32 error_code; /* error code for exception */ | ||
| 222 | bool error_code_valid; | ||
| 223 | unsigned long cr2; /* faulted address in case of #PF */ | ||
| 224 | |||
| 205 | /* decode cache */ | 225 | /* decode cache */ |
| 206 | struct decode_cache decode; | 226 | struct decode_cache decode; |
| 207 | }; | 227 | }; |
