From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B98842882DE for ; Fri, 22 May 2026 22:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779488206; cv=none; b=hYpUFvzudG7bBEWpD/sXnP6fKIEkoOSFahXkowntuolTFoUo3vZecpsvFL3o8rpKFR/iKuNwII3p7rIIpvEwt+L4uSMhZ9uwkd5ALFCDhifgWkp9W8P/EMEyL4e+m9gy8gH3uDYsRLBdhFUxb95Sb4638Sy4MsdbZ2FyK48/44s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779488206; c=relaxed/simple; bh=7phEfV0DfHKjs3d7SFeIGds1Ji9Cj/d8z4HajdOi4D4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FbmBGGR0YT2IULOdKzaaDM9EkGjeaLq6vSD2RUsX9Wa1x7j35o9aozZvoUvQN8h7qenl51ERVNHx2QFHRpOODok4hKFH9Lgwh2CSq01SnuIyJZHtbnX+lBRH6twsxkWiAJVH8nQPdhh1NuJHMrnLQoEDH4ythWulRs5fJCZmlMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=FJZurkhr; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="FJZurkhr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5DJw2e4kYirLgZ8z1STD7GnvmrTeKZ0f90N46FJPCJk=; b=FJZurkhrP3XqBaA2lBjUQw3IR5 nrsCoCAZZbteyNvKjAg5C8NApZNIHXuiUQ6ePbCwP6+idtrEZNKLPhxN5EHVh28d6N5+NbF02bcQI 0M1p1vUFDRZMG+m5bV4g9OyfiXLG/wXga5SD2mKhLACRWx9DJ+WOXVAOITFft45ASomzwa9sBt+u2 C5j9q/ZEMCsVXHnfSP/6lnk+MkJgARS+sJ/UVSKdrYtfDcc+6hGw8mAyocyVuvWP6jCFwuW2eezRx Op8ARCfo6xhLyQc178C5/ayK1OFI52jo5zUYB7k1awC0H/TyVNWh9Id33QebXOajXEbSQ8XUlUEYq LBFTl+sA==; Received: from [179.193.2.40] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1wQYAZ-0054mX-RF; Sat, 23 May 2026 00:16:40 +0200 Message-ID: <539749bd-4c40-43e0-82ff-f262e95a0a55@igalia.com> Date: Fri, 22 May 2026 19:16:33 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 15/14] selftests: futex: Add tests for robust unlock within the critical section. To: Sebastian Andrzej Siewior Cc: LKML , Mathieu Desnoyers , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Thomas Gleixner , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , "Liam R . Howlett" , Uros Bizjak , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= References: <20260402151131.876492985@kernel.org> <20260404093939.7XgeW_54@linutronix.de> Content-Language: en-US From: =?UTF-8?Q?Andr=C3=A9_Almeida?= In-Reply-To: <20260404093939.7XgeW_54@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Em 04/04/2026 06:39, Sebastian Andrzej Siewior escreveu: > From: Sebastian Andrzej Siewior > > I took Thomas’ initial test case from the cover letter and reworked it > so that it uses ptrace() to single‑step through the VDSO unlock > operation. The test expects the lock to remain locked, with > `list_op_pending' pointing somewhere, when entering the VDSO unlock > path. Once execution steps into the critical section, it expects the > kernel to perform the fixup that is, to unlock the lock and clear > `list_op_pending'. > > The test requires VDSO debug symbols, typically provided by > vdso64.so.dbg or vdso32.so.dbg. It attempts to locate the appropriate > file automatically, but the user may override this by setting the > VDSO_DBG environment variable. If neither method succeeds, libelf falls > back to its usual lookup mechanism under /usr/lib/debug/.build-id/ > Tested on x86 and arm64 and it worked, thanks! > Signed-off-by: Sebastian Andrzej Siewior > --- > .../selftests/futex/functional/Makefile | 3 +- > .../futex/functional/robust_list_critical.c | 402 ++++++++++++++++++ > 2 files changed, 404 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/futex/functional/robust_list_critical.c Missing the addition to .gitignore. [...] > +static bool pc_is_within(struct user_regs_struct *regs, uint64_t start, uint64_t end) > +{ > + unsigned long pc; > + > +#if defined(__x86_64__) > + pc = regs->rip; > +#elif defined(__riscv) > + pc = reg->pc; I think this should be regs as well. And this is what I changed to make it work with arm64: --- .../futex/functional/robust_list_critical.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/futex/functional/robust_list_critical.c b/tools/testing/selftests/futex/functional/robust_list_critical.c index b9490d24eb10..89062c921054 100644 --- a/tools/testing/selftests/futex/functional/robust_list_critical.c +++ b/tools/testing/selftests/futex/functional/robust_list_critical.c @@ -67,6 +67,9 @@ static bool pc_is_within(struct user_regs_struct *regs, uint64_t start, uint64_t pc = regs->rip; #elif defined(__riscv) pc = reg->pc; +#elif defined(__aarch64__) + pc = regs->pc; +#else # error Missing ptrace support #endif if (pc >= (long) start && pc < end) @@ -219,6 +222,23 @@ enum trace_state { STATE_LEAVE_VDSO, }; +static int ptrace_get_regs(struct user_regs_struct *regs, pid_t child) +{ +#if defined(__x86_64__) + + return ptrace(PTRACE_GETREGS, child, 0, regs); + +#elif defined(__aarch64__) + + struct iovec io; + io.iov_base = regs; + io.iov_len = sizeof(struct user_regs_struct); + + return ptrace(PTRACE_GETREGSET, child, NT_PRSTATUS, &io); + +#endif +} + static void trace_child(struct __test_metadata *_metadata, pid_t child, bool is_32bit) { int state = STATE_WAIT; @@ -247,8 +267,8 @@ static void trace_child(struct __test_metadata *_metadata, pid_t child, bool is_ return; } - if (ptrace(PTRACE_GETREGS, child, 0, ®s) != 0) - errx(1, "PTRACE_GETREGS"); + if (ptrace_get_regs(®s, child) == -1) + errx(1, "ptrace_get_regs"); if (is_32bit) { in_vdso = pc_is_within(®s, (long)frtu32, frtu32_end); -- 2.54.0