Thread (1 message) 1 message, 1 author, 2017-08-09

Re: [PATCH 01/11] KVM: arm64: Store vcpu on the stack during __guest_enter()

From: Christoffer Dall <hidden>
Date: 2017-08-09 08:48:09
Also in: kvmarm, linux-arm-kernel

On Tue, Aug 08, 2017 at 05:48:29PM +0100, James Morse wrote:
Hi Christoffer,

On 06/06/17 20:59, Christoffer Dall wrote:
quoted
On Mon, May 15, 2017 at 06:43:49PM +0100, James Morse wrote:
quoted
KVM uses tpidr_el2 as its private vcpu register, which makes sense for
non-vhe world switch as only KVM can access this register. This means
vhe Linux has to use tpidr_el1, which KVM has to save/restore as part
of the host context.

__guest_enter() stores the host_ctxt on the stack, do the same with
the vcpu.
quoted
quoted
diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S
index 12ee62d6d410..113735df7d01 100644
--- a/arch/arm64/kvm/hyp/entry.S
+++ b/arch/arm64/kvm/hyp/entry.S
@@ -159,9 +159,15 @@ abort_guest_exit_end:
 ENDPROC(__guest_exit)
 
 ENTRY(__fpsimd_guest_restore)
+	// x0: esr
+	// x1: vcpu
+	// x2-x29,lr: vcpu regs
+	// vcpu x0-x1 on the stack
 	stp	x2, x3, [sp, #-16]!
 	stp	x4, lr, [sp, #-16]!
 
+	mov	x3, x1
+
nit: can you avoid this by using x1 for the vcpu pointer in this routine
instead?
Unfortunately x1 is clobbered by the __fpsimd_{save,restore}_state() macros that
are called further down this function.

(its a bit obscure:
quoted
fpsimd_save	x0, 1
that '1' is used to generate 'x1' or 'w1' in includes/asm/fpsimdmacros.h)
Ah, I guess I missed that.

Thanks,
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help