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

kselftest/arm64: Verify that we reject out of bounds VLs in sve-ptrace



We do not currently have a test that asserts that we reject attempts to set
a vector length smaller than SVE_VL_MIN or larger than SVE_VL_MAX, add one
since that is our current behaviour.

Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 5b7bdc44
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ static const struct vec_type vec_types[] = {
};

#define VL_TESTS (((TEST_VQ_MAX - SVE_VQ_MIN) + 1) * 4)
#define FLAG_TESTS 2
#define FLAG_TESTS 4
#define FPSIMD_TESTS 2

#define EXPECTED_TESTS ((VL_TESTS + FLAG_TESTS + FPSIMD_TESTS) * ARRAY_SIZE(vec_types))
@@ -286,6 +286,25 @@ static void check_u32(unsigned int vl, const char *reg,
	}
}

/* Set out of range VLs */
static void ptrace_set_vl_ranges(pid_t child, const struct vec_type *type)
{
	struct user_sve_header sve;
	int ret;

	memset(&sve, 0, sizeof(sve));
	sve.flags = SVE_PT_REGS_SVE;
	sve.size = sizeof(sve);

	ret = set_sve(child, type, &sve);
	ksft_test_result(ret != 0, "%s Set invalid VL 0\n", type->name);

	sve.vl = SVE_VL_MAX + SVE_VQ_BYTES;
	ret = set_sve(child, type, &sve);
	ksft_test_result(ret != 0, "%s Set invalid VL %d\n", type->name,
			 SVE_VL_MAX + SVE_VQ_BYTES);
}

/* Access the FPSIMD registers via the SVE regset */
static void ptrace_sve_fpsimd(pid_t child, const struct vec_type *type)
{
@@ -719,6 +738,17 @@ static int do_parent(pid_t child)
					      vec_types[i].name);
		}

		/* Setting out of bounds VLs should fail */
		if (getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap) {
			ptrace_set_vl_ranges(child, &vec_types[i]);
		} else {
			ksft_test_result_skip("%s Set invalid VL 0\n",
					      vec_types[i].name);
			ksft_test_result_skip("%s Set invalid VL %d\n",
					      vec_types[i].name,
					      SVE_VL_MAX + SVE_VQ_BYTES);
		}

		/* Step through every possible VQ */
		for (vq = SVE_VQ_MIN; vq <= TEST_VQ_MAX; vq++) {
			vl = sve_vl_from_vq(vq);