The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	apais@microsoft.com,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Fuad Tabba <fuad.tabba@linux.dev>,
	hargar@linux.microsoft.com, Joey Gouly <joey.gouly@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Navneet Singh <navneetsingh@microsoft.com>,
	Oliver Upton <oupton@kernel.org>,
	rlmenge@gmail.com,
	Siddharth Chintamaneni <sidchintamaneni@gmail.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Sven Schnelle <sven@linux.ibm.com>,
	Yicong Yang <yangyicong@hisilicon.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	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	[thread overview]
Message-ID: <20261203095703.655796-5-arnd@kernel.org> (raw)
In-Reply-To: <20261203095703.655796-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

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 <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/all/20241202135504.14252-4-yangyicong@huawei.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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


      parent reply	other threads:[~2026-12-03  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:56 [PATCH v3 0/4] st64bv0 support in iommu-sva Arnd Bergmann
2026-12-03  9:57 ` [PATCH v3 1/4] arm64: kvm: save and restore ACCDATA_EL1 if used by host Arnd Bergmann
2026-12-03  9:57 ` [PATCH v3 2/4] arm64: dynamically enable st64bv0 for SVA Arnd Bergmann
2026-12-03  9:57 ` [PATCH v3 3/4] arm64: add HWCAP3_LS64_ACCDATA Arnd Bergmann
2026-12-03  9:57 ` Arnd Bergmann [this message]

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=20261203095703.655796-5-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=apais@microsoft.com \
    --cc=arnd@arndb.de \
    --cc=borntraeger@linux.ibm.com \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=hargar@linux.microsoft.com \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=navneetsingh@microsoft.com \
    --cc=oupton@kernel.org \
    --cc=rlmenge@gmail.com \
    --cc=seiden@linux.ibm.com \
    --cc=sidchintamaneni@gmail.com \
    --cc=suzuki.poulose@arm.com \
    --cc=sven@linux.ibm.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.com \
    --cc=yuzenghui@huawei.com \
    /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