Commit 32de73e8 authored by Mark Brown's avatar Mark Brown Committed by Will Deacon
Browse files

kselftest/arm64: signal: Allow tests to be incompatible with features



Some features may invalidate some tests, for example by supporting an
operation which would trap otherwise. Allow tests to list features that
they are incompatible with so we can cover the case where a signal will
be generated without disruption on systems where that won't happen.

Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20220207152109.197566-6-broonie@kernel.org


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 0a775ccb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ struct tdescr {
	char			*name;
	char			*name;
	char			*descr;
	char			*descr;
	unsigned long		feats_required;
	unsigned long		feats_required;
	unsigned long		feats_incompatible;
	/* bitmask of effectively supported feats: populated at run-time */
	/* bitmask of effectively supported feats: populated at run-time */
	unsigned long		feats_supported;
	unsigned long		feats_supported;
	bool			initialized;
	bool			initialized;
+25 −9
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@ static inline char *feats_to_string(unsigned long feats)
{
{
	size_t flen = MAX_FEATS_SZ - 1;
	size_t flen = MAX_FEATS_SZ - 1;


	feats_string[0] = '\0';

	for (int i = 0; i < FMAX_END; i++) {
	for (int i = 0; i < FMAX_END; i++) {
		if (feats & (1UL << i)) {
		if (feats & (1UL << i)) {
			size_t tlen = strlen(feats_names[i]);
			size_t tlen = strlen(feats_names[i]);
@@ -256,7 +258,7 @@ int test_init(struct tdescr *td)
		td->minsigstksz = MINSIGSTKSZ;
		td->minsigstksz = MINSIGSTKSZ;
	fprintf(stderr, "Detected MINSTKSIGSZ:%d\n", td->minsigstksz);
	fprintf(stderr, "Detected MINSTKSIGSZ:%d\n", td->minsigstksz);


	if (td->feats_required) {
	if (td->feats_required || td->feats_incompatible) {
		td->feats_supported = 0;
		td->feats_supported = 0;
		/*
		/*
		 * Checking for CPU required features using both the
		 * Checking for CPU required features using both the
@@ -267,15 +269,29 @@ int test_init(struct tdescr *td)
		if (getauxval(AT_HWCAP) & HWCAP_SVE)
		if (getauxval(AT_HWCAP) & HWCAP_SVE)
			td->feats_supported |= FEAT_SVE;
			td->feats_supported |= FEAT_SVE;
		if (feats_ok(td)) {
		if (feats_ok(td)) {
			if (td->feats_required & td->feats_supported)
				fprintf(stderr,
				fprintf(stderr,
					"Required Features: [%s] supported\n",
					"Required Features: [%s] supported\n",
					feats_to_string(td->feats_required &
					feats_to_string(td->feats_required &
							td->feats_supported));
							td->feats_supported));
			if (!(td->feats_incompatible & td->feats_supported))
				fprintf(stderr,
					"Incompatible Features: [%s] absent\n",
					feats_to_string(td->feats_incompatible));
		} else {
		} else {
			if ((td->feats_required & td->feats_supported) !=
			    td->feats_supported)
				fprintf(stderr,
				fprintf(stderr,
					"Required Features: [%s] NOT supported\n",
					"Required Features: [%s] NOT supported\n",
					feats_to_string(td->feats_required &
					feats_to_string(td->feats_required &
							~td->feats_supported));
							~td->feats_supported));
			if (td->feats_incompatible & td->feats_supported)
				fprintf(stderr,
					"Incompatible Features: [%s] supported\n",
					feats_to_string(td->feats_incompatible &
							~td->feats_supported));


			td->result = KSFT_SKIP;
			td->result = KSFT_SKIP;
			return 0;
			return 0;
		}
		}
+2 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@ void test_result(struct tdescr *td);


static inline bool feats_ok(struct tdescr *td)
static inline bool feats_ok(struct tdescr *td)
{
{
	if (td->feats_incompatible & td->feats_supported)
		return false;
	return (td->feats_required & td->feats_supported) == td->feats_required;
	return (td->feats_required & td->feats_supported) == td->feats_required;
}
}