From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] x86/hypercall: Move hypercall continuation logic
Date: Wed, 15 Feb 2017 19:41:44 +0000 [thread overview]
Message-ID: <1487187705-24445-7-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1487187705-24445-1-git-send-email-andrew.cooper3@citrix.com>
The newly-repurposed arch/x86/hypercall.c is a more appropriate place for the
hypercall continuation logic to live.
This is purely code motion.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/domain.c | 177 -----------------------------------------------
xen/arch/x86/hypercall.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 177 insertions(+), 177 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 3209eb3..8d7cae3 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -2184,183 +2184,6 @@ void sync_vcpu_execstate(struct vcpu *v)
flush_tlb_mask(v->vcpu_dirty_cpumask);
}
-#define next_arg(fmt, args) ({ \
- unsigned long __arg; \
- switch ( *(fmt)++ ) \
- { \
- case 'i': __arg = (unsigned long)va_arg(args, unsigned int); break; \
- case 'l': __arg = (unsigned long)va_arg(args, unsigned long); break; \
- case 'h': __arg = (unsigned long)va_arg(args, void *); break; \
- default: __arg = 0; BUG(); \
- } \
- __arg; \
-})
-
-void hypercall_cancel_continuation(void)
-{
- current->hcall_preempted = false;
-}
-
-unsigned long hypercall_create_continuation(
- unsigned int op, const char *format, ...)
-{
- struct vcpu *curr = current;
- struct mc_state *mcs = &curr->mc_state;
- const char *p = format;
- unsigned long arg;
- unsigned int i;
- va_list args;
-
- curr->hcall_preempted = true;
-
- va_start(args, format);
-
- if ( mcs->flags & MCSF_in_multicall )
- {
- for ( i = 0; *p != '\0'; i++ )
- mcs->call.args[i] = next_arg(p, args);
- }
- else
- {
- struct cpu_user_regs *regs = guest_cpu_user_regs();
-
- regs->rax = op;
-
- if ( !curr->hcall_compat )
- {
- for ( i = 0; *p != '\0'; i++ )
- {
- arg = next_arg(p, args);
- switch ( i )
- {
- case 0: regs->rdi = arg; break;
- case 1: regs->rsi = arg; break;
- case 2: regs->rdx = arg; break;
- case 3: regs->r10 = arg; break;
- case 4: regs->r8 = arg; break;
- case 5: regs->r9 = arg; break;
- }
- }
- }
- else
- {
- for ( i = 0; *p != '\0'; i++ )
- {
- arg = next_arg(p, args);
- switch ( i )
- {
- case 0: regs->rbx = arg; break;
- case 1: regs->rcx = arg; break;
- case 2: regs->rdx = arg; break;
- case 3: regs->rsi = arg; break;
- case 4: regs->rdi = arg; break;
- case 5: regs->rbp = arg; break;
- }
- }
- }
- }
-
- va_end(args);
-
- return op;
-}
-
-int hypercall_xlat_continuation(unsigned int *id, unsigned int nr,
- unsigned int mask, ...)
-{
- int rc = 0;
- struct mc_state *mcs = ¤t->mc_state;
- struct cpu_user_regs *regs;
- unsigned int i, cval = 0;
- unsigned long nval = 0;
- va_list args;
-
- ASSERT(nr <= ARRAY_SIZE(mcs->call.args));
- ASSERT(!(mask >> nr));
- ASSERT(!id || *id < nr);
- ASSERT(!id || !(mask & (1U << *id)));
-
- va_start(args, mask);
-
- if ( mcs->flags & MCSF_in_multicall )
- {
- if ( !current->hcall_preempted )
- {
- va_end(args);
- return 0;
- }
-
- for ( i = 0; i < nr; ++i, mask >>= 1 )
- {
- if ( mask & 1 )
- {
- nval = va_arg(args, unsigned long);
- cval = va_arg(args, unsigned int);
- if ( cval == nval )
- mask &= ~1U;
- else
- BUG_ON(nval == (unsigned int)nval);
- }
- else if ( id && *id == i )
- {
- *id = mcs->call.args[i];
- id = NULL;
- }
- if ( (mask & 1) && mcs->call.args[i] == nval )
- {
- mcs->call.args[i] = cval;
- ++rc;
- }
- else
- BUG_ON(mcs->call.args[i] != (unsigned int)mcs->call.args[i]);
- }
- }
- else
- {
- regs = guest_cpu_user_regs();
- for ( i = 0; i < nr; ++i, mask >>= 1 )
- {
- unsigned long *reg;
-
- switch ( i )
- {
- case 0: reg = ®s->rbx; break;
- case 1: reg = ®s->rcx; break;
- case 2: reg = ®s->rdx; break;
- case 3: reg = ®s->rsi; break;
- case 4: reg = ®s->rdi; break;
- case 5: reg = ®s->rbp; break;
- default: BUG(); reg = NULL; break;
- }
- if ( (mask & 1) )
- {
- nval = va_arg(args, unsigned long);
- cval = va_arg(args, unsigned int);
- if ( cval == nval )
- mask &= ~1U;
- else
- BUG_ON(nval == (unsigned int)nval);
- }
- else if ( id && *id == i )
- {
- *id = *reg;
- id = NULL;
- }
- if ( (mask & 1) && *reg == nval )
- {
- *reg = cval;
- ++rc;
- }
- else
- BUG_ON(*reg != (unsigned int)*reg);
- }
- }
-
- va_end(args);
-
- return rc;
-}
-
static int relinquish_memory(
struct domain *d, struct page_list_head *list, unsigned long type)
{
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index f807332..e301818 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -74,6 +74,183 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
#undef COMP
#undef ARGS
+#define next_arg(fmt, args) ({ \
+ unsigned long __arg; \
+ switch ( *(fmt)++ ) \
+ { \
+ case 'i': __arg = (unsigned long)va_arg(args, unsigned int); break; \
+ case 'l': __arg = (unsigned long)va_arg(args, unsigned long); break; \
+ case 'h': __arg = (unsigned long)va_arg(args, void *); break; \
+ default: __arg = 0; BUG(); \
+ } \
+ __arg; \
+})
+
+void hypercall_cancel_continuation(void)
+{
+ current->hcall_preempted = false;
+}
+
+unsigned long hypercall_create_continuation(
+ unsigned int op, const char *format, ...)
+{
+ struct vcpu *curr = current;
+ struct mc_state *mcs = &curr->mc_state;
+ const char *p = format;
+ unsigned long arg;
+ unsigned int i;
+ va_list args;
+
+ curr->hcall_preempted = true;
+
+ va_start(args, format);
+
+ if ( mcs->flags & MCSF_in_multicall )
+ {
+ for ( i = 0; *p != '\0'; i++ )
+ mcs->call.args[i] = next_arg(p, args);
+ }
+ else
+ {
+ struct cpu_user_regs *regs = guest_cpu_user_regs();
+
+ regs->rax = op;
+
+ if ( !curr->hcall_compat )
+ {
+ for ( i = 0; *p != '\0'; i++ )
+ {
+ arg = next_arg(p, args);
+ switch ( i )
+ {
+ case 0: regs->rdi = arg; break;
+ case 1: regs->rsi = arg; break;
+ case 2: regs->rdx = arg; break;
+ case 3: regs->r10 = arg; break;
+ case 4: regs->r8 = arg; break;
+ case 5: regs->r9 = arg; break;
+ }
+ }
+ }
+ else
+ {
+ for ( i = 0; *p != '\0'; i++ )
+ {
+ arg = next_arg(p, args);
+ switch ( i )
+ {
+ case 0: regs->rbx = arg; break;
+ case 1: regs->rcx = arg; break;
+ case 2: regs->rdx = arg; break;
+ case 3: regs->rsi = arg; break;
+ case 4: regs->rdi = arg; break;
+ case 5: regs->rbp = arg; break;
+ }
+ }
+ }
+ }
+
+ va_end(args);
+
+ return op;
+}
+
+int hypercall_xlat_continuation(unsigned int *id, unsigned int nr,
+ unsigned int mask, ...)
+{
+ int rc = 0;
+ struct mc_state *mcs = ¤t->mc_state;
+ struct cpu_user_regs *regs;
+ unsigned int i, cval = 0;
+ unsigned long nval = 0;
+ va_list args;
+
+ ASSERT(nr <= ARRAY_SIZE(mcs->call.args));
+ ASSERT(!(mask >> nr));
+ ASSERT(!id || *id < nr);
+ ASSERT(!id || !(mask & (1U << *id)));
+
+ va_start(args, mask);
+
+ if ( mcs->flags & MCSF_in_multicall )
+ {
+ if ( !current->hcall_preempted )
+ {
+ va_end(args);
+ return 0;
+ }
+
+ for ( i = 0; i < nr; ++i, mask >>= 1 )
+ {
+ if ( mask & 1 )
+ {
+ nval = va_arg(args, unsigned long);
+ cval = va_arg(args, unsigned int);
+ if ( cval == nval )
+ mask &= ~1U;
+ else
+ BUG_ON(nval == (unsigned int)nval);
+ }
+ else if ( id && *id == i )
+ {
+ *id = mcs->call.args[i];
+ id = NULL;
+ }
+ if ( (mask & 1) && mcs->call.args[i] == nval )
+ {
+ mcs->call.args[i] = cval;
+ ++rc;
+ }
+ else
+ BUG_ON(mcs->call.args[i] != (unsigned int)mcs->call.args[i]);
+ }
+ }
+ else
+ {
+ regs = guest_cpu_user_regs();
+ for ( i = 0; i < nr; ++i, mask >>= 1 )
+ {
+ unsigned long *reg;
+
+ switch ( i )
+ {
+ case 0: reg = ®s->rbx; break;
+ case 1: reg = ®s->rcx; break;
+ case 2: reg = ®s->rdx; break;
+ case 3: reg = ®s->rsi; break;
+ case 4: reg = ®s->rdi; break;
+ case 5: reg = ®s->rbp; break;
+ default: BUG(); reg = NULL; break;
+ }
+ if ( (mask & 1) )
+ {
+ nval = va_arg(args, unsigned long);
+ cval = va_arg(args, unsigned int);
+ if ( cval == nval )
+ mask &= ~1U;
+ else
+ BUG_ON(nval == (unsigned int)nval);
+ }
+ else if ( id && *id == i )
+ {
+ *id = *reg;
+ id = NULL;
+ }
+ if ( (mask & 1) && *reg == nval )
+ {
+ *reg = cval;
+ ++rc;
+ }
+ else
+ BUG_ON(*reg != (unsigned int)*reg);
+ }
+ }
+
+ va_end(args);
+
+ return rc;
+}
+
/*
* Local variables:
* mode: C
--
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 ` [PATCH] arm/hypercall: Use the common hcall_preempted boolean Andrew Cooper
2017-02-16 12:04 ` 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 ` Andrew Cooper [this message]
2017-02-16 11:23 ` [PATCH] x86/hypercall: Move hypercall continuation logic 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-7-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--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).