diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-02-20 14:36:45 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-02-20 14:36:45 +0000 |
commit | 3bb4f99d8cec90c3d7731d004333dd03998e2287 (patch) | |
tree | 106e622cfc9218e44d1c25a29c3409172a55acb0 /xen/include | |
parent | 10d08139c54258700129aebe4193b86efdd94f13 (diff) | |
download | xen-3bb4f99d8cec90c3d7731d004333dd03998e2287.tar.gz xen-3bb4f99d8cec90c3d7731d004333dd03998e2287.tar.bz2 xen-3bb4f99d8cec90c3d7731d004333dd03998e2287.zip |
x86 hvm: Replace old MMIO emulator with x86_emulate()-based harness.
Re-factor VMX real-mode emulation to use the same harness.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/include')
-rw-r--r-- | xen/include/asm-x86/hvm/emulate.h | 55 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/hvm.h | 12 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/io.h | 18 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/support.h | 1 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vcpu.h | 9 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vmx/vmcs.h | 5 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vmx/vmx.h | 8 | ||||
-rw-r--r-- | xen/include/public/hvm/ioreq.h | 6 |
8 files changed, 80 insertions, 34 deletions
diff --git a/xen/include/asm-x86/hvm/emulate.h b/xen/include/asm-x86/hvm/emulate.h new file mode 100644 index 0000000000..f059bcdedf --- /dev/null +++ b/xen/include/asm-x86/hvm/emulate.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * hvm/emulate.h + * + * HVM instruction emulation. Used for MMIO and VMX real mode. + * + * Copyright (c) 2008 Citrix Systems, Inc. + * + * Authors: + * Keir Fraser <keir.fraser@citrix.com> + */ + +#ifndef __ASM_X86_HVM_EMULATE_H__ +#define __ASM_X86_HVM_EMULATE_H__ + +#include <xen/config.h> +#include <asm/x86_emulate.h> + +struct hvm_emulate_ctxt { + struct x86_emulate_ctxt ctxt; + + /* Cache of 16 bytes of instruction. */ + uint8_t insn_buf[16]; + unsigned long insn_buf_eip; + unsigned int insn_buf_bytes; + + struct segment_register seg_reg[10]; + unsigned long seg_reg_accessed; + unsigned long seg_reg_dirty; + + union { + struct { + unsigned int hlt:1; + unsigned int mov_ss:1; + unsigned int sti:1; + unsigned int exn_pending:1; + } flags; + unsigned int flag_word; + }; + + uint8_t exn_vector; + uint8_t exn_insn_len; +}; + +int hvm_emulate_one( + struct hvm_emulate_ctxt *hvmemul_ctxt); +void hvm_emulate_prepare( + struct hvm_emulate_ctxt *hvmemul_ctxt, + struct cpu_user_regs *regs); +void hvm_emulate_writeback( + struct hvm_emulate_ctxt *hvmemul_ctxt); +struct segment_register *hvmemul_get_seg_reg( + enum x86_segment seg, + struct hvm_emulate_ctxt *hvmemul_ctxt); + +#endif /* __ASM_X86_HVM_EMULATE_H__ */ diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index d04691ead6..ed56da054c 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -117,6 +117,15 @@ struct hvm_function_table { int (*cpu_up)(void); void (*cpu_down)(void); + + /* Instruction intercepts: non-void return values are X86EMUL codes. */ + void (*cpuid_intercept)( + unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx); + void (*wbinvd_intercept)(void); + void (*fpu_dirty_intercept)(void); + int (*msr_read_intercept)(struct cpu_user_regs *regs); + int (*msr_write_intercept)(struct cpu_user_regs *regs); }; extern struct hvm_function_table hvm_funcs; @@ -163,9 +172,6 @@ hvm_guest_x86_mode(struct vcpu *v) return hvm_funcs.guest_x86_mode(v); } -int hvm_instruction_fetch(unsigned long pc, int address_bytes, - unsigned char *buf); - static inline void hvm_update_host_cr3(struct vcpu *v) { diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h index 0b5197f3a7..863f460e23 100644 --- a/xen/include/asm-x86/hvm/io.h +++ b/xen/include/asm-x86/hvm/io.h @@ -120,8 +120,8 @@ struct hvm_mmio_handler { }; /* global io interception point in HV */ -extern int hvm_io_intercept(ioreq_t *p, int type); -extern int register_io_handler( +int hvm_io_intercept(ioreq_t *p, int type); +int register_io_handler( struct domain *d, unsigned long addr, unsigned long size, void *action, int type); @@ -135,8 +135,8 @@ static inline int hvm_buffered_io_intercept(ioreq_t *p) return hvm_io_intercept(p, HVM_BUFFERED_IO); } -extern int hvm_mmio_intercept(ioreq_t *p); -extern int hvm_buffered_io_send(ioreq_t *p); +int hvm_mmio_intercept(ioreq_t *p); +int hvm_buffered_io_send(ioreq_t *p); static inline int register_portio_handler( struct domain *d, unsigned long addr, @@ -159,11 +159,11 @@ void send_pio_req(unsigned long port, unsigned long count, int size, paddr_t value, int dir, int df, int value_is_ptr); void send_timeoffset_req(unsigned long timeoff); void send_invalidate_req(void); -extern void handle_mmio(paddr_t gpa); -extern void hvm_interrupt_post(struct vcpu *v, int vector, int type); -extern void hvm_io_assist(void); -extern void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq, - union vioapic_redir_entry *ent); +int handle_mmio(void); +void hvm_interrupt_post(struct vcpu *v, int vector, int type); +void hvm_io_assist(void); +void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq, + union vioapic_redir_entry *ent); struct hvm_hw_stdvga { uint8_t sr_index; diff --git a/xen/include/asm-x86/hvm/support.h b/xen/include/asm-x86/hvm/support.h index 48338f454b..d2da0e87c9 100644 --- a/xen/include/asm-x86/hvm/support.h +++ b/xen/include/asm-x86/hvm/support.h @@ -138,6 +138,7 @@ int hvm_do_hypercall(struct cpu_user_regs *pregs); void hvm_hlt(unsigned long rflags); void hvm_triple_fault(void); +/* These functions all return X86EMUL return codes. */ int hvm_set_efer(uint64_t value); int hvm_set_cr0(unsigned long value); int hvm_set_cr3(unsigned long value); diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index f6c55dba12..003b7f84b4 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -59,9 +59,6 @@ struct hvm_vcpu { bool_t flag_dr_dirty; bool_t debug_state_latch; - /* Callback function for I/O completion. */ - int (*io_complete)(void); - union { struct arch_vmx_struct vmx; struct arch_svm_struct svm; @@ -72,6 +69,12 @@ struct hvm_vcpu { /* Which cache mode is this VCPU in (CR0:CD/NW)? */ u8 cache_mode; + + /* I/O request in flight to device model. */ + bool_t mmio_in_progress; + bool_t io_in_progress; + bool_t io_completed; + unsigned long io_data; }; #define ARCH_HVM_IO_WAIT 1 /* Waiting for I/O completion */ diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h index e73cbad7e0..db69542a35 100644 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -94,11 +94,6 @@ struct arch_vmx_struct { #define VMXEMUL_BAD_CS 2 /* Yes, because CS.RPL != CPL */ #define VMXEMUL_BAD_SS 4 /* Yes, because SS.RPL != CPL */ uint8_t vmxemul; - - /* I/O request in flight to device model. */ - bool_t real_mode_io_in_progress; - bool_t real_mode_io_completed; - unsigned long real_mode_io_data; }; int vmx_create_vmcs(struct vcpu *v); diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index f15975a097..94e4168fd7 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -33,15 +33,7 @@ void vmx_intr_assist(void); void vmx_do_resume(struct vcpu *); void set_guest_time(struct vcpu *v, u64 gtime); void vmx_vlapic_msr_changed(struct vcpu *v); -void vmx_do_no_device_fault(void); -void vmx_cpuid_intercept( - unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx); -int vmx_msr_read_intercept(struct cpu_user_regs *regs); -int vmx_msr_write_intercept(struct cpu_user_regs *regs); -void vmx_wbinvd_intercept(void); void vmx_realmode(struct cpu_user_regs *regs); -int vmx_realmode_io_complete(void); /* * Exit Reasons diff --git a/xen/include/public/hvm/ioreq.h b/xen/include/public/hvm/ioreq.h index 91e7de5c26..5b6873074c 100644 --- a/xen/include/public/hvm/ioreq.h +++ b/xen/include/public/hvm/ioreq.h @@ -34,14 +34,8 @@ #define IOREQ_TYPE_PIO 0 /* pio */ #define IOREQ_TYPE_COPY 1 /* mmio ops */ -#define IOREQ_TYPE_AND 2 -#define IOREQ_TYPE_OR 3 -#define IOREQ_TYPE_XOR 4 -#define IOREQ_TYPE_XCHG 5 -#define IOREQ_TYPE_ADD 6 #define IOREQ_TYPE_TIMEOFFSET 7 #define IOREQ_TYPE_INVALIDATE 8 /* mapcache */ -#define IOREQ_TYPE_SUB 9 /* * VMExit dispatcher should cooperate with instruction decoder to |