All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Vincenzo Frascino <Vincenzo.Frascino@arm.com>,
	Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>
Cc: Kees Cook <keescook@chromium.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
	Mark Brown <broonie@kernel.org>,
	Amit Kachhap <amit.kachhap@arm.com>,
	Dave Martin <Dave.Martin@arm.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 08/11] arm64: asm: Provide a mechanism for generating ELF note for BTI
Date: Wed,  6 May 2020 20:51:35 +0100	[thread overview]
Message-ID: <20200506195138.22086-9-broonie@kernel.org> (raw)
In-Reply-To: <20200506195138.22086-1-broonie@kernel.org>

ELF files built for BTI should have a program property note section which
identifies them as such. The linker expects to find this note in all
object files it is linking into a BTI annotated output, the compiler will
ensure that this happens for C files but for assembler files we need to do
this in the source so provide a macro which can be used for this purpose.
To support likely future requirements for additional notes we split the
defininition of the flags to set for BTI code from the macro that creates
the note itself.

This is mainly for use in the vDSO which should be a normal ELF shared
library and should therefore include BTI annotations when built for BTI.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/include/asm/assembler.h | 50 ++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 0bff325117b4..54d181177656 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -736,4 +736,54 @@ USER(\label, ic	ivau, \tmp2)			// invalidate I line PoU
 .Lyield_out_\@ :
 	.endm
 
+/*
+ * This macro emits a program property note section identifying
+ * architecture features which require special handling, mainly for
+ * use in assembly files included in the VDSO.
+ */
+
+#define NT_GNU_PROPERTY_TYPE_0  5
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND      0xc0000000
+
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI      (1U << 0)
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC      (1U << 1)
+
+#ifdef CONFIG_ARM64_BTI_KERNEL
+#define GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT		\
+		((GNU_PROPERTY_AARCH64_FEATURE_1_BTI |	\
+		  GNU_PROPERTY_AARCH64_FEATURE_1_PAC))
+#endif
+
+#ifdef GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT
+.macro emit_aarch64_feature_1_and, feat=GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT
+	.pushsection .note.gnu.property, "a"
+	.align  3
+	.long   2f - 1f
+	.long   6f - 3f
+	.long   NT_GNU_PROPERTY_TYPE_0
+1:      .string "GNU"
+2:
+	.align  3
+3:      .long   GNU_PROPERTY_AARCH64_FEATURE_1_AND
+	.long   5f - 4f
+4:
+	/*
+	 * This is described with an array of char in the Linux API
+	 * spec but the text and all other usage (including binutils,
+	 * clang and GCC) treat this as a 32 bit value so no swizzling
+	 * is required for big endian.
+	 */
+	.long   \feat
+5:
+	.align  3
+6:
+	.popsection
+.endm
+
+#else
+.macro emit_aarch64_feature_1_and, feat=0
+.endm
+
+#endif /* GNU_PROPERTY_AARCH64_FEATURE_1_DEFAULT */
+
 #endif	/* __ASM_ASSEMBLER_H */
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-05-06 19:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 19:51 [PATCH v3 00/11] arm64: BTI kernel and vDSO support Mark Brown
2020-05-06 19:51 ` [PATCH v3 01/11] arm64: Document why we enable PAC support for leaf functions Mark Brown
2020-05-06 19:51 ` [PATCH v3 02/11] arm64: bti: Support building kernel C code using BTI Mark Brown
2020-05-06 19:51 ` [PATCH v3 03/11] arm64: asm: Override SYM_FUNC_START when building the kernel with BTI Mark Brown
2020-05-06 19:51 ` [PATCH v3 04/11] arm64: Set GP bit in kernel page tables to enable BTI for the kernel Mark Brown
2020-05-06 19:51 ` [PATCH v3 05/11] arm64: bpf: Annotate JITed code for BTI Mark Brown
2020-05-07 20:15   ` Daniel Borkmann
2020-05-07 20:15     ` Daniel Borkmann
2020-05-06 19:51 ` [PATCH v3 06/11] arm64: mm: Mark executable text as guarded pages Mark Brown
2020-05-06 19:51 ` [PATCH v3 07/11] arm64: bti: Provide Kconfig for kernel mode BTI Mark Brown
2020-05-06 19:51 ` Mark Brown [this message]
2020-05-06 19:51 ` [PATCH v3 09/11] arm64: vdso: Annotate for BTI Mark Brown
2020-05-06 19:51 ` [PATCH v3 10/11] arm64: vdso: Force the vDSO to be linked as BTI when built " Mark Brown
2020-05-06 19:51 ` [PATCH v3 11/11] arm64: vdso: Map the vDSO text with guarded pages " Mark Brown
2020-05-07 14:33 ` [PATCH v3 00/11] arm64: BTI kernel and vDSO support Will Deacon
2020-05-07 14:35   ` Will Deacon
2020-05-07 14:59     ` Will Deacon
2020-05-07 15:09       ` Mark Brown
2020-05-07 15:18         ` Will Deacon
2020-05-07 15:48           ` Mark Brown
2020-05-07 15:55             ` Will Deacon
2020-05-07 16:30               ` Mark Brown
2020-05-07 16:36                 ` Will Deacon
2020-05-07 16:47                   ` Mark Brown
2020-05-08 16:53                   ` Mark Brown
2020-05-07 15:07     ` Mark Brown
2020-05-07 15:26       ` Will Deacon
2020-05-07 17:25 ` Will Deacon

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-all 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=20200506195138.22086-9-broonie@kernel.org \
    --to=broonie@kernel.org \
    --cc=Dave.Martin@arm.com \
    --cc=Vincenzo.Frascino@arm.com \
    --cc=amit.kachhap@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=jean-philippe.brucker@arm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.