HACK: Install a trampoline instruction into pvmfw memory
In order to aid testing on systems that provide an empty pvmfw carveout,
install a single trampoline instruction from the host prior to
deprivilege which simply branches to the address in X4.
Signed-off-by: Will Deacon <will@kernel.org>
diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c
index b769a88..a795efab 100644
--- a/arch/arm64/kvm/pkvm.c
+++ b/arch/arm64/kvm/pkvm.c
@@ -314,3 +314,21 @@
kvm->arch.pkvm.enabled = true;
return 0;
}
+
+static int BODGE_install_loader(void)
+{
+ void *addr;
+
+ if (!pkvm_firmware_mem)
+ return -ENOMEM;
+
+ addr = memremap(pkvm_firmware_mem->base, PAGE_SIZE, MEMREMAP_WB);
+ if (!addr)
+ return -EFAULT;
+
+ pr_info("!! Installing dummy pvmfw into reserved memory region...\n");
+ ((u32 *)addr)[0] = 0xd61f0080; // BR X4
+ memunmap(addr);
+ return 0;
+}
+arch_initcall(BODGE_install_loader);