KVM: Access registers for instructions with ModR/M byte and Mod = 3
PATCH 1/1 KVM: Access registers for instructions with ModR/M byte and Mod = 3
Quoted 9 lines · Aurelien Jarno
Quoted 4 lines
Quoted 1 line
The 0F 01 instruction is then correctly emulated, but another of this
Oops s/0F 01/invlpg/
Quoted 1 line
group is probably not, as the patch clearly fix the problem on AMD.
I confirm the problem. SVM does not virtualize smsw and lmsw that have to be emulated. And it looks like the decoding or/and emulation of those instructions is currently broken in KVM.
Ok, next try. This time I have opened the IA32 manual (I should have done that before), so I hope it is correct.
KVM: Access registers for instructions with ModR/M byte and Mod = 3
The patch belows changes the access type to register from memory for instructions that are declared as SrcMem or DstMem, but have a ModR/M byte with Mod = 3.
It fixes (at least) the lmsw and smsw instructions on an AMD64 CPU, which are needed for FreeBSD.
drivers/kvm/x86_emulate.c +12 -1
@@ -831,6 +831,12 @@ modrm_done:if (c->twobyte && c->b ==0x01 && c->modrm_reg ==7 )break ; +/* For instructions with a ModR/M byte, switch to register +access if Mod = 3. */ +if ((c->d & ModRM) && c->modrm_mod ==3 ) { + c->src.type =OP_REG ; +break ; + } srcmem_common: c->src.type =OP_MEM ;break ;
@@ -893,7 +899,12 @@ srcmem_common: }break ;case DstMem: - c->dst.type =OP_MEM ; +/* For instructions with a ModR/M byte, switch to register +access if Mod = 3. */ +if ((c->d & ModRM) && c->modrm_mod ==3 ) + c->dst.type =OP_REG ; +else + c->dst.type =OP_MEM ;break ; }
Signature · 10 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net ------------------------------------------------------------------------- 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/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Avi Kivity
AppliedQuoted 4 lines · Aurelien Jarno
Ok, next try. This time I have opened the IA32 manual (I should have done that before), so I hope it is correct.
Quoted 10 lines
KVM: Access registers for instructions with ModR/M byte and Mod = 3
The patch belows changes the access type to register from memory for instructions that are declared as SrcMem or DstMem, but have a ModR/M byte with Mod = 3.
It fixes (at least) the lmsw and smsw instructions on an AMD64 CPU, which are needed for FreeBSD.
Applied, thanks.
We probably want to move modrm decoding to create a 'modrm_operand' of type 'struct operand' and then simply copy that into c->src or c->dst as needed.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- 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/