mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
Replace grant-table typedefs with explicit structs.
Reduce MAPTRACK_MAX_ENTRIES to something plausible. Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
8965df86b5
commit
813669dd41
4 files changed
+43
-43
No files matched your search
@@ -639,7 +639,7 @@ void _audit_domain(struct domain *d, int flags)
|
||||
void scan_for_pfn_in_grant_table(struct domain *d, unsigned xmfn)
|
||||
{
|
||||
int i;
|
||||
active_grant_entry_t *act = d->grant_table->active;
|
||||
struct active_grant_entry *act = d->grant_table->active;
|
||||
|
||||
spin_lock(&d->grant_table->lock);
|
||||
|
||||
|
||||
+29
-30
@@ -41,7 +41,7 @@
|
||||
|
||||
static inline int
|
||||
get_maptrack_handle(
|
||||
grant_table_t *t)
|
||||
struct grant_table *t)
|
||||
{
|
||||
unsigned int h;
|
||||
if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
|
||||
@@ -53,7 +53,7 @@ get_maptrack_handle(
|
||||
|
||||
static inline void
|
||||
put_maptrack_handle(
|
||||
grant_table_t *t, int handle)
|
||||
struct grant_table *t, int handle)
|
||||
{
|
||||
t->maptrack[handle].ref = t->maptrack_head;
|
||||
t->maptrack_head = handle;
|
||||
@@ -76,7 +76,7 @@ __gnttab_map_grant_ref(
|
||||
int handle;
|
||||
unsigned long frame = 0;
|
||||
int rc = GNTST_okay;
|
||||
active_grant_entry_t *act;
|
||||
struct active_grant_entry *act;
|
||||
|
||||
/* Entry details from @rd's shared grant table. */
|
||||
grant_entry_t *sha;
|
||||
@@ -123,9 +123,9 @@ __gnttab_map_grant_ref(
|
||||
/* Get a maptrack handle. */
|
||||
if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
|
||||
{
|
||||
int i;
|
||||
grant_mapping_t *new_mt;
|
||||
grant_table_t *lgt = ld->grant_table;
|
||||
int i;
|
||||
struct grant_mapping *new_mt;
|
||||
struct grant_table *lgt = ld->grant_table;
|
||||
|
||||
if ( (lgt->maptrack_limit << 1) > MAPTRACK_MAX_ENTRIES )
|
||||
{
|
||||
@@ -264,10 +264,9 @@ __gnttab_map_grant_ref(
|
||||
|
||||
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, op->dom);
|
||||
|
||||
ld->grant_table->maptrack[handle].domid = op->dom;
|
||||
ld->grant_table->maptrack[handle].ref = op->ref;
|
||||
ld->grant_table->maptrack[handle].flags =
|
||||
(op->flags & MAPTRACK_GNTMAP_MASK);
|
||||
ld->grant_table->maptrack[handle].domid = op->dom;
|
||||
ld->grant_table->maptrack[handle].ref = op->ref;
|
||||
ld->grant_table->maptrack[handle].flags = op->flags;
|
||||
|
||||
op->dev_bus_addr = (u64)frame << PAGE_SHIFT;
|
||||
op->handle = handle;
|
||||
@@ -326,9 +325,9 @@ __gnttab_unmap_grant_ref(
|
||||
domid_t dom;
|
||||
grant_ref_t ref;
|
||||
struct domain *ld, *rd;
|
||||
active_grant_entry_t *act;
|
||||
struct active_grant_entry *act;
|
||||
grant_entry_t *sha;
|
||||
grant_mapping_t *map;
|
||||
struct grant_mapping *map;
|
||||
u16 flags;
|
||||
s16 rc = 0;
|
||||
unsigned long frame;
|
||||
@@ -534,12 +533,12 @@ static int
|
||||
gnttab_prepare_for_transfer(
|
||||
struct domain *rd, struct domain *ld, grant_ref_t ref)
|
||||
{
|
||||
grant_table_t *rgt;
|
||||
grant_entry_t *sha;
|
||||
domid_t sdom;
|
||||
u16 sflags;
|
||||
u32 scombo, prev_scombo;
|
||||
int retries = 0;
|
||||
struct grant_table *rgt;
|
||||
struct grant_entry *sha;
|
||||
domid_t sdom;
|
||||
u16 sflags;
|
||||
u32 scombo, prev_scombo;
|
||||
int retries = 0;
|
||||
|
||||
if ( unlikely((rgt = rd->grant_table) == NULL) ||
|
||||
unlikely(ref >= NR_GRANT_ENTRIES) )
|
||||
@@ -775,11 +774,11 @@ int
|
||||
grant_table_create(
|
||||
struct domain *d)
|
||||
{
|
||||
grant_table_t *t;
|
||||
int i;
|
||||
struct grant_table *t;
|
||||
int i;
|
||||
|
||||
BUG_ON(MAPTRACK_MAX_ENTRIES < NR_GRANT_ENTRIES);
|
||||
if ( (t = xmalloc(grant_table_t)) == NULL )
|
||||
if ( (t = xmalloc(struct grant_table)) == NULL )
|
||||
goto no_mem;
|
||||
|
||||
/* Simple stuff. */
|
||||
@@ -787,16 +786,16 @@ grant_table_create(
|
||||
spin_lock_init(&t->lock);
|
||||
|
||||
/* Active grant table. */
|
||||
if ( (t->active = xmalloc_array(active_grant_entry_t, NR_GRANT_ENTRIES))
|
||||
== NULL )
|
||||
t->active = xmalloc_array(struct active_grant_entry, NR_GRANT_ENTRIES);
|
||||
if ( t->active == NULL )
|
||||
goto no_mem;
|
||||
memset(t->active, 0, sizeof(active_grant_entry_t) * NR_GRANT_ENTRIES);
|
||||
memset(t->active, 0, sizeof(struct active_grant_entry) * NR_GRANT_ENTRIES);
|
||||
|
||||
/* Tracking of mapped foreign frames table */
|
||||
if ( (t->maptrack = alloc_xenheap_page()) == NULL )
|
||||
goto no_mem;
|
||||
t->maptrack_order = 0;
|
||||
t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
|
||||
t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping);
|
||||
memset(t->maptrack, 0, PAGE_SIZE);
|
||||
for ( i = 0; i < t->maptrack_limit; i++ )
|
||||
t->maptrack[i].ref = i+1;
|
||||
@@ -829,13 +828,13 @@ void
|
||||
gnttab_release_mappings(
|
||||
struct domain *d)
|
||||
{
|
||||
grant_table_t *gt = d->grant_table;
|
||||
grant_mapping_t *map;
|
||||
struct grant_table *gt = d->grant_table;
|
||||
struct grant_mapping *map;
|
||||
grant_ref_t ref;
|
||||
grant_handle_t handle;
|
||||
struct domain *rd;
|
||||
active_grant_entry_t *act;
|
||||
grant_entry_t *sha;
|
||||
struct active_grant_entry *act;
|
||||
struct grant_entry *sha;
|
||||
|
||||
BUG_ON(!test_bit(_DOMF_dying, &d->domain_flags));
|
||||
|
||||
@@ -912,7 +911,7 @@ void
|
||||
grant_table_destroy(
|
||||
struct domain *d)
|
||||
{
|
||||
grant_table_t *t = d->grant_table;
|
||||
struct grant_table *t = d->grant_table;
|
||||
|
||||
if ( t == NULL )
|
||||
return;
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#include <asm/grant_table.h>
|
||||
|
||||
/* Active grant entry - used for shadowing GTF_permit_access grants. */
|
||||
typedef struct {
|
||||
struct active_grant_entry {
|
||||
u32 pin; /* Reference count information. */
|
||||
domid_t domid; /* Domain being granted access. */
|
||||
unsigned long frame; /* Frame being granted. */
|
||||
} active_grant_entry_t;
|
||||
};
|
||||
|
||||
/* Count of writable host-CPU mappings. */
|
||||
#define GNTPIN_hstw_shift (0)
|
||||
@@ -60,29 +60,30 @@ typedef struct {
|
||||
* Tracks a mapping of another domain's grant reference. Each domain has a
|
||||
* table of these, indexes into which are returned as a 'mapping handle'.
|
||||
*/
|
||||
typedef struct {
|
||||
struct grant_mapping {
|
||||
u32 ref; /* grant ref */
|
||||
u16 flags; /* 0-4: GNTMAP_* ; 5-15: unused */
|
||||
domid_t domid; /* granting domain */
|
||||
} grant_mapping_t;
|
||||
#define MAPTRACK_GNTMAP_MASK 0x1f
|
||||
#define MAPTRACK_MAX_ENTRIES (~((u32)0))
|
||||
};
|
||||
|
||||
/* Fairly arbitrary. [POLICY] */
|
||||
#define MAPTRACK_MAX_ENTRIES 16384
|
||||
|
||||
/* Per-domain grant information. */
|
||||
typedef struct {
|
||||
struct grant_table {
|
||||
/* Shared grant table (see include/public/grant_table.h). */
|
||||
grant_entry_t *shared;
|
||||
struct grant_entry *shared;
|
||||
/* Active grant table. */
|
||||
active_grant_entry_t *active;
|
||||
struct active_grant_entry *active;
|
||||
/* Mapping tracking table. */
|
||||
grant_mapping_t *maptrack;
|
||||
struct grant_mapping *maptrack;
|
||||
unsigned int maptrack_head;
|
||||
unsigned int maptrack_order;
|
||||
unsigned int maptrack_limit;
|
||||
unsigned int map_count;
|
||||
/* Lock protecting updates to active and shared grant tables. */
|
||||
spinlock_t lock;
|
||||
} grant_table_t;
|
||||
};
|
||||
|
||||
/* Create/destroy per-domain grant table context. */
|
||||
int grant_table_create(
|
||||
|
||||
@@ -125,7 +125,7 @@ struct domain
|
||||
struct evtchn *evtchn[NR_EVTCHN_BUCKETS];
|
||||
spinlock_t evtchn_lock;
|
||||
|
||||
grant_table_t *grant_table;
|
||||
struct grant_table *grant_table;
|
||||
|
||||
/*
|
||||
* Interrupt to event-channel mappings. Updates should be protected by the
|
||||
|
||||