diff --git a/tools/testing/selftests/arm64/fp/.gitignore b/tools/testing/selftests/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/selftests/arm64/fp/Makefile
index 3c4e17a34776..dbe0fcd4a722 100644
--- a/tools/testing/selftests/arm64/fp/Makefile
+++ b/tools/testing/selftests/arm64/fp/Makefile
@@ -3,6 +3,8 @@
# A proper top_srcdir is needed by KSFT(lib.mk)
top_srcdir = $(realpath ../../../../../)
+include ../../../../build/Build.include
+
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := \
@@ -21,17 +23,41 @@ TEST_GEN_PROGS_EXTENDED := fp-pidbench fp-stress-vmm fpsimd-test \
zt-test \
vlset
TEST_PROGS_EXTENDED := fpsimd-stress sve-stress ssve-stress za-stress
+TEST_GEN_FILES := \
+ fpsimd-test-kvm.bin \
+ sve-test-kvm.bin \
+ ssve-test-kvm.bin \
+ za-test-kvm.bin \
+ zt-test-kvm.bin
EXTRA_CLEAN += $(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)
ASM_UTILS_LINUX := $(OUTPUT)/asm-utils.o $(OUTPUT)/asm-utils-linux.o
+ASM_UTILS_KVM := asm-utils.S asm-utils-kvm.S
+
+ifneq ($(LLVM),)
+OBJCOPY ?= $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
+else
+OBJCOPY ?= $(CROSS_COMPILE)objcopy
+endif
# For sysreg definitons
ARCH_INCLUDES := $(KHDR_INCLUDES) -I$(top_srcdir)/tools/arch/arm64/include \
-I$(top_srcdir)/tools/include \
-I$(top_srcdir)/tools/include/generated
+# 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 := $(OUTPUT)/fp-stress-kvm.lds
+KVM_LDFLAGS := -nostdlib -static $(ARCH_INCLUDES) -D__ASSEMBLY__ \
+ -Wl,-T,$(KVM_LDS)
+
+$(KVM_LDS): fp-stress-kvm.lds.S fp-stress-vmm.h
+ $(CC) -E -P -x c $< -o $@
+
$(OUTPUT)/fp-stress-vmm: CFLAGS += $(ARCH_INCLUDES)
# Build with nolibc to avoid effects due to libc's clone() support
@@ -61,4 +87,18 @@ $(OUTPUT)/zt-ptrace: zt-ptrace.c
$(OUTPUT)/zt-test: zt-test.S $(ASM_UTILS_LINUX)
$(CC) -nostdlib $^ -o $@
+$(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/testing/selftests/arm64/fp/asm-utils-kvm.S
new file mode 100644
index 000000000000..89a6385a5768
--- /dev/null
+++ b/tools/testing/selftests/arm64/fp/asm-utils-kvm.S
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Utility functions for assembly code programs run under fp-stress-vmm.
+//
+// Copyright 2026, Arm Ltd
+
+#include <asm/sysreg.h>
+
+#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)
+
+ // PSCI uses SMC at EL2 and HVC at EL1.
+ mrs x1, CurrentEL
+ cmp x1, #(2 << 2)
+ b.eq 1f
+ hvc #0
+ b 2f
+
+1: smc #0
+2: b 2b // 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, =_end
+ ldr x1, =GUEST_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/testing/selftests/arm64/fp/fp-stress-kvm.lds.S
new file mode 100644
index 000000000000..ecb904bbf4ec
--- /dev/null
+++ b/tools/testing/selftests/arm64/fp/fp-stress-kvm.lds.S
@@ -0,0 +1,65 @@
+/* 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)
+
+PHDRS
+{
+ text PT_LOAD FLAGS(5); /* PF_R | PF_X */
+ rodata PT_LOAD FLAGS(4); /* PF_R */
+ data PT_LOAD FLAGS(6); /* PF_R | PF_W */
+}
+
+SECTIONS
+{
+ . = GUEST_RAM_BASE;
+
+ .text : {
+ *(.text.boot)
+ *(.text)
+ *(.text.*)
+ } :text
+
+ .rodata : {
+ *(.rodata)
+ *(.rodata.*)
+ } :rodata
+
+ .data : {
+ *(.data)
+ *(.data.*)
+ } :data
+
+ .bss : {
+ *(.bss)
+ *(.bss.*)
+ *(COMMON)
+ } :data
+
+ . = ALIGN(16);
+ _end = .;
+
+ /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) == 0, "fp-stress guests must not have a .bss")
--
2.47.3