|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 21/43] arm/p2m: Change func prototype and impl of p2m_{alloc,free}_vmid
From: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
This commit changes the prototype and implementation of the functions
"p2m_alloc_vmid" and "p2m_free_vmid". The function "p2m_alloc_vmid" does
not expect the struct domain as argument anymore and returns an
allocated vmid. The function "p2m_free_vmid" takes only the vmid that is
to be freed as argument.
This is commit 10/12 of the altp2m_init/altp2m_teardown routines phase.
Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
---
v3: Changed function prototypes and implementation of the functions
"p2m_alloc_vmid" and "p2m_free_vmid".
Changes in "p2m_alloc_vmid":
This function does not expect any arguments. Also, in this commit,
the function "p2m_alloc_vmid" returns either the successfully
allocated vmid or the value INVALID_VMID. Thus, it is now the
responsibility of the caller to set the returned vmid in the
associated fields.
Changes in "p2m_free_vmid":
This function expects now only the vmid of type uint8_t.
---
xen/arch/arm/include/asm/p2m.h | 4 ++--
xen/arch/arm/mmu/p2m.c | 8 ++++----
xen/arch/arm/p2m.c | 23 ++++++++---------------
3 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
index 5c6dfe4a9789..62261d41e780 100644
--- a/xen/arch/arm/include/asm/p2m.h
+++ b/xen/arch/arm/include/asm/p2m.h
@@ -195,8 +195,8 @@ static inline bool arch_acquire_resource_check(struct
domain *d)
void p2m_restrict_ipa_bits(unsigned int ipa_bits);
void p2m_vmid_allocator_init(void);
-int p2m_alloc_vmid(struct domain *d);
-void p2m_free_vmid(struct domain *d);
+uint8_t p2m_alloc_vmid(void);
+void p2m_free_vmid(uint8_t vmid);
/* Second stage paging setup, to be called on all CPUs */
void setup_virt_paging(void);
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index f546f63f2489..0d37760ef5d5 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -1519,7 +1519,7 @@ void p2m_free_one(struct p2m_domain *p2m)
p2m->root = NULL;
- p2m_free_vmid(p2m->domain);
+ p2m_free_vmid(p2m->vmid);
radix_tree_destroy(&p2m->mem_access_settings, NULL);
@@ -1570,9 +1570,9 @@ static int p2m_initialise(struct domain *d, struct
p2m_domain *p2m)
*/
p2m->domain = d;
- rc = p2m_alloc_vmid(d);
- if ( rc )
- return rc;
+ p2m->vmid = p2m_alloc_vmid();
+ if ( p2m->vmid == INVALID_VMID )
+ return -EBUSY;
rc = p2m_alloc_table(p2m);
if ( rc )
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 2c43b6033360..3342fafcc8a7 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -282,11 +282,9 @@ void p2m_vmid_allocator_init(void)
set_bit(INVALID_VMID, vmid_mask);
}
-int p2m_alloc_vmid(struct domain *d)
+uint8_t p2m_alloc_vmid(void)
{
- struct p2m_domain *p2m = p2m_get_hostp2m(d);
-
- int rc, vmid;
+ uint8_t vmid;
spin_lock(&vmid_alloc_lock);
@@ -296,28 +294,23 @@ int p2m_alloc_vmid(struct domain *d)
if ( vmid == MAX_VMID )
{
- rc = -EBUSY;
- printk(XENLOG_ERR "p2m.c: dom%d: VMID pool exhausted\n", d->domain_id);
+ vmid = INVALID_VMID;
+ printk(XENLOG_ERR "p2m.c: VMID pool exhausted\n");
goto out;
}
set_bit(vmid, vmid_mask);
- p2m->vmid = vmid;
-
- rc = 0;
-
out:
spin_unlock(&vmid_alloc_lock);
- return rc;
+ return vmid;
}
-void p2m_free_vmid(struct domain *d)
+void p2m_free_vmid(uint8_t vmid)
{
- struct p2m_domain *p2m = p2m_get_hostp2m(d);
spin_lock(&vmid_alloc_lock);
- if ( p2m->vmid != INVALID_VMID )
- clear_bit(p2m->vmid, vmid_mask);
+ if ( vmid != INVALID_VMID )
+ clear_bit(vmid, vmid_mask);
spin_unlock(&vmid_alloc_lock);
}
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |