From patchwork Fri Jan 7 19:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 12707009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00A75C433F5 for ; Fri, 7 Jan 2022 19:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KwPQXMhZNjNxApLESawQSpSb1G9YBMH+enliOW1jpso=; b=BAidrCgkEAFxb8 jqXpCB1HeOEy+p/59szAQ3y3y63gzd6SC96y4ktJ6Z1x/t0juOzBgHf+5rAmZXheZYECJM/YoXvBW LTZ97KUmjAQ2HbfXgdvChC83ZKDMs+/nq2efEnIGcxUUqpWcCLfS/L+yBjYX7Jb4tLXqeWk9y0oSe o535/c2vBIrNcqjOk1a/GCrLPCJkU7XXKTyeGpnNHGPMjYSpwwQ1YC+NSLDYH9BQ9Gayhs2sljbjj e4vwtFc8bcFA9OyHzGxcB5xUWyGSMvmhuy793B0tPun8oJm378laXUOhdedQCueJV+sBCbL6nJChO LCjRHZ6WieUD74IpcMOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5v9b-0056JN-Uh; Fri, 07 Jan 2022 19:44:00 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5v9X-0056Io-TL for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 19:43:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA79A60AC1; Fri, 7 Jan 2022 19:43:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D3DDC36AE9; Fri, 7 Jan 2022 19:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641584634; bh=3ReycX2PmwqL8N5r5obhn2BQBzx0StuQjWOgoCkzjTg=; h=From:To:Cc:Subject:Date:From; b=g2keSuf4cMWXwPuCTD0CXq/i07A34+fzYW+SiqaBpryXa3ZouwEi5Ger2a26eSQAa sYyGQdtYiFYYmnEAGSU/bcbXr85Zj6nIOaqP4Z7xQr+nAqy+phyBrMoi6LLBFg2v68 llt3q9hjNxxNrbwf/xb8+fDAvDmAh1/PB1WLeOM0LdkAWZqMGrP5S3Sf8LCDF2k57r KlPlNW5H4Yc8a2nncHxLJXBK1lVT/lbs8YAPsg9Rgw13HHiJzJn1swbJ4lP7LLDgpv 01GzVx+zjOpncwEZtfXXR50nBsPzbqHGgtVQS9m6kE91nObUGKYSpVA+DGHq5RhW82 QaEH7LxIGASSw== From: Nathan Chancellor To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH RFC 4.9 0/5] Fix booting arm64 big endian with QEMU 5.0.0+ Date: Fri, 7 Jan 2022 12:43:30 -0700 Message-Id: <20220107194335.3090066-1-nathan@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220107_114356_054522_A3014F16 X-CRM114-Status: GOOD ( 16.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello everyone, After upgrading the version of QEMU used in our CI from 4.2.0 to 6.2.0, I noticed that our 4.9 arm64 big endian builds stopped booting properly. This is not something that is clang specific, I could reproduce it with GCC 8.3.0 (the rootfs is at [1]). $ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- distclean defconfig $ scripts/config -e CPU_BIG_ENDIAN $ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig Image.gz $ qemu-system-aarch64 \ -initrd rootfs.cpio \ -append 'console=ttyAMA0 earlycon' \ -cpu max \ -machine virt,gic-version=max \ -machine virtualization=true \ -display none \ -kernel arch/arm64/boot/Image.gz \ -m 512m \ -nodefaults \ -serial mon:stdio [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.9.296 (nathan@archlinux-ax161) (gcc version 8.3.0 (Debian 8.3.0-2) ) #1 SMP PREEMPT Fri Jan 7 19:10:49 UTC 2022 ... [ 0.773924] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 0.773924] [ 0.776016] CPU: 0 PID: 1 Comm: init Not tainted 4.9.296 #1 [ 0.776149] Hardware name: linux,dummy-virt (DT) [ 0.776375] Call trace: [ 0.777063] [] dump_backtrace+0x0/0x1b0 [ 0.777293] [] show_stack+0x14/0x20 [ 0.777420] [] dump_stack+0x98/0xb8 [ 0.777555] [] panic+0x11c/0x278 [ 0.777684] [] do_exit+0x940/0x970 [ 0.777816] [] do_group_exit+0x38/0xa0 [ 0.777974] [] get_signal+0xb8/0x678 [ 0.778111] [] do_signal+0xd8/0x9b0 [ 0.778248] [] do_notify_resume+0x8c/0xa8 [ 0.778392] [] work_pending+0x8/0x10 [ 0.778790] Kernel Offset: disabled [ 0.778891] Memory Limit: none [ 0.779241] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b I ended up bisecting QEMU down to cd3f80aba0 ("target/arm: Enable ARMv8.1-VHE in -cpu max") [2], which did not seem obviously broken. I noticed that our 4.14 builds were fine so I ended up doing a reverse bisect down to commit ec347012bbec ("arm64: sysreg: Move to use definitions for all the SCTLR bits"). Getting that change to apply cleanly involved applying the three other arm64 patches in this series and making it build properly required the BUILD_BUG_ON header split (including bug.h might have been sufficient but I did not want to risk any further breakage). I searched through mainline to see if there were any fixes commits that I missed and I did not find any. I am not sure if this series would be acceptable in 4.9, hence the RFC tag. If not, I am happy to just spin down our boot tests of arm64 big endian on 4.9, which is not a super valuable target, but I figured I would send the series and let others decide! [1]: https://github.com/ClangBuiltLinux/boot-utils/tree/6cfa15992d375dfb874ca0677abdaebfba4f74e6/images/arm64be [2]: https://gitlab.com/qemu-project/qemu/-/commit/cd3f80aba0c559a6291f7c3e686422b15381f6b7 Cheers, Nathan Ian Abbott (1): bug: split BUILD_BUG stuff out into James Morse (1): arm64: sysreg: Move to use definitions for all the SCTLR bits Mark Rutland (2): arm64: reduce el2_setup branching arm64: move !VHE work to end of el2_setup Stefan Traby (1): arm64: Remove a redundancy in sysreg.h arch/arm64/include/asm/sysreg.h | 69 +++++++++++++++++++++++++-- arch/arm64/kernel/head.S | 49 ++++++++----------- arch/arm64/mm/proc.S | 24 +--------- include/linux/bug.h | 72 +--------------------------- include/linux/build_bug.h | 84 +++++++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+), 128 deletions(-) create mode 100644 include/linux/build_bug.h base-commit: 710bf39c7aec32641ea63f6593db1df8c3e4a4d7