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>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v3 6/12] xen/gnttab: Pass max_{grant, maptrack}_frames into grant_table_create()
Date: Wed, 29 Aug 2018 10:38:39 +0100 [thread overview]
Message-ID: <1535535519-23117-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1534154469-6076-7-git-send-email-andrew.cooper3@citrix.com>
... rather than setting the limits up after domain_create() has completed.
This removes the common gnttab infrastructure for calculating the number of
dom0 grant frames (as the common grant table code is not an appropriate place
for it to live), opting instead to require the dom0 construction code to pass
a sane value in via the configuration.
In practice, this now means that there is never a partially constructed grant
table for a reference-able domain.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: Wei Liu <wei.liu2@citrix.com>
v2:
* Split/rearrange to avoid the post-domain-create error path.
v3:
* Retain gnttab_dom0_frames() for ARM. Sadly needs to be a macro as
opt_max_grant_frames isn't declared until later in xen/grant_table.h
---
xen/arch/arm/setup.c | 3 +++
xen/arch/x86/setup.c | 3 +++
xen/common/domain.c | 3 ++-
xen/common/grant_table.c | 16 +++-------------
xen/include/asm-arm/grant_table.h | 6 ++----
xen/include/asm-x86/grant_table.h | 5 -----
xen/include/xen/grant_table.h | 6 ++----
7 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 45f3841..501a9d5 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -20,6 +20,7 @@
#include <xen/compile.h>
#include <xen/device_tree.h>
#include <xen/domain_page.h>
+#include <xen/grant_table.h>
#include <xen/types.h>
#include <xen/string.h>
#include <xen/serial.h>
@@ -693,6 +694,8 @@ void __init start_xen(unsigned long boot_phys_offset,
struct domain *dom0;
struct xen_domctl_createdomain dom0_cfg = {
.max_evtchn_port = -1,
+ .max_grant_frames = gnttab_dom0_frames(),
+ .max_maptrack_frames = opt_max_maptrack_frames,
};
dcache_line_bytes = read_dcache_line_bytes();
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index dd11815..8440643 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1,6 +1,7 @@
#include <xen/init.h>
#include <xen/lib.h>
#include <xen/err.h>
+#include <xen/grant_table.h>
#include <xen/sched.h>
#include <xen/sched-if.h>
#include <xen/domain.h>
@@ -682,6 +683,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
struct xen_domctl_createdomain dom0_cfg = {
.flags = XEN_DOMCTL_CDF_s3_integrity,
.max_evtchn_port = -1,
+ .max_grant_frames = opt_max_grant_frames,
+ .max_maptrack_frames = opt_max_maptrack_frames,
};
/* Critical region without IDT or TSS. Any fault is deadly! */
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 171d25e..1dcab8d 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -366,7 +366,8 @@ struct domain *domain_create(domid_t domid,
goto fail;
init_status |= INIT_evtchn;
- if ( (err = grant_table_create(d)) != 0 )
+ if ( (err = grant_table_create(d, config->max_grant_frames,
+ config->max_maptrack_frames)) != 0 )
goto fail;
init_status |= INIT_gnttab;
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index ad55cfa..f08341e 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3567,9 +3567,8 @@ do_grant_table_op(
#include "compat/grant_table.c"
#endif
-int
-grant_table_create(
- struct domain *d)
+int grant_table_create(struct domain *d, unsigned int max_grant_frames,
+ unsigned int max_maptrack_frames)
{
struct grant_table *t;
int ret = 0;
@@ -3587,11 +3586,7 @@ grant_table_create(
t->domain = d;
d->grant_table = t;
- if ( d->domain_id == 0 )
- {
- ret = grant_table_init(d, t, gnttab_dom0_frames(),
- opt_max_maptrack_frames);
- }
+ ret = grant_table_set_limits(d, max_maptrack_frames, max_maptrack_frames);
return ret;
}
@@ -4049,11 +4044,6 @@ static int __init gnttab_usage_init(void)
}
__initcall(gnttab_usage_init);
-unsigned int __init gnttab_dom0_frames(void)
-{
- return min(opt_max_grant_frames, gnttab_dom0_max());
-}
-
/*
* Local variables:
* mode: C
diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h
index 5113b91..d8fde01 100644
--- a/xen/include/asm-arm/grant_table.h
+++ b/xen/include/asm-arm/grant_table.h
@@ -30,10 +30,8 @@ void gnttab_mark_dirty(struct domain *d, mfn_t mfn);
* Only use the text section as it's always present and will contain
* enough space for a large grant table
*/
-static inline unsigned int gnttab_dom0_max(void)
-{
- return PFN_DOWN(_etext - _stext);
-}
+#define gnttab_dom0_frames() \
+ min_t(unsigned int, opt_max_grant_frames, PFN_DOWN(_etext - _stext))
#define gnttab_init_arch(gt) \
({ \
diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_table.h
index 76ec5dd..761a8c3 100644
--- a/xen/include/asm-x86/grant_table.h
+++ b/xen/include/asm-x86/grant_table.h
@@ -39,11 +39,6 @@ static inline int replace_grant_host_mapping(uint64_t addr, mfn_t frame,
return replace_grant_pv_mapping(addr, frame, new_addr, flags);
}
-static inline unsigned int gnttab_dom0_max(void)
-{
- return UINT_MAX;
-}
-
#define gnttab_init_arch(gt) 0
#define gnttab_destroy_arch(gt) do {} while ( 0 )
#define gnttab_set_frame_gfn(gt, st, idx, gfn) do {} while ( 0 )
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index c881414..b46bb0a 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -35,8 +35,8 @@ extern unsigned int opt_max_grant_frames;
extern unsigned int opt_max_maptrack_frames;
/* Create/destroy per-domain grant table context. */
-int grant_table_create(
- struct domain *d);
+int grant_table_create(struct domain *d, unsigned int max_grant_frames,
+ unsigned int max_maptrack_frames);
void grant_table_destroy(
struct domain *d);
void grant_table_init_vcpu(struct vcpu *v);
@@ -63,6 +63,4 @@ int gnttab_get_shared_frame(struct domain *d, unsigned long idx,
int gnttab_get_status_frame(struct domain *d, unsigned long idx,
mfn_t *mfn);
-unsigned int gnttab_dom0_frames(void);
-
#endif /* __XEN_GRANT_TABLE_H__ */
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-08-29 9:38 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 10:00 [PATCH v2 00/12] Improvements to domain creation Andrew Cooper
2018-08-13 10:00 ` [PATCH v2 01/12] tools/ocaml: Pass a full domctl_create_config into stub_xc_domain_create() Andrew Cooper
2018-08-13 10:00 ` [PATCH v2 02/12] tools: Rework xc_domain_create() to take a full xen_domctl_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 03/12] xen/domctl: Merge set_max_evtchn into createdomain Andrew Cooper
2018-08-14 13:58 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 04/12] xen/evtchn: Pass max_evtchn_port into evtchn_init() Andrew Cooper
2018-08-14 14:07 ` Roger Pau Monné
2018-08-15 12:45 ` Jan Beulich
2018-08-15 12:57 ` Julien Grall
2018-08-13 10:01 ` [PATCH v2 05/12] tools: Pass grant table limits to XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 06/12] xen/gnttab: Pass max_{grant, maptrack}_frames into grant_table_create() Andrew Cooper
2018-08-14 14:17 ` Roger Pau Monné
2018-08-15 12:51 ` Jan Beulich
2018-08-15 13:04 ` Julien Grall
2018-08-15 13:08 ` Andrew Cooper
2018-08-15 13:32 ` Julien Grall
2018-08-15 19:03 ` Andrew Cooper
2018-08-16 8:59 ` Julien Grall
2018-08-29 9:38 ` Andrew Cooper [this message]
2018-08-30 19:40 ` [PATCH v3 6/12] " Julien Grall
2018-08-13 10:01 ` [PATCH v2 07/12] xen/domctl: Remove XEN_DOMCTL_set_gnttab_limits Andrew Cooper
2018-08-14 14:19 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 08/12] xen/gnttab: Fold grant_table_{create, set_limits}() into grant_table_init() Andrew Cooper
2018-08-14 14:31 ` Roger Pau Monné
2018-08-15 12:54 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 09/12] xen/domain: Call arch_domain_create() as early as possible in domain_create() Andrew Cooper
2018-08-14 14:37 ` Roger Pau Monné
2018-08-15 12:56 ` Jan Beulich
2018-09-04 18:44 ` Rats nest with domain pirq initialisation Andrew Cooper
2018-09-05 7:24 ` Jan Beulich
2018-09-05 11:38 ` Jan Beulich
2018-09-05 12:04 ` Andrew Cooper
2018-09-05 12:25 ` Jan Beulich
2018-09-05 12:39 ` Andrew Cooper
2018-09-05 15:44 ` Roger Pau Monné
2018-08-13 10:01 ` [PATCH v2 10/12] tools: Pass max_vcpus to XEN_DOMCTL_createdomain Andrew Cooper
2018-08-13 10:01 ` [PATCH v2 11/12] xen/dom0: Arrange for dom0_cfg to contain the real max_vcpus value Andrew Cooper
2018-08-14 15:05 ` Roger Pau Monné
2018-08-15 12:59 ` Jan Beulich
2018-08-13 10:01 ` [PATCH v2 12/12] xen/domain: Allocate d->vcpu[] in domain_create() Andrew Cooper
2018-08-14 15:17 ` Roger Pau Monné
2018-08-15 13:17 ` Julien Grall
2018-08-15 13:50 ` Andrew Cooper
2018-08-15 13:52 ` Julien Grall
2018-08-15 13:56 ` Andrew Cooper
2018-08-15 13:11 ` Jan Beulich
2018-08-15 14:03 ` Andrew Cooper
2018-08-15 15:18 ` Jan Beulich
2018-08-29 10:36 ` Andrew Cooper
2018-08-29 12:10 ` Jan Beulich
2018-08-29 12:29 ` Andrew Cooper
2018-08-29 12:49 ` Jan Beulich
2018-08-29 14:40 ` [PATCH v3 " Andrew Cooper
2018-08-29 15:03 ` Jan Beulich
2018-08-31 10:33 ` Wei Liu
2018-08-31 10:42 ` Jan Beulich
2018-08-31 10:57 ` Julien Grall
2018-08-31 11:00 ` Juergen Gross
2018-08-31 10:58 ` Andrew Cooper
2018-08-30 19:46 ` Julien Grall
2018-08-30 20:04 ` Andrew Cooper
2018-08-14 13:12 ` [PATCH v2 00/12] Improvements to domain creation Christian Lindig
2018-08-14 13:34 ` Andrew Cooper
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=1535535519-23117-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=wei.liu2@citrix.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).