Skip to contentSkip to conversation

efi: remove modular option for ovmf-debug-log

PATCH In review Gerd Hoffmann 2 participants 2 messages Jul 9, 2025 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: remove modular option for ovmf-debug-log

Flip the driver from tristate to bool, so it can not be built modular any more. Also drop the platform device boilerplate, simply call the probe function directly instead.

---
 include/linux/efi.h                   |  2 ++
 drivers/firmware/efi/efi.c            |  2 +-
 drivers/firmware/efi/ovmf-debug-log.c | 43 ++++++---------------------
 drivers/firmware/efi/Kconfig          |  2 +-
 4 files changed, 13 insertions(+), 36 deletions(-)
include/linux/efi.h +2 -0
index a71830608422..f6da5c226fda 100644
@@ -1346,6 +1346,8 @@ bool efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table)
 
 umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n);
 
+int ovmf_log_probe(unsigned long ovmf_debug_log_table);
+
 /*
  * efivar ops event type
  */
drivers/firmware/efi/efi.c +1 -1
index 3161f918ce53..1ce428e2ac8a 100644
@@ -476,7 +476,7 @@ static int __init efisubsys_init(void)
 
 	if (IS_ENABLED(CONFIG_OVMF_DEBUG_LOG) &&
 	    efi.ovmf_debug_log != EFI_INVALID_TABLE_ADDR)
-		platform_device_register_simple("ovmf_debug_log", 0, NULL, 0);
+		ovmf_log_probe(efi.ovmf_debug_log);
 
 	return 0;
 
drivers/firmware/efi/ovmf-debug-log.c +9 -34

77 lines not on this page · raw message

drivers/firmware/efi/Kconfig +1 -1
index ac0a03ec3452..eb1bff6968a5 100644
@@ -264,7 +264,7 @@ config EFI_COCO_SECRET
 	  allows userspace programs to access the injected secrets.
 
 config OVMF_DEBUG_LOG
-	tristate "Expose OVMF firmware debug log via sysfs"
+	bool "Expose OVMF firmware debug log via sysfs"
 	depends on EFI
 	help
 	  Recent OVMF versions (edk2-stable202508 + newer) can write
Signature · 1 line
2.50.0
maintainer
#1 lore raw
Quoted 9 lines · Gerd Hoffmann

Flip the driver from tristate to bool, so it can not be built modular any more. Also drop the platform device boilerplate, simply call the probe function directly instead.

Quoted 7 lines
---
 include/linux/efi.h                   |  2 ++
 drivers/firmware/efi/efi.c            |  2 +-
 drivers/firmware/efi/ovmf-debug-log.c | 43 ++++++---------------------
 drivers/firmware/efi/Kconfig          |  2 +-
 4 files changed, 13 insertions(+), 36 deletions(-)

Thanks Gerd. I'll fold this into the existing patch instead, so we don't break bisect needlessly.

Quoted 127 lines
include/linux/efi.h +2 -0
index a71830608422..f6da5c226fda 100644
@@ -1346,6 +1346,8 @@ bool efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table)
 
 umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n);
 
+int ovmf_log_probe(unsigned long ovmf_debug_log_table);
+
 /*
  * efivar ops event type
  */
drivers/firmware/efi/efi.c +1 -1
index 3161f918ce53..1ce428e2ac8a 100644
@@ -476,7 +476,7 @@ static int __init efisubsys_init(void)
 
        if (IS_ENABLED(CONFIG_OVMF_DEBUG_LOG) &&
            efi.ovmf_debug_log != EFI_INVALID_TABLE_ADDR)
-               platform_device_register_simple("ovmf_debug_log", 0, NULL, 0);
+               ovmf_log_probe(efi.ovmf_debug_log);
 
        return 0;
 
drivers/firmware/efi/ovmf-debug-log.c +9 -34
index d4fec178fa9f..b292f35109b6 100644
@@ -64,38 +64,33 @@ static struct bin_attribute ovmf_log_bin_attr = {
        .read = ovmf_log_read,
 };
 
-static int ovmf_log_probe(struct platform_device *dev)
+__init int ovmf_log_probe(unsigned long ovmf_debug_log_table)
 {
        u64 size;
        int ret = -EINVAL;
 
-       if (efi.ovmf_debug_log == EFI_INVALID_TABLE_ADDR) {
-               dev_err(&dev->dev, "OVMF debug log: not available\n");
-               return -EINVAL;
-       }
-
        /* map + verify header */
-       hdr = memremap(efi.ovmf_debug_log, sizeof(*hdr), MEMREMAP_WB);
+       hdr = memremap(ovmf_debug_log_table, sizeof(*hdr), MEMREMAP_WB);
        if (!hdr) {
-               dev_err(&dev->dev, "OVMF debug log: header map failed\n");
+               printk(KERN_ERR "OVMF debug log: header map failed\n");
                return -EINVAL;
        }
 
        if (hdr->magic1 != OVMF_DEBUG_LOG_MAGIC1 ||
            hdr->magic2 != OVMF_DEBUG_LOG_MAGIC2) {
-               dev_err(&dev->dev, "OVMF debug log: magic mismatch\n");
+               printk(KERN_ERR "OVMF debug log: magic mismatch\n");
                goto err_unmap;
        }
 
        size = hdr->hdr_size + hdr->log_size;
-       dev_info(&dev->dev, "firmware version: \"%s\"\n", hdr->fw_version);
-       dev_info(&dev->dev, "log buffer size: %lluk\n", size / 1024);
+       printk(KERN_INFO "OVMF debug log: firmware version: \"%s\"\n", hdr->fw_version);
+       printk(KERN_INFO "OVMF debug log: buffer size: %lluk\n", size / 1024);
 
        /* map complete log buffer */
        memunmap(hdr);
-       hdr = memremap(efi.ovmf_debug_log, size, MEMREMAP_WB);
+       hdr = memremap(ovmf_debug_log_table, size, MEMREMAP_WB);
        if (!hdr) {
-               dev_err(&dev->dev, "OVMF debug log: buffer map failed\n");
+               printk(KERN_ERR "OVMF debug log: buffer map failed\n");
                return -EINVAL;
        }
        logbuf = (void *)hdr + hdr->hdr_size;
@@ -104,7 +99,7 @@ static int ovmf_log_probe(struct platform_device *dev)
        ovmf_log_bin_attr.size = size;
        ret = sysfs_create_bin_file(efi_kobj, &ovmf_log_bin_attr);
        if (ret != 0) {
-               dev_err(&dev->dev, "OVMF debug log: sysfs register failed\n");
+               printk(KERN_ERR "OVMF debug log: sysfs register failed\n");
                goto err_unmap;
        }
 
@@ -114,23 +109,3 @@ static int ovmf_log_probe(struct platform_device *dev)
        memunmap(hdr);
        return ret;
 }
-
-static void ovmf_log_remove(struct platform_device *dev)
-{
-       memunmap(hdr);
-}
-
-static struct platform_driver ovmf_log_driver = {
-       .probe = ovmf_log_probe,
-       .remove = ovmf_log_remove,
-       .driver = {
-               .name = "ovmf_debug_log",
-       },
-};
-
-module_platform_driver(ovmf_log_driver);
-
-MODULE_DESCRIPTION("OVMF debug log");
-MODULE_AUTHOR("Gerd Hoffmann <[email protected]>");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:ovmf_debug_log");
drivers/firmware/efi/Kconfig +1 -2
index ac0a03ec3452..eb1bff6968a5 100644
@@ -264,7 +264,7 @@ config EFI_COCO_SECRET
          allows userspace programs to access the injected secrets.
 
 config OVMF_DEBUG_LOG
-       tristate "Expose OVMF firmware debug log via sysfs"
+       bool "Expose OVMF firmware debug log via sysfs"
        depends on EFI
        help
          Recent OVMF versions (edk2-stable202508 + newer) can write
--

2.50.0