VHE: Associate a page table with an ASID/VMID
Added an id field to page table structures(struct mm_ptable). This will
help future changes where we can invalidate TLB entries by VMID's and
ASID's. In the near term, this is primarily expected to be useful for
EL0 partitions, where we want to be able to invalidate TLB by ASID's
when mapping/unmapping/replacing page table entries for an EL0
partition.
Change-Id: I3b6ea97eaf4281954ca953cb8f5a40edbf5a2661
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
diff --git a/src/mm.c b/src/mm.c
index c1e7059..c7b7e45 100644
--- a/src/mm.c
+++ b/src/mm.c
@@ -202,7 +202,8 @@
/**
* Initialises the given page table.
*/
-bool mm_ptable_init(struct mm_ptable *t, int flags, struct mpool *ppool)
+bool mm_ptable_init(struct mm_ptable *t, uint16_t id, int flags,
+ struct mpool *ppool)
{
uint8_t i;
size_t j;
@@ -226,7 +227,7 @@
* enabled?
*/
t->root = pa_init((uintpaddr_t)tables);
-
+ t->id = id;
return true;
}
@@ -824,9 +825,9 @@
return got_attrs;
}
-bool mm_vm_init(struct mm_ptable *t, struct mpool *ppool)
+bool mm_vm_init(struct mm_ptable *t, uint16_t id, struct mpool *ppool)
{
- return mm_ptable_init(t, 0, ppool);
+ return mm_ptable_init(t, id, 0, ppool);
}
void mm_vm_fini(struct mm_ptable *t, struct mpool *ppool)
@@ -1064,7 +1065,8 @@
dlog_info("data: %#x - %#x\n", pa_addr(layout_data_begin()),
pa_addr(layout_data_end()));
- if (!mm_ptable_init(&ptable, MM_FLAG_STAGE1, ppool)) {
+ /* ASID 0 is reserved for use by the hypervisor. */
+ if (!mm_ptable_init(&ptable, 0, MM_FLAG_STAGE1, ppool)) {
dlog_error("Unable to allocate memory for page table.\n");
return false;
}