* [PATCH] KVM: nVMX: Reset RFLAGS on VM-exit
@ 2013-03-03 12:06 Jan Kiszka
2013-03-03 19:15 ` Nadav Har'El
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2013-03-03 12:06 UTC (permalink / raw)
To: Gleb Natapov, Marcelo Tosatti; +Cc: kvm, Nadav Har'El, Nakajima, Jun
From: Jan Kiszka <jan.kiszka@siemens.com>
Ouch, how could this work so well that far? We need to clear RFLAGS to
the reset value as specified by the SDM. Particularly, IF must be off
after VM-exit!
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
arch/x86/kvm/vmx.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 486078d..252f9c4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7454,6 +7454,7 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
kvm_register_write(vcpu, VCPU_REGS_RSP, vmcs12->host_rsp);
kvm_register_write(vcpu, VCPU_REGS_RIP, vmcs12->host_rip);
+ vmx_set_rflags(vcpu, 0x02);
/*
* Note that calling vmx_set_cr0 is important, even if cr0 hasn't
* actually changed, because it depends on the current state of
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Reset RFLAGS on VM-exit
2013-03-03 12:06 [PATCH] KVM: nVMX: Reset RFLAGS on VM-exit Jan Kiszka
@ 2013-03-03 19:15 ` Nadav Har'El
2013-03-03 19:23 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Nadav Har'El @ 2013-03-03 19:15 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Gleb Natapov, Marcelo Tosatti, kvm, Nakajima, Jun
On Sun, Mar 03, 2013, Jan Kiszka wrote about "[PATCH] KVM: nVMX: Reset RFLAGS on VM-exit":
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Ouch, how could this work so well that far? We need to clear RFLAGS to
> the reset value as specified by the SDM. Particularly, IF must be off
> after VM-exit!
nested_vmx_succeed() or nested_vmx_fail*() were already clearing some of
the fields that I understood was necessary to clear. But they did not clear
the IF - I never realised (and didn't verify now) that this is part of the
spec. And since L1 KVM anyways enters L2 with interrupts disabled, nested KVM
would not see a difference.
> + vmx_set_rflags(vcpu, 0x02);
There's a macro X86_EFLAGS_BIT1 which you can use for this 0x02.
--
Nadav Har'El | Sunday, Mar 3 2013, 22 Adar 5773
nyh@math.technion.ac.il |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |"I don't use drugs, my dreams are
http://nadav.harel.org.il |frightening enough." -- M. C. Escher
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Reset RFLAGS on VM-exit
2013-03-03 19:15 ` Nadav Har'El
@ 2013-03-03 19:23 ` Jan Kiszka
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2013-03-03 19:23 UTC (permalink / raw)
To: Nadav Har'El; +Cc: Gleb Natapov, Marcelo Tosatti, kvm, Nakajima, Jun
[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]
On 2013-03-03 20:15, Nadav Har'El wrote:
> On Sun, Mar 03, 2013, Jan Kiszka wrote about "[PATCH] KVM: nVMX: Reset RFLAGS on VM-exit":
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> Ouch, how could this work so well that far? We need to clear RFLAGS to
>> the reset value as specified by the SDM. Particularly, IF must be off
>> after VM-exit!
>
> nested_vmx_succeed() or nested_vmx_fail*() were already clearing some of
> the fields that I understood was necessary to clear. But they did not clear
> the IF - I never realised (and didn't verify now) that this is part of the
> spec. And since L1 KVM anyways enters L2 with interrupts disabled, nested KVM
> would not see a difference.
But we didn't restore rflags on vmexit either, we reused the guest value
for L1. It was pure luck (and due to KVM's short IRQ-off phase after
vmexit) when things worked. But I bet this should fix some spurious issues.
>
>> + vmx_set_rflags(vcpu, 0x02);
>
> There's a macro X86_EFLAGS_BIT1 which you can use for this 0x02.
Ah, good to know. Checked vmx_vcpu_reset and found this value.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-03 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-03 12:06 [PATCH] KVM: nVMX: Reset RFLAGS on VM-exit Jan Kiszka
2013-03-03 19:15 ` Nadav Har'El
2013-03-03 19:23 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox