(big) real mode emulation - mov rl/rh/r
PATCH 1/1 (big) real mode emulation - mov rl/rh/r
Hi Avi,
Attached is the patch to implement emulation of instructions mov rl, imm8 (opcodes 0xb0-0xb3)
mov rh, imm8 (opcodes 0xb4-0xb7)
mov r, imm (opcodes0xb8-0xbf)
please apply.
Signature · 5 lines
Thanks & Regards, Nitin Open Source Technology Center, Intel Corporation ----------------------------------------------------------------- The mind is like a parachute; it works much better when it's open
From 6d23ef752e157c5eff60531d8470b6102376be2b Mon Sep 17 00:00:00 2001
From: Nitin A Kamble <[email protected]>
Date: Tue, 30 Oct 2007 19:38:49 -0800
Subject: [PATCH] Implement emulation of instructions: mov rl/rh/r
mov rl, imm8 (opcodes: 0xb0 ... 0xb3)
mov rh, imm8 (opcodes: 0xb4 ... 0xb7)
mov r, imm (opcodes: 0xb8 ... 0xbf)--- drivers/kvm/x86_emulate.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-)
drivers/kvm/x86_emulate.c +26 -2
@@ -146,8 +146,12 @@ static u16 opcode_table[256] = {0 ,0 , ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps, ImplicitOps, -/* 0xB0 - 0xBF */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0xB0 - 0xB7 */ + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, +/* 0xB8 - 0xBF */ + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm,/* 0xC0 - 0xC7 */ ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, 0, ImplicitOps, 0, 0,
@@ -1407,6 +1411,26 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) case 0xa2 ... 0xa3: /* mov */ c->dst.val = (unsigned long )c->regs[VCPU_REGS_RAX ];break ; + case 0xb0 ... 0xb3: /* mov rl, imm8 */ + c->dst.ptr = + (unsigned long *)&c->regs[VCPU_REGS_RAX + (c->b &0x3 )]; + c->dst.val = c->src.val; + c->dst.type =OP_REG ; + c->dst.bytes =1 ; +break ; + case 0xb4 ... 0xb7: /* mov rh, imm8 */ + c->dst.ptr = + ((void *)&c->regs[VCPU_REGS_RAX + (c->b &0x3 )] +1 ); + c->dst.val = c->src.val; + c->dst.type =OP_REG ; + c->dst.bytes =1 ; +break ; + case 0xb8 ... 0xbf: /* mov r, imm */ + c->dst.ptr = + (unsigned long *)&c->regs[VCPU_REGS_RAX + (c->b &0x7 )]; + c->dst.val = c->src.val; + c->dst.type =OP_REG ; +break ; case 0xc0 ... 0xc1:emulate_grp2 (ctxt);break ;
Signature · 1 line
1.5.2.2
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Quoted 12 lines · Nitin A Kamble
Hi Avi,
Attached is the patch to implement emulation of instructions mov rl, imm8 (opcodes 0xb0-0xb3)
mov rh, imm8 (opcodes 0xb4-0xb7)
mov r, imm (opcodes0xb8-0xbf)drivers/kvm/x86_emulate.c +0
-1@@ -146,8 +146,12 @@ static u16 opcode_table[256] = {0 ,0 , ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps, ImplicitOps, -/* 0xB0 - 0xBF */
drivers/kvm/x86_emulate.c static u16 opcode_table[256] = { · line 157
Quoted 10 lines
drivers/kvm/x86_emulate.c +6
-1-0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0xB0 - 0xB7 */ + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, +/* 0xB8 - 0xBF */ + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, /* 0xC0 - 0xC7 */
Perhaps adding DstReg would reduce the decoding code later on?
Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Quoted 17 lines · Avi Kivity
Quoted 16 lines · Nitin A Kamble
Hi Avi,
Attached is the patch to implement emulation of instructions mov rl, imm8 (opcodes 0xb0-0xb3)
mov rh, imm8 (opcodes 0xb4-0xb7)
mov r, imm (opcodes0xb8-0xbf)drivers/kvm/x86_emulate.c +2
-2@@ -146,8 +146,12 @@ static u16 opcode_table[256] = {0 ,0 , ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps, ImplicitOps, -/* 0xB0 - 0xBF */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0xB0 - 0xB7 */ + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte,
Quoted 8 lines
drivers/kvm/x86_emulate.c static u16 opcode_table[256] = { · line 155
Quoted 6 lines
drivers/kvm/x86_emulate.c +4
-0+ Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, +/* 0xB8 - 0xBF */ + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, /* 0xC0 - 0xC7 */Perhaps adding DstReg would reduce the decoding code later on?
Avi,
The decoding of register is significantly different for these instructions. It will be just moving code from one place to other place.
+ c->dst.ptr =
+ (unsigned long *)&c->regs[VCPU_REGS_RAX + (c->b
& 0x3)];
+ c->dst.ptr =
+ ((void *)&c->regs[VCPU_REGS_RAX + (c->b & 0x3)]
+ 1);
+ c->dst.ptr =
+ (unsigned long *)&c->regs[VCPU_REGS_RAX + (c->b
& 0x7)];
Quoted 4 lines
--
Any sufficiently difficult bug is indistinguishable from a feature.
Signature · 5 lines
Thanks & Regards, Nitin Open Source Technology Center, Intel Corporation ----------------------------------------------------------------- The mind is like a parachute; it works much better when it's open
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Quoted 30 lines · Nitin A Kamble
Quoted 18 lines · Avi Kivity
Quoted 16 lines · Nitin A Kamble
Hi Avi,
Attached is the patch to implement emulation of instructions mov rl, imm8 (opcodes 0xb0-0xb3)
mov rh, imm8 (opcodes 0xb4-0xb7)
mov r, imm (opcodes0xb8-0xbf)drivers/kvm/x86_emulate.c +2
-2@@ -146,8 +146,12 @@ static u16 opcode_table[256] = {0 ,0 , ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps, ImplicitOps, -/* 0xB0 - 0xBF */ -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0xB0 - 0xB7 */ + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte,Quoted 9 lines
drivers/kvm/x86_emulate.c static u16 opcode_table[256] = { · line 155
Quoted 7 lines
drivers/kvm/x86_emulate.c +4
-0+ Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, +/* 0xB8 - 0xBF */ + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, /* 0xC0 - 0xC7 */Perhaps adding DstReg would reduce the decoding code later on?
Quoted 5 lines
Avi,
The decoding of register is significantly different for these instructions. It will be just moving code from one place to other place.
Right.
But perhaps we can have a ShortReg modifier to make the decoding common. There are several instructions which can use this (inc, dec, xchg, push, mov).
I'll look into this.
Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Quoted 37 lines · Avi Kivity
Quoted 30 lines · Nitin A Kamble
Quoted 18 lines · Avi Kivity
Quoted 16 lines · Nitin A Kamble
Hi Avi,
Attached is the patch to implement emulation of instructions mov rl, imm8 (opcodes 0xb0-0xb3)
mov rh, imm8 (opcodes 0xb4-0xb7)
mov r, imm (opcodes0xb8-0xbf)(quoted diff) +2
-2@@ -146,8 +146,12 @@ static u16 opcode_table[256] = { 0, 0, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps | Mov, ImplicitOps | Mov, ByteOp | ImplicitOps, ImplicitOps, - /* 0xB0 - 0xBF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0xB0 - 0xB7 */ + Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte,Quoted 9 lines
Review static u16 opcode_table[256] = { · line 157
Quoted 7 lines
(quoted diff) +4
-0+ Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, Mov | SrcImmByte, + /* 0xB8 - 0xBF */ + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, + Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, Mov | SrcImm, /* 0xC0 - 0xC7 */Perhaps adding DstReg would reduce the decoding code later on?
Quoted 5 lines
Avi,
The decoding of register is significantly different for these instructions. It will be just moving code from one place to other place.
Quoted 8 lines
Right.
But perhaps we can have a ShortReg modifier to make the decoding common. There are several instructions which can use this (inc, dec, xchg, push, mov).
I'll look into this.
I've committed a few patches which enable this. Now, a DstReg or SrcReg without ModRM will decode the opcode byte to get the register. It also fixes a minor issue with ignoring rex prefixes on 64-bit byte insns. mov, inc, dec, push, and pop have been converted.
Please review these patches carefully as I haven't been able to give them a real workout other than booting a few guests.
Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/