From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@arm.com>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: [PATCH] arm/hypercall: Use the common hcall_preempted boolean
Date: Wed, 15 Feb 2017 19:41:40 +0000 [thread overview]
Message-ID: <1487187705-24445-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1487187705-24445-1-git-send-email-andrew.cooper3@citrix.com>
With hcall_preempted having just been made common, ARM can use use it to
simplify its hypercall handling.
This simplifies the continuation logic and removes the risk of accidentally
skipping multiple instructions.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
NB: Only compile tested, not functionally tested. However, it is basically an
identical transformation as done to x86 PV guests in the previous patch, which
I have tested thoroughly.
---
xen/arch/arm/domain.c | 10 ++--------
xen/arch/arm/traps.c | 16 ++++++++--------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 7e43691..fb1d8a5 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -349,17 +349,12 @@ void sync_vcpu_execstate(struct vcpu *v)
void hypercall_cancel_continuation(void)
{
- struct cpu_user_regs *regs = guest_cpu_user_regs();
struct mc_state *mcs = ¤t->mc_state;
if ( mcs->flags & MCSF_in_multicall )
- {
__clear_bit(_MCSF_call_preempted, &mcs->flags);
- }
else
- {
- regs->pc += 4; /* undo re-execute 'hvc #XEN_HYPERCALL_TAG' */
- }
+ current->hcall_preempted = false;
}
unsigned long hypercall_create_continuation(
@@ -391,8 +386,7 @@ unsigned long hypercall_create_continuation(
{
regs = guest_cpu_user_regs();
- /* Ensure the hypercall trap instruction is re-executed. */
- regs->pc -= 4; /* re-execute 'hvc #XEN_HYPERCALL_TAG' */
+ current->hcall_preempted = true;
#ifdef CONFIG_ARM_64
if ( !is_32bit_domain(current->domain) )
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 92b1d80..7c99dc2 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1454,9 +1454,6 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
unsigned long iss)
{
arm_hypercall_fn_t call = NULL;
-#ifndef NDEBUG
- register_t orig_pc = regs->pc;
-#endif
BUILD_BUG_ON(NR_hypercalls < ARRAY_SIZE(arm_hypercall_table) );
@@ -1470,6 +1467,8 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
return;
}
+ current->hcall_preempted = false;
+
perfc_incra(hypercalls, *nr);
call = arm_hypercall_table[*nr].fn;
if ( call == NULL )
@@ -1481,12 +1480,9 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
HYPERCALL_RESULT_REG(regs) = call(HYPERCALL_ARGS(regs));
#ifndef NDEBUG
- /*
- * Clobber argument registers only if pc is unchanged, otherwise
- * this is a hypercall continuation.
- */
- if ( orig_pc == regs->pc )
+ if ( !current->hcall_preempted )
{
+ /* Deliberately corrupt parameter regs used by this hypercall. */
switch ( arm_hypercall_table[*nr].nr_args ) {
case 5: HYPERCALL_ARG5(regs) = 0xDEADBEEF;
case 4: HYPERCALL_ARG4(regs) = 0xDEADBEEF;
@@ -1499,6 +1495,10 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,
*nr = 0xDEADBEEF;
}
#endif
+
+ /* Ensure the hypercall trap instruction is re-executed. */
+ if ( current->hcall_preempted )
+ regs->pc -= 4; /* re-execute 'hvc #XEN_HYPERCALL_TAG' */
}
static bool check_multicall_32bit_clean(struct multicall_entry *multi)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-15 19:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 19:41 [PATCH] Common hypercall handing improvements Andrew Cooper
2017-02-15 19:41 ` [PATCH] x86/hypercall: Make the HVM hcall_preempted boolean common Andrew Cooper
2017-02-16 10:44 ` [PATCH 1/7] " Jan Beulich
2017-02-15 19:41 ` Andrew Cooper [this message]
2017-02-16 12:04 ` [PATCH] arm/hypercall: Use the common hcall_preempted boolean Julien Grall
2017-02-15 19:41 ` [PATCH] xen/multicall: " Andrew Cooper
2017-02-16 10:37 ` Jan Beulich
2017-02-16 10:42 ` Andrew Cooper
2017-02-16 11:02 ` [PATCH 2/7] " Jan Beulich
2017-02-16 12:10 ` [PATCH] " Julien Grall
2017-02-15 19:41 ` [PATCH] x86/hypercall: Make the HVM hcall_64bit boolean common Andrew Cooper
2017-02-16 11:07 ` [PATCH 4/7] " Jan Beulich
2017-02-15 19:41 ` [PATCH] x86/hypercall: Split out PV hypercall infrastructure Andrew Cooper
2017-02-16 11:19 ` Jan Beulich
2017-02-15 19:41 ` [PATCH] x86/hypercall: Move hypercall continuation logic Andrew Cooper
2017-02-16 11:23 ` Jan Beulich
2017-02-15 19:41 ` [PATCH] [RFC] x86/kconfig: Introduce CONFIG_PV and CONFIG_HVM Andrew Cooper
2017-02-16 14:39 ` Jan Beulich
2017-02-16 14:58 ` Andrew Cooper
2017-02-16 15:49 ` Jan Beulich
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=1487187705-24445-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.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).