From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
sstabellini@kernel.org, wei.liu2@citrix.com,
George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com,
jbeulich@suse.com, dgdegra@tycho.nsa.gov
Subject: [PATCH v8 12/15] xen/arm: move arch specific grant table bits into grant_table.c
Date: Wed, 20 Sep 2017 08:34:27 +0200 [thread overview]
Message-ID: <20170920063430.9105-13-jgross@suse.com> (raw)
In-Reply-To: <20170920063430.9105-1-jgross@suse.com>
Instead of attaching the ARM specific grant table data to the domain
structure add it to struct grant_table. Add the needed arch functions
to the asm-*/grant_table.h includes.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
---
V7:
- re-add #include <asm/grant-table.h> in grant_table.h (Julien Grall)
---
xen/arch/arm/domain.c | 2 --
xen/common/grant_table.c | 26 +++++++++++++++++++-------
xen/include/asm-arm/domain.h | 1 -
xen/include/asm-arm/grant_table.h | 26 +++++++++++++++++++-------
xen/include/asm-x86/grant_table.h | 12 +++++++-----
xen/include/xen/grant_table.h | 2 ++
6 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 784ae392cf..e39a79885c 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -486,13 +486,11 @@ struct domain *alloc_domain_struct(void)
return NULL;
clear_page(d);
- d->arch.grant_table_gfn = xzalloc_array(gfn_t, max_grant_frames);
return d;
}
void free_domain_struct(struct domain *d)
{
- xfree(d->arch.grant_table_gfn);
free_xenheap_page(d);
}
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index f66940551e..26f9a32656 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -72,6 +72,8 @@ struct grant_table {
struct active_grant_entry **active;
/* Mapping tracking table per vcpu. */
struct grant_mapping **maptrack;
+
+ struct grant_table_arch arch;
};
#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */
@@ -1658,6 +1660,8 @@ gnttab_unpopulate_status_frames(struct domain *d, struct grant_table *gt)
static int
grant_table_init(struct grant_table *gt)
{
+ int ret = -ENOMEM;
+
if ( gt->active )
return -EBUSY;
@@ -1665,34 +1669,40 @@ grant_table_init(struct grant_table *gt)
gt->active = xzalloc_array(struct active_grant_entry *,
max_nr_active_grant_frames);
if ( gt->active == NULL )
- goto no_mem;
+ goto out;
/* Tracking of mapped foreign frames table */
gt->maptrack = vzalloc(max_maptrack_frames * sizeof(*gt->maptrack));
if ( gt->maptrack == NULL )
- goto no_mem;
+ goto out;
/* Shared grant table. */
gt->shared_raw = xzalloc_array(void *, max_grant_frames);
if ( gt->shared_raw == NULL )
- goto no_mem;
+ goto out;
/* Status pages for grant table - for version 2 */
gt->status = xzalloc_array(grant_status_t *,
grant_to_status_frames(max_grant_frames));
if ( gt->status == NULL )
- goto no_mem;
+ goto out;
+
+ ret = gnttab_init_arch(gt);
+ if ( ret )
+ goto out;
return 0;
- no_mem:
+ out:
+ xfree(gt->status);
+ gt->status = NULL;
xfree(gt->shared_raw);
gt->shared_raw = NULL;
vfree(gt->maptrack);
gt->maptrack = NULL;
xfree(gt->active);
gt->active = NULL;
- return -ENOMEM;
+ return ret;
}
/*
@@ -3603,6 +3613,8 @@ grant_table_destroy(
if ( t == NULL )
return;
+ gnttab_destroy_arch(t);
+
for ( i = 0; i < nr_grant_frames(t); i++ )
free_xenheap_page(t->shared_raw[i]);
xfree(t->shared_raw);
@@ -3729,7 +3741,7 @@ int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
}
if ( !rc )
- gnttab_set_frame_gfn(d, idx, gfn);
+ gnttab_set_frame_gfn(gt, idx, gfn);
grant_write_unlock(gt);
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index b174c65080..ce9b6a4032 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -50,7 +50,6 @@ struct arch_domain
struct p2m_domain p2m;
struct hvm_domain hvm_domain;
- gfn_t *grant_table_gfn;
struct vmmio vmmio;
diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h
index 0a248a765a..0870b5b782 100644
--- a/xen/include/asm-arm/grant_table.h
+++ b/xen/include/asm-arm/grant_table.h
@@ -6,6 +6,10 @@
#define INITIAL_NR_GRANT_FRAMES 4
+struct grant_table_arch {
+ gfn_t *gfn;
+};
+
void gnttab_clear_flag(unsigned long nr, uint16_t *addr);
int create_grant_host_mapping(unsigned long gpaddr,
unsigned long mfn, unsigned int flags, unsigned int
@@ -22,11 +26,19 @@ static inline int replace_grant_supported(void)
return 1;
}
-static inline void gnttab_set_frame_gfn(struct domain *d, unsigned long idx,
- gfn_t gfn)
-{
- d->arch.grant_table_gfn[idx] = gfn;
-}
+#define gnttab_init_arch(gt) \
+ ( ((gt)->arch.gfn = xzalloc_array(gfn_t, max_grant_frames)) == 0 \
+ ? 0 : -ENOMEM )
+
+#define gnttab_destroy_arch(gt) \
+ do { \
+ xfree((gt)->arch.gfn); \
+ } while ( 0 )
+
+#define gnttab_set_frame_gfn(gt, idx, gfn) \
+ do { \
+ (gt)->arch.gfn[idx] = gfn; \
+ } while ( 0 )
#define gnttab_create_shared_page(d, t, i) \
do { \
@@ -36,8 +48,8 @@ static inline void gnttab_set_frame_gfn(struct domain *d, unsigned long idx,
} while ( 0 )
#define gnttab_shared_gmfn(d, t, i) \
- ( ((i >= nr_grant_frames(d->grant_table)) && \
- (i < max_grant_frames)) ? 0 : gfn_x(d->arch.grant_table_gfn[i]))
+ ( ((i >= nr_grant_frames(t)) && \
+ (i < max_grant_frames)) ? 0 : gfn_x(t->arch.gfn[i]))
#define gnttab_need_iommu_mapping(d) \
(is_domain_direct_mapped(d) && need_iommu(d))
diff --git a/xen/include/asm-x86/grant_table.h b/xen/include/asm-x86/grant_table.h
index c865999a33..1b93c5720d 100644
--- a/xen/include/asm-x86/grant_table.h
+++ b/xen/include/asm-x86/grant_table.h
@@ -14,6 +14,9 @@
#define INITIAL_NR_GRANT_FRAMES 4
+struct grant_table_arch {
+};
+
/*
* Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
* must hold a reference to the page.
@@ -36,6 +39,10 @@ static inline int replace_grant_host_mapping(uint64_t addr, unsigned long frame,
return replace_grant_pv_mapping(addr, frame, new_addr, flags);
}
+#define gnttab_init_arch(gt) 0
+#define gnttab_destroy_arch(gt) do {} while ( 0 )
+#define gnttab_set_frame_gfn(gt, idx, gfn) do {} while ( 0 )
+
#define gnttab_create_shared_page(d, t, i) \
do { \
share_xen_page_with_guest( \
@@ -75,11 +82,6 @@ static inline void gnttab_clear_flag(unsigned int nr, uint16_t *st)
asm volatile ("lock btrw %w1,%0" : "=m" (*st) : "Ir" (nr), "m" (*st));
}
-static inline void gnttab_set_frame_gfn(struct domain *d, unsigned long idx,
- gfn_t gfn)
-{
-}
-
/* Foreign mappings of HHVM-guest pages do not modify the type count. */
#define gnttab_host_mapping_get_page_type(ro, ld, rd) \
(!(ro) && (((ld) == (rd)) || !paging_mode_external(rd)))
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index df11b31264..d2bd2416c4 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -29,6 +29,8 @@
#include <asm/page.h>
#include <asm/grant_table.h>
+struct grant_table;
+
/* The maximum size of a grant table. */
extern unsigned int max_grant_frames;
--
2.12.3
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-20 6:34 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 6:34 [PATCH v8 00/15] xen: better grant v2 support Juergen Gross
2017-09-20 6:34 ` [PATCH v8 01/15] xen: move XENMAPSPACE_grant_table code into grant_table.c Juergen Gross
2017-09-20 12:40 ` Julien Grall
2017-09-20 6:34 ` [PATCH v8 02/15] xen: clean up grant_table.h Juergen Gross
2017-09-20 6:34 ` [PATCH v8 03/15] xen: add new domctl hypercall to set grant table resource limits Juergen Gross
2017-09-20 8:26 ` Paul Durrant
2017-09-20 8:49 ` Jan Beulich
2017-09-20 6:34 ` [PATCH v8 04/15] xen: add function for obtaining highest possible memory address Juergen Gross
2017-09-20 8:57 ` Jan Beulich
[not found] ` <59C2499A020000780017D412@suse.com>
2017-09-20 8:58 ` Juergen Gross
2017-09-20 9:32 ` Jan Beulich
[not found] ` <59C251C8020000780017D4D7@suse.com>
2017-09-20 9:39 ` Juergen Gross
2017-09-20 12:51 ` Julien Grall
2017-09-20 13:08 ` Juergen Gross
2017-09-20 14:24 ` Julien Grall
2017-09-20 14:33 ` Juergen Gross
2017-09-20 17:15 ` Julien Grall
2017-09-21 4:18 ` Juergen Gross
2017-09-20 6:34 ` [PATCH v8 05/15] xen: add max possible mfn to struct xen_sysctl_physinfo Juergen Gross
2017-09-20 8:58 ` Jan Beulich
[not found] ` <59C249F3020000780017D415@suse.com>
2017-09-20 9:00 ` Juergen Gross
2017-09-20 12:53 ` Julien Grall
2017-09-20 13:06 ` Juergen Gross
2017-09-20 6:34 ` [PATCH v8 06/15] libxc: add libxc support for setting grant table resource limits Juergen Gross
2017-09-20 6:34 ` [PATCH v8 07/15] tools: set grant limits for xenstore stubdom Juergen Gross
2017-09-20 6:34 ` [PATCH v8 08/15] libxl: add max possible mfn to libxl_physinfo Juergen Gross
2017-09-20 6:34 ` [PATCH v8 09/15] xl: add global grant limit config items Juergen Gross
2017-09-20 6:34 ` [PATCH v8 10/15] libxl: add libxl support for setting grant table resource limits Juergen Gross
2017-09-20 6:34 ` [PATCH v8 11/15] xen: delay allocation of grant table sub structures Juergen Gross
2017-09-20 9:22 ` Jan Beulich
[not found] ` <59C24F80020000780017D473@suse.com>
2017-09-20 9:44 ` Juergen Gross
2017-09-20 10:02 ` Jan Beulich
[not found] ` <59C258D4020000780017D521@suse.com>
2017-09-20 10:05 ` Juergen Gross
2017-09-20 6:34 ` Juergen Gross [this message]
2017-09-20 9:25 ` [PATCH v8 12/15] xen/arm: move arch specific grant table bits into grant_table.c Jan Beulich
2017-09-20 14:34 ` Julien Grall
2017-09-21 4:36 ` Juergen Gross
2017-09-20 6:34 ` [PATCH v8 13/15] xen: make grant resource limits per domain Juergen Gross
2017-09-20 10:34 ` Jan Beulich
2017-09-20 14:37 ` Julien Grall
[not found] ` <59C2603C020000780017D561@suse.com>
2017-09-20 11:10 ` Juergen Gross
2017-09-20 11:48 ` Jan Beulich
[not found] ` <59C271B9020000780017D620@suse.com>
2017-09-20 12:44 ` Juergen Gross
2017-09-20 15:35 ` Jan Beulich
[not found] ` <59C2A6DE020000780017D874@suse.com>
2017-09-21 4:35 ` Juergen Gross
2017-09-21 6:15 ` Jan Beulich
[not found] ` <59C3751D020000780017DCB6@suse.com>
2017-09-21 7:53 ` Juergen Gross
2017-09-21 11:31 ` Jan Beulich
[not found] ` <59C3BF28020000780017DE68@suse.com>
2017-09-21 11:39 ` Juergen Gross
2017-09-21 11:48 ` Jan Beulich
[not found] ` <59C3C33E020000780017DEC3@suse.com>
2017-09-21 11:51 ` Juergen Gross
2017-09-22 6:19 ` Juergen Gross
2017-09-22 7:53 ` Jan Beulich
[not found] ` <59C4DD9B020000780017E575@suse.com>
2017-09-22 8:27 ` Juergen Gross
2017-09-22 8:35 ` Jan Beulich
[not found] ` <59C4E78B020000780017E67D@suse.com>
2017-09-22 8:44 ` Juergen Gross
2017-09-22 8:51 ` Jan Beulich
2017-09-20 6:34 ` [PATCH v8 14/15] xen: make grant table limits boot parameters dom0 only Juergen Gross
2017-09-20 12:07 ` Jan Beulich
[not found] ` <59C27619020000780017D66F@suse.com>
2017-09-20 12:48 ` Juergen Gross
2017-09-20 15:36 ` Jan Beulich
[not found] ` <59C2A72D020000780017D881@suse.com>
2017-09-21 4:27 ` Juergen Gross
2017-09-21 6:16 ` Jan Beulich
2017-09-20 6:34 ` [PATCH v8 15/15] xen: add new Xen cpuid node for max address width info Juergen Gross
2017-09-20 12:18 ` Jan Beulich
[not found] ` <59C278A3020000780017D689@suse.com>
2017-09-20 12:58 ` Juergen Gross
2017-09-20 15:42 ` Jan Beulich
[not found] ` <59C2A880020000780017D8A2@suse.com>
2017-09-21 4:21 ` Juergen Gross
2017-09-20 13:00 ` Julien Grall
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=20170920063430.9105-13-jgross@suse.com \
--to=jgross@suse.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).