From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCHv2 06/23] KVM: x86 emulator: add (set|get)_dr callbacks to x86_emulate_ops
Date: Wed, 28 Apr 2010 19:15:27 +0300 [thread overview]
Message-ID: <1272471344-7076-7-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1272471344-7076-1-git-send-email-gleb@redhat.com>
Add (set|get)_dr callbacks to x86_emulate_ops instead of calling
them directly.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/include/asm/kvm_emulate.h | 2 ++
arch/x86/include/asm/kvm_host.h | 4 ----
arch/x86/kvm/emulate.c | 7 +++++--
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 69a64a6..c37296d 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 {
void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
int (*cpl)(struct kvm_vcpu *vcpu);
void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
+ int (*get_dr)(int dr, unsigned long *dest, struct kvm_vcpu *vcpu);
+ int (*set_dr)(int dr, unsigned long value, struct kvm_vcpu *vcpu);
};
/* 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 3f0007b..74cb6ac 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -590,10 +590,6 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu);
int kvm_emulate_halt(struct kvm_vcpu *vcpu);
int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address);
int emulate_clts(struct kvm_vcpu *vcpu);
-int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr,
- unsigned long *dest);
-int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr,
- unsigned long value);
void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg);
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 9b19838..c54f381 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3132,7 +3132,7 @@ twobyte_insn:
kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
goto done;
}
- emulator_get_dr(ctxt, c->modrm_reg, &c->regs[c->modrm_rm]);
+ ops->get_dr(c->modrm_reg, &c->regs[c->modrm_rm], ctxt->vcpu);
c->dst.type = OP_NONE; /* no writeback */
break;
case 0x22: /* mov reg, cr */
@@ -3145,7 +3145,10 @@ twobyte_insn:
kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
goto done;
}
- emulator_set_dr(ctxt, c->modrm_reg, c->regs[c->modrm_rm]);
+
+ ops->set_dr(c->modrm_reg,c->regs[c->modrm_rm] &
+ ((ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U),
+ ctxt->vcpu);
c->dst.type = OP_NONE; /* no writeback */
break;
case 0x30:
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6b2ce1d..c0d6e4c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3558,16 +3558,14 @@ int emulate_clts(struct kvm_vcpu *vcpu)
return X86EMUL_CONTINUE;
}
-int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest)
+int emulator_get_dr(int dr, unsigned long *dest, struct kvm_vcpu *vcpu)
{
- return kvm_get_dr(ctxt->vcpu, dr, dest);
+ return kvm_get_dr(vcpu, dr, dest);
}
-int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
+int emulator_set_dr(int dr, unsigned long value, struct kvm_vcpu *vcpu)
{
- unsigned long mask = (ctxt->mode == X86EMUL_MODE_PROT64) ? ~0ULL : ~0U;
-
- return kvm_set_dr(ctxt->vcpu, dr, value & mask);
+ return kvm_set_dr(vcpu, dr, value);
}
void kvm_report_emulation_failure(struct kvm_vcpu *vcpu, const char *context)
@@ -3749,6 +3747,8 @@ static struct x86_emulate_ops emulate_ops = {
.set_cr = emulator_set_cr,
.cpl = emulator_get_cpl,
.set_rflags = emulator_set_rflags,
+ .get_dr = emulator_get_dr,
+ .set_dr = emulator_set_dr,
};
static void cache_all_regs(struct kvm_vcpu *vcpu)
--
1.6.5
next prev parent reply other threads:[~2010-04-28 16:15 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 16:15 [PATCHv2 00/23] next round of emulator cleanups Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 01/23] KVM: x86 emulator: introduce read cache Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 02/23] KVM: x86 emulator: fix Move r/m16 to segment register decoding Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 03/23] KVM: x86 emulator: cleanup xchg emulation Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 04/23] KVM: x86 emulator: cleanup nop emulation Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 05/23] KVM: x86 emulator: handle "far address" source operand Gleb Natapov
2010-04-28 16:15 ` Gleb Natapov [this message]
2010-04-28 16:15 ` [PATCHv2 07/23] KVM: x86 emulator: add (set|get)_msr callbacks to x86_emulate_ops Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 08/23] KVM: x86 emulator: add get_cached_segment_base() callback " Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 09/23] KVM: x86 emulator: cleanup some direct calls into kvm to use existing callbacks Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 10/23] KVM: x86 emulator: make set_cr() callback return error if it fails Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 11/23] KVM: x86 emulator: make (get|set)_dr() " Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 12/23] KVM: x86 emulator: fix X86EMUL_RETRY_INSTR and X86EMUL_CMPXCHG_FAILED values Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 13/23] KVM: fill in run->mmio details in (read|write)_emulated function Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 14/23] KVM: x86 emulator: x86_emulate_insn() return -1 only in case of emulation failure Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 15/23] KVM: remove export of emulator_write_emulated() Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 16/23] KVM: do not inject #PF in (read|write)_emulated() callbacks Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 17/23] KVM: handle emulation failure case first Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 18/23] KVM: x86 emulator: advance RIP outside x86 emulator code Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 19/23] KVM: x86 emulator: set RFLAGS " Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 20/23] KVM: x86 emulator: use shadowed register in emulate_sysexit() Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 21/23] KVM: x86 exmulator: handle shadowed registers outside emulator Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 22/23] KVM: x86 emulator: move interruptibility state tracking out of emulator Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 23/23] KVM: x86 emulator: do not inject exception directly into vcpu Gleb Natapov
[not found] ` <446597.86519.qm@web55502.mail.re4.yahoo.com>
2010-04-29 10:17 ` qemu-kvm.0.12.2 aborts on linux Gleb Natapov
[not found] ` <792291.45224.qm@web55507.mail.re4.yahoo.com>
2010-05-02 5:23 ` Gleb Natapov
[not found] ` <710443.70603.qm@web55504.mail.re4.yahoo.com>
2010-05-03 7:44 ` Gleb Natapov
2010-04-29 9:26 ` [PATCHv2 00/23] next round of emulator cleanups Avi Kivity
2010-05-05 7:57 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272471344-7076-7-git-send-email-gleb@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox