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>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] xen/multicall: Use the common hcall_preempted boolean
Date: Wed, 15 Feb 2017 19:41:41 +0000 [thread overview]
Message-ID: <1487187705-24445-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1487187705-24445-1-git-send-email-andrew.cooper3@citrix.com>
The now-common hcall_preempted boolean is perfectly usable for multicalls.
Remove the multicall-specific preemption mechanism.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
xen/arch/arm/domain.c | 13 +++----------
xen/arch/x86/domain.c | 19 ++++++-------------
xen/common/multicall.c | 4 +++-
xen/include/xen/multicall.h | 2 --
4 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index fb1d8a5..39b6eb8 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -349,12 +349,7 @@ void sync_vcpu_execstate(struct vcpu *v)
void hypercall_cancel_continuation(void)
{
- struct mc_state *mcs = ¤t->mc_state;
-
- if ( mcs->flags & MCSF_in_multicall )
- __clear_bit(_MCSF_call_preempted, &mcs->flags);
- else
- current->hcall_preempted = false;
+ current->hcall_preempted = false;
}
unsigned long hypercall_create_continuation(
@@ -370,12 +365,12 @@ unsigned long hypercall_create_continuation(
/* All hypercalls take at least one argument */
BUG_ON( !p || *p == '\0' );
+ current->hcall_preempted = true;
+
va_start(args, format);
if ( mcs->flags & MCSF_in_multicall )
{
- __set_bit(_MCSF_call_preempted, &mcs->flags);
-
for ( i = 0; *p != '\0'; i++ )
mcs->call.args[i] = next_arg(p, args);
@@ -386,8 +381,6 @@ unsigned long hypercall_create_continuation(
{
regs = guest_cpu_user_regs();
- current->hcall_preempted = true;
-
#ifdef CONFIG_ARM_64
if ( !is_32bit_domain(current->domain) )
{
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index b199c70..08c5813 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -2198,41 +2198,34 @@ void sync_vcpu_execstate(struct vcpu *v)
void hypercall_cancel_continuation(void)
{
- struct mc_state *mcs = ¤t->mc_state;
-
- if ( mcs->flags & MCSF_in_multicall )
- __clear_bit(_MCSF_call_preempted, &mcs->flags);
- else
- current->hcall_preempted = false;
+ current->hcall_preempted = false;
}
unsigned long hypercall_create_continuation(
unsigned int op, const char *format, ...)
{
- struct mc_state *mcs = ¤t->mc_state;
+ 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 )
{
- __set_bit(_MCSF_call_preempted, &mcs->flags);
-
for ( i = 0; *p != '\0'; i++ )
mcs->call.args[i] = next_arg(p, args);
}
else
{
struct cpu_user_regs *regs = guest_cpu_user_regs();
- struct vcpu *curr = current;
regs->rax = op;
- curr->hcall_preempted = true;
-
if ( is_pv_vcpu(curr) ?
!is_pv_32bit_vcpu(curr) :
curr->arch.hvm_vcpu.hcall_64bit )
@@ -2293,7 +2286,7 @@ int hypercall_xlat_continuation(unsigned int *id, unsigned int nr,
if ( mcs->flags & MCSF_in_multicall )
{
- if ( !(mcs->flags & MCSF_call_preempted) )
+ if ( !current->hcall_preempted )
{
va_end(args);
return 0;
diff --git a/xen/common/multicall.c b/xen/common/multicall.c
index 524c9bf..02f57cb 100644
--- a/xen/common/multicall.c
+++ b/xen/common/multicall.c
@@ -79,7 +79,7 @@ do_multicall(
if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) )
rc = -EFAULT;
- else if ( mcs->flags & MCSF_call_preempted )
+ else if ( current->hcall_preempted )
{
/* Translate sub-call continuation to guest layout */
xlat_multicall_entry(mcs);
@@ -87,6 +87,8 @@ do_multicall(
/* Copy the sub-call continuation. */
if ( likely(!__copy_to_guest(call_list, &mcs->call, 1)) )
goto preempted;
+ else
+ hypercall_cancel_continuation();
rc = -EFAULT;
}
else
diff --git a/xen/include/xen/multicall.h b/xen/include/xen/multicall.h
index fff15eb..e8d7905 100644
--- a/xen/include/xen/multicall.h
+++ b/xen/include/xen/multicall.h
@@ -11,9 +11,7 @@
#endif
#define _MCSF_in_multicall 0
-#define _MCSF_call_preempted 1
#define MCSF_in_multicall (1<<_MCSF_in_multicall)
-#define MCSF_call_preempted (1<<_MCSF_call_preempted)
struct mc_state {
unsigned long flags;
union {
--
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 ` Andrew Cooper [this message]
2017-02-16 10:37 ` [PATCH] xen/multicall: " 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-4-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.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).