git: 043999b1ae49 - main - riscv/vmm: Fix the build after a97f683fe3c4

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 05 Nov 2024 04:24:00 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=043999b1ae49635be530badeb6c5d50002e622f4

commit 043999b1ae49635be530badeb6c5d50002e622f4
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-11-05 03:13:47 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-11-05 04:23:49 +0000

    riscv/vmm: Fix the build after a97f683fe3c4
    
    - Make machine/vmm_dev.h self-contained.
    - Check for errors from vmmdev_init().
    - Make VM_MAX_NAMELEN visible to userspace.
    
    Reported by:    Jenkins
    Fixes:  a97f683fe3c4 ("vmm: Add a device file interface for creating and destroying VMs")
---
 sys/riscv/include/vmm.h     | 3 +--
 sys/riscv/include/vmm_dev.h | 2 ++
 sys/riscv/vmm/vmm.c         | 4 +++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/riscv/include/vmm.h b/sys/riscv/include/vmm.h
index e148cd95b522..1093e1cd0096 100644
--- a/sys/riscv/include/vmm.h
+++ b/sys/riscv/include/vmm.h
@@ -102,12 +102,11 @@ enum vm_reg_name {
 #define	VM_INTINFO_HWEXCEPTION	(3 << 8)
 #define	VM_INTINFO_SWINTR	(4 << 8)
 
+#define	VM_MAX_NAMELEN	32
 #define VM_MAX_SUFFIXLEN 15
 
 #ifdef _KERNEL
 
-#define	VM_MAX_NAMELEN	32
-
 struct vm;
 struct vm_exception;
 struct vm_exit;
diff --git a/sys/riscv/include/vmm_dev.h b/sys/riscv/include/vmm_dev.h
index a21528a8dc68..856ff0778b95 100644
--- a/sys/riscv/include/vmm_dev.h
+++ b/sys/riscv/include/vmm_dev.h
@@ -34,6 +34,8 @@
 #ifndef	_VMM_DEV_H_
 #define	_VMM_DEV_H_
 
+#include <machine/vmm.h>
+
 struct vm_memmap {
 	vm_paddr_t	gpa;
 	int		segid;		/* memory segment */
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
index 52e881dd220c..1c0290ace570 100644
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -255,7 +255,9 @@ vmm_handler(module_t mod, int what, void *arg)
 	switch (what) {
 	case MOD_LOAD:
 		/* TODO: check if has_hyp here? */
-		vmmdev_init();
+		error = vmmdev_init();
+		if (error != 0)
+			break;
 		error = vmm_init();
 		if (error == 0)
 			vmm_initialized = true;