Received: by 10.213.65.68 with SMTP id h4csp1363267imn; Wed, 14 Mar 2018 18:59:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELugrlVS+Vc/TEm6SAJlN/DJAq0FoGy8BVXv3S1/geQehpibAx3whkeeuXBLNl512NyeJ5AD X-Received: by 2002:a17:902:b683:: with SMTP id c3-v6mr6021077pls.154.1521079145023; Wed, 14 Mar 2018 18:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521079144; cv=none; d=google.com; s=arc-20160816; b=zSSmp9lTdf7OJrpwCt44YARWMLzjIL+65E0XTYoxJJzXJoOQz9b8+KraPWPC/6casK CF/D+W/nJZg3oJOVokYnQ75NkVqNDsWMZDsPJZQA6PPNxaTwha31cPqTfRX5sxv9Jg1Q KlTJuSmERGu24jR0Nv4qGrATZpR2sZh0GJ9TinCu3Y6MaeLoGBQTkh+D2wvEDJFhVL/k f99w0kffVc6FjqjnGSshRLwnbgKbDt0fesGgf3vZyGEfzaJl8rBxI3+YXI1Qmoqpm0Sw wlGkwrlZAn7tOlPIKXg2fL6GgX21SOz+HX6VlZp3z/e4sy2x6ZGx0aiO4NS+P+iThhN5 zNPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=FCI6fNWRe4PWwj2/qsrrBC6caEC3NyvDozXhxbf73SA=; b=axqD9KGPatRlreExcxuhMzpgBNzVczZ1tl+/4/8c9d/r6Cn3FQotOJYEjHTi/XDHGp zBV2V931Hq6yZg6QSOTIHyyko1KYHMxvFUt/NGQ8G3+EfoA2P3DDyYt9IMBrPMRGISVb ISa7qp8Hu3C0geCCdFK5/5JxvICIfThKh1Yup9QHLFluq1Ncmb7cjK/PyxLOnBjbHXyN LUhkE64ARZtEFHXeBndqo2B2QOg3Hw2bVmpTLZRgjapH1rJvwTqwIqYKopjxxAVg7Y0+ n61tSLpKU2+3pLzJjObLQo4/TGqVicZu0BsmlwjRe4D+AkEuHEBBnsrNZ4DuU77rDQmZ nZbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Eq4iqJJw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si2991297pfi.31.2018.03.14.18.58.50; Wed, 14 Mar 2018 18:59:04 -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=pass header.i=@chromium.org header.s=google header.b=Eq4iqJJw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751571AbeCOB54 (ORCPT + 99 others); Wed, 14 Mar 2018 21:57:56 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:46007 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390AbeCOB5y (ORCPT ); Wed, 14 Mar 2018 21:57:54 -0400 Received: by mail-ua0-f195.google.com with SMTP id n24so3376395ual.12 for ; Wed, 14 Mar 2018 18:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FCI6fNWRe4PWwj2/qsrrBC6caEC3NyvDozXhxbf73SA=; b=Eq4iqJJwjHnQezcVUA6t2FgHntim9L40xKhQdH89N40Q0yfk5RHmnq3KngK3PIB8hE HQ6Hjqns07c4MWOpMnkL/t34PGt7cxq5x0dOnICVLcMsW9hISUm4DKC1HukD72Izx10u s+6dM1IoXxWv7saEaCyf26VCfLLivb+GyT91U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FCI6fNWRe4PWwj2/qsrrBC6caEC3NyvDozXhxbf73SA=; b=dcswL7Sn0dgC1T/1RgmPWwHn/Oy2sJ7c4UjqZA16LS2HDeCTRVcAY5MwHdVkEQHLcM Ddm47zLTDpq2+Lnb3h8hvkUPqdTZWMkxcNRp3WuQZ2yGNP4GH14hXFAtz9hwQgFmmiAu vs9dP+pyYjIv9bNuA3NyaaiGC/ijzypWqyXY5FJT8vjb3TY6kw3QAygpe4z163lprAkR xywZngPF6l0Qgbm5R7AS10H4dRvPW8jKl0kh7+oVLHZbVce+GkqHoiepwu0A7/Bc5eOa A21dL31lDVOE+9tOREjsY1AKFxj6/re3ReN1SHn29ZIys1SFiIpYLAOgHNi8RMzA+3pB HG/w== X-Gm-Message-State: AElRT7Eby7smPVl6+6FYHsMU6zS7iFCvCzTewBLqWylXJTsVh1VNolqt 7RJN7USTcqA5uIiwha5p6jHBjKe+LozWLbZThYHuz7QbNNZrOqm/CM7Zd6cqDZ80jdfclo+USx6 ZHRlKgFcnobsen7ADjzsiw5sZn9b/UgU= X-Received: by 10.176.81.212 with SMTP id h20mr3003733uaa.67.1521079073383; Wed, 14 Mar 2018 18:57:53 -0700 (PDT) MIME-Version: 1.0 References: <20180315014817.142930-1-djkurtz@chromium.org> In-Reply-To: <20180315014817.142930-1-djkurtz@chromium.org> From: Daniel Kurtz Date: Thu, 15 Mar 2018 01:57:41 +0000 Message-ID: Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again To: peter@hurleysoftware.com, Rob Herring Cc: adurbin@chromium.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Grant Likely , Rob Herring , frowand.list@gmail.com, jslaby@suse.com, Arnd Bergmann , "open list:OPEN FIRMWARE AND..." , linux-serial@vger.kernel.org, linux-arch@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-ccpol: medium Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 14, 2018 at 7: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. > Signed-off-by: Daniel Kurtz Oops, I forgot to add: Suggested-by: Aaron Durbin > --- > 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) > -- > 2.16.2.804.g6dcf76e118-goog