From patchwork Thu Dec 22 02:38:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9484145 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 A9D1D601D4 for ; Thu, 22 Dec 2016 02:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FFA8282E2 for ; Thu, 22 Dec 2016 02:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93DF628410; Thu, 22 Dec 2016 02:41:42 +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 07E11282E2 for ; Thu, 22 Dec 2016 02:41:42 +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 1cJtHe-0003wm-7x; Thu, 22 Dec 2016 02:39:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cJtHc-0003va-PE for xen-devel@lists.xensource.com; Thu, 22 Dec 2016 02:39:04 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id AB/A6-04025-8CC3B585; Thu, 22 Dec 2016 02:39:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVybKJsh+5xm+g Ig54TAhb3prxnd2D02N63iz2AMYo1My8pvyKBNWPOr89sBY80Ks4+PcTawHhFsYuRi0NIYCqj xJKJB9khnGVMEgcvv2DrYuTgYBPQlbh5WwIkLiLwj0ni3aQGVhCHWeAPj8TtKZ8ZQYqEBTwln rx16mLk5GARUJU4uX0uI4jNK2Am0dW2GsyWEJCXWHj+CBOIzSlgLjH19CYWkFYhgRyJV/f4IU oyJOb1zGGFsL0kFt24BGWrSVw9t4l5AiPfAkaGVYwaxalFZalFukZmeklFmekZJbmJmTm6hga mermpxcWJ6ak5iUnFesn5uZsYgWFSz8DAuIPx9mS/Q4ySHExKoryntKMjhPiS8lMqMxKLM+KL SnNSiw8xynBwKEnwTrAGygkWpaanVqRl5gADFiYtwcGjJMK71RIozVtckJhbnJkOkTrFqCglz nsLpE8AJJFRmgfXBouSS4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEebeDTOHJzCuBm/4KaD ET0OKF3eEgi0sSEVJSDYztsecnXuFVsvv0REQ2SIdjye/Mtu+3D7Lv/t4zr/CvhXDh16kGaxj MBGzvi34+suddHk/zT40bshO3ztoW0ewSMr3nwdpLf1hMN5117Zbdrs/39Pn9/asUdp/qY5l+ wSM1eXnak1jnawVx6RGXuJ78DDmeKanYPHX/vc9rilaE+/VXlHeGn1+ixFKckWioxVxUnAgAN gFl840CAAA= X-Env-Sender: mcgrof@kernel.org X-Msg-Ref: server-14.tower-206.messagelabs.com!1482374341!37860305!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 8401 invoked from network); 22 Dec 2016 02:39:02 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-14.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Dec 2016 02:39:02 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56937203DB; Thu, 22 Dec 2016 02:39:00 +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 6129B203C0; Thu, 22 Dec 2016 02:38:56 +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: Wed, 21 Dec 2016 18:38:03 -0800 Message-Id: <20161222023811.21246-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161222023811.21246-1-mcgrof@kernel.org> References: <1471642454-5679-1-git-send-email-mcgrof@kernel.org> <20161222023811.21246-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 v5 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. 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 c4bb2f7169f6..09133ef2c31b 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..94f2cf24d85d 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 */ \