* [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
@ 2014-03-15 20:01 Igor Mammedov
2014-03-15 20:01 ` [PATCH 1/2] KVM: x86 emulator: emulate MOVAPS Igor Mammedov
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Igor Mammedov @ 2014-03-15 20:01 UTC (permalink / raw)
To: linux-kernel; +Cc: gleb, pbonzini, tglx, mingo, hpa, x86, kvm
MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
instruction emulation, this series adds it and while at it,
it adds emulation of MOVAPD which is trivial to implement on
top of MOVAPS.
Igor Mammedov (2):
KVM: x86 emulator: emulate MOVAPS
KVM: x86 emulator: emulate MOVAPD
arch/x86/kvm/emulate.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--
1.8.5.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] KVM: x86 emulator: emulate MOVAPS
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
@ 2014-03-15 20:01 ` Igor Mammedov
2014-03-15 20:02 ` [PATCH 2/2] KVM: x86 emulator: emulate MOVAPD Igor Mammedov
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Igor Mammedov @ 2014-03-15 20:01 UTC (permalink / raw)
To: linux-kernel; +Cc: gleb, pbonzini, tglx, mingo, hpa, x86, kvm
HCK memory driver test fails when testing 32-bit Windows 8.1
with baloon driver.
tracing KVM shows error:
reason EXIT_ERR rip 0x81c18326 info 0 0
x/10i 0x81c18326-20
0x0000000081c18312: add %al,(%eax)
0x0000000081c18314: add %cl,-0x7127711d(%esi)
0x0000000081c1831a: rolb $0x0,0x80ec(%ecx)
0x0000000081c18321: and $0xfffffff0,%esp
0x0000000081c18324: mov %esp,%esi
0x0000000081c18326: movaps %xmm0,(%esi)
0x0000000081c18329: movaps %xmm1,0x10(%esi)
0x0000000081c1832d: movaps %xmm2,0x20(%esi)
0x0000000081c18331: movaps %xmm3,0x30(%esi)
0x0000000081c18335: movaps %xmm4,0x40(%esi)
which points to MOVAPS instruction currently no emulated by KVM.
Fix it by adding appropriate entries to opcode table in KVM's emulator.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
arch/x86/kvm/emulate.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 07ffca0..a26d075 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3668,6 +3668,10 @@ static const struct gprefix pfx_vmovntpx = {
I(0, em_mov), N, N, N,
};
+static const struct gprefix pfx_0f_28_0f_29 = {
+ I(Aligned, em_mov), N, N, N,
+};
+
static const struct escape escape_d9 = { {
N, N, N, N, N, N, N, I(DstMem, em_fnstcw),
}, {
@@ -3870,7 +3874,9 @@ static const struct opcode twobyte_table[256] = {
IIP(ModRM | SrcMem | Priv | Op3264, em_cr_write, cr_write, check_cr_write),
IIP(ModRM | SrcMem | Priv | Op3264, em_dr_write, dr_write, check_dr_write),
N, N, N, N,
- N, N, N, GP(ModRM | DstMem | SrcReg | Sse | Mov | Aligned, &pfx_vmovntpx),
+ GP(ModRM | DstReg | SrcMem | Mov | Sse, &pfx_0f_28_0f_29),
+ GP(ModRM | DstMem | SrcReg | Mov | Sse, &pfx_0f_28_0f_29),
+ N, GP(ModRM | DstMem | SrcReg | Sse | Mov | Aligned, &pfx_vmovntpx),
N, N, N, N,
/* 0x30 - 0x3F */
II(ImplicitOps | Priv, em_wrmsr, wrmsr),
--
1.8.5.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] KVM: x86 emulator: emulate MOVAPD
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
2014-03-15 20:01 ` [PATCH 1/2] KVM: x86 emulator: emulate MOVAPS Igor Mammedov
@ 2014-03-15 20:02 ` Igor Mammedov
2014-03-15 22:39 ` [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions H. Peter Anvin
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Igor Mammedov @ 2014-03-15 20:02 UTC (permalink / raw)
To: linux-kernel; +Cc: gleb, pbonzini, tglx, mingo, hpa, x86, kvm
Add emulation for 0x66 prefixed instruction of 0f 28 opcode
that has been added earlier.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
arch/x86/kvm/emulate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a26d075..205b17e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3669,7 +3669,7 @@ static const struct gprefix pfx_vmovntpx = {
};
static const struct gprefix pfx_0f_28_0f_29 = {
- I(Aligned, em_mov), N, N, N,
+ I(Aligned, em_mov), I(Aligned, em_mov), N, N,
};
static const struct escape escape_d9 = { {
--
1.8.5.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
2014-03-15 20:01 ` [PATCH 1/2] KVM: x86 emulator: emulate MOVAPS Igor Mammedov
2014-03-15 20:02 ` [PATCH 2/2] KVM: x86 emulator: emulate MOVAPD Igor Mammedov
@ 2014-03-15 22:39 ` H. Peter Anvin
2014-03-17 11:19 ` Paolo Bonzini
2014-03-15 22:42 ` H. Peter Anvin
2014-03-17 11:18 ` Paolo Bonzini
4 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2014-03-15 22:39 UTC (permalink / raw)
To: Igor Mammedov, linux-kernel; +Cc: gleb, pbonzini, tglx, mingo, x86, kvm
MOVAPS, MOVAPD, and MOVDQA are the same operation. They may, architecturally, have different performance characteristics, but nothing that would affect an emulator.
On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com> wrote:
>MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>instruction emulation, this series adds it and while at it,
>it adds emulation of MOVAPD which is trivial to implement on
>top of MOVAPS.
>
>Igor Mammedov (2):
> KVM: x86 emulator: emulate MOVAPS
> KVM: x86 emulator: emulate MOVAPD
>
> arch/x86/kvm/emulate.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
--
Sent from my mobile phone. Please pardon brevity and lack of formatting.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
` (2 preceding siblings ...)
2014-03-15 22:39 ` [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions H. Peter Anvin
@ 2014-03-15 22:42 ` H. Peter Anvin
2014-03-17 9:30 ` Paolo Bonzini
2014-03-17 11:18 ` Paolo Bonzini
4 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2014-03-15 22:42 UTC (permalink / raw)
To: Igor Mammedov, linux-kernel; +Cc: gleb, pbonzini, tglx, mingo, x86, kvm
Stupid question... what instructions do NOT need emulsion in KVM? It would seem that at least anything that touches memory would?
On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com> wrote:
>MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>instruction emulation, this series adds it and while at it,
>it adds emulation of MOVAPD which is trivial to implement on
>top of MOVAPS.
>
>Igor Mammedov (2):
> KVM: x86 emulator: emulate MOVAPS
> KVM: x86 emulator: emulate MOVAPD
>
> arch/x86/kvm/emulate.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
--
Sent from my mobile phone. Please pardon brevity and lack of formatting.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-15 22:42 ` H. Peter Anvin
@ 2014-03-17 9:30 ` Paolo Bonzini
2014-03-17 15:16 ` H. Peter Anvin
0 siblings, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2014-03-17 9:30 UTC (permalink / raw)
To: H. Peter Anvin, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
Il 15/03/2014 23:42, H. Peter Anvin ha scritto:
> Stupid question... what instructions do NOT need emulsion in KVM? It would seem that at least anything that touches memory would?
Yes, indeed. Anything that touches memory can be used on MMIO and then
needs emulation.
Paolo
> On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com> wrote:
>> MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>> instruction emulation, this series adds it and while at it,
>> it adds emulation of MOVAPD which is trivial to implement on
>> top of MOVAPS.
>>
>> Igor Mammedov (2):
>> KVM: x86 emulator: emulate MOVAPS
>> KVM: x86 emulator: emulate MOVAPD
>>
>> arch/x86/kvm/emulate.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
` (3 preceding siblings ...)
2014-03-15 22:42 ` H. Peter Anvin
@ 2014-03-17 11:18 ` Paolo Bonzini
4 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2014-03-17 11:18 UTC (permalink / raw)
To: Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, hpa, x86, kvm
Il 15/03/2014 21:01, Igor Mammedov ha scritto:
> MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
> instruction emulation, this series adds it and while at it,
> it adds emulation of MOVAPD which is trivial to implement on
> top of MOVAPS.
>
> Igor Mammedov (2):
> KVM: x86 emulator: emulate MOVAPS
> KVM: x86 emulator: emulate MOVAPD
>
> arch/x86/kvm/emulate.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
Applied both to kvm/next, thanks.
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-15 22:39 ` [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions H. Peter Anvin
@ 2014-03-17 11:19 ` Paolo Bonzini
0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2014-03-17 11:19 UTC (permalink / raw)
To: H. Peter Anvin, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
Il 15/03/2014 23:39, H. Peter Anvin ha scritto:
> MOVAPS, MOVAPD, and MOVDQA are the same operation. They may, architecturally, have different performance characteristics, but nothing that would affect an emulator.
In fact MOVAPS and MOVAPD are implemented the same way in this patch:
I(Aligned, em_mov), I(Aligned, em_mov), N, N,
These are respectively for no prefix, 0x66, 0xf2 and 0xf3. MOVDQA was
already implemented, but on AMD some memcpy implementations use MOVAPS
because it's a byte shorter.
Paolo
> On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com> wrote:
>> MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>> instruction emulation, this series adds it and while at it,
>> it adds emulation of MOVAPD which is trivial to implement on
>> top of MOVAPS.
>>
>> Igor Mammedov (2):
>> KVM: x86 emulator: emulate MOVAPS
>> KVM: x86 emulator: emulate MOVAPD
>>
>> arch/x86/kvm/emulate.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-17 9:30 ` Paolo Bonzini
@ 2014-03-17 15:16 ` H. Peter Anvin
2014-03-17 17:01 ` Paolo Bonzini
0 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2014-03-17 15:16 UTC (permalink / raw)
To: Paolo Bonzini, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
After seeing the sheer number of one-off additions, I'm wondering if going through the opcode map systematically and see what is still missing might not be a bad idea.
On March 17, 2014 2:30:43 AM PDT, Paolo Bonzini <pbonzini@redhat.com> wrote:
>Il 15/03/2014 23:42, H. Peter Anvin ha scritto:
>> Stupid question... what instructions do NOT need emulsion in KVM? It
>would seem that at least anything that touches memory would?
>
>Yes, indeed. Anything that touches memory can be used on MMIO and then
>
>needs emulation.
>
>Paolo
>
>> On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com>
>wrote:
>>> MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>>> instruction emulation, this series adds it and while at it,
>>> it adds emulation of MOVAPD which is trivial to implement on
>>> top of MOVAPS.
>>>
>>> Igor Mammedov (2):
>>> KVM: x86 emulator: emulate MOVAPS
>>> KVM: x86 emulator: emulate MOVAPD
>>>
>>> arch/x86/kvm/emulate.c | 8 +++++++-
>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
--
Sent from my mobile phone. Please pardon brevity and lack of formatting.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-17 15:16 ` H. Peter Anvin
@ 2014-03-17 17:01 ` Paolo Bonzini
2014-03-17 17:38 ` H. Peter Anvin
0 siblings, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2014-03-17 17:01 UTC (permalink / raw)
To: H. Peter Anvin, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
Il 17/03/2014 16:16, H. Peter Anvin ha scritto:
> After seeing the sheer number of one-off additions, I'm wondering if going through the opcode map systematically and see what is still missing might not be a bad idea.
Memory access instructions always need emulation, but there aren't that
many left. There are some, such as MOVUPS/MOVUPD.
However, this is not the only use of emulation. The problem stems from
pre-Westmere Intel chips that didn't have unrestricted mode
virtualization. For these chips, you need to emulate all instructions
that might be used in protected mode transitions and also, possibly, in
big real mode. In practice you will rarely see big real mode (the main
exception is option ROMs, due to PMM), still every OS likes to do
something different in their protected mode transitions so this is the
source of most one-off additions that you have seen.
Until around 3.6, KVM used to transform big real mode into a "good" real
mode that the processor would like, while breaking completely in big
real mode; this is now emulate_invalid_guest_state=N. Nowadays, it uses
emulation, which is emulate_invalid_guest_state=Y. As you can imagine
it's quite slow (though some performance can certainly be scraped off
the emulator).
If CS and possibly SS are valid real mode selectors, it should be
possible to run big real mode at almost-full speed, taking exits only
for memory accesses via other segment registers. It is on my todo list,
but not very high. Depending on the exit overhead, it may be a better
idea to revert the emulate_invalid_guest_state default to N and let
people who care about big real mode specify Y.
Paolo
> On March 17, 2014 2:30:43 AM PDT, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> Il 15/03/2014 23:42, H. Peter Anvin ha scritto:
>>> Stupid question... what instructions do NOT need emulsion in KVM? It
>> would seem that at least anything that touches memory would?
>>
>> Yes, indeed. Anything that touches memory can be used on MMIO and then
>>
>> needs emulation.
>>
>> Paolo
>>
>>> On March 15, 2014 1:01:58 PM PDT, Igor Mammedov <imammedo@redhat.com>
>> wrote:
>>>> MS HCK test fails on 32-bit Windows 8.1 due to missing MOVAPS
>>>> instruction emulation, this series adds it and while at it,
>>>> it adds emulation of MOVAPD which is trivial to implement on
>>>> top of MOVAPS.
>>>>
>>>> Igor Mammedov (2):
>>>> KVM: x86 emulator: emulate MOVAPS
>>>> KVM: x86 emulator: emulate MOVAPD
>>>>
>>>> arch/x86/kvm/emulate.c | 8 +++++++-
>>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-17 17:01 ` Paolo Bonzini
@ 2014-03-17 17:38 ` H. Peter Anvin
2014-03-18 12:11 ` Paolo Bonzini
0 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2014-03-17 17:38 UTC (permalink / raw)
To: Paolo Bonzini, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
On 03/17/2014 10:01 AM, Paolo Bonzini wrote:
> the emulator).
>
> If CS and possibly SS are valid real mode selectors, it should be
> possible to run big real mode at almost-full speed, taking exits only
> for memory accesses via other segment registers. It is on my todo list,
> but not very high. Depending on the exit overhead, it may be a better
> idea to revert the emulate_invalid_guest_state default to N and let
> people who care about big real mode specify Y.
>
I'm not sure what you mean with "valid real mode selectors"; the normal
case in big real mode is that either CS = SS = 0 or CS = SS = <some
program base address>.
As Big Real Mode is part of the spec for certain things (option ROMs, as
we discussed) it probably matters, but especially with the CPUs not
supporting unrestricted mode fading into history I suspect it is fine
for BRM to be slow on those older processors.
The PM transitions that you mentioned are usually only a handful of
instructions and thus can be slow.
-hpa
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions
2014-03-17 17:38 ` H. Peter Anvin
@ 2014-03-18 12:11 ` Paolo Bonzini
0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2014-03-18 12:11 UTC (permalink / raw)
To: H. Peter Anvin, Igor Mammedov, linux-kernel; +Cc: gleb, tglx, mingo, x86, kvm
Il 17/03/2014 18:38, H. Peter Anvin ha scritto:
> I'm not sure what you mean with "valid real mode selectors"; the normal
> case in big real mode is that either CS = SS = 0 or CS = SS = <some
> program base address>.
I mean "valid according to the VMX spec" for running in vm86 mode: base
= selector << 4, limit = 0xffff, access rights = 0xf3.
If a segment does not follow the rules, but CS does, we could run the
guest normally and trap memory accesses to KVM.
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-03-18 12:11 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 20:01 [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions Igor Mammedov
2014-03-15 20:01 ` [PATCH 1/2] KVM: x86 emulator: emulate MOVAPS Igor Mammedov
2014-03-15 20:02 ` [PATCH 2/2] KVM: x86 emulator: emulate MOVAPD Igor Mammedov
2014-03-15 22:39 ` [PATCH 0/2] KVM: x86 emulator: emulate MOVAPS and MOVAPD SSE instructions H. Peter Anvin
2014-03-17 11:19 ` Paolo Bonzini
2014-03-15 22:42 ` H. Peter Anvin
2014-03-17 9:30 ` Paolo Bonzini
2014-03-17 15:16 ` H. Peter Anvin
2014-03-17 17:01 ` Paolo Bonzini
2014-03-17 17:38 ` H. Peter Anvin
2014-03-18 12:11 ` Paolo Bonzini
2014-03-17 11:18 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).