From patchwork Sun Jan 15 21:10:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9517843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17CFD600F6 for ; Sun, 15 Jan 2017 21:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC8E726CF9 for ; Sun, 15 Jan 2017 21:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C062728412; Sun, 15 Jan 2017 21:14:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DBBE26CF9 for ; Sun, 15 Jan 2017 21:14:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSs5b-00086d-1G; Sun, 15 Jan 2017 21:11:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSs5Z-00084f-Ab for xen-devel@lists.xensource.com; Sun, 15 Jan 2017 21:11:45 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 7E/BA-02804-095EB785; Sun, 15 Jan 2017 21:11:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVybKJsh27/0+o Ig/P/eS3uTXnP7sDosb1vF3sAYxRrZl5SfkUCa8a9H4fZCmZpVkzd/5+9gbFJqYuRi0NIYCqj xPLzlxghnGVMEjdXLmftYuTgYBPQlbh5WwIkLiLQzSzxad5OsCJmgT88ErenfAZyODmEBTwlH uxoBLNZBFQltu89xQjSzCtgJrH+OTNIWEJAXmJX20VWEJtTwFyic/4LNpASIYEkiaZNLhAlGR LzeuawQtheEotuXIKy1SSuntvEPIGRbwEjwypGjeLUorLUIl0jM72kosz0jJLcxMwcXUMDY73 c1OLixPTUnMSkYr3k/NxNjMAwqWdgYNzB2LDX7xCjJAeTkijvMZ3qCCG+pPyUyozE4oz4otKc 1OJDjDIcHEoSvKzAsBMSLEpNT61Iy8wBBixMWoKDR0mE98ZjoDRvcUFibnFmOkTqFKOilDivx xOghABIIqM0D64NFiWXGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnzKoBM4cnMK4Gb/gpoMR PQ4us6YItLEhFSUg2Mms3ZkZxmVRPs9/SukFwsGPLwe76Vs0Pftrhmu1/rLB75VgYvWTJlyxe hSuaEgjdlppWyiz78cv1sdolBsLi69pTW95qoqA8KSWLSivKW3qm7g2e5X+jec9S0KGVpzzSd /neXOjf+nPDCjKWz4NSM1YLad3f/7rdnU5uQ8P/7wi1vI+e+vlqpxFKckWioxVxUnAgAzNbNA I0CAAA= X-Env-Sender: mcgrof@kernel.org X-Msg-Ref: server-15.tower-31.messagelabs.com!1484514701!76634343!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6014 invoked from network); 15 Jan 2017 21:11:42 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-15.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jan 2017 21:11:42 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 251FF205AA; Sun, 15 Jan 2017 21:11:40 +0000 (UTC) Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A9886205BE; Sun, 15 Jan 2017 21:11:35 +0000 (UTC) From: "Luis R. Rodriguez" To: bp@alien8.de, bp@suse.de, hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, mingo@redhat.com, jpoimboe@redhat.com, npiggin@gmail.com, mhiramat@kernel.org, masami.hiramatsu.pt@hitachi.com, jbaron@akamai.com, heiko.carstens@de.ibm.com, ananth@linux.vnet.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, realmz6@gmail.com, dalias@libc.org, linux@arm.linux.org.uk Date: Sun, 15 Jan 2017 13:10:50 -0800 Message-Id: <20170115211057.17167-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170115211057.17167-1-mcgrof@kernel.org> References: <20170109145833.11502-1-mcgrof@kernel.org> <20170115211057.17167-1-mcgrof@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: gnomes@lxorguk.ukuu.org.uk, linux-ia64@vger.kernel.org, jkosina@suse.cz, benh@kernel.crashing.org, ming.lei@canonical.com, linux@rasmusvillemoes.dk, platform-driver-x86@vger.kernel.org, James.Bottomley@HansenPartnership.com, paul.gortmaker@windriver.com, paulus@samba.org, sparclinux@vger.kernel.org, wangnan0@huawei.com, Michael Matz , Barry Song , mchehab@osg.samsung.com, linux-arch@vger.kernel.org, markus.heiser@darmarit.de, xen-devel@lists.xensource.com, msalter@redhat.com, linux-sh@vger.kernel.org, mpe@ellerman.id.au, joro@8bytes.org, x86@kernel.org, fontana@sharpeleven.org, dsahern@gmail.com, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, dvhart@infradead.org, dwmw2@infradead.org, linux@roeck-us.net, linux-xtensa@linux-xtensa.org, pali.rohar@gmail.com, Mike Frysinger , keescook@chromium.org, arnd@arndb.de, konrad.wilk@oracle.com, jani.nikula@intel.com, will.deacon@arm.com, rusty@rustcorp.com.au, rostedt@goodmis.org, ak@linux.intel.com, namhyung@kernel.org, andriy.shevchenko@linux.intel.com, mcb30@ipxe.org, linux-kbuild@vger.kernel.org, alan@linux.intel.com, jgross@suse.com, chris@zankel.net, pebolle@tiscali.nl, tony.luck@intel.com, jcmvbkbc@gmail.com, gregkh@linuxfoundation.org, dmitry.torokhov@gmail.com, adrian.hunter@intel.com, luto@amacapital.net, "Luis R. Rodriguez" , mmarek@suse.com, david.vrabel@citrix.com, jolsa@kernel.org, andrew.cooper3@citrix.com, akpm@linux-foundation.org, Fengguang Wu , torvalds@linux-foundation.org, korea.drzix@gmail.com Subject: [Xen-devel] [PATCH v7 07/14] firmware: port built-in section to linker table X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This ports built-in firmware to use linker tables, this replaces the custom section solution with a generic solution. This also demos the use of the .rodata linker table. Tested with 0 built-in firmware, 1 and 2 built-in firmwares successfully. v6: rename table macro as suggested by Andy Shevchenko v5: o since we dropped SECTION_ORDER_ANY, use 'any' order level explicitly v4: o work around c6x toolchain bug by using SECTION_TBL_RO o fix compilation on blackfin v3: o explicitly include tables.h as we no longer include tables.h from sections.h o use new section_tbl_asmtype() helper on firmware/Makefile to enable having to unfold things on our own. v2: introduced this file in this version of the series Cc: Barry Song Cc: Mike Frysinger Cc: Steven Miao Cc: Michael Matz Cc: Guenter Roeck Cc: Fengguang Wu Signed-off-by: Luis R. Rodriguez --- arch/x86/kernel/cpu/microcode/core.c | 8 ++++---- drivers/base/firmware_class.c | 12 ++++++------ firmware/Makefile | 3 ++- include/asm-generic/vmlinux.lds.h | 7 ------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 2af69d27da62..2c5004343b45 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -110,15 +111,14 @@ static bool __init check_loader_disabled_bsp(void) return *res; } -extern struct builtin_fw __start_builtin_fw[]; -extern struct builtin_fw __end_builtin_fw[]; +DECLARE_LINKTABLE_RO(struct builtin_fw, builtin_fw); bool get_builtin_firmware(struct cpio_data *cd, const char *name) { #ifdef CONFIG_FW_LOADER - struct builtin_fw *b_fw; + const struct builtin_fw *b_fw; - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { + linktable_for_each(b_fw, builtin_fw) { if (!strcmp(name, b_fw->name)) { cd->size = b_fw->size; cd->data = b_fw->data; diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 4497d263209f..b9ac348e8d33 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -44,15 +45,14 @@ MODULE_LICENSE("GPL"); #ifdef CONFIG_FW_LOADER -extern struct builtin_fw __start_builtin_fw[]; -extern struct builtin_fw __end_builtin_fw[]; +DEFINE_LINKTABLE_RO(struct builtin_fw, builtin_fw); static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, void *buf, size_t size) { - struct builtin_fw *b_fw; + const struct builtin_fw *b_fw; - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { + linktable_for_each(b_fw, builtin_fw) { if (strcmp(name, b_fw->name) == 0) { fw->size = b_fw->size; fw->data = b_fw->data; @@ -68,9 +68,9 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, static bool fw_is_builtin_firmware(const struct firmware *fw) { - struct builtin_fw *b_fw; + const struct builtin_fw *b_fw; - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) + linktable_for_each(b_fw, builtin_fw) if (fw->data == b_fw->data) return true; diff --git a/firmware/Makefile b/firmware/Makefile index fa3e81c2a97b..9c8cae144ede 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -155,6 +155,7 @@ quiet_cmd_fwbin = MK_FW $@ ASM_ALIGN=$(if $(CONFIG_64BIT),3,2); \ PROGBITS=$(if $(CONFIG_ARM),%,@)progbits; \ echo "/* Generated by firmware/Makefile */" > $@;\ + echo "\#include " >>$@;\ echo " .section .rodata" >>$@;\ echo " .p2align $${ASM_ALIGN}" >>$@;\ echo "_fw_$${FWSTR}_bin:" >>$@;\ @@ -164,7 +165,7 @@ quiet_cmd_fwbin = MK_FW $@ echo " .p2align $${ASM_ALIGN}" >>$@;\ echo "_fw_$${FWSTR}_name:" >>$@;\ echo " .string \"$$FWNAME\"" >>$@;\ - echo " .section .builtin_fw,\"a\",$${PROGBITS}" >>$@;\ + echo " set_section_tbl_type(SECTION_TBL_RO, builtin_fw, any, a,$${PROGBITS})" >>$@;\ echo " .p2align $${ASM_ALIGN}" >>$@;\ echo " $${ASM_WORD} _fw_$${FWSTR}_name" >>$@;\ echo " $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@;\ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index ce1e9a310ada..8a5325d75932 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -324,13 +324,6 @@ VMLINUX_SYMBOL(__end_pci_fixups_suspend_late) = .; \ } \ \ - /* Built-in firmware blobs */ \ - .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \ - VMLINUX_SYMBOL(__start_builtin_fw) = .; \ - KEEP(*(.builtin_fw)) \ - VMLINUX_SYMBOL(__end_builtin_fw) = .; \ - } \ - \ TRACEDATA \ \ /* Kernel symbol table: Normal symbols */ \