Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (C) 2021 ARM Limited
0004  *
0005  * Check that the SME vector length reported in signal contexts is the
0006  * expected one.
0007  */
0008 
0009 #include <signal.h>
0010 #include <ucontext.h>
0011 #include <sys/prctl.h>
0012 
0013 #include "test_signals_utils.h"
0014 #include "testcases.h"
0015 
0016 struct fake_sigframe sf;
0017 unsigned int vl;
0018 
0019 static bool get_sme_vl(struct tdescr *td)
0020 {
0021     int ret = prctl(PR_SME_GET_VL);
0022     if (ret == -1)
0023         return false;
0024 
0025     vl = ret;
0026 
0027     return true;
0028 }
0029 
0030 static int sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc)
0031 {
0032     size_t resv_sz, offset;
0033     struct _aarch64_ctx *head = GET_SF_RESV_HEAD(sf);
0034     struct za_context *za;
0035 
0036     /* Get a signal context which should have a ZA frame in it */
0037     if (!get_current_context(td, &sf.uc))
0038         return 1;
0039 
0040     resv_sz = GET_SF_RESV_SIZE(sf);
0041     head = get_header(head, ZA_MAGIC, resv_sz, &offset);
0042     if (!head) {
0043         fprintf(stderr, "No ZA context\n");
0044         return 1;
0045     }
0046     za = (struct za_context *)head;
0047 
0048     if (za->vl != vl) {
0049         fprintf(stderr, "ZA sigframe VL %u, expected %u\n",
0050             za->vl, vl);
0051         return 1;
0052     } else {
0053         fprintf(stderr, "got expected VL %u\n", vl);
0054     }
0055 
0056     td->pass = 1;
0057 
0058     return 0;
0059 }
0060 
0061 struct tdescr tde = {
0062     .name = "SME VL",
0063     .descr = "Check that we get the right SME VL reported",
0064     .feats_required = FEAT_SME,
0065     .timeout = 3,
0066     .init = get_sme_vl,
0067     .run = sme_vl,
0068 };