From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 66-220-155-179.mail-mxout.facebook.com (66-220-155-179.mail-mxout.facebook.com [66.220.155.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7892C387363 for ; Fri, 11 Sep 2026 04:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.220.155.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789099816; cv=none; b=mbvJgsgbA1/M9xX0W/PdXeTCMb143gdGroYukixcGK2AUEO/wAHA6Rrp6dK72yP0Qg0d9c+1XJUKHPijWj6bKJLt3zRxNRc38Thx/aRVDeKkzYsDNoO/kOTDVSclf+evuAe//4fktGjI2kDilom6vztQMNt7Fi9wx6dZg267FRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789099816; c=relaxed/simple; bh=97a7RdYdiN707NQHEf1vAgoKhgDkIk+l/W4WLUeCG/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pdtjNOlL+3+WtuXu+Q+2u716XJc4H/rl4VU1g1LE3AwDqt6pudpDgjmKk8U2uAIxZ7hjfBGY6PdhBEj3DJYXooXrw4YLK+4yl1dGSrAooreIXO0Df2VItOhEJHnrMejY3Gha6oR15VdgMBRnGkzLFTOnVqRM063PHUrgwl8OUis= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=66.220.155.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id CB83A29FDA2C50; Thu, 10 Sep 2026 21:10:00 -0700 (PDT) From: Yonghong Song To: Alan Maguire , Arnaldo Carvalho de Melo , dwarves@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, kernel-team@fb.com Subject: [PATCH dwarves 2/2] tests: tests: Add test for 16-byte aligned arguments on arm64 Date: Thu, 10 Sep 2026 21:10:00 -0700 Message-ID: <20260911041000.340219-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260911040955.339939-1-yonghong.song@linux.dev> References: <20260911040955.339939-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Cover the arm64 even-register rule for 16-byte aligned arguments: f_even() and f_stack() where the rule does not bite, f_odd() and f_odd_tail() where it leaves a register hole, and f_box() where the alignment comes from a struct member rather than from the parameter type itself. The test results on arm64: $ VERBOSE=3D1 ./clang_parm_align16.sh Validation of BTF encoding of over-aligned arguments. BTF: u64 f_even(u64 a, u64 b, __int128 v); BTF: u64 f_odd(u64 a, __int128 v, u64 b); BTF: u64 f_odd_tail(u64 a, __int128 v, u64 b, u64 c, u64 d); BTF: u64 f_stack(u64 a, u64 b, u64 c, u64 d, u64 e, u64 f, u64 g, __= int128 v); BTF: u64 f_box(u64 a, struct box s, u64 b); Test ./clang_parm_align16.sh passed Signed-off-by: Yonghong Song --- tests/clang_parm_align16.sh | 77 +++++++++++++++++++++++++++++++++++++ tests/test_lib.sh | 3 +- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100755 tests/clang_parm_align16.sh diff --git a/tests/clang_parm_align16.sh b/tests/clang_parm_align16.sh new file mode 100755 index 0000000..484aeb6 --- /dev/null +++ b/tests/clang_parm_align16.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source test_lib.sh + +outdir=3D$(make_tmpdir) + +# Comment this out to save test data. +trap cleanup EXIT + +title_log "Validation of BTF encoding of over-aligned arguments." + +align16=3D"${outdir}/align16" +CC=3D$(which clang 2>/dev/null) + +if [[ -z "$CC" ]]; then + info_log "skip: clang not available" + test_skip +fi + +arch=3D$(uname -m) +if [[ "$arch" !=3D "aarch64" ]]; then + info_log "skip: test is arm64 only, running on $arch" + test_skip +fi + +# arm64 makes an argument whose alignment is 16 start on an even-numbere= d +# argument register, so f_odd() passes a in x0, v in x2:x3 -- leaving x1= as a +# hole -- and b in x4. pahole has to account for that hole, otherwise e= very +# parameter after v looks like it is in an unexpected register and the w= hole +# function is dropped from BTF. +cat > ${align16}.c << EOF +typedef unsigned long long u64; +struct box { __int128 v; }; + +__attribute__((noinline)) u64 f_even(u64 a, u64 b, __int128 v) +{ return a + b + (u64)v; } + +__attribute__((noinline)) u64 f_odd(u64 a, __int128 v, u64 b) +{ return a + b + (u64)v; } + +__attribute__((noinline)) u64 f_odd_tail(u64 a, __int128 v, u64 b, u64 c= , u64 d) +{ return a + b + c + d + (u64)v; } + +__attribute__((noinline)) u64 f_stack(u64 a, u64 b, u64 c, u64 d, u64 e,= u64 f, + u64 g, __int128 v) +{ return a + b + c + d + e + f + g + (u64)v; } + +__attribute__((noinline)) u64 f_box(u64 a, struct box s, u64 b) +{ return a + b + (u64)s.v; } + +u64 (*keep[])() =3D { (u64(*)())f_even, (u64(*)())f_odd, (u64(*)())f_odd= _tail, + (u64(*)())f_stack, (u64(*)())f_box }; +EOF + +${CC} -g -O2 -c -o ${align16}.o ${align16}.c 2>/dev/null +if [[ $? -ne 0 ]]; then + info_log "skip: clang could not compile ${align16}.c" + test_skip +fi + +LLVM_OBJCOPY=3Dobjcopy pahole -J --btf_features=3Dconsistent_func ${alig= n16}.o +if [[ $? -ne 0 ]]; then + error_log "Could not encode BTF for ${align16}.o" + test_fail +fi + +for fn in f_even f_odd f_odd_tail f_stack f_box; do + encoded=3D$(pfunct --all --format_path=3Dbtf ${align16}.o | grep " ${fn= }(") + verbose_log "BTF: $encoded" + if [[ -z "$encoded" ]]; then + error_log "${fn}() is missing from BTF" + test_fail + fi +done + +test_pass diff --git a/tests/test_lib.sh b/tests/test_lib.sh index e2a7218..e2d0b0c 100755 --- a/tests/test_lib.sh +++ b/tests/test_lib.sh @@ -661,8 +661,7 @@ check_bpftool_btf_support() cleanup() { if [ -n "$outdir" ] && [ -d "$outdir" ]; then - rm ${outdir}/* - rmdir $outdir + rm -rf "$outdir" fi return 0 } --=20 2.53.0-Meta