diff options
author | Avi Kivity <avi@redhat.com> | 2010-08-18 07:51:45 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:51:12 -0400 |
commit | 0ef753b8c323f5b8d75d7dc57ceef6b35982afdb (patch) | |
tree | 194e86a361fb9b541ddd6e0dfd0eb3260330d959 /arch/x86/kvm/emulate.c | |
parent | 7af04fc05cc185869271927eb470de3d25064b4a (diff) |
KVM: x86 emulator: implement CALL FAR (FF /3)
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 83ded7c03d12..313357793968 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -2214,6 +2214,40 @@ static int em_das(struct x86_emulate_ctxt *ctxt) | |||
2214 | return X86EMUL_CONTINUE; | 2214 | return X86EMUL_CONTINUE; |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | static int em_call_far(struct x86_emulate_ctxt *ctxt) | ||
2218 | { | ||
2219 | struct decode_cache *c = &ctxt->decode; | ||
2220 | u16 sel, old_cs; | ||
2221 | ulong old_eip; | ||
2222 | int rc; | ||
2223 | |||
2224 | old_cs = ctxt->ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu); | ||
2225 | old_eip = c->eip; | ||
2226 | |||
2227 | memcpy(&sel, c->src.valptr + c->op_bytes, 2); | ||
2228 | if (load_segment_descriptor(ctxt, ctxt->ops, sel, VCPU_SREG_CS)) | ||
2229 | return X86EMUL_CONTINUE; | ||
2230 | |||
2231 | c->eip = 0; | ||
2232 | memcpy(&c->eip, c->src.valptr, c->op_bytes); | ||
2233 | |||
2234 | c->src.val = old_cs; | ||
2235 | emulate_push(ctxt, ctxt->ops); | ||
2236 | rc = writeback(ctxt, ctxt->ops); | ||
2237 | if (rc != X86EMUL_CONTINUE) | ||
2238 | return rc; | ||
2239 | |||
2240 | c->src.val = old_eip; | ||
2241 | emulate_push(ctxt, ctxt->ops); | ||
2242 | rc = writeback(ctxt, ctxt->ops); | ||
2243 | if (rc != X86EMUL_CONTINUE) | ||
2244 | return rc; | ||
2245 | |||
2246 | c->dst.type = OP_NONE; | ||
2247 | |||
2248 | return X86EMUL_CONTINUE; | ||
2249 | } | ||
2250 | |||
2217 | #define D(_y) { .flags = (_y) } | 2251 | #define D(_y) { .flags = (_y) } |
2218 | #define N D(0) | 2252 | #define N D(0) |
2219 | #define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } | 2253 | #define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } |
@@ -2241,7 +2275,8 @@ static struct opcode group4[] = { | |||
2241 | 2275 | ||
2242 | static struct opcode group5[] = { | 2276 | static struct opcode group5[] = { |
2243 | D(DstMem | SrcNone | ModRM | Lock), D(DstMem | SrcNone | ModRM | Lock), | 2277 | D(DstMem | SrcNone | ModRM | Lock), D(DstMem | SrcNone | ModRM | Lock), |
2244 | D(SrcMem | ModRM | Stack), N, | 2278 | D(SrcMem | ModRM | Stack), |
2279 | I(SrcMemFAddr | ModRM | ImplicitOps | Stack, em_call_far), | ||
2245 | D(SrcMem | ModRM | Stack), D(SrcMemFAddr | ModRM | ImplicitOps), | 2280 | D(SrcMem | ModRM | Stack), D(SrcMemFAddr | ModRM | ImplicitOps), |
2246 | D(SrcMem | ModRM | Stack), N, | 2281 | D(SrcMem | ModRM | Stack), N, |
2247 | }; | 2282 | }; |