Path: blob/master/tools/testing/selftests/arm64/signal/testcases/sve_vl.c
26295 views
// SPDX-License-Identifier: GPL-2.01/*2* Copyright (C) 2021 ARM Limited3*4* Check that the SVE 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_sve_vl(struct tdescr *td)19{20int ret = prctl(PR_SVE_GET_VL);21if (ret == -1)22return false;2324vl = ret;2526return true;27}2829static int sve_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 sve_context *sve;3435/* Get a signal context which should have a SVE 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, SVE_MAGIC, resv_sz, &offset);41if (!head) {42fprintf(stderr, "No SVE context\n");43return 1;44}45sve = (struct sve_context *)head;4647if (sve->vl != vl) {48fprintf(stderr, "sigframe VL %u, expected %u\n",49sve->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 = "SVE VL",62.descr = "Check that we get the right SVE VL reported",63.feats_required = FEAT_SVE,64.timeout = 3,65.init = get_sve_vl,66.run = sve_vl,67};686970