Module Name: src
Committed By: riastradh
Date: Sun Mar 30 14:36:49 UTC 2025
Modified Files:
src/sbin/efi: defs.h efiio.c
src/sys/dev: efi.c
Log Message:
efi(8)/efi(9): Rename EFI_VARNAME_MAXLENGTH -> EFI_VARNAME_MAXBYTES.
This should help avoid potential confusion over the units.
No functional change intended.
Prompted by (but will not fix):
PR kern/59235: efi(8) panics
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/efi/defs.h
cvs rdiff -u -r1.3 -r1.4 src/sbin/efi/efiio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/efi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/efi/defs.h
diff -u src/sbin/efi/defs.h:1.1 src/sbin/efi/defs.h:1.2
--- src/sbin/efi/defs.h:1.1 Mon Feb 24 13:47:56 2025
+++ src/sbin/efi/defs.h Sun Mar 30 14:36:48 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1 2025/02/24 13:47:56 christos Exp $ */
+/* $NetBSD: defs.h,v 1.2 2025/03/30 14:36:48 riastradh Exp $ */
/*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
#define _DEFS_H_
#ifndef lint
-__RCSID("$NetBSD: defs.h,v 1.1 2025/02/24 13:47:56 christos Exp $");
+__RCSID("$NetBSD: defs.h,v 1.2 2025/03/30 14:36:48 riastradh Exp $");
#endif /* not lint */
#define PUBLIC
@@ -74,13 +74,13 @@ __RCSID("$NetBSD: defs.h,v 1.1 2025/02/2
/*
* XXX: It would be nice to have QueryVariableInfo() support to get
- * maximum variable size ... or at least export EFI_VARNAME_MAXLENGTH
+ * maximum variable size ... or at least export EFI_VARNAME_MAXBYTES
* from efi.h!
*/
/* From sys/arch/x86/include/efi.h */
#define EFI_PAGE_SHIFT 12
#define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT)
-#define EFI_VARNAME_MAXLENGTH EFI_PAGE_SIZE
+#define EFI_VARNAME_MAXBYTES EFI_PAGE_SIZE
/* XXX: Why is this not exposed in sys/uuid.h? */
#define UUID_STR_LEN _UUID_STR_LEN
Index: src/sbin/efi/efiio.c
diff -u src/sbin/efi/efiio.c:1.3 src/sbin/efi/efiio.c:1.4
--- src/sbin/efi/efiio.c:1.3 Sun Mar 30 14:30:40 2025
+++ src/sbin/efi/efiio.c Sun Mar 30 14:36:48 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: efiio.c,v 1.3 2025/03/30 14:30:40 riastradh Exp $ */
+/* $NetBSD: efiio.c,v 1.4 2025/03/30 14:36:48 riastradh Exp $ */
/*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: efiio.c,v 1.3 2025/03/30 14:30:40 riastradh Exp $");
+__RCSID("$NetBSD: efiio.c,v 1.4 2025/03/30 14:36:48 riastradh Exp $");
#endif /* not lint */
#include <sys/efiio.h>
@@ -140,10 +140,10 @@ get_variable_info(int fd, bool (*choose)
memset(&ev, 0, sizeof(ev));
- ev.name = ecalloc(EFI_VARNAME_MAXLENGTH, 1);
+ ev.name = ecalloc(EFI_VARNAME_MAXBYTES, 1);
cnt = 0;
for (;;) {
- ev.namesize = EFI_VARNAME_MAXLENGTH;
+ ev.namesize = EFI_VARNAME_MAXBYTES;
if (ioctl(fd, EFIIOC_VAR_NEXT, &ev) == -1) {
char *buf;
Index: src/sys/dev/efi.c
diff -u src/sys/dev/efi.c:1.9 src/sys/dev/efi.c:1.10
--- src/sys/dev/efi.c:1.9 Wed May 24 00:02:51 2023
+++ src/sys/dev/efi.c Sun Mar 30 14:36:48 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: efi.c,v 1.9 2023/05/24 00:02:51 riastradh Exp $ */
+/* $NetBSD: efi.c,v 1.10 2025/03/30 14:36:48 riastradh Exp $ */
/*-
* Copyright (c) 2021 Jared McNeill <[email protected]>
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.9 2023/05/24 00:02:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.10 2025/03/30 14:36:48 riastradh Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -48,11 +48,11 @@ __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.9
#include "ioconf.h"
/*
- * Maximum length of an EFI variable name. The UEFI spec doesn't specify a
- * constraint, but we want to limit the size to act as a guard rail against
- * allocating too much kernel memory.
+ * Maximum length of an EFI variable name in bytes. The UEFI spec
+ * doesn't specify a constraint, but we want to limit the size to act
+ * as a guard rail against allocating too much kernel memory.
*/
-#define EFI_VARNAME_MAXLENGTH EFI_PAGE_SIZE
+#define EFI_VARNAME_MAXBYTES EFI_PAGE_SIZE
/*
* Pointer to arch specific EFI backend.
@@ -345,7 +345,7 @@ efi_ioctl_var_get(struct efi_var_ioc *va
(var->data != NULL && var->datasize == 0)) {
return EINVAL;
}
- if (var->namesize > EFI_VARNAME_MAXLENGTH) {
+ if (var->namesize > EFI_VARNAME_MAXBYTES) {
return ENOMEM;
}
if (var->datasize > ULONG_MAX) { /* XXX stricter limit */
@@ -405,7 +405,7 @@ efi_ioctl_var_next(struct efi_var_ioc *v
if (var->name == NULL || var->namesize == 0) {
return EINVAL;
}
- if (var->namesize > EFI_VARNAME_MAXLENGTH) {
+ if (var->namesize > EFI_VARNAME_MAXBYTES) {
return ENOMEM;
}
@@ -416,7 +416,7 @@ efi_ioctl_var_next(struct efi_var_ioc *v
goto done;
}
- CTASSERT(EFI_VARNAME_MAXLENGTH <= ULONG_MAX);
+ CTASSERT(EFI_VARNAME_MAXBYTES <= ULONG_MAX);
namesize = namebufsize;
status = efi_ops->efi_nextvar(&namesize, namebuf, &var->vendor);
if (status != EFI_SUCCESS && status != EFI_BUFFER_TOO_SMALL) {