From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: julien.grall@citrix.com, tim@xen.org,
Ian Campbell <ian.campbell@citrix.com>,
stefano.stabellini@eu.citrix.com
Subject: [PATCH 11/17] xen: arm: refactor 64-bit return from trap path
Date: Mon, 29 Jul 2013 13:21:00 +0100 [thread overview]
Message-ID: <1375100466-7564-11-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1375100431.14896.95.camel@kazak.uk.xensource.com>
Refactor exit path to use a single "exit" macro similar to the entry path.
We can also remove the logic at "return_to_new_vcpu" which detects returns to
hypervisor mode -- seemingly trying to handle hypervisor threads which aren't
an thing which we have. The idle VCPUs do not take this path. This simplifies
the return_to_new_vcpu code, we also split it into 32- and 64-bit VCPU paths.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v4: split out from "xen: arm: handle traps from 64-bit guests"
---
xen/arch/arm/arm32/entry.S | 2 +-
xen/arch/arm/arm64/entry.S | 40 +++++++++++++++++++++++-----------------
xen/arch/arm/domain.c | 6 +++++-
3 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S
index 6cdf0aa..81d5990 100644
--- a/xen/arch/arm/arm32/entry.S
+++ b/xen/arch/arm/arm32/entry.S
@@ -87,7 +87,7 @@ DEFINE_TRAP_ENTRY_NOIRQ(fiq)
return_from_trap:
mov sp, r11
-ENTRY(return_to_new_vcpu)
+ENTRY(return_to_new_vcpu32)
ldr r11, [sp, #UREGS_cpsr]
and r11, #PSR_MODE_MASK
cmp r11, #PSR_MODE_HYP
diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S
index c0d2bd8..390a11d 100644
--- a/xen/arch/arm/arm64/entry.S
+++ b/xen/arch/arm/arm64/entry.S
@@ -57,7 +57,7 @@ lr .req x30 // link register
.endm
/*
- * Save state on entry to hypervisor
+ * Save state on entry to hypervisor, restore on exit
*/
.macro entry, hyp, compat
sub sp, sp, #(UREGS_SPSR_el1 - UREGS_LR) /* CPSR, PC, SP, LR */
@@ -96,6 +96,18 @@ lr .req x30 // link register
.endm
+ .macro exit, hyp, compat
+
+ .if \hyp == 0 /* Guest mode */
+
+ bl leave_hypervisor_tail /* Disables interrupts on return */
+
+ .endif
+
+ b return_from_trap
+
+ .endm
+
/*
* Bad Abort numbers
*-----------------
@@ -133,13 +145,13 @@ hyp_sync:
msr daifclr, #2
mov x0, sp
bl do_trap_hypervisor
- b return_to_hypervisor
+ exit hyp=1
hyp_irq:
entry hyp=1
mov x0, sp
bl do_trap_irq
- b return_to_hypervisor
+ exit hyp=1
guest_sync:
entry hyp=0, compat=0
@@ -162,13 +174,13 @@ guest_sync_compat:
msr daifclr, #2
mov x0, sp
bl do_trap_hypervisor
- b return_to_guest
+ exit hyp=0, compat=1
guest_irq_compat:
entry hyp=0, compat=1
mov x0, sp
bl do_trap_irq
- b return_to_guest
+ exit hyp=0, compat=1
guest_fiq_invalid_compat:
entry hyp=0, compat=1
@@ -178,18 +190,12 @@ guest_error_invalid_compat:
entry hyp=0, compat=1
invalid BAD_ERROR
-ENTRY(return_to_new_vcpu)
- ldr x21, [sp, #UREGS_CPSR]
- and x21, x21, #PSR_MODE_MASK
- /* Returning to EL2? */
- cmp x21, #PSR_MODE_EL2t
- ccmp x21, #PSR_MODE_EL2h, #0x4, ne
- b.eq return_to_hypervisor /* Yes */
- /* Fall thru */
-return_to_guest:
- bl leave_hypervisor_tail /* Disables interrupts on return */
- /* Fall thru */
-return_to_hypervisor:
+ENTRY(return_to_new_vcpu32)
+ exit hyp=0, compat=1
+ENTRY(return_to_new_vcpu64)
+ exit hyp=0, compat=0
+
+return_from_trap:
msr daifset, #2 /* Mask interrupts */
ldp x21, x22, [sp, #UREGS_PC] // load ELR, SPSR
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index b4d99f1..4e9cece 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -250,9 +250,13 @@ static void continue_new_vcpu(struct vcpu *prev)
if ( is_idle_vcpu(current) )
reset_stack_and_jump(idle_loop);
+ else if is_pv32_domain(current->domain)
+ /* check_wakeup_from_wait(); */
+ reset_stack_and_jump(return_to_new_vcpu32);
else
/* check_wakeup_from_wait(); */
- reset_stack_and_jump(return_to_new_vcpu);
+ reset_stack_and_jump(return_to_new_vcpu64);
+
}
void context_switch(struct vcpu *prev, struct vcpu *next)
--
1.7.2.5
next prev parent reply other threads:[~2013-07-29 12:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-29 12:20 [PATCH v4 00/17] xen: arm: 64-bit dom0 kernel support Ian Campbell
2013-07-29 12:20 ` [PATCH 01/17] xen: arm: tweak arm64 stack frame layout Ian Campbell
2013-07-29 12:20 ` [PATCH 02/17] xen: arm: rename 32-bit specific zImage field offset constants Ian Campbell
2013-07-29 12:20 ` [PATCH 03/17] xen: arm: support for loading 64-bit zImage dom0 Ian Campbell
2013-07-29 12:20 ` [PATCH 04/17] xen: arm: support building a 64-bit dom0 domain Ian Campbell
2013-07-29 18:29 ` Julien Grall
2013-07-30 9:34 ` Ian Campbell
2013-07-30 9:43 ` Julien Grall
2013-08-02 16:07 ` Ian Campbell
2013-07-29 12:20 ` [PATCH 05/17] xen: arm: precalculate VTTBR_EL2 for a domain when setting up its p2m Ian Campbell
2013-07-29 12:20 ` [PATCH 06/17] xen: arm: improve register dump output for 64-bit guest (and more generally too) Ian Campbell
2013-07-29 12:53 ` Tim Deegan
2013-07-29 12:20 ` [PATCH 07/17] xen: arm: support dumping 64-bit guest stack Ian Campbell
2013-07-29 12:20 ` [PATCH 08/17] xen: arm: show less words in a line of a stack trace in 64-bit builds Ian Campbell
2013-07-29 12:20 ` [PATCH 09/17] xen: arm: Set EL1 register width in HCR_EL2 during context switch Ian Campbell
2013-07-29 12:20 ` [PATCH 10/17] xen: arm: some cleanups to hypervisor entry code Ian Campbell
2013-07-29 12:56 ` Tim Deegan
2013-07-29 12:21 ` Ian Campbell [this message]
2013-07-29 13:01 ` [PATCH 11/17] xen: arm: refactor 64-bit return from trap path Tim Deegan
2013-07-29 12:21 ` [PATCH 12/17] xen: arm: handle traps from 64-bit guests Ian Campbell
2013-07-29 13:49 ` Tim Deegan
2013-07-29 12:21 ` [PATCH 13/17] xen: arm: handle hypercalls " Ian Campbell
2013-07-29 12:21 ` [PATCH 14/17] xen: arm: handle 64-bit system register access traps Ian Campbell
2013-07-29 12:21 ` [PATCH 15/17] xen: arm: align some comments Ian Campbell
2013-07-29 12:21 ` [PATCH 16/17] xen: arm: document HCR bits Ian Campbell
2013-07-29 12:21 ` [PATCH 17/17] xen: arm: Handle SMC from 64-bit guests Ian Campbell
2013-07-29 13:53 ` Tim Deegan
2013-07-29 12:21 ` [PATCH v4 00/17] xen: arm: 64-bit dom0 kernel support Ian Campbell
2013-07-29 15:58 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1375100466-7564-11-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).