From patchwork Fri Sep 17 12:08:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 514176 Delivered-To: patch@linaro.org Received: by 2002:a17:906:f46:0:0:0:0 with SMTP id h6csp2076366ejj; Fri, 17 Sep 2021 05:10:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd7Kme4YACExgi2PaqTyF6hWyzVArmokc7+wdjsg7nbAlAjEFQH1Poq0esI7Jpqp05SQz2 X-Received: by 2002:a1c:7217:: with SMTP id n23mr14888316wmc.63.1631880613452; Fri, 17 Sep 2021 05:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631880613; cv=none; d=google.com; s=arc-20160816; b=LxSipajUxBffK9reWdaU0AQA9H38iA2Wrv5S7lx80lestgaLglL8+TeAPQY/8QjCuZ VwRrB5Cm+Y26bYBhFvt2H0QGZ54qVhasHoP6+xgAEPpSI8FiLkDgvixhxofPjbee68OA M1/Kb754U8QUN4gSMs6nDsmTzbKehVx0sF4SQMwCp7il0lQlRIyxZC0F38r1Eiu0qW2e NEbaNnCMJFcMf/76xpwXBiWYKD6BD0Yz5Z2jfYiDC9TEM/e9++ySiYQUMikImYadKlNI 2MifjihqI4KORCrSZ+veqV/WoJ+LIBePxvwvxltRonpR5uVqjmMapJ47x7bcu5KKWmpE nG7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q3dGov9Hjt67FzTv5KEqTl5rSJ8PKGprORubRt51DKk=; b=w8X4R3XZqMOJFevKCISffeFDv2Pt+lmxTGcmN7NaLnVt1doCBa7H32Aou0B9jfdLAI 5FQsZYmnRs89AMz4CteOuFpv4pnJsMsGLJAL47HrqBZEdYqQvbA+jYn5MxQJg6Vc3mxx 0IMR/jhcM6o8bJksGKhKcT1rvCmvJsRNwkFppHncsc/F6V13opAuSRY8YLse9wHnA2+i DHvrRm+G7rBR1pk7cMyyw6tzSmFDWeJfU+IMQWmpkGfm+M3PsaBqUFE2hmLYOb3nAE2z zP52o/+W1R8UJ4k1j35jTrqyL+iSnUq6ssM3v4AhMyDk0bPS6ArRpfKWyMJzVYtGsGLu TAhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DjssvoiU; spf=pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kselftest-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p31si8992252edb.554.2021.09.17.05.10.13; Fri, 17 Sep 2021 05:10:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DjssvoiU; spf=pass (google.com: domain of linux-kselftest-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kselftest-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231897AbhIQMLe (ORCPT + 5 others); Fri, 17 Sep 2021 08:11:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:48328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbhIQMLd (ORCPT ); Fri, 17 Sep 2021 08:11:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B52D61029; Fri, 17 Sep 2021 12:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631880611; bh=kxlmWsIvJBPFCGEqPWM9dGFH0Yj8wRu49i4D5IG/WpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjssvoiUN5ANfMlWEbsdVn27ClLMffxblPudScRWVEYnp70toFZQEF5yluaGvcD5T tcwWUgZ7BV8I8VTPTiYTyaKElxEvm3udJnn2pjfdh7Fq6JwfjbPb9L52aKZrL5oBT5 oA9J2bfntOd6hOOAJupg9l6LDGZDY619hpuxESuVatHAPuEObluGG39IZohXfl8450 bZODniQo2zAlX/+vww/QUTzjqE5LOFjH+ooUxmwLICYSshKet6vCypnFGcnSRtPcsV BzvYz2fn5y2l6C63SEgSWsZ9G1AET4t4OCMq+ZjGQV4on8m8WmpT2+DAaKKD2OtJDH l/BlQA8Mh0yZQ== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, misono.tomohiro@fujitsu.com, Mark Brown Subject: [PATCH v2 4/4] selftests: arm64: Verify that all possible vector lengths are handled Date: Fri, 17 Sep 2021 13:08:55 +0100 Message-Id: <20210917120855.13858-5-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210917120855.13858-1-broonie@kernel.org> References: <20210917120855.13858-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3010; h=from:subject; bh=kxlmWsIvJBPFCGEqPWM9dGFH0Yj8wRu49i4D5IG/WpE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhRIVU7U6WVRMbQ4I9XZp4rIOvx6l6GsqSZbOGzJik VwZX33qJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYUSFVAAKCRAk1otyXVSH0GjyB/ 9OudLcJQvNJfeWWWwTv0IOwf9iJzcdz57NT/VhZhZeKz0Wa49MaxrVo/M8/eT6cDV1M4eXDZ4LQP7p aJ96q4m1oDRHHk+mNSxwOikjecvNd0T1jNwKQt1hQmfBqe6b7QBfExKcPG7JJas3k77Als3XlzYI7q jpRQyrcpyYAqlABUl+gQnI32isOCaJwHHyCGQX0A5WYzoBc01a4a7U8jNZerEL+5+dVwWMvExrqs5u jy3JkODPeluOmpM1668rlNb3lLErdRciVL0DHOmUT+K6T9P0fY9aSXbfiprFf8LjQgl7SYplwPSDsZ nPv/33qFF2z6NyZ5IA7DeY0oEcnGJ3 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org As part of the enumeration interface for setting vector lengths it is valid to set vector lengths not supported in the system, these will be rounded to a supported vector length and returned from the prctl(). Add a test which exercises this for every valid vector length and makes sure that the return value is as expected and that this is reflected in the actual system state. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/vec-syscfg.c | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) -- 2.20.1 Reviewed-by: Tomohiro Misono diff --git a/tools/testing/selftests/arm64/fp/vec-syscfg.c b/tools/testing/selftests/arm64/fp/vec-syscfg.c index 9d6ac843e651..de11cd2f5d79 100644 --- a/tools/testing/selftests/arm64/fp/vec-syscfg.c +++ b/tools/testing/selftests/arm64/fp/vec-syscfg.c @@ -540,6 +540,76 @@ static void prctl_set_onexec(struct vec_data *data) file_write_integer(data->default_vl_file, data->default_vl); } +/* For each VQ verify that setting via prctl() does the right thing */ +static void prctl_set_all_vqs(struct vec_data *data) +{ + int ret, vq, vl, new_vl; + int errors = 0; + + for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) { + vl = sve_vl_from_vq(vq); + + /* Attempt to set the VL */ + ret = prctl(data->prctl_set, vl); + if (ret < 0) { + errors++; + ksft_print_msg("%s prctl set failed for %d: %d (%s)\n", + data->name, vl, + errno, strerror(errno)); + continue; + } + + new_vl = ret & PR_SVE_VL_LEN_MASK; + + /* Check that we actually have the reported new VL */ + if (data->rdvl() != new_vl) { + ksft_print_msg("Set %s VL %d but RDVL reports %d\n", + data->name, new_vl, data->rdvl()); + errors++; + } + + /* Was that the VL we asked for? */ + if (new_vl == vl) + continue; + + /* Should round up to the minimum VL if below it */ + if (vl < data->min_vl) { + if (new_vl != data->min_vl) { + ksft_print_msg("%s VL %d returned %d not minimum %d\n", + data->name, vl, new_vl, + data->min_vl); + errors++; + } + + continue; + } + + /* Should round down to maximum VL if above it */ + if (vl > data->max_vl) { + if (new_vl != data->max_vl) { + ksft_print_msg("%s VL %d returned %d not maximum %d\n", + data->name, vl, new_vl, + data->max_vl); + errors++; + } + + continue; + } + + /* Otherwise we should've rounded down */ + if (!(new_vl < vl)) { + ksft_print_msg("%s VL %d returned %d, did not round down\n", + data->name, vl, new_vl); + errors++; + + continue; + } + } + + ksft_test_result(errors == 0, "%s prctl() set all VLs, %d errors\n", + data->name, errors); +} + typedef void (*test_type)(struct vec_data *); static const test_type tests[] = { @@ -557,6 +627,7 @@ static const test_type tests[] = { prctl_set_no_child, prctl_set_for_child, prctl_set_onexec, + prctl_set_all_vqs, }; int main(void)