x86 bug fix for -rc2

A fix from Vitaly Kuznetsov for a CPU reset bug
 reported by Jan Kiszka.
 -----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCAAyFiEEWjIv1avE09usz9GqKAeTb5hNxaYFAl8Z4LAUHGVoYWJrb3N0
 QHJlZGhhdC5jb20ACgkQKAeTb5hNxaYYFQ/+N2mcdYcGtzkbf8x3zZ096wf0caIl
 bEKcr5bwcfOV+ruXpS7MfNvH89GKBa6qd6TjnsSN7QuWiWkSZGD4/T5Q9ITayRj8
 vrqPFpiqP1LJzsP1amwBrPqIFWAO6BxQUT6fg3rm79zA3bu7utKp2lhPcDah+4RZ
 zWYAMzlCftpI6bZvUlOa2dGNaQwFp+IVXQD5UxeTsRCV9dP5HYxDzFC0JMMUnyxQ
 AGyuX9Sgbv347YW7OfH1uU2W6vc8B9GpLIFjz3y21jVxUcRdr7epAzW+/tauvyJr
 q+wVrqYZIT2C4XwFNPygiUfp+ZBvAcZeT4psmoPhWBazw7i8CHSi4wDN9j5EBPe3
 Nx4K+y2Y5cfBei7lce0wswr9ye5ZsVMIqmEQ/HBxVevwbW+SGkr973qeuauPWVVS
 GWaGDxN8LaoltK974hiz38X2LKzOhjc0OuLPLRuSNnc4cvTg5AT9aWMbP82F0ouZ
 TkShaubeXZmFdHSzMwDUABUbH7WjdLtO3OzCn7Uadx5wf2QmEkBIbpWIy4LfRTnT
 oMn7snHpZ31v6enbdYr+flaXe6fbXyJDPVPI7IuhpNqO/fN6kgn6EVhk1AD9DMFC
 SgWbMNrJkV/3aGvWrwzahrxBI2AaEizfZb0e/Mqt0ohQhwUrCPxtZI0L1aUYuh1f
 qFZerMSTJV8gu5I=
 =FCDW
 -----END PGP SIGNATURE-----

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 "ehabkost@redhat.com"
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [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 <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-07-24 10:52:20 +01:00
commit 7adfbea8fd

View File

@ -3877,7 +3877,9 @@ static int kvm_put_nested_state(X86CPU *cpu)
} else { } else {
env->nested_state->flags &= ~KVM_STATE_NESTED_GUEST_MODE; 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; env->nested_state->flags |= KVM_STATE_NESTED_GIF_SET;
} else { } else {
env->nested_state->flags &= ~KVM_STATE_NESTED_GIF_SET; env->nested_state->flags &= ~KVM_STATE_NESTED_GIF_SET;
@ -3919,10 +3921,14 @@ static int kvm_get_nested_state(X86CPU *cpu)
} else { } else {
env->hflags &= ~HF_GUEST_MASK; env->hflags &= ~HF_GUEST_MASK;
} }
if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
env->hflags2 |= HF2_GIF_MASK; /* Keep HF2_GIF_MASK set on !SVM as x86_cpu_pending_interrupt() needs it */
} else { if (cpu_has_svm(env)) {
env->hflags2 &= ~HF2_GIF_MASK; if (env->nested_state->flags & KVM_STATE_NESTED_GIF_SET) {
env->hflags2 |= HF2_GIF_MASK;
} else {
env->hflags2 &= ~HF2_GIF_MASK;
}
} }
return ret; return ret;