new file mode 100644
@@ -0,0 +1,147 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Baker <tyler.baker@oss.qualcomm.com>
+Date: Thu, 3 Dec 2026 07:43:46 +0000
+Subject: [PATCH 1/2] Bug 519254 - arm64: decode RETAA and RETAB
+
+With -mbranch-protection=pac-ret and Armv8.3-A or later, GCC returns
+through RETAA or RETAB instead of AUTIASP; RET. OpenEmbedded builds
+every aarch64 target with -mbranch-protection=standard, so on an
+Armv8.6-A glibc every dynamically linked program dies in ld.so:
+
+ disInstr(arm64): unhandled instruction 0xD65F0BFF
+
+PACIASP and PACIBSP are hints that Valgrind runs as NOPs, so X30 is
+never signed and RETAA and RETAB are plain RET X30. Decode them that
+way. HWCAP_PACA is already masked out of the client auxv, so code that
+checks it does not take non-hint PAC paths.
+
+GCC's pac-ret never emits BRAA, BRAB, BLRAA or BLRAB. Clang's pointer
+authentication ABI (aarch64-linux-pauthtest) emits their Z forms for
+indirect and tail calls and signs code pointers with PACIZA; these are
+out of scope here and still stop as unhandled.
+
+Add none/tests/arm64/pac_ret.
+
+https://bugs.kde.org/show_bug.cgi?id=519254
+
+Upstream-Status: Submitted [https://bugs.kde.org/show_bug.cgi?id=519254]
+
+Notes: Drop the .gitignore change for the release tarball
+
+Signed-off-by: Tyler Baker <tyler.baker@oss.qualcomm.com>
+---
+ VEX/priv/guest_arm64_toIR.c | 14 +++++++++++
+ none/tests/arm64/Makefile.am | 4 +++-
+ none/tests/arm64/pac_ret.c | 36 +++++++++++++++++++++++++++++
+ none/tests/arm64/pac_ret.stdout.exp | 2 ++
+ none/tests/arm64/pac_ret.vgtest | 2 ++
+ 5 files changed, 57 insertions(+), 1 deletion(-)
+ create mode 100644 none/tests/arm64/pac_ret.c
+ create mode 100644 none/tests/arm64/pac_ret.stdout.exp
+ create mode 100644 none/tests/arm64/pac_ret.vgtest
+
+diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c
+index a4770b86e..048b68b6b 100644
+--- a/VEX/priv/guest_arm64_toIR.c
++++ b/VEX/priv/guest_arm64_toIR.c
+@@ -7476,6 +7476,20 @@ Bool dis_ARM64_branch_etc(/*MB_OUT*/DisResult* dres, UInt insn,
+ }
+ }
+
++ /* ------------------ RETAA, RETAB ------------------ */
++ /* 31 24 22 20 15 11 10 9 4
++ 1101011 00 10 11111 0000 1 M 11111 11111 RETAA (M=0), RETAB (M=1)
++ PACIASP and PACIBSP are decoded as hints, so LR was never signed
++ and there is nothing to authenticate: this is RET X30.
++ */
++ if ((INSN(31,0) & 0xFFFFFBFF) == 0xD65F0BFF) {
++ putPC(getIReg64orZR(30));
++ dres->whatNext = Dis_StopHere;
++ dres->jk_StopHere = Ijk_Ret;
++ DIP("reta%c\n", INSN(10,10) ? 'b' : 'a');
++ return True;
++ }
++
+ /* -------------------- CB{N}Z -------------------- */
+ /* sf 011 010 1 imm19 Rt CBNZ Xt|Wt, (PC + sxTo64(imm19 << 2))
+ sf 011 010 0 imm19 Rt CBZ Xt|Wt, (PC + sxTo64(imm19 << 2))
+diff --git a/none/tests/arm64/Makefile.am b/none/tests/arm64/Makefile.am
+index 3d31aa08c..b7b48f775 100644
+--- a/none/tests/arm64/Makefile.am
++++ b/none/tests/arm64/Makefile.am
+@@ -25,6 +25,7 @@ EXTRA_DIST = \
+ fp_and_simd_v82.stdout.exp fp_and_simd_v82.vgtest \
+ ldxp_stxp_basisimpl.stdout.exp ldxp_stxp_basisimpl.vgtest \
+ ldxp_stxp_fallbackimpl.stdout.exp ldxp_stxp_fallbackimpl.vgtest \
++ pac_ret.stdout.exp pac_ret.vgtest \
+ sha512_v82.stdout.exp sha512_v82.vgtest \
+ v8crypto.stdout.exp v8crypto.vgtest
+
+@@ -38,7 +39,8 @@ check_PROGRAMS = \
+ integer \
+ memory_test \
+ fmadd_sub \
+- ldxp_stxp
++ ldxp_stxp \
++ pac_ret
+
+ if BUILD_ARMV8_CRC_TESTS
+ check_PROGRAMS += crc32
+diff --git a/none/tests/arm64/pac_ret.c b/none/tests/arm64/pac_ret.c
+new file mode 100644
+index 000000000..c489974db
+--- /dev/null
++++ b/none/tests/arm64/pac_ret.c
+@@ -0,0 +1,36 @@
++/* Return through RETAA and RETAB, as code built with
++ -mbranch-protection=pac-ret for Armv8.3-A or later does. The
++ instructions are emitted as words so that no assembler support for
++ pointer authentication is needed. PACIASP and PACIBSP are BTI
++ landing pads, so the functions are valid in an object marked BTI
++ compatible by -mbranch-protection=standard. */
++
++#include <stdio.h>
++
++extern long ret_a(long);
++extern long ret_b(long);
++
++__asm__(
++ ".text\n"
++ ".global ret_a\n"
++ ".type ret_a, %function\n"
++ "ret_a:\n"
++ " hint #25\n" /* paciasp */
++ " add x0, x0, #1\n"
++ " .inst 0xd65f0bff\n" /* retaa */
++ ".size ret_a, .-ret_a\n"
++ ".global ret_b\n"
++ ".type ret_b, %function\n"
++ "ret_b:\n"
++ " hint #27\n" /* pacibsp */
++ " add x0, x0, #2\n"
++ " .inst 0xd65f0fff\n" /* retab */
++ ".size ret_b, .-ret_b\n"
++);
++
++int main(void)
++{
++ printf("retaa %ld\n", ret_a(40));
++ printf("retab %ld\n", ret_b(40));
++ return 0;
++}
+diff --git a/none/tests/arm64/pac_ret.stdout.exp b/none/tests/arm64/pac_ret.stdout.exp
+new file mode 100644
+index 000000000..29567877e
+--- /dev/null
++++ b/none/tests/arm64/pac_ret.stdout.exp
+@@ -0,0 +1,2 @@
++retaa 41
++retab 42
+diff --git a/none/tests/arm64/pac_ret.vgtest b/none/tests/arm64/pac_ret.vgtest
+new file mode 100644
+index 000000000..dbdab8e09
+--- /dev/null
++++ b/none/tests/arm64/pac_ret.vgtest
+@@ -0,0 +1,2 @@
++prog: pac_ret
++vgopts: -q
new file mode 100644
@@ -0,0 +1,227 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tyler Baker <tyler.baker@oss.qualcomm.com>
+Date: Thu, 3 Dec 2026 00:23:56 +0000
+Subject: [PATCH 2/2] Bug 519254 - arm64: decode STLUR and LDAPUR
+
+With RETAA and RETAB decoded, the same ld.so dies next on an FEAT_LRCPC2
+unscaled-offset store-release:
+
+ disInstr(arm64): unhandled instruction 0xD9008001
+
+(stlur x1, [x0, #8]). Valgrind decodes LDAR, STLR and LDAPR, but not
+STLUR{B,H}, LDAPUR{B,H} and LDAPURS{B,H,W}.
+
+Decode them like LDAR, STLR and LDAPR: base plus signed 9-bit offset,
+alignment check, fence after the load or before the store. LDAPURS
+sign-extends to 64 bits for Xt, and to 32 bits zero-extended to 64 for
+Wt.
+
+Add none/tests/arm64/lrcpc2, covering every form, negative offsets and
+SP as the base; its expected output comes from FEAT_LRCPC2 hardware.
+
+https://bugs.kde.org/show_bug.cgi?id=519254
+
+Upstream-Status: Submitted [https://bugs.kde.org/show_bug.cgi?id=519254]
+
+Notes: Drop the NEWS and .gitignore changes for the release tarball
+
+Signed-off-by: Tyler Baker <tyler.baker@oss.qualcomm.com>
+---
+ VEX/priv/guest_arm64_toIR.c | 46 ++++++++++++++++++
+ none/tests/arm64/Makefile.am | 2 +
+ none/tests/arm64/lrcpc2.c | 77 ++++++++++++++++++++++++++++++
+ none/tests/arm64/lrcpc2.stdout.exp | 14 ++++++
+ none/tests/arm64/lrcpc2.vgtest | 2 +
+ 5 files changed, 141 insertions(+)
+ create mode 100644 none/tests/arm64/lrcpc2.c
+ create mode 100644 none/tests/arm64/lrcpc2.stdout.exp
+ create mode 100644 none/tests/arm64/lrcpc2.vgtest
+
+diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c
+index 048b68b6b..9d995371f 100644
+--- a/VEX/priv/guest_arm64_toIR.c
++++ b/VEX/priv/guest_arm64_toIR.c
+@@ -7096,6 +7096,52 @@ Bool dis_ARM64_load_store(/*MB_OUT*/DisResult* dres, UInt insn,
+ return True;
+ }
+
++ /* ---------- STLUR{B,H}, LDAPUR{B,H}, LDAPURS{B,H,W} ---------- */
++ /* 31 29 23 21 20 11 9 4
++ sz 011001 00 0 imm9 00 n t STLUR<sz> Rt, [Xn|SP, #simm9]
++ sz 011001 01 0 imm9 00 n t LDAPUR<sz> Rt, [Xn|SP, #simm9]
++ sz 011001 10 0 imm9 00 n t LDAPURS<sz> Xt, [Xn|SP, #simm9]
++ sz 011001 11 0 imm9 00 n t LDAPURS<sz> Wt, [Xn|SP, #simm9]
++ LDAPURS to Xt exists for sz = 00, 01, 10; to Wt for sz = 00, 01.
++ */
++ if (INSN(29,24) == BITS6(0,1,1,0,0,1) && INSN(21,21) == 0
++ && INSN(11,10) == BITS2(0,0)) {
++ UInt szBlg2 = INSN(31,30);
++ UInt opc = INSN(23,22);
++ ULong simm9 = sx_to_64(INSN(20,12), 9);
++ UInt nn = INSN(9,5);
++ UInt tt = INSN(4,0);
++ if (opc <= 1 || (opc == 2 && szBlg2 <= 2)
++ || (opc == 3 && szBlg2 <= 1)) {
++ UInt szB = 1 << szBlg2;
++ IRType ty = integerIRTypeOfSize(szB);
++ Bool isX = opc == 2 || (opc != 3 && szB == 8);
++ const HChar* name[4] = { "stlur", "ldapur", "ldapurs", "ldapurs" };
++ const HChar* sfx = szBlg2 == 0 ? "b" : szBlg2 == 1 ? "h"
++ : opc == 2 ? "w" : "";
++
++ IRTemp ea = newTemp(Ity_I64);
++ assign(ea, binop(Iop_Add64, getIReg64orSP(nn), mkU64(simm9)));
++ gen_SIGBUS_if_not_XX_aligned(ea, szB);
++
++ if (opc == 0) {
++ stmt(IRStmt_MBE(Imbe_Fence));
++ storeLE(mkexpr(ea), narrowFrom64(ty, getIReg64orZR(tt)));
++ } else {
++ IRExpr* res = loadLE(ty, mkexpr(ea));
++ res = opc == 1 ? widenUto64(ty, res) : widenSto64(ty, res);
++ if (opc == 3)
++ res = unop(Iop_32Uto64, unop(Iop_64to32, res));
++ putIReg64orZR(tt, res);
++ stmt(IRStmt_MBE(Imbe_Fence));
++ }
++ DIP("%s%s %s, [%s, #%lld]\n", name[opc], sfx,
++ nameIRegOrZR(isX, tt), nameIReg64orSP(nn), (Long)simm9);
++ return True;
++ }
++ /* else fall through */
++ }
++
+ /* The PRFM cases that follow are possibly allow Rt values (the
+ prefetch operation) which are not allowed by the documentation.
+ This should be looked into. */
+diff --git a/none/tests/arm64/Makefile.am b/none/tests/arm64/Makefile.am
+index b7b48f775..1f50f9097 100644
+--- a/none/tests/arm64/Makefile.am
++++ b/none/tests/arm64/Makefile.am
+@@ -25,6 +25,7 @@ EXTRA_DIST = \
+ fp_and_simd_v82.stdout.exp fp_and_simd_v82.vgtest \
+ ldxp_stxp_basisimpl.stdout.exp ldxp_stxp_basisimpl.vgtest \
+ ldxp_stxp_fallbackimpl.stdout.exp ldxp_stxp_fallbackimpl.vgtest \
++ lrcpc2.stdout.exp lrcpc2.vgtest \
+ pac_ret.stdout.exp pac_ret.vgtest \
+ sha512_v82.stdout.exp sha512_v82.vgtest \
+ v8crypto.stdout.exp v8crypto.vgtest
+@@ -40,6 +41,7 @@ check_PROGRAMS = \
+ memory_test \
+ fmadd_sub \
+ ldxp_stxp \
++ lrcpc2 \
+ pac_ret
+
+ if BUILD_ARMV8_CRC_TESTS
+diff --git a/none/tests/arm64/lrcpc2.c b/none/tests/arm64/lrcpc2.c
+new file mode 100644
+index 000000000..f753b8261
+--- /dev/null
++++ b/none/tests/arm64/lrcpc2.c
+@@ -0,0 +1,77 @@
++/* Load-acquire RCpc and store-release with an unscaled offset (FEAT_LRCPC2,
++ Armv8.4-A), as emitted by GCC for C11 atomics at -march=armv8.4-a and
++ later. The instructions are emitted as words so that no assembler
++ support for them is needed. */
++
++#include <stdio.h>
++#include <string.h>
++
++static unsigned char buf[32] __attribute__((aligned(16)));
++
++static void fill(void)
++{
++ for (int i = 0; i < 32; i++)
++ buf[i] = 0x80 + i;
++}
++
++#define LOAD(name, word) \
++ do { \
++ unsigned long out; \
++ fill(); \
++ __asm__ __volatile__( \
++ "mov x1, #0x5555\n" \
++ "movk x1, #0x5555, lsl #48\n" \
++ "mov x2, %1\n" \
++ ".inst " #word "\n" \
++ "mov %0, x1\n" \
++ : "=r"(out) : "r"(buf + 16) : "x1", "x2", "memory"); \
++ printf("%-24s %016lx\n", name, out); \
++ } while (0)
++
++#define STORE(name, word) \
++ do { \
++ memset(buf, 0, sizeof(buf)); \
++ __asm__ __volatile__( \
++ "mov x2, %1\n" \
++ "mov x1, %0\n" \
++ ".inst " #word "\n" \
++ : : "r"(0x0123456789abcdefUL), "r"(buf + 16) \
++ : "x1", "x2", "memory"); \
++ printf("%-24s", name); \
++ for (int i = 8; i < 24; i++) \
++ printf(" %02x", buf[i]); \
++ printf("\n"); \
++ } while (0)
++
++int main(void)
++{
++ LOAD("ldapurb w1, [x2, #-7]", 0x195f9041);
++ LOAD("ldapurh w1, [x2, #-6]", 0x595fa041);
++ LOAD("ldapur w1, [x2, #4]", 0x99404041);
++ LOAD("ldapur x1, [x2, #-8]", 0xd95f8041);
++ LOAD("ldapursb x1, [x2, #-1]", 0x199ff041);
++ LOAD("ldapursb w1, [x2, #-1]", 0x19dff041);
++ LOAD("ldapursh x1, [x2, #-2]", 0x599fe041);
++ LOAD("ldapursh w1, [x2, #-2]", 0x59dfe041);
++ LOAD("ldapursw x1, [x2, #-4]", 0x999fc041);
++ STORE("stlurb w1, [x2, #-5]", 0x191fb041);
++ STORE("stlurh w1, [x2, #2]", 0x59002041);
++ STORE("stlur w1, [x2, #4]", 0x99004041);
++ STORE("stlur x1, [x2, #-8]", 0xd91f8041);
++
++ /* SP as the base register. */
++ {
++ unsigned long out;
++ __asm__ __volatile__(
++ "sub sp, sp, #32\n"
++ "mov x1, %1\n"
++ ".inst 0xd90083e1\n" /* stlur x1, [sp, #8] */
++ "mov x1, #0\n"
++ ".inst 0xd94083e1\n" /* ldapur x1, [sp, #8] */
++ "add sp, sp, #32\n"
++ "mov %0, x1\n"
++ : "=r"(out) : "r"(0xfedcba9876543210UL) : "x1", "memory");
++ printf("%-24s %016lx\n", "stlur/ldapur [sp, #8]", out);
++ }
++ return 0;
++}
+diff --git a/none/tests/arm64/lrcpc2.stdout.exp b/none/tests/arm64/lrcpc2.stdout.exp
+new file mode 100644
+index 000000000..d7fd42388
+--- /dev/null
++++ b/none/tests/arm64/lrcpc2.stdout.exp
+@@ -0,0 +1,14 @@
++ldapurb w1, [x2, #-7] 0000000000000089
++ldapurh w1, [x2, #-6] 0000000000008b8a
++ldapur w1, [x2, #4] 0000000097969594
++ldapur x1, [x2, #-8] 8f8e8d8c8b8a8988
++ldapursb x1, [x2, #-1] ffffffffffffff8f
++ldapursb w1, [x2, #-1] 00000000ffffff8f
++ldapursh x1, [x2, #-2] ffffffffffff8f8e
++ldapursh w1, [x2, #-2] 00000000ffff8f8e
++ldapursw x1, [x2, #-4] ffffffff8f8e8d8c
++stlurb w1, [x2, #-5] 00 00 00 ef 00 00 00 00 00 00 00 00 00 00 00 00
++stlurh w1, [x2, #2] 00 00 00 00 00 00 00 00 00 00 ef cd 00 00 00 00
++stlur w1, [x2, #4] 00 00 00 00 00 00 00 00 00 00 00 00 ef cd ab 89
++stlur x1, [x2, #-8] ef cd ab 89 67 45 23 01 00 00 00 00 00 00 00 00
++stlur/ldapur [sp, #8] fedcba9876543210
+diff --git a/none/tests/arm64/lrcpc2.vgtest b/none/tests/arm64/lrcpc2.vgtest
+new file mode 100644
+index 000000000..eb6216772
+--- /dev/null
++++ b/none/tests/arm64/lrcpc2.vgtest
+@@ -0,0 +1,2 @@
++prog: lrcpc2
++vgopts: -q
@@ -27,6 +27,8 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
file://0001-tests-arm-Use-O-instead-of-O0.patch \
file://0001-getdents_filter.c-workaround-off64_t-not-defined-in-.patch \
file://0001-Bug-5277723-configure.ac-do-not-fail-the-arm64-test-.patch \
+ file://0004-Bug-519254-arm64-decode-RETAA-and-RETAB.patch \
+ file://0005-Bug-519254-arm64-decode-STLUR-and-LDAPUR.patch \
"
SRC_URI[sha256sum] = "9f7a18d128f05d3a80fea53e6953f34aad7200a425ceaee46099a8a798a7dd9c"
OE-core builds every aarch64 target with -mbranch-protection=standard (arch-arm64.inc). With an Armv8.3-A or later tune GCC then returns through RETAA, and with Armv8.4-A or later it uses the FEAT_LRCPC2 STLUR/LDAPUR forms for C11 atomics. Valgrind 3.28.0 decodes neither, so on such a machine every dynamically linked program dies with SIGILL in ld.so before main, first on RETAA (0xD65F0BFF) in _dl_sysdep_parse_arguments and, with that decoded, on stlur x1, [x0, #8] (0xD9008001). Valgrind master has the same gap. Add the two fixes submitted on the upstream bug. They also add the none/tests/arm64 regression tests pac_ret and lrcpc2, kept so that the patches match the upstream submission; the recipe does not run them, as valgrind ptest has been disabled since commit 8fc31fb235 ("valgrind: disable ptests"). Link: https://bugs.kde.org/show_bug.cgi?id=519254 AI-Generated: Claude Code, Opus 5.5 Reviewed-by: Khem Raj <khem.raj@oss.qualcomm.com> Signed-off-by: Tyler Baker <tyler.baker@oss.qualcomm.com> --- ...-519254-arm64-decode-RETAA-and-RETAB.patch | 147 ++++++++++++ ...519254-arm64-decode-STLUR-and-LDAPUR.patch | 227 ++++++++++++++++++ .../valgrind/valgrind_3.28.0.bb | 2 + 3 files changed, 376 insertions(+) create mode 100644 meta/recipes-devtools/valgrind/valgrind/0004-Bug-519254-arm64-decode-RETAA-and-RETAB.patch create mode 100644 meta/recipes-devtools/valgrind/valgrind/0005-Bug-519254-arm64-decode-STLUR-and-LDAPUR.patch