From: Eduard Zingerman <eddyz87@gmail.com>
To: Vineet Gupta <vineet.gupta@linux.dev>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
x86@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Check per-CPU address resolution per register
Date: Fri, 14 Aug 2026 13:49:23 -0700 [thread overview]
Message-ID: <d87ed8b8140ef404436d7ddf7a4143cb07ef98cd.camel@gmail.com> (raw)
In-Reply-To: <20260814203248.3714536-3-vineet.gupta@linux.dev>
On Fri, 2026-08-14 at 13:32 -0700, Vineet Gupta wrote:
...
> +/*
> + * An ld_imm64 of a per-CPU map value is followed by a mov_percpu_addr that
> + * reuses the same register, so the register the address lands in decides how
> + * the JIT encodes the add. On x86 R5, R7, R8 and R9 are the extended
> + * registers, whose high bit needs REX.R because the destination sits in
> + * ModRM.reg. Check one program per extended register, since getting the
> + * prefix wrong resolves the address into whichever register shares the low
> + * three bits instead.
> + */
> +
> +SEC("raw_tp")
> +__description("per-CPU address into r5")
> +__success
> +__arch_x86_64
> +__jited(" addq %gs:{{.*}}, %r8")
> +__naked void percpu_addr_into_r5(void)
> +{
> + asm volatile (" \
> + r5 = %[percpu_data] ll; \
> + r0 = *(u32 *)(r5 + 0); \
> + exit; \
> +" :
> + : __imm_addr(percpu_data)
> + : __clobber_all);
> +}
Thank you for adding the tests.
Maybe save some space by just packing it as a single test?
__jited(" addq %gs:{{.*}}, %...")
__jited(" addq %gs:{{.*}}, %...")
__jited(" addq %gs:{{.*}}, %...")
__jited(" addq %gs:{{.*}}, %...")
__jited(" addq %gs:{{.*}}, %...")
r0 = %[percpu_data] ll; \
r1 = %[percpu_data] ll; \
r2 = %[percpu_data] ll; \
r3 = %[percpu_data] ll; \
r4 = %[percpu_data] ll; \
r5 = %[percpu_data] ll; \
r6 = %[percpu_data] ll; \
r7 = %[percpu_data] ll; \
r8 = %[percpu_data] ll; \
r9 = %[percpu_data] ll; \
More compact and no need to describe in length why only R{5,7,8,9} are selected.
...
next prev parent reply other threads:[~2026-08-14 20:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 20:32 [PATCH bpf v2 0/2] bpf, x86: fix per-CPU address resolution into an extended register Vineet Gupta
2026-08-14 20:32 ` [PATCH bpf v2 1/2] bpf, x86: Fix " Vineet Gupta
2026-08-14 20:44 ` Eduard Zingerman
2026-08-14 21:20 ` bot+bpf-ci
2026-08-14 21:30 ` Vineet Gupta
2026-08-14 20:32 ` [PATCH bpf v2 2/2] selftests/bpf: Check per-CPU address resolution per register Vineet Gupta
2026-08-14 20:49 ` Eduard Zingerman [this message]
2026-08-14 21:20 ` bot+bpf-ci
2026-08-14 21:51 ` Vineet Gupta
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=d87ed8b8140ef404436d7ddf7a4143cb07ef98cd.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=stable@vger.kernel.org \
--cc=vineet.gupta@linux.dev \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox