From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web10.33790.1679921226084645453 for ; Mon, 27 Mar 2023 05:47:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rRX18J/Y; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2FDBDB811EA for ; Mon, 27 Mar 2023 12:47:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1AA8C433D2 for ; Mon, 27 Mar 2023 12:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679921223; bh=qsywq6Mx0tib+eM15Sb3cGGXdmHx3uztX9aQUnGAUgA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rRX18J/YBgXOmBD48x0LqHUU0/YUDd1ugDC/o5y62+h8M4FKGpaoqL6PMRyusDzLX nlL97FLGN+3IyZJgzqNUOaiN9aB8JyDaAP7C+tOtA++iPw4c0Oh48BH7P3iCBpUaJB Mkv7d8K8L5OVkJZaDcAMLCNvBBJ1W/4GrApxNuknevYqHGdpnb/lEHmjdZ7AqzFX5J Nh53usLOYzBiuEmrFylglcHpOuruaPqje3y22h42L+ElDRxSceMymIlkMI2d8pAHyz kOR1WvaQo/U0n47wjGlWzLscWWySt1w2OC1nlIQ4njOhOl8KhyYYZoubWXz2vGj1sM Ba7+nV+sTmZXA== Received: by mail-lf1-f47.google.com with SMTP id h25so11272092lfv.6 for ; Mon, 27 Mar 2023 05:47:02 -0700 (PDT) X-Gm-Message-State: AAQBX9cEAo7ESPtgTyK+NXOS1aJ5gMZJsf5JIYqrr6QBtzh0nLY0IRHF 8sVpohnOW4gdxaVyhS4TJFzAiTjHMM7M45d0UTk= X-Google-Smtp-Source: AKy350YE/IpT8BdNDRHTACT/ITr246LHpckV0HHC0AKiq4MYj/L+INl20pUf51HfbEbZMs9GC9PQGkk6Dcs3ka/UyM8= X-Received: by 2002:a05:6512:4de:b0:4db:1c2a:a96e with SMTP id w30-20020a05651204de00b004db1c2aa96emr3384717lfq.9.1679921221022; Mon, 27 Mar 2023 05:47:01 -0700 (PDT) MIME-Version: 1.0 References: <20230327110112.262503-1-ardb@kernel.org> <20230327110112.262503-2-ardb@kernel.org> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 27 Mar 2023 14:46:49 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note To: devel@edk2.groups.io, quic_llindhol@quicinc.com Cc: Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Sami Mujawar , Taylor Beebe , =?UTF-8?Q?Marvin_H=C3=A4user?= , Bob Feng Content-Type: text/plain; charset="UTF-8" On Mon, 27 Mar 2023 at 14:45, Leif Lindholm wrote: > > On Mon, Mar 27, 2023 at 13:00:56 +0200, Ard Biesheuvel wrote: > > Implement a CPP macro that can be called from .S files to emit the .note > > section carrying the annotation that informs the linker that the object > > file is compatible with BTI control flow integrity checks. > > > > Signed-off-by: Ard Biesheuvel > > --- > > MdePkg/Include/AArch64/ProcessorBind.h | 31 ++++++++++++++++++++ > > 1 file changed, 31 insertions(+) > > > > diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h > > index abe2571245c665f3..11814f1ffaef698a 100644 > > --- a/MdePkg/Include/AArch64/ProcessorBind.h > > +++ b/MdePkg/Include/AArch64/ProcessorBind.h > > @@ -186,6 +186,37 @@ typedef INT64 INTN; > > #define GCC_ASM_IMPORT(func__) \ > > .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__) > > > > +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1 > > +#define AARCH64_BTI(__type) \ > > + .ifnc __type, ;\ > > + bti __type ;\ > > + .endif ;\ > > This didn't jump out at me until looking at the consumer side. > This overlays two different sets of functionality depending on whether > an option is given to the macro or not, which feels semantically > suboptimal to me (i.e. it makes my head hurt). > > Could we split this into two macros - one that inserts the instruction > and one that inserts the note, and expand the latter in the former? > Yeah, fair point. So AARCH64_BTI_NOTE() to emit the note, and AARCH64_BTI() to emit the instruction as well as the note.