All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
To: ard.biesheuvel@linaro.org, mingo@kernel.org, kasong@redhat.com,
	hdegoede@redhat.com, matthewgarrett@google.com,
	linux-efi@vger.kernel.org
Subject: [PATCH 1/1] efi/libstub: Workaround for data abort on armv6z architecture
Date: Mon, 18 Nov 2019 19:42:52 +0200	[thread overview]
Message-ID: <20191118174252.26758-2-cristian.ciocaltea@gmail.com> (raw)
In-Reply-To: <20191118174252.26758-1-cristian.ciocaltea@gmail.com>

The armv6-eabihf toolchains generate some ldrd instructions
that trigger data abort on RaspberryPi Zero (ARM1176JZF-S CPU):

drivers/firmware/efi/libstub/efi-stub-helper.c:91
	*map->map_size =	*map->desc_size * 32;
    92c8:	e1c420d4 	ldrd	r2, [r4, #4]

This patch is a hack to instruct the compiler to avoid
using the problematic ldrd instructions.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
 drivers/firmware/efi/libstub/efi-stub-helper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 35dbc2791c97..8d7d27b8b9c2 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -86,9 +86,10 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
 	efi_status_t status;
 	unsigned long key;
 	u32 desc_version;
+	unsigned long hack;
 
 	*map->desc_size =	sizeof(*m);
-	*map->map_size =	*map->desc_size * 32;
+	*map->map_size =	sizeof(*m) * 32;
 	*map->buff_size =	*map->map_size;
 again:
 	status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
@@ -111,7 +112,9 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
 		 * exceed this headroom once we are ready to trigger
 		 * ExitBootServices()
 		 */
-		*map->map_size += *map->desc_size * EFI_MMAP_NR_SLACK_SLOTS;
+		hack = *map->desc_size * EFI_MMAP_NR_SLACK_SLOTS + 1;
+		*map->map_size += hack;
+		--(*map->map_size);
 		*map->buff_size = *map->map_size;
 		goto again;
 	}
-- 
2.17.1


  reply	other threads:[~2019-11-18 17:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18 17:42 [PATCH 0/1] Temporary fix for data abort on armv6z EFI boot Cristian Ciocaltea
2019-11-18 17:42 ` Cristian Ciocaltea [this message]
2019-11-18 18:02 ` Ard Biesheuvel
2019-11-19  1:52   ` Heinrich Schuchardt
2019-11-18 18:10 ` Mark Rutland
2019-11-18 18:15   ` Ard Biesheuvel
2019-11-18 18:51     ` Mark Rutland
2019-11-18 19:41       ` Ard Biesheuvel
2019-11-19  3:15         ` Heinrich Schuchardt
2019-11-19  7:27           ` Guillaume Gardet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191118174252.26758-2-cristian.ciocaltea@gmail.com \
    --to=cristian.ciocaltea@gmail.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=hdegoede@redhat.com \
    --cc=kasong@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=matthewgarrett@google.com \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.