From: "André Almeida" <andrealmeid@igalia.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-arm-kernel@lists.infradead.org,
"Rich Felker" <dalias@aerifal.cx>,
"Florian Weimer" <fweimer@redhat.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Carlos O'Donell" <carlos@redhat.com>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Will Deacon" <will@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Uros Bizjak" <ubizjak@gmail.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Darren Hart" <dvhart@infradead.org>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
"Torvald Riegel" <triegel@redhat.com>,
"Ingo Molnar" <mingo@kernel.org>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
kernel-dev@igalia.com, "Mark Rutland" <mark.rutland@arm.com>
Subject: Re: [PATCH v3 2/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock()
Date: Mon, 1 Jun 2026 13:22:28 -0300 [thread overview]
Message-ID: <798c75ba-615d-48d1-bc04-53bc40bc6503@igalia.com> (raw)
In-Reply-To: <844b56fe-b5d4-42b2-ae8e-ce07980d0f50@efficios.com>
Em 29/05/2026 14:47, Mathieu Desnoyers escreveu:
> On 2026-05-29 12:33, André Almeida wrote:
>> Based on the x86 implementation, implement the vDSO function for
>> unlocking
>> a robust futex correctly.
>>
>> Commit xxxxxxxxxxxx ("x86/vdso: Implement
>> __vdso_futex_robust_try_unlock()") has
>> the full explanation about why this mechanism is needed.
>>
>> The unlock assembly sequence for arm64 is:
>>
>> __vdso_futex_robust_list64_try_unlock:
>> retry:
>> ldxr w8, [x0] // Load the value from *futex
>> cmp w1, w8 // Compare with TID
>> b.ne __vdso_futex_list64_try_unlock_cs_end
>> stlxr w9, wzr, [x0] // Try to zero *futex
>
> So it looks like stlxr can be successful, and the process is killed
> right here. This is not within the start/end critical section, so the
> fixup is missed ? Or am I missing something ?
>
As me and Mathieu discussed on IRC, this should be the right thing to do
here:
- Move the critical section label one instruction above to include
`cbnz` on it
- Use the result register as the check for the store success, not the
zero flag register.
So it will look like this:
__vdso_futex_robust_list64_try_unlock:
retry:
ldxr w8, [x0] // Load the value from *futex
cmp w1, w8 // Compare with TID
b.ne __vdso_futex_list64_try_unlock_cs_end
stlxr w9, wzr, [x0] // Try to zero *futex
__vdso_futex_list64_try_unlock_cs_start:
cbnz w9, retry
str xzr, [x2] // After zeroing *futex, zero *op_pending
__vdso_futex_list64_try_unlock_cs_end>:
The decision regarding if the pointer should be cleared or not lies on
checking the result register:
return (regs->user_regs[9]) ? NULL :
(void __user *) regs->user_regs.regs[2];
Thanks for the review!
next prev parent reply other threads:[~2026-06-01 16:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 16:33 [PATCH v3 0/5] " André Almeida
2026-05-29 16:33 ` [PATCH v3 1/5] arm64: vdso: Prepare for robust futex unlock support André Almeida
2026-05-29 17:16 ` Thomas Weißschuh
2026-06-01 16:17 ` André Almeida
2026-05-29 16:33 ` [PATCH v3 2/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-05-29 17:18 ` Thomas Weißschuh
2026-05-29 17:47 ` Mathieu Desnoyers
2026-06-01 16:22 ` André Almeida [this message]
2026-05-29 16:33 ` [PATCH v3 3/5] selftests: futex: Add support for aarch64 in robust_list_critical André Almeida
2026-05-29 16:33 ` [PATCH v3 4/5] arm64: vdso32: Bring vdso32-offsets.h back André Almeida
2026-05-29 16:33 ` [PATCH v3 5/5] arm64: vdso32: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-05-29 19:15 ` Mathieu Desnoyers
2026-06-02 8:30 ` Thomas Weißschuh
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=798c75ba-615d-48d1-bc04-53bc40bc6503@igalia.com \
--to=andrealmeid@igalia.com \
--cc=Liam.Howlett@oracle.com \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=carlos@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=dalias@aerifal.cx \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=fweimer@redhat.com \
--cc=kernel-dev@igalia.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=triegel@redhat.com \
--cc=ubizjak@gmail.com \
--cc=will@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
all inboxes | Powered by JetHome®