[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 5/5] xen: add new hypercall to get grant table limits



Today a guest can get the maximum grant table frame number for the
currently selected grant table interface version (1 or 2) only. Add
a new grant table operation to get the limits of both variants in
order to give the guest an opportunity to select the version serving
its needs best.

Background for the need for this new hypercall is that e.g. the Linux
kernel won't use v2 as long as this will allow less active grants as
v1. As soon as the kernel can detect it can create as many v2 entries
as for v1, it will have no reason not to use v2. And this will allow
Xen placing a pv-domain with such a kernel above the current 16TB
RAM limit.

For setting up the grant table a kernel needs the following
information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,
GNTTABOP_get_version, GNTTABOP_get_v1_and_v2_max), let the new
hypercall return all the needed information.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/grant_table.c         | 26 ++++++++++++++++++++++++++
 xen/include/public/grant_table.h | 14 ++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 33cf1f9ea2..83370a0390 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3041,6 +3041,28 @@ 
gnttab_get_version(XEN_GUEST_HANDLE_PARAM(gnttab_get_version_t) uop)
     return 0;
 }
 
+static long
+gnttab_get_setup_info(XEN_GUEST_HANDLE_PARAM(gnttab_setup_info_t) uop)
+{
+    gnttab_setup_info_t op;
+    struct domain *d = rcu_lock_current_domain();
+    struct grant_table *gt = d->grant_table;
+
+    grant_write_lock(gt);
+    op.version = gt->gt_version;
+    op.nr_frames = nr_grant_frames(gt);
+    grant_write_unlock(gt);
+    op.max_nr_frames_v1 = max_grant_frames_v1;
+    op.max_nr_frames_v2 = max_grant_frames_v2;
+
+    rcu_unlock_domain(d);
+
+    if ( __copy_to_guest(uop, &op, 1) )
+        return -EFAULT;
+
+    return 0;
+}
+
 static s16
 swap_grant_ref(grant_ref_t ref_a, grant_ref_t ref_b)
 {
@@ -3389,6 +3411,10 @@ do_grant_table_op(
         break;
     }
 
+    case GNTTABOP_get_setup_info:
+        rc = gnttab_get_setup_info(guest_handle_cast(uop, 
gnttab_setup_info_t));
+        break;
+
     default:
         rc = -ENOSYS;
         break;
diff --git a/xen/include/public/grant_table.h b/xen/include/public/grant_table.h
index 018036e825..b30f85b2f8 100644
--- a/xen/include/public/grant_table.h
+++ b/xen/include/public/grant_table.h
@@ -312,6 +312,7 @@ typedef uint16_t grant_status_t;
 #define GNTTABOP_get_version          10
 #define GNTTABOP_swap_grant_ref              11
 #define GNTTABOP_cache_flush         12
+#define GNTTABOP_get_setup_info       13
 #endif /* __XEN_INTERFACE_VERSION__ */
 /* ` } */
 
@@ -597,6 +598,19 @@ struct gnttab_cache_flush {
 typedef struct gnttab_cache_flush gnttab_cache_flush_t;
 DEFINE_XEN_GUEST_HANDLE(gnttab_cache_flush_t);
 
+/*
+ * GNTTABOP_get_setup_info: Get information needed for grant table setup
+ * of the calling domain.
+ */
+struct gnttab_setup_info {
+    uint32_t version;
+    uint32_t nr_frames;
+    uint32_t max_nr_frames_v1;
+    uint32_t max_nr_frames_v2;
+};
+typedef struct gnttab_setup_info gnttab_setup_info_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_setup_info_t);
+
 #endif /* __XEN_INTERFACE_VERSION__ */
 
 /*
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.