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 9C55AC4338F for ; Thu, 19 Aug 2021 13:48:14 +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 640556113B for ; Thu, 19 Aug 2021 13:48:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 640556113B 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=/PANOJievQ73da8Mlm/W8P2ZRGK/fVqMraWZlnLo+fc=; b=M+Mdm59BIWGa++ nJxnE5o5My5Jy54SF58q0ckAA1DJulj7TABwD9GxqJQTBRMmeyD6CaSHd50joWyQ8/iRzN0FXaArx m3F596FNOAhkF/jL9gIUKFhGcevSe+sMmgT3mR2FveBa1wZk2jPSk68wqTzRVZsejhJTPytgeIy/H P78z66xKQw6HzZs20xZnfhhQTB92q7AEm4r66KqkTEiifY9Hr+e+udDhCCgde6kdAmtTnbw1OzQCq orVYPSCZaszhwbi5fKquAZeqlxTkNhOEgtZlisQrsYJasuy81X4hg9QxZhHhwQ8GumxRGftAC5HFo GnodRY2/8R9m7i1HZkYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGiMm-008Too-G4; Thu, 19 Aug 2021 13:45:57 +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 1mGiLq-008TUk-QU for linux-arm-kernel@lists.infradead.org; Thu, 19 Aug 2021 13:45:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BED761130; Thu, 19 Aug 2021 13:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629380698; bh=k5HcpS2IjTmtfAGToFk4s0LdB0WauBhwZdp5bdaIxKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XrVIyFVoFUUq7WoAZRCDy/a/RrMR753nUiI9OB4N97hAAaF5aG4uXRvCocySDk2QM iRAoJgl9Qp0s3nmDtidqlWlHdOe5x7CSix+hoG2o2uWp89uaOjWQ6PUu6KepUh51Da JP+ovpSZLFP96BDQNSWpM70AHNNXWk5n/Kx7qh7tngLRU+rq1mxxvMrLZb5SWIFqSJ Pi5ptok1algDCIOo4sNlB//v+tgewPXp0O51vAdy6Nt0S2lTKzSvA5gFJm9dASV4nk wAWCz+I+rIWXiIeFKdFS0wWDtaZS4qUTRfGKMoVERqbAbvwS8BE7u+uNbTFaprQbzN wdqWePGSk8kyw== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 5/6] kselftest/arm64: signal: Add test case for SVE register state in signals Date: Thu, 19 Aug 2021 14:42:44 +0100 Message-Id: <20210819134245.13935-6-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=3482; h=from:subject; bh=k5HcpS2IjTmtfAGToFk4s0LdB0WauBhwZdp5bdaIxKw=; b=owGbwMvMwMWocq27KDak/QLjabUkhkS5+Mvt5W2SXU82TDc7Ujm7U7kgqfxua7XaI06BF1srW6ue NFh3MhqzMDByMciKKbKsfZaxKj1cYuv8R/NfwQxiZQKZwsDFKQAT8bBi/+/Ru+Dr7YinOnftTdQ+T+ TgZTU4/IbX+sXMd8/1X6S81v1kUnPI/XLH63fCTQuszGY9NmXPqzEQexaRJnbdaykn44mAtI+vePhm fOxoalXj6dzU8qq3Yfb34F9MlZs2Ns1JeZr1+8Ruff64Bx5/jzR73WTJmpVjr/d0ktOR0gCVuDNn23 znCwWqaJ3lsFhTGviK7VTpZb9l3OUrWVU9Qua8PH3C9HyZl0dR1LKU/C9SunH5KcXv4lTvfOa/tpn7 nln0b822rg2S1mnrFnK5qM/pFHbx1ZTvKi9mWxV5Lt3lXpELW3Z+2wmBOIG9du3VDf7xWhETt5fP38 D56JnsxvfbXpZe/5HV+bew4FcwAA== 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_064458_935279_EE547168 X-CRM114-Status: GOOD ( 20.68 ) 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 Currently this doesn't actually verify that the register contents do the right thing, it just verifes that a SVE context with appropriate size appears. Signed-off-by: Mark Brown --- .../arm64/signal/testcases/sve_regs.c | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 tools/testing/selftests/arm64/signal/testcases/sve_regs.c diff --git a/tools/testing/selftests/arm64/signal/testcases/sve_regs.c b/tools/testing/selftests/arm64/signal/testcases/sve_regs.c new file mode 100644 index 000000000000..4b2418aa08a9 --- /dev/null +++ b/tools/testing/selftests/arm64/signal/testcases/sve_regs.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 ARM Limited + * + * Verify that the SVE register context in signal frames is set up as + * expected. + */ + +#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 one VL */ + if (nvls < 1) { + fprintf(stderr, "Only %d VL supported\n", nvls); + return false; + } + + return true; +} + +static void setup_sve_regs(void) +{ + /* RDVL x16, #1 so we should have SVE regs; real data is TODO */ + asm volatile(".inst 0x04bf5030" : : : "x16" ); +} + +static int do_one_sve_vl(struct tdescr *td, siginfo_t *si, ucontext_t *uc, + unsigned int vl) +{ + size_t resv_sz, offset; + struct _aarch64_ctx *head = GET_SF_RESV_HEAD(sf); + struct sve_context *sve; + + fprintf(stderr, "Testing VL %d\n", vl); + + if (prctl(PR_SVE_SET_VL, vl) == -1) { + fprintf(stderr, "Failed to set VL\n"); + return 1; + } + + /* + * Get a signal context which should have a SVE frame and registers + * in it. + */ + setup_sve_regs(); + 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; + } + + sve = (struct sve_context *)head; + if (sve->vl != vl) { + fprintf(stderr, "Got VL %d, expected %d\n", sve->vl, vl); + return 1; + } + + /* The actual size validation is done in get_current_context() */ + fprintf(stderr, "Got expected size %u and VL %d\n", + head->size, sve->vl); + + return 0; +} + +static int sve_regs(struct tdescr *td, siginfo_t *si, ucontext_t *uc) +{ + int i; + + for (i = 0; i < nvls; i++) { + /* + * TODO: the signal test helpers can't currently cope + * with signal frames bigger than struct sigcontext, + * skip VLs that will trigger that. + */ + if (vls[i] > 64) + continue; + + if (do_one_sve_vl(td, si, uc, vls[i])) + return 1; + } + + td->pass = 1; + + return 0; +} + +struct tdescr tde = { + .name = "SVE registers", + .descr = "Check that we get the right SVE registers reported", + .feats_required = FEAT_SVE, + .timeout = 3, + .init = sve_get_vls, + .run = sve_regs, +}; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel