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 80A33606A322 for ; Thu, 3 Dec 2026 09:57:55 +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=b/s9/iE4; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E77N/lBw 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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=XE1YC+eY7Jz0jA3eGCk2CpNcrDIfnFDBSTzOisOVH3Q=; b=b/s9/iE4u2OBdM /QmWjAZofn/XFa8RpmPy+Lm4jzvcEp0NTZbW21FAHcB/TZXUZEhhdU+ksex/5q24XQv0rAozK6Pwd /Yd6vbRWOrxoENGQ+e+yl89h6XsmyoBdQX2eQj9JkAiWUw0XFO+1JvaoxYv1cfOVfAC6/53nTccJh VIRGeV+Rh9fl7+qFtOHa4YhP6uaEPSmUL3BXe2zRQowVGDACrieGpcDsBAL187Ppua1FMn2r5SLBs lBqpTdbpL+OYMKtv9mldZ/d6rV36kvukFZcA+4fE5Q5GpV4CjzoFX2i8PkK5wmMVUM301YNvWU07+ 2sBiOU5k8UE+G1dzXCfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ3ZS-0000000E5Jc-1bJ9; Thu, 03 Dec 2026 09:57:47 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ3ZM-0000000E5H3-0M7V for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 09:57:44 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id D40E143DFD; Thu, 3 Dec 2026 09:57:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FEF71F00898; Thu, 3 Dec 2026 09:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796291859; bh=XE1YC+eY7Jz0jA3eGCk2CpNcrDIfnFDBSTzOisOVH3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E77N/lBwURxerTIqZr2XhJgceyDVYTR/i1gyvWFg+m7hnpRO29vjTmjAGK3XvHGV/ r5ZMNcvqy9IaQhnAE5pf87WGZT06L56c5ksfGm5d3tTHxxKC4KnJNJvO5Z2i8mVUAV 8IraEJHlKmN02DDCOvnizC9Kjm+f0VCvHJlmFH2vea+OKQ7VMYFkxO9CMTOKzNLJCp aemf7ueQSsz0BvpB0YZfankFes/D40bAWXlHe57dAG5kHgD4eU1ZlLw/+ePqO5zs5E gThL/+9qoc/nMVmR2O1hSCT3EjQHL4Zuror4Ip/fMGmKP42ZD+cD7FMYwW1XvlbQhD eNfEExEtR8W9g== From: Arnd Bergmann To: Catalin Marinas , Mark Rutland , Will Deacon Cc: Arnd Bergmann , apais@microsoft.com, Christian Borntraeger , Fuad Tabba , hargar@linux.microsoft.com, Joey Gouly , Marc Zyngier , Navneet Singh , Oliver Upton , rlmenge@gmail.com, Siddharth Chintamaneni , Steffen Eiden , Suzuki K Poulose , Sven Schnelle , Yicong Yang , Zenghui Yu , Zhou Wang , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/4] kselftest/arm64: Add HWCAP test for FEAT_LS64_ACCDATA Date: Thu, 3 Dec 2026 10:57:03 +0100 Message-ID: <20261203095703.655796-5-arnd@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203095703.655796-1-arnd@kernel.org> References: <20261203095703.655796-1-arnd@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=-18.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,USER_AGENT_GIT 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 From: Arnd Bergmann Add tests for FEAT_LS64_ACCDATA, similar to FEAT_LS64 test added in 57a96356bb69 ("kselftest/arm64: Add HWCAP test for FEAT_LS64"). st64bv0 only works on very specific devices and returns a bus error on anything else, but an illegal instruction on machines without the feature. Based on an earlier patch by Yicong Yang. Cc: Yicong Yang Link: https://lore.kernel.org/all/20241202135504.14252-4-yangyicong@huawei.com/ Signed-off-by: Arnd Bergmann --- tools/testing/selftests/arm64/abi/hwcap.c | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c index 19fca95f7c22..4c89a897837d 100644 --- a/tools/testing/selftests/arm64/abi/hwcap.c +++ b/tools/testing/selftests/arm64/abi/hwcap.c @@ -693,6 +693,48 @@ static void ls64_sigill(void) /* ST64B x0, [x8] */ asm volatile(".inst 0xf83f9100" : : "r" (xt_1), "r" (xn) : "x1", "x2", "x3", "x4", "x5", "x6", "x7"); + sigaction(SIGBUS, &old, NULL); +} + +static void ls64_accdata_sigill(void) +{ + struct sigaction ign, old; + char dst[64] __aligned(64); + + /* + * Like LS64, LS64_ACCDATA requires both the feature to be + * available in hardware, and the address to be on a device + * capable of the transaction. + * In addition, the device driver that has mapped the device + * must have created a PASID that can be used as ACCDATA. + * + * For testing the ABI, check only that st64bv0 on a user + * address gives the expected SIGBUS error when the instruction + * is not enabled for this thread. If it was enabled, the + * error status would be reported in 'st' instead of a signal, + * but that can only be tested if a PASID is set for this thread. + */ + ign.sa_sigaction = ignore_signal; + ign.sa_flags = SA_SIGINFO | SA_RESTART; + sigemptyset(&ign.sa_mask); + sigaction(SIGBUS, &ign, &old); + + register void *xn asm ("x8") = dst; + register u64 xt_1 asm ("x0") = 1; + register u64 xt_2 asm ("x1") = 2; + register u64 xt_3 asm ("x2") = 3; + register u64 xt_4 asm ("x3") = 4; + register u64 xt_5 asm ("x4") = 5; + register u64 xt_6 asm ("x5") = 6; + register u64 xt_7 asm ("x6") = 7; + register u64 xt_8 asm ("x7") = 8; + register u64 st asm ("x9"); + + /* ST64BV0 x9, x0, [x8] */ + asm volatile(".inst 0xf829a100" : "=r" (st) : + "r" (xt_1), "r" (xt_2), "r" (xt_3), "r" (xt_4), + "r" (xt_5), "r" (xt_6), "r" (xt_7), "r" (xt_8), + "r" (xn)); sigaction(SIGBUS, &old, NULL); } @@ -1300,6 +1342,14 @@ static const struct hwcap_data { .sigill_fn = ls64_sigill, .sigill_reliable = true, }, + { + .name = "LS64_ACCDATA", + .at_hwcap = AT_HWCAP3, + .hwcap_bit = HWCAP3_LS64_ACCDATA, + .cpuinfo = "ls64accdata", + .sigill_fn = ls64_accdata_sigill, + .sigill_reliable = true, + }, }; typedef void (*sighandler_fn)(int, siginfo_t *, void *); -- 2.53.0