Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 512C6C432C0 for ; Mon, 18 Nov 2019 17:42:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A3312192B for ; Mon, 18 Nov 2019 17:42:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gkLRXoXD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbfKRRm4 (ORCPT ); Mon, 18 Nov 2019 12:42:56 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55157 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbfKRRm4 (ORCPT ); Mon, 18 Nov 2019 12:42:56 -0500 Received: by mail-wm1-f65.google.com with SMTP id z26so167995wmi.4 for ; Mon, 18 Nov 2019 09:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Iu/BAUq4FXml3nbiF+fFEOptFj5ZHDj51Dcbb6JbVKA=; b=gkLRXoXDxXKOcdl7ohhuQQ7Si8V6aVPFPHA/t1Z9Igx0fxtJjfsOqPtwa3BxC+3egy YHmx6AKoXs+tUduIpamv7WBG1cHKUyjE2RvlzeJoZboueIMP4E6Pgv5LJ1wg3kRjtZzc pzu/+4Rfb9P143/VKMZvVzCMKPmLhGJgHxJGllHdc9r01ZDLtr1NTtjFchuCQA/pgs3R U7qRXrgxYuC+hiAsIjWmpPUo1sJFEo0rufCiDE6TasWB//A6fT5rTP6ZIXNVJoBA88RV qmaEKczChljZ6Cz1Nl2SSVA5mMZSzEAH9UP7f2sn7Jv1Od3ritiATWqmUA/e9q8YBLj1 sF3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=Iu/BAUq4FXml3nbiF+fFEOptFj5ZHDj51Dcbb6JbVKA=; b=nJRCDOBEtlr4U1qWVxcCUhLC3htGj/OTIpGtABq91fIB5uT9yZNvPpZGIgJGVYAp3O BIxgyPk5KWqRDVgpYq3Bk1NNJaC/5c98V5ed1uNzBR7s7E7IWbXsOHrH+u3UnQ2rwN5x IIdFZR5sP4OSY7Zk1Zi8uY+aBdmRxCd61CDIU8Bb/jJCbskeCOhkWnZPh2sDK97LdTEN tFXeXmnbygG6f+8bw/bMApTkYd4PhyBxoZo0gOw2m5f86v47BbnLG+OXJgKaNoe/Xxi8 wNP99Ve4jm0mfzbl785CMjWGpd42TX6SWArcPuKNFSMRh5n6NNNP/1eILqxllUCyC2VF k2Xw== X-Gm-Message-State: APjAAAXVOWru51dAEohyZUx4UZY0oDn3zZP+zSyECmUoyIWUBOicgUCP AZpjKTdckmZZG93X4g7+wD01YVa3nqE= X-Google-Smtp-Source: APXvYqwvlJevUrdXI2bEvCw9sJJHVLsV1G38ATVj78G+iYJ1s0ZvHWYphzeh4Az60TQ2+aSCBRPIgA== X-Received: by 2002:a05:600c:2253:: with SMTP id a19mr211029wmm.97.1574098974325; Mon, 18 Nov 2019 09:42:54 -0800 (PST) Received: from localhost.localdomain ([79.116.233.68]) by smtp.gmail.com with ESMTPSA id c10sm71198wml.37.2019.11.18.09.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 09:42:53 -0800 (PST) From: Cristian Ciocaltea To: ard.biesheuvel@linaro.org, mingo@kernel.org, kasong@redhat.com, hdegoede@redhat.com, matthewgarrett@google.com, linux-efi@vger.kernel.org Subject: [PATCH 0/1] Temporary fix for data abort on armv6z EFI boot Date: Mon, 18 Nov 2019 19:42:51 +0200 Message-Id: <20191118174252.26758-1-cristian.ciocaltea@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org I'm trying to boot the Linux kernel on RaspberryPi Zero via GRUB2, which in turn is executed by U-Boot as an UEFI binary. However, I'm facing data abort issues in efi_get_memory_map() that seem to be related to some ldrd instructions generated by the compiler. To simplify the investigation, I temporarily gave up on GRUB2 and started directly the Linux kernel via U-Boot bootefi command. The result is an immediate crash at PC 0x92c8: data abort pc : [<1c6b12c8>] lr : [<1c6b1558>] reloc pc : [] lr : [] sp : 1db43b30 ip : 00000000 fp : 1db43cc0 r10: 20494249 r9 : ffffffff r8 : 00000000 r7 : 1db43b3c r6 : 00000000 r5 : 1db43bfa r4 : 1db43bb0 r3 : 1db43b9c r2 : 00000028 r1 : 00000000 r0 : 1df4f828 Flags: nZCv IRQs off FIQs off Mode SVC_32 Code: e3a02028 e3a01000 e527100c e5832000 (e1c420d4) UEFI image [0x1c6a8000:0x1cb2ffff] pc=0x92c8 '/boot\zImage' Resetting CPU ... The related disassembled section shows the *ldrd* instruction in the context of the following statement: *map->map_size = *map->desc_size * 32; drivers/firmware/efi/libstub/efi-stub-helper.c:90 *map->desc_size = sizeof(*m); 92ac: e5913008 ldr r3, [r1, #8] drivers/firmware/efi/libstub/efi-stub-helper.c:84 { 92b0: e1a04001 mov r4, r1 drivers/firmware/efi/libstub/efi-stub-helper.c:85 efi_memory_desc_t *m = NULL; 92b4: e28d7018 add r7, sp, #24 linux/drivers/firmware/efi/libstub/efi-stub-helper.c:90 *map->desc_size = sizeof(*m); 92b8: e3a02028 mov r2, #40 ; 0x28 92c4: e5832000 str r2, [r3] linux/drivers/firmware/efi/libstub/efi-stub-helper.c:91 *map->map_size = *map->desc_size * 32; 92c8: e1c420d4 ldrd r2, [r4, #4] I changed the code to avoid the memory access and eventually get rid of the ldrd instruction: *map->map_size = sizeof(*m) * 32; A subsequent data abort was caused by a similar ldrd instruction generated in the context of the statement: *map->map_size += *map->desc_size * EFI_MMAP_NR_SLACK_SLOTS; The workaround to avoid the ldrd instruction was trickier in that case, as you may see in the patch, but eventually the kernel was able to boot successfully, with or without GRUB2 chain-loading. The system looks stable for the moment, but most probably there are many other similar statements which were not enabled for this particular use case and still have the potential to trigger data aborts. Unfortunately I'm not sure how to further investigate this issue and, therefore, I would kindly ask for some feedback or suggestions. Some additional notes: - Used GCC 7.3.0 and GCC 8.2.0 based armv6-eabihf toolchains: https://toolchains.bootlin.com/releases_armv6-eabihf.html - Kernel and root filesystem build process handled by buildroot - Tested with kernels: 4.2, 4.3, 4.4 -- 2.17.1