From: Arnd Bergmann <arnd@kernel.org>
To: linux-arm-kernel@lists.infradead.org
Cc: Arnd Bergmann <arnd@arndb.de>, Yicong Yang <yangyicong@hisilicon.com>
Subject: [PATCH v2 3/3] kselftest/arm64: Add HWCAP test for FEAT_LS64_ACCDATA
Date: Thu, 26 Nov 2026 16:53:39 +0100 [thread overview]
Message-ID: <20261126155339.1349218-4-arnd@kernel.org> (raw)
In-Reply-To: <20261126155339.1349218-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..8981a1eed2ca 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 = "ls64_accdata",
+ .sigill_fn = ls64_accdata_sigill,
+ .sigill_reliable = true,
+ },
};
typedef void (*sighandler_fn)(int, siginfo_t *, void *);
--
2.53.0
prev parent reply other threads:[~2026-11-26 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:53 [PATCH v2 0/3] st64bv0 support in iommu-sva Arnd Bergmann
2026-11-26 15:53 ` [PATCH v2 1/3] arm64: dynamically enable st64bv0 for SVA Arnd Bergmann
2026-11-30 17:24 ` Catalin Marinas
2026-11-26 15:53 ` [PATCH v2 2/3] arm64: add HWCAP3_LS64_ACCDATA Arnd Bergmann
2026-11-30 18:02 ` Catalin Marinas
2026-11-26 15:53 ` 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=20261126155339.1349218-4-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=yangyicong@hisilicon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.