[RFC PATCH v1 10/42] allow the command line to be specified for kernels in other planes

Sriram Nambakam <[email protected]> Wed, 5 Aug 2026 04:02:52 -0700
Newsgroups org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
---
 include/linux/vm_planes.h |  2 ++
 init/vm_planes.c          | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/linux/vm_planes.h b/include/linux/vm_planes.h
index 5850c9e0d097..bb06dcbcf0cb 100644
--- a/include/linux/vm_planes.h
+++ b/include/linux/vm_planes.h
@@ -8,6 +8,7 @@
 #ifdef CONFIG_VM_PLANES
 
 #define VM_PLANE_KERNEL_NAME_MAX	128
+#define VM_PLANE_CMDLINE_MAX		512
 
 enum vm_plane_kernel_format {
 	VM_PLANE_KFMT_RAW = 0,
@@ -21,6 +22,7 @@ struct vm_plane_config {
 	unsigned int vcpu_count;
 	unsigned int kernel_format;
 	char kernel[VM_PLANE_KERNEL_NAME_MAX];
+	char cmdline[VM_PLANE_CMDLINE_MAX];
 };
 
 void __init arch_init_vm_planes(void);
diff --git a/init/vm_planes.c b/init/vm_planes.c
index 6fac52af4b77..613daa161298 100644
--- a/init/vm_planes.c
+++ b/init/vm_planes.c
@@ -25,6 +25,7 @@ struct vm_plane_parse_state {
 	unsigned int vcpu_count;
 	unsigned int kernel_format;
 	char kernel[VM_PLANE_KERNEL_NAME_MAX];
+	char cmdline[VM_PLANE_CMDLINE_MAX];
 };
 
 #define VM_PLANES_UNSET_VALUE	((phys_addr_t)~0)
@@ -141,7 +142,7 @@ static int __init parse_plane_cfg_line(const char *line, size_t len,
 				       struct vm_plane_config *plane_cfg,
 				       struct vm_plane_parse_state *state)
 {
-	char tmp[192];
+	char tmp[VM_PLANE_CMDLINE_MAX + 64];
 	char *p, *key, *val;
 	unsigned int plane_id;
 	u64 parsed_u64;
@@ -229,6 +230,25 @@ static int __init parse_plane_cfg_line(const char *line, size_t len,
 		return 0;
 	}
 
+	if (!strcmp(key, "CMDLINE")) {
+		size_t val_len = strlen(val);
+
+		if (val_len >= 2 && val[0] == '"') {
+			if (val[val_len - 1] != '"')
+				return -EINVAL;
+			val[val_len - 1] = '\0';
+			val++;
+		}
+
+		if (strscpy(plane_cfg[plane_id].cmdline, val,
+			    sizeof(plane_cfg[plane_id].cmdline)) < 0)
+			return -E2BIG;
+
+		strscpy(state[plane_id].cmdline, val,
+			sizeof(state[plane_id].cmdline));
+		return 0;
+	}
+
 	if (kstrtou64(val, 0, &parsed_u64))
 		return -EINVAL;
 
@@ -292,6 +312,7 @@ static int __init parse_vm_planes_kconfig(const char *buf, size_t len,
 		state[i].memory_size = VM_PLANES_UNSET_VALUE;
 		state[i].vcpu_count = 0;
 		state[i].kernel[0] = '\0';
+		state[i].cmdline[0] = '\0';
 	}
 
 	while (p < end) {
-- 
2.55.0