public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <quic_llindhol@quicinc.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: devel@edk2.groups.io,
	"Michael Kinney" <michael.d.kinney@intel.com>,
	"Liming Gao" <gaoliming@byosoft.com.cn>,
	"Jiewen Yao" <jiewen.yao@intel.com>,
	"Michael Kubacki" <michael.kubacki@microsoft.com>,
	"Sean Brogan" <sean.brogan@microsoft.com>,
	"Rebecca Cran" <quic_rcran@quicinc.com>,
	"Sami Mujawar" <sami.mujawar@arm.com>,
	"Taylor Beebe" <t@taylorbeebe.com>,
	"Marvin Häuser" <mhaeuser@posteo.de>,
	"Bob Feng" <bob.c.feng@intel.com>
Subject: Re: [PATCH v2 11/17] ArmPkg, BaseTools AARCH64: Add BTI ELF note to .hii objects
Date: Mon, 27 Mar 2023 14:09:51 +0100	[thread overview]
Message-ID: <ZCGVn7ITMMH0fCvC@qc-i7.hemma.eciton.net> (raw)
In-Reply-To: <20230327110112.262503-12-ardb@kernel.org>

On Mon, Mar 27, 2023 at 13:01:06 +0200, Ard Biesheuvel wrote:
> The ELF based toolchains use objcopy to create HII object files, which
> contain only a single .hii section. This means no GNU note is inserted
> that describes the object as compatible with BTI, even though the lack
> of executable code in such an object makes the distinction irrelevant.
> However, the linker will not add the note globally to the resulting ELF
> executable, and this breaks BTI compatibility.
> 
> So let's insert a GNU BTI-compatible ELF note by hand when generating
> such object files.
> 
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  ArmPkg/Library/GnuNoteBti.bin     | Bin 0 -> 32 bytes
>  BaseTools/Conf/tools_def.template |   4 ++--
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ArmPkg/Library/GnuNoteBti.bin b/ArmPkg/Library/GnuNoteBti.bin
> new file mode 100644
> index 0000000000000000000000000000000000000000..339567b4e89943c610b44767ddad5f631229ed3b
> GIT binary patch
> literal 32
> dcmZQ!U|<jcVpbq__X`D*3<p?%1S5zA1OOf&0m%RW
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 471eb67c0c839730..ed6050aa96157cb9 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -2400,7 +2400,7 @@ RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS
>  *_GCC5_AARCH64_DTCPP_FLAGS       = DEF(GCC_DTCPP_FLAGS)
>  *_GCC5_AARCH64_PLATFORM_FLAGS    =
>  *_GCC5_AARCH64_PP_FLAGS          = $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
> -*_GCC5_AARCH64_RC_FLAGS          = DEF(GCC_AARCH64_RC_FLAGS)
> +*_GCC5_AARCH64_RC_FLAGS          = DEF(GCC_AARCH64_RC_FLAGS) --add-section .note.gnu.property=$(WORKSPACE)/ArmPkg/Library/GnuNoteBti.bin --set-section-flags .note.gnu.property=alloc,readonly
>  *_GCC5_AARCH64_VFRPP_FLAGS       = $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
>  *_GCC5_AARCH64_CC_XIPFLAGS       = DEF(GCC5_AARCH64_CC_XIPFLAGS)
>  
> @@ -2735,7 +2735,7 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
>  *_CLANG38_AARCH64_DLINK2_FLAGS   = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
>  *_CLANG38_AARCH64_PLATFORM_FLAGS =
>  *_CLANG38_AARCH64_PP_FLAGS       = DEF(GCC_PP_FLAGS) DEF(CLANG38_AARCH64_TARGET) $(PLATFORM_FLAGS)
> -*_CLANG38_AARCH64_RC_FLAGS       = DEF(GCC_AARCH64_RC_FLAGS)
> +*_CLANG38_AARCH64_RC_FLAGS       = DEF(GCC_AARCH64_RC_FLAGS) --add-section .note.gnu.property=$(WORKSPACE)/ArmPkg/Library/GnuNoteBti.bin --set-section-flags .note.gnu.property=alloc,readonly

Bikeshedding, but could we have an AARCH64_BTI_RC_FLAGS or something
set, which is expanded for each toolchain profile? I think this is
esoteric enough that it's helpful to group just the
bti-note-incantations together in a single place.

/
    Leif

>  *_CLANG38_AARCH64_VFRPP_FLAGS    = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_AARCH64_TARGET) $(PLATFORM_FLAGS)
>  *_CLANG38_AARCH64_ASLPP_FLAGS    = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_AARCH64_TARGET)
>  *_CLANG38_AARCH64_CC_XIPFLAGS    = DEF(GCC_AARCH64_CC_XIPFLAGS)
> -- 
> 2.39.2
> 

  reply	other threads:[~2023-03-27 13:10 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 11:00 [PATCH v2 00/17] Enable BTI support in memory attributes table Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note Ard Biesheuvel
2023-03-27 11:52   ` Leif Lindholm
2023-03-27 12:15     ` Ard Biesheuvel
2023-03-27 12:56       ` Leif Lindholm
2023-03-27 12:45   ` Leif Lindholm
2023-03-27 12:46     ` [edk2-devel] " Ard Biesheuvel
2023-03-27 12:49       ` Leif Lindholm
2023-03-27 14:12   ` Pedro Falcato
2023-03-27 14:24     ` Leif Lindholm
2023-03-30  7:28       ` Ard Biesheuvel
2023-03-30 10:47         ` Leif Lindholm
2023-03-27 11:00 ` [PATCH v2 02/17] MdePkg/BaseCpuLib AARCH64: Make asm files BTI compatible Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 03/17] MdePkg/BaseIoLibIntrinsic " Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 04/17] MdePkg/BaseLib AARCH64: Make LongJump() " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 05/17] MdePkg/BaseLib AARCH64: Make asm files " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 06/17] MdePkg/BaseMemoryLibOptDxe " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 07/17] MdePkg/BaseSynchronizationLib " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 08/17] MdePkg/BaseRngLib " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 09/17] ArmPkg: Emit BTI opcodes when BTI codegen is enabled Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 10/17] ArmPkg/GccLto AARCH64: Add BTI note to LTO helper library Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 11/17] ArmPkg, BaseTools AARCH64: Add BTI ELF note to .hii objects Ard Biesheuvel
2023-03-27 13:09   ` Leif Lindholm [this message]
2023-03-27 13:16     ` [edk2-devel] " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 12/17] ArmPlatformPkg/PrePeiCore: Make vector table object BTI compatible Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 13/17] BaseTools/GenFw: Parse IBT/BTI support status from ELF note Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 14/17] BaseTools/GenFw: Add DllCharacteristicsEx field to debug data Ard Biesheuvel
2023-03-27 15:46   ` Marvin Häuser
2023-03-27 16:41     ` Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 15/17] MdePkg: Update MemoryAttributesTable to v2.10 Ard Biesheuvel
2023-03-27 13:29   ` Leif Lindholm
2023-03-29 16:47     ` [edk2-devel] " Ard Biesheuvel
2023-03-29 18:07       ` Leif Lindholm
2023-03-27 11:01 ` [PATCH v2 16/17] MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context Ard Biesheuvel
2023-03-30 14:44   ` [edk2-devel] " Michael Kubacki
2023-03-30 14:53     ` Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 17/17] MdeModulePkg: Enable forward edge CFI in mem attributes table Ard Biesheuvel
2023-03-28 22:59   ` [edk2-devel] " Oliver Smith-Denny
2023-04-03 15:48   ` osde
2023-04-04 10:41     ` Ard Biesheuvel
2023-04-04 15:00       ` Oliver Smith-Denny
2023-04-04 15:30         ` Ard Biesheuvel
2023-03-27 11:43 ` [PATCH v2 00/17] Enable BTI support in memory " Leif Lindholm
2023-03-27 12:54   ` [edk2-devel] " Ard Biesheuvel
2023-03-27 13:37     ` Gerd Hoffmann
2023-03-28 23:00 ` Oliver Smith-Denny
2023-03-29 16:31 ` Leif Lindholm
2023-03-30  7:41   ` [edk2-devel] " Ard Biesheuvel

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-list 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=ZCGVn7ITMMH0fCvC@qc-i7.hemma.eciton.net \
    --to=devel@edk2.groups.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox