Message ID | 20220207152109.197566-36-broonie@kernel.org |
---|---|
State | Superseded |
Headers | show |
Series | None | expand |
On 2/7/22 8:21 AM, Mark Brown wrote: > 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: Mark Brown <broonie@kernel.org> > --- > .../arm64/signal/testcases/testcases.c | 36 +++++++++++++++++++ > .../arm64/signal/testcases/testcases.h | 3 +- > 2 files changed, 38 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c > index 8c2a57fc2f9c..84c36bee4d82 100644 > --- a/tools/testing/selftests/arm64/signal/testcases/testcases.c > +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c > @@ -75,6 +75,31 @@ bool validate_sve_context(struct sve_context *sve, char **err) > 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 terminated = false; > @@ -82,6 +107,7 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) > int flags = 0; > struct extra_context *extra = NULL; > struct sve_context *sve = NULL; > + struct za_context *za = NULL; > struct _aarch64_ctx *head = > (struct _aarch64_ctx *)uc->uc_mcontext.__reserved; > > @@ -120,6 +146,13 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) > sve = (struct sve_context *)head; > flags |= SVE_CTX; > break; > + case ZA_MAGIC: > + if (flags & ZA_CTX) > + *err = "Multiple ZA_MAGIC"; Is this considered an error? > + /* Size is validated in validate_za_context() */ > + za = (struct za_context *)head; > + flags |= ZA_CTX; > + break; > case EXTRA_MAGIC: > if (flags & EXTRA_CTX) > *err = "Multiple EXTRA_MAGIC"; > @@ -165,6 +198,9 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) > if (flags & SVE_CTX) > if (!validate_sve_context(sve, err)) > return false; > + if (flags & ZA_CTX) > + if (!validate_za_context(za, err)) If validate_za_context() finds an error, the above "Multiple ZA_MAGIC" will be overwritten? Is that the intent? > + return false; > > head = GET_RESV_NEXT_HEAD(head); > } > diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.h b/tools/testing/selftests/arm64/signal/testcases/testcases.h > index ad884c135314..49f1d5de7b5b 100644 > --- a/tools/testing/selftests/arm64/signal/testcases/testcases.h > +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.h > @@ -16,7 +16,8 @@ > > #define FPSIMD_CTX (1 << 0) > #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 > > With these explained or fixed: Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> thanks, -- Shuah thanks, -- Shuah
On Mon, Feb 07, 2022 at 06:01:49PM -0700, Shuah Khan wrote: > On 2/7/22 8:21 AM, Mark Brown wrote: > > + case ZA_MAGIC: > > + if (flags & ZA_CTX) > > + *err = "Multiple ZA_MAGIC"; > > Is this considered an error? Yes. > > @@ -165,6 +198,9 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) > > if (flags & SVE_CTX) > > if (!validate_sve_context(sve, err)) > > return false; > > + if (flags & ZA_CTX) > > + if (!validate_za_context(za, err)) > If validate_za_context() finds an error, the above "Multiple ZA_MAGIC" will > be overwritten? Is that the intent? Both are errors.
On Mon, Feb 07, 2022 at 03:21:04PM +0000, Mark Brown wrote: > 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: Mark Brown <broonie@kernel.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c index 8c2a57fc2f9c..84c36bee4d82 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.c +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c @@ -75,6 +75,31 @@ bool validate_sve_context(struct sve_context *sve, char **err) 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 terminated = false; @@ -82,6 +107,7 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) int flags = 0; struct extra_context *extra = NULL; struct sve_context *sve = NULL; + struct za_context *za = NULL; struct _aarch64_ctx *head = (struct _aarch64_ctx *)uc->uc_mcontext.__reserved; @@ -120,6 +146,13 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) sve = (struct sve_context *)head; flags |= SVE_CTX; 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: if (flags & EXTRA_CTX) *err = "Multiple EXTRA_MAGIC"; @@ -165,6 +198,9 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) if (flags & SVE_CTX) if (!validate_sve_context(sve, err)) return false; + if (flags & ZA_CTX) + if (!validate_za_context(za, err)) + return false; head = GET_RESV_NEXT_HEAD(head); } diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.h b/tools/testing/selftests/arm64/signal/testcases/testcases.h index ad884c135314..49f1d5de7b5b 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.h +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.h @@ -16,7 +16,8 @@ #define FPSIMD_CTX (1 << 0) #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
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: Mark Brown <broonie@kernel.org> --- .../arm64/signal/testcases/testcases.c | 36 +++++++++++++++++++ .../arm64/signal/testcases/testcases.h | 3 +- 2 files changed, 38 insertions(+), 1 deletion(-)