From: Ian Campbell Subject: [PATCH 12/17] xen: arm: handle traps from 64-bit guests Date: Mon, 29 Jul 2013 13:21:01 +0100 Message-ID: <1375100466-7564-12-git-send-email-ian.campbell@citrix.com> References: <1375100431.14896.95.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1375100431.14896.95.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: julien.grall@citrix.com, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org While there observe that we weren't ever restoring the outer stack frame, even for 32-bit guests when running a 64-bit hypervisor! The outer stack frame "only" contains most of the SPSR registers for 32-bit... Signed-off-by: Ian Campbell --- v4: split out various bits of refactoring into precursor patches. v3: actually restore the outer stack frame! Due to this change I have dropped the previous Acks. --- xen/arch/arm/arm64/entry.S | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 41 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 390a11d..9cda8f1 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -56,6 +56,38 @@ lr .req x30 // link register .endm + .macro exit_guest, compat + + add x21, sp, #UREGS_SPSR_el1 + ldr x23, [x21] + msr SPSR_el1, x23 + + .if \compat == 0 /* Aarch64 mode */ + + add x21, sp, #UREGS_SP_el0 + ldr x22, [x21] + msr SP_el0, x22 + + add x21, sp, #UREGS_SP_el1 + ldp x22, x23, [x21] + msr SP_el1, x22 + msr ELR_el1, x23 + + .else /* Aarch32 mode */ + + add x21, sp, #UREGS_SPSR_fiq + ldp w22, w23, [x21] + msr SPSR_fiq, x22 + msr SPSR_irq, x23 + + add x21, sp, #UREGS_SPSR_und + ldp w22, w23, [x21] + msr SPSR_und, x22 + msr SPSR_abt, x23 + + .endif + + .endm /* * Save state on entry to hypervisor, restore on exit */ @@ -102,6 +134,8 @@ lr .req x30 // link register bl leave_hypervisor_tail /* Disables interrupts on return */ + exit_guest \compat + .endif b return_from_trap @@ -155,11 +189,16 @@ hyp_irq: guest_sync: entry hyp=0, compat=0 - invalid BAD_SYNC /* No AArch64 guest support yet */ + msr daifclr, #2 + mov x0, sp + bl do_trap_hypervisor + exit hyp=0, compat=0 guest_irq: entry hyp=0, compat=0 - invalid BAD_IRQ /* No AArch64 guest support yet */ + mov x0, sp + bl do_trap_irq + exit hyp=0, compat=0 guest_fiq_invalid: entry hyp=0, compat=0 -- 1.7.2.5