VHE: Add vm helper function get memory mode for a partitions range.
Added vm helper that gets the memory mode for a given range(ipa for a vm
and va for a el0 partition).
Change-Id: Ia0d7094528795571b4e5203312222b3e30d69682
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
diff --git a/src/vm.c b/src/vm.c
index 635b3d1..bb9d7f1 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -393,3 +393,22 @@
notifications->bindings_sender_id[i] = HF_INVALID_VM_ID;
}
}
+
+/**
+ * Gets the mode of the given range of ipa or va if they are mapped with the
+ * same mode.
+ *
+ * Returns true if the range is mapped with the same mode and false otherwise.
+ * The wrapper calls the appropriate mm function depending on if the partition
+ * is a vm or a el0 partition.
+ */
+bool vm_mem_get_mode(struct vm_locked vm_locked, ipaddr_t begin, ipaddr_t end,
+ uint32_t *mode)
+{
+ if (vm_locked.vm->el0_partition) {
+ return mm_get_mode(&vm_locked.vm->ptable,
+ va_from_pa(pa_from_ipa(begin)),
+ va_from_pa(pa_from_ipa(end)), mode);
+ }
+ return mm_vm_get_mode(&vm_locked.vm->ptable, begin, end, mode);
+}