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: Make the HVM hcall_64bit boolean common
Date: Wed, 15 Feb 2017 19:41:42 +0000 [thread overview]
Message-ID: <1487187705-24445-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1487187705-24445-1-git-send-email-andrew.cooper3@citrix.com>
HVM guests currently make use of arch.hvm_vcpu.hcall_64bit to track the ABI of
the hypercall in use.
The rest of Xen deals in terms of the comat ABI or not, so rename the boolean
and make it common, guared by CONFIG_COMPAT to avoid bloat if a compat ABI is
not wanted/needed.
Set hcall_compat uniformly for PV guests as well as HVM guests. This removes
the remaining piece of guest-type-specific knowledge from
hypercall_create_continuation(), allowing it to operate only in terms of the
hypercall ABI in use.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/domain.c | 4 +---
xen/arch/x86/hvm/hvm.c | 9 +++------
xen/arch/x86/hvm/hypercall.c | 11 +++++------
xen/arch/x86/hypercall.c | 2 ++
xen/include/asm-x86/hvm/vcpu.h | 2 --
xen/include/xen/sched.h | 4 ++++
6 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 08c5813..3209eb3 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -2226,9 +2226,7 @@ unsigned long hypercall_create_continuation(
regs->rax = op;
- if ( is_pv_vcpu(curr) ?
- !is_pv_32bit_vcpu(curr) :
- curr->arch.hvm_vcpu.hcall_64bit )
+ if ( !curr->hcall_compat )
{
for ( i = 0; *p != '\0'; i++ )
{
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 266f708..4d29e3c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3254,8 +3254,7 @@ unsigned long copy_to_user_hvm(void *to, const void *from, unsigned int len)
{
int rc;
- if ( !current->arch.hvm_vcpu.hcall_64bit &&
- is_compat_arg_xlat_range(to, len) )
+ if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
{
memcpy(to, from, len);
return 0;
@@ -3269,8 +3268,7 @@ unsigned long clear_user_hvm(void *to, unsigned int len)
{
int rc;
- if ( !current->arch.hvm_vcpu.hcall_64bit &&
- is_compat_arg_xlat_range(to, len) )
+ if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
{
memset(to, 0x00, len);
return 0;
@@ -3284,8 +3282,7 @@ unsigned long copy_from_user_hvm(void *to, const void *from, unsigned len)
{
int rc;
- if ( !current->arch.hvm_vcpu.hcall_64bit &&
- is_compat_arg_xlat_range(from, len) )
+ if ( current->hcall_compat && is_compat_arg_xlat_range(from, len) )
{
memcpy(to, from, len);
return 0;
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index fe7802b..0f7c310 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -35,7 +35,7 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
return -ENOSYS;
}
- if ( curr->arch.hvm_vcpu.hcall_64bit )
+ if ( !curr->hcall_compat )
rc = do_memory_op(cmd, arg);
else
rc = compat_memory_op(cmd, arg);
@@ -65,7 +65,7 @@ static long hvm_grant_table_op(
return -ENOSYS;
}
- if ( current->arch.hvm_vcpu.hcall_64bit )
+ if ( !current->hcall_compat )
return do_grant_table_op(cmd, uop, count);
else
return compat_grant_table_op(cmd, uop, count);
@@ -89,7 +89,7 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
break;
}
- if ( curr->arch.hvm_vcpu.hcall_64bit )
+ if ( !curr->hcall_compat )
return do_physdev_op(cmd, arg);
else
return compat_physdev_op(cmd, arg);
@@ -203,12 +203,9 @@ int hvm_hypercall(struct cpu_user_regs *regs)
}
#endif
- curr->arch.hvm_vcpu.hcall_64bit = 1;
regs->rax = hvm_hypercall_table[eax].native(rdi, rsi, rdx, r10, r8,
r9);
- curr->arch.hvm_vcpu.hcall_64bit = 0;
-
#ifndef NDEBUG
if ( !curr->hcall_preempted )
{
@@ -250,8 +247,10 @@ int hvm_hypercall(struct cpu_user_regs *regs)
}
#endif
+ curr->hcall_compat = true;
regs->rax = hvm_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi,
ebp);
+ curr->hcall_compat = false;
#ifndef NDEBUG
if ( !curr->hcall_preempted )
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index 945afa0..c0718f8 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -234,7 +234,9 @@ void pv_hypercall(struct cpu_user_regs *regs)
__trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args);
}
+ curr->hcall_compat = true;
regs->_eax = pv_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp);
+ curr->hcall_compat = false;
#ifndef NDEBUG
if ( !curr->hcall_preempted )
diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h
index 6d5553d..6c54773 100644
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -166,8 +166,6 @@ struct hvm_vcpu {
bool debug_state_latch;
bool single_step;
- bool hcall_64bit;
-
struct hvm_vcpu_asid n1asid;
u32 msr_tsc_aux;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 5b62238..738bb43 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -204,6 +204,10 @@ struct vcpu
bool affinity_broken;
/* A hypercall has been preempted. */
bool hcall_preempted;
+#ifdef CONFIG_COMPAT
+ /* A hypercall is using the compat ABI? */
+ bool hcall_compat;
+#endif
/*
--
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 ` Andrew Cooper [this message]
2017-02-16 11:07 ` [PATCH 4/7] x86/hypercall: Make the HVM hcall_64bit boolean common 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-5-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).