diff options
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 4 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 7 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 12 |
4 files changed, 13 insertions, 12 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 69a64a6a36f4..c37296d0e909 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -137,6 +137,8 @@ struct x86_emulate_ops { | |||
137 | void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); | 137 | void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); |
138 | int (*cpl)(struct kvm_vcpu *vcpu); | 138 | int (*cpl)(struct kvm_vcpu *vcpu); |
139 | void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); | 139 | void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); |
140 | int (*get_dr)(int dr, unsigned long *dest, struct kvm_vcpu *vcpu); | ||
141 | int (*set_dr)(int dr, unsigned long value, struct kvm_vcpu *vcpu); | ||
140 | }; | 142 | }; |
141 | 143 | ||
142 | /* Type, address-of, and value of an instruction's operand. */ | 144 | /* Type, address-of, and value of an instruction's operand. */ |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 76f5483cffec..97774ae3c874 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -591,10 +591,6 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu); | |||
591 | int kvm_emulate_halt(struct kvm_vcpu *vcpu); | 591 | int kvm_emulate_halt(struct kvm_vcpu *vcpu); |
592 | int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address); | 592 | int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address); |
593 | int emulate_clts(struct kvm_vcpu *vcpu); | 593 | int emulate_clts(struct kvm_vcpu *vcpu); |
594 | int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, | ||
595 | unsigned long *dest); | ||
596 | int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, | ||
597 | unsigned long value); | ||
598 | 594 | ||
599 | void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); | 595 | void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); |
600 | int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg); | 596 | int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg); |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 687ea0906b79..8a4aa73ff1e4 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -3132,7 +3132,7 @@ twobyte_insn: | |||
3132 | kvm_queue_exception(ctxt->vcpu, UD_VECTOR); | 3132 | kvm_queue_exception(ctxt->vcpu, UD_VECTOR); |
3133 | goto done; | 3133 | goto done; |
3134 | } | 3134 | } |
3135 | emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm]); | 3135 | ops->get_dr(c->modrm_reg, &c->regs[c->modrm_rm], ctxt->vcpu); |
3136 | c->dst.type = OP_NONE; /* no writeback */ | 3136 | c->dst.type = OP_NONE; /* no writeback */ |
3137 | break; | 3137 | break; |
3138 | case 0x22: /* mov reg, cr */ | 3138 | case 0x22: /* mov reg, cr */ |
@@ -3145,7 +3145,10 @@ twobyte_insn: | |||
3145 | kvm_queue_exception(ctxt->vcpu, UD_VECTOR); | 3145 | kvm_queue_exception(ctxt->vcpu, UD_VECTOR); |
3146 | goto done; | 3146 | goto done; |
3147 | } | 3147 | } |
3148 | emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm]); | 3148 | |
3149 | ops->set_dr(c->modrm_reg,c->regs[c->modrm_rm] & | ||
3150 | ((ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U), | ||
3151 | ctxt->vcpu); | ||
3149 | c->dst.type = OP_NONE; /* no writeback */ | 3152 | c->dst.type = OP_NONE; /* no writeback */ |
3150 | break; | 3153 | break; |
3151 | case 0x30: | 3154 | case 0x30: |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 801afc6461ed..059d63de169b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3620,16 +3620,14 @@ int emulate_clts(struct kvm_vcpu *vcpu) | |||
3620 | return X86EMUL_CONTINUE; | 3620 | return X86EMUL_CONTINUE; |
3621 | } | 3621 | } |
3622 | 3622 | ||
3623 | int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest) | 3623 | int emulator_get_dr(int dr, unsigned long *dest, struct kvm_vcpu *vcpu) |
3624 | { | 3624 | { |
3625 | return kvm_get_dr(ctxt->vcpu, dr, dest); | 3625 | return kvm_get_dr(vcpu, dr, dest); |
3626 | } | 3626 | } |
3627 | 3627 | ||
3628 | int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value) | 3628 | int emulator_set_dr(int dr, unsigned long value, struct kvm_vcpu *vcpu) |
3629 | { | 3629 | { |
3630 | unsigned long mask = (ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U; | 3630 | return kvm_set_dr(vcpu, dr, value); |
3631 | |||
3632 | return kvm_set_dr(ctxt->vcpu, dr, value & mask); | ||
3633 | } | 3631 | } |
3634 | 3632 | ||
3635 | void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context) | 3633 | void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context) |
@@ -3811,6 +3809,8 @@ static struct x86_emulate_ops emulate_ops = { | |||
3811 | .set_cr = emulator_set_cr, | 3809 | .set_cr = emulator_set_cr, |
3812 | .cpl = emulator_get_cpl, | 3810 | .cpl = emulator_get_cpl, |
3813 | .set_rflags = emulator_set_rflags, | 3811 | .set_rflags = emulator_set_rflags, |
3812 | .get_dr = emulator_get_dr, | ||
3813 | .set_dr = emulator_set_dr, | ||
3814 | }; | 3814 | }; |
3815 | 3815 | ||
3816 | static void cache_all_regs(struct kvm_vcpu *vcpu) | 3816 | static void cache_all_regs(struct kvm_vcpu *vcpu) |