Skip to contentSkip to conversation

efivars update for 2.6.1

PATCH In review Matt Tolentino 4 participants 4 messages Jan 13, 2004 – Jan 15, 2004 EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efivars update for 2.6.1

Andrew, David:

Here's a patch that has been posted here before, but not yet merged. Essentially, it converts efivars (i.e. Matt Domsch's driver that provides access to the EFI variable runtime services) to export variable information and systab info via sysfs. So the tree looks something like this crude diagram:

/sys |

     ...
     |-firmware 
	       |-efi
		   |-systab
		   |-vars 
			 |- BootNext-xxxx-xxx-x-x-x-x *
				|-attributes
				|-data
				|-guid
				|-raw_var
				|-size
			 |- BootCurrent-xxxxxx-x-x-x-x *
			 ...
			 |- del_var
			 |- new_var 

* s.t. {x|-}* is an EFI defined guid

The systab attribute displays the same table info that was previously available via /proc/efi/systab. The variables may be added or deleted via del_var and new_var. Details for each variable may be inspected as well.

This patch also creates a new directory drivers/efi into which I've moved the efivars driver instead of adding multiple exact copies into each architecture that supports EFI. Also, the selection of the efivars driver is contingent on CONFIG_EFI.

Feedback is welcome, so let me know if you have any questions. Please consider applying.

thanks,
matt

arch/i386/Kconfig +2 -0
diff -urNp linux-2.6.1/arch/i386/Kconfig linux-2.6.1-efivars/arch/i386/Kconfig
@@ -808,6 +808,8 @@ config EFI
 	anything about EFI).  However, even with this option, the resultant
 	kernel should continue to boot on existing non-EFI platforms.
 
+source "drivers/efi/Kconfig"
+
 config HAVE_DEC_LOCK
 	bool
 	depends on (SMP || PREEMPT) && X86_CMPXCHG
arch/i386/kernel/efi.c +2 -13
diff -urNp linux-2.6.1/arch/i386/kernel/efi.c linux-2.6.1-efivars/arch/i386/kernel/efi.c
@@ -28,7 +28,7 @@
 #include <linux/spinlock.h>
 #include <linux/bootmem.h>
 #include <linux/ioport.h>
-#include <linux/proc_fs.h>
+#include <linux/module.h>
 #include <linux/efi.h>
 
 #include <asm/setup.h>
@@ -46,6 +46,7 @@
 extern efi_status_t asmlinkage efi_call_phys(void *, ...);
 
 struct efi efi;
+EXPORT_SYMBOL(efi);
 struct efi efi_phys __initdata;
 struct efi_memory_map memmap __initdata;
 
@@ -55,18 +56,6 @@ struct efi_memory_map memmap __initdata;
 extern void * boot_ioremap(unsigned long, unsigned long);
 
 /*
- * efi_dir is allocated here, but the directory isn't created
- * here, as proc_mkdir() doesn't work this early in the bootup
- * process.  Therefore, each module, like efivars, must test for
- *    if (!efi_dir) efi_dir = proc_mkdir("efi", NULL);
- * prior to creating their own entries under /proc/efi.
- */
-#ifdef CONFIG_PROC_FS
-struct proc_dir_entry *efi_dir;
-#endif
-
-
-/*
  * To make EFI call EFI runtime service in physical addressing mode we need
  * prelog/epilog before/after the invocation to disable interrupt, to
  * claim EFI runtime service handler exclusively and to duplicate a memory in
arch/ia64/Kconfig +1 -9
diff -urNp linux-2.6.1/arch/ia64/Kconfig linux-2.6.1-efivars/arch/ia64/Kconfig
@@ -400,15 +400,7 @@ config EFI
 	depends on !IA64_HP_SIM
 	default y
 
-config EFI_VARS
-	tristate "/proc/efi/vars support"
-	help
-	  If you say Y here, you are able to get EFI (Extensible Firmware
-	  Interface) variable information in /proc/efi/vars.  You may read,
-	  write, create, and destroy EFI variables through this interface.
-
-	  To use this option, you have to check that the "/proc file system
-	  support" (CONFIG_PROC_FS) is enabled, too.
+source "drivers/efi/Kconfig"
 
 config NR_CPUS
 	int "Maximum number of CPUs"
arch/ia64/kernel/efi.c +0 -20
diff -urNp linux-2.6.1/arch/ia64/kernel/efi.c linux-2.6.1-efivars/arch/ia64/kernel/efi.c
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/time.h>
-#include <linux/proc_fs.h>
 #include <linux/efi.h>
 
 #include <asm/io.h>
@@ -39,17 +38,6 @@ extern efi_status_t efi_call_phys (void 
 struct efi efi;
 static efi_runtime_services_t *runtime;
 
-/*
- * efi_dir is allocated here, but the directory isn't created
- * here, as proc_mkdir() doesn't work this early in the bootup
- * process.  Therefore, each module, like efivars, must test for
- *    if (!efi_dir)  efi_dir = proc_mkdir("efi", NULL);
- * prior to creating their own entries under /proc/efi.
- */
-#ifdef CONFIG_PROC_FS
-struct proc_dir_entry *efi_dir;
-#endif
-
 static unsigned long mem_limit = ~0UL;
 
 #define efi_call_virt(f, args...)	(*(f))(args)
@@ -748,11 +736,3 @@ valid_phys_addr_range (unsigned long phy
 	}
 	return 0;
 }
-
-static void __exit
-efivars_exit (void)
-{
-#ifdef CONFIG_PROC_FS
- 	remove_proc_entry(efi_dir->name, NULL);
-#endif
-}
arch/ia64/kernel/efivars.c +0 -508

508 lines not on this page · raw message

arch/ia64/kernel/ia64_ksyms.c +0 -4
diff -urNp linux-2.6.1/arch/ia64/kernel/ia64_ksyms.c linux-2.6.1-efivars/arch/ia64/kernel/ia64_ksyms.c
@@ -152,10 +152,6 @@ EXPORT_SYMBOL(ia64_save_scratch_fpregs);
 extern struct efi efi;
 EXPORT_SYMBOL(efi);
 
-#include <linux/proc_fs.h>
-extern struct proc_dir_entry *efi_dir;
-EXPORT_SYMBOL(efi_dir);
-
 #include <asm/machvec.h>
 #ifdef CONFIG_IA64_GENERIC
 EXPORT_SYMBOL(ia64_mv);
arch/ia64/kernel/Makefile +0 -1
diff -urNp linux-2.6.1/arch/ia64/kernel/Makefile linux-2.6.1-efivars/arch/ia64/kernel/Makefile
@@ -8,7 +8,6 @@ obj-y := acpi.o entry.o efi.o efi_stub.o
 	 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o		\
 	 salinfo.o semaphore.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o unwind.o
 
-obj-$(CONFIG_EFI_VARS)		+= efivars.o
 obj-$(CONFIG_IA64_BRL_EMU)	+= brl_emu.o
 obj-$(CONFIG_IA64_GENERIC)	+= acpi-ext.o
 obj-$(CONFIG_IA64_HP_ZX1)	+= acpi-ext.o
arch/ia64/mm/init.c +1 -0
diff -urNp linux-2.6.1/arch/ia64/mm/init.c linux-2.6.1-efivars/arch/ia64/mm/init.c
@@ -18,6 +18,7 @@
 #include <linux/reboot.h>
 #include <linux/slab.h>
 #include <linux/swap.h>
+#include <linux/proc_fs.h>
 
 #include <asm/a.out.h>
 #include <asm/bitops.h>
drivers/efi/efivars.c +745 -0

745 lines not on this page · raw message

drivers/efi/Kconfig +18 -0
diff -urNp linux-2.6.1/drivers/efi/Kconfig linux-2.6.1-efivars/drivers/efi/Kconfig
@@ -0,0 +1,18 @@
+#
+# EFI Driver Configuration
+#
+
+menu "EFI driver support"
+depends on EFI
+
+config EFI_VARS
+	tristate "EFI Variable Support via sysfs"
+	depends on EFI
+	default n
+	---help---
+	  If you say Y here, you are able to get EFI (Extensible Firmware
+	  Interface) variable information via sysfs.  You may read,
+	  write, create, and destroy EFI variables through this interface.
+
+
+endmenu
drivers/efi/Makefile +4 -0
diff -urNp linux-2.6.1/drivers/efi/Makefile linux-2.6.1-efivars/drivers/efi/Makefile
@@ -0,0 +1,4 @@
+# EFI Variable Access
+
+obj-$(CONFIG_EFI_VARS)		+= efivars.o
+
drivers/Makefile +1 -0
diff -urNp linux-2.6.1/drivers/Makefile linux-2.6.1-efivars/drivers/Makefile
@@ -49,3 +49,4 @@ obj-$(CONFIG_ISDN_BOOL)		+= isdn/
 obj-$(CONFIG_MCA)		+= mca/
 obj-$(CONFIG_EISA)		+= eisa/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
+obj-$(CONFIG_EFI)		+= efi/
include/linux/efi.h +1 -7
diff -urNp linux-2.6.1/include/linux/efi.h linux-2.6.1-efivars/include/linux/efi.h
@@ -15,9 +15,9 @@
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/types.h>
-#include <linux/proc_fs.h>
 #include <linux/rtc.h>
 #include <linux/ioport.h>
+#include <linux/kobject.h>
 
 #include <asm/page.h>
 #include <asm/system.h>
@@ -315,11 +315,5 @@ extern int efi_enabled;
 #define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
 
 
-/*
- * efi_dir is allocated in arch/ia64/kernel/efi.c.
- */
-#ifdef CONFIG_PROC_FS
-extern struct proc_dir_entry *efi_dir;
-#endif
 
 #endif /* _LINUX_EFI_H */
#1 lore raw
Quoted 5 lines · Matt Tolentino

Andrew, David:

Here's a patch that has been posted here before, but not yet merged.

Big, isn't it?

Quoted 4 lines

Essentially, it converts efivars (i.e. Matt Domsch's driver that provides access to the EFI variable runtime services) to export variable information and systab info via sysfs.

I'd need confirmation from David M-T and if poss a quick review from Greg K-H.

From a super-quick scan:

- Someone seems to have mangled the files with an editor which doesn't understand hard tabs.

- This function:

	> +static void __exit
	> +efivars_exit(void)
	> +{
	> +	struct list_head *pos, *n;
	> +
	> +        spin_lock(&efivars_lock);
	> +
	> +	list_for_each_safe(pos, n, &efivar_list)
	> +		efivar_unregister(get_efivar_entry(pos));
	> +
	> +	spin_unlock(&efivars_lock);
	> +
	> +	subsystem_unregister(&vars_subsys);
	> +	firmware_unregister(&efi_subsys);
	> +}

cannot call efivar_unregister() under spinlock - it does all sorts of illegal-under-spinlock things.

#2 lore raw
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Andrew Morton

Essentially, it converts efivars (i.e. Matt Domsch's driver that provides access to the EFI variable runtime services) to export variable information and systab info via sysfs.

Andrew> I'd need confirmation from David M-T and if poss a quick Andrew> review from Greg K-H.

Matt is the owner of efivars so if he is OK with it, that's fine with me. My only request is that if/when the patch is accepted that there is some documentation that makes it clear where one can can get an updated/matching efibootmgr from.

	--david
#3 lore raw
Quoted 4 lines

Matt is the owner of efivars so if he is OK with it, that's fine with me. My only request is that if/when the patch is accepted that there is some documentation that makes it clear where one can can get an updated/matching efibootmgr from.

Andrew found a spinlock use bug in efivars_exit that needs to get fixed first. Then I'm fine with it.

efibootmgr 0.5.0-test1 is available at
http://domsch.com/linux/ia64/efibootmgr/testing/efibootmgr-0.5.0-test1.tar.gz

which supports both /proc-style and sysfs-style accesses. With additional feedback that it works as expected for several people, I'll remove the 'test' moniker.

Thanks,
Matt

Signature · 4 lines
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com