feat(ff-a): Implement FFA_MEM_PERM_GET/SET
This patch implements the new ABI from the FF-A v1.1 Beta0 spec. These
ABIs are expected to be used by S-EL0 use cases such as StandaloneMM or
other S-EL0 applications such as trusted firmware services or any other
S-EL0 FF-A partition.
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
Change-Id: I6a57420ce5821993671362280a66c5c4f190ffbc
diff --git a/inc/hf/addr.h b/inc/hf/addr.h
index 1f1e2bf..a2d2080 100644
--- a/inc/hf/addr.h
+++ b/inc/hf/addr.h
@@ -168,3 +168,11 @@
{
return (void *)va_addr(va);
}
+
+/**
+ * Advances a virtual address.
+ */
+static inline vaddr_t va_add(vaddr_t va, size_t n)
+{
+ return va_init(va_addr(va) + n);
+}
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 46bd8f9..cbc521e 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -116,3 +116,7 @@
struct vcpu *current);
struct ffa_value api_ffa_notification_info_get(struct vcpu *current);
+
+struct ffa_value api_ffa_mem_perm_get(vaddr_t base_addr, struct vcpu *current);
+struct ffa_value api_ffa_mem_perm_set(vaddr_t base_addr, uint32_t page_count,
+ uint32_t mem_perm, struct vcpu *current);
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 1dcb050..2cd51e6 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -133,3 +133,6 @@
uint32_t *lists_sizes,
uint32_t *lists_count,
const uint32_t ids_count_max);
+
+bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current);
+bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current);
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 749e4ac..6b57c92 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -456,3 +456,19 @@
.func = FFA_NOTIFICATION_INFO_GET_64,
});
}
+
+static inline struct ffa_value ffa_mem_perm_get(uint64_t base_va)
+{
+ return ffa_call((struct ffa_value){.func = FFA_MEM_PERM_GET_32,
+ .arg1 = base_va});
+}
+
+static inline struct ffa_value ffa_mem_perm_set(uint64_t base_va,
+ uint32_t page_count,
+ uint32_t mem_perm)
+{
+ return ffa_call((struct ffa_value){.func = FFA_MEM_PERM_SET_32,
+ .arg1 = base_va,
+ .arg2 = page_count,
+ .arg3 = mem_perm});
+}
diff --git a/inc/vmapi/hf/ffa.h b/inc/vmapi/hf/ffa.h
index dda1001..cc87c42 100644
--- a/inc/vmapi/hf/ffa.h
+++ b/inc/vmapi/hf/ffa.h
@@ -77,6 +77,8 @@
#define FFA_SECONDARY_EP_REGISTER_64 0xC4000087
#define FFA_MEM_PERM_GET_32 0x84000088
#define FFA_MEM_PERM_SET_32 0x84000089
+#define FFA_MEM_PERM_GET_64 0xC4000088
+#define FFA_MEM_PERM_SET_64 0xC4000089
/* FF-A error codes. */
#define FFA_NOT_SUPPORTED INT32_C(-1)
@@ -102,6 +104,10 @@
#define FFA_SLEEP_INDEFINITE 0
+#define FFA_MEM_PERM_RO UINT32_C(0x7)
+#define FFA_MEM_PERM_RW UINT32_C(0x5)
+#define FFA_MEM_PERM_RX UINT32_C(0x3)
+
/**
* For use where the FF-A specification refers explicitly to '4K pages'. Not to
* be confused with PAGE_SIZE, which is the translation granule Hafnium is