Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andi Kleen" <ak@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v2 11/11] ptwrite uprobes: Add kernel self tests
Date: Thu, 17 Sep 2026 23:28:46 +0000	[thread overview]
Message-ID: <20260917232846.C27481F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917230127.924985-12-ak@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] kselftests/uprobes: test unconditionally skips due to undefined FLT_V variable
- [Medium] kselftests/uprobes: unaligned_nopfn site does not cross 8-byte boundary, invalidating test
- [Low] kselftests/uprobes: 64-bit inline assembly causes build failure on 32-bit x86
--

commit af4e3ff18548d1ab18ec7d6c2b846c7b5c15b34e
Author: Andi Kleen <ak@kernel.org>
Subject: ptwrite uprobes: Add kernel self tests

This commit adds selftests for PTWRITE uprobes to exercise instruction
punning, multinop patching, and probe lifecycle on x86 architectures.

> diff --git a/tools/testing/selftests/uprobes/Makefile b/tools/testing/selftests/uprobes/Makefile
> new file mode 100644
> index 0000000000000..ee97442f8c9dc
> --- /dev/null
> +++ b/tools/testing/selftests/uprobes/Makefile
> @@ -0,0 +1,14 @@
[ ... ]
> +TEST_PROGS := run_ptw.sh
> +
> +ifneq ($(filter x86 x86_64,$(ARCH)),)
> +TEST_GEN_FILES := ptw_probe
> +else

[Severity: Low]
Will this fail to build on 32-bit x86 architectures? The Makefile enables test
compilation for the x86 architecture filter, which includes 32-bit builds.
However, ptw_probe.c uses strict 64-bit inline assembly like movabs, %rax,
and %rsp. When compiled with a 32-bit toolchain, won't the assembler reject
these instructions?

> diff --git a/tools/testing/selftests/uprobes/ptw_probe.c b/tools/testing/selftests/uprobes/ptw_probe.c
> new file mode 100644
> index 0000000000000..b232fbd4d2aa0
> --- /dev/null
> +++ b/tools/testing/selftests/uprobes/ptw_probe.c
> @@ -0,0 +1,156 @@
[ ... ]
> +static __attribute__((noipa)) uint64_t
> +unaligned_nopfn(uint64_t a)
> +{
> +	asm volatile(".p2align 3, 0x90\n\t"
> +		     "nop\n\t"
> +		     ".globl nopfn_unaligned_site\n\t"
> +		     "nopfn_unaligned_site:\n\t"
> +		     "nop\n\tnop\n\tnop\n\tnop\n\tnop" ::: "memory");
> +	return a * 13 + 5;
> +}

[Severity: Medium]
Does this actually create an unaligned sequence that crosses an 8-byte
boundary?

The assembly code aligns to 8 bytes with .p2align 3 and adds a 1-byte nop,
placing the start of the 5-byte target sequence at offset 1. Since offsets 1
through 5 fit perfectly within a single 8-byte word, the kernel's atomic
patch path can handle it safely.

Won't the kernel accept this probe instead of rejecting it, causing test 11 in
run_ptw.sh to incorrectly report a failure when it expects the kernel to
reject the probe?

> diff --git a/tools/testing/selftests/uprobes/run_ptw.sh b/tools/testing/selftests/uprobes/run_ptw.sh
> new file mode 100755
> index 0000000000000..a16b7adeabb74
> --- /dev/null
> +++ b/tools/testing/selftests/uprobes/run_ptw.sh
> @@ -0,0 +1,219 @@
[ ... ]
> +PUN_V=$(objdump -d "$BIN" | awk '/^[0-9a-f]+ <punfn>:/{print $1;exit}' | tr -d ':')
> +JCC_V=$(objdump -d "$BIN" |
> +	awk '/^[0-9a-f]+ <jcc8>:/ {f=1; next} f&&/jne/{print $1; exit}' |
> +	tr -d ':')
> +NOP_V=$(objdump -d "$BIN" | awk '/^[0-9a-f]+ <nopfn_site>:/{print $1;exit}' | tr -d ':')
> +NOP5_V=$(objdump -d "$BIN" | awk '/^[0-9a-f]+ <nop5>:/{print $1;exit}' | tr -d ':')
> +UNOP_V=$(objdump -d "$BIN" |
> +	awk '/^[0-9a-f]+ <nopfn_unaligned_site>:/{print $1;exit}' | tr -d ':')
> +RZ_V=$(objdump -d "$BIN" | awk '/^[0-9a-f]+ <rz_probe_site>:/{print $1;exit}' | tr -d ':')
> +if [ -z "$PUN_V" ] || [ -z "$JCC_V" ] || [ -z "$FLT_V" ] ||
> +   [ -z "$NOP_V" ] || [ -z "$NOP5_V" ] || [ -z "$UNOP_V" ] ||
> +   [ -z "$RZ_V" ]; then
> +	echo "1..0 # SKIP unable to resolve ptw_probe symbols"
> +	exit 0
> +fi

[Severity: Medium]
Is the FLT_V variable supposed to be defined or populated before this check?

The script tests for the existence of an undefined variable FLT_V, which
causes this condition to always evaluate to true. Doesn't this mean the entire
ptwrite uprobe selftest unconditionally skips execution and reports
'unable to resolve ptw_probe symbols' on every run, resulting in no test
coverage?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917230127.924985-2-ak@kernel.org?part=11

      reply	other threads:[~2026-09-17 23:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 23:00 ptwrite uprobes v2 Andi Kleen
2026-09-17 23:00 ` [RFC PATCH v2 01/11] ptwrite uprobes: Add infrastructure for ptwrite uprobes Andi Kleen
2026-09-17 23:19   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 02/11] ptwrite uprobes: Add minimal low level support for x86 Andi Kleen
2026-09-17 23:25   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 03/11] ptwrite uprobes: Add a sample module to exercise interface Andi Kleen
2026-09-17 23:20   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 04/11] ptwrite uprobes: Add support to tracing infrastructure Andi Kleen
2026-09-17 23:23   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 05/11] ptwrite uprobes: Factor file-backed instruction reads Andi Kleen
2026-09-17 23:14   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 06/11] ptwrite uprobes: Add basic memory references Andi Kleen
2026-09-17 23:17   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 07/11] ptwrite uprobes: Add multinop support Andi Kleen
2026-09-17 23:22   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 08/11] ptwrite uprobes: Support instruction punning Andi Kleen
2026-09-17 23:27   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 09/11] ptwrite uprobes: Use atomic patching for multinop sites Andi Kleen
2026-09-17 23:32   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 10/11] ptwrite uprobes: Add a tutorial and overview documentation Andi Kleen
2026-09-17 23:21   ` sashiko-bot
2026-09-17 23:00 ` [RFC PATCH v2 11/11] ptwrite uprobes: Add kernel self tests Andi Kleen
2026-09-17 23:28   ` sashiko-bot [this message]

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=20260917232846.C27481F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ak@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox