From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D359F418348; Tue, 1 Sep 2026 17:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282582; cv=none; b=UckEc0d8jESnHLXKH0FpAvKsRxrZdK0mYHxzx1ojARgKeu97aMRfQIjgrA1Gl3jNg/van3hrgC4PfiP9Q07Ve3mPSDShtFYWMmYdcTh5fhjz9xbvRFYLX95cTUC4X6FZ0Cj5fLIhuwm4+0NwKfScHehx+UaPwmTkPlb1DN5gwEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282582; c=relaxed/simple; bh=snKqfqgpbLGblFFfDtlaIFqBjQdPY6+ur0ZqOXC1eJo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tEeUMGhVcyf3E7JYjo7n8B6us1scGWf9+sXZS3ji+TgwuZDcbWQoSCUWRDlxNN9HdHF5+vOcE656jjYyOiFRSnlPvEPb2zKIV60N0PALng+otyjmjOTitkiHRnU0UeL2CeLbdjSu51OIOL21LU+1jrSCscPVvjV8aw9Vx3J4LLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GfccV3vh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GfccV3vh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C6D91F00A3A; Tue, 1 Sep 2026 17:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282580; bh=HULJndtp0Tjhll/Q5SWktZ6wE7CK9FfHbxH2HGfHzI0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=GfccV3vhxqpptjn1zxNTpPWoJOV3Atdg1depCPnGYPVctGKiKAA697Lr7jZVHjr2K 0g/xiZxJs+ElWWJNKebsZNjTF/DuB9UwUhBb6H9mprvTZT5VpEy5hIBnaO7fcI4/Te KuSXLPR404IFX3kAgli/U0DAXgPHeOIsFlOKdzv2K9GUnYVSne+JQPOnDLL/MY/Xcx tsZaHNa40MWFZUJLiDS55LTbD+pZOhv5eWBHud8JfZcItLV7TXivpPN/FjUi3omaX2 z55a/Q9kIlSmuh33k0kmiDDn4UkeX2Xb+0jjUGdVSDg3fHTkm3hIXwuJy7fIuxg+9P EOr85rtwwBFuQ== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:41 +0100 Subject: [PATCH 01/11] kselftest/arm64: Factor Linux syscalls out of asm-utils.S Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-1-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4894; i=broonie@kernel.org; h=from:subject:message-id; bh=snKqfqgpbLGblFFfDtlaIFqBjQdPY6+ur0ZqOXC1eJo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbFyvxRgj5yarSWfYu94qZF9l6oHxKOlnEtY 5f/dVPnsm6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGxQAKCRAk1otyXVSH 0HNnB/9g5R84rfeuTXzwQkrVqKRjsMHwxgvoL7Lyt1ZPR8rV5/TccRuzRs0a66TBDAwt3erBsj8 53vI6g2K2BhCdogP65GC4lyK2w1dcWXujK9aaV160czAp8e6YXwrbtOXTQOGBboz+2MjrWKJouT Mxt7FpVdo5Zi2z9egSyhGT1OzycedqYvZ12o0oTa0poJoK1R3UD3NjN0Louy69Ylp3mMqLHDHku d+iZAhv5E7PztctUD6KDRx+7cBGF6fuPNsswlcjB/CRaLSf7+XVu5NizsHcd5EyxQ3fk2eE9adE 7/mTP+LxtsJVswom8iQxSWKN9YZ19hTgUEYfrGd0Egz1Q74x X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB In preparation for building versions of the load programs for fp-stress that run as KVM guests move the functions that perform syscalls out of the shared code assembly code in asm-utils.S into a new Linux specific file asm-utils-linux.S. No functional change. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/Makefile | 17 +++++---- tools/testing/selftests/arm64/fp/asm-utils-linux.S | 43 ++++++++++++++++++= ++++ tools/testing/selftests/arm64/fp/asm-utils.S | 36 ------------------ 3 files changed, 53 insertions(+), 43 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/self= tests/arm64/fp/Makefile index d171021e4cdd..183e9d319b65 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -22,21 +22,24 @@ TEST_GEN_PROGS_EXTENDED :=3D fp-pidbench fpsimd-test \ vlset TEST_PROGS_EXTENDED :=3D fpsimd-stress sve-stress ssve-stress za-stress =20 -EXTRA_CLEAN +=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-= asm.o +EXTRA_CLEAN +=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o \ + $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o + +ASM_UTILS :=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o =20 # Build with nolibc to avoid effects due to libc's clone() support -$(OUTPUT)/fp-pidbench: fp-pidbench.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/fp-pidbench: fp-pidbench.S $(ASM_UTILS) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/fp-ptrace: fp-ptrace.c fp-ptrace-asm.S -$(OUTPUT)/fpsimd-test: fpsimd-test.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/fpsimd-test: fpsimd-test.S $(ASM_UTILS) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/rdvl-sve: rdvl-sve.c $(OUTPUT)/rdvl.o $(OUTPUT)/rdvl-sme: rdvl-sme.c $(OUTPUT)/rdvl.o $(OUTPUT)/sve-ptrace: sve-ptrace.c $(OUTPUT)/sve-probe-vls: sve-probe-vls.c $(OUTPUT)/rdvl.o -$(OUTPUT)/sve-test: sve-test.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/sve-test: sve-test.S $(ASM_UTILS) $(CC) -nostdlib $^ -o $@ -$(OUTPUT)/ssve-test: sve-test.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/ssve-test: sve-test.S $(ASM_UTILS) $(CC) -DSSVE -nostdlib $^ -o $@ $(OUTPUT)/vec-syscfg: vec-syscfg.c $(OUTPUT)/rdvl.o $(OUTPUT)/vlset: vlset.c @@ -45,10 +48,10 @@ $(OUTPUT)/za-fork: za-fork.c $(OUTPUT)/za-fork-asm.o -include ../../../../include/nolibc/nolibc.h -I../..\ -static -ffreestanding -Wall $^ -o $@ $(OUTPUT)/za-ptrace: za-ptrace.c -$(OUTPUT)/za-test: za-test.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/za-test: za-test.S $(ASM_UTILS) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/zt-ptrace: zt-ptrace.c -$(OUTPUT)/zt-test: zt-test.S $(OUTPUT)/asm-utils.o +$(OUTPUT)/zt-test: zt-test.S $(ASM_UTILS) $(CC) -nostdlib $^ -o $@ =20 include ../../lib.mk diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/tes= ting/selftests/arm64/fp/asm-utils-linux.S new file mode 100644 index 000000000000..e6c22b41dc5e --- /dev/null +++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (C) 2015-2021 ARM Limited. +// Original author: Dave Martin +// +// Utility functions for assembly code which use Linux syscalls. + +#include +#include "assembler.h" + +// Print a single character x0 to stdout +// Clobbers x0-x2,x8 +function putc + str x0, [sp, #-16]! + + mov x0, #1 // STDOUT_FILENO + mov x1, sp + mov x2, #1 + mov x8, #__NR_write + svc #0 + + add sp, sp, #16 + ret +endfunction +.globl putc + +// Print a NUL-terminated string starting at address x0 to stdout +// Clobbers x0-x3,x8 +function puts + mov x1, x0 + + mov x2, #0 +0: ldrb w3, [x0], #1 + cbz w3, 1f + add x2, x2, #1 + b 0b + +1: mov w0, #1 // STDOUT_FILENO + mov x8, #__NR_write + svc #0 + + ret +endfunction +.globl puts diff --git a/tools/testing/selftests/arm64/fp/asm-utils.S b/tools/testing/s= elftests/arm64/fp/asm-utils.S index 4b9728efc18d..6d43eb10e01f 100644 --- a/tools/testing/selftests/arm64/fp/asm-utils.S +++ b/tools/testing/selftests/arm64/fp/asm-utils.S @@ -4,44 +4,8 @@ // // Utility functions for assembly code. =20 -#include #include "assembler.h" =20 -// Print a single character x0 to stdout -// Clobbers x0-x2,x8 -function putc - str x0, [sp, #-16]! - - mov x0, #1 // STDOUT_FILENO - mov x1, sp - mov x2, #1 - mov x8, #__NR_write - svc #0 - - add sp, sp, #16 - ret -endfunction -.globl putc -=09 -// Print a NUL-terminated string starting at address x0 to stdout -// Clobbers x0-x3,x8 -function puts - mov x1, x0 - - mov x2, #0 -0: ldrb w3, [x0], #1 - cbz w3, 1f - add x2, x2, #1 - b 0b - -1: mov w0, #1 // STDOUT_FILENO - mov x8, #__NR_write - svc #0 - - ret -endfunction -.globl puts - // Print an unsigned decimal number x0 to stdout // Clobbers x0-x4,x8 function putdec --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16CD9486656; Tue, 1 Sep 2026 17:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282584; cv=none; b=EuplwMpdvE1B3Nvsh8uj743lZUx0Zc8LtBK12CBeZKstwXoCZzOQp7M6ooODUpqM1pZiaZSE+Xbe8gG//3Z8fkrIcmIJAbVNIxUUo1YKM+Ol/oa8K6zP6mCXuzfvufmSmd8W6lP4JGJxdAnYh34S7ABZOqBfHRWE8hfAVV68f6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282584; c=relaxed/simple; bh=RUm+OmsCqb1Gk0GBEixjr9Ge7JmaFMl9sztHiFSBLFk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fV+hZIbr4FosVtAk7TzIYmQZptfrFXS98Yj9NxPPlGuROzmptHhiyYp2PO2PqKNwANvUiEzEuPNge5IpooIKmc7CBJ8+sQUxm4F0FpZceFKZTnSNKCDjy6mdo1YUsdpIQ/SQ9CFuVuH+GsLY374b822oYOPStY1aPfuhwp8BP8I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M8dNKu3/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M8dNKu3/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E494C1F000E9; Tue, 1 Sep 2026 17:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282583; bh=jF5y9L+l3jNt20qPhgwwrkHDJKBrYSzsOIzrzqXhq2w=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=M8dNKu3/YOT7vpbR9f4HLYY4F751R7JlZIubqKgxCTrnrN86cMUnzO2FQK6+JhI9c GoZWLX92lk9Jaffs06LfbPBZGBEX+YqSuIqAPQXzScpbeMw0fOcwqPkeFryxkD6JYg va0V+i5cbDtFcjtsJLc1T9pLialrMv3fbbys8mckyms3C+wB6kSylg8JheNfF0iP0R JvfIq18FLBSO6IgFDvR3nOKZ4Qch8KSfXZsUIpaTBX7cavQMck/AxA5JndX7ZVM/ye DtQcUI3zG9qqRFLwByUMmKBuBPOtkWbncQ/MFN89frLFf8fOfVy48jBuBujuLNSwOl C3F26wvFrfbsQ== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:42 +0100 Subject: [PATCH 02/11] kselftest/arm64: Factor shared signal handlers out of fp-stress loads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-2-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8112; i=broonie@kernel.org; h=from:subject:message-id; bh=RUm+OmsCqb1Gk0GBEixjr9Ge7JmaFMl9sztHiFSBLFk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbG/hXeR6h2D1b6d8tkkH+2fP8TFm0f8NWHs 7r+mE7iMAmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGxgAKCRAk1otyXVSH 0CKuB/9JKo1etOWICqzLxdOFGeZTIBxbPPlSLA7tedxD9XUR+ktF9V01dk7HVFxWcr6SwFhxNwt ZnE2URyXMyHr7fJ7iftTwlUoL88PY2vNTFCqrZDOev4P3kbT29WHhS151Ea4bzA5/Ug2Dce2FKZ 7dUjpK3FZaZvCKM/Y3bP7bk9gmGs3/QeLRhYvDo0pp8FsEHPuq2tsCQN7/4ZVCmP0xJT38vH/7a SAOoodPBT4X38ewzldXYhWfMGKdmFLpHQneiPAvr8z6jCADOoxE9jmMKdQjCkHeARYuWUT5IpyM y3OeT63WnlOzoP/YgguGZsVQw9Nq5y5BCays+wP2sSk3xEcA X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB The assembly programs run by fp-stress all have identical signal handlers for cleanly exiting the program and simply countil signal deliveries, consolidate them into a single copies in asm-utils-linux.S. No functional change. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/Makefile | 14 +++---- tools/testing/selftests/arm64/fp/asm-utils-linux.S | 43 ++++++++++++++++++= ++++ tools/testing/selftests/arm64/fp/fpsimd-test.S | 28 -------------- tools/testing/selftests/arm64/fp/sve-test.S | 28 -------------- tools/testing/selftests/arm64/fp/za-test.S | 28 -------------- tools/testing/selftests/arm64/fp/zt-test.S | 28 -------------- 6 files changed, 50 insertions(+), 119 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/self= tests/arm64/fp/Makefile index 183e9d319b65..d92a755837ff 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -25,21 +25,21 @@ TEST_PROGS_EXTENDED :=3D fpsimd-stress sve-stress ssve-= stress za-stress EXTRA_CLEAN +=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o \ $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o =20 -ASM_UTILS :=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o +ASM_UTILS_LINUX :=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o =20 # Build with nolibc to avoid effects due to libc's clone() support -$(OUTPUT)/fp-pidbench: fp-pidbench.S $(ASM_UTILS) +$(OUTPUT)/fp-pidbench: fp-pidbench.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/fp-ptrace: fp-ptrace.c fp-ptrace-asm.S -$(OUTPUT)/fpsimd-test: fpsimd-test.S $(ASM_UTILS) +$(OUTPUT)/fpsimd-test: fpsimd-test.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/rdvl-sve: rdvl-sve.c $(OUTPUT)/rdvl.o $(OUTPUT)/rdvl-sme: rdvl-sme.c $(OUTPUT)/rdvl.o $(OUTPUT)/sve-ptrace: sve-ptrace.c $(OUTPUT)/sve-probe-vls: sve-probe-vls.c $(OUTPUT)/rdvl.o -$(OUTPUT)/sve-test: sve-test.S $(ASM_UTILS) +$(OUTPUT)/sve-test: sve-test.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ -$(OUTPUT)/ssve-test: sve-test.S $(ASM_UTILS) +$(OUTPUT)/ssve-test: sve-test.S $(ASM_UTILS_LINUX) $(CC) -DSSVE -nostdlib $^ -o $@ $(OUTPUT)/vec-syscfg: vec-syscfg.c $(OUTPUT)/rdvl.o $(OUTPUT)/vlset: vlset.c @@ -48,10 +48,10 @@ $(OUTPUT)/za-fork: za-fork.c $(OUTPUT)/za-fork-asm.o -include ../../../../include/nolibc/nolibc.h -I../..\ -static -ffreestanding -Wall $^ -o $@ $(OUTPUT)/za-ptrace: za-ptrace.c -$(OUTPUT)/za-test: za-test.S $(ASM_UTILS) +$(OUTPUT)/za-test: za-test.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ $(OUTPUT)/zt-ptrace: zt-ptrace.c -$(OUTPUT)/zt-test: zt-test.S $(ASM_UTILS) +$(OUTPUT)/zt-test: zt-test.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ =20 include ../../lib.mk diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/tes= ting/selftests/arm64/fp/asm-utils-linux.S index e6c22b41dc5e..3effeb1fbf50 100644 --- a/tools/testing/selftests/arm64/fp/asm-utils-linux.S +++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S @@ -6,6 +6,7 @@ =20 #include #include "assembler.h" +#include "asm-offsets.h" =20 // Print a single character x0 to stdout // Clobbers x0-x2,x8 @@ -41,3 +42,45 @@ function puts ret endfunction .globl puts + +// Signal handler which reports a clean exit and terminates the program. +// The tests keep their iteration count in x22 and their signal count in +// x23, report those from the interrupted context. +// +// w0: signal number +// x2: ucontext +function terminate_handler + mov w21, w0 + mov x20, x2 + + puts "Terminated by signal " + mov w0, w21 + bl putdec + puts ", no error, iterations=3D" + ldr x0, [x20, #ucontext_regs + 8 * 22] + bl putdec + puts ", signals=3D" + ldr x0, [x20, #ucontext_regs + 8 * 23] + bl putdecn + + mov x0, #0 + mov x8, #__NR_exit + svc #0 +endfunction +.globl terminate_handler + +// Signal handler which only records that the program was interrupted. +// The tests keep their signal count in x23, update that in the +// interrupted context. +// +// w0: signal number +// x2: ucontext +function tickle_handler + // Increment the signal count (x23): + ldr x0, [x2, #ucontext_regs + 8 * 23] + add x0, x0, #1 + str x0, [x2, #ucontext_regs + 8 * 23] + + ret +endfunction +.globl tickle_handler diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing= /selftests/arm64/fp/fpsimd-test.S index f89d67894c2e..9db7b5419397 100644 --- a/tools/testing/selftests/arm64/fp/fpsimd-test.S +++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S @@ -149,34 +149,6 @@ function irritator_handler ret endfunction =20 -function tickle_handler - // Increment the signal count (x23): - ldr x0, [x2, #ucontext_regs + 8 * 23] - add x0, x0, #1 - str x0, [x2, #ucontext_regs + 8 * 23] - - ret -endfunction - -function terminate_handler - mov w21, w0 - mov x20, x2 - - puts "Terminated by signal " - mov w0, w21 - bl putdec - puts ", no error, iterations=3D" - ldr x0, [x20, #ucontext_regs + 8 * 22] - bl putdec - puts ", signals=3D" - ldr x0, [x20, #ucontext_regs + 8 * 23] - bl putdecn - - mov x0, #0 - mov x8, #__NR_exit - svc #0 -endfunction - // w0: signal number // x1: sa_action // w2: sa_flags diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index 7ef7835389e7..2aadb5c3c0f3 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -317,34 +317,6 @@ function irritator_handler ret endfunction =20 -function tickle_handler - // Increment the signal count (x23): - ldr x0, [x2, #ucontext_regs + 8 * 23] - add x0, x0, #1 - str x0, [x2, #ucontext_regs + 8 * 23] - - ret -endfunction - -function terminate_handler - mov w21, w0 - mov x20, x2 - - puts "Terminated by signal " - mov w0, w21 - bl putdec - puts ", no error, iterations=3D" - ldr x0, [x20, #ucontext_regs + 8 * 22] - bl putdec - puts ", signals=3D" - ldr x0, [x20, #ucontext_regs + 8 * 23] - bl putdecn - - mov x0, #0 - mov x8, #__NR_exit - svc #0 -endfunction - // w0: signal number // x1: sa_action // w2: sa_flags diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index 9c33e13e9dc4..84e63e510f23 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -162,34 +162,6 @@ function irritator_handler ret endfunction =20 -function tickle_handler - // Increment the signal count (x23): - ldr x0, [x2, #ucontext_regs + 8 * 23] - add x0, x0, #1 - str x0, [x2, #ucontext_regs + 8 * 23] - - ret -endfunction - -function terminate_handler - mov w21, w0 - mov x20, x2 - - puts "Terminated by signal " - mov w0, w21 - bl putdec - puts ", no error, iterations=3D" - ldr x0, [x20, #ucontext_regs + 8 * 22] - bl putdec - puts ", signals=3D" - ldr x0, [x20, #ucontext_regs + 8 * 23] - bl putdecn - - mov x0, #0 - mov x8, #__NR_exit - svc #0 -endfunction - // w0: signal number // x1: sa_action // w2: sa_flags diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index a8df05771670..afcadb5aff23 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -131,34 +131,6 @@ function irritator_handler ret endfunction =20 -function tickle_handler - // Increment the signal count (x23): - ldr x0, [x2, #ucontext_regs + 8 * 23] - add x0, x0, #1 - str x0, [x2, #ucontext_regs + 8 * 23] - - ret -endfunction - -function terminate_handler - mov w21, w0 - mov x20, x2 - - puts "Terminated by signal " - mov w0, w21 - bl putdec - puts ", no error, iterations=3D" - ldr x0, [x20, #ucontext_regs + 8 * 22] - bl putdec - puts ", signals=3D" - ldr x0, [x20, #ucontext_regs + 8 * 23] - bl putdecn - - mov x0, #0 - mov x8, #__NR_exit - svc #0 -endfunction - // w0: signal number // x1: sa_action // w2: sa_flags --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4CED48424C; Tue, 1 Sep 2026 17:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282587; cv=none; b=HrZG5/9mCtls6BQ3n4UM0bID4RCXyfqIixQ4b2hcOpS/E6SqC0cPeBSWyCar9mg4NS6gvXgH5WVoGMOrGKecqYK4kk86O2cpuwnDrov310riNs9SnH0jiggT9vElxxaKppCOve3NMjQYMjw4xxsQWMStZ/fl13mpuDM1WzBY25g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282587; c=relaxed/simple; bh=AQJq+CKXY/YCxbx3S1Crh5Cc+9JzITkjPfuPVDoNhoc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EX2GnIpNZrT/ZpIKe93pdSBBnJt5dYxx7Yp1qOj3tDlqob+RERPmFtuorpmnXGB6yhHhoh/DfqcqRf6N+xfPZ7kf9WYbcr8UPchlTq/JXia7QfCQZ1wlJgCS5a+UeUUBwvHsg99aHIoYX8VIaOylZn/S27PdxMN0eOeDwErmaw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pd0feej7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pd0feej7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690991F00A3A; Tue, 1 Sep 2026 17:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282585; bh=Cdp+bm1mdsMMRA3P0qz+QQPcUs8yHc+X7Osf02oZ5Qw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Pd0feej7bCnza9zZEMqhBC3w90bucu6KzIr8hEX72OUdzVI2njA1yZUHto8h4UoNW hzxqY1CQbw95fcDAdFnnL3NU/zW2TzbmIAlSjBP9nzWBa2Y42gaBM9hpdcpf+lqGjq D2Gqr1VJwQXnBginPxBtGtWaSWBle22suBt7fm4uw7HmKhDxVQY4e1doB94vKLRxIn 25ZJFQHrto7M385QfVgM0vhjQhqkO2ybDhvDMDMD7m0NydABtBL1wis3HgX6hXQILF qblwee1CnSoNP7hkQgywrhFiJN5nhI1DsytnLKsxFYjG33kfKbA4L9A5vvn0iX/nJG v7gPW24XV8h2Q== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:43 +0100 Subject: [PATCH 03/11] kselftest/arm64: Move exit calls out of fp-stress loads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-3-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3155; i=broonie@kernel.org; h=from:subject:message-id; bh=AQJq+CKXY/YCxbx3S1Crh5Cc+9JzITkjPfuPVDoNhoc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbHHFWOQ5yPW6+rAaHtNdLqXYsj8Uz/tFY2L tVS1NUTbBGJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGxwAKCRAk1otyXVSH 0ChRB/90PovUmXRmKPEgEabP3rDR1mrNE5tvMok5jLUuu1q2XpGtIlbJ+1nzLn2N5Gscr8HjBF/ 0e6As3B3kXkYRFRJQLyve9kKIvYZdv1TcAEzIesDQ7k7clTLABOXlONt8wI2/tUmXcSVWdFjdaO fHn6B3KW5AJTesIUBTWKLCC7NTtiP/n1Jv06VfF0hu1OwltkNO3W3djK9zw0L16mEkuCCkK/UuP ktqi6uPBEeqbomvIJhUQl2k5BoXgoubdKqKu5S2CnwvQlbziPAoGhwCDahAlLM2I2zPO0kaOCG2 s78pRkwGy6qx+RKt5PAh9MulmcWzVNHMFCUzTOCca6Oe0AQ0 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB When they detect corruption the fp-stress test loads print load specific diagnostics and exits with a failure status. In preparation for building versions intended to run as KVM guests factor the exits into asm-utils-linux.S. No functional change. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/asm-utils-linux.S | 8 ++++++++ tools/testing/selftests/arm64/fp/fpsimd-test.S | 4 +--- tools/testing/selftests/arm64/fp/sve-test.S | 8 ++------ tools/testing/selftests/arm64/fp/za-test.S | 8 ++------ tools/testing/selftests/arm64/fp/zt-test.S | 4 +--- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/tes= ting/selftests/arm64/fp/asm-utils-linux.S index 3effeb1fbf50..9cd31dc47709 100644 --- a/tools/testing/selftests/arm64/fp/asm-utils-linux.S +++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S @@ -84,3 +84,11 @@ function tickle_handler ret endfunction .globl tickle_handler + +// Terminate the program, reporting failure. Does not return. +function exit_error + mov x0, #1 + mov x8, #__NR_exit + svc #0 +endfunction +.globl exit_error diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing= /selftests/arm64/fp/fpsimd-test.S index 9db7b5419397..5ee8ef51ea4e 100644 --- a/tools/testing/selftests/arm64/fp/fpsimd-test.S +++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S @@ -298,7 +298,5 @@ function barf bl dumphex puts "]\n" =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index 2aadb5c3c0f3..3447fe0e5554 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -543,9 +543,7 @@ function vl_barf mov x0, x10 bl putdecn =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction =20 function svcr_barf @@ -555,7 +553,5 @@ function svcr_barf mov x0, x10 bl putdecn =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index 84e63e510f23..33dc4ce8bfa1 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -354,9 +354,7 @@ function vl_barf mov x0, x10 bl putdecn =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction =20 function svcr_barf @@ -366,7 +364,5 @@ function svcr_barf mov x0, x10 bl putdecn =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index afcadb5aff23..c67242c2d5ab 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -284,7 +284,5 @@ function svcr_barf mov x0, x10 bl putdecn =20 - mov x8, #__NR_exit - mov x1, #1 - svc #0 + b exit_error endfunction --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5607C48875D; Tue, 1 Sep 2026 17:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282589; cv=none; b=lvwWubEMvFkQw3zCscj06Aev9AgqQYhIt4BwOPNf2NsY5vclcCbtrVwmOXR3xBd/qtgilC3ZJZ72A99di6qJTFlAw1XiNFoRKbu4TaLrk1e5OlsMBU7P9Xb+d4hznqHv0EpNPyN91rjz//yFnt1wpMSNFXEhh8m6Tfn9muoxAJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282589; c=relaxed/simple; bh=FXUiqfWAxLn/rDMJ8bXvf0uXEP+dmfnB7tIwO5Ir/ek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fyI727BWv2p+tTZNMsFrSAoxuC5p3YVQM+2zQWsi5I4f8mw/fmEQyn/Kv0T2wPjLeSBlTOJQfXmG5WkfGLxcGmQruoNiAS3xFKInYrlB5S6Ku7m8EFV2iWGFBcYs1hkVHkvaD9J3DWQVjjFcptXASIP4t/ZbSiZRPTRA7vy3iRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q+PG/KP5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q+PG/KP5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E44931F000E9; Tue, 1 Sep 2026 17:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282588; bh=9xPD/724Mzj6/cTLTKyYHK6fDZVywVJCjXBWuB9RfxI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Q+PG/KP5Pss+s8uN4aaomcoQyQpjWFzFcdwBSWka/ekfc6gl01Yl4Zd4X73QeIkm6 EzuHqQyMKzm6nUh+u9DpfnQZMRLFRrJJpsqlN1yMPqN/+WUittI5Z9OsYzQ1CdaEuw AdS1X8J9Y9O6vzlGnNa73DAkcHRBk8E5QNiUb0ASF32sWdTC3dfex08gMAnJjwqAm3 ymOU5Iwg2rJ1ohAdta9FpQv4kCIpehE4XO+BmV+Kx1V1W6bWwexgmx5IuNhwwlVGD0 cppB1gU2DCR6t7FFjSMYeJXnJ+tVVBfI6MWS3RzQglqispN2Af/s5TmBfXFv5P1t2W RA+ZgDn8OlOlw== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:44 +0100 Subject: [PATCH 04/11] kselftest/arm64: Use exit_error() rather than SIGABRT in fp-stress Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-4-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3760; i=broonie@kernel.org; h=from:subject:message-id; bh=FXUiqfWAxLn/rDMJ8bXvf0uXEP+dmfnB7tIwO5Ir/ek=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbHeVsYcbve7l+7wqdI6RQc91yq/6IcwfQcS eSWseNyoZiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGxwAKCRAk1otyXVSH 0Bg+B/0R6Wq1KDKm5O+KFzeu3nmryrSKKA1NlfpMPg1wFMpjn5bR3DgNNpI3zndXgqg+S+Jz9ou /3xMqeNDCnpqiHNeLbVuaKm7EaKTkjoI3ZxW1hEF7g06EtzpB4/I4FKnjs688k8vtsRQ20kpchM i0NXDz7PxOGt+uCjkj19Av0KPw3xe3F62nlOXcTAjb77IJIvGswSOlSL6rn2trzssU91XWcs2M7 om+jjrlrrZG8chv+87sCJipdhweiecG1h+Q7shspQ/Mu57ktQGdvojpzc9MybSRBKk23i9AKnu/ HaTndkgQ63pe5M+LmS2Nc0ErPx2DPadCfOuefqsq8uuu6yxP X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB The fp-stress test loads all deliver a SIGABRT to the process group to report some errors they detect. There is no particular reason to use this mechanism over exiting with an error code, the fp-stress harness does not care. In order to facilitate running as KVM guests replace this with use of the exit_error() function we added. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fpsimd-test.S | 10 ++-------- tools/testing/selftests/arm64/fp/sve-test.S | 10 ++-------- tools/testing/selftests/arm64/fp/za-test.S | 10 ++-------- tools/testing/selftests/arm64/fp/zt-test.S | 8 +------- 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing= /selftests/arm64/fp/fpsimd-test.S index 5ee8ef51ea4e..fcbb3a872490 100644 --- a/tools/testing/selftests/arm64/fp/fpsimd-test.S +++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S @@ -176,7 +176,7 @@ function setsignal cbz w0, 1f =20 puts "sigaction failure\n" - b .Labort + b exit_error =20 1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) ret @@ -224,7 +224,7 @@ function _start 1: puts "Bad vector length: " mov x0, x19 bl putdecn - b .Labort + b exit_error =20 2: puts "Vector length:\t" mov x0, x19 @@ -266,12 +266,6 @@ function _start =20 add x22, x22, #1 b .Ltest_loop - -.Labort: - mov x0, #0 - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 endfunction =20 function barf diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index 3447fe0e5554..26efdbdd88f9 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -344,7 +344,7 @@ function setsignal cbz w0, 1f =20 puts "sigaction failure\n" - b .Labort + b exit_error =20 1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) ret @@ -397,7 +397,7 @@ function _start 1: puts "Bad vector length: " mov x0, x19 bl putdecn - b .Labort + b exit_error =20 2: puts "Vector length:\t" mov x0, x19 @@ -474,12 +474,6 @@ function _start =20 add x22, x22, #1 b .Ltest_loop - -.Labort: - mov x0, #0 - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 endfunction =20 function barf diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index 33dc4ce8bfa1..7208bb2db9f1 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -189,7 +189,7 @@ function setsignal cbz w0, 1f =20 puts "sigaction failure\n" - b .Labort + b exit_error =20 1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) ret @@ -240,7 +240,7 @@ function _start 1: puts "bad vector length: " mov x0, x19 bl putdecn - b .Labort + b exit_error =20 2: puts "vector length:\t" mov x0, x19 @@ -288,12 +288,6 @@ function _start =20 add x22, x22, #1 // Everything still working b .Ltest_loop - -.Labort: - mov x0, #0 - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 endfunction =20 function barf diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index c67242c2d5ab..c6cfbdeb2f0c 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -158,7 +158,7 @@ function setsignal cbz w0, 1f =20 puts "sigaction failure\n" - b .Labort + b exit_error =20 1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) ret @@ -222,12 +222,6 @@ function _start =20 add x22, x22, #1 // Everything still working b .Ltest_loop - -.Labort: - mov x0, #0 - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 endfunction =20 function barf --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECEDD489866; Tue, 1 Sep 2026 17:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282592; cv=none; b=X4OlM3fOCMU76IdCi0XNVeJ6Wuh5HuyBGEbCFl89RE3mqw6eOCexrU6vvHMiswqhfubuMMc1CPJ4G/pF4nMeMBXTtXW5BvN9vkVCraFWpnt7lSxuZBd6zpSta1THIg/NbfwGqWl5XL8IdgDp4YFBQcD5X22Oc+tN8s0h12DyTz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282592; c=relaxed/simple; bh=yDqcvWjmApZFYi3sYMgKyJQuc1WrRv18LtEuTPnRUWI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CpOqV1ffsUwxYUhh3548MhBlGkU4bk6TZA1eIj/lRdQnQCMWsg/HwUIRei97UgY5dijJaN99tpK75wgtLN2ov8yMmrpJ+PSRmiDC7TZ5mvWKj4cMDz92S2HZvpI5CExZF9m5/3gtojfCE8rb/Muu+0hqMkuuXfzBrMZqGrCOFj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=abaNRV00; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="abaNRV00" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 692BE1F00A3A; Tue, 1 Sep 2026 17:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282590; bh=IIoWTUlvXX13Appnh+taaKXv0sle6+B+jUGuGwjmcYU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=abaNRV004TpvAQQP7LZEvPQGAs4yksHJQQ/KT6RR4k+deK/NPHpKXJwKmKwa+eURu XJsOh6v7k+ZETIqRlc2R6X2jN/YFQfjaqcMBz2R14sNyp7SLoki2K5tbhsQciVRw/c lFvtk7jV0xjGV56U8XgwZZWSovbPxtjdmMzwqgOCmHWCY+9Vdyw27BPXe4SshI1t1N rfIZom5sn6kNBcA8Na4+5mSiYX7KdOD/hVd6/Ciq1KkDQ1VOxZ+tqdv3nOTvKK4Wk6 LLC8Ah67V1PcSgKCeWIsiFIQ+44cGxVXrpbZZCJTgjH4tFmogxsSxEGVUSAiX0SYuK PbiQ973CQDj5g== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:45 +0100 Subject: [PATCH 05/11] kselftest/arm64: Exit with an error code on data mismatches in fp-stress Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-5-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2794; i=broonie@kernel.org; h=from:subject:message-id; bh=yDqcvWjmApZFYi3sYMgKyJQuc1WrRv18LtEuTPnRUWI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbIHH7Ri4sFF3IW6/0tYNw/ZUaW+ah8bbzQL aN/igojoZyJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGyAAKCRAk1otyXVSH 0MXeB/sFbb8V+tj0pCZ5OSMtZxsUjQT6dJfd86NDA8ZTYwKfbO5pvXjEFM0kSO4x5TbJ3gdnxQN k5WPUq1WZMmJ8qYqw8XCgK/qju9o7V61Ewk8zzEylV7LFC7KTI+720fpe7spBtzTOENkOnqxLSi u1uUQ5SquRyQWdS6WgmuogF1iwLFiHjjC4Zefky+OD4bQtf1EYe+pVDbR8THTNv4h0+KGxHVFYj 98V988a4EJ273T9tKm+FTYgQJw9SKiILQ00/Jt9rj9mJyOnlwDxjYPVipf5RyWAcpkf9JgSGG/V SFC0XDJE90W0Mv7RElwZ2Si04UY8gpwQi1m+oVP9OGml8o1P X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Several of the fp-stress test loads have blocks at the end of their barf functions with a range of commented out options for how to exit the program after logging an error. Comments indicate that these were intended to interact with some long gone debugging code in the kernel. At the minute the option selected by all the programs is to delivera SIGABRT to themselves but there is no need to do this over a normal exit with a non zero status. In order to facilitate running as a KVM guest replace these repeated blocks with calls to exit_error(), this will integrate just as well with the fp-stress harness. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-test.S | 14 +------------- tools/testing/selftests/arm64/fp/za-test.S | 14 +------------- tools/testing/selftests/arm64/fp/zt-test.S | 14 +------------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index 26efdbdd88f9..88c3220caf7c 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -515,19 +515,7 @@ function barf bl putdecn #endif =20 - mov x8, #__NR_getpid - svc #0 -// fpsimd.c acitivty log dump hack -// ldr w0, =3D0xdeadc0de -// mov w8, #__NR_exit -// svc #0 -// ^ end of hack - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 -// mov x8, #__NR_exit -// mov x1, #1 -// svc #0 + b exit_error endfunction =20 function vl_barf diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index 7208bb2db9f1..4a5b4b37d475 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -326,19 +326,7 @@ function barf mov x0, x13 bl putdecn =20 - mov x8, #__NR_getpid - svc #0 -// fpsimd.c acitivty log dump hack -// ldr w0, =3D0xdeadc0de -// mov w8, #__NR_exit -// svc #0 -// ^ end of hack - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 -// mov x8, #__NR_exit -// mov x1, #1 -// svc #0 + b exit_error endfunction =20 function vl_barf diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index c6cfbdeb2f0c..82a76bb2307a 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -256,19 +256,7 @@ function barf mov x0, x13 bl putdecn =20 - mov x8, #__NR_getpid - svc #0 -// fpsimd.c acitivty log dump hack -// ldr w0, =3D0xdeadc0de -// mov w8, #__NR_exit -// svc #0 -// ^ end of hack - mov x1, #SIGABRT - mov x8, #__NR_kill - svc #0 -// mov x8, #__NR_exit -// mov x1, #1 -// svc #0 + b exit_error endfunction =20 function svcr_barf --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1198B489869; Tue, 1 Sep 2026 17:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282594; cv=none; b=r5MtwA9FXGZYbxnfMyqj7FkP9s2FWEmWOdw3r5bbAScy12Vxz4Ozqn/4ZCna0hjWpdjwCKkaL2s/JTeTtUTeSfggWpNADzIQ2jhqQpff1x2832STQw5tdXT+cl9PNiAY2bLFkoyS3/vLIClICR71sTZvjtR5JeY4v1rPZzNaRzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282594; c=relaxed/simple; bh=S8t6QheLhHSURbpl7NHhjC/DVyDqCCCCmMoeH1vfA4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PCZ6oQ9sDmvy02HjR/9TtqipG6D00mI8Ov4pST6o52qVheBxBtbQjummigiTiLStWdBuRYJgveNgh9taCs81716nNVyJk9iZOyTBPOrq9MIzi2rh0H4122ipJQGzkODQSagqurcdMVtRFKYO4IGJ/3cOcrKfRQosmpOotSXq6rw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SioKBrYb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SioKBrYb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0DB91F000E9; Tue, 1 Sep 2026 17:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282593; bh=4BpEenBswVIoaAlsrWaWaf3Pka8VbbWtdA3TAEWiAV0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=SioKBrYb8qTj4njJifEcDCZ1UK4qp3zpgTY80bfidvL7Zd6u8M7g7ISNFHDx/NgDv B/oUbMDABMR5GQvkruxZsxpjPSbur5qV1D4zgeLm8seWWS0rWMWopBf2AvKntR/uLU 4j6kiyxYnXleJ4+5L8mZNi7C4UecGzyvR7K1jQ8gyaPdksWlkcssrzTqFMGZuU9UNk UPOyVD4ehgCPUEhDQeTa7lBsXn/Yre9rKdybE5oXaqqkhzJF3TqerymxuJILC+wxQU r4xux6wbJXmyPHxr/1eGPSgDHAbwutQ1+E+54hwmaCl0dPkjCRPo2+ktnhyWTjXwPe +K/0t3sM2Xcvg== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:46 +0100 Subject: [PATCH 06/11] kselftest/arm64: Factor startup code out of fp-stress load programs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-6-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=11923; i=broonie@kernel.org; h=from:subject:message-id; bh=S8t6QheLhHSURbpl7NHhjC/DVyDqCCCCmMoeH1vfA4g=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbJ5bgNtxthm8Onze9Cn3GUO1zLRHfE0E0du wROVIkc2Z6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGyQAKCRAk1otyXVSH 0OeNB/9e6XCd6LhFJy711KXT0mNm7ajGHAMDxZykfZnSEB3Y4Ag71a776L9nvZQn0HJCgBz69/e c0+3qMR7+8CARDdiTQHwtU3pT9tf63EUcIT9/Aueyo+fhFddIUTeTA1i9EgIEVNIWJ9GQ7PLnUF byliphl1HLazLAAL6ydWiCwVa1+/E4opm1UQkxKIJb9nwvXxUXcRdgIuwvhmDq+s61n2MV5YJC5 qBHThinP1PwAiqv+M1kuJRjQYl8KMTTs0RmIK69rU6KseYV67a4O6bAZaot2DzeL8l4TwlWIbj1 LYhenqgX3Sh+g7DChykTVrbqJFUoj0KlV9kFgWBcJkK2Tren X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB The fp-stress load programs all start up with some startup code which installs signal handlers and fetches and reports the current PID into x20. In order to facilitate running as KVM guests and reduce duplication factor this code out into a asm-utils-linux.S, making the per-test entry point main() similarly to more normal environments. As the irritator_handler varies per test they are left in place. Since the PID is now reported before main() runs it is printed before rather than after the vector length for those programs that report one, fp-stress does not parse the output so this has no impact. Since asm-utils is also used by fp-pidbench that also gets converted to the new _start implementation, this will install some signal handlers that were not previously there and report a PID which was not previously reported but should otherwise have no impact. Since it does not need an irritator none is provided and a weak definition left in asm-utils-linux.S, this will end up as 0 which happens to be SIG_DFL which is what we would have anyway. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/asm-utils-linux.S | 87 ++++++++++++++++++= ++++ tools/testing/selftests/arm64/fp/fp-pidbench.S | 6 +- tools/testing/selftests/arm64/fp/fpsimd-test.S | 76 +------------------ tools/testing/selftests/arm64/fp/sve-test.S | 76 +------------------ tools/testing/selftests/arm64/fp/za-test.S | 75 +------------------ tools/testing/selftests/arm64/fp/zt-test.S | 75 +------------------ 6 files changed, 106 insertions(+), 289 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/asm-utils-linux.S b/tools/tes= ting/selftests/arm64/fp/asm-utils-linux.S index 9cd31dc47709..9519be4d8f1e 100644 --- a/tools/testing/selftests/arm64/fp/asm-utils-linux.S +++ b/tools/testing/selftests/arm64/fp/asm-utils-linux.S @@ -92,3 +92,90 @@ function exit_error svc #0 endfunction .globl exit_error + +// Install a signal handler +// +// w0: signal number +// x1: sa_action +// w2: sa_flags +// Clobbers x0-x6,x8 +function setsignal + str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]! + + mov w4, w0 + mov x5, x1 + mov w6, w2 + + add x0, sp, #16 + mov x1, #sa_sz + bl memclr + + mov w0, w4 + add x1, sp, #16 + str w6, [x1, #sa_flags] + str x5, [x1, #sa_handler] + mov x2, #0 + mov x3, #sa_mask_sz + mov x8, #__NR_rt_sigaction + svc #0 + + cbz w0, 1f + + puts "sigaction failure\n" + b exit_error + +1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) + ret +endfunction +.globl setsignal + +// Programs which want to be interrupted by SIGUSR1 provide an +// irritator_handler(), for those that don't the signal is left alone. +.weak irritator_handler + +// Main program entry point. Install the signal handlers shared by the +// programs, zeroing the signal count in x23 that the handlers maintain, +// read and report the PID the programs use for uniqueness in x20, then +// run the program specific main(). +.globl _start +function _start + enable_gcs + + mov x23, #0 // signal count + + mov w0, #SIGINT + adr x1, terminate_handler + mov w2, #SA_SIGINFO + bl setsignal + + mov w0, #SIGTERM + adr x1, terminate_handler + mov w2, #SA_SIGINFO + bl setsignal + + // Load as a literal, adr can't reference the symbol when the + // program provides no handler and it resolves to 0 + ldr x1, =3Dirritator_handler + cbz x1, 1f + mov w0, #SIGUSR1 + mov w2, #SA_SIGINFO + orr w2, w2, #SA_NODEFER + bl setsignal + +1: mov w0, #SIGUSR2 + adr x1, tickle_handler + mov w2, #SA_SIGINFO + orr w2, w2, #SA_NODEFER + bl setsignal + + // Obtain our PID, to ensure test pattern uniqueness between processes + mov x8, #__NR_getpid + svc #0 + mov x20, x0 + + puts "PID:\t" + mov x0, x20 + bl putdecn + + b main +endfunction diff --git a/tools/testing/selftests/arm64/fp/fp-pidbench.S b/tools/testing= /selftests/arm64/fp/fp-pidbench.S index 881dfa3b342e..80f45560290d 100644 --- a/tools/testing/selftests/arm64/fp/fp-pidbench.S +++ b/tools/testing/selftests/arm64/fp/fp-pidbench.S @@ -28,9 +28,9 @@ puts "\n" .endm =20 -// Main program entry point -.globl _start -function _start +// Program specific main function +.globl main +function main puts "Iterations per test: " mov x20, #10000 lsl x20, x20, #12 diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing= /selftests/arm64/fp/fpsimd-test.S index fcbb3a872490..df040283d076 100644 --- a/tools/testing/selftests/arm64/fp/fpsimd-test.S +++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S @@ -148,69 +148,11 @@ function irritator_handler =20 ret endfunction +.globl irritator_handler =20 -// w0: signal number -// x1: sa_action -// w2: sa_flags -// Clobbers x0-x6,x8 -function setsignal - str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]! - - mov w4, w0 - mov x5, x1 - mov w6, w2 - - add x0, sp, #16 - mov x1, #sa_sz - bl memclr - - mov w0, w4 - add x1, sp, #16 - str w6, [x1, #sa_flags] - str x5, [x1, #sa_handler] - mov x2, #0 - mov x3, #sa_mask_sz - mov x8, #__NR_rt_sigaction - svc #0 - - cbz w0, 1f - - puts "sigaction failure\n" - b exit_error - -1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) - ret -endfunction - -// Main program entry point -.globl _start -function _start - enable_gcs - - mov x23, #0 // signal count - - mov w0, #SIGINT - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGTERM - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGUSR1 - adr x1, irritator_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - - mov w0, #SIGUSR2 - adr x1, tickle_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - +// Program specific main function +.globl main +function main // Sanity-check and report the vector length =20 mov x19, #128 @@ -231,16 +173,6 @@ function _start bl putdec puts " bits\n" =20 - // Obtain our PID, to ensure test pattern uniqueness between processes - - mov x8, #__NR_getpid - svc #0 - mov x20, x0 - - puts "PID:\t" - mov x0, x20 - bl putdecn - mov x22, #0 // generation number, increments per iteration .Ltest_loop: =20 diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index 88c3220caf7c..c7d9514f964e 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -316,69 +316,11 @@ function irritator_handler =20 ret endfunction +.globl irritator_handler =20 -// w0: signal number -// x1: sa_action -// w2: sa_flags -// Clobbers x0-x6,x8 -function setsignal - str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]! - - mov w4, w0 - mov x5, x1 - mov w6, w2 - - add x0, sp, #16 - mov x1, #sa_sz - bl memclr - - mov w0, w4 - add x1, sp, #16 - str w6, [x1, #sa_flags] - str x5, [x1, #sa_handler] - mov x2, #0 - mov x3, #sa_mask_sz - mov x8, #__NR_rt_sigaction - svc #0 - - cbz w0, 1f - - puts "sigaction failure\n" - b exit_error - -1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) - ret -endfunction - -// Main program entry point -.globl _start -function _start - enable_gcs - - mov x23, #0 // Irritation signal count - - mov w0, #SIGINT - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGTERM - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGUSR1 - adr x1, irritator_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - - mov w0, #SIGUSR2 - adr x1, tickle_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - +// Program specific main function +.globl main +function main #ifdef SSVE puts "Streaming mode " smstart_sm @@ -404,16 +346,6 @@ function _start bl putdec puts " bits\n" =20 - // Obtain our PID, to ensure test pattern uniqueness between processes - - mov x8, #__NR_getpid - svc #0 - mov x20, x0 - - puts "PID:\t" - mov x0, x20 - bl putdecn - #ifdef SSVE smstart_sm // syscalls will have exited streaming mode #endif diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index 4a5b4b37d475..a0165a81a937 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -161,69 +161,11 @@ function irritator_handler =20 ret endfunction +.globl irritator_handler =20 -// w0: signal number -// x1: sa_action -// w2: sa_flags -// Clobbers x0-x6,x8 -function setsignal - str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]! - - mov w4, w0 - mov x5, x1 - mov w6, w2 - - add x0, sp, #16 - mov x1, #sa_sz - bl memclr - - mov w0, w4 - add x1, sp, #16 - str w6, [x1, #sa_flags] - str x5, [x1, #sa_handler] - mov x2, #0 - mov x3, #sa_mask_sz - mov x8, #__NR_rt_sigaction - svc #0 - - cbz w0, 1f - - puts "sigaction failure\n" - b exit_error - -1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) - ret -endfunction - -// Main program entry point -.globl _start -function _start - enable_gcs - - mov x23, #0 // signal count - - mov w0, #SIGINT - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGTERM - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGUSR1 - adr x1, irritator_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - - mov w0, #SIGUSR2 - adr x1, tickle_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - +// Program specific main function +.globl main +function main puts "Streaming mode " smstart_za =20 @@ -247,15 +189,6 @@ function _start bl putdec puts " bits\n" =20 - // Obtain our PID, to ensure test pattern uniqueness between processes - mov x8, #__NR_getpid - svc #0 - mov x20, x0 - - puts "PID:\t" - mov x0, x20 - bl putdecn - mov x22, #0 // generation number, increments per iteration .Ltest_loop: rdsvl 0, 8 diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index 82a76bb2307a..1c7db1298fb1 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -130,80 +130,13 @@ function irritator_handler =20 ret endfunction +.globl irritator_handler =20 -// w0: signal number -// x1: sa_action -// w2: sa_flags -// Clobbers x0-x6,x8 -function setsignal - str x30, [sp, #-((sa_sz + 15) / 16 * 16 + 16)]! - - mov w4, w0 - mov x5, x1 - mov w6, w2 - - add x0, sp, #16 - mov x1, #sa_sz - bl memclr - - mov w0, w4 - add x1, sp, #16 - str w6, [x1, #sa_flags] - str x5, [x1, #sa_handler] - mov x2, #0 - mov x3, #sa_mask_sz - mov x8, #__NR_rt_sigaction - svc #0 - - cbz w0, 1f - - puts "sigaction failure\n" - b exit_error - -1: ldr x30, [sp], #((sa_sz + 15) / 16 * 16 + 16) - ret -endfunction - -// Main program entry point -.globl _start -function _start - enable_gcs - - mov x23, #0 // signal count - - mov w0, #SIGINT - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGTERM - adr x1, terminate_handler - mov w2, #SA_SIGINFO - bl setsignal - - mov w0, #SIGUSR1 - adr x1, irritator_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - - mov w0, #SIGUSR2 - adr x1, tickle_handler - mov w2, #SA_SIGINFO - orr w2, w2, #SA_NODEFER - bl setsignal - +// Program specific main function +.globl main +function main smstart_za =20 - // Obtain our PID, to ensure test pattern uniqueness between processes - mov x8, #__NR_getpid - svc #0 - mov x20, x0 - - puts "PID:\t" - mov x0, x20 - bl putdecn - mov x22, #0 // generation number, increments per iteration .Ltest_loop: mov x0, x20 --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E73D3485507; Tue, 1 Sep 2026 17:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282597; cv=none; b=R2RN+HwjdrlX2YQ86vgk9ElCKL+SKFwvNhZbMA8HNeKkmNyXq9mjbYMu+Qa9vDNd/1xypIOIOZgNt5P7KIpQU8ANUgd3a8ilOKr7/37LGZdQXxGVX+5pfEjg1NY3HQzhXEnqFJ/AcVrU7yuLJJH62FIxiaH25ZepxonMIfJNtng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282597; c=relaxed/simple; bh=GdbDqMwhKS4dvNXEnU5ojuDWOVHjqy8HghJqycB6KsI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rHpA5mP1K4dfYzhSUG/i7sXXA7P+dbect2oICUn/O4fQErXjUONq7PYRi68VVrdRbITAHimMAjbdorYZqA65zYmDypyfTS9AVGH38BI/IWO+T6LRapbsNGo8OubR5TI94QvQc8hTmqJrsfRbXLWZG6QMHLuWy331ahjFnSyJI84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l4yB8LX+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l4yB8LX+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 652361F00ADB; Tue, 1 Sep 2026 17:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282595; bh=NxI+FpOAmxzg2hKYXBYiDpr6L2PYG+09QYQFHVt1TSo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=l4yB8LX+vDTiOKEzrwwpXiZhiM0zUvRfh264ziRNaC3LdH1YAteSETLqdUZOpRVSZ g35FbqIEWxDEVYqILqegQuTaI333IF6RoarCa36St9RFDtGc1rNDv4hEDJz10qT/uG IlpM7TlWUulrl2khmXML0UhGzCG2usU0Kk2ZwAhNZ72f8gpDmUly1IDaCZd8G1yDPs 344QS4ozGUuPUpSrV2cbPbiGOwBrnphwzEg3y8GNSW9LbYkywJKRoyNxMbum8fK3YJ MkbgShzNjwj2LwK2VTxVp9STjyEygsj/xl6F5EXbUrKso0l/9eNRPDBI4zqRnueq/c 8fwAm/V4RMLrQ== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:47 +0100 Subject: [PATCH 07/11] kselftest/arm64: Remove the sched_yield()s from the fp-stress loads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-7-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3902; i=broonie@kernel.org; h=from:subject:message-id; bh=GdbDqMwhKS4dvNXEnU5ojuDWOVHjqy8HghJqycB6KsI=; b=owEBbAGT/pANAwAKASTWi3JdVIfQAcsmYgBqlwbKNftVcanUlhQIMWx2Mid/cKISxY4XA0ZWE mmqno9pEWuJATIEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGygAKCRAk1otyXVSH 0FB4B/jUlFlmRbsCnYtLKyHr7MX8IiDWp2IBn0FWw6fqMdglnCaYOIx0pio8sUkLkjFfZiDxpQL 7VQAYtpjNCcoqCumDbnR1oziUI6A/7VVAnX1tZNj+u0TaM7mXnhy344kTcnVZXIKYEGuW3zBZkR t7W1m/kRzX7LwwRzZbpzCGKXc6pXAoD5B8xb8wHanq14mTu/oBpT1ntkmHbQfmtUeJ21xA+/GEp c94XVenkGXvMN2VjK2vdfi22rSsJv6GBze7LY9qsrRLyvzIgAgqfIW0AYpotGSz3wM99hXn3bb8 DaDEPKyY5n9Ej7KadB0F9OShtwGRC37O7jXdlExyuz5oI7M= X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB The fp-stress load programs call sched_yield() on each iteration of their test loops in order to encourage preemption, except for sve-test where the call is commented out since the SVE state is destroyed by system calls. This is most likely counterproductive since we are more likely to notice corruption if preemption happens while setting or reading the register state, and since fp-stress starts multiple test programs per CPU we should have no trouble observing preemption anyway. Remove these calls, including the commented out one in sve-test, both due to this and in order to prepare for running as KVM guests. We also remove the inclusions of unistd.h since we no longer need it in any of the programs. za-test had an unreferenced local label in the middle of the sched_yield(), remove that too. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fpsimd-test.S | 5 ----- tools/testing/selftests/arm64/fp/sve-test.S | 5 ----- tools/testing/selftests/arm64/fp/za-test.S | 5 ----- tools/testing/selftests/arm64/fp/zt-test.S | 4 ---- 4 files changed, 19 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/fpsimd-test.S b/tools/testing= /selftests/arm64/fp/fpsimd-test.S index df040283d076..5e19799f1b2e 100644 --- a/tools/testing/selftests/arm64/fp/fpsimd-test.S +++ b/tools/testing/selftests/arm64/fp/fpsimd-test.S @@ -10,7 +10,6 @@ // (leave it running for as long as you want...) // kill $pids =20 -#include #include "assembler.h" #include "asm-offsets.h" =20 @@ -185,10 +184,6 @@ function main cmp x21, #NVR b.lo 0b =20 -// Can't do this when SVE state is volatile across SVC: - mov x8, #__NR_sched_yield // Encourage preemption - svc #0 - mov x21, #0 0: mov x0, x21 bl check_vreg diff --git a/tools/testing/selftests/arm64/fp/sve-test.S b/tools/testing/se= lftests/arm64/fp/sve-test.S index c7d9514f964e..fdb295bde45c 100644 --- a/tools/testing/selftests/arm64/fp/sve-test.S +++ b/tools/testing/selftests/arm64/fp/sve-test.S @@ -10,7 +10,6 @@ // (leave it running for as long as you want...) // kill $pids =20 -#include #include "assembler.h" #include "asm-offsets.h" #include "sme-inst.h" @@ -378,10 +377,6 @@ function main cmp x21, #NZR + NPR b.lo 0b =20 -// Can't do this when SVE state is volatile across SVC: -// mov x8, #__NR_sched_yield // Encourage preemption -// svc #0 - #ifdef SSVE mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=3D0,SM=3D1 and x1, x0, #3 diff --git a/tools/testing/selftests/arm64/fp/za-test.S b/tools/testing/sel= ftests/arm64/fp/za-test.S index a0165a81a937..8d449e114301 100644 --- a/tools/testing/selftests/arm64/fp/za-test.S +++ b/tools/testing/selftests/arm64/fp/za-test.S @@ -10,7 +10,6 @@ // (leave it running for as long as you want...) // kill $pids =20 -#include #include "assembler.h" #include "asm-offsets.h" #include "sme-inst.h" @@ -203,10 +202,6 @@ function main subs x21, x21, #1 b.ne 0b =20 - mov x8, #__NR_sched_yield // encourage preemption -1: - svc #0 - mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=3D1,SM=3D0 and x1, x0, #3 cmp x1, #2 diff --git a/tools/testing/selftests/arm64/fp/zt-test.S b/tools/testing/sel= ftests/arm64/fp/zt-test.S index 1c7db1298fb1..2333e72760a5 100644 --- a/tools/testing/selftests/arm64/fp/zt-test.S +++ b/tools/testing/selftests/arm64/fp/zt-test.S @@ -6,7 +6,6 @@ // Repeatedly writes unique test patterns into ZT0 // and reads them back to verify integrity. =20 -#include #include "assembler.h" #include "asm-offsets.h" #include "sme-inst.h" @@ -143,9 +142,6 @@ function main mov x1, x22 bl setup_zt =20 - mov x8, #__NR_sched_yield // Encourage preemption - svc #0 - mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=3D1,SM=3D0 and x1, x0, #3 cmp x1, #2 --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B30748A8B1; Tue, 1 Sep 2026 17:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282600; cv=none; b=fjOFSLWiavY9vk1lzuzUxTBHPnBVCxC/g/bay2ZV6Oo4HxaY8cRPeLTbBKyrWAH542QIn3ep+8LA1n7bOMzL105tIoL7Sb6WvE4e9it7trHo0O6Cjpc+U5N7rPYXzR6HQnBEE2mh3YcyE3SVSAZFOqQDb2lT/Q/LLqP8qVkRr78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282600; c=relaxed/simple; bh=2D0HjzHLTDEvC1yuBPsBbDoLYqxKjJ1h2Ns6+IKSiOE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qbNmmSobdx8qh25Mgp6j0/Yr7PlMSxxQSOJ89HbiahNLu9n1+i4B6OXMdcMXA8RBeeHJz+a4lK6LoacTv/MsqO3lp0+hiJovXK5eUy9EkWeOCXC+nehyjZqy/h5ChzFQc24k6ZENBgNWMcAtJTsWgDHYF9YN0vAUi1M0F/AziJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g6tniRN2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g6tniRN2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E123C1F00A3F; Tue, 1 Sep 2026 17:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282598; bh=Rcdwv2phLB9ABk252mp3owcHm4h9CXxhxuSslYv2njs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=g6tniRN2USLo4+/uX4dAVYgxswzYxpZf5LtYcV3TRdLwKQeyjNdnBO4VzreqiLpJx IDxMiIPdAEG4hNKljL5R+N2dYLLv4IpeBHTBCZihj19nbh0+RgFwM3QhSLXpSraqM4 nA9P3YkEdoR2EErVRU+zpmiYgbcDa/zI2f7o2wQPgkdYpUDH3siajyqiCd2ex98ttE ZOIirapsp7ttk3eihTiKlOoM93toUefeUHolxsQQG9zwnG2JR53B37OOw6pmimQJvy dKrh4+YY3E/Ihmyr4Bk+G0hpUE3qcDSSX5yWZ4PoJO9Z3QRkniKanrbirbanjVU6X1 PzkgG+fLMcFkw== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:48 +0100 Subject: [PATCH 08/11] kselftest/arm64: Add a very simple VMM for use in fp-stress Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-8-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=22903; i=broonie@kernel.org; h=from:subject:message-id; bh=2D0HjzHLTDEvC1yuBPsBbDoLYqxKjJ1h2Ns6+IKSiOE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbLjQaj8JKEdLoGqfKnY5E8Kn7oAv9yLfDYQ 7myh9HKe3eJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGywAKCRAk1otyXVSH 0KyfB/9UECVmNKnLZus+CYIffDmOYfiiT+4T2o+1Oxq0u0SNnXotgw2659/wd9C+CDLbMfhuBWD nI399qtc12Ng9CZgwmT+dDsIEZhyxHyYwdWViFaVKxBCHgrtbd5bYe3wUK0ECYirxy+M+nlEFL8 Vqhu56uoPRXe3EzKyDZkA+OC9xF9liLbjfLu2XbxNQo71rzC7fyXSw3+1bENr9bBNvAxZgpfzKj uVu80Xutq+t3Y/r93SGTx+Gy/4xp82Tz/CkN0whL8g2eLFl4uvgHghuzKLbm8QGV/YoS34GlaN7 m8s2I7bA16CyTvSn6zhDBA+ICMrGKF8ijTVSy9bgfVkPgj0w X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB In order to have fp-stress cover the interaction of KVM guests with the rest of the floating point state management we need to provide some KVM guest versions of the test loads that fp-stress runs. fp-stress itself expects to start test loads which continually load, save and verify the floating point state, shutting down when requested via signals or if they detect an error. The host versions of these are written in assembler and all follow a very similar template. Provide a simple VMM for running under fp-stress which loads a flat binary at a fixed address and runs it. The guest can output characters by writing to a MMIO address and can report errors by using PSCI to request a shutdown. If fp-stress sends a signal requesting a shutdown the program exits. We allocate some extra space after the test binary for the program to use for it's stack, and provide a handler for guest exceptions which logs the exception state based on the guest executing BRK in all exception vectors. fp-stress uses SIGUSR1 signals to peturb the scheduling and exercise the signal handling paths, we add a handler for this which simply counts the number of signals delivered (as we do in the host versions). Exiting the guest to userspace to handle the signals should still provide some disruption, it would be better to do something more extensive like saving and restoring at least the floating point register state in the handler but we don't do that here. We also include SIGUSR2 in the count, this is also supported by the host versions as it can be useful in manual testing. Command line options are provided for enabling pKVM, NV and SVE. With NV we start the guest at EL2 in VHE mode so the guest doesn't need to do anything EL specific. For SVE we configure the VL at the VMM level and set all bits in ZCR_ELx.LEN so KVM is context switching the VL that is configured. We configure FPEN and ZEN in CAPCR_ELx for the guest because it's a little simpler than doing anything feature conditional in guest code. We don't do any validation of the combination of options that is provided, we rely on the caller for that. On the host the test programs differentiate data between instances by using the PID, they store this in x20 so we prefill this for them with our own PID. The programs also log the number of iterations they have run on exit, storing the number of iterations in x22. When the host requests an exit we log this value as part of a similar format clean exit message to that generated by the host programs. We don't use the generated sysreg-defs.h but instead replicate a few defines from there, this is because an empty stub stub introduced as part of 8bc7c5e52558 (selftests: vDSO: don't include generated headers for chacha test) breaks that. This will be looked at separately, we should fix it independently of this work. This is all very much specialised for fp-stress - the VMM hard codes specifics of register allocation in the guest code it, implements the signal and exit code interface that fp-stress expects and we're not making much effort to handle anything surprising the guest might to. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/.gitignore | 1 + tools/testing/selftests/arm64/fp/Makefile | 9 +- tools/testing/selftests/arm64/fp/fp-stress-vmm.c | 596 +++++++++++++++++++= ++++ tools/testing/selftests/arm64/fp/fp-stress-vmm.h | 17 + 4 files changed, 622 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/fp/.gitignore b/tools/testing/se= lftests/arm64/fp/.gitignore index 8362e7ec35ad..229a5c65b65f 100644 --- a/tools/testing/selftests/arm64/fp/.gitignore +++ b/tools/testing/selftests/arm64/fp/.gitignore @@ -1,6 +1,7 @@ fp-pidbench fp-ptrace fp-stress +fp-stress-vmm fpsimd-test kernel-test rdvl-sme diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/self= tests/arm64/fp/Makefile index d92a755837ff..3c4e17a34776 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -11,7 +11,7 @@ TEST_GEN_PROGS :=3D \ sve-ptrace sve-probe-vls \ vec-syscfg \ za-fork za-ptrace -TEST_GEN_PROGS_EXTENDED :=3D fp-pidbench fpsimd-test \ +TEST_GEN_PROGS_EXTENDED :=3D fp-pidbench fp-stress-vmm fpsimd-test \ kernel-test \ rdvl-sme rdvl-sve \ sve-test \ @@ -27,6 +27,13 @@ EXTRA_CLEAN +=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-uti= ls-linux.o \ =20 ASM_UTILS_LINUX :=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o =20 +# For sysreg definitons +ARCH_INCLUDES :=3D $(KHDR_INCLUDES) -I$(top_srcdir)/tools/arch/arm64/inclu= de \ + -I$(top_srcdir)/tools/include \ + -I$(top_srcdir)/tools/include/generated + +$(OUTPUT)/fp-stress-vmm: CFLAGS +=3D $(ARCH_INCLUDES) + # Build with nolibc to avoid effects due to libc's clone() support $(OUTPUT)/fp-pidbench: fp-pidbench.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ diff --git a/tools/testing/selftests/arm64/fp/fp-stress-vmm.c b/tools/testi= ng/selftests/arm64/fp/fp-stress-vmm.c new file mode 100644 index 000000000000..4c5cfa43a170 --- /dev/null +++ b/tools/testing/selftests/arm64/fp/fp-stress-vmm.c @@ -0,0 +1,596 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Minimal arm64 KVM VMM used to run fp-stress test loads in VMs. + * + * Runs a single vCPU guest loaded from a flat binary read from a file, wi= th + * PSCI 0.2 enabled so the guest can shut itself down via SYSTEM_OFF and a + * simple MMIO console for guest output. + * + * Unhandled guest exceptions are reported via the guest's vector + * table: each entry is a BRK instruction and we use software * breakpoint + * debugging to us with KVM_EXIT_DEBUG. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "fp-stress-vmm.h" + +#define ARM64_CORE_REG(name) \ + (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | KVM_REG_ARM_CORE | \ + KVM_REG_ARM_CORE_REG(name)) + +#define CPACR_EL1 ARM64_SYS_REG(3, 0, 1, 0, 2) +#define CPTR_EL2 ARM64_SYS_REG(3, 4, 1, 1, 2) +#define ELR_EL2 ARM64_SYS_REG(3, 4, 4, 0, 1) +#define ESR_EL1 ARM64_SYS_REG(3, 0, 5, 2, 0) +#define ESR_EL2 ARM64_SYS_REG(3, 4, 5, 2, 0) +#define FAR_EL1 ARM64_SYS_REG(3, 0, 6, 0, 0) +#define FAR_EL2 ARM64_SYS_REG(3, 4, 6, 0, 0) +#define HCR_EL2 ARM64_SYS_REG(3, 4, 1, 1, 0) +#define ZCR_EL1 ARM64_SYS_REG(3, 0, 1, 2, 0) +#define ZCR_EL2 ARM64_SYS_REG(3, 4, 1, 2, 0) + +/* Both halves of the field, as the guest's own no-trapping value */ +#define CPACR_EL1_FPEN (CPACR_EL1_FPEN_EL1EN | CPACR_EL1_FPEN_EL0EN) +#define CPACR_EL1_ZEN (CPACR_EL1_ZEN_EL1EN | CPACR_EL1_ZEN_EL0EN) + +/* We should fix the build system to let us get these from sysreg-defs.h */ +#define HCR_EL2_E2H BIT(34) +#define ZCR_ELx_LEN 0xf + +/* VGIC MMIO ranges, below the console and guest RAM */ +#define VGIC_DIST_BASE 0x08000000 +#define VGIC_REDIST_BASE 0x08010000 + +/* The vector length set is a bitmap of vector quadwords, index into it */ +#define vq_word(vq) (((vq) - KVM_ARM64_SVE_VQ_MIN) / 64) +#define vq_mask(vq) (1ULL << (((vq) - KVM_ARM64_SVE_VQ_MIN) % 64)) +#define vq_present(vqs, vq) (!!((vqs)[vq_word(vq)] & vq_mask(vq))) + +/* The guest's vector entries BRK with their entry number as immediate */ +#define NR_VECTORS 16 + +/* The vCPU our signal handler reports the state of, -1 until we have one = */ +static int vcpu_fd =3D -1; + +static bool guest_pkvm; +static bool guest_el2; + +/* SVE vector length in bits for the guest, 0 for no SVE, from --sve */ +static int guest_sve_vl; + +static const char *const vector_origins[] =3D { + "current EL, SP_EL0", + "current EL, SP_ELx", + "lower EL, AArch64", + "lower EL, AArch32", +}; + +static const char *const vector_kinds[] =3D { + "synchronous", "IRQ", "FIQ", "SError", +}; + +static void __attribute__((noreturn, format(printf, 1, 2))) +die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + putchar('\n'); + + exit(EXIT_FAILURE); +} + +static void __attribute__((noreturn)) die_perror(const char *what) +{ + die("%s: %d (%s)", what, errno, strerror(errno)); +} + +static void *load_guest(const char *path, size_t *ram_size) +{ + struct stat st; + long page_size; + ssize_t ret; + size_t off; + void *ram; + int fd; + + fd =3D open(path, O_RDONLY); + if (fd < 0) + die("%s: %s", path, strerror(errno)); + + if (fstat(fd, &st)) + die_perror("fstat"); + + if (!st.st_size) + die("%s: image is empty", path); + + page_size =3D sysconf(_SC_PAGESIZE); + if (page_size < 0) + die_perror("sysconf(_SC_PAGESIZE)"); + + /* Guest memory is allocated in whole pages */ + *ram_size =3D ((size_t)st.st_size + GUEST_EXTRA_RAM + page_size - 1) & + ~((size_t)page_size - 1); + + ram =3D mmap(NULL, *ram_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (ram =3D=3D MAP_FAILED) + die_perror("mmap(guest RAM)"); + + for (off =3D 0; off < (size_t)st.st_size; off +=3D ret) { + ret =3D read(fd, (char *)ram + off, st.st_size - off); + if (ret < 0) + die_perror("read"); + if (!ret) + die("%s: short read", path); + } + + close(fd); + + return ram; +} + +static uint64_t get_reg(int vcpu_fd, uint64_t id) +{ + uint64_t val; + struct kvm_one_reg reg =3D { + .id =3D id, + .addr =3D (uint64_t)&val, + }; + + if (ioctl(vcpu_fd, KVM_GET_ONE_REG, ®)) + die_perror("KVM_GET_ONE_REG"); + + return val; +} + +/* + * The guest shouldn't be doing anything that results in us seeing an + * exception, report anything we do see as an error. + */ +static void __attribute__((noreturn)) +report_guest_exception(int vcpu_fd, unsigned int vector) +{ + uint64_t esr, elr, far, ec; + int el; + + if (guest_el2) { + esr =3D get_reg(vcpu_fd, ESR_EL2); + elr =3D get_reg(vcpu_fd, ELR_EL2); + far =3D get_reg(vcpu_fd, FAR_EL2); + el =3D 2; + } else { + esr =3D get_reg(vcpu_fd, ESR_EL1); + elr =3D get_reg(vcpu_fd, ARM64_CORE_REG(elr_el1)); + far =3D get_reg(vcpu_fd, FAR_EL1); + el =3D 1; + } + + ec =3D ESR_ELx_EC(esr); + + printf("Unhandled guest exception: %s, %s\n", + vector_kinds[vector % 4], vector_origins[vector / 4]); + printf(" ESR_EL%d 0x%016lx (EC 0x%02lx)\n", el, esr, ec); + printf(" ELR_EL%d 0x%016lx FAR_EL%d 0x%016lx\n", el, elr, el, far); + + exit(EXIT_FAILURE); +} + +/* + * The natively built loads are poked with SIGUSR1 and SIGUSR2 while they + * run and count what they were sent in x23. Those signals come to us + * rather than the guest so keep the count out here instead, the guest + * leaves its own x23 at zero. + */ +static volatile sig_atomic_t signal_count; + +static void handle_count_signal(int sig) +{ + signal_count++; +} + +/* + * We were asked to stop, report where the guest got to and exit + * successfully in the same form as the natively built loads do from + * their own terminate handler. They keep their iteration count in x22. + */ +static void handle_exit_signal(int sig) +{ + uint64_t iterations =3D 0; + char buf[128]; + int len; + + /* We can be signalled before there is a vCPU */ + if (vcpu_fd >=3D 0) + iterations =3D get_reg(vcpu_fd, ARM64_CORE_REG(regs.regs[22])); + + len =3D snprintf(buf, sizeof(buf), + "Terminated by signal %d, iterations=3D%llu, signals=3D%llu\n", + sig, (unsigned long long)iterations, + (unsigned long long)signal_count); + write(STDOUT_FILENO, buf, len); + + _exit(EXIT_SUCCESS); +} + +/* + * Arrange for SIGTERM and SIGINT to stop us, reporting where the guest + * got to rather than dying on the spot, and for SIGUSR1 and SIGUSR2 to + * be counted. Done before we have a VM so that we do not die by default + * action if we are signalled while setting one up. + */ +static void setup_signals(void) +{ + struct sigaction stop =3D { .sa_handler =3D handle_exit_signal }; + struct sigaction count =3D { .sa_handler =3D handle_count_signal }; + + sigemptyset(&stop.sa_mask); + if (sigaction(SIGTERM, &stop, NULL) || sigaction(SIGINT, &stop, NULL)) + die_perror("sigaction"); + + sigemptyset(&count.sa_mask); + sigaddset(&count.sa_mask, SIGUSR1); + sigaddset(&count.sa_mask, SIGUSR2); + if (sigaction(SIGUSR1, &count, NULL) || sigaction(SIGUSR2, &count, NULL)) + die_perror("sigaction"); +} + +static void set_reg(int vcpu_fd, uint64_t id, uint64_t val) +{ + struct kvm_one_reg reg =3D { + .id =3D id, + .addr =3D (uint64_t)&val, + }; + + if (ioctl(vcpu_fd, KVM_SET_ONE_REG, ®)) + die_perror("KVM_SET_ONE_REG"); +} + +static void set_device_attr(int fd, uint32_t group, uint64_t attr, + void *addr) +{ + struct kvm_device_attr device_attr =3D { + .group =3D group, + .attr =3D attr, + .addr =3D (uint64_t)addr, + }; + + if (ioctl(fd, KVM_SET_DEVICE_ATTR, &device_attr)) + die_perror("KVM_SET_DEVICE_ATTR"); +} + +/* + * For NV we need a vGIC since KVM uses it to provide the virtual + * maintenance interrupt, + */ +static void setup_vgic(int vm_fd) +{ + struct kvm_create_device device =3D { + .type =3D KVM_DEV_TYPE_ARM_VGIC_V3, + }; + uint64_t addr; + + if (ioctl(vm_fd, KVM_CREATE_DEVICE, &device)) + die_perror("KVM_CREATE_DEVICE(VGICv3)"); + + addr =3D VGIC_DIST_BASE; + set_device_attr(device.fd, KVM_DEV_ARM_VGIC_GRP_ADDR, + KVM_VGIC_V3_ADDR_TYPE_DIST, &addr); + + addr =3D VGIC_REDIST_BASE; + set_device_attr(device.fd, KVM_DEV_ARM_VGIC_GRP_ADDR, + KVM_VGIC_V3_ADDR_TYPE_REDIST, &addr); + + set_device_attr(device.fd, KVM_DEV_ARM_VGIC_GRP_CTRL, + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL); + close(device.fd); +} + +/* + * Tell KVM which vector lengths the guest may use. It can only limit + * the maximum rather than hide individual VLs, the set we ask for has to + * match the ones the host has exactly up to that maximum, so start from + * what KVM is offering us and mask off everything above what we want. + */ +static void setup_sve(int vl) +{ + __u64 vqs[KVM_ARM64_SVE_VLS_WORDS]; + struct kvm_one_reg reg =3D { + .id =3D KVM_REG_ARM64_SVE_VLS, + .addr =3D (uint64_t)vqs, + }; + /* Our VLs are in bits, the vector quadword helpers work in bytes */ + unsigned int max_vq =3D sve_vq_from_vl(vl / 8); + int feature =3D KVM_ARM_VCPU_SVE; + unsigned int vq; + + if (ioctl(vcpu_fd, KVM_GET_ONE_REG, ®)) + die_perror("KVM_GET_ONE_REG(SVE_VLS)"); + + if (!vq_present(vqs, max_vq)) + die("KVM has no SVE VL %d", vl); + + for (vq =3D max_vq + 1; vq <=3D KVM_ARM64_SVE_VQ_MAX; vq++) + vqs[vq_word(vq)] &=3D ~vq_mask(vq); + + if (ioctl(vcpu_fd, KVM_SET_ONE_REG, ®)) + die_perror("KVM_SET_ONE_REG(SVE_VLS)"); + + if (ioctl(vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) + die_perror("KVM_ARM_VCPU_FINALIZE(SVE)"); + + /* Rely on the VM level configuration to constrain the VL */ + if (guest_el2) + set_reg(vcpu_fd, ZCR_EL2, ZCR_ELx_LEN); + set_reg(vcpu_fd, ZCR_EL1, ZCR_ELx_LEN); +} + +static void setup_vm(const char *path, struct kvm_run **run) +{ + struct kvm_userspace_memory_region mem; + struct kvm_guest_debug dbg; + struct kvm_vcpu_init init; + uint64_t cpacr, pstate; + unsigned long vm_type; + int kvm_fd, vm_fd; + size_t ram_size; + long mmap_size; + void *ram; + + kvm_fd =3D open("/dev/kvm", O_RDWR | O_CLOEXEC); + if (kvm_fd < 0) + die_perror("/dev/kvm"); + + if (ioctl(kvm_fd, KVM_GET_API_VERSION, 0) !=3D KVM_API_VERSION) + die("KVM API version mismatch"); + + if (guest_pkvm) + vm_type =3D KVM_VM_TYPE_ARM_PROTECTED; + else + vm_type =3D 0; + vm_fd =3D ioctl(kvm_fd, KVM_CREATE_VM, vm_type); + if (vm_fd < 0) + die_perror("KVM_CREATE_VM"); + + ram =3D load_guest(path, &ram_size); + + mem =3D (struct kvm_userspace_memory_region) { + .slot =3D 0, + .guest_phys_addr =3D GUEST_RAM_BASE, + .memory_size =3D ram_size, + .userspace_addr =3D (uint64_t)ram, + }; + if (ioctl(vm_fd, KVM_SET_USER_MEMORY_REGION, &mem)) + die_perror("KVM_SET_USER_MEMORY_REGION"); + + vcpu_fd =3D ioctl(vm_fd, KVM_CREATE_VCPU, 0); + if (vcpu_fd < 0) + die_perror("KVM_CREATE_VCPU"); + + if (ioctl(vm_fd, KVM_ARM_PREFERRED_TARGET, &init)) + die_perror("KVM_ARM_PREFERRED_TARGET"); + + if (!ioctl(kvm_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_PSCI_0_2)) + die("KVM_CAP_ARM_PSCI_0_2 not supported"); + init.features[0] |=3D 1UL << KVM_ARM_VCPU_PSCI_0_2; + + /* + * Running the guest at EL2 gets us coverage of the nested paths + * through the floating point context switching. + */ + if (guest_el2) { + if (!ioctl(kvm_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_EL2)) + die("KVM_CAP_ARM_EL2 not supported"); + init.features[0] |=3D 1UL << KVM_ARM_VCPU_HAS_EL2; + } + + if (guest_sve_vl) { + if (!ioctl(kvm_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE)) + die("KVM_CAP_ARM_SVE not supported"); + init.features[0] |=3D 1UL << KVM_ARM_VCPU_SVE; + } + + if (ioctl(vcpu_fd, KVM_ARM_VCPU_INIT, &init)) + die_perror("KVM_ARM_VCPU_INIT"); + + /* + * A vGIC is only needed for EL2 guests so skip otherwise, + * avoids issues with configuring on GICv2 systems. + */ + if (guest_el2) + setup_vgic(vm_fd); + + if (guest_sve_vl) + setup_sve(guest_sve_vl); + + set_reg(vcpu_fd, ARM64_CORE_REG(regs.pc), GUEST_RAM_BASE); + + /* + * Disable FP traps for the guest, we set things up here since it's + * easier than looking at ID registers in the guest. + */ + if (guest_el2) { + cpacr =3D get_reg(vcpu_fd, CPTR_EL2) | CPACR_EL1_FPEN; + if (guest_sve_vl) + cpacr |=3D CPACR_EL1_ZEN; + set_reg(vcpu_fd, CPTR_EL2, cpacr); + + } + cpacr =3D get_reg(vcpu_fd, CPACR_EL1) | CPACR_EL1_FPEN; + if (guest_sve_vl) + cpacr |=3D CPACR_EL1_ZEN; + set_reg(vcpu_fd, CPACR_EL1, cpacr); + + /* + * An EL2 guest needs to be in VHE mode, everything it sets up + * uses the EL1 registers and those only reach the EL2 ones it is + * really running on while E2H is set. KVM only sets E2H for us + * at reset on hardware without FEAT_E2H0. + */ + if (guest_el2) + set_reg(vcpu_fd, HCR_EL2, + get_reg(vcpu_fd, HCR_EL2) | HCR_EL2_E2H); + + /* + * Guests can't use getpid() to disambiguate their data, let's call + * it for them. + */ + set_reg(vcpu_fd, ARM64_CORE_REG(regs.regs[20]), getpid()); + + /* + * Trap guest BRKs to us so the guest's vector stubs can report + * unhandled exceptions. + */ + if (!ioctl(kvm_fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_GUEST_DEBUG)) + die("KVM_CAP_SET_GUEST_DEBUG not supported"); + + dbg =3D (struct kvm_guest_debug) { + .control =3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP, + }; + if (ioctl(vcpu_fd, KVM_SET_GUEST_DEBUG, &dbg)) + die_perror("KVM_SET_GUEST_DEBUG"); + + mmap_size =3D ioctl(kvm_fd, KVM_GET_VCPU_MMAP_SIZE, 0); + if (mmap_size < 0) + die_perror("KVM_GET_VCPU_MMAP_SIZE"); + + *run =3D mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, + vcpu_fd, 0); + if (*run =3D=3D MAP_FAILED) + die_perror("mmap(kvm_run)"); + + /* Mask everything by default, and start in the expected mode */ + pstate =3D PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT; + if (guest_el2) + pstate |=3D PSR_MODE_EL2h; + else + pstate |=3D PSR_MODE_EL1h; + set_reg(vcpu_fd, ARM64_CORE_REG(regs.pstate), pstate); +} + +static const struct option options[] =3D { + { "el1", no_argument, NULL, 'e' }, + { "el2", no_argument, NULL, 'E' }, + { "protected", no_argument, NULL, 'p' }, + { "sve", required_argument, NULL, 's' }, + { } +}; + +int main(int argc, char *argv[]) +{ + struct kvm_run *run; + int c; + + while ((c =3D getopt_long(argc, argv, "es:", options, NULL)) !=3D -1) { + switch (c) { + case 'e': + break; + case 'E': + guest_el2 =3D true; + break; + case 'p': + guest_pkvm =3D true; + break; + case 's': + if (sscanf(optarg, "%d", &guest_sve_vl) !=3D 1) + die("Failed to parse SVE VL %s", optarg); + if (guest_sve_vl < 128 || guest_sve_vl % 128 || + guest_sve_vl / 8 > __SVE_VL_MAX) + die("Invalid SVE VL %d", guest_sve_vl); + break; + default: + die("Usage: %s [--el2] [--sve VL] ", + argv[0]); + } + } + + if (optind !=3D argc - 1) + die("Usage: %s [--el2] [--protected] [--sve VL] ", + argv[0]); + + /* Ensure output is unbuffered to get it to the monitor promptly */ + setvbuf(stdout, NULL, _IONBF, 0); + + setup_signals(); + + setup_vm(argv[optind], &run); + + for (;;) { + if (ioctl(vcpu_fd, KVM_RUN, 0)) { + /* + * The signals we handle do not come back here, + * anything else that interrupts us can just go + * round again. + */ + if (errno =3D=3D EINTR) + continue; + + die_perror("KVM_RUN"); + } + + switch (run->exit_reason) { + case KVM_EXIT_MMIO: + if (!run->mmio.is_write || + run->mmio.phys_addr !=3D CONSOLE_BASE || + run->mmio.len !=3D 1) + die("Unhandled MMIO %s at 0x%llx len %u", + run->mmio.is_write ? "write" : "read", + run->mmio.phys_addr, run->mmio.len); + + putchar(run->mmio.data[0]); + break; + case KVM_EXIT_DEBUG: { + uint32_t esr =3D run->debug.arch.hsr; + + if (ESR_ELx_EC(esr) !=3D ESR_ELx_EC_BRK64 || + esr_brk_comment(esr) >=3D NR_VECTORS) + die("Unexpected debug exit, ESR 0x%x", esr); + + report_guest_exception(vcpu_fd, esr_brk_comment(esr)); + } + case KVM_EXIT_SYSTEM_EVENT: + switch (run->system_event.type) { + case KVM_SYSTEM_EVENT_SHUTDOWN: + /* + * The guest should report errors by logging + * and shutting down, add our own log in case + * we get here without a log. + */ + die("Guest requested shutdown"); + default: + die("Unexpected system event %u", + run->system_event.type); + } + break; + default: + die("Unexpected exit reason %u", run->exit_reason); + } + } + + /* We should never get here */ + return EXIT_FAILURE; +} diff --git a/tools/testing/selftests/arm64/fp/fp-stress-vmm.h b/tools/testi= ng/selftests/arm64/fp/fp-stress-vmm.h new file mode 100644 index 000000000000..cdf96b617db5 --- /dev/null +++ b/tools/testing/selftests/arm64/fp/fp-stress-vmm.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#ifndef FP_STRESS_H +#define FP_STRESS_H + +#define GUEST_RAM_BASE 0x80000000 + +/* For stack */ +#define GUEST_EXTRA_RAM (1024 * 1024) + +/* + * Console: byte writes to CONSOLE_BASE are emitted on stdout. Not + * backed by a memslot, so guest accesses trap with KVM_EXIT_MMIO. + */ +#define CONSOLE_BASE 0x09000000 + +#endif --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D08DB48AE1F; Tue, 1 Sep 2026 17:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282602; cv=none; b=j2lYp0zBO8Q4hfi8kmP9P/ntl6CCLYCfOCErbC1wg4EzDnBoxg9uOXWCxnqkZU7IPN5LC+HsYwoBWdqizHYKcc4Gt3DbaT9V1wlgDH5CFD/Aq21+g+snEnnCi7W7vZpG5xUVsFTB8F/J0pO73AMK50978KgSZ95/CllWAsUyqAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282602; c=relaxed/simple; bh=nsfRN3vA/YB/iklxl04ir42UJyixVBb1znwL44VYW8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NsGseuF2GhZ02r70E4YznWVDE/7LfS6+aB9RaI6Ag7oqljldgBPF+A3S/qgI2u65e0UKvW08y5sWdVZagINs4GVBoE+OH6ohQm2yLetfEH5AxLKQdQBcIbrbXzwrBIa1HM2imQWHPMfZW0TTbq/esTIbymLr0U9cJvWPh/FUUhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WXStHWhT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WXStHWhT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B9F51F000E9; Tue, 1 Sep 2026 17:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282600; bh=FZWqgJ4teRUo17pRZx48qbUnmqiDa8be6aGrpRe0ayc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=WXStHWhTD5NAFu6myy0/O/lugU7QgBdT0ANF8Fnww4L64EJDuJbW9KOZUt+LATpPt FOcxqaaBf2i+iKOJ5CTZo0MHd+OVpCGH6Ruv2DLPHbkIZUyjE3W50j3XVw8/LpVYmN p3Oggg2oBFh8gdfgcBYq/eOeKgPLEvqexjNLOgiSMCcVfr5l+xxuCjQ2Aw/37JzZDq fCecEAHIv0M0U7TksBES9orPZosb+L9skis7lY6ZNsq2xlt0TQ6vG0eTLmhEvJIZvw kEblK+FvQHKBzQnlYLJFhqvS0o+qJWClglEagdfYZuNPNOQ/1Jt7+omkmLIKtaVj/3 I2ZVyju/Ei9ow== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:49 +0100 Subject: [PATCH 09/11] kselftest/arm64: Build KVM guest versions of the fp-stress loads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-9-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8394; i=broonie@kernel.org; h=from:subject:message-id; bh=nsfRN3vA/YB/iklxl04ir42UJyixVBb1znwL44VYW8s=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbLzPAVC3GKJMpZYrNGubZMa9quDjrjRba7j 6FJKixCFYmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGywAKCRAk1otyXVSH 0K31B/0cIAmaYL8I6tsjl8t22xJsPtW5Is5VY7qEYHvEoZrJqXOfg0YHykFjQqEY051kMW+AKzN Vn5ZdT1ArVL6nVQauys4/1T2yeC4QM9zMp9PIjn3e0a7CoRPHX80gm45FUHOSFL6juZSbptDP9V YVNGfZF1g+8yAWml5nauzvwPmRajxKh3bXBeuxdmURMmp62Au2GHKP7sPAG23j9X6/kEmY7t/CK JtRlHXBsKLFsJUWqiCefOLxUQBszX0GY/if35yg8xFwTqR6iTCNVHXzWRj25c/IfROL7a0gk2p/ p+UMvwqA8gNkIo/ECxy8vU3TgIlVDQ/7C8TDlOoRPkusERrk X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Now that all the Linux specifics have been factored out of the load programs that fp-stress uses and we have a simple VMM we can build versions for running with that VMM. Provide an asm-utils-kvm.S with startup code that's easier in the guest and implementations of the functions that the programs call, writing output to the fixed address expected by the VMM and using PSCI to shut down on error. The programs are built into flat binaries to simplify the VMM, this is a bit more Makefile effort but it's all fairly standard for bare metal programming. We install single instruction BRK handlers for all exceptions with the expectation that the VMM will trap BRKs and log exception state, we do not expect to trigger any exceptions in normal operation. We log the current EL to help with diagnostics. Since we're constantly reading and writing the contents of the floating point registers to and from memory there is fairly heavy memory traffic. We do not currently turn the MMU on so on hardware the number of iterations a test does will be very much lower that that seen on the host, this can be addressed in future. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/.gitignore | 3 + tools/testing/selftests/arm64/fp/Makefile | 40 +++++++++- tools/testing/selftests/arm64/fp/asm-utils-kvm.S | 86 ++++++++++++++++++= ++++ .../testing/selftests/arm64/fp/fp-stress-kvm.lds.S | 58 +++++++++++++++ 4 files changed, 186 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/fp/.gitignore b/tools/testing/se= lftests/arm64/fp/.gitignore index 229a5c65b65f..7a788b23ae76 100644 --- a/tools/testing/selftests/arm64/fp/.gitignore +++ b/tools/testing/selftests/arm64/fp/.gitignore @@ -1,6 +1,7 @@ fp-pidbench fp-ptrace fp-stress +fp-stress-kvm.lds fp-stress-vmm fpsimd-test kernel-test @@ -17,3 +18,5 @@ za-ptrace za-test zt-ptrace zt-test +*-kvm.bin +*-kvm.elf diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/self= tests/arm64/fp/Makefile index 3c4e17a34776..5322cb66f0a9 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -21,17 +21,41 @@ TEST_GEN_PROGS_EXTENDED :=3D fp-pidbench fp-stress-vmm = fpsimd-test \ zt-test \ vlset TEST_PROGS_EXTENDED :=3D fpsimd-stress sve-stress ssve-stress za-stress +TEST_GEN_FILES :=3D \ + fpsimd-test-kvm.bin \ + sve-test-kvm.bin \ + ssve-test-kvm.bin \ + za-test-kvm.bin \ + zt-test-kvm.bin =20 EXTRA_CLEAN +=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o \ - $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o + $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o \ + $(patsubst %.bin,%.elf,$(TEST_GEN_FILES)) \ + $(KVM_LDS) =20 ASM_UTILS_LINUX :=3D $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o +ASM_UTILS_KVM :=3D asm-utils.S asm-utils-kvm.S + +OBJCOPY ?=3D $(CROSS_COMPILE)objcopy =20 # For sysreg definitons ARCH_INCLUDES :=3D $(KHDR_INCLUDES) -I$(top_srcdir)/tools/arch/arm64/inclu= de \ -I$(top_srcdir)/tools/include \ -I$(top_srcdir)/tools/include/generated =20 +# The guests run with no OS under them at all, link them as flat binaries +# with the link script placing them where fp-stress-vmm puts their RAM. +KVM_LDS :=3D $(OUTPUT)/fp-stress-kvm.lds +KVM_LDFLAGS :=3D -nostdlib -static $(ARCH_INCLUDES) -D__ASSEMBLY__ \ + -Wl,-T,$(KVM_LDS) + +# Supported/required from GNU ld 2.39, not confirmed LLD but after 22.1.2 +COMMA=3D, +KVM_LDFLAGS +=3D $(call try-run,$(LD) --warn-rwx-segments -v,-Wl$(COMMA)--= warn-rwx-segments) + +$(KVM_LDS): fp-stress-kvm.lds.S fp-stress-vmm.h + $(CC) -E -P -x c $< -o $@ + $(OUTPUT)/fp-stress-vmm: CFLAGS +=3D $(ARCH_INCLUDES) =20 # Build with nolibc to avoid effects due to libc's clone() support @@ -61,4 +85,18 @@ $(OUTPUT)/zt-ptrace: zt-ptrace.c $(OUTPUT)/zt-test: zt-test.S $(ASM_UTILS_LINUX) $(CC) -nostdlib $^ -o $@ =20 +$(OUTPUT)/fpsimd-test-kvm.elf: fpsimd-test.S $(ASM_UTILS_KVM) $(KVM_LDS) + $(CC) $(KVM_LDFLAGS) $(filter %.S,$^) -o $@ +$(OUTPUT)/sve-test-kvm.elf: sve-test.S $(ASM_UTILS_KVM) $(KVM_LDS) + $(CC) $(KVM_LDFLAGS) $(filter %.S,$^) -o $@ +$(OUTPUT)/ssve-test-kvm.elf: sve-test.S $(ASM_UTILS_KVM) $(KVM_LDS) + $(CC) -DSSVE $(KVM_LDFLAGS) $(filter %.S,$^) -o $@ +$(OUTPUT)/za-test-kvm.elf: za-test.S $(ASM_UTILS_KVM) $(KVM_LDS) + $(CC) $(KVM_LDFLAGS) $(filter %.S,$^) -o $@ +$(OUTPUT)/zt-test-kvm.elf: zt-test.S $(ASM_UTILS_KVM) $(KVM_LDS) + $(CC) $(KVM_LDFLAGS) $(filter %.S,$^) -o $@ + +$(OUTPUT)/%-kvm.bin: $(OUTPUT)/%-kvm.elf + $(OBJCOPY) -O binary $< $@ + include ../../lib.mk diff --git a/tools/testing/selftests/arm64/fp/asm-utils-kvm.S b/tools/testi= ng/selftests/arm64/fp/asm-utils-kvm.S new file mode 100644 index 000000000000..422d6425ab56 --- /dev/null +++ b/tools/testing/selftests/arm64/fp/asm-utils-kvm.S @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Utility functions for assembly code programs run under fp-stress-vmm. +// +// Copyright 2026, Arm Ltd + +#include + +#include "assembler.h" +#include "asm-offsets.h" +#include "fp-stress-vmm.h" + +#define PSCI_0_2_FN_SYSTEM_OFF 0x84000008 + +// Print a single character x0 to the console +// Clobbers x1 +function putc + movz x1, #(CONSOLE_BASE >> 16), lsl #16 + strb w0, [x1] + ret +endfunction +.globl putc + +// Print a \0 terminated string starting at address x0 to the console. +// Doesn't use putc as a slight optimisation. +// Clobbers x0-x3 +function puts + mov x2, x0 + movz x3, #(CONSOLE_BASE >> 16), lsl #16 + +0: ldrb w0, [x2], #1 + cbz w0, 1f + strb w0, [x3] + b 0b + +1: ret +endfunction +.globl puts + +// Report errors to the host by shutting down, there is no other reason one +// of these test programs should exit. +function exit_error + movz x0, #(PSCI_0_2_FN_SYSTEM_OFF >> 16), lsl #16 + movk x0, #(PSCI_0_2_FN_SYSTEM_OFF & 0xffff) + hvc #0 + +0: b 0b // PSCI should not have returned +endfunction +.globl exit_error + +// Exception vectors. We have no handlers for anything so each entry +// just BRKs with its own number. + .balign 2048 +vectors: + .irp vector, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + .balign 0x80 + brk #\vector + .endr + +// Main program entry point. +// +// The VMM starts us at the very start of the image so the link script +// places .text.boot first. + .section .text.boot, "ax" +.globl _start +function _start + // Vectors that report any exception we take to the VMM. + adr x0, vectors + msr VBAR_EL1, x0 + + // The VMM sizes our RAM as the image plus GUEST_EXTRA_RAM, put the + // stack at the top of that so it grows down away from the image. + ldr x0, =3D_end + ldr x1, =3DGUEST_EXTRA_RAM + add x0, x0, x1 + and x0, x0, #~15 + mov sp, x0 + + // Log the current EL for diagnostic purposes. + puts "EL:\t\tEL" + mrs x0, CurrentEL + ubfx x0, x0, #2, #2 + bl putdecn + + b main +endfunction diff --git a/tools/testing/selftests/arm64/fp/fp-stress-kvm.lds.S b/tools/t= esting/selftests/arm64/fp/fp-stress-kvm.lds.S new file mode 100644 index 000000000000..f1d44f0ae49c --- /dev/null +++ b/tools/testing/selftests/arm64/fp/fp-stress-kvm.lds.S @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Link script for the flat binary builds of the fp-stress loads which run + * as guests under fp-stress-vmm. + * + * The VMM loads the image at the start of the guest RAM and starts the + * guest there so the startup code has to be first in the image, it is in + * .text.boot for that. + */ + +#include "fp-stress-vmm.h" + +OUTPUT_ARCH(aarch64) +ENTRY(_start) + +SECTIONS +{ + . =3D GUEST_RAM_BASE; + + .text : { + *(.text.boot) + *(.text) + *(.text.*) + } + + .rodata : { + *(.rodata) + *(.rodata.*) + } + + .data : { + *(.data) + *(.data.*) + } + + .bss : { + *(.bss) + *(.bss.*) + *(COMMON) + } + + . =3D ALIGN(16); + _end =3D .; + + /DISCARD/ : { + *(.note*) + *(.comment) + *(.eh_frame*) + } +} + +/* + * The VMM sizes the guest RAM from the size of the image file and the + * guest puts its stack immediately above _end, anything allocated but not + * present in the file would leave the two disagreeing about where the RAM + * ends. + */ +ASSERT(SIZEOF(.bss) =3D=3D 0, "fp-stress guests must not have a .bss") --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D051648B374; Tue, 1 Sep 2026 17:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282605; cv=none; b=moXzbIT4c5tGaEuKZhQncQzjVu+6qy1PeZ5VidK26pfs2k/SRI0+UKhzuIxH3MJ1xgMiY8UEHUIvufhX7TY7hj3dg0iqk1Z+YmNr2D/+JCxh3t2sWJftqaoJg6RBv3Tqy5M1F3iz2yLX2598EHi7BZoKawI/FY4R0W6q2gWei+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282605; c=relaxed/simple; bh=OD+Ba64C7inB0cl5Iu32U66JVXkD8/nZCh6jkxPgkhI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BihnwWgKzSfG2hEorEXW8siT68Okxut5zHo5YTIx1lqQ1/hDStzel930nl180IPEVifc5tKrOsJe4meDlJCq12J32AlQx4qs4uCRMp4F8++/lzCdOABakOb/CwHVQ1OTZXVZE7KktXZZ5PZipGgyoIeykRcmZK0XSzQApefWPX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m7HFcvQ6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m7HFcvQ6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 271851F00A3D; Tue, 1 Sep 2026 17:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282603; bh=UUr2L0xZXuVjXC0opxsWwmpYI8eWn5RdN8+EU6TaHG8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=m7HFcvQ6ZOILVfCIPfGcm2sYoC7+RyTjKQyrVhaLuGAlAaQkpHrqKZdgmymsBlVvu UOTAkmWvAP0w6Npou0cuyHNEwg4+rZ+ihYIhdXQnc4/CSSvlJDBXfJVOAv1QSwOF3K 6a/V2SuAbbwKJIQ0BSI7lZJ4rP0qMiVlgDAC+VNHtI32EUpnuza3+Mef+zscIlYOcn 2veJgDLftSAOpHbT0BJjwdUXEuMyWdNDcIjDrUMRw8/fmuTjuufBDbOnMl7VcRzskf TMKVUbCY4nniS9yeuiGaGUTTvwGk+0AT6SKsnwEH7arwConpLkvkxslfQ2s6ahLKX3 Mg+YchyeYj0aQ== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:50 +0100 Subject: [PATCH 10/11] kselftest/arm64: Use execv() to start fp-stress test loads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-10-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3995; i=broonie@kernel.org; h=from:subject:message-id; bh=OD+Ba64C7inB0cl5Iu32U66JVXkD8/nZCh6jkxPgkhI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbMVzi46ham4MZ37vEa0QuE+9ue1LBEjwxEU OE99wvmAlOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGzAAKCRAk1otyXVSH 0JN5B/4vmuinpRF9rcr/7Xwi3BARN1hFTeH+b0NVSjDDSdFgiRYjK2eoFv8hjldBC22vtMalmQs tZ0Lx0FHcDxL/MQZXNSkoQqM9DeiaQ1UhHTByKLvUM4fXgs1Hse2eFTPim+HLgMzf2/5FzSA4SI W8wSGiGPv/bMKsRy9TYGRIYYuvuVB28lmkI+axBErFzYX4627IN7N6TLsAbFNwQ+YuxHO4jJQPV TISvJ0x1sKaza/1L9c0A+Y0Eo2V/tA1M+uzMTYuvXq6u+YOP1CUkqx8e64Y4pWaCFi54Bv21pUQ HjMf2Ki+JreB0J+EuwEy4WNovrwO8BaPC9vmWSWDHjntWuCU X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB In preparation for adding KVM test loads which will take command line arguments switch to using execv() instead of execl() to start the test load programs. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fp-stress.c | 26 ++++++++++++++++--------= -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c b/tools/testing/s= elftests/arm64/fp/fp-stress.c index 65e01aba96ff..e96fe1ac1ad1 100644 --- a/tools/testing/selftests/arm64/fp/fp-stress.c +++ b/tools/testing/selftests/arm64/fp/fp-stress.c @@ -60,7 +60,7 @@ static int num_processors(void) return nproc; } =20 -static void child_start(struct child_data *child, const char *program) +static void child_start(struct child_data *child, char *const prog_args[]) { int ret, pipefd[2], i; struct epoll_event ev; @@ -116,9 +116,9 @@ static void child_start(struct child_data *child, const= char *program) printf("%d bytes of data on startup pipe\n", ret); close(3); =20 - ret =3D execl(program, program, NULL); - printf("execl(%s) failed: %d (%s)\n", - program, errno, strerror(errno)); + ret =3D execv(prog_args[0], prog_args); + printf("execv(%s) failed: %d (%s)\n", + prog_args[0], errno, strerror(errno)); =20 exit(EXIT_FAILURE); } else { @@ -310,32 +310,35 @@ static void handle_exit_signal(int sig, siginfo_t *in= fo, void *context) =20 static void start_fpsimd(struct child_data *child, int cpu, int copy) { + char *args[] =3D { "./fpsimd-test", NULL }; int ret; =20 ret =3D asprintf(&child->name, "FPSIMD-%d-%d", cpu, copy); if (ret =3D=3D -1) ksft_exit_fail_msg("asprintf() failed\n"); =20 - child_start(child, "./fpsimd-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } =20 static void start_kernel(struct child_data *child, int cpu, int copy) { + char *args[] =3D { "./kernel-test", NULL }; int ret; =20 ret =3D asprintf(&child->name, "KERNEL-%d-%d", cpu, copy); if (ret =3D=3D -1) ksft_exit_fail_msg("asprintf() failed\n"); =20 - child_start(child, "./kernel-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } =20 static void start_sve(struct child_data *child, int vl, int cpu) { + char *args[] =3D { "./sve-test", NULL }; int ret; =20 ret =3D prctl(PR_SVE_SET_VL, vl | PR_SVE_VL_INHERIT); @@ -346,13 +349,14 @@ static void start_sve(struct child_data *child, int v= l, int cpu) if (ret =3D=3D -1) ksft_exit_fail_msg("asprintf() failed\n"); =20 - child_start(child, "./sve-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } =20 static void start_ssve(struct child_data *child, int vl, int cpu) { + char *args[] =3D { "./ssve-test", NULL }; int ret; =20 ret =3D asprintf(&child->name, "SSVE-VL-%d-%d", vl, cpu); @@ -363,13 +367,14 @@ static void start_ssve(struct child_data *child, int = vl, int cpu) if (ret < 0) ksft_exit_fail_msg("Failed to set SME VL %d\n", ret); =20 - child_start(child, "./ssve-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } =20 static void start_za(struct child_data *child, int vl, int cpu) { + char *args[] =3D { "./za-test", NULL }; int ret; =20 ret =3D prctl(PR_SME_SET_VL, vl | PR_SVE_VL_INHERIT); @@ -380,20 +385,21 @@ static void start_za(struct child_data *child, int vl= , int cpu) if (ret =3D=3D -1) ksft_exit_fail_msg("asprintf() failed\n"); =20 - child_start(child, "./za-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } =20 static void start_zt(struct child_data *child, int cpu) { + char *args[] =3D { "./zt-test", NULL }; int ret; =20 ret =3D asprintf(&child->name, "ZT-%d", cpu); if (ret =3D=3D -1) ksft_exit_fail_msg("asprintf() failed\n"); =20 - child_start(child, "./zt-test"); + child_start(child, args); =20 ksft_print_msg("Started %s\n", child->name); } --=20 2.47.3 From nobody Sat Sep 26 12:28:39 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 065E748BD56; Tue, 1 Sep 2026 17:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282607; cv=none; b=F/rSZlt7GqocaElwLyQIjYgCr7lFVIyNDciBbms8QRD7l4apzQ2+oZcaUMtNEVEa5pPIFcGaW+UE2mHb6KlepP1PxzKq5ZFGh6KDI7rv3tRv6zOQs8Bnjw5EcHnXHXzSYKjwUJiWj8hQ3Vo5L2wLBqlkLWoPRH+FfZKQLxHj/YY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788282607; c=relaxed/simple; bh=uBEt48fkdIrhDTjaKvMKXF0+9Hsw4hMyzSvrjNvM2hk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K/NQ2Fmj6q8v4sc4dEa1gFM9UC3rOtDCpcprpsYKn9IYI0/GpZDH3xRetzwJT9wPkLzgSdLRqXTuDoKIyiwxCCDDfRN2P5VZu6Z0YnlwWkPUxxHw99g1jJkzgUwizfiQSWzVFetUVnIOd8dBTxQVfj9U+JDNchUACCYOYe+5Cek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RDyWF401; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RDyWF401" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C68BC1F00ACA; Tue, 1 Sep 2026 17:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788282605; bh=hvbqHcICkknYa23vS53IIzBlXB8gIPFaVx5czPkQzuM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=RDyWF4015QhkHk49lqGVk76m7TKYPTRJ2wknd5RLtp7RkRqsYQSCWJ/3cjyL3a5Of dU8zweNQ5tq6TTGwO/afHVMC1c7Na6tRbE+TFSbLJ7h6gT7x1EWp+7jX3EUn1i6FYB qR6VKwOLNe/ppToLt2mGe8oN5D2lpNnCqSu4UjqvLI082eKUAuoEDoyFt5G298cLXa UrdrMi6d/uzdzKNF96MwA3KjVZzhjYBA4oUSGKndcqIW4j660NgNlMBYsZVdWKvSXs +77G49CNEvnkabh5LwdmPC1WuUwk79ykLx/QuACcXWNd2lZoi4hrE17RCdRRsKM8aP SPmN0NsCuQIHg== From: Mark Brown Date: Tue, 01 Sep 2026 18:06:51 +0100 Subject: [PATCH 11/11] kselftest/arm64: Run KVM guests from fp-stress Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260901-arm64-fp-stress-kvm-v1-11-31bce995b49b@kernel.org> References: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> In-Reply-To: <20260901-arm64-fp-stress-kvm-v1-0-31bce995b49b@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Marc Zyngier , Oliver Upton , Fuad Tabba , Mark Rutland , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=8727; i=broonie@kernel.org; h=from:subject:message-id; bh=uBEt48fkdIrhDTjaKvMKXF0+9Hsw4hMyzSvrjNvM2hk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBqlwbN4akSMGwELlkKeqlfq3eTOnGxRaNSEIYGN hSL7J4l9+2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCapcGzQAKCRAk1otyXVSH 0ExeB/9MfI9CctAFe7/OeJpYmCe8K+Tmqf3Zq+RXkJzgAGKleoXhkP6JmbY/Y6Kc7q63TJnLzdF WuZ7B1DfFoCgYarhTRLEhzbi0LN+x/aQQ0lo32JT5FmLT+q+U4QLWmabrRJVyYXM91+itrUuTJ6 egodvY5Lkz9HXKU0RJPFIRctbVMYCGuXgH9E4hnTQmPfBzGgAffw2ErUk/NJSFT/Ekw0A5weGG1 tmEFNkbk6go5G8KUZaaq3IC7bIzDrW/RkI8vYimwkxCEtlWKUecwBGJmysAcQquxe1SSa0eW+yQ TRrFcyGtKMocv+AoIPRRLMhwCQy0f+DAoYE7kNTsF4ihE4IG X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Now that we have a VMM that integrates with fp-stress and the guest code to run with it extend fp-stress to run KVM guests along with host test loads. When we have access to KVM we start FPSIMD and SVE test loads in KVM on odd numbered CPUs. If nested virtualisation is supported half of those will be run in guests with EL2 support. Although the VMM supports protected guests we do not currently start any since doing so taints the kernel, having this happen as standard is likely to lead to confusion if other tests fail on a system with pKVM enabled. If any non-virtualisable SVE VLs are detected we will skip SVE, currently no such systems are known to exist. Should any be encountered the appropriate enumeration code can be implemented. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/fp-stress.c | 204 +++++++++++++++++++++++= +++- 1 file changed, 199 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/fp-stress.c b/tools/testing/s= elftests/arm64/fp/fp-stress.c index e96fe1ac1ad1..968983a5e39f 100644 --- a/tools/testing/selftests/arm64/fp/fp-stress.c +++ b/tools/testing/selftests/arm64/fp/fp-stress.c @@ -7,6 +7,7 @@ #define _POSIX_C_SOURCE 199309L =20 #include +#include #include #include #include @@ -18,11 +19,13 @@ #include #include #include +#include #include #include #include #include #include +#include =20 #include "kselftest.h" =20 @@ -46,6 +49,11 @@ static struct epoll_event *evs; static int tests; static int num_children; static bool terminate; +static int sve_vl_count, sme_vl_count; +static int sve_vls[MAX_VLS], sme_vls[MAX_VLS]; +static bool have_kvm; +static bool have_kvm_el2; +static bool have_kvm_sve; =20 static int startup_pipe[2]; =20 @@ -60,6 +68,14 @@ static int num_processors(void) return nproc; } =20 +static char *kvm_el_arg(int cpu) +{ + if (have_kvm_el2 && ((cpu % 4) =3D=3D 3)) + return "--el2"; + else + return "--el1"; +} + static void child_start(struct child_data *child, char *const prog_args[]) { int ret, pipefd[2], i; @@ -322,6 +338,21 @@ static void start_fpsimd(struct child_data *child, int= cpu, int copy) ksft_print_msg("Started %s\n", child->name); } =20 +static void start_fpsimd_kvm(struct child_data *child, int cpu, int copy) +{ + char *args[] =3D { "./fp-stress-vmm", kvm_el_arg(cpu), + "./fpsimd-test-kvm.bin", NULL }; + int ret; + + ret =3D asprintf(&child->name, "FPSIMD-KVM-%d-%d", cpu, copy); + if (ret =3D=3D -1) + ksft_exit_fail_msg("asprintf() failed\n"); + + child_start(child, args); + + ksft_print_msg("Started %s\n", child->name); +} + static void start_kernel(struct child_data *child, int cpu, int copy) { char *args[] =3D { "./kernel-test", NULL }; @@ -354,6 +385,26 @@ static void start_sve(struct child_data *child, int vl= , int cpu) ksft_print_msg("Started %s\n", child->name); } =20 +static void start_sve_kvm(struct child_data *child, int vl, int cpu) +{ + char *args[] =3D { "./fp-stress-vmm", "--sve", NULL, kvm_el_arg(cpu), + "./sve-test-kvm.bin", NULL }; + char vl_str[32]; + int ret; + + /* Our VLs are in bytes, fp-stress-vmm wants bits */ + snprintf(vl_str, sizeof(vl_str), "%d", vl * 8); + args[2] =3D vl_str; + + ret =3D asprintf(&child->name, "SVE-KVM-VL-%d-%d", vl, cpu); + if (ret =3D=3D -1) + ksft_exit_fail_msg("asprintf() failed\n"); + + child_start(child, args); + + ksft_print_msg("Started %s\n", child->name); +} + static void start_ssve(struct child_data *child, int vl, int cpu) { char *args[] =3D { "./ssve-test", NULL }; @@ -404,6 +455,136 @@ static void start_zt(struct child_data *child, int cp= u) ksft_print_msg("Started %s\n", child->name); } =20 +static void kvm_put_vcpu(int vm_fd, int vcpu_fd) +{ + if (vcpu_fd >=3D 0) + close(vcpu_fd); + if (vm_fd >=3D 0) + close(vm_fd); +} + +static bool kvm_get_vcpu(int kvm_fd, int feature, int *vm_fd, int *vcpu_fd) +{ + struct kvm_vcpu_init init; + int ret; + + *vcpu_fd =3D -1; + + *vm_fd =3D ioctl(kvm_fd, KVM_CREATE_VM, 0); + if (*vm_fd < 0) { + ksft_print_msg("KVM_CREATE_VM failed: %s (%d)\n", + strerror(errno), errno); + return false; + } + + *vcpu_fd =3D ioctl(*vm_fd, KVM_CREATE_VCPU, 0); + if (*vcpu_fd < 0) { + ksft_print_msg("KVM_CREATE_VCPU failed: %s (%d)\n", + strerror(errno), errno); + goto err; + } + + ret =3D ioctl(*vm_fd, KVM_ARM_PREFERRED_TARGET, &init); + if (ret) { + ksft_print_msg("KVM_ARM_PREFERRED_TARGET failed: %s (%d)\n", + strerror(errno), errno); + goto err; + } + + init.features[0] |=3D 1 << feature; + ret =3D ioctl(*vcpu_fd, KVM_ARM_VCPU_INIT, &init); + if (ret) { + ksft_print_msg("KVM_ARM_VCPU_INIT feature %d failed: %s (%d)\n", + feature, strerror(errno), errno); + goto err; + } + + return true; + +err: + kvm_put_vcpu(*vm_fd, *vcpu_fd); + return false; +} + +static void probe_kvm_sve(int kvm_fd) +{ + __u64 vqs[KVM_ARM64_SVE_VLS_WORDS]; + struct kvm_one_reg reg =3D { + .id =3D KVM_REG_ARM64_SVE_VLS, + .addr =3D (__u64)vqs, + }; + int vm_fd, vcpu_fd, i; + unsigned int vq; + + if (!sve_vl_count) + return; + + if (!ioctl(kvm_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE)) { + ksft_print_msg("No KVM SVE support\n"); + return; + } + + if (!kvm_get_vcpu(kvm_fd, KVM_ARM_VCPU_SVE, &vm_fd, &vcpu_fd)) + return; + + /* + * The vector length set is readable without finalizing the vCPU, + * we only want to look at it rather than run anything. + */ + if (ioctl(vcpu_fd, KVM_GET_ONE_REG, ®)) { + ksft_print_msg("Failed to read KVM SVE VLs: %s (%d)\n", + strerror(errno), errno); + goto out; + } + + have_kvm_sve =3D true; + for (i =3D 0; i < sve_vl_count; i++) { + vq =3D sve_vq_from_vl(sve_vls[i]); + + if (!(vqs[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] & + (1ULL << ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)))) { + ksft_print_msg("KVM has no SVE VL %d\n", sve_vls[i]); + have_kvm_sve =3D false; + } + } + +out: + kvm_put_vcpu(vm_fd, vcpu_fd); +} + +/* + * We don't act as a VMM for guests directly, this just enumerates what + * can be run with KVM. + */ +static void probe_kvm(void) +{ + int fd, ret; + + fd =3D open("/dev/kvm", O_RDWR | O_CLOEXEC); + if (fd < 0) { + ksft_print_msg("Not using KVM, /dev/kvm: %s (%d)\n", + strerror(errno), errno); + return; + } + + ret =3D ioctl(fd, KVM_GET_API_VERSION, 0); + if (ret !=3D KVM_API_VERSION) { + ksft_print_msg("Not using KVM, API version %d not %d\n", + ret, KVM_API_VERSION); + close(fd); + return; + } + + have_kvm =3D true; + + if (ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_EL2)) + have_kvm_el2 =3D true; + + probe_kvm_sve(fd); + + close(fd); +} + static void probe_vls(int vls[], int *vl_count, int set_vl) { unsigned int vq; @@ -460,10 +641,8 @@ int main(int argc, char **argv) int timeout =3D 10 * (1000 / SIGNAL_INTERVAL_MS); int poll_interval =3D 5000; int cpus, i, j, c; - int sve_vl_count, sme_vl_count; bool all_children_started =3D false; int seen_children; - int sve_vls[MAX_VLS], sme_vls[MAX_VLS]; bool have_sme2; struct sigaction sa; =20 @@ -509,9 +688,15 @@ int main(int argc, char **argv) ksft_print_header(); ksft_set_plan(tests); =20 + probe_kvm(); + ksft_print_msg("%d CPUs, %d SVE VLs, %d SME VLs, SME2 %s\n", cpus, sve_vl_count, sme_vl_count, have_sme2 ? "present" : "absent"); + ksft_print_msg("KVM: %s, %s EL2, %s SVE\n", + have_kvm ? "present" : "absent", + have_kvm_el2 ? "with" : "without", + have_kvm_sve ? "with" : "without"); =20 if (timeout > 0) ksft_print_msg("Will run for %d\n", timeout); @@ -559,11 +744,20 @@ int main(int argc, char **argv) tests); =20 for (i =3D 0; i < cpus; i++) { - start_fpsimd(&children[num_children++], i, 0); + if (have_kvm && (i % 2)) + start_fpsimd_kvm(&children[num_children++], i, 0); + else + start_fpsimd(&children[num_children++], i, 0); start_kernel(&children[num_children++], i, 0); =20 - for (j =3D 0; j < sve_vl_count; j++) - start_sve(&children[num_children++], sve_vls[j], i); + for (j =3D 0; j < sve_vl_count; j++) { + if (have_kvm_sve && (i % 2)) + start_sve_kvm(&children[num_children++], + sve_vls[j], i); + else + start_sve(&children[num_children++], + sve_vls[j], i); + } =20 for (j =3D 0; j < sme_vl_count; j++) { start_ssve(&children[num_children++], sme_vls[j], i); --=20 2.47.3