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

Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/abi/hwcap.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/arm64/abi/hwcap.c
Extension
.c
Size
29691 bytes
Lines
1462
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2022 ARM Limited.
 */

#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/auxvec.h>
#include <linux/compiler.h>
#include <sys/auxv.h>
#include <sys/prctl.h>
#include <asm/hwcap.h>
#include <asm/sigcontext.h>
#include <asm/unistd.h>

#include <linux/auxvec.h>

#include "kselftest.h"

#define TESTS_PER_HWCAP 3

#ifndef AT_HWCAP3
#define AT_HWCAP3 29
#endif

/*
 * Function expected to generate exception when the feature is not
 * supported and return when it is supported. If the specific exception
 * is generated then the handler must be able to skip over the
 * instruction safely.
 *
 * Note that it is expected that for many architecture extensions
 * there are no specific traps due to no architecture state being
 * added so we may not fault if running on a kernel which doesn't know
 * to add the hwcap.
 */
typedef void (*sig_fn)(void);

static void aes_sigill(void)
{
	/* AESE V0.16B, V0.16B */
	asm volatile(".inst 0x4e284800" : : : );
}

static void atomics_sigill(void)
{
	/* STADD W0, [SP] */
	asm volatile(".inst 0xb82003ff" : : : );
}

static void cmpbr_sigill(void)
{
	asm volatile(".inst 0x74C00040\n" /* CBEQ w0, w0, +8 */
		     "udf #0" : : : "cc"); /* UDF #0 */
}

static void crc32_sigill(void)
{
	/* CRC32W W0, W0, W1 */
	asm volatile(".inst 0x1ac14800" : : : );
}

static void cssc_sigill(void)
{
	/* CNT x0, x0 */
	asm volatile(".inst 0xdac01c00" : : : "x0");
}

static void f8cvt_sigill(void)
{
	/* FSCALE V0.4H, V0.4H, V0.4H */
	asm volatile(".inst 0x2ec03c00");
}

static void f8dp2_sigill(void)
{
	/* FDOT V0.4H, V0.4H, V0.5H */
	asm volatile(".inst 0xe40fc00");
}

static void f8dp4_sigill(void)
{
	/* FDOT V0.2S, V0.2S, V0.2S */
	asm volatile(".inst 0xe00fc00");

Annotation

Implementation Notes