From patchwork Mon Jan 9 14:58:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9505019 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 ABB6D60710 for ; Mon, 9 Jan 2017 15:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E406284C2 for ; Mon, 9 Jan 2017 15:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9200A284E5; Mon, 9 Jan 2017 15:01:58 +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 07C5C284C2 for ; Mon, 9 Jan 2017 15:01:58 +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 1cQbPy-0007o7-40; Mon, 09 Jan 2017 14:59:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQbPw-0007ma-VR for xen-devel@lists.xensource.com; Mon, 09 Jan 2017 14:59:25 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 66/EB-29440-C45A3785; Mon, 09 Jan 2017 14:59:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsVybKJsh6730uI Igyc7JS3uTXnP7sDosb1vF3sAYxRrZl5SfkUCa8a9H4fZCmZpVkzd/5+9gbFJqYuRi0NIYCqj xOPOV2wQzjImiS2f/gE5HBxsAroSN29LgMRFBP4xSbyb1MAK4jAL/OGRuD3lM2MXIyeHsICnx PvpL9lBGlgEVCXal4SDhHkFzCRmXL7DBGJLCMhL7Gq7yApicwqYS8y/sBbMFhJIkji3+gJYq4 RAgcT+w9EQ5V4Si25cYoWw1SSuntvEPIGRbwEjwypG9eLUorLUIl0zvaSizPSMktzEzBxdQwM zvdzU4uLE9NScxKRiveT83E2MwCBhAIIdjPNO+B9ilORgUhLldYwqiBDiS8pPqcxILM6ILyrN SS0+xCjDwaEkwcu6pDhCSLAoNT21Ii0zBxiuMGkJDh4lEd5Ti4HSvMUFibnFmekQqVOMilLiv EdAEgIgiYzSPLg2WIxcYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjAvG8h2nsy8Erjpr4AWMw EtjrQDW1ySiJCSamAs+LJNdlkJ81EunpZZtl+13y8S5E+qcNu3OGWL+hatK9y6ksJ+L7QYJpy vv7K/5YtRocPTxCV7zyywX/R6CYdp6HaDcNk/FwI2i+7abat24tvMmKPT5xV5NTLcFtx55MSL /oyr+yUOCh7Uf8/E1jndkOfcb/uHYvfWcMbvPrDNbtHUyo5D7hVrlViKMxINtZiLihMB89m0M YwCAAA= X-Env-Sender: mcgrof@kernel.org X-Msg-Ref: server-3.tower-21.messagelabs.com!1483973962!51203242!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 57550 invoked from network); 9 Jan 2017 14:59:23 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-3.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 9 Jan 2017 14:59:23 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E41D42015A; Mon, 9 Jan 2017 14:59:16 +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 2C9F1203A5; Mon, 9 Jan 2017 14:59:13 +0000 (UTC) From: "Luis R. Rodriguez" To: hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, mingo@redhat.com, jpoimboe@redhat.com, bp@alien8.de, 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: Mon, 9 Jan 2017 06:58:25 -0800 Message-Id: <20170109145833.11502-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170109145833.11502-1-mcgrof@kernel.org> References: <20161222023811.21246-1-mcgrof@kernel.org> <20170109145833.11502-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, 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 v6 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 */ \