From patchwork Fri Jul 5 10:01:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168532 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3361132ilk; Fri, 5 Jul 2019 03:03:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUE4LhvhTb2tMsWH0RSzGnL1dzadi5vLBQYYvihPDVNUz+L9U1ww/a9V7M0NV4GhJ2s6ov X-Received: by 2002:a63:494d:: with SMTP id y13mr4499957pgk.109.1562320981113; Fri, 05 Jul 2019 03:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562320981; cv=none; d=google.com; s=arc-20160816; b=h53LWVVcW6W9rQnLIohF+psXVwc8JfYu9X4DG7NumS7JAOa7T4iri/TxNg032r1RLx ERfKcCxJ09j3PfMwZLQQ1nOQJKgJMoSuqsMARy8LBfDbBCQDEz3pFzg9kqaTRYw+4K64 wIOykxPJ5Nc7TDZd5AXWwuyG6TE/id7+5vpjXX4IN2oVIFJPLVc4/U1hkWrbn+FxHh9B ZHmYksNVEksC7ctBMkNFhzsHc26hxT0bvT5PJIMS8Obsnb6K/IfSOoJKzUkvX3oGKWIF h2wvGmRMWDbBr6DrENQMYYMGhuqc7y7QeCBOOyiUnzK8CsTL6hf4/etiLo4l+WWFah0m +UPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=Xti9N2uoikpsP8LMl2xLbOM7UsUpmVEcrDR7xeNals8=; b=ZgxdQQqsG5ksFeLCvi5Z8kGKdFDSbKPdeM14pXzKYdrrVtX02n30mCyJE+edLIEHbW 0EzG0POj/i6OJ/B/HOQF7L6U4hrKtVO8sLTgOq3+3gwRLw+foB32ARaS+FsLjP36/IOo E2YzFBPDjzcl2eDI8je7xzeBcPGQqzkOOAjRaTZ6dQvU1+6efpd+h1TQRyXEsEKnp3Ij Cazga8W35kyspZEWm9+eVAYe1Tzh7oOHJeV7B9tAodAIt8BEzeNiu2rR/U8ToqtrXtmy VVUXY8N+/No2wg5NtK66rqGQ8vlUloIQPEaoLTH9H9jk2f/XPC9wuvewmG6lNbOzlfvZ T6oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DAJtJ4z1; 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 32si8302179plb.86.2019.07.05.03.03.00; Fri, 05 Jul 2019 03:03:01 -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=@nifty.com header.s=dec2015msa header.b=DAJtJ4z1; 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 S1727352AbfGEKC7 (ORCPT + 30 others); Fri, 5 Jul 2019 06:02:59 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:38520 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfGEKC7 (ORCPT ); Fri, 5 Jul 2019 06:02:59 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id x65A1j3L018855; Fri, 5 Jul 2019 19:01:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com x65A1j3L018855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1562320906; bh=Xti9N2uoikpsP8LMl2xLbOM7UsUpmVEcrDR7xeNals8=; h=From:To:Cc:Subject:Date:From; b=DAJtJ4z1GTHt6BCACcdqmOamV5V5SCo5vNWy4ncAZHidFuIEhuzka6OGUSkwOu1Rn 8Ib1TzBZB6lXOpxml2+M4wZIQlfzrwXKvJDM/KITBGora5Z8FvtYKo4567a3bD62Ap O9rniDQ0MA+5JMQvwvSKf9bECEs0+qogaJF8waoB6DnKdKj0UkGms4NW+7+2EyUDTW TJv77oI63cvToCdMr9UtjF3yh/DIzWVwmzNheqcCEFPACM5XGYGfioGGp3ajqNe2K8 Q0Skp4Gv8ES120HlXJtLG5hvo9PZ7GjF6dUXxL8yPAo7soUaef8+MVcWZxs0w61oBc qqLQfO8q5oXQQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linuxppc-dev@lists.ozlabs.org, Michael Ellerman Cc: Masahiro Yamada , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Paul Mackerras Subject: [PATCH v3 1/2] powerpc/boot: add {get, put}_unaligned_be32 to xz_config.h Date: Fri, 5 Jul 2019 19:01:43 +0900 Message-Id: <20190705100144.28785-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The next commit will make the way of passing CONFIG options more robust. Unfortunately, it would uncover another hidden issue; without this commit, skiroot_defconfig would be broken like this: | WRAP arch/powerpc/boot/zImage.pseries | arch/powerpc/boot/wrapper.a(decompress.o): In function `bcj_powerpc.isra.10': | decompress.c:(.text+0x720): undefined reference to `get_unaligned_be32' | decompress.c:(.text+0x7a8): undefined reference to `put_unaligned_be32' | make[1]: *** [arch/powerpc/boot/Makefile;383: arch/powerpc/boot/zImage.pseries] Error 1 | make: *** [arch/powerpc/Makefile;295: zImage] Error 2 skiroot_defconfig is the only defconfig that enables CONFIG_KERNEL_XZ for ppc, which has never been correctly built before. I figured out the root cause in lib/decompress_unxz.c: | #ifdef CONFIG_PPC | # define XZ_DEC_POWERPC | #endif CONFIG_PPC is undefined here in the ppc bootwrapper because autoconf.h is not included except by arch/powerpc/boot/serial.c XZ_DEC_POWERPC is not defined, therefore, bcj_powerpc() is not compiled for the bootwrapper. With the next commit passing CONFIG_PPC correctly, we would realize that {get,put}_unaligned_be32 was missing. Unlike the other decompressors, the ppc bootwrapper duplicates all the necessary helpers in arch/powerpc/boot/. The other architectures define __KERNEL__ and pull in helpers for building the decompressors. If ppc bootwrapper had defined __KERNEL__, lib/xz/xz_private.h would have included : | #ifdef __KERNEL__ | # include | # include | # include However, doing so would cause tons of definition conflicts since the bootwrapper has duplicated everything. I just added copies of {get,put}_unaligned_be32, following the bootwrapper coding convention. Signed-off-by: Masahiro Yamada --- Changes in v3: - New patch to fix the potential issue of skiroot_defconfig Changes in v2: None arch/powerpc/boot/xz_config.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.17.1 diff --git a/arch/powerpc/boot/xz_config.h b/arch/powerpc/boot/xz_config.h index e22e5b3770dd..ebfadd39e192 100644 --- a/arch/powerpc/boot/xz_config.h +++ b/arch/powerpc/boot/xz_config.h @@ -20,10 +20,30 @@ static inline uint32_t swab32p(void *p) #ifdef __LITTLE_ENDIAN__ #define get_le32(p) (*((uint32_t *) (p))) +#define cpu_to_be32(x) swab32(x) +static inline u32 be32_to_cpup(const u32 *p) +{ + return swab32p((u32 *)p); +} #else #define get_le32(p) swab32p(p) +#define cpu_to_be32(x) (x) +static inline u32 be32_to_cpup(const u32 *p) +{ + return *p; +} #endif +static inline uint32_t get_unaligned_be32(const void *p) +{ + return be32_to_cpup(p); +} + +static inline void put_unaligned_be32(u32 val, void *p) +{ + *((u32 *)p) = cpu_to_be32(val); +} + #define memeq(a, b, size) (memcmp(a, b, size) == 0) #define memzero(buf, size) memset(buf, 0, size) From patchwork Fri Jul 5 10:01:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 168533 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3361539ilk; Fri, 5 Jul 2019 03:03:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmnyS7P2d133kzwQlJ+eUjBpgc6zDtH/0n2tOjDc/AFBKHotH4GHyrS9lfE/Dm9mVy4MQo X-Received: by 2002:a63:6981:: with SMTP id e123mr4399421pgc.136.1562320997840; Fri, 05 Jul 2019 03:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562320997; cv=none; d=google.com; s=arc-20160816; b=YO/6sfEY8CSJeYI7OZv8Oi7Z21rTgwmAxDKgxfw4YmwqDnWjhW06t78fDQN0bcNKwt wjG53uGk4LCAP1HgxJjgJnmo4eQ0h4vIjABswZhrnwFSUth9CYzDRGMfDDmGEOILAzwG sf+a77WRQWC6Jv0ulT4RMm4omid4nXtiiGm10NCmkDdPYptLniTfqxviUGSYjeOEwTyG BSqjMFgu6Nv7JsKcIqGr1QslxvEXKzBEFKQ28NDLnUIODMqh148kwKzMsxm718JAowsY gCNOZjm7YUy7zNnEvLkv+BjmUgJ15QgMBBa4+kGKMlg+N9WFIX30zb1QqmFq+HNEkMRd eXsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=c40ebdQGyZ/hZreWO45KBSfAn6dKspavgReY8ujfFGE=; b=q7jhkywG9aydMIK61HrPgmXA1A5QKPCMre8FvhWndYmb3Nnqs8FFwihQOCUpwGM36A 2LqyAE2L8R+wyFci4+S7EKFUIlRwbbWdL5KACrigs9dMGU1xuIp8ysj55iNkBHhytclU Y21wAoaQ0qvFIr6noKZTzo2kuD8mPTFH0C3uFHvYJHpMz/qbtwXa1pnny9DVrFB/anQI qdZ1J+Vg2hi61XM9c5DwBaRk+SHxNIsIsv+1zQJOslby7WPiGQ3H4qS8vBfnQ4YRLEmM OG+lyCjHtzN97weCEpTQN7qQpaeW1FK7nMNKSS+4Woz5+UWjSoIx6WfzXLcYVw8tAyWS ypSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nifty.com header.s=dec2015msa header.b=G5mHWkqQ; 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 32si8302179plb.86.2019.07.05.03.03.17; Fri, 05 Jul 2019 03:03:17 -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=@nifty.com header.s=dec2015msa header.b=G5mHWkqQ; 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 S1727595AbfGEKDQ (ORCPT + 30 others); Fri, 5 Jul 2019 06:03:16 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:38967 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfGEKDQ (ORCPT ); Fri, 5 Jul 2019 06:03:16 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id x65A1j3M018855; Fri, 5 Jul 2019 19:01:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com x65A1j3M018855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1562320908; bh=c40ebdQGyZ/hZreWO45KBSfAn6dKspavgReY8ujfFGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G5mHWkqQk66xKntbKGNRpKasDoMOcuLlCrRWOrvZ3NQXVq6RXSHit8Mv0fYBgh6Ot kuUGKXiXI7LRGxqjwyqAEGDmfpldBTPjdwhBLW5Wo0stUrrWdJTmH++IhfNRZpk0Dy PH/GaQveKnPu0xaZnsgD5FWvhhQ1IdLPv0cNVZZyG2yYx9Fj0X1n7z9RG5laoknOH8 i+gkq9kdv5OAL2nHWLd+mapqIa4TQK6S9GOHPLjeSts+o9KbSU+8stJzMiJnUAxEQh cdHvgU6dvlaVFHrtqnsgREfe337E+aE2ZkpuXYsDuiVBc0b6SmJQi6qyyyybknAGv7 DZnUK0j2cXY6g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linuxppc-dev@lists.ozlabs.org, Michael Ellerman Cc: Masahiro Yamada , Rob Herring , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, "Rodrigo R. Galvao" , "Oliver O'Halloran" , Paul Mackerras , Joel Stanley Subject: [PATCH v3 2/2] powerpc/boot: pass CONFIG options in a simpler and more robust way Date: Fri, 5 Jul 2019 19:01:44 +0900 Message-Id: <20190705100144.28785-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190705100144.28785-1-yamada.masahiro@socionext.com> References: <20190705100144.28785-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 5e9dcb6188a4 ("powerpc/boot: Expose Kconfig symbols to wrapper") was wrong, but commit e41b93a6be57 ("powerpc/boot: Fix build failures with -j 1") was also wrong. The correct dependency is: $(obj)/serial.o: $(obj)/autoconf.h However, I do not see the reason why we need to copy autoconf.h to arch/power/boot/. Nor do I see consistency in the way of passing CONFIG options. decompress.c references CONFIG_KERNEL_GZIP and CONFIG_KERNEL_XZ, which are passed via the command line. serial.c includes autoconf.h to reference a couple of CONFIG options, but this is fragile because we often forget to include "autoconf.h" from source files. In fact, it is already broken. ppc_asm.h references CONFIG_PPC_8xx, but utils.S is not given any way to access CONFIG options. So, CONFIG_PPC_8xx is never defined here. Pass $(LINUXINCLUDE) to make sure CONFIG options are accessible from all .c and .S files in arch/powerpc/boot/. I also removed the -traditional flag to make include/linux/kconfig.h work. This flag makes the preprocessor imitate the behavior of the pre-standard C compiler, but I do not understand why it is necessary. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: - reword commit log arch/powerpc/boot/.gitignore | 2 -- arch/powerpc/boot/Makefile | 14 +++----------- arch/powerpc/boot/serial.c | 1 - 3 files changed, 3 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore index 32034a0cc554..6610665fcf5e 100644 --- a/arch/powerpc/boot/.gitignore +++ b/arch/powerpc/boot/.gitignore @@ -44,5 +44,3 @@ fdt_sw.c fdt_wip.c libfdt.h libfdt_internal.h -autoconf.h - diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 73d1f3562978..b8a82be2af2a 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -20,9 +20,6 @@ all: $(obj)/zImage -compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP -compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ - ifdef CROSS32_COMPILE BOOTCC := $(CROSS32_COMPILE)gcc BOOTAR := $(CROSS32_COMPILE)ar @@ -34,7 +31,7 @@ endif BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \ -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ - -D$(compress-y) + $(LINUXINCLUDE) ifdef CONFIG_PPC64_BOOT_WRAPPER BOOTCFLAGS += -m64 @@ -51,7 +48,7 @@ BOOTCFLAGS += -mlittle-endian BOOTCFLAGS += $(call cc-option,-mabi=elfv2) endif -BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc +BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) @@ -202,14 +199,9 @@ $(obj)/empty.c: $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S $(Q)cp $< $@ -$(srctree)/$(src)/serial.c: $(obj)/autoconf.h - -$(obj)/autoconf.h: $(obj)/%: $(objtree)/include/generated/% - $(Q)cp $< $@ - clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \ $(zlib-decomp-) $(libfdt) $(libfdtheader) \ - autoconf.h empty.c zImage.coff.lds zImage.ps3.lds zImage.lds + empty.c zImage.coff.lds zImage.ps3.lds zImage.lds quiet_cmd_bootcc = BOOTCC $@ cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c index b0491b8c0199..9457863147f9 100644 --- a/arch/powerpc/boot/serial.c +++ b/arch/powerpc/boot/serial.c @@ -18,7 +18,6 @@ #include "stdio.h" #include "io.h" #include "ops.h" -#include "autoconf.h" static int serial_open(void) {