xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: patches@linaro.org, ian.campbell@citrix.com,
	Julien Grall <julien.grall@linaro.org>,
	Stefano.Stabellini@eu.citrix.com
Subject: [PATCH v2 2/3] xen/arm: Allow secondary cpus to start in THUMB
Date: Thu, 25 Jul 2013 16:21:31 +0100	[thread overview]
Message-ID: <1374765692-31370-3-git-send-email-julien.grall@linaro.org> (raw)
In-Reply-To: <1374765692-31370-1-git-send-email-julien.grall@linaro.org>

Unlike bx, eret will not update the instruction set (THUMB,ARM) according to
the return address. This will result to an unpredicable behaviour for the
processor if the address doesn't match the right instruction set.

When the kernel is compiled with THUMB2, THUMB bit needs to be set in CPSR
for the secondary cpus.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Changes in v2:
        - Return PSCI_EINVAL if an aarch64 guest tries to use THUMB set
---
 xen/arch/arm/psci.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index 18feead..200769c 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -24,6 +24,7 @@ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point)
     struct domain *d = current->domain;
     struct vcpu_guest_context *ctxt;
     int rc;
+    int is_thumb = entry_point & 1;
 
     if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
         return PSCI_EINVAL;
@@ -31,6 +32,10 @@ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point)
     if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
         return PSCI_EINVAL;
 
+    /* THUMB set is not allowed with 64-bit domain */
+    if ( is_pv64_domain(d) && is_thumb )
+        return PSCI_EINVAL;
+
     if ( (ctxt = alloc_vcpu_guest_context()) == NULL )
         return PSCI_DENIED;
 
@@ -43,6 +48,9 @@ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point)
     ctxt->ttbr1 = 0;
     ctxt->ttbcr = 0; /* Defined Reset Value */
     ctxt->user_regs.cpsr = PSR_GUEST_INIT;
+    /* Start the VCPU with THUMB set if it's requested by the kernel */
+    if ( is_thumb )
+        ctxt->user_regs.cpsr |= PSR_THUMB;
     ctxt->flags = VGCF_online;
 
     domain_lock(d);
-- 
1.7.10.4

  parent reply	other threads:[~2013-07-25 15:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25 15:21 [PATCH v2 0/3] Add support for THUMB guest kernel Julien Grall
2013-07-25 15:21 ` [PATCH v2 1/3] xen/arm: Don't emulate the MMIO access if the instruction syndrome is invalid Julien Grall
2013-07-29 15:57   ` Ian Campbell
2013-07-25 15:21 ` Julien Grall [this message]
2013-07-29 15:57   ` [PATCH v2 2/3] xen/arm: Allow secondary cpus to start in THUMB Ian Campbell
2013-07-25 15:21 ` [PATCH v2 3/3] xen/arm: errata 766422: decode thumb store during data abort Julien Grall
2013-07-29 15:15   ` Ian Campbell
2013-07-30 17:37     ` Julien Grall
2013-07-31  8:47       ` Ian Campbell
2013-07-31 10:19         ` Julien Grall

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=1374765692-31370-3-git-send-email-julien.grall@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=patches@linaro.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).