From a9dedea652b5198bebf99d646ffa6b698f1980e5 Mon Sep 17 00:00:00 2001 From: Marcus Shawcroft Date: Mon, 30 Mar 2015 18:06:22 -0700 Subject: [AArch64] Workaround for cortex-a53 erratum 843419 Some early revisions of the Cortex-A53 have an erratum (843419). The details of the erratum are quite complex and involve dynamic conditions. For the purposes of the workaround we have simplified the static conditions to an ADRP in the last two instructions of a 4KByte page, followed within four instructions by a load/store dependent on the ADRP. This patch adds support to conservatively scan for and workaround the erratum. There are two different workaround strategies used. The first is to rewrite ADRP instructions which form part of an erratum sequence with an ADR instruction. In situations where the ADR provides insufficient offset the dependent load or store instruction from the sequence is moved to a stub section and branches are inserted from the original sequence to the relocated instruction and back again. Stub section sizes are rounded up to a multiple of 4096 in order to ensure that the act of inserting work around stubs does not create more errata sequences. Workaround stubs are always inserted into the stub section associated with the input section containing the erratum sequence. This ensures that the fully relocated form of the veneered load store instruction is available at the point in time when the stub section is written. 2015-03-30 Tejas Belagod Marcus Shawcroft Jiong Wang * bfd-in.h (bfd_elf64_aarch64_set_options) (bfd_elf32_aarch64_set_options): Add parameter. * bfd-in2.h: Regenerated. * elfnn-aarch64.c (aarch64_erratum_843419_stub) (_bfd_aarch64_adrp_p, _bfd_aarch64_erratum_843419_sequence_p) (_bfd_aarch64_erratum_843419_stub_name) (_bfd_aarch64_erratum_843419_fixup) (_bfd_aarch64_erratum_843419_scan) (_bfd_aarch64_erratum_843419_branch_to_stub) (_bfd_aarch64_erratum_843419_p): Define. (enum elf_aarch64_stub_type): Define aarch64_stub_erratum_843419_veneer. (struct elf_aarch64_stub_hash_entry): Define adrp_offset. (struct elf_aarch64_link_hash_table): Define fix_erratum_843419 and fix_erratum_843419_adr. (stub_hash_newfunc): Initialize adrp_offset; (_bfd_aarch64_add_stub_entry_after): Define. (aarch64_map_one_stub, aarch64_build_one_stub) (aarch64_size_one_stub): Handle aarch64_stub_erratum_843419_veneer. (_bfd_aarch64_resize_stubs): Round stub section size. (elfNN_aarch64_size_stubs): Add scan for 843419. (bfd_elfNN_aarch64_set_options): Add parameter. Initialize fix_erratum_843419 and fix_erratum_843419_adr. (struct erratum_835769_branch_to_stub_data): Add info. (elfNN_aarch64_write_section): Initialise info. Handle 843419. (elfNN_aarch64_size_dynamic_sections): Handle 843419. * elfxx-aarch64.c (_bfd_aarch64_decode_adrp_imm) (_bfd_aarch64_sign_extend): Define. (reencode_adr_imm): Remove static. Rename to: (_bfd_aarch64_reencode_adr_imm): Define. (_bfd_aarch64_elf_put_addend): Call _bfd_aarch64_reencode_adr_imm. * elfxx-aarch64.h (AARCH64_ADR_OP, AARCH64_ADRP_OP) (AARCH64_ADRP_OP_MASK, _bfd_aarch64_sign_extend) (_bfd_aarch64_decode_adrp_imm, _bfd_aarch64_reencode_adr_imm): Define. ld/testsuite: 2015-03-24 Tejas Belagod * emultempl/aarch64elf.em (aarch64_elf_create_output_section_statements): Add parameter in bfd_elf${ELFSIZE}_aarch64_set_options call. (OPTION_FIX_ERRATUM_843419): Define. (PARSE_AND_LIST_LONGOPTS): Add fix-cortex-a53-843419. (PARSE_AND_LIST_ARGS_CASES): Add OPTION_FIX_ERRATUM_843419. Change-Id: I758b04c90d431f4e72a978871d5a66676c413d92 --- binutils-2.25/bfd/bfd-in.h | 4 +- binutils-2.25/bfd/bfd-in2.h | 4 +- binutils-2.25/bfd/elfnn-aarch64.c | 438 ++++++++++++++++++++- binutils-2.25/bfd/elfxx-aarch64.c | 29 +- binutils-2.25/bfd/elfxx-aarch64.h | 13 + binutils-2.25/ld/emultempl/aarch64elf.em | 11 +- .../ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 + .../ld/testsuite/ld-aarch64/erratum843419.d | 69 ++++ .../ld/testsuite/ld-aarch64/erratum843419.s | 84 ++++ 9 files changed, 639 insertions(+), 14 deletions(-) create mode 100644 binutils-2.25/ld/testsuite/ld-aarch64/erratum843419.d create mode 100644 binutils-2.25/ld/testsuite/ld-aarch64/erratum843419.s (limited to 'binutils-2.25') diff --git a/binutils-2.25/bfd/bfd-in.h b/binutils-2.25/bfd/bfd-in.h index 1f80a76b..1e6b2159 100644 --- a/binutils-2.25/bfd/bfd-in.h +++ b/binutils-2.25/bfd/bfd-in.h @@ -937,10 +937,10 @@ extern void bfd_elf32_aarch64_init_maps (bfd *); extern void bfd_elf64_aarch64_set_options - (bfd *, struct bfd_link_info *, int, int, int, int); + (bfd *, struct bfd_link_info *, int, int, int, int, int); extern void bfd_elf32_aarch64_set_options - (bfd *, struct bfd_link_info *, int, int, int, int); + (bfd *, struct bfd_link_info *, int, int, int, int, int); /* ELF AArch64 mapping symbol support. */ #define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0) diff --git a/binutils-2.25/bfd/bfd-in2.h b/binutils-2.25/bfd/bfd-in2.h index c7a2bb52..5f7879f4 100644 --- a/binutils-2.25/bfd/bfd-in2.h +++ b/binutils-2.25/bfd/bfd-in2.h @@ -944,10 +944,10 @@ extern void bfd_elf32_aarch64_init_maps (bfd *); extern void bfd_elf64_aarch64_set_options - (bfd *, struct bfd_link_info *, int, int, int, int); + (bfd *, struct bfd_link_info *, int, int, int, int, int); extern void bfd_elf32_aarch64_set_options - (bfd *, struct bfd_link_info *, int, int, int, int); + (bfd *, struct bfd_link_info *, int, int, int, int, int); /* ELF AArch64 mapping symbol support. */ #define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0) diff --git a/binutils-2.25/bfd/elfnn-aarch64.c b/binutils-2.25/bfd/elfnn-aarch64.c index 27601fcf..e6206c88 100644 --- a/binutils-2.25/bfd/elfnn-aarch64.c +++ b/binutils-2.25/bfd/elfnn-aarch64.c @@ -1617,6 +1617,12 @@ static const uint32_t aarch64_erratum_835769_stub[] = 0x14000000, /* b