From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317572; b=3vwcvjl7A5APJWvpmLvhZ/bGDOAoJ/Go05bniKj5znQnLt1Aa1VDDW59Wkw/4tVcY73z x3NSi7vocVUpi5evEveFGAEzljPouZxC5XMny/PnU7dJOwvIUu8QFyrIpeaLtJpbcyfle pqOZ2Cdc1qd74kLv3sMvrOGGFZKo9eKxZeWtcaM2jHfgWcI4a2V6ZN0LVfaerPEi4Ok67 h8uFWTC6rVtuuQ9P0caSxxRsHULvz1cGdUL3UtyNvorj3RpZcyPQNfl8LUlOSToTzgq5U fvT2TV08te7Uuu0z9JlKG/ODPRnkqzPMXVSA9GpwSGSeIkx8H4qcwkFNVIYJ7UFCViw== 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=hp6YJeGWyglH+SEOugFGtVJfhmD3TyT8lv5wU2rCVCu+QKjFxElFhmDRBeoJrmlHo16A gMfXcJSOX4YyKVBW6QrrB18aFDFOsFvGg/Beraoj8YlMMldl1r2aVA0Du0ZSD4OMUipp/ r/2TYNLhuDioR3BPFuLIXLOapJCCiff2TzHM5EvSwZ9uoWIS60wpWfs6tgAeZkTo6gNvo xlKczJ7SlxD76RGZzPqPNaL45RfYW7oKtf0T3gZieKN1cKDj7lcHFxj5ZZJlcjzt8CbXA WgJ27OGrJyGz46iVXg0esRCQwski6wy7M4MIGmg0i+lx5ExEtb3jbYeUeXhNMOfRxlA== 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.180 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 6D2EF606A322 for ; Thu, 3 Dec 2026 17:06:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6D2EF606A322 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-f180.google.com with SMTP id d2e1a72fcca58-8c70c2ab5a2so21234b3a.3 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=mKrdiMolr1gZ6F3lLXSZ4R4TBXhaDAXeJ8qtwML5x6MHLN1Z5OtUhxRYAPvuIGmLiy 89ZyUyBbRE4BM+aXXotc0ihpWjpcxEx2ajm2MBU5KdyNfue8fNTjlFvNPhqwwez45P+Q ZlY0fYE7x3EVHAONEPGz/rS5taF8BrSzllXdyXFhTURnlrWxDiX9sCJ9c4sa6y+QU/il Nh71zu7u+A3UoeaWAW60Gjivx5mPxm+A7GgxMJStdhxfMIAFzohlaqD7WBc/FktjRUM4 Rd4pJ/FbqCiS5oHeGrG4Ad4Pbs0u/nAlFExYzIvLhmuSJa6wUsDBNQiA+gehsfwhggZY bsTQ== X-Forwarded-Encrypted: i=1; AL+hErGic/YN4IWcWb1Kpr6mJtfQQE7NbdQ7PNQhNN7GhaRQdOslStKQ3y4uArokBVYL5pCzGgqI2YYbc1v8Ezg=@vger.kernel.org X-Gm-Message-State: APuU4Z/EUuEWMEKHAwYOWQU5pdC472bFqp3UXmDSG6zz+0rWQPtwIXDe vkUPdJuDmpaYD/Wuunacm+IzBjcgWWA3OqlVPz7XO+R7MTHiLjUO7xLL X-Gm-Gg: AZFdTZd/pW9NlkbQiScRsgBx+ct9eJ30o5HbyXAL91sERC/cD5JAojl9JwzjeyE5LTm vEkKzCktKeKGDiOm1IEq26MirK39Xy+tm14BhVc17zQXWcXrsbfIslWsjZZ0jlMsqZIhpd8fR8j Aot6o9N2uNZT3xTZuETT7HqEfU8OxD3OknScj8Wv5fWJn74ZSp+zZs3EM+KgcESReJ6kLDwt8Kx vXlnYA1nEwEP13oyv6jjymaIL7Z//ab7a2vaTYdAfpc5HSmRDjDBEtzIjE2Nx+gAax2xEC/gLuU W4UNOwrM7ZB5At0kR6Aju+oKW3y8QEd21bpYOUwMdJcf0rwnr7cDv8xfVxRa2537HbRRvGlVo/K PqUt5DtqiC2yHovJ1Fz2mIXAfYD+/lviZHpXIeS4XRkWIinGBmBNpKuFs60PXMvor12HXqvEqCP fyH7UEawU7i0vKYkMKlIJ30PVaFpj7keixj7FekffhKVwOtjjQwgSUqHE5DyjHzGz5rpFXbdluW 8vvGCcPBY5Yp7MatBybHyGE3xQkhQv9qqXboInG/eGTHaWrculgqbFcoxc8heDTn8bKuitD7j4z zV4L2d3R+SuURfGvu4k9Jpg0TiZK1EljL4baHdWnD3v5hJYBVEfbVVYcFDPfqz5CL9Ml8BilJvf XAsf2lRKtsKwelVJSBKO8DVNFp0oQZlhTbg== 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-kernel@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