git: 4c5188bbeb88 - main - bhyve: Assert success in a couple of libvmmapi calls

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 31 Jul 2024 23:44:41 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4c5188bbeb88362112fa2891ccb6330f4c429ff3

commit 4c5188bbeb88362112fa2891ccb6330f4c429ff3
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-07-31 22:40:51 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-07-31 22:41:30 +0000

    bhyve: Assert success in a couple of libvmmapi calls
    
    - In vmexit_smccc(), copy an assertion from amd64.
    - In fbsdrun_addcpu(), make sure that our vm_suspend_cpu() call is
      succesful.
    
    Reviewed by:    jhb
    MFC after:      2 weeks
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D46197
---
 usr.sbin/bhyve/aarch64/vmexit.c | 3 ++-
 usr.sbin/bhyve/bhyverun.c       | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/bhyve/aarch64/vmexit.c b/usr.sbin/bhyve/aarch64/vmexit.c
index 7f0cfe672c55..e1a9509d5d12 100644
--- a/usr.sbin/bhyve/aarch64/vmexit.c
+++ b/usr.sbin/bhyve/aarch64/vmexit.c
@@ -249,7 +249,8 @@ vmexit_smccc(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
 			how = VM_SUSPEND_POWEROFF;
 		else
 			how = VM_SUSPEND_RESET;
-		vm_suspend(ctx, how);
+		error = vm_suspend(ctx, how);
+		assert(error == 0 || errno == EALREADY);
 		break;
 	default:
 		break;
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index aca770a92642..f844da90e76c 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -413,7 +413,8 @@ fbsdrun_addcpu(int vcpuid)
 
 	CPU_SET_ATOMIC(vcpuid, &cpumask);
 
-	vm_suspend_cpu(vi->vcpu);
+	error = vm_suspend_cpu(vi->vcpu);
+	assert(error == 0);
 
 	error = pthread_create(&thr, NULL, fbsdrun_start_thread, vi);
 	assert(error == 0);