Skip to content

Commit 82e7882

Browse files
henryZewilldeacon
authored andcommitted
kselftest/arm64: add lse and lse2 features to hwcap test
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 <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent fd49cf0 commit 82e7882

File tree

1 file changed

+30
-0
lines changed
  • tools/testing/selftests/arm64/abi

1 file changed

+30
-0
lines changed

tools/testing/selftests/arm64/abi/hwcap.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
*/
3535
typedef void (*sig_fn)(void);
3636

37+
static void atomics_sigill(void)
38+
{
39+
/* STADD W0, [SP] */
40+
asm volatile(".inst 0xb82003ff" : : : );
41+
}
42+
3743
static void crc32_sigill(void)
3844
{
3945
asm volatile("crc32w w0, w0, w1");
@@ -231,6 +237,14 @@ static void svebf16_sigill(void)
231237
asm volatile(".inst 0x658aa000" : : : "z0");
232238
}
233239

240+
static void uscat_sigbus(void)
241+
{
242+
/* unaligned atomic access */
243+
asm volatile("ADD x1, sp, #2" : : : );
244+
/* STADD W0, [X1] */
245+
asm volatile(".inst 0xb820003f" : : : );
246+
}
247+
234248
static const struct hwcap_data {
235249
const char *name;
236250
unsigned long at_hwcap;
@@ -276,6 +290,22 @@ static const struct hwcap_data {
276290
.cpuinfo = "ilrcpc",
277291
.sigill_fn = ilrcpc_sigill,
278292
},
293+
{
294+
.name = "LSE",
295+
.at_hwcap = AT_HWCAP,
296+
.hwcap_bit = HWCAP_ATOMICS,
297+
.cpuinfo = "atomics",
298+
.sigill_fn = atomics_sigill,
299+
},
300+
{
301+
.name = "LSE2",
302+
.at_hwcap = AT_HWCAP,
303+
.hwcap_bit = HWCAP_USCAT,
304+
.cpuinfo = "uscat",
305+
.sigill_fn = atomics_sigill,
306+
.sigbus_fn = uscat_sigbus,
307+
.sigbus_reliable = true,
308+
},
279309
{
280310
.name = "MOPS",
281311
.at_hwcap = AT_HWCAP2,

0 commit comments

Comments
 (0)