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 13/17] xen: arm: handle hypercalls from 64-bit guests
Date: Mon, 29 Jul 2013 13:21:02 +0100 [thread overview]
Message-ID: <1375100466-7564-13-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1375100431.14896.95.camel@kazak.uk.xensource.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/traps.c | 70 +++++++++++++++++++++++++++++----------
xen/include/asm-arm/processor.h | 7 +++-
2 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index abbaadd..32de87f 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -796,8 +796,8 @@ unsigned long do_arch_0(unsigned int cmd, unsigned long long value)
return 0;
}
-typedef unsigned long (*arm_hypercall_fn_t)(
- unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
+typedef register_t (*arm_hypercall_fn_t)(
+ register_t, register_t, register_t, register_t, register_t);
typedef struct {
arm_hypercall_fn_t fn;
@@ -853,6 +853,7 @@ static arm_psci_t arm_psci_table[] = {
PSCI(cpu_on, 2),
};
+#ifndef NDEBUG
static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
{
register_t *r;
@@ -881,6 +882,7 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
break;
}
}
+#endif
static void do_trap_psci(struct cpu_user_regs *regs)
{
@@ -901,30 +903,49 @@ static void do_trap_psci(struct cpu_user_regs *regs)
regs->r0 = psci_call(regs->r1, regs->r2);
}
-static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss)
+#ifdef CONFIG_ARM_64
+#define HYPERCALL_RESULT_REG(r) (r)->x0
+#define HYPERCALL_ARG1(r) (r)->x0
+#define HYPERCALL_ARG2(r) (r)->x1
+#define HYPERCALL_ARG3(r) (r)->x2
+#define HYPERCALL_ARG4(r) (r)->x3
+#define HYPERCALL_ARG5(r) (r)->x4
+#define HYPERCALL_ARGS(r) (r)->x0, (r)->x1, (r)->x2, (r)->x3, (r)->x4
+#else
+#define HYPERCALL_RESULT_REG(r) (r)->r0
+#define HYPERCALL_ARG1(r) (r)->r0
+#define HYPERCALL_ARG2(r) (r)->r1
+#define HYPERCALL_ARG3(r) (r)->r2
+#define HYPERCALL_ARG4(r) (r)->r3
+#define HYPERCALL_ARG5(r) (r)->r4
+#define HYPERCALL_ARGS(r) (r)->r0, (r)->r1, (r)->r2, (r)->r3, (r)->r4
+#endif
+
+static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
+ unsigned long iss)
{
arm_hypercall_fn_t call = NULL;
#ifndef NDEBUG
- uint32_t orig_pc = regs->pc;
+ register_t orig_pc = regs->pc;
#endif
if ( iss != XEN_HYPERCALL_TAG )
domain_crash_synchronous();
- if ( regs->r12 >= ARRAY_SIZE(arm_hypercall_table) )
+ if ( *nr >= ARRAY_SIZE(arm_hypercall_table) )
{
- regs->r0 = -ENOSYS;
+ HYPERCALL_RESULT_REG(regs) = -ENOSYS;
return;
}
- call = arm_hypercall_table[regs->r12].fn;
+ call = arm_hypercall_table[*nr].fn;
if ( call == NULL )
{
- regs->r0 = -ENOSYS;
+ HYPERCALL_RESULT_REG(regs) = -ENOSYS;
return;
}
- regs->r0 = call(regs->r0, regs->r1, regs->r2, regs->r3, regs->r4);
+ HYPERCALL_RESULT_REG(regs) = call(HYPERCALL_ARGS(regs));
#ifndef NDEBUG
/*
@@ -933,16 +954,16 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss)
*/
if ( orig_pc == regs->pc )
{
- switch ( arm_hypercall_table[regs->r12].nr_args ) {
- case 5: regs->r4 = 0xDEADBEEF;
- case 4: regs->r3 = 0xDEADBEEF;
- case 3: regs->r2 = 0xDEADBEEF;
- case 2: regs->r1 = 0xDEADBEEF;
- case 1: /* Don't clobber r0 -- it's the return value */
+ switch ( arm_hypercall_table[*nr].nr_args ) {
+ case 5: HYPERCALL_ARG5(regs) = 0xDEADBEEF;
+ case 4: HYPERCALL_ARG4(regs) = 0xDEADBEEF;
+ case 3: HYPERCALL_ARG3(regs) = 0xDEADBEEF;
+ case 2: HYPERCALL_ARG2(regs) = 0xDEADBEEF;
+ case 1: /* Don't clobber x0/r0 -- it's the return value */
break;
default: BUG();
}
- regs->r12 = 0xDEADBEEF;
+ *nr = 0xDEADBEEF;
}
#endif
}
@@ -1221,13 +1242,26 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
*/
inject_undef_exception(regs, regs->pc32);
break;
- case HSR_EC_HVC:
+ case HSR_EC_HVC32:
+#ifndef NDEBUG
if ( (hsr.iss & 0xff00) == 0xff00 )
return do_debug_trap(regs, hsr.iss & 0x00ff);
+#endif
if ( hsr.iss == 0 )
return do_trap_psci(regs);
- do_trap_hypercall(regs, hsr.iss);
+ do_trap_hypercall(regs, (register_t *)®s->r12, hsr.iss);
break;
+#ifdef CONFIG_ARM_64
+ case HSR_EC_HVC64:
+#ifndef NDEBUG
+ if ( (hsr.iss & 0xff00) == 0xff00 )
+ return do_debug_trap(regs, hsr.iss & 0x00ff);
+#endif
+ if ( hsr.iss == 0 )
+ return do_trap_psci(regs);
+ do_trap_hypercall(regs, ®s->x16, hsr.iss);
+ break;
+#endif
case HSR_EC_DATA_ABORT_GUEST:
do_trap_data_abort_guest(regs, hsr.dabt);
break;
diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h
index 59215b8..d662f07 100644
--- a/xen/include/asm-arm/processor.h
+++ b/xen/include/asm-arm/processor.h
@@ -92,9 +92,12 @@
#define HSR_EC_JAZELLE 0x09
#define HSR_EC_BXJ 0x0a
#define HSR_EC_CP14_64 0x0c
-#define HSR_EC_SVC 0x11
-#define HSR_EC_HVC 0x12
+#define HSR_EC_SVC32 0x11
+#define HSR_EC_HVC32 0x12
#define HSR_EC_SMC 0x13
+#ifdef CONFIG_ARM_64
+#define HSR_EC_HVC64 0x16
+#endif
#define HSR_EC_INSTR_ABORT_GUEST 0x20
#define HSR_EC_INSTR_ABORT_HYP 0x21
#define HSR_EC_DATA_ABORT_GUEST 0x24
--
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 ` [PATCH 11/17] xen: arm: refactor 64-bit return from trap path Ian Campbell
2013-07-29 13:01 ` 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 ` Ian Campbell [this message]
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-13-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).