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.web11.33313.1679919326065891024 for ; Mon, 27 Mar 2023 05:15:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lSLCas+a; 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 8C95CB8117B for ; Mon, 27 Mar 2023 12:15:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7B9DC433A8 for ; Mon, 27 Mar 2023 12:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679919322; bh=vTvDf1MS57UKAa95otaeGQf2douf8nF0goY01SCsdtI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lSLCas+apvOS3C7o9/yijN46Nwf5ZjSSSd9+veYcY2gxCZfsLMPIWu6N4IKRik6yM fdb3gJLc7eGzn7mZSoE+yaacljnJhf4F2MwBWgqUBGtsAtPHALnoape7oneeOMA/cx o2Zcsq2IChsiAB1MdUudKm0ljk+gan2DpeOR4wpTfcHxyYDypLA24GLFBRAgb03JKG TTJkKj8nB/5CcZsTNHcLgycIes9l84LVdtgapI4ftH9uqS/4fDo5fAk4z3pNJfPGXA l+KjMCZfH+o06vf3pl6n39RK+pfCnmGT84XQwzU9iRN8j+PwHmfH1T+BHVBZlRYlcX A3uTfcLGjz5Nw== Received: by mail-lf1-f43.google.com with SMTP id g17so11153738lfv.4 for ; Mon, 27 Mar 2023 05:15:22 -0700 (PDT) X-Gm-Message-State: AAQBX9cEDuFWh2ndQJ7OA+VneANtYLWPOmO9SWkeMxMcsfx9JTb6oY5N XMTYLUEWae62Ijp2PMJ+4Ol9RWWKRiBjT+amZtY= X-Google-Smtp-Source: AKy350YHokNG/loeShqH0HZT3FM7hrFNB26vS8+hyXBhxtYZNfQIEYeHbh/cIWOV43zAVatrplWodG+iwROJM3ykhZs= X-Received: by 2002:ac2:568d:0:b0:4eb:c44:ed50 with SMTP id 13-20020ac2568d000000b004eb0c44ed50mr1536140lfr.9.1679919320813; Mon, 27 Mar 2023 05:15:20 -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:15:09 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note To: Leif Lindholm Cc: devel@edk2.groups.io, 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 13:53, 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 ;\ > > + .ifndef .Lgnu_bti_notesize ;\ > > + .pushsection .note.gnu.property, "a" ;\ > > + .set NT_GNU_PROPERTY_TYPE_0, 0x5 ;\ > > + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 ;\ > > + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\ > > + .align 3 ;\ > > + .long .Lnamesize ;\ > > + .long .Lgnu_bti_notesize ;\ > > + .long NT_GNU_PROPERTY_TYPE_0 ;\ > > +0: .asciz "GNU" ;\ > > + .set .Lnamesize, . - 0b ;\ > > + .align 3 ;\ > > +1: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND ;\ > > + .long .Lvalsize ;\ > > +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI ;\ > > + .set .Lvalsize, . - 2b ;\ > > + .align 3 ;\ > > + .set .Lgnu_bti_notesize, . - 1b ;\ > > + .popsection ;\ > > + .endif > > +#endif > > + > > +#endif > > Is that second endif superflouous? > No the diff just turned out a bit odd.