From mboxrd@z Thu Jan 1 00:00:00 1970 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 5F2C7C433F5 for ; Thu, 3 Feb 2022 18:50:01 +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:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aKxxLpGb40T3r0s6RWKIJNTghkrNSekkt9277H5yq3g=; b=4oc379ntqX/tzS CTDQwXAWyZ/ZmfxDlMYtD86uONDyd9kp0UTRiVlBP2twGUGq+6beMgIu71CBmemJWk0G4tl/OrwIW eDbwaabOnQEW7GuNXtcCboTMveIn2FhGlvV6L90S6AsPQTCTetUWogWQshdQBXn7RJyu2rD/0Vc1j Ae+7/uCmGKDd7RE91fCrKC017Z1iqnV/IZ0DdpU4tV+5U0lKmzilER8vgptMqS/hZXKhlggae5KBz /Utp321N+KaeE4G12SRMVmjOj1+UFHj8EmgAFQdhF1l8GxDGV9QMY+qDgvgDJ499eXMA2O2IxHqBv IOz+l9irZ3Z/nh2l3Hmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFhA4-002XEJ-Nn; Thu, 03 Feb 2022 18:48:52 +0000 Received: from usmailhost21.kioxia.com ([12.0.68.226] helo=SJSMAIL01.us.kioxia.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFhA0-002XDm-Kx for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 18:48:50 +0000 Received: from SJSMAIL01.us.kioxia.com (10.90.133.90) by SJSMAIL01.us.kioxia.com (10.90.133.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Thu, 3 Feb 2022 10:48:43 -0800 Received: from SJSMAIL01.us.kioxia.com ([fe80::115a:2c13:209c:d3d8]) by SJSMAIL01.us.kioxia.com ([fe80::115a:2c13:209c:d3d8%3]) with mapi id 15.01.2176.014; Thu, 3 Feb 2022 10:48:43 -0800 From: Rory Bolt To: "linux-arm-kernel@lists.infradead.org" Subject: Big endian modifications Thread-Topic: Big endian modifications Thread-Index: AdgZLLI0pSrc17e5TZWCqUNSP1GMNg== Date: Thu, 3 Feb 2022 18:48:43 +0000 Message-ID: <358bd5598bdb4343a43309c081efa06e@kioxia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.90.53.172] MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_104848_706314_7D71F5A2 X-CRM114-Status: GOOD ( 10.48 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, I have been modifying GRUB on Das U-boot to allow it to boot aarch64_be big endian kernels on the RockPro64 board. Since the RockPro64 has a PCIe (albeit 2.0) slot, it provides a low cost/reasonable performance (vs QEMU) system to test our devices, drivers and software stack on a big endian system. I am in the process of publishing the required changes to GRUB, however there are two minor changes made to the kernel itself. Arguably the modification to head.S could be moved to grub itself, however it is in the defensive spirit of not assuming the boot loader has set up everything correctly and is very similar to the startup of NetBSD which contains similar code in its startup. The second change to Kconfig allows a EFI/PE/COFF header to be added to a big endian kernel (although unfortunately it also adds a useless big endian efistub to the kernel too). With the following two changes the modified GRUB can boot either big endian or little endian Arm64 images. Please consider the following two modifications for inclusion: diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 6a98f1a38c29..40a18d767d15 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -89,6 +89,24 @@ * x24 __primary_switch() .. relocate_kernel() current RELR displacement */ SYM_CODE_START(primary_entry) +#ifdef CONFIG_CPU_BIG_ENDIAN + mrs x21, CurrentEL + lsr x21, x21, #2 + cmp x21, #0x2 + b.lo 1f + + mrs x21, sctlr_el2 + orr x21, x21, #SCTLR_ELx_EE /* set: Big Endian */ + msr sctlr_el2, x21 + isb + +1: + mrs x21, sctlr_el1 + orr x21, x21, #(SCTLR_ELx_EE | SCTLR_EL1_E0E) /* set: Big Endian */ + msr sctlr_el1, x21 + isb + +#endif bl preserve_boot_args bl init_kernel_el // w0=cpu_boot_mode adrp x23, __PHYS_OFFSET diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c4207cf9bb17..a9ccbeb75ea7 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1997,7 +1997,7 @@ config EFI_STUB config EFI bool "UEFI runtime support" - depends on OF && !CPU_BIG_ENDIAN + depends on OF depends on KERNEL_MODE_NEON select ARCH_SUPPORTS_ACPI select LIBFDT Rory Bolt KIOXIA America, Inc. | formerly Toshiba Memory America, Inc. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel