Commit 1a792b54 authored by Mark Brown's avatar Mark Brown Committed by Catalin Marinas

kselftest/arm64: signal: Handle ZA signal context in core code

As part of the generic code for signal handling test cases we parse all
signal frames to make sure they have at least the basic form we expect
and that there are no unexpected frames present in the signal context.
Add coverage of the ZA signal frame to this code.
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/20220419112247.711548-34-broonie@kernel.orgSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 4126bde0
...@@ -75,6 +75,31 @@ bool validate_sve_context(struct sve_context *sve, char **err) ...@@ -75,6 +75,31 @@ bool validate_sve_context(struct sve_context *sve, char **err)
return true; return true;
} }
bool validate_za_context(struct za_context *za, char **err)
{
/* Size will be rounded up to a multiple of 16 bytes */
size_t regs_size
= ((ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(za->vl)) + 15) / 16) * 16;
if (!za || !err)
return false;
/* Either a bare za_context or a za_context followed by regs data */
if ((za->head.size != sizeof(struct za_context)) &&
(za->head.size != regs_size)) {
*err = "bad size for ZA context";
return false;
}
if (!sve_vl_valid(za->vl)) {
*err = "SME VL in ZA context invalid";
return false;
}
return true;
}
bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
{ {
bool terminated = false; bool terminated = false;
...@@ -82,6 +107,7 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) ...@@ -82,6 +107,7 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
int flags = 0; int flags = 0;
struct extra_context *extra = NULL; struct extra_context *extra = NULL;
struct sve_context *sve = NULL; struct sve_context *sve = NULL;
struct za_context *za = NULL;
struct _aarch64_ctx *head = struct _aarch64_ctx *head =
(struct _aarch64_ctx *)uc->uc_mcontext.__reserved; (struct _aarch64_ctx *)uc->uc_mcontext.__reserved;
...@@ -120,6 +146,13 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) ...@@ -120,6 +146,13 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
sve = (struct sve_context *)head; sve = (struct sve_context *)head;
flags |= SVE_CTX; flags |= SVE_CTX;
break; break;
case ZA_MAGIC:
if (flags & ZA_CTX)
*err = "Multiple ZA_MAGIC";
/* Size is validated in validate_za_context() */
za = (struct za_context *)head;
flags |= ZA_CTX;
break;
case EXTRA_MAGIC: case EXTRA_MAGIC:
if (flags & EXTRA_CTX) if (flags & EXTRA_CTX)
*err = "Multiple EXTRA_MAGIC"; *err = "Multiple EXTRA_MAGIC";
...@@ -165,6 +198,9 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) ...@@ -165,6 +198,9 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err)
if (flags & SVE_CTX) if (flags & SVE_CTX)
if (!validate_sve_context(sve, err)) if (!validate_sve_context(sve, err))
return false; return false;
if (flags & ZA_CTX)
if (!validate_za_context(za, err))
return false;
head = GET_RESV_NEXT_HEAD(head); head = GET_RESV_NEXT_HEAD(head);
} }
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
#define FPSIMD_CTX (1 << 0) #define FPSIMD_CTX (1 << 0)
#define SVE_CTX (1 << 1) #define SVE_CTX (1 << 1)
#define EXTRA_CTX (1 << 2) #define ZA_CTX (1 << 2)
#define EXTRA_CTX (1 << 3)
#define KSFT_BAD_MAGIC 0xdeadbeef #define KSFT_BAD_MAGIC 0xdeadbeef
......
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