All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zeng Heng <zengheng4@huawei.com>
To: <kristina.martsenko@arm.com>, <shuah@kernel.org>,
	<catalin.marinas@arm.com>, <broonie@kernel.org>,
	<will@kernel.org>
Cc: <zengheng4@huawei.com>, <linux-kselftest@vger.kernel.org>,
	<xiexiuqi@huawei.com>, <linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 5/5] kselftest/arm64: add lse and lse2 features to hwcap test
Date: Tue, 8 Aug 2023 14:13:55 +0800	[thread overview]
Message-ID: <20230808061356.2215158-5-zengheng4@huawei.com> (raw)
In-Reply-To: <20230808061356.2215158-1-zengheng4@huawei.com>

Add the LSE and various features check in the set of hwcap tests.

As stated in the ARM manual, the LSE2 feature allows for atomic access
to unaligned memory. Therefore, for processors that only have the LSE
feature, we register .sigbus_fn to test their ability to perform
unaligned access.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index bc1491075987..d702f05f33e3 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -34,6 +34,12 @@
  */
 typedef void (*sig_fn)(void);
 
+static void atomics_sigill(void)
+{
+	/* STADD W0, [SP] */
+	asm volatile(".inst 0xb82003ff" : : : );
+}
+
 static void crc32_sigill(void)
 {
 	/* CRC32W W0, W0, W1 */
@@ -233,6 +239,14 @@ static void svebf16_sigill(void)
 	asm volatile(".inst 0x658aa000" : : : "z0");
 }
 
+static void uscat_sigbus(void)
+{
+	/* unaligned atomic access */
+	asm volatile("ADD x1, sp, #2" : : : );
+	/* STADD W0, [X1] */
+	asm volatile(".inst 0xb820003f" : : : );
+}
+
 static const struct hwcap_data {
 	const char *name;
 	unsigned long at_hwcap;
@@ -278,6 +292,22 @@ static const struct hwcap_data {
 		.cpuinfo = "ilrcpc",
 		.sigill_fn = ilrcpc_sigill,
 	},
+	{
+		.name = "LSE",
+		.at_hwcap = AT_HWCAP,
+		.hwcap_bit = HWCAP_ATOMICS,
+		.cpuinfo = "atomics",
+		.sigill_fn = atomics_sigill,
+	},
+	{
+		.name = "LSE2",
+		.at_hwcap = AT_HWCAP,
+		.hwcap_bit = HWCAP_USCAT,
+		.cpuinfo = "uscat",
+		.sigill_fn = atomics_sigill,
+		.sigbus_fn = uscat_sigbus,
+		.sigbus_reliable = true,
+	},
 	{
 		.name = "MOPS",
 		.at_hwcap = AT_HWCAP2,
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Zeng Heng <zengheng4@huawei.com>
To: <kristina.martsenko@arm.com>, <shuah@kernel.org>,
	<catalin.marinas@arm.com>, <broonie@kernel.org>,
	<will@kernel.org>
Cc: <zengheng4@huawei.com>, <linux-kselftest@vger.kernel.org>,
	<xiexiuqi@huawei.com>, <linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 5/5] kselftest/arm64: add lse and lse2 features to hwcap test
Date: Tue, 8 Aug 2023 14:13:55 +0800	[thread overview]
Message-ID: <20230808061356.2215158-5-zengheng4@huawei.com> (raw)
In-Reply-To: <20230808061356.2215158-1-zengheng4@huawei.com>

Add the LSE and various features check in the set of hwcap tests.

As stated in the ARM manual, the LSE2 feature allows for atomic access
to unaligned memory. Therefore, for processors that only have the LSE
feature, we register .sigbus_fn to test their ability to perform
unaligned access.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index bc1491075987..d702f05f33e3 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -34,6 +34,12 @@
  */
 typedef void (*sig_fn)(void);
 
+static void atomics_sigill(void)
+{
+	/* STADD W0, [SP] */
+	asm volatile(".inst 0xb82003ff" : : : );
+}
+
 static void crc32_sigill(void)
 {
 	/* CRC32W W0, W0, W1 */
@@ -233,6 +239,14 @@ static void svebf16_sigill(void)
 	asm volatile(".inst 0x658aa000" : : : "z0");
 }
 
+static void uscat_sigbus(void)
+{
+	/* unaligned atomic access */
+	asm volatile("ADD x1, sp, #2" : : : );
+	/* STADD W0, [X1] */
+	asm volatile(".inst 0xb820003f" : : : );
+}
+
 static const struct hwcap_data {
 	const char *name;
 	unsigned long at_hwcap;
@@ -278,6 +292,22 @@ static const struct hwcap_data {
 		.cpuinfo = "ilrcpc",
 		.sigill_fn = ilrcpc_sigill,
 	},
+	{
+		.name = "LSE",
+		.at_hwcap = AT_HWCAP,
+		.hwcap_bit = HWCAP_ATOMICS,
+		.cpuinfo = "atomics",
+		.sigill_fn = atomics_sigill,
+	},
+	{
+		.name = "LSE2",
+		.at_hwcap = AT_HWCAP,
+		.hwcap_bit = HWCAP_USCAT,
+		.cpuinfo = "uscat",
+		.sigill_fn = atomics_sigill,
+		.sigbus_fn = uscat_sigbus,
+		.sigbus_reliable = true,
+	},
 	{
 		.name = "MOPS",
 		.at_hwcap = AT_HWCAP2,
-- 
2.25.1


  parent reply	other threads:[~2023-08-08  6:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08  6:13 [PATCH 1/5] kselftest/arm64: add float-point feature to hwcap test Zeng Heng
2023-08-08  6:13 ` Zeng Heng
2023-08-08  6:13 ` [PATCH 2/5] kselftest/arm64: add crc32 " Zeng Heng
2023-08-08  6:13   ` Zeng Heng
2023-08-08 12:28   ` Mark Brown
2023-08-08 12:28     ` Mark Brown
2023-08-08  6:13 ` [PATCH 3/5] kselftest/arm64: add DEF_SIGHANDLER_FUNC() and DEF_INST_RAISE_SIG() helpers Zeng Heng
2023-08-08  6:13   ` Zeng Heng
2023-08-08  6:13 ` [PATCH 4/5] kselftest/arm64: add test item that support to capturing the SIGBUS signal Zeng Heng
2023-08-08  6:13   ` Zeng Heng
2023-08-08  6:13 ` Zeng Heng [this message]
2023-08-08  6:13   ` [PATCH 5/5] kselftest/arm64: add lse and lse2 features to hwcap test Zeng Heng
2023-08-08  6:13 ` [PATCH 0/5] kselftest/arm64: add features check " Zeng Heng
2023-08-08  6:13   ` Zeng Heng
2023-08-08 12:57   ` Mark Brown
2023-08-08 12:57     ` Mark Brown
2023-08-08 12:25 ` [PATCH 1/5] kselftest/arm64: add float-point feature " Mark Brown
2023-08-08 12:25   ` Mark Brown
2023-08-08 12:48   ` Zeng Heng
2023-08-08 12:48     ` Zeng Heng

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=20230808061356.2215158-5-zengheng4@huawei.com \
    --to=zengheng4@huawei.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=will@kernel.org \
    --cc=xiexiuqi@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 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.