Same as for arm32, do no longer hvc for getting Linux's hyp-stub vector
address. We now use the address in the Hypervisor header.
For reasons of simplicity, we now restore vbar_el2 in inline assembly.
hypervisor/arch/arm64/asm-defines.c | 1 -
hypervisor/arch/arm64/entry.S | 26 +++++---------------------
hypervisor/arch/arm64/include/asm/percpu.h | 1 -
hypervisor/arch/arm64/setup.c | 4 ++++
4 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/hypervisor/arch/arm64/asm-defines.c b/hypervisor/arch/arm64/asm-defines.c
index 5a92b00a..d850b1aa 100644
--- a/hypervisor/arch/arm64/asm-defines.c
+++ b/hypervisor/arch/arm64/asm-defines.c
@@ -32,7 +32,6 @@ void common(void)
__builtin_offsetof(struct per_cpu, stack) + \
FIELD_SIZEOF(struct per_cpu, stack));
DEFINE(PERCPU_SIZE_SHIFT_ASM, PERCPU_SIZE_SHIFT);
- OFFSET(PERCPU_SAVED_VECTORS, per_cpu, saved_vectors);
BLANK();
DEFINE(DCACHE_CLEAN_ASM, DCACHE_CLEAN);
diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S
index d1377c75..8dfdb249 100644
--- a/hypervisor/arch/arm64/entry.S
+++ b/hypervisor/arch/arm64/entry.S
@@ -18,7 +18,6 @@
#include <asm/percpu.h>
#include <asm/jailhouse_hypercall.h>
-#define LINUX_HVC_GET_VECTORS 0
#define LINUX_HVC_SET_VECTORS 1
/* x11 must contain the virt-to-phys offset */
@@ -45,17 +44,11 @@ arch_entry:
* x13: virtual hypervisor address
* x14: physical UART address
* x15: virtual UART address
- * x16: saved hyp vectors
- * x17: cpuid
- * x18: caller lr
+ * x16: cpuid
+ * x17: caller lr
*/
- mov x17, x0
- mov x18, x30
-
- /* keep the Linux stub EL2 vectors for later */
- mov x0, #LINUX_HVC_GET_VECTORS
- hvc #0
mov x16, x0
+ mov x17, x30
/*
* Access the just updated hypervisor_header prior to turning off the
@@ -128,7 +121,7 @@ el2_entry:
adr x1, hyp_vectors
msr vbar_el2, x1
- mov x0, x17 /* preserved cpuid, will be passed to entry */
+ mov x0, x16 /* preserved cpuid, will be passed to entry */
adrp x1, __page_pool
mov x2, #(1 << PERCPU_SIZE_SHIFT_ASM)
/*
@@ -139,7 +132,7 @@ el2_entry:
/* set up the stack and push the root cell's callee saved registers */
add sp, x1, #PERCPU_STACK_END
- stp x29, x18, [sp, #-16]! /* note: our caller lr is in x18 */
+ stp x29, x17, [sp, #-16]! /* note: our caller lr is in x17 */
stp x27, x28, [sp, #-16]!
stp x25, x26, [sp, #-16]!
stp x23, x24, [sp, #-16]!
@@ -156,10 +149,6 @@ el2_entry:
mov x29, xzr /* reset fp,lr */
mov x30, xzr
- /* save the Linux stub vectors we kept earlier */
- add x2, x1, #PERCPU_SAVED_VECTORS
- str x16, [x2]
-
/* Call entry(cpuid, struct per_cpu*). Should not return. */
bl entry
b .
@@ -189,11 +178,6 @@ shutdown_el2:
msr tpidr_el2, xzr
- /* hand over control of EL2 back to Linux */
- add x1, x0, #PERCPU_SAVED_VECTORS
- ldr x2, [x1]
- msr vbar_el2, x2
-
/* Call vmreturn(guest_registers) */
add x0, x0, #(PERCPU_STACK_END - 32 * 8)
b vmreturn
diff --git a/hypervisor/arch/arm64/include/asm/percpu.h b/hypervisor/arch/arm64/include/asm/percpu.h
index f00b8fb4..5bfece6d 100644
--- a/hypervisor/arch/arm64/include/asm/percpu.h
+++ b/hypervisor/arch/arm64/include/asm/percpu.h
@@ -27,7 +27,6 @@
struct per_cpu {
u8 stack[PAGE_SIZE];
- unsigned long saved_vectors;
/* common fields */
unsigned int cpu_id;
diff --git a/hypervisor/arch/arm64/setup.c b/hypervisor/arch/arm64/setup.c
index 0e49bb09..6ba002a0 100644
--- a/hypervisor/arch/arm64/setup.c
+++ b/hypervisor/arch/arm64/setup.c
@@ -131,6 +131,10 @@ void arch_shutdown_self(struct per_cpu *cpu_data)
arch_paging_flush_cpu_caches(cpu_data, sizeof(*cpu_data));
dsb(ish);
+ /* hand over control of EL2 back to Linux */
+ asm volatile("msr vbar_el2, %0"
+ :: "r" (hypervisor_header.arm_hyp_info.saved_vector) :);
+
/* Return to EL1 */
shutdown_func((struct per_cpu *)paging_hvirt2phys(cpu_data));
}
--
2.13.1