Skip to content

Commit 7adfbea

Browse files
committed
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-next-for-5.1-pull-request' into staging
x86 bug fix for -rc2 A fix from Vitaly Kuznetsov for a CPU reset bug reported by Jan Kiszka. # gpg: Signature made Thu 23 Jul 2020 20:10:40 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "[email protected]" # gpg: Good signature from "Eduardo Habkost <[email protected]>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/x86-next-for-5.1-pull-request: KVM: fix CPU reset wrt HF2_GIF_MASK Signed-off-by: Peter Maydell <[email protected]>
2 parents 09e0cd7 + 0baa4b4 commit 7adfbea

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

target/i386/kvm.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,7 +3877,9 @@ static int kvm_put_nested_state(X86CPU *cpu)
38773877
} else {
38783878
env->nested_state->flags &= ~KVM_STATE_NESTED_GUEST_MODE;
38793879
}
3880-
if (env->hflags2 & HF2_GIF_MASK) {
3880+
3881+
/* Don't set KVM_STATE_NESTED_GIF_SET on VMX as it is illegal */
3882+
if (cpu_has_svm(env) && (env->hflags2 & HF2_GIF_MASK)) {
38813883
env->nested_state->flags |= KVM_STATE_NESTED_GIF_SET;
38823884
} else {
38833885
env->nested_state->flags &= ~KVM_STATE_NESTED_GIF_SET;
@@ -3919,10 +3921,14 @@ static int kvm_get_nested_state(X86CPU *cpu)
39193921
} else {
39203922
env->hflags &= ~HF_GUEST_MASK;
39213923
}
3922-
if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
3923-
env->hflags2 |= HF2_GIF_MASK;
3924-
} else {
3925-
env->hflags2 &= ~HF2_GIF_MASK;
3924+
3925+
/* Keep HF2_GIF_MASK set on !SVM as x86_cpu_pending_interrupt() needs it */
3926+
if (cpu_has_svm(env)) {
3927+
if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
3928+
env->hflags2 |= HF2_GIF_MASK;
3929+
} else {
3930+
env->hflags2 &= ~HF2_GIF_MASK;
3931+
}
39263932
}
39273933

39283934
return ret;

0 commit comments

Comments
 (0)