kselftest/arm64: Allow larger buffers in get_signal_context()
authorMark Brown <broonie@kernel.org>
Mon, 29 Aug 2022 16:07:02 +0000 (17:07 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 7 Sep 2022 13:25:47 +0000 (14:25 +0100)
In order to allow testing of signal contexts that overflow the base signal
frame allow callers to pass the buffer size for the user context into
get_signal_context(). No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220829160703.874492-10-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
14 files changed:
tools/testing/selftests/arm64/signal/test_signals_utils.h
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_bad_magic.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_bad_size.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_bad_size_for_magic0.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_duplicated_fpsimd.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_misaligned_sp.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_missing_fpsimd.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sme_change_vl.c
tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sve_change_vl.c
tools/testing/selftests/arm64/signal/testcases/sme_vl.c
tools/testing/selftests/arm64/signal/testcases/ssve_regs.c
tools/testing/selftests/arm64/signal/testcases/sve_regs.c
tools/testing/selftests/arm64/signal/testcases/sve_vl.c
tools/testing/selftests/arm64/signal/testcases/za_regs.c

index f3aa99b..222093f 100644 (file)
@@ -56,7 +56,8 @@ static inline bool feats_ok(struct tdescr *td)
  * at sizeof(ucontext_t).
  */
 static __always_inline bool get_current_context(struct tdescr *td,
-                                               ucontext_t *dest_uc)
+                                               ucontext_t *dest_uc,
+                                               size_t dest_sz)
 {
        static volatile bool seen_already;
 
@@ -64,7 +65,7 @@ static __always_inline bool get_current_context(struct tdescr *td,
        /* it's a genuine invocation..reinit */
        seen_already = 0;
        td->live_uc_valid = 0;
-       td->live_sz = sizeof(*dest_uc);
+       td->live_sz = dest_sz;
        memset(dest_uc, 0x00, td->live_sz);
        td->live_uc = dest_uc;
        /*
index 8dc600a..8c7f00e 100644 (file)
@@ -21,7 +21,7 @@ static int fake_sigreturn_bad_magic_run(struct tdescr *td,
        struct _aarch64_ctx *shead = GET_SF_RESV_HEAD(sf), *head;
 
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        /* need at least 2*HDR_SZ space: KSFT_BAD_MAGIC + terminator. */
index b3c3621..1c03f6b 100644 (file)
@@ -24,7 +24,7 @@ static int fake_sigreturn_bad_size_run(struct tdescr *td,
        struct _aarch64_ctx *shead = GET_SF_RESV_HEAD(sf), *head;
 
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index a44b88b..bc22f64 100644 (file)
@@ -21,7 +21,7 @@ static int fake_sigreturn_bad_size_for_magic0_run(struct tdescr *td,
        struct _aarch64_ctx *shead = GET_SF_RESV_HEAD(sf), *head;
 
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        /* at least HDR_SZ for the badly sized terminator. */
index afe8915..63e3906 100644 (file)
@@ -21,7 +21,7 @@ static int fake_sigreturn_duplicated_fpsimd_run(struct tdescr *td,
        struct _aarch64_ctx *shead = GET_SF_RESV_HEAD(sf), *head;
 
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        head = get_starting_head(shead, sizeof(struct fpsimd_context) + HDR_SZ,
index 1e089e6..d00625f 100644 (file)
@@ -19,7 +19,7 @@ static int fake_sigreturn_misaligned_run(struct tdescr *td,
                                         siginfo_t *si, ucontext_t *uc)
 {
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        /* Forcing sigframe on misaligned SP (16 + 3) */
index 08ecd80..f805138 100644 (file)
@@ -23,7 +23,7 @@ static int fake_sigreturn_missing_fpsimd_run(struct tdescr *td,
        struct _aarch64_ctx *head = GET_SF_RESV_HEAD(sf);
 
        /* just to fill the ucontext_t with something real */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 7ed762b..ebd5815 100644 (file)
@@ -54,7 +54,7 @@ static int fake_sigreturn_ssve_change_vl(struct tdescr *td,
        struct sve_context *sve;
 
        /* Get a signal context with a SME ZA frame in it */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 9158213..e2a4521 100644 (file)
@@ -56,7 +56,7 @@ static int fake_sigreturn_sve_change_vl(struct tdescr *td,
        struct sve_context *sve;
 
        /* Get a signal context with a SVE frame in it */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 13ff3b3..75f387f 100644 (file)
@@ -34,7 +34,7 @@ static int sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
        struct za_context *za;
 
        /* Get a signal context which should have a ZA frame in it */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 9022a6c..71f1463 100644 (file)
@@ -73,7 +73,7 @@ static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
         * in it.
         */
        setup_ssve_regs();
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 4b2418a..4cdedb7 100644 (file)
@@ -71,7 +71,7 @@ static int do_one_sve_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
         * in it.
         */
        setup_sve_regs();
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 9290465..aa835ac 100644 (file)
@@ -34,7 +34,7 @@ static int sve_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
        struct sve_context *sve;
 
        /* Get a signal context which should have a SVE frame in it */
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);
index 6f0c158..a92b8e9 100644 (file)
@@ -73,7 +73,7 @@ static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
         * in it.
         */
        setup_za_regs();
-       if (!get_current_context(td, &sf.uc))
+       if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))
                return 1;
 
        resv_sz = GET_SF_RESV_SIZE(sf);