From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A65E606A330 for ; Thu, 3 Dec 2026 17:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=uRGxXaHQ; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=jrDOeiFE DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=ZSnwPl4oUNg2PFDf8oB7E9kVjcWNOaVOpvRrxHuaB18=; b=uRGxXaHQJS40vRBi1a4CNbAAJD zb9+Aj3jrb8ZzGxkYe0Y+Ds3M5yoe/hf0DABbfOOE0E3OzgvPNsiSvw6XrHd+KfmOovqYeYWt4C0+ KOJbvSa79046ndq98EsDP1DOvI4PtM1M+2zPX86FnJUHwCwY8uNyj/A7ScogQx6LHGdanbDuahWrU bevwGnNOQvR0HilKRir7K/3T6lQ3Quss9R0KXuFGp2fAL2euS1vLW367yfr1N34h+GZyVt6YOZtds cbLlzmx4+xf09PldkewS/eswvLu9Ic4J66XoZ1g5CSfiro2IrP4355eDJROYZlNH3Ntp/uzlPI/7t 1LsNz7hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZAG8-0000000FNKK-0FCy; Thu, 03 Dec 2026 17:06:16 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZAG5-0000000FNJT-14Dv for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 17:06:14 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-8b612fd74e1so33964b3a.0 for ; Thu, 03 Dec 2026 09:06:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796317572; x=1796922372; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZSnwPl4oUNg2PFDf8oB7E9kVjcWNOaVOpvRrxHuaB18=; b=jrDOeiFEMzXOqVDxtuINaY+9AsXFRJqdsakwwB8J8Bnjc/jITK3Oc43U/R71IHhdfg CvzcDiX6qggMZkNxxkNfkYa9d07+B0SmxwjQCYHAwUAiuo0frBZeKMz02g/T1V7LaLjR 13aypXSaFQ1U9h6EVc0AlM3aZcYvBM7gZZA+4g4kjXkIVfTPWeswt5zL3ofaNmVdFvNL R/eWH00AcexIpRReU9k0OX4BIpgsSlrCpF6r340WW6WtlRks2zG8fQMLLu4fHYFXjX5R ML1EUaJiEiCrWj3EnmZSm0cBusfIk4O+KPwiPoiOBA65t0Ru/5Jhx2bC/ROommfTt50w nMvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796317572; x=1796922372; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZSnwPl4oUNg2PFDf8oB7E9kVjcWNOaVOpvRrxHuaB18=; b=HHeBt9I5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+NcN8U/bDUV6cp6Ny5AOL8L3y1I8tGySBaNVS8ir oDUPzXEDuVCRoIN7sYsGkKCZu7QZtEfCM+ZGeiNRSWr2Wy9d6sAkrsQyRu+SMwFsyuED0F79g23 hEEV1HifsZzTWAEr0BgzavdBXh+eWPqRl4zYYLSzcXMsmvTPn3vUkFfBVTv5SnNhQIycdHcRoph NFf6iQQCPC7MiN59QdbuhTc02Q6wYgI8Cwg== X-Received: by 2002:a05:6a00:21c8:b0:89d:f19f:5dd1 with SMTP id d2e1a72fcca58-8c87c862aadmr42423014b3a.33.1796317571410; Thu, 03 Dec 2026 09:06:11 -0800 (PST) Received: from localhost.localdomain ([2001:56a:78dd:ba00:210d:c389:a74c:3f94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c86d821637sm24653725b3a.0.2026.12.03.09.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 09:06:11 -0800 (PST) From: Abdalla Eldoumani To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Mark Brown , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Abdalla Eldoumani Subject: [PATCH v2] kselftest/arm64: Check that PR_SVE_VL_INHERIT survives a second exec Date: Thu, 3 Dec 2026 11:05:07 -0600 Message-ID: <20261203170507.1444-1-aamsdoumani@gmail.com> X-Mailer: git-send-email 2.49.0.windows.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_090613_302664_12DA4083 X-CRM114-Status: GOOD ( 25.36 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Abdalla Eldoumani The prctl_set_for_child test sets a vector length with PR_SVE_VL_INHERIT and checks that a forked and exec()ed child sees it. That only covers the first exec(). The kernel keeps the inherit flag and the on-exec VL across exec() so that later descendants keep the VL too, and nothing checks that part, which the fp TODO list notes as testing PR_SVE_VL_INHERIT after a double fork. Extend the test to also read the VL in a grandchild. Add a small fork-exec helper next to rdvl-sve and rdvl-sme that forks, execs the program it is given and passes on its exit status. The child execs fork-exec with the rdvl helper, so the VL is read after two fork() and exec() generations. Both SVE and SME are covered since the test runs for each vector type. With a kernel modified to clear the inherit flag on exec() the existing check still passes and the new check fails for both vector types, with the grandchild getting the default VL. Drop the item from the TODO list. Assisted-by: LLM Signed-off-by: Abdalla Eldoumani --- Changes in v2: - Move the middle generation into a fork-exec helper next to rdvl-sve and rdvl-sme, instead of re-running vec-syscfg through /proc/self/exe, so main() is left alone (Mark Brown). tools/testing/selftests/arm64/fp/.gitignore | 1 + tools/testing/selftests/arm64/fp/Makefile | 4 +- tools/testing/selftests/arm64/fp/TODO | 1 - tools/testing/selftests/arm64/fp/fork-exec.c | 43 +++++++++++++++++++ tools/testing/selftests/arm64/fp/vec-syscfg.c | 32 +++++++++++++- 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tools/testing/selftests/arm64/fp/fork-exec.c diff --git a/tools/testing/selftests/arm64/fp/.gitignore b/tools/testing/selftests/arm64/fp/.gitignore index 8362e7e..535c6d8 100644 --- a/tools/testing/selftests/arm64/fp/.gitignore +++ b/tools/testing/selftests/arm64/fp/.gitignore @@ -1,3 +1,4 @@ +fork-exec fp-pidbench fp-ptrace fp-stress diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/selftests/arm64/fp/Makefile index d171021..e194cd4 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -11,7 +11,8 @@ TEST_GEN_PROGS := \ sve-ptrace sve-probe-vls \ vec-syscfg \ za-fork za-ptrace -TEST_GEN_PROGS_EXTENDED := fp-pidbench fpsimd-test \ +TEST_GEN_PROGS_EXTENDED := fork-exec \ + fp-pidbench fpsimd-test \ kernel-test \ rdvl-sme rdvl-sve \ sve-test \ @@ -24,6 +25,7 @@ TEST_PROGS_EXTENDED := fpsimd-stress sve-stress ssve-stress za-stress EXTRA_CLEAN += $(OUTPUT)/asm-utils.o $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o +$(OUTPUT)/fork-exec: fork-exec.c # Build with nolibc to avoid effects due to libc's clone() support $(OUTPUT)/fp-pidbench: fp-pidbench.S $(OUTPUT)/asm-utils.o $(CC) -nostdlib $^ -o $@ diff --git a/tools/testing/selftests/arm64/fp/TODO b/tools/testing/selftests/arm64/fp/TODO index 44004e5..90ee128 100644 --- a/tools/testing/selftests/arm64/fp/TODO +++ b/tools/testing/selftests/arm64/fp/TODO @@ -4,4 +4,3 @@ - Ensure ptraced processes actually see the register state visible through the ptrace interface. - Big endian. -- Test PR_SVE_VL_INHERIT after a double fork. diff --git a/tools/testing/selftests/arm64/fp/fork-exec.c b/tools/testing/selftests/arm64/fp/fork-exec.c new file mode 100644 index 0000000..e758c0d --- /dev/null +++ b/tools/testing/selftests/arm64/fp/fork-exec.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Fork, exec the program named on the command line and exit with its + * status, so a test can read state two exec() generations down. + */ + +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + pid_t child; + int status; + + if (argc != 2) { + fprintf(stderr, "usage: %s program\n", argv[0]); + return EXIT_FAILURE; + } + + child = fork(); + if (child == -1) { + fprintf(stderr, "fork() failed: %d (%s)\n", + errno, strerror(errno)); + return EXIT_FAILURE; + } + + if (child == 0) { + execl(argv[1], argv[1], NULL); + fprintf(stderr, "execl(%s) failed: %d (%s)\n", + argv[1], errno, strerror(errno)); + _exit(EXIT_FAILURE); + } + + if (waitpid(child, &status, 0) != child || !WIFEXITED(status)) + return EXIT_FAILURE; + + return WEXITSTATUS(status); +} diff --git a/tools/testing/selftests/arm64/fp/vec-syscfg.c b/tools/testing/selftests/arm64/fp/vec-syscfg.c index 2c8ccbe..63b8f52 100644 --- a/tools/testing/selftests/arm64/fp/vec-syscfg.c +++ b/tools/testing/selftests/arm64/fp/vec-syscfg.c @@ -24,6 +24,8 @@ #define ARCH_MIN_VL SVE_VL_MIN +#define FORK_EXEC_BINARY "./fork-exec" + struct vec_data { const char *name; unsigned long hwcap_type; @@ -85,8 +87,13 @@ static int stdio_read_integer(FILE *f, const char *what, int *val) return 0; } -/* Start a new process and return the vector length it sees */ -static int get_child_rdvl(struct vec_data *data) +/* + * Start a new process and return the vector length it sees. With + * grandchild set the child execs the fork-exec helper, which forks and + * execs the rdvl binary, so the VL is read two fork()/exec() generations + * down. + */ +static int get_descendant_rdvl(struct vec_data *data, bool grandchild) { FILE *out; int pipefd[2]; @@ -123,6 +130,14 @@ static int get_child_rdvl(struct vec_data *data) exit(EXIT_FAILURE); } + if (grandchild) { + execl(FORK_EXEC_BINARY, FORK_EXEC_BINARY, + data->rdvl_binary, NULL); + fprintf(stderr, "execl(%s) failed: %d (%s)\n", + FORK_EXEC_BINARY, errno, strerror(errno)); + exit(EXIT_FAILURE); + } + /* exec() a new binary which puts the VL on stdout */ ret = execl(data->rdvl_binary, data->rdvl_binary, NULL); fprintf(stderr, "execl(%s) failed: %d (%s)\n", @@ -174,6 +189,11 @@ static int get_child_rdvl(struct vec_data *data) return read_vl; } +static int get_child_rdvl(struct vec_data *data) +{ + return get_descendant_rdvl(data, false); +} + static int file_read_integer(const char *name, int *val) { FILE *f; @@ -498,6 +518,14 @@ static void prctl_set_for_child(struct vec_data *data) return; } + /* _INHERIT must survive the child's exec(), check a grandchild */ + child_vl = get_descendant_rdvl(data, true); + if (child_vl != data->min_vl) { + ksft_test_result_fail("%s set %d _INHERIT but grandchild VL is %d\n", + data->name, data->min_vl, child_vl); + return; + } + ksft_test_result_pass("%s vector length was inherited\n", data->name); file_write_integer(data->default_vl_file, data->default_vl); base-commit: efded46f0a94d8e2cd7fb61aaf01be3ba1e9ee7d -- 2.43.0