~ [ 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-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 <signal.h>
 10 #include <ucontext.h>
 11 #include <sys/prctl.h>
 12 
 13 #include "test_signals_utils.h"
 14 #include "testcases.h"
 15 
 16 static union {
 17         ucontext_t uc;
 18         char buf[1024 * 128];
 19 } context;
 20 static unsigned int vls[SVE_VQ_MAX];
 21 unsigned int nvls = 0;
 22 
 23 static bool sme_get_vls(struct tdescr *td)
 24 {
 25         int vq, vl;
 26 
 27         /*
 28          * Enumerate up to SME_VQ_MAX vector lengths
 29          */
 30         for (vq = SVE_VQ_MAX; vq > 0; --vq) {
 31                 vl = prctl(PR_SME_SET_VL, vq * 16);
 32                 if (vl == -1)
 33                         return false;
 34 
 35                 vl &= PR_SME_VL_LEN_MASK;
 36 
 37                 /* Skip missing VLs */
 38                 vq = sve_vq_from_vl(vl);
 39 
 40                 vls[nvls++] = vl;
 41         }
 42 
 43         /* We need at least one VL */
 44         if (nvls < 1) {
 45                 fprintf(stderr, "Only %d VL supported\n", nvls);
 46                 return false;
 47         }
 48 
 49         return true;
 50 }
 51 
 52 static int do_one_sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc,
 53                          unsigned int vl)
 54 {
 55         size_t offset;
 56         struct _aarch64_ctx *head = GET_BUF_RESV_HEAD(context);
 57         struct za_context *za;
 58 
 59         fprintf(stderr, "Testing VL %d\n", vl);
 60 
 61         if (prctl(PR_SME_SET_VL, vl) != vl) {
 62                 fprintf(stderr, "Failed to set VL\n");
 63                 return 1;
 64         }
 65 
 66         /*
 67          * Get a signal context which should have a SVE frame and registers
 68          * in it.
 69          */
 70         if (!get_current_context(td, &context.uc, sizeof(context)))
 71                 return 1;
 72 
 73         head = get_header(head, ZA_MAGIC, GET_BUF_RESV_SIZE(context), &offset);
 74         if (!head) {
 75                 fprintf(stderr, "No ZA context\n");
 76                 return 1;
 77         }
 78 
 79         za = (struct za_context *)head;
 80         if (za->vl != vl) {
 81                 fprintf(stderr, "Got VL %d, expected %d\n", za->vl, vl);
 82                 return 1;
 83         }
 84 
 85         if (head->size != ZA_SIG_REGS_OFFSET) {
 86                 fprintf(stderr, "Context size %u, expected %lu\n",
 87                         head->size, ZA_SIG_REGS_OFFSET);
 88                 return 1;
 89         }
 90 
 91         /* The actual size validation is done in get_current_context() */
 92         fprintf(stderr, "Got expected size %u and VL %d\n",
 93                 head->size, za->vl);
 94 
 95         return 0;
 96 }
 97 
 98 static int sme_regs(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
 99 {
100         int i;
101 
102         for (i = 0; i < nvls; i++) {
103                 if (do_one_sme_vl(td, si, uc, vls[i]))
104                         return 1;
105         }
106 
107         td->pass = 1;
108 
109         return 0;
110 }
111 
112 struct tdescr tde = {
113         .name = "ZA registers - ZA disabled",
114         .descr = "Check ZA context with ZA disabled",
115         .feats_required = FEAT_SME,
116         .timeout = 3,
117         .init = sme_get_vls,
118         .run = sme_regs,
119 };
120 

~ [ 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