This is the first step to get rid of arch_handle_exit().

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 hypervisor/arch/arm64/asm-defines.c |  3 +++
 hypervisor/arch/arm64/entry.S       | 14 ++++++++++++++
 hypervisor/arch/arm64/traps.c       |  2 --
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/hypervisor/arch/arm64/asm-defines.c 
b/hypervisor/arch/arm64/asm-defines.c
index f513c540..ce8e224d 100644
--- a/hypervisor/arch/arm64/asm-defines.c
+++ b/hypervisor/arch/arm64/asm-defines.c
@@ -35,6 +35,9 @@ void common(void)
               __builtin_offsetof(struct per_cpu, stack) + \
               FIELD_SIZEOF(struct per_cpu, stack));
        DEFINE(PERCPU_SIZE_ASM, sizeof(struct per_cpu));
+       DEFINE(CPU_STAT_VMEXITS_TOTAL, LOCAL_CPU_BASE +
+              __builtin_offsetof(struct per_cpu,
+                      public.stats[JAILHOUSE_CPU_STAT_VMEXITS_TOTAL]));
        BLANK();
 
        DEFINE(DCACHE_CLEAN_ASM, DCACHE_CLEAN);
diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S
index 2d6c69b2..97033e91 100644
--- a/hypervisor/arch/arm64/entry.S
+++ b/hypervisor/arch/arm64/entry.S
@@ -21,6 +21,10 @@
 #define LINUX_HVC_SET_VECTORS_LEGACY   1
 #define LINUX_HVC_SET_VECTORS          0
 
+       .data
+vmexits_total:
+       .quad CPU_STAT_VMEXITS_TOTAL
+
 /* x11 must contain the virt-to-phys offset */
 .macro virt2phys, register
        add     \register, \register, x11
@@ -282,6 +286,16 @@ bootstrap_vectors:
 
        /* [x0-x4] may now be clobbered. */
 
+       /*
+        * increase vmexits_total on each exit. Using x3 and x4 will preserve
+        * x0, which still holds the guest's value on exit.
+        */
+       ldr     x3, =vmexits_total
+       ldr     x3, [x3]
+       ldr     x4, [x3]
+       add     x4, x4, #1
+       str     x4, [x3]
+
        /* Fill the rest of the union registers. Should comply with 
NUM_USR_REGS */
        stp     x5, x6, [sp, #(3 * 16)]
        stp     x7, x8, [sp, #(4 * 16)]
diff --git a/hypervisor/arch/arm64/traps.c b/hypervisor/arch/arm64/traps.c
index e2397b11..42dd9792 100644
--- a/hypervisor/arch/arm64/traps.c
+++ b/hypervisor/arch/arm64/traps.c
@@ -194,8 +194,6 @@ static void arch_dump_exit(union registers *regs, const 
char *reason)
 
 union registers *arch_handle_exit(union registers *regs)
 {
-       this_cpu_public()->stats[JAILHOUSE_CPU_STAT_VMEXITS_TOTAL]++;
-
        switch (regs->exit_reason) {
        case EXIT_REASON_EL1_IRQ:
                irqchip_handle_irq();
-- 
2.20.1

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to