Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Sep 2024 14:09:40 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 780675e1bed9 - main - arm64: Fix the VM_MAX_NAMELEN definition
Message-ID:  <202409011409.481E9e3w099552@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=780675e1bed9fa8e328327e3b6416642a16b2a98

commit 780675e1bed9fa8e328327e3b6416642a16b2a98
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-09-01 14:00:20 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-09-01 14:03:15 +0000

    arm64: Fix the VM_MAX_NAMELEN definition
    
    The maximum VM name length has changed since the arm64 vmm code was
    forked.  For now, just sync with the amd64 definitions, since they
    permit longer VM names.  As arm64/vmm is implemented only in main, I
    won't bother dealing with backward compat.
    
    Reviewed by:    jhb
    Differential Revision:  https://reviews.freebsd.org/D46484
---
 sys/arm64/include/vmm.h | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/sys/arm64/include/vmm.h b/sys/arm64/include/vmm.h
index 05b013557c06..acbd8f5cbcb9 100644
--- a/sys/arm64/include/vmm.h
+++ b/sys/arm64/include/vmm.h
@@ -102,14 +102,30 @@ enum vm_reg_name {
 #define	VM_INTINFO_HWEXCEPTION	(3 << 8)
 #define	VM_INTINFO_SWINTR	(4 << 8)
 
-#define VM_MAX_SUFFIXLEN 15
-
 #define VM_GUEST_BASE_IPA	0x80000000UL	/* Guest kernel start ipa */
 
-#ifdef _KERNEL
-
-#define	VM_MAX_NAMELEN	32
+/*
+ * The VM name has to fit into the pathname length constraints of devfs,
+ * governed primarily by SPECNAMELEN.  The length is the total number of
+ * characters in the full path, relative to the mount point and not 
+ * including any leading '/' characters.
+ * A prefix and a suffix are added to the name specified by the user.
+ * The prefix is usually "vmm/" or "vmm.io/", but can be a few characters
+ * longer for future use.
+ * The suffix is a string that identifies a bootrom image or some similar
+ * image that is attached to the VM. A separator character gets added to
+ * the suffix automatically when generating the full path, so it must be
+ * accounted for, reducing the effective length by 1.
+ * The effective length of a VM name is 229 bytes for FreeBSD 13 and 37
+ * bytes for FreeBSD 12.  A minimum length is set for safety and supports
+ * a SPECNAMELEN as small as 32 on old systems.
+ */
+#define VM_MAX_PREFIXLEN 10
+#define VM_MAX_SUFFIXLEN 15
+#define VM_MAX_NAMELEN \
+    (SPECNAMELEN - VM_MAX_PREFIXLEN - VM_MAX_SUFFIXLEN - 1)
 
+#ifdef _KERNEL
 struct vm;
 struct vm_exception;
 struct vm_exit;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409011409.481E9e3w099552>