return c->seg_override;
}
-static ulong linear(struct x86_emulate_ctxt *ctxt,
- struct segmented_address addr)
+static int linearize(struct x86_emulate_ctxt *ctxt,
+ struct segmented_address addr,
+ ulong *linear)
{
struct decode_cache *c = &ctxt->decode;
ulong la;
la = seg_base(ctxt, ctxt->ops, addr.seg) + addr.ea;
if (c->ad_bytes != 8)
la &= (u32)-1;
- return la;
+ *linear = la;
+ return X86EMUL_CONTINUE;
}
static int emulate_exception(struct x86_emulate_ctxt *ctxt, int vec,
void *data,
unsigned size)
{
- return ctxt->ops->read_std(linear(ctxt, addr), data, size, ctxt->vcpu,
+ int rc;
+ ulong linear;
+
+ rc = linearize(ctxt, addr, &linear);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;
+ return ctxt->ops->read_std(linear, data, size, ctxt->vcpu,
&ctxt->exception);
}
void *data,
unsigned size)
{
- return read_emulated(ctxt, ctxt->ops, linear(ctxt, addr), data, size);
+ int rc;
+ ulong linear;
+
+ rc = linearize(ctxt, addr, &linear);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;
+ return read_emulated(ctxt, ctxt->ops, linear, data, size);
}
static int segmented_write(struct x86_emulate_ctxt *ctxt,
const void *data,
unsigned size)
{
- return ctxt->ops->write_emulated(linear(ctxt, addr), data, size,
+ int rc;
+ ulong linear;
+
+ rc = linearize(ctxt, addr, &linear);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;
+ return ctxt->ops->write_emulated(linear, data, size,
&ctxt->exception, ctxt->vcpu);
}
const void *orig_data, const void *data,
unsigned size)
{
- return ctxt->ops->cmpxchg_emulated(linear(ctxt, addr), orig_data, data,
+ int rc;
+ ulong linear;
+
+ rc = linearize(ctxt, addr, &linear);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;
+ return ctxt->ops->cmpxchg_emulated(linear, orig_data, data,
size, &ctxt->exception, ctxt->vcpu);
}
static int em_invlpg(struct x86_emulate_ctxt *ctxt)
{
struct decode_cache *c = &ctxt->decode;
- emulate_invlpg(ctxt->vcpu, linear(ctxt, c->src.addr.mem));
+ int rc;
+ ulong linear;
+
+ rc = linearize(ctxt, c->src.addr.mem, &linear);
+ if (rc == X86EMUL_CONTINUE)
+ emulate_invlpg(ctxt->vcpu, linear);
/* Disable writeback. */
c->dst.type = OP_NONE;
return X86EMUL_CONTINUE;