summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/Makefile
diff options
context:
space:
mode:
authorAaron Lewis <aaronlewis@google.com>2023-07-28 17:36:14 -0700
committerSean Christopherson <seanjc@google.com>2023-08-02 14:41:59 -0700
commite5119382499cefc839097dcc78f27ab00131e7ad (patch)
treea46d59739c5b576c43c91356ba9dea961514a90c /tools/testing/selftests/kvm/Makefile
parenta1c1b55e116c14de4f8a78286b502101f2a1620c (diff)
KVM: selftests: Add guest_snprintf() to KVM selftests
Add a local version of guest_snprintf() for use in the guest. Having a local copy allows the guest access to string formatting options without dependencies on LIBC. LIBC is problematic because it heavily relies on both AVX-512 instructions and a TLS, neither of which are guaranteed to be set up in the guest. The file guest_sprintf.c was lifted from arch/x86/boot/printf.c and adapted to work in the guest, including the addition of buffer length. I.e. s/sprintf/snprintf/ The functions where prefixed with "guest_" to allow guests to explicitly call them. A string formatted by this function is expected to succeed or die. If something goes wrong during the formatting process a GUEST_ASSERT() will be thrown. Signed-off-by: Aaron Lewis <aaronlewis@google.com> Link: https://lore.kernel.org/all/mtdi6smhur5rqffvpu7qux7mptonw223y2653x2nwzvgm72nlo@zyc4w3kwl3rg [sean: add a link to the discussion of other options] Link: https://lore.kernel.org/r/20230729003643.1053367-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/Makefile')
-rw-r--r--tools/testing/selftests/kvm/Makefile1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index f6c14ab476ac..f65889f5a083 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -23,6 +23,7 @@ LIBKVM += lib/guest_modes.c
LIBKVM += lib/io.c
LIBKVM += lib/kvm_util.c
LIBKVM += lib/memstress.c
+LIBKVM += lib/guest_sprintf.c
LIBKVM += lib/rbtree.c
LIBKVM += lib/sparsebit.c
LIBKVM += lib/test_util.c