From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755409AbcJNFxU (ORCPT ); Fri, 14 Oct 2016 01:53:20 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:32836 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbcJNFxQ (ORCPT ); Fri, 14 Oct 2016 01:53:16 -0400 Subject: Re: [PATCH] firmware: declare __{start,end}_builtin_fw as pointers To: Linus Torvalds , Vegard Nossum References: <1466867073-4824-1-git-send-email-vegard.nossum@oracle.com> Cc: Vegard Nossum , Ming Lei , LKML , Steven Rostedt From: Jiri Slaby Message-ID: <2d5d3a4d-5b9c-2968-df93-6a8369d06634@suse.cz> Date: Fri, 14 Oct 2016 07:52:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/26/2016, 07:17 PM, Linus Torvalds wrote: > On Sun, Jun 26, 2016 at 2:24 AM, Vegard Nossum wrote: >> >> This is the best I could come up with: assuming gcc is not allowed to >> reason about what's inside the asm(), this is the only way I could >> think of to lose the array information without incurring unnecessary >> overheads. It should also be relatively safe as there is no way to >> accidentally use the underlying arrays without explicitly declaring >> them. > > Ugh. I worry about the other places where we do things like this, > depending on the linker just assigning the addresses and us being able > to compare them. > > If there is a compiler option to disable this optimization, I would > almost prefer that.. Because we really do have a whole slew of these > things. Any update on this? Couple months later and I still hit this. Quick checking shows, that a lot code depends on comparing two arrays (undefined behaviour): ftrace_init count = __stop_mcount_loc - __start_mcount_loc; tracer_alloc_buffers if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) FWIW this indeed fixes the get_builtin_firmware case for me: --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -97,9 +97,11 @@ extern struct builtin_fw __end_builtin_fw[]; bool get_builtin_firmware(struct cpio_data *cd, const char *name) { #ifdef CONFIG_FW_LOADER - struct builtin_fw *b_fw; + struct builtin_fw *b_fw = __start_builtin_fw; - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { + OPTIMIZER_HIDE_VAR(b_fw); + + for (; b_fw != __end_builtin_fw; b_fw++) { if (!strcmp(name, b_fw->name)) { cd->size = b_fw->size; cd->data = b_fw->data; What about adding: #define for_each_vmlinux_symbol(sym, start, stop) \ for (sym = start, OPTIMIZER_HIDE_VAR(sym); sym != stop; sym++) and converting at least the iterators? What to do with the array subtractions and comparisons (like tracing), I don't know (yet). thanks, -- js suse labs