|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v6 12/12] xen: make grant table limits boot parameters dom0 only
The boot parameters gnttab_max_frames and gnttab_max_maptrack_frames
are used for dom0 only now, as all other domains require a
XEN_DOMCTL_set_gnttab_limits call now. So make that explicit by
setting the boot values for dom0 only.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
xen/arch/arm/domain_build.c | 2 +-
xen/common/grant_table.c | 35 ++++++++++++++---------------------
xen/include/xen/grant_table.h | 4 +---
3 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index d6f9585503..ecfeab0969 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2097,7 +2097,7 @@ static void __init find_gnttab_region(struct domain *d,
kinfo->gnttab_size = (_etext - _stext) & PAGE_MASK;
/* Make sure the grant table will fit in the region */
- if ( (kinfo->gnttab_size >> PAGE_SHIFT) < max_grant_frames )
+ if ( grant_table_verify_size(d, kinfo->gnttab_size >> PAGE_SHIFT) )
panic("Cannot find a space for the grant table region\n");
#ifdef CONFIG_ARM_32
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index dc878a84f9..99eac11a16 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -85,21 +85,8 @@ struct grant_table {
#define DEFAULT_MAX_NR_GRANT_FRAMES 32
#endif
-unsigned int __read_mostly max_grant_frames;
-integer_param("gnttab_max_frames", max_grant_frames);
-
-/* The maximum number of grant mappings is defined as a multiplier of the
- * maximum number of grant table entries. This defines the multiplier used.
- * Pretty arbitrary. [POLICY]
- * As gnttab_max_nr_frames has been deprecated, this multiplier is deprecated
too.
- * New options allow to set max_maptrack_frames and
- * map_grant_table_frames independently.
- */
#define DEFAULT_MAX_MAPTRACK_FRAMES 1024
-static unsigned int __read_mostly max_maptrack_frames;
-integer_param("gnttab_max_maptrack_frames", max_maptrack_frames);
-
/*
* Note that the three values below are effectively part of the ABI, even if
* we don't need to make them a formal part of it: A guest suspended for
@@ -3463,6 +3450,10 @@ grant_table_create(
struct domain *d)
{
struct grant_table *t;
+ static unsigned int max_grant_frames;
+ static unsigned int max_maptrack_frames;
+ integer_param("gnttab_max_frames", max_grant_frames);
+ integer_param("gnttab_max_maptrack_frames", max_maptrack_frames);
if ( (t = xzalloc(struct grant_table)) == NULL )
return -ENOMEM;
@@ -3470,14 +3461,17 @@ grant_table_create(
/* Simple stuff. */
percpu_rwlock_resource_init(&t->lock, grant_rwlock);
spin_lock_init(&t->maptrack_lock);
- t->max_grant_frames = max_grant_frames;
- t->max_maptrack_frames = max_maptrack_frames;
/* Okay, install the structure. */
d->grant_table = t;
if ( d->domain_id == 0 )
+ {
+ t->max_grant_frames = max_grant_frames ? : DEFAULT_MAX_NR_GRANT_FRAMES;
+ t->max_maptrack_frames =
+ max_maptrack_frames ? : DEFAULT_MAX_MAPTRACK_FRAMES;
return grant_table_init(t);
+ }
return 0;
}
@@ -3855,18 +3849,17 @@ static int __init gnttab_usage_init(void)
{
BUILD_BUG_ON(DEFAULT_MAX_MAPTRACK_FRAMES < DEFAULT_MAX_NR_GRANT_FRAMES);
- if ( !max_grant_frames )
- max_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES;
-
- if ( !max_maptrack_frames )
- max_maptrack_frames = DEFAULT_MAX_MAPTRACK_FRAMES;
-
register_keyhandler('g', gnttab_usage_print_all,
"print grant table usage", 1);
return 0;
}
__initcall(gnttab_usage_init);
+bool __init grant_table_verify_size(struct domain *d, unsigned int frames)
+{
+ return d->grant_table->max_grant_frames > frames;
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index f3f2fb9ebc..1633364ff3 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -30,9 +30,6 @@
struct grant_table;
-/* The maximum size of a grant table. */
-extern unsigned int max_grant_frames;
-
/* Create/destroy per-domain grant table context. */
int grant_table_create(
struct domain *d);
@@ -41,6 +38,7 @@ void grant_table_destroy(
void grant_table_init_vcpu(struct vcpu *v);
int grant_table_set_limits(struct domain *d, unsigned int grant_frames,
unsigned int maptrack_frames);
+bool grant_table_verify_size(struct domain *d, unsigned int frames);
/*
* Check if domain has active grants and log first 10 of them.
--
2.12.3
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |