KVM: x86 emulator: Provide more callbacks for x86 emulator.
[pandora-kernel.git] / arch / x86 / include / asm / kvm_emulate.h
index 7a6f54f..f901467 100644 (file)
@@ -62,6 +62,15 @@ struct x86_emulate_ops {
        int (*read_std)(unsigned long addr, void *val,
                        unsigned int bytes, struct kvm_vcpu *vcpu, u32 *error);
 
+       /*
+        * write_std: Write bytes of standard (non-emulated/special) memory.
+        *            Used for descriptor writing.
+        *  @addr:  [IN ] Linear address to which to write.
+        *  @val:   [OUT] Value write to memory, zero-extended to 'u_long'.
+        *  @bytes: [IN ] Number of bytes to write to memory.
+        */
+       int (*write_std)(unsigned long addr, void *val,
+                        unsigned int bytes, struct kvm_vcpu *vcpu, u32 *error);
        /*
         * fetch: Read bytes of standard (non-emulated/special) memory.
         *        Used for instruction fetch.
@@ -108,7 +117,16 @@ struct x86_emulate_ops {
                                const void *new,
                                unsigned int bytes,
                                struct kvm_vcpu *vcpu);
-
+       bool (*get_cached_descriptor)(struct desc_struct *desc,
+                                     int seg, struct kvm_vcpu *vcpu);
+       void (*set_cached_descriptor)(struct desc_struct *desc,
+                                     int seg, struct kvm_vcpu *vcpu);
+       u16 (*get_segment_selector)(int seg, struct kvm_vcpu *vcpu);
+       void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu);
+       void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu);
+       ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu);
+       void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
+       int (*cpl)(struct kvm_vcpu *vcpu);
 };
 
 /* Type, address-of, and value of an instruction's operand. */
@@ -139,7 +157,7 @@ struct decode_cache {
        u8 seg_override;
        unsigned int d;
        unsigned long regs[NR_VCPU_REGS];
-       unsigned long eip, eip_orig;
+       unsigned long eip;
        /* modrm */
        u8 modrm;
        u8 modrm_mod;
@@ -153,14 +171,12 @@ struct decode_cache {
        struct fetch_cache fetch;
 };
 
-#define X86_SHADOW_INT_MOV_SS  1
-#define X86_SHADOW_INT_STI     2
-
 struct x86_emulate_ctxt {
        /* Register state before/after emulation. */
        struct kvm_vcpu *vcpu;
 
        unsigned long eflags;
+       unsigned long eip; /* eip before instruction emulation */
        /* Emulated execution mode, represented by an X86EMUL_MODE value. */
        int mode;
        u32 cs_base;