summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@cvs.openbsd.org>2023-07-05 18:23:11 +0000
committerAnton Lindqvist <anton@cvs.openbsd.org>2023-07-05 18:23:11 +0000
commit205f38591802247882a1aac84b2e8c56acd07702 (patch)
tree251012da26477537fffbff78078ad788be4f194d
parent99326b8dcc01239c320c1338997604e259ad413b (diff)
The hypercall page populated with instructions by the hypervisor is not IBT
compatible due to lack of endbr64. Replace the indirect call with a new hv_hypercall_trampoline() routine which jumps to the hypercall page without any indirection. Allows me to boot OpenBSD using Hyper-V on Windows 11 again. ok guenther@
-rw-r--r--sys/arch/amd64/amd64/locore.S24
-rw-r--r--sys/dev/pv/hyperv.c5
2 files changed, 18 insertions, 11 deletions
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index 677c816d6f9..ec41559e6bf 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.134 2023/04/17 00:14:59 deraadt Exp $ */
+/* $OpenBSD: locore.S,v 1.135 2023/07/05 18:23:10 anton Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -1149,20 +1149,28 @@ NENTRY(rdmsr_resume)
lfence
END(rdmsr_safe)
-#if NXEN > 0
+#if NHYPERV > 0
+/* uint64_t hv_hypercall_trampoline(uint64_t control, paddr_t input, paddr_t output) */
+NENTRY(hv_hypercall_trampoline)
+ endbr64
+ mov %rdx, %r8
+ mov %rsi, %rdx
+ mov %rdi, %rcx
+ jmp hv_hypercall_page
+END(hv_hypercall_trampoline)
/* Hypercall page needs to be page aligned */
.text
.align NBPG, 0xcc
- .globl xen_hypercall_page
-xen_hypercall_page:
+ .globl hv_hypercall_page
+hv_hypercall_page:
.skip 0x1000, 0xcc
-#endif /* NXEN > 0 */
+#endif /* NHYPERV > 0 */
-#if NHYPERV > 0
+#if NXEN > 0
/* Hypercall page needs to be page aligned */
.text
.align NBPG, 0xcc
- .globl hv_hypercall_page
-hv_hypercall_page:
+ .globl xen_hypercall_page
+xen_hypercall_page:
.skip 0x1000, 0xcc
#endif /* NXEN > 0 */
diff --git a/sys/dev/pv/hyperv.c b/sys/dev/pv/hyperv.c
index 08a713d814d..da9bf3ae6d7 100644
--- a/sys/dev/pv/hyperv.c
+++ b/sys/dev/pv/hyperv.c
@@ -407,9 +407,8 @@ hv_hypercall(struct hv_softc *sc, uint64_t control, void *input,
}
#ifdef __amd64__
- __asm__ volatile ("mov %0, %%r8" : : "r" (output_pa) : "r8");
- __asm__ volatile ("call *%3" : "=a" (status) : "c" (control),
- "d" (input_pa), "m" (sc->sc_hc));
+ extern uint64_t hv_hypercall_trampoline(uint64_t, paddr_t, paddr_t);
+ status = hv_hypercall_trampoline(control, input_pa, output_pa);
#else /* __i386__ */
{
uint32_t control_hi = control >> 32;