|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN][PATCH 2/5] x86: hvm: compat: introduce vcpu_is_hcall_compat() helper
From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
Introduce vcpu_is_hcall_compat() helper and use it instead of direct access
to struct vcpu->hcall_compat field in preparation for making HVM COMPAT
code optional.
Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 9 +++++----
xen/arch/x86/hvm/hypercall.c | 6 +++---
xen/arch/x86/hypercall.c | 6 +-----
xen/common/kernel.c | 2 +-
xen/include/xen/sched.h | 9 +++++++++
5 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0c60faa39d7b..2e47a71714fd 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3500,7 +3500,7 @@ unsigned int copy_to_user_hvm(void *to, const void *from,
unsigned int len)
{
int rc;
- if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
+ if ( vcpu_is_hcall_compat(current) && is_compat_arg_xlat_range(to, len) )
{
memcpy(to, from, len);
return 0;
@@ -3514,7 +3514,7 @@ unsigned int clear_user_hvm(void *to, unsigned int len)
{
int rc;
- if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
+ if ( vcpu_is_hcall_compat(current) && is_compat_arg_xlat_range(to, len) )
{
memset(to, 0x00, len);
return 0;
@@ -3529,7 +3529,7 @@ unsigned int copy_from_user_hvm(void *to, const void
*from, unsigned int len)
{
int rc;
- if ( current->hcall_compat && is_compat_arg_xlat_range(from, len) )
+ if ( vcpu_is_hcall_compat(current) && is_compat_arg_xlat_range(from, len) )
{
memcpy(to, from, len);
return 0;
@@ -5214,7 +5214,8 @@ long do_hvm_op(unsigned long op,
XEN_GUEST_HANDLE_PARAM(void) arg)
break;
case HVMOP_altp2m:
- rc = current->hcall_compat ? compat_altp2m_op(arg) : do_altp2m_op(arg);
+ rc = vcpu_is_hcall_compat(current) ? compat_altp2m_op(arg)
+ : do_altp2m_op(arg);
break;
default:
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index b254b3e2f7d6..549e25445e67 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -29,7 +29,7 @@ long hvm_memory_op(unsigned long cmd,
XEN_GUEST_HANDLE_PARAM(void) arg)
return -ENOSYS;
}
- if ( !current->hcall_compat )
+ if ( !vcpu_is_hcall_compat(current) )
rc = do_memory_op(cmd, arg);
else
rc = compat_memory_op(cmd, arg);
@@ -57,7 +57,7 @@ long hvm_grant_table_op(
return -ENOSYS;
}
- if ( !current->hcall_compat )
+ if ( !vcpu_is_hcall_compat(current) )
return do_grant_table_op(cmd, uop, count);
else
return compat_grant_table_op(cmd, uop, count);
@@ -96,7 +96,7 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
return -ENOSYS;
}
- if ( !curr->hcall_compat )
+ if ( !vcpu_is_hcall_compat(curr) )
return do_physdev_op(cmd, arg);
else
return compat_physdev_op(cmd, arg);
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index dc0a90ca0915..3a1a363d8648 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -53,11 +53,7 @@ unsigned long hypercall_create_continuation(
regs->rax = op;
-#ifdef CONFIG_COMPAT
- if ( !curr->hcall_compat )
-#else
- if ( true )
-#endif
+ if ( !vcpu_is_hcall_compat(curr) )
{
for ( i = 0; *p != '\0'; i++ )
{
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index e6979352e100..99be0fbb9d90 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -615,7 +615,7 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void)
arg)
const struct vcpu *curr = current;
#ifdef CONFIG_COMPAT
- if ( curr->hcall_compat )
+ if ( vcpu_is_hcall_compat(curr) )
{
compat_platform_parameters_t params = {
.virt_start = is_pv_vcpu(curr)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 02bdc256ce37..e3ce427f0bd9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -311,6 +311,15 @@ struct vcpu
#endif
};
+static inline bool vcpu_is_hcall_compat(const struct vcpu *v)
+{
+#ifdef CONFIG_COMPAT
+ return v->hcall_compat;
+#else
+ return false;
+#endif /* CONFIG_COMPAT */
+}
+
struct sched_unit {
struct domain *domain;
struct vcpu *vcpu_list;
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |