Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3130463ybi; Thu, 18 Jul 2019 21:37:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOX9mya61YK6VG4qDf5h/KTbnoI7DrC3HXA2tmO+ivXhrZBElsX0XBevSOPgGB0sk1AmP4 X-Received: by 2002:a63:d002:: with SMTP id z2mr53125656pgf.364.1563511046843; Thu, 18 Jul 2019 21:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511046; cv=none; d=google.com; s=arc-20160816; b=ayR0M97SC6QPRLZ5xohH3ZNurI1YlW1mj0TeXFSAXmaX7OI/1phRDGzy5teMqz1E92 SkDhaJGfrDOuAgXZ1q1dKsT2BRL6ls4nCDtksooe2Zac1DxOoALUGG0zMc3FAYPUW1Pc lfPrsHBTzuUkOutWlqSa5ZYdaE/2HICuXRK0KZ+aKVGfunVkfPRpkOaNDqc2mwSQT8ZW re/bax8l+2K0nGU9dtqFaxWraNHnjPumbIBvCJs1Om2pfx7QrPpulC0uUXfbG30KYoqu 45Oa4CwT4EJlecw71V+lf4v1R0yULXhOQz0ygzNqUOqJXSABSpdUP39j0y3oy37pL3pv LocA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PcNAIC6uBktDtFt63oXa3BiwAcws1qgv6pNVhwax18E=; b=Qe1KSjf5q2TOeEXCL60x72Qq7QMUhTQyoywM9KtZoRLVOlZ4EmytOUx7Dozjo9x3Yu 1Nd/ai3IIGXvoFS7FitR0oBsBM1uKF9rwUSFxYILTCAU/b8XVuxuhZwU9URA7r8x0uWe tsNzjGf6Upk3bchSAD05qwjhgdQw8D8Kro6deCS9fu+4ylqmNIEcSbQVlt5CIo53QMSY k5Yc3TPtjHCvdOfAJwWuuY5pByGa4n4VFgfjQVeDTKi3R9neYC8UQQsfPpp26szzae+N Hq4g7Y7DiHnGp8ef8trEUYEsx++lobsN9cPrCEL572zwT7R+8bI6H+duBr+4jD1G2zey DfMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Btk434um; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si879524plr.260.2019.07.18.21.37.10; Thu, 18 Jul 2019 21:37:26 -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=@kernel.org header.s=default header.b=Btk434um; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729606AbfGSEBl (ORCPT + 99 others); Fri, 19 Jul 2019 00:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:33302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728707AbfGSEBd (ORCPT ); Fri, 19 Jul 2019 00:01:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 4E79B218A5; Fri, 19 Jul 2019 04:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508893; bh=5objRnYHCmulPFW07H0iD2s+QME+63EI23t7tqFFspE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Btk434umaW44ES/jNthjsdREPrpR86bQOCpxhYATE8qrqizfOmlBuabBnk+UoK0Ns FpRfWz1NL6Mb+hPrKK/cyJI4+QUPp8iHkMLfAVT/bmgR9Hhz6DLyOlZG9ySMQ01xUn BzQive5rNhXw7AVV8cNaV6D9zRco3UODihi5t2xs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masahiro Yamada , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.2 141/171] powerpc/boot: add {get, put}_unaligned_be32 to xz_config.h Date: Thu, 18 Jul 2019 23:56:12 -0400 Message-Id: <20190719035643.14300-141-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 9e005b761e7ad153dcf40a6cba1d681fe0830ac6 ] 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 Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190705100144.28785-1-yamada.masahiro@socionext.com Signed-off-by: Sasha Levin --- arch/powerpc/boot/xz_config.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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) -- 2.20.1