Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FC18C4338F for ; Thu, 19 Aug 2021 13:48:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D31116113B for ; Thu, 19 Aug 2021 13:47:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D31116113B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pQyQFsNXfkj9EhtVvbmG5FIvn+DBF9ZxxD5LaV+lHew=; b=pJ8M+tAFkZ0KVY irO3wu6sux0X/G7K+RYzlIwCDSIIsbtQsrN1l8Rbfwzi2IySx4FfXFfjNTFFcLVwtk4Oh4piwiBJk pxpIcqHNUoyB+CChG4jLi6sT6r7wg9OPO2Ib1bK4Y/Y+vxQYpTFP4SjFrDcIKR49lT5SjYsvdJcN+ W7AgaorkOuIpcfzvVPxXCVHorlTLEqS4mVMuCxSjd+3oTre3y6pgxC47/hI3TYYsML4pC0PULzgx1 hv7/sUKd7Npnda+lILQZp+bz4xNO/Yj/4/pFnJwrkBgW4N+LFhYZ5JGELR2keUF0S5FCz524Fw3wx CScWLAzJp8GtvByNfGWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGiMW-008Ti2-Kx; Thu, 19 Aug 2021 13:45:40 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGiLo-008TU8-99 for linux-arm-kernel@lists.infradead.org; Thu, 19 Aug 2021 13:44:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73F086113D; Thu, 19 Aug 2021 13:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629380696; bh=K+2RWYHSib+VorGSiRaCb3eSdU1CThHK4Naz8yGV1Lo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxf/AG+BkeKeM54+8EPp4yZdxii6LO/Tys6D+gQtPr2kZwwVnjBS3IJG9z0NdsgFL 4vGYAIcEQFSeX4spZ9FSOdF4ZGbS+ECHoyRAY2zKTRy1AGPSK7SfTGJEQJpz7AxNZ8 PBL24eiFV7Y/fLFQGJQoimQKoRpLIVq02y6voSx+YY9c1NG8r9NgPp1D9+0Xkeowe7 EUKnmxaFtzQMuwmW/73+5H9v2SkX2mZUkpYdwhl5ziG1CbOTXqryncl/U+qAJAMt24 UHggpSy7Ao0Zm/QFhMbJIlUhajDJ0yAb36irq87wXOE3upWrmA445qNNUebXcpPH2G 55QU5Pb+GwTnQ== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 4/6] kselftest/arm64: signal: Verify that signals can't change the SVE vector length Date: Thu, 19 Aug 2021 14:42:43 +0100 Message-Id: <20210819134245.13935-5-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819134245.13935-1-broonie@kernel.org> References: <20210819134245.13935-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2906; h=from:subject; bh=K+2RWYHSib+VorGSiRaCb3eSdU1CThHK4Naz8yGV1Lo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhHl/Sp0VM9z9CCvlTyC0fBgCXxfdGMN7w5P86JsH1 8VsIIX2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYR5f0gAKCRAk1otyXVSH0CSvB/ 9ScRLG+RYySndMdZejvkTgU+XIOOUYCGPsm2sGQ3kwEH6bVrXpJdiQCTdzEreh3CrTOsXit7dFymGK HxEHij2Xh1CjOKfE0NzTF9IMOaPg556aXp2d1Lqz+olQKr33Cxe8lfaBs0P0U3cVKXVfNaCYU70BFm 637CH5V0yK4R/jxhI48BiWzgLtZqYCN5jkKe6POmS9ngrEg07EX3CFUhz+p9JfxFww9FoN5QB588Qa s2h48JIeueRmcgp960pHR01VtXMLtin9v56sIOMkcJcJZq+FYmX5f9wh8BLZ5+Zokj8i6MoZspgJec ohP3osvn5+8lJFiOYxfD6LUg7KO05P X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210819_064456_399605_80080445 X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We do not support changing the SVE vector length as part of signal return, verify that this is the case if the system supports multiple vector lengths. Signed-off-by: Mark Brown --- .../testcases/fake_sigreturn_sve_change_vl.c | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sve_change_vl.c diff --git a/tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sve_change_vl.c b/tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sve_change_vl.c new file mode 100644 index 000000000000..bb50b5adbf10 --- /dev/null +++ b/tools/testing/selftests/arm64/signal/testcases/fake_sigreturn_sve_change_vl.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 ARM Limited + * + * Attempt to change the SVE vector length in a signal hander, this is not + * supported and is expected to segfault. + */ + +#include +#include +#include + +#include "test_signals_utils.h" +#include "testcases.h" + +struct fake_sigframe sf; +static unsigned int vls[SVE_VQ_MAX]; +unsigned int nvls = 0; + +static bool sve_get_vls(struct tdescr *td) +{ + int vq, vl; + + /* + * Enumerate up to SVE_VQ_MAX vector lengths + */ + for (vq = SVE_VQ_MAX; vq > 0; --vq) { + vl = prctl(PR_SVE_SET_VL, vq * 16); + if (vl == -1) + return false; + + vl &= PR_SVE_VL_LEN_MASK; + + /* Skip missing VLs */ + vq = sve_vq_from_vl(vl); + + vls[nvls++] = vl; + } + + /* We need at least two VLs */ + if (nvls < 2) { + fprintf(stderr, "Only %d VL supported\n", nvls); + return false; + } + + return true; +} + +static int fake_sigreturn_sve_change_vl(struct tdescr *td, + siginfo_t *si, ucontext_t *uc) +{ + size_t resv_sz, offset; + struct _aarch64_ctx *head = GET_SF_RESV_HEAD(sf); + struct sve_context *sve; + + /* Get a signal context with a SVE frame in it */ + if (!get_current_context(td, &sf.uc)) + return 1; + + resv_sz = GET_SF_RESV_SIZE(sf); + head = get_header(head, SVE_MAGIC, resv_sz, &offset); + if (!head) { + fprintf(stderr, "No SVE context\n"); + return 1; + } + + if (head->size != sizeof(struct sve_context)) { + fprintf(stderr, "SVE register state active, skipping\n"); + return 1; + } + + sve = (struct sve_context *)head; + + /* No changes are supported; init left us at minimum VL so go to max */ + fprintf(stderr, "Attempting to change VL from %d to %d\n", + sve->vl, vls[0]); + sve->vl = vls[0]; + + fake_sigreturn(&sf, sizeof(sf), 0); + + return 1; +} + +struct tdescr tde = { + .name = "FAKE_SIGRETURN_SVE_CHANGE", + .descr = "Attempt to change SVE VL", + .feats_required = FEAT_SVE, + .sig_ok = SIGSEGV, + .timeout = 3, + .init = sve_get_vls, + .run = fake_sigreturn_sve_change_vl, +}; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel