Merge tag 'nios2-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan...
[sfrench/cifs-2.6.git] / arch / arm64 / kvm / hyp / hyp-entry.S
index 5e9052f087f289851108daf8c5521a9f2fe9c617..5170ce1021da05a6ce3b7f50ca8830c6abcdf66f 100644 (file)
         * Shuffle the parameters before calling the function
         * pointed to in x0. Assumes parameters in x[1,2,3].
         */
+       str     lr, [sp, #-16]!
        mov     lr, x0
        mov     x0, x1
        mov     x1, x2
        mov     x2, x3
        blr     lr
+       ldr     lr, [sp], #16
 .endm
 
 ENTRY(__vhe_hyp_call)
-       str     lr, [sp, #-16]!
        do_el2_call
-       ldr     lr, [sp], #16
        /*
         * We used to rely on having an exception return to get
         * an implicit isb. In the E2H case, we don't have it anymore.
@@ -53,21 +53,6 @@ ENTRY(__vhe_hyp_call)
        ret
 ENDPROC(__vhe_hyp_call)
 
-/*
- * Compute the idmap address of __kvm_hyp_reset based on the idmap
- * start passed as a parameter, and jump there.
- *
- * x0: HYP phys_idmap_start
- */
-ENTRY(__kvm_hyp_teardown)
-       mov     x4, x0
-       adr_l   x3, __kvm_hyp_reset
-
-       /* insert __kvm_hyp_reset()s offset into phys_idmap_start */
-       bfi     x4, x3, #0, #PAGE_SHIFT
-       br      x4
-ENDPROC(__kvm_hyp_teardown)
-       
 el1_sync:                              // Guest trapped into EL2
        stp     x0, x1, [sp, #-16]!
 
@@ -87,10 +72,24 @@ alternative_endif
        /* Here, we're pretty sure the host called HVC. */
        ldp     x0, x1, [sp], #16
 
-       cmp     x0, #HVC_GET_VECTORS
-       b.ne    1f
-       mrs     x0, vbar_el2
-       b       2f
+       /* Check for a stub HVC call */
+       cmp     x0, #HVC_STUB_HCALL_NR
+       b.hs    1f
+
+       /*
+        * Compute the idmap address of __kvm_handle_stub_hvc and
+        * jump there. Since we use kimage_voffset, do not use the
+        * HYP VA for __kvm_handle_stub_hvc, but the kernel VA instead
+        * (by loading it from the constant pool).
+        *
+        * Preserve x0-x4, which may contain stub parameters.
+        */
+       ldr     x5, =__kvm_handle_stub_hvc
+       ldr_l   x6, kimage_voffset
+
+       /* x5 = __pa(x5) */
+       sub     x5, x5, x6
+       br      x5
 
 1:
        /*
@@ -99,7 +98,7 @@ alternative_endif
        kern_hyp_va     x0
        do_el2_call
 
-2:     eret
+       eret
 
 el1_trap:
        /*