Path: blob/master/tools/testing/selftests/arm64/signal/testcases/sme_vl.c
26295 views
// SPDX-License-Identifier: GPL-2.01/*2* Copyright (C) 2021 ARM Limited3*4* Check that the SME vector length reported in signal contexts is the5* expected one.6*/78#include <signal.h>9#include <ucontext.h>10#include <sys/prctl.h>1112#include "test_signals_utils.h"13#include "testcases.h"1415struct fake_sigframe sf;16unsigned int vl;1718static bool get_sme_vl(struct tdescr *td)19{20int ret = prctl(PR_SME_GET_VL);21if (ret == -1)22return false;2324vl = ret;2526return true;27}2829static int sme_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc)30{31size_t resv_sz, offset;32struct _aarch64_ctx *head = GET_SF_RESV_HEAD(sf);33struct za_context *za;3435/* Get a signal context which should have a ZA frame in it */36if (!get_current_context(td, &sf.uc, sizeof(sf.uc)))37return 1;3839resv_sz = GET_SF_RESV_SIZE(sf);40head = get_header(head, ZA_MAGIC, resv_sz, &offset);41if (!head) {42fprintf(stderr, "No ZA context\n");43return 1;44}45za = (struct za_context *)head;4647if (za->vl != vl) {48fprintf(stderr, "ZA sigframe VL %u, expected %u\n",49za->vl, vl);50return 1;51} else {52fprintf(stderr, "got expected VL %u\n", vl);53}5455td->pass = 1;5657return 0;58}5960struct tdescr tde = {61.name = "SME VL",62.descr = "Check that we get the right SME VL reported",63.feats_required = FEAT_SME,64.timeout = 3,65.init = get_sme_vl,66.run = sme_vl,67};686970