* [PULL 0/1] x86 bug fix for -rc2
@ 2020-07-23 19:13 Eduardo Habkost
2020-07-23 19:13 ` [PULL 1/1] KVM: fix CPU reset wrt HF2_GIF_MASK Eduardo Habkost
2020-07-24 15:10 ` [PULL 0/1] x86 bug fix for -rc2 Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Habkost @ 2020-07-23 19:13 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Marcelo Tosatti, Dr. David Alan Gilbert,
Paolo Bonzini, Philippe Mathieu-Daudé,
Richard Henderson
The following changes since commit 8ffa52c20d5693d454f65f2024a1494edfea65d4:
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-07-23 13:38:21 +0100)
are available in the Git repository at:
git://github.com/ehabkost/qemu.git tags/x86-next-for-5.1-pull-request
for you to fetch changes up to 0baa4b445e28f37243e5dc72e7efe32f0c9d7801:
KVM: fix CPU reset wrt HF2_GIF_MASK (2020-07-23 15:03:54 -0400)
----------------------------------------------------------------
x86 bug fix for -rc2
A fix from Vitaly Kuznetsov for a CPU reset bug
reported by Jan Kiszka.
----------------------------------------------------------------
Vitaly Kuznetsov (1):
KVM: fix CPU reset wrt HF2_GIF_MASK
target/i386/kvm.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PULL 1/1] KVM: fix CPU reset wrt HF2_GIF_MASK
2020-07-23 19:13 [PULL 0/1] x86 bug fix for -rc2 Eduardo Habkost
@ 2020-07-23 19:13 ` Eduardo Habkost
2020-07-24 15:10 ` [PULL 0/1] x86 bug fix for -rc2 Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Habkost @ 2020-07-23 19:13 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Jan Kiszka, Marcelo Tosatti,
Dr. David Alan Gilbert, Paolo Bonzini, Vitaly Kuznetsov,
Philippe Mathieu-Daudé,
Richard Henderson
From: Vitaly Kuznetsov <vkuznets@redhat.com>
HF2_GIF_MASK is set in env->hflags2 unconditionally on CPU reset
(see x86_cpu_reset()) but when calling KVM_SET_NESTED_STATE,
KVM_STATE_NESTED_GIF_SET is only valid for nSVM as e.g. nVMX code
looks like
if (kvm_state->hdr.vmx.vmxon_pa == -1ull) {
if (kvm_state->flags & ~KVM_STATE_NESTED_EVMCS)
return -EINVAL;
}
Also, when adjusting the environment after KVM_GET_NESTED_STATE we
need not reset HF2_GIF_MASK on VMX as e.g. x86_cpu_pending_interrupt()
expects it to be set.
Alternatively, we could've made env->hflags2 SVM-only.
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Fixes: b16c0e20c742 ("KVM: add support for AMD nested live migration")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200723142701.2521161-1-vkuznets@redhat.com>
Tested-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target/i386/kvm.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index b8455c89ed..6f18d940a5 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -3877,7 +3877,9 @@ static int kvm_put_nested_state(X86CPU *cpu)
} else {
env->nested_state->flags &= ~KVM_STATE_NESTED_GUEST_MODE;
}
- if (env->hflags2 & HF2_GIF_MASK) {
+
+ /* Don't set KVM_STATE_NESTED_GIF_SET on VMX as it is illegal */
+ if (cpu_has_svm(env) && (env->hflags2 & HF2_GIF_MASK)) {
env->nested_state->flags |= KVM_STATE_NESTED_GIF_SET;
} else {
env->nested_state->flags &= ~KVM_STATE_NESTED_GIF_SET;
@@ -3919,10 +3921,14 @@ static int kvm_get_nested_state(X86CPU *cpu)
} else {
env->hflags &= ~HF_GUEST_MASK;
}
- if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
- env->hflags2 |= HF2_GIF_MASK;
- } else {
- env->hflags2 &= ~HF2_GIF_MASK;
+
+ /* Keep HF2_GIF_MASK set on !SVM as x86_cpu_pending_interrupt() needs it */
+ if (cpu_has_svm(env)) {
+ if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
+ env->hflags2 |= HF2_GIF_MASK;
+ } else {
+ env->hflags2 &= ~HF2_GIF_MASK;
+ }
}
return ret;
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PULL 0/1] x86 bug fix for -rc2
2020-07-23 19:13 [PULL 0/1] x86 bug fix for -rc2 Eduardo Habkost
2020-07-23 19:13 ` [PULL 1/1] KVM: fix CPU reset wrt HF2_GIF_MASK Eduardo Habkost
@ 2020-07-24 15:10 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-07-24 15:10 UTC (permalink / raw)
To: Eduardo Habkost
Cc: Marcelo Tosatti, QEMU Developers, Dr. David Alan Gilbert,
Paolo Bonzini, Philippe Mathieu-Daudé,
Richard Henderson
On Thu, 23 Jul 2020 at 20:14, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> The following changes since commit 8ffa52c20d5693d454f65f2024a1494edfea65d4:
>
> Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-07-23 13:38:21 +0100)
>
> are available in the Git repository at:
>
> git://github.com/ehabkost/qemu.git tags/x86-next-for-5.1-pull-request
>
> for you to fetch changes up to 0baa4b445e28f37243e5dc72e7efe32f0c9d7801:
>
> KVM: fix CPU reset wrt HF2_GIF_MASK (2020-07-23 15:03:54 -0400)
>
> ----------------------------------------------------------------
> x86 bug fix for -rc2
>
> A fix from Vitaly Kuznetsov for a CPU reset bug
> reported by Jan Kiszka.
>
> ----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-24 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 19:13 [PULL 0/1] x86 bug fix for -rc2 Eduardo Habkost
2020-07-23 19:13 ` [PULL 1/1] KVM: fix CPU reset wrt HF2_GIF_MASK Eduardo Habkost
2020-07-24 15:10 ` [PULL 0/1] x86 bug fix for -rc2 Peter Maydell
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).