@@ -22,6 +22,7 @@
#include <asm/kvm_mmu.h>
#include <asm/pgtable-hwdef.h>
#include <asm/sysreg.h>
+#include <asm/virt.h>
.text
.pushsection .hyp.idmap.text, "ax"
@@ -58,6 +59,9 @@ __invalid:
* x2: HYP vectors
*/
__do_hyp_init:
+ /* Check for a stub HVC call */
+ cmp x0, #HVC_STUB_HCALL_NR
+ b.lo __kvm_handle_stub_hvc
msr ttbr0_el2, x0
@@ -119,6 +123,9 @@ __do_hyp_init:
eret
ENDPROC(__kvm_hyp_init)
+ENTRY(__kvm_handle_stub_hvc)
+ cmp x0, #HVC_RESET_VECTORS
+ b.ne 1f
/*
* Reset kvm back to the hyp stub.
*/
@@ -133,9 +140,15 @@ ENTRY(__kvm_hyp_reset)
/* Install stub vectors */
adr_l x0, __hyp_stub_vectors
msr vbar_el2, x0
+ b exit
+1: /* Bad stub call */
+ ldr x0, =HVC_STUB_ERR
+
+exit:
eret
ENDPROC(__kvm_hyp_reset)
+ENDPROC(__kvm_handle_stub_hvc)
.ltorg