~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/arm64/signal/testcases/za_no_regs.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright (C) 2021 ARM Limited
  4  *
  5  * Verify that the ZA register context in signal frames is set up as
  6  * expected.
  7  */
  8 
  9 #include <kselftest.h>
 10 #include <signal.h>
 11 #include <ucontext.h>
 12 #include <sys/prctl.h>
 13 
 14 #include "test_signals_utils.h"
 15 #include "sve_helpers.h"
 16 #include "testcases.h"
 17 
 18 static union {
 19         ucontext_t uc;
 20         char buf[1024 * 128];
 21 } context;
 22 
 23 static bool sme_get_vls(struct tdescr *td)
 24 {
 25         int res = sve_fill_vls(VLS_USE_SME, 1);
 26 
 27         if (!res)
 28                 return true;
 29 
 30         if (res == KSFT_SKIP)
 31                 td->result = KSFT_SKIP;
 32 
 33         return false;
 34 }
 35 
 36 static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
 37                          unsigned int vl)
 38 {
 39         size_t offset;
 40         struct _aarch64_ctx *head = GET_BUF_RESV_HEAD(context);
 41         struct za_context *za;
 42 
 43         fprintf(stderr, "Testing VL %d\n", vl);
 44 
 45         if (prctl(PR_SME_SET_VL, vl) != vl) {
 46                 fprintf(stderr, "Failed to set VL\n");
 47                 return 1;
 48         }
 49 
 50         /*
 51          * Get a signal context which should have a SVE frame and registers
 52          * in it.
 53          */
 54         if (!get_current_context(td, &context.uc, sizeof(context)))
 55                 return 1;
 56 
 57         head = get_header(head, ZA_MAGIC, GET_BUF_RESV_SIZE(context), &offset);
 58         if (!head) {
 59                 fprintf(stderr, "No ZA context\n");
 60                 return 1;
 61         }
 62 
 63         za = (struct za_context *)head;
 64         if (za->vl != vl) {
 65                 fprintf(stderr, "Got VL %d, expected %d\n", za->vl, vl);
 66                 return 1;
 67         }
 68 
 69         if (head->size != ZA_SIG_REGS_OFFSET) {
 70                 fprintf(stderr, "Context size %u, expected %lu\n",
 71                         head->size, ZA_SIG_REGS_OFFSET);
 72                 return 1;
 73         }
 74 
 75         /* The actual size validation is done in get_current_context() */
 76         fprintf(stderr, "Got expected size %u and VL %d\n",
 77                 head->size, za->vl);
 78 
 79         return 0;
 80 }
 81 
 82 static int sme_regs(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
 83 {
 84         int i;
 85 
 86         for (i = 0; i < nvls; i++) {
 87                 if (do_one_sme_vl(td, si, uc, vls[i]))
 88                         return 1;
 89         }
 90 
 91         td->pass = 1;
 92 
 93         return 0;
 94 }
 95 
 96 struct tdescr tde = {
 97         .name = "ZA registers - ZA disabled",
 98         .descr = "Check ZA context with ZA disabled",
 99         .feats_required = FEAT_SME,
100         .timeout = 3,
101         .init = sme_get_vls,
102         .run = sme_regs,
103 };
104 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php