From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x236.google.com (mail-it0-x236.google.com [IPv6:2607:f8b0:4001:c0b::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E5AF71A1E10 for ; Tue, 2 Aug 2016 02:03:46 -0700 (PDT) Received: by mail-it0-x236.google.com with SMTP id f6so194819051ith.0 for ; Tue, 02 Aug 2016 02:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nByPqgA7QwILRjUzXk2haymgOCwzSgWb8HBIC99TgCw=; b=TtkcmTWSNhIvcI7cbvBtNQ81n4qg14lRFp5oGqdG6QS3ulSNwp9lkbPkdMg7kDzbgC uSjeskTBU56u7Qk/qLfEWlx0vHE+r7eEOV024PVNyYF+zY6AZtrDXAAmdvEEyX0sVlYl TcS0ZRPML+QT0u5pgZHoy4WCdK3QT9NLjeKrg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nByPqgA7QwILRjUzXk2haymgOCwzSgWb8HBIC99TgCw=; b=fUQMHoWEvsPJy/1qWOUMIyiqoEo899u6rLLSlhopueenOUYiMAbKf2D0g+RDeKz0Yz XIgpnTTPq4adWCqbO8qlYinkcFBPXbeb6WhiIhF2TUjJrAKRNGz+xsDACH0gfBW/9Ut2 +J0fgOhSp3AiaqS+eqWSb+PaHy1WiUv3hBW04RSa5QZ6cWPiWteNHv/3+nlQ9uDPq/CJ K/pIjJ39ZWZlSPKtRWOmPgX95rJK3rp1fpop5utUN3fQFxEe+ZTPD+NmZ3hpdGl4z79f 2/ZOWo3Ez19kMLxrfXZ9sd1qwnyDa1FRcGo1r7sfDMt407OmeQhhGYNd5K8HD+qQOVHE Xxeg== X-Gm-Message-State: AEkoousOlsPF0oCRJ2Hv3YvkFf0m07OtOrt5AGs/4OdslSsZv00WtOswZ8S1uhueV2gXZiB8L9RgDXBvhCQUt77F X-Received: by 10.36.39.77 with SMTP id g74mr17264785ita.51.1470128626244; Tue, 02 Aug 2016 02:03:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.204.195 with HTTP; Tue, 2 Aug 2016 02:03:45 -0700 (PDT) In-Reply-To: <20160801141907.GT31760@bivouac.eciton.net> References: <1469618762-7648-1-git-send-email-ard.biesheuvel@linaro.org> <20160801141907.GT31760@bivouac.eciton.net> From: Ard Biesheuvel Date: Tue, 2 Aug 2016 11:03:45 +0200 Message-ID: To: Leif Lindholm Cc: edk2-devel-01 , "Gao, Liming" , "Zhu, Yonghong" , "Cohen, Eugene" Subject: Re: [PATCH 1/2] BaseTools/GenFw AARCH64: convert ADRP to ADR if binary size allows it X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 09:03:47 -0000 Content-Type: text/plain; charset=UTF-8 On 1 August 2016 at 16:19, Leif Lindholm wrote: > Apologies, lost track of this one. > > On Mon, Aug 01, 2016 at 01:53:09PM +0200, Ard Biesheuvel wrote: >> On 27 July 2016 at 13:26, Ard Biesheuvel wrote: >> > The ADRP instruction in the AArch64 ISA requires the link time and load >> > time offsets of a binary to be equal modulo 4 KB. The reason is that this >> > instruction always produces a multiple of 4 KB, and relies on a subsequent >> > ADD or LDR instruction to set the offset into the page. The resulting >> > symbol reference only produces the correct value if the symbol in question >> > resides at that exact offset into the page, and so loading the binary at >> > arbitrary offsets is not possible. >> > >> > Due to the various levels of padding when packing FVs into FVs into FDs, >> > this alignment is very costly for XIP code, and so we would like to relax >> > this alignment requirement if possible. >> > >> > Given that symbols that are sufficiently close (within 1 MB) of the >> > reference can also be reached using an ADR instruction which does not >> > suffer from this alignment issue, let's replace ADRP instructions with ADR >> > after linking if the offset can be encoded in this instruction's immediate >> > field. Note that this only makes sense if the section alignment is < 4 KB. >> > Otherwise, replacing the ADRP has no benefit, considering that the >> > subsequent ADD or LDR instruction is retained, and that micro-architectures >> > are more likely to be optimized for ADRP/ADD pairs (i.e., via micro op >> > fusing) than for ADR/ADD pairs, which are non-typical. >> > >> > Contributed-under: TianoCore Contribution Agreement 1.0 >> > Signed-off-by: Ard Biesheuvel >> >> @Liming, @Leif: >> >> are there any objections to these patches? I know it is unfortunate >> that we need to modify instructions as part of the ELF to PE/COFF >> conversion, but it is very effective > > It's absolutely horrid, but extremely useful. > For the series: > Reviewed-by: Leif Lindholm > Thanks Committed as 026a82abf0bd BaseTools/GenFw AARCH64: convert ADRP to ADR instructions if binary size allows it b89919ee8f8c BaseTools AARCH64: override XIP module linker alignment to 32 bytes