* [PATCH 0/2] KVM: x86: Emulator fixes for VM86
@ 2014-12-10 9:19 Nadav Amit
2014-12-10 9:19 ` [PATCH 1/2] KVM: x86: Do not push eflags.vm on pushf Nadav Amit
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nadav Amit @ 2014-12-10 9:19 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, Nadav Amit
Two minor fixes for emulation of instructions on VM86.
Thanks for reviewing them.
Nadav Amit (2):
KVM: x86: Do not push eflags.vm on pushf
KVM: x86: Emulate should check #UD before #GP
arch/x86/kvm/emulate.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] KVM: x86: Do not push eflags.vm on pushf
2014-12-10 9:19 [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Nadav Amit
@ 2014-12-10 9:19 ` Nadav Amit
2014-12-10 9:19 ` [PATCH 2/2] KVM: x86: Emulate should check #UD before #GP Nadav Amit
2014-12-10 11:53 ` [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Nadav Amit @ 2014-12-10 9:19 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, Nadav Amit
The pushf instruction does not push eflags.VM, so emulation should not do so as
well. Although eflags.RF should not be pushed as well, it is already cleared
by the time pushf is executed.
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
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 33ecfcf..5cd5401 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1863,7 +1863,7 @@ static int em_pusha(struct x86_emulate_ctxt *ctxt)
static int em_pushf(struct x86_emulate_ctxt *ctxt)
{
- ctxt->src.val = (unsigned long)ctxt->eflags;
+ ctxt->src.val = (unsigned long)ctxt->eflags & ~EFLG_VM;
return em_push(ctxt);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] KVM: x86: Emulate should check #UD before #GP
2014-12-10 9:19 [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Nadav Amit
2014-12-10 9:19 ` [PATCH 1/2] KVM: x86: Do not push eflags.vm on pushf Nadav Amit
@ 2014-12-10 9:19 ` Nadav Amit
2014-12-10 11:53 ` [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Nadav Amit @ 2014-12-10 9:19 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, Nadav Amit
Intel SDM table 6-2 ("Priority Among Simultaneous Exceptions and Interrupts")
shows that faults from decoding the next instruction got higher priority than
general protection. Moving the protected-mode check before the CPL check to
avoid wrong exception on vm86 mode.
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
arch/x86/kvm/emulate.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 5cd5401..0d42aca 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4803,6 +4803,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
goto done;
}
+ /* Instruction can only be executed in protected mode */
+ if ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) {
+ rc = emulate_ud(ctxt);
+ goto done;
+ }
+
/* Privileged instruction can be executed only in CPL=0 */
if ((ctxt->d & Priv) && ops->cpl(ctxt)) {
if (ctxt->d & PrivUD)
@@ -4812,12 +4818,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
goto done;
}
- /* Instruction can only be executed in protected mode */
- if ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) {
- rc = emulate_ud(ctxt);
- goto done;
- }
-
/* Do instruction specific permission checks */
if (ctxt->d & CheckPerm) {
rc = ctxt->check_perm(ctxt);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] KVM: x86: Emulator fixes for VM86
2014-12-10 9:19 [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Nadav Amit
2014-12-10 9:19 ` [PATCH 1/2] KVM: x86: Do not push eflags.vm on pushf Nadav Amit
2014-12-10 9:19 ` [PATCH 2/2] KVM: x86: Emulate should check #UD before #GP Nadav Amit
@ 2014-12-10 11:53 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2014-12-10 11:53 UTC (permalink / raw)
To: Nadav Amit; +Cc: kvm
On 10/12/2014 10:19, Nadav Amit wrote:
> Two minor fixes for emulation of instructions on VM86.
>
> Thanks for reviewing them.
>
> Nadav Amit (2):
> KVM: x86: Do not push eflags.vm on pushf
> KVM: x86: Emulate should check #UD before #GP
>
> arch/x86/kvm/emulate.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-10 11:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 9:19 [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Nadav Amit
2014-12-10 9:19 ` [PATCH 1/2] KVM: x86: Do not push eflags.vm on pushf Nadav Amit
2014-12-10 9:19 ` [PATCH 2/2] KVM: x86: Emulate should check #UD before #GP Nadav Amit
2014-12-10 11:53 ` [PATCH 0/2] KVM: x86: Emulator fixes for VM86 Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox