diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2007-10-17 13:30:41 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-22 06:03:29 -0400 |
commit | 4e62417bf317504c0b85e0d7abd236f334f54eaf (patch) | |
tree | 67d1716640ca88c0b67dda3831e30efc0f0a0c06 /drivers/kvm | |
parent | 78f7826868da8e27d097802139a3fec39f47f3b8 (diff) |
KVM: x86 emulator: fix 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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/x86_emulate.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 0a8696d9b82c..a6ace302e0cd 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c | |||
@@ -825,6 +825,14 @@ done_prefixes: | |||
825 | if (twobyte && b == 0x01 && modrm_reg == 7) | 825 | if (twobyte && b == 0x01 && modrm_reg == 7) |
826 | break; | 826 | break; |
827 | srcmem_common: | 827 | srcmem_common: |
828 | /* | ||
829 | * For instructions with a ModR/M byte, switch to register | ||
830 | * access if Mod = 3. | ||
831 | */ | ||
832 | if ((d & ModRM) && modrm_mod == 3) { | ||
833 | src.type = OP_REG; | ||
834 | break; | ||
835 | } | ||
828 | src.type = OP_MEM; | 836 | src.type = OP_MEM; |
829 | src.ptr = (unsigned long *)cr2; | 837 | src.ptr = (unsigned long *)cr2; |
830 | src.val = 0; | 838 | src.val = 0; |
@@ -893,6 +901,14 @@ done_prefixes: | |||
893 | dst.ptr = (unsigned long *)cr2; | 901 | dst.ptr = (unsigned long *)cr2; |
894 | dst.bytes = (d & ByteOp) ? 1 : op_bytes; | 902 | dst.bytes = (d & ByteOp) ? 1 : op_bytes; |
895 | dst.val = 0; | 903 | dst.val = 0; |
904 | /* | ||
905 | * For instructions with a ModR/M byte, switch to register | ||
906 | * access if Mod = 3. | ||
907 | */ | ||
908 | if ((d & ModRM) && modrm_mod == 3) { | ||
909 | dst.type = OP_REG; | ||
910 | break; | ||
911 | } | ||
896 | if (d & BitOp) { | 912 | if (d & BitOp) { |
897 | unsigned long mask = ~(dst.bytes * 8 - 1); | 913 | unsigned long mask = ~(dst.bytes * 8 - 1); |
898 | 914 | ||