unsigned int d;
int (*execute)(struct x86_emulate_ctxt *ctxt);
int (*check_perm)(struct x86_emulate_ctxt *ctxt);
- unsigned long regs[NR_VCPU_REGS];
- unsigned long eip;
/* modrm */
u8 modrm;
u8 modrm_mod;
u8 modrm_rm;
u8 modrm_seg;
bool rip_relative;
+ unsigned long eip;
+ /* Fields above regs are cleared together. */
+ unsigned long regs[NR_VCPU_REGS];
struct fetch_cache fetch;
struct read_cache io_read;
struct read_cache mem_read;
kvm_queue_exception(vcpu, ctxt->exception.vector);
}
+static void init_decode_cache(struct decode_cache *c,
+ const unsigned long *regs)
+{
+ memset(c, 0, offsetof(struct decode_cache, regs));
+ memcpy(c->regs, regs, sizeof(c->regs));
+
+ c->fetch.start = 0;
+ c->fetch.end = 0;
+ c->io_read.pos = 0;
+ c->io_read.end = 0;
+ c->mem_read.pos = 0;
+ c->mem_read.end = 0;
+}
+
static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
{
struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
X86EMUL_MODE_PROT16;
ctxt->guest_mode = is_guest_mode(vcpu);
- memset(c, 0, sizeof(struct decode_cache));
- memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
+ init_decode_cache(c, vcpu->arch.regs);
vcpu->arch.emulate_regs_need_sync_from_vcpu = false;
}