All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Zhang <rmxpzlb@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Frank Zhang <rmxpzlb@gmail.com>
Subject: [PATCH] armv8a: Set -mbranch-protection more specifically
Date: Thu, 13 Nov 2025 15:47:47 +0800	[thread overview]
Message-ID: <20251113074747.6735-1-rmxpzlb@gmail.com> (raw)

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)}"


             reply	other threads:[~2025-11-13  7:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13  7:47 Frank Zhang [this message]
2025-11-13 11:17 ` [OE-core] [PATCH] armv8a: Set -mbranch-protection more specifically 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

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=20251113074747.6735-1-rmxpzlb@gmail.com \
    --to=rmxpzlb@gmail.com \
    --cc=openembedded-core@lists.openembedded.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.