summaryrefslogtreecommitdiff
path: root/arch/arm64/kvm/hyp/nvhe/ffa.c
diff options
context:
space:
mode:
authorWill Deacon <will@kernel.org>2023-05-23 11:18:20 +0100
committerOliver Upton <oliver.upton@linux.dev>2023-06-01 21:34:50 +0000
commitbc3888a0f4e979ecf9dd8c33a84b8da8cc130790 (patch)
tree8e82812248a4ce48682e680402ecc8b85454ae7f /arch/arm64/kvm/hyp/nvhe/ffa.c
parent12bdce4f41197a1a97ba1c711f77d557841e13d9 (diff)
KVM: arm64: Allocate pages for hypervisor FF-A mailboxes
The FF-A proxy code needs to allocate its own buffer pair for communication with EL3 and for forwarding calls from the host at EL1. Reserve a couple of pages for this purpose and use them to initialise the hypervisor's FF-A buffer structure. Co-developed-by: Andrew Walbran <qwandor@google.com> Signed-off-by: Andrew Walbran <qwandor@google.com> Signed-off-by: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20230523101828.7328-4-will@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/kvm/hyp/nvhe/ffa.c')
-rw-r--r--arch/arm64/kvm/hyp/nvhe/ffa.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
index abdcaf98d9b0..c85e5d46a90d 100644
--- a/arch/arm64/kvm/hyp/nvhe/ffa.c
+++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
@@ -28,8 +28,11 @@
#include <linux/arm-smccc.h>
#include <linux/arm_ffa.h>
+#include <asm/kvm_pkvm.h>
+
#include <nvhe/ffa.h>
#include <nvhe/trap_handler.h>
+#include <nvhe/spinlock.h>
/*
* "ID value 0 must be returned at the Non-secure physical FF-A instance"
@@ -37,6 +40,19 @@
*/
#define HOST_FFA_ID 0
+struct kvm_ffa_buffers {
+ hyp_spinlock_t lock;
+ void *tx;
+ void *rx;
+};
+
+/*
+ * Note that we don't currently lock these buffers explicitly, instead
+ * relying on the locking of the host FFA buffers as we only have one
+ * client.
+ */
+static struct kvm_ffa_buffers hyp_buffers;
+
static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno)
{
*res = (struct arm_smccc_res) {
@@ -124,7 +140,7 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt)
return true;
}
-int hyp_ffa_init(void)
+int hyp_ffa_init(void *pages)
{
struct arm_smccc_res res;
@@ -145,5 +161,11 @@ int hyp_ffa_init(void)
if (res.a2 != HOST_FFA_ID)
return -EINVAL;
+ hyp_buffers = (struct kvm_ffa_buffers) {
+ .lock = __HYP_SPIN_LOCK_UNLOCKED,
+ .tx = pages,
+ .rx = pages + (KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE),
+ };
+
return 0;
}