All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] armv8a: Set -mbranch-protection more specifically
@ 2025-11-13  7:47 Frank Zhang
  2025-11-13 11:17 ` [OE-core] " Ross Burton
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Zhang @ 2025-11-13  7:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: Frank Zhang

GCC-15 enable gcs in standard branch protection, which is support by armv9.
Openssl don't support this feature in assemble code, caused ld warning.
Moeover, other recipes will fail when link with openssl.
This patch set armv8a branch protection based on extension version.

Signed-off-by: Frank Zhang <rmxpzlb@gmail.com>
---
 meta/conf/machine/include/arm/arch-arm64.inc | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/meta/conf/machine/include/arm/arch-arm64.inc b/meta/conf/machine/include/arm/arch-arm64.inc
index 832d0000ac..938dee4798 100644
--- a/meta/conf/machine/include/arm/arch-arm64.inc
+++ b/meta/conf/machine/include/arm/arch-arm64.inc
@@ -41,4 +41,23 @@ TARGET_FPU = "${@bb.utils.contains('TUNE_FEATURES', 'aarch64', '${TARGET_FPU_64}
 # Emit branch protection (PAC/BTI) instructions.  On hardware that doesn't
 # support these they're meaningless NOP instructions, so there's very little
 # reason not to.
-TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'aarch64', ' -mbranch-protection=standard', '', d)}"
+def arm64_get_branch_protection(d):
+    import re
+    bp = "standard"
+    tunes = d.getVar('AVAILTUNES')
+    if "armv8a" in tunes.split():
+        bp = "none"
+        subver = 0
+        for tune in tunes.split():
+            arch = re.match('armv8-[1-9]a', tune)
+            if arch:
+                subver = int(tune[6:7])
+                break
+
+        if subver >= 5:
+            bp = "bti+pac-ret"
+        elif subver >= 3:
+            bp = "pac-ret"
+    return bp
+
+TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'aarch64', ' -mbranch-protection=%s' % (arm64_get_branch_protection(d)), '', d)}"


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-14 11:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-13  7:47 [PATCH] armv8a: Set -mbranch-protection more specifically Frank Zhang
2025-11-13 11:17 ` [OE-core] " Ross Burton
2025-11-14  3:19   ` Frank Zhang
2025-11-14  4:15     ` [OE-core] " Khem Raj
2025-11-14 11:49       ` Ross Burton

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.