Received: by 10.213.65.68 with SMTP id h4csp1376750imn; Wed, 14 Mar 2018 19:34:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELsJj/8pn2fOI5teuxfoKt2Wt5i/BNywoq8CYi6FM/73o6VRr/7WVkXJi0AQmZPpupwqJewM X-Received: by 2002:a17:902:3283:: with SMTP id z3-v6mr6145640plb.118.1521081286258; Wed, 14 Mar 2018 19:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521081286; cv=none; d=google.com; s=arc-20160816; b=spenGM/LOG9qekwi2s4XojBa4sfXm9QGu82x6cQejJDCIIe7FRcG8PqbZm0OpOB3m2 dWK20ZkhUF3/xFTzSxYG5fw7tIvbszdd6+EsfRKI+6A3Vly7iRothcpw7PrKKI77kVtj E+TVna42aB/A2UsZovKqJ3DFxXoQpo02hRrTcU5z0zLxCu/SF/KKC4eBlI7AHVR1zBcE 48VcICGfBNLvYnn5rCDI3F0AGDa8+149pFo/QNnr07byjZSw80VbvwgKz5r5XtMu+k9U VmOZ+huniQEnHrrXAcMVdJtSPc8RAQhSz5DSMIOM4tGOBUYrd5hDQ0V/YPsmrprRfJG4 oBug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=KYMde5wQB+95EWim+f9P9cYiV++xstVd5fWTgOLGDyk=; b=e44gkY+De9ebe4MOepqYiENnN5HaQ42qak13hKIDIIofpxa2a1yo/Jw8zRWiiX/zOD rlBZPcj4tvbEE5LmmZyTTmCd53QQPNLOeXYlcU/l42BPOJJG8wAG3go+iSNWBD4bXaYb 2d7/nYpgop2K6+UVWcIrSSt9cBiJB3WfLSFGF1ICuThq0ZuKcBkzN5SGQ9sMX09M/Tt2 ALPWNcOta04YMXAk+egLBo6m7kwY0WNYA5hKT3iAlxbbtniqwI8+oEfRUJ6wWDsnuc4W l0AVA8gCKbJTyASKFnM4apkX6slmjocAz5s48TOXLUtMmrDkpBWmaM7hV5qnMcIb+bsZ SeLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WfBeJ//H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q87si3078208pfa.385.2018.03.14.19.34.31; Wed, 14 Mar 2018 19:34:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WfBeJ//H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbeCOCdg (ORCPT + 99 others); Wed, 14 Mar 2018 22:33:36 -0400 Received: from merlin.infradead.org ([205.233.59.134]:45344 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbeCOCde (ORCPT ); Wed, 14 Mar 2018 22:33:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KYMde5wQB+95EWim+f9P9cYiV++xstVd5fWTgOLGDyk=; b=WfBeJ//Hyi3rXfwc77/EmG+IV5 ydt6brAnrzdjaVzl4GRCgPzIo4wnxe/Z2wjg8yAHw4RPy0Y6brx2w4+iLhJ3BO34rCswEmXT9Nxfi inXBiIUq00BpQO5gVMefEnXT50Wy+jl5stZkodBY65TchwmrN1ePtQbpsh22yA7mvuk1l2D/NEmsP COqj7JqPvREhvr1KZVgjr6sjix2ZHpe4/qA3J1iijKOovqCVjMRsqsEIWFof63JR5TiEWJRCf9MNh QliBywqcjq8kKX26Uf4AuNiGxIrUcUo+fWy3yQZJOHZ/b2jy+tELCEyHxXYcVpVDvHTj46Vn+YsnN PAMoGhww==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewIhv-0007yS-4f; Thu, 15 Mar 2018 02:33:31 +0000 Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again To: Daniel Kurtz , Peter Hurley , Rob Herring Cc: adurbin@chromium.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Grant Likely , Rob Herring , Frank Rowand , Jiri Slaby , Arnd Bergmann , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , "open list:SERIAL DRIVERS" , "open list:GENERIC INCLUDE/ASM HEADER FILES" References: <20180315014817.142930-1-djkurtz@chromium.org> From: Randy Dunlap Message-ID: <398eebd9-9ec9-50ef-88ea-c3d5ae9f5d90@infradead.org> Date: Wed, 14 Mar 2018 19:33:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180315014817.142930-1-djkurtz@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/14/2018 06:48 PM, Daniel Kurtz wrote: > Commit 470ca0de69fe ("serial: earlycon: Enable earlycon without command > line param") added EARLYCON_TABLE(). > > Commit 99492c39f39f ("earlycon: Fix __earlycon_table stride") referenced > commit 07fca0e57fca92 ("tracing: Properly align linker defined symbols") > and tried to fix EARLYCON_TABLE() using __aligned(32). > > However, the fix copied just works around compiler behavior. In fact, it > was subsequently re-implemented for tracing using a table of pointers in > commit 3d56e331b653 ("tracing: Replace syscall_meta_data struct array with > pointer array"), commit 654986462939 ("tracepoints: Fix section alignment > using pointer array") and commit e4a9ea5ee7c8 ("tracing: Replace > trace_event struct array with pointer array"). > > Let's do the same "array of pointers to structs" approach for > EARLYCON_TABLE. Please describe what the problem is instead of just what the fix is. Thanks. > Signed-off-by: Daniel Kurtz > --- > Changes since v1: > * Change __earlycon_table to an array of pointers. > > Note: I do not have a convenient system to test the of/fdt.c part of this > patch, so would apreciate help verifying it. Thanks! > > drivers/of/fdt.c | 7 +++++-- > drivers/tty/serial/earlycon.c | 6 ++++-- > include/asm-generic/vmlinux.lds.h | 2 +- > include/linux/serial_core.h | 21 ++++++++++++++------- > 4 files changed, 24 insertions(+), 12 deletions(-) > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > index 84aa9d676375..6da20b9688f7 100644 > --- a/drivers/of/fdt.c > +++ b/drivers/of/fdt.c > @@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void) > int offset; > const char *p, *q, *options = NULL; > int l; > - const struct earlycon_id *match; > + const struct earlycon_id **p_match; > const void *fdt = initial_boot_params; > > offset = fdt_path_offset(fdt, "/chosen"); > @@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void) > return 0; > } > > - for (match = __earlycon_table; match < __earlycon_table_end; match++) { > + for (p_match = __earlycon_table; p_match < __earlycon_table_end; > + p_match++) { > + const struct earlycon_id *match = *p_match; > + > if (!match->compatible[0]) > continue; > > diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c > index a24278380fec..22683393a0f2 100644 > --- a/drivers/tty/serial/earlycon.c > +++ b/drivers/tty/serial/earlycon.c > @@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match) > */ > int __init setup_earlycon(char *buf) > { > - const struct earlycon_id *match; > + const struct earlycon_id **p_match; > > if (!buf || !buf[0]) > return -EINVAL; > @@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf) > if (early_con.flags & CON_ENABLED) > return -EALREADY; > > - for (match = __earlycon_table; match < __earlycon_table_end; match++) { > + for (p_match = __earlycon_table; p_match < __earlycon_table_end; > + p_match++) { > + const struct earlycon_id *match = *p_match; > size_t len = strlen(match->name); > > if (strncmp(buf, match->name, len)) > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 1ab0e520d6fc..e17de55c2542 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -179,7 +179,7 @@ > #endif > > #ifdef CONFIG_SERIAL_EARLYCON > -#define EARLYCON_TABLE() STRUCT_ALIGN(); \ > +#define EARLYCON_TABLE() . = ALIGN(8); \ > VMLINUX_SYMBOL(__earlycon_table) = .; \ > KEEP(*(__earlycon_table)) \ > VMLINUX_SYMBOL(__earlycon_table_end) = .; > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h > index b32df49a3bd5..93b7add47087 100644 > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -351,10 +351,10 @@ struct earlycon_id { > char name[16]; > char compatible[128]; > int (*setup)(struct earlycon_device *, const char *options); > -} __aligned(32); > +}; > > -extern const struct earlycon_id __earlycon_table[]; > -extern const struct earlycon_id __earlycon_table_end[]; > +extern const struct earlycon_id *__earlycon_table[]; > +extern const struct earlycon_id *__earlycon_table_end[]; > > #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE) > #define EARLYCON_USED_OR_UNUSED __used > @@ -362,12 +362,19 @@ extern const struct earlycon_id __earlycon_table_end[]; > #define EARLYCON_USED_OR_UNUSED __maybe_unused > #endif > > -#define OF_EARLYCON_DECLARE(_name, compat, fn) \ > - static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \ > - EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \ > +#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \ > + static const struct earlycon_id unique_id \ > + EARLYCON_USED_OR_UNUSED __initdata \ > = { .name = __stringify(_name), \ > .compatible = compat, \ > - .setup = fn } > + .setup = fn }; \ > + static const struct earlycon_id EARLYCON_USED_OR_UNUSED \ > + __section(__earlycon_table) \ > + * const __PASTE(__p, unique_id) = &unique_id > + > +#define OF_EARLYCON_DECLARE(_name, compat, fn) \ > + _OF_EARLYCON_DECLARE(_name, compat, fn, \ > + __UNIQUE_ID(__earlycon_##_name)) > > #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn) > > -- ~Randy