From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B694606A32C for ; Thu, 19 Nov 2026 10:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=4UXXa/+6; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=Ukd6Bz4k DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=GgDxgmdIK5ZFV6i2LVaxKcVaEgHgnRDEHjSLl+YAUZg=; b=4UXXa/+62sTAaaLw4KAucwCPQb +74XulHfVqlbdNKZ4GPiBs0nOwx2RElR9hgWmI7F4KiqfTEqzv5VS0jeJA8O4l9xOLl+0YZqGVkZc 5yR3u9cMTbdIf6TybkEvhuYz39PKhDM8+4yMRY84uMjuU26GTSFj03qfwE05/oPtpIFWvhKC8CQZl NvkwFfUXvmaADteE0rgSe/JZ91pG1aEUyqbdpc4wwQJFl5J5+F/bYCHVa1Qsvk8gghXpvJaHzYa6r WEJIEhOhWHWWJU6D63BUaguB6JGH09ppNCUfS+nHRAFUI/QBBKJUaXiJQKA0kZyFRN5ExOanLT8p+ dp32az7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTzUl-0000000BZjx-2nhV; Thu, 19 Nov 2026 10:35:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTzUi-0000000BZik-3Yik for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2026 10:35:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C2221575; Thu, 19 Nov 2026 02:35:52 -0800 (PST) Received: from e129823.arm.com (e129823.arm.com [10.2.213.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9E0AD3F632; Thu, 19 Nov 2026 02:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795084555; bh=OQ40n8vCPLl2z6BAfUVaBr1U7k9Hcye30/imffmeJkU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ukd6Bz4kAAGvhzWNxydXfeleNFT7s4hkrLTBz8YA0eSfizAgpG284yfj/uWv8Qmg/ GU7Mc3I3LUmAbziW00YfUH2GQnnv/0d7Yj9KSsSxJX/sdAF/1I4qnwOfRpFJksRSS7 /tH7gbrgw7jm7xXpEwdKoFzcCptXzAiwFIlesn2g= Date: Thu, 19 Nov 2026 10:35:51 +0000 From: Yeoreum Yun To: Kevin Brodsky Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Joey Gouly , Linu Cherian , Mark Brown , Shuah Khan , Will Deacon , Yeoreum Yun , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v2 2/2] kselftest/arm64: Add test for atomic futex uaccess with POE Message-ID: References: <20261119-poe_futex-v2-0-244c7a01f788@arm.com> <20261119-poe_futex-v2-2-244c7a01f788@arm.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261119-poe_futex-v2-2-244c7a01f788@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261119_023556_957665_35BC99B1 X-CRM114-Status: GOOD ( 27.64 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Look good to me. Reviewed-by: Yeoreum Yun On Thu, Nov 19, 2026 at 09:54:38AM +0000, Kevin Brodsky wrote: > Add a new test to ensure that atomic futex uaccess succeeds on > memory mapped with a non-default POIndex/pkey. > > In the absence of FEAT_LSUI, atomic futex uaccess operations such as > those triggered by FUTEX_WAKE_OP use privileged atomic load/store > instructions and thus cannot have user permission overlays (POR_EL0) > applied. In case the kernel enabled POE at EL1, it is worth > checking that kernel overlays (POR_EL1) are not applied to these > accesses, as that would fail for non-zero pkeys. > > Note that if such misconfiguration occurs, futex_wake_op() may get > stuck in an infinite loop because futex_atomic_op_inuser() will fail > but fault_in_user_writeable() will still report success. > > Signed-off-by: Kevin Brodsky > --- > tools/testing/selftests/arm64/Makefile | 2 +- > tools/testing/selftests/arm64/poe/.gitignore | 2 + > tools/testing/selftests/arm64/poe/Makefile | 6 +++ > tools/testing/selftests/arm64/poe/poe_futex.c | 62 +++++++++++++++++++++++++++ > 4 files changed, 71 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/arm64/Makefile b/tools/testing/selftests/arm64/Makefile > index e456f3b62fa1..bad5c3b33dce 100644 > --- a/tools/testing/selftests/arm64/Makefile > +++ b/tools/testing/selftests/arm64/Makefile > @@ -4,7 +4,7 @@ > ARCH ?= $(shell uname -m 2>/dev/null || echo not) > > ifneq (,$(filter $(ARCH),aarch64 arm64)) > -ARM64_SUBTARGETS ?= tags signal pauth fp mte bti abi gcs > +ARM64_SUBTARGETS ?= tags signal pauth fp mte bti abi gcs poe > else > ARM64_SUBTARGETS := > endif > diff --git a/tools/testing/selftests/arm64/poe/.gitignore b/tools/testing/selftests/arm64/poe/.gitignore > new file mode 100644 > index 000000000000..0dce4a3aa38b > --- /dev/null > +++ b/tools/testing/selftests/arm64/poe/.gitignore > @@ -0,0 +1,2 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +poe_futex > diff --git a/tools/testing/selftests/arm64/poe/Makefile b/tools/testing/selftests/arm64/poe/Makefile > new file mode 100644 > index 000000000000..2af2bbf3f6d3 > --- /dev/null > +++ b/tools/testing/selftests/arm64/poe/Makefile > @@ -0,0 +1,6 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +CFLAGS += $(KHDR_INCLUDES) > +TEST_GEN_PROGS := poe_futex > + > +include ../../lib.mk > diff --git a/tools/testing/selftests/arm64/poe/poe_futex.c b/tools/testing/selftests/arm64/poe/poe_futex.c > new file mode 100644 > index 000000000000..21a2e109ee43 > --- /dev/null > +++ b/tools/testing/selftests/arm64/poe/poe_futex.c > @@ -0,0 +1,62 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include > +#include > +#include > + > +#include > +#include > + > +#include "kselftest_harness.h" > + > +static int sys_pkey_alloc(unsigned long flags, unsigned long init_val) > +{ > + return syscall(__NR_pkey_alloc, flags, init_val); > +} > + > +static int sys_pkey_mprotect(void *ptr, size_t size, int prot, int pkey) > +{ > + return syscall(__NR_pkey_mprotect, ptr, size, prot, pkey); > +} > + > +static int futex_wake_op(uint32_t *uaddr, uint32_t val, uint32_t val2, > + uint32_t *uaddr2, uint32_t val3) > +{ > + return syscall(SYS_futex, uaddr, FUTEX_WAKE_OP, val, val2, > + uaddr2, val3); > +} > + > +/* > + * Trigger some atomic uaccess on a page mapped with a non-default pkey. > + * > + * This ensures that such access is not mistakenly checked against the > + * kernel's POR_EL1 register. > + */ > +TEST(poe_futex) > +{ > + int ret, pkey; > + void *ptr; > + size_t size = getpagesize(); > + > + pkey = sys_pkey_alloc(0, 0); > + > + if (pkey == -1 && errno == ENOSPC) > + SKIP(return, "pkeys are not supported"); > + > + ASSERT_GT(pkey, 0); > + > + ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, > + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); > + ASSERT_NE(ptr, MAP_FAILED); > + > + ret = sys_pkey_mprotect(ptr, size, PROT_READ | PROT_WRITE, pkey); > + ASSERT_EQ(ret, 0); > + > + /* > + * There is no one to wake up so this syscall boils down to *(ptr+4) = 0 > + * (arch_futex_atomic_op_inuser() called with FUTEX_OP_SET and op_arg=0). > + */ > + ret = futex_wake_op(ptr, 1, 1, ptr + sizeof(uint32_t), 0); > + ASSERT_EQ(ret, 0); > +} > + > +TEST_HARNESS_MAIN > > -- > 2.56.0 > -- Sincerely, Yeoreum Yun