lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1211734802.31212.129.camel@shinybook.infradead.org>
Date:	Sun, 25 May 2008 18:00:02 +0100
From:	David Woodhouse <dwmw2@...radead.org>
To:	linux-kernel@...r.kernel.org
Cc:	sam@...nborg.org, alan@...rguk.ukuu.org.uk,
	akpm@...ux-foundation.org, johannes@...solutions.net
Subject: [PATCHv3 27/28] firmware: Add CONFIG_BUILTIN_FIRMWARE option

Feedback/patches from Johannes Berg -- sort $(firmware_dirs) to prevent
make from complaining about duplicates, and don't unconditionally depend
on include/config/64bit.h. Also fix O= compilation again by including
$(srctree) in the filename passed to .incbin in the .S files.

I also fixed up the dependencies for the object files built from
binaries -- the .S file doesn't need to depend on the binary, but the .o
does.

Still don't have the behaviour we want from clean/mrproper, but I think
we need Sam's help with that.

commit bb71d4c53b14456ec591eb579923566f9c3302ed
Author: David Woodhouse <dwmw2@...radead.org>
Date:   Fri May 23 13:58:12 2008 +0100

    firmware: Add CONFIG_BUILTIN_FIRMWARE option
    
    This allows arbitrary firmware files to be included in the static kernel
    where the firmware loader can find them without requiring userspace to
    be alive.
    
    Signed-off-by: David Woodhouse <dwmw2@...radead.org>

diff --git a/Makefile b/Makefile
index 20b3235..ac2ab7e 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ scripts: scripts_basic include/config/auto.conf
 
 # Objects we will link into vmlinux / subdirs we need to visit
 init-y		:= init/
-drivers-y	:= drivers/ sound/
+drivers-y	:= drivers/ sound/ firmware/
 net-y		:= net/
 libs-y		:= lib/
 core-y		:= usr/
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d7da109..b856fe8 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -34,6 +34,18 @@ config FW_LOADER
 	  require userspace firmware loading support, but a module built outside
 	  the kernel tree does.
 
+config BUILTIN_FIRMWARE
+	string "Firmware blobs to build into the kernel binary"
+	depends on FW_LOADER
+	help
+	  This option allows firmware to be built into the kernel, for the
+	  cases where the user either cannot or doesn't want to provide it from
+	  userspace at runtime (for example, when the firmware in question is
+	  required for accessing the boot device, and the user doesn't want to
+	  use an initrd). Multiple files should be separated with spaces, and
+	  the required files should exist under the firmware/ directory in
+	  the source tree.
+
 config DEBUG_DRIVER
 	bool "Driver Core verbose debug messages"
 	depends on DEBUG_KERNEL
diff --git a/firmware/Makefile b/firmware/Makefile
new file mode 100644
index 0000000..02e0a05
--- /dev/null
+++ b/firmware/Makefile
@@ -0,0 +1,70 @@
+#
+# kbuild file for firmware/
+#
+
+firmware-y :=
+
+firmware_bins := $(subst ",,$(CONFIG_BUILTIN_FIRMWARE))
+firmware_srcs := $(patsubst %,$(obj)/%.S, $(firmware_bins))
+firmware_objs := $(patsubst %,%.o, $(firmware_bins) $(firmware-y))
+firmware_dirs := $(sort $(patsubst %,$(objtree)/$(obj)/%,$(dir $(firmware_objs))))
+
+quiet_cmd_mkdir = MKDIR   $@
+      cmd_mkdir = mkdir -p $@
+
+ifdef CONFIG_64BIT
+ASM_WORD := .quad
+ASM_ALIGN := 3
+else
+ASM_WORD := .long
+ASM_ALIGN := 2
+endif
+
+quiet_cmd_fwbin = MK_FW   $@
+      cmd_fwbin = FWNAME="$(patsubst firmware/%.S,%,$@)";		     \
+		  INCFILE="$(srctree)/$(patsubst %.S,%,$@)";		     \
+		  FWSTR="$(subst /,_,$(subst .,_,$(patsubst 		     \
+				firmware/%.S,%,$@)))";			     \
+		  echo "/* Generated by firmware/Makefile */"		> $@;\
+		  echo "    .section .rodata"				>>$@;\
+		  echo "    .align $(ASM_ALIGN)"			>>$@;\
+		  echo "_fw_$${FWSTR}_bin:"				>>$@;\
+		  echo "    .incbin \"$$INCFILE\""			>>$@;\
+		  echo "_fw_end:"					>>$@;\
+		  echo "   .section .rodata.str,\"aMS\",@progbits,1"	>>$@;\
+		  echo "    .align $(ASM_ALIGN)"			>>$@;\
+		  echo "_fw_$${FWSTR}_name:"				>>$@;\
+		  echo "    .string \"$$FWNAME\""			>>$@;\
+		  echo "    .section .builtin_fw,\"a\",@progbits"	>>$@;\
+		  echo "    .align $(ASM_ALIGN)"			>>$@;\
+		  echo "    $(ASM_WORD) _fw_$${FWSTR}_name" 		>>$@;\
+		  echo "    $(ASM_WORD) _fw_$${FWSTR}_bin" 		>>$@;\
+		  echo "    $(ASM_WORD) _fw_end - _fw_$${FWSTR}_bin"	>>$@;
+
+# One of these files will change, or come into existence, whenever
+# the configuration changes between 32-bit and 64-bit...
+DEPS_64BIT := $(wildcard include/config/64bit.h include/config/32bit.h \
+		include/config/ppc32.h include/config/ppc64.h \
+		include/config/superh32.h include/config/superh64.h \
+		include/config/x86_32.h include/config/x86_64.h)
+
+# ... and the .S files must change when that happens.
+$(firmware_srcs): $(DEPS_64BIT)
+	$(call cmd,fwbin)
+
+# The .o files depend directly on the binary because it's included in
+# the .S file with .incbin -- so the .S file doesn't need to change.
+$(patsubst %.S,%.o,$(firmware_srcs)): %.o: %
+
+$(firmware_dirs):
+	$(call cmd,mkdir)
+
+$(patsubst %,$(obj)/%,$(firmware_objs)): $(firmware_dirs)
+
+obj-y := $(firmware_objs)
+
+targets := $(firmware_objs) $(patsubst $(obj)/%,%, $(firmware_srcs))
+
+# Without this, built-in.o won't be created when it's empty, and the
+# final vmlinux link will fail.
+obj-n := dummy


-- 
dwmw2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ