Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317572; b=g6+AHlYSmvFguqur/nx5t+xv83rxUtVHwqp6uxfHugYE2CQn3QftnISWTfpLlinqUEWC X8u0LEIdviQgdxjjX9mxSB0uZMH1Pep3sQgUw6HxelcVYkhJklMAlq7q32J9wR0QoI5aw Kif/580HR5fMHFTCFuX/q5xpDH2ffOmxGGbigkQLsDHAugtC5GXqgehDofahHfbGUuCTH B+8f0WzEURkeU5a/awraAFW7m3d4B2M6YsAKXCIj6CeOMsE1cv1hf28KdmeXul+Yzwl2d WmqxABV7HP5R5rBM4zLT5BfW/bt2jDvHSnacVC41pnpjfPFU5UXGZ77Os0NbRmDF0ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796317572; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=ZSnwPl4oUNg2PFDf8oB7E9kVjcWNOaVOpvRrxHuaB18=; b=arUY9bN2onFww7eCDDp//A99zL97mLZCYNNHbxmy856Wv0/TXCsFNqXq7iAKS4NYTXRj IkqHCzBPQN+qKVmpoPe5W2AT1sEXWdB5n1nufZwE7Nc/f9Gr4whetJ1iTO8/OUgrCB+xK bu+5EF0uBLz6o1m35l3m4QHP0q1cl6ewqqH5HH5+88GP1/JzGSUa2PYBwgAzsVpC0dltu Zlc6sUK8yRl4B0AoW9exBlrNkkyQyD+a2Tf3X67/PEfn/GK9q4eBjYIRJUFriPnp4/Lik 4qnF2akq2lNdZDHe2XkM5fhv5Z4O79A/pcpcJnQeICH7DydSnNfLZX8/XJevMkNLRlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=m+X5ijU1; arc=none smtp.remote-ip=209.85.210.181 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B412606A32C for ; Thu, 3 Dec 2026 17:06:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7B412606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=m+X5ijU1 Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8b600fae14dso20198b3a.2 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=vger.kernel.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=m+X5ijU1LhbNzOEaKNdQb8911QG0FGV1b6HrLmpYKINyJ4/1muhX+GN5DNjCF+vVDT UoUBD+LutoXhDv0hoMoP4PY6t4q6BmV9pon91w1+wLL2FDTs9DQ6SKrXqJTSw+WeRAJV CPTYKmbDePZkK9MVnYV58jLBkpDetuBVT1cZ8YeACdprHLnafJxNkIgiM/zzP8KVQSFs QHPFCij/WtiZsnmaxJRbVUfxfSP/TWBMhdpaIiljFvzfK0L3UUFOZwzY36M+3Mb6/NXW DuZVGYVfpxdeMoW+HnwxQySX6CAEgZ2JDPp3M/v77YmKKAlhB1mm+yMiPi8u0FCf0Yaw 0gbw== 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=rh+0snt+Y+Q7KjbW7t4yxO8oRf788NIERIWFD+K/okI03eEr/3wyLt7GZhC8Zc/b8h 77kc3W0b/Ijr7V3vQudaZZg3fNC72ghItbNFi8UP0XKA4h38V13ifInNAMn+TnuLrNxH l0D9xialyRXGD0Gvk0F0rtQnrxBzzUZZ4A8Gt1nqA8zqofE13eZgCH8i35ViOOVD2MfU 6Ek1uMpvGLJ73HCk4LI/1xzXAhWjEUGwTv9+M5NVwwP+ALs/nSXRPt7rDx5/HqhrqBmZ RKZMfB2mHN6HlO3F2uShd8GAKWLegFufCEbCxfGRC0dClsUvPDViuu7GtpBjJs8IRQgt B4tQ== X-Forwarded-Encrypted: i=1; AL+hErFnge0WaTtNcQDqMIIc4Q9rDdD5yoc8CX7Pr5uy2PlhcVkB8m4EX3Skna0DXISD2/6gNgWfQ7um2iY819iqYAs=@vger.kernel.org X-Gm-Message-State: APuU4Z+HYOVxpARYa1pEgqpSn+ts1c3ue+DjH5yLmNk6Y/i2onclM6bD vI189VM4guPClauXdmHlY4qjIkK/gMqMDBpv/iytV2l3jHW1jqUEBt3k X-Gm-Gg: AZFdTZdX1E245nw1C3Mb/eOMb3f3TqvgA9EeO1wDVT0a2HLh4QQnLg+KQhVoqNVI8yo fQp2OARarEKgIQ1DCWcG+xA/3uc0Z0VD0c8FA75mqPhf7QxD1upVEnWg7uirURaJwr5ZTUXV0Vg M46CJTNh3Un69U6yybnGIAtiZqASS3XeX/wi0xTcFQgwfoL8eaaZFyk4b0hgYOjpNNgUZP42cRi 7D95T10K9A4/fljMugjsI79NaJD2QCD2E8GWijgu8UlZFZ/oghG1I1k+X1e7BDTlr9z1qHkTbK9 Q4NhHSnt0uoOHLqfdnMAhFTXJamnlRySBYsIo/lBscvGRNfqsLKpPakRfzOd/lEH2THbSdP1Rm1 oexiRyk0bD/cj8UB3x6coGCCBQFD715AnGihPhIZwGOZh/uLNkRQjpMJnfld4TCCgbZI9PqGbVe a4XlAee9winCloX8CrQYhF9P8/JqMrO7Dpqe0kyDw9djqTDQIR86ZlgaGwYeBmdr6SQTiE3MAxc etgQgCNis0YHZ21deho9treH1N6EFvjX/zjhpCfrPQbdhUC4icAFeGdjTbTJfMfUvwk/L8L71AR Pf7ZiVbiYMuMe6s3Y4Z39EbrP7WZF4+mkatTxYuBKLaUYa2cLWxuU4QIIAC7MhCltoQ+Hiboz8J D5TH9dx/zJqnxIRaqx/9YoNjU7PXLNh71fA== 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-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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