Commit b95b07d1 authored by Mark Brown's avatar Mark Brown Committed by Catalin Marinas

kselftest/arm64: Tighten up validation of ZA signal context

Currently we accept any size for the ZA signal context that the shared
code will accept which means we don't verify that any data is present.
Since we have enabled ZA we know that there must be data so strengthen
the check to only accept a signal frame with data, and while we're at it
since we enabled ZA but did not set any data we know that ZA must contain
zeros, confirm that.
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220829155728.854947-2-broonie@kernel.orgSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent fd5c2c6f
......@@ -52,6 +52,8 @@ static void setup_za_regs(void)
asm volatile(".inst 0xd503457f" : : : );
}
static char zeros[ZA_SIG_REGS_SIZE(SVE_VQ_MAX)];
static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
unsigned int vl)
{
......@@ -87,10 +89,22 @@ static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
return 1;
}
/* The actual size validation is done in get_current_context() */
if (head->size != ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(vl))) {
fprintf(stderr, "ZA context size %u, expected %lu\n",
head->size, ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(vl)));
return 1;
}
fprintf(stderr, "Got expected size %u and VL %d\n",
head->size, za->vl);
/* We didn't load any data into ZA so it should be all zeros */
if (memcmp(zeros, (char *)za + ZA_SIG_REGS_OFFSET,
ZA_SIG_REGS_SIZE(sve_vq_from_vl(za->vl))) != 0) {
fprintf(stderr, "ZA data invalid\n");
return 1;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment