git: 5aab578e3efe - stable/13 - vmm: do not leak halted_cpus bit after suspension

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 08 Nov 2022 22:08:56 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5aab578e3efe209f280d163e4370ce018fc8d619

commit 5aab578e3efe209f280d163e4370ce018fc8d619
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-10-31 23:30:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-11-08 22:08:25 +0000

    vmm: do not leak halted_cpus bit after suspension
    
    PR:     267468
    
    (cherry picked from commit 4d447b30f7be761b0c2877513e79f484511a00a5)
---
 sys/amd64/vmm/vmm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index b417a2345bed..fc7ea3d7b4be 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -1424,8 +1424,13 @@ vm_handle_hlt(struct vm *vm, int vcpuid, bool intr_disabled, bool *retu)
 		if ((td->td_flags & TDF_NEEDSUSPCHK) != 0) {
 			vcpu_unlock(vcpu);
 			error = thread_check_susp(td, false);
-			if (error != 0)
+			if (error != 0) {
+				if (vcpu_halted) {
+					CPU_CLR_ATOMIC(vcpuid,
+					    &vm->halted_cpus);
+				}
 				return (error);
+			}
 			vcpu_lock(vcpu);
 		}
 	}