[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250424141341.841734-14-karim.manaouil@linaro.org>
Date: Thu, 24 Apr 2025 15:13:20 +0100
From: Karim Manaouil <karim.manaouil@...aro.org>
To: linux-kernel@...r.kernel.org,
kvm@...r.kernel.org,
linux-arm-msm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.linux.dev
Cc: Karim Manaouil <karim.manaouil@...aro.org>,
Alexander Graf <graf@...zon.com>,
Alex Elder <elder@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
Fuad Tabba <tabba@...gle.com>,
Joey Gouly <joey.gouly@....com>,
Jonathan Corbet <corbet@....net>,
Marc Zyngier <maz@...nel.org>,
Mark Brown <broonie@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Oliver Upton <oliver.upton@...ux.dev>,
Paolo Bonzini <pbonzini@...hat.com>,
Prakruthi Deepak Heragu <quic_pheragu@...cinc.com>,
Quentin Perret <qperret@...gle.com>,
Rob Herring <robh@...nel.org>,
Srinivas Kandagatla <srini@...nel.org>,
Srivatsa Vaddagiri <quic_svaddagi@...cinc.com>,
Will Deacon <will@...nel.org>,
Haripranesh S <haripran@....qualcomm.com>,
Carl van Schaik <cvanscha@....qualcomm.com>,
Murali Nalajala <mnalajal@...cinc.com>,
Sreenivasulu Chalamcharla <sreeniva@....qualcomm.com>,
Trilok Soni <tsoni@...cinc.com>,
Stefan Schmidt <stefan.schmidt@...aro.org>,
Elliot Berman <quic_eberman@...cinc.com>,
Alex Elder <elder@...aro.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Subject: [RFC PATCH 13/34] gunyah: Add hypercalls to send and receive messages
From: Elliot Berman <quic_eberman@...cinc.com>
Add hypercalls to send and receive messages on a Gunyah message queue.
Reviewed-by: Alex Elder <elder@...aro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Signed-off-by: Elliot Berman <quic_eberman@...cinc.com>
Signed-off-by: Karim Manaouil <karim.manaouil@...aro.org>
---
arch/arm64/gunyah/gunyah_hypercall.c | 55 ++++++++++++++++++++++++++++
include/linux/gunyah.h | 8 ++++
2 files changed, 63 insertions(+)
diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c
index d44663334f38..1302e128be6e 100644
--- a/arch/arm64/gunyah/gunyah_hypercall.c
+++ b/arch/arm64/gunyah/gunyah_hypercall.c
@@ -37,6 +37,8 @@ EXPORT_SYMBOL_GPL(arch_is_gunyah_guest);
/* clang-format off */
#define GUNYAH_HYPERCALL_HYP_IDENTIFY GUNYAH_HYPERCALL(0x8000)
+#define GUNYAH_HYPERCALL_MSGQ_SEND GUNYAH_HYPERCALL(0x801B)
+#define GUNYAH_HYPERCALL_MSGQ_RECV GUNYAH_HYPERCALL(0x801C)
/* clang-format on */
/**
@@ -58,5 +60,58 @@ void gunyah_hypercall_hyp_identify(
}
EXPORT_SYMBOL_GPL(gunyah_hypercall_hyp_identify);
+/**
+ * gunyah_hypercall_msgq_send() - Send a buffer on a message queue
+ * @capid: capability ID of the message queue to add message
+ * @size: Size of @buff
+ * @buff: Address of buffer to send
+ * @tx_flags: See GUNYAH_HYPERCALL_MSGQ_TX_FLAGS_*
+ * @ready: If the send was successful, ready is filled with true if more
+ * messages can be sent on the queue. If false, then the tx IRQ will
+ * be raised in future when send can succeed.
+ */
+enum gunyah_error gunyah_hypercall_msgq_send(u64 capid, size_t size, void *buff,
+ u64 tx_flags, bool *ready)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_1_1_hvc(GUNYAH_HYPERCALL_MSGQ_SEND, capid, size,
+ (uintptr_t)buff, tx_flags, 0, &res);
+
+ if (res.a0 == GUNYAH_ERROR_OK)
+ *ready = !!res.a1;
+
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(gunyah_hypercall_msgq_send);
+
+/**
+ * gunyah_hypercall_msgq_recv() - Send a buffer on a message queue
+ * @capid: capability ID of the message queue to add message
+ * @buff: Address of buffer to copy received data into
+ * @size: Size of @buff
+ * @recv_size: If the receive was successful, recv_size is filled with the
+ * size of data received. Will be <= size.
+ * @ready: If the receive was successful, ready is filled with true if more
+ * messages are ready to be received on the queue. If false, then the
+ * rx IRQ will be raised in future when recv can succeed.
+ */
+enum gunyah_error gunyah_hypercall_msgq_recv(u64 capid, void *buff, size_t size,
+ size_t *recv_size, bool *ready)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_1_1_hvc(GUNYAH_HYPERCALL_MSGQ_RECV, capid, (uintptr_t)buff,
+ size, 0, &res);
+
+ if (res.a0 == GUNYAH_ERROR_OK) {
+ *recv_size = res.a1;
+ *ready = !!res.a2;
+ }
+
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(gunyah_hypercall_msgq_recv);
+
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Gunyah Hypervisor Hypercalls");
diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h
index 33bcbd22d39f..acd70f982425 100644
--- a/include/linux/gunyah.h
+++ b/include/linux/gunyah.h
@@ -141,4 +141,12 @@ gunyah_api_version(const struct gunyah_hypercall_hyp_identify_resp *gunyah_api)
void gunyah_hypercall_hyp_identify(
struct gunyah_hypercall_hyp_identify_resp *hyp_identity);
+/* Immediately raise RX vIRQ on receiver VM */
+#define GUNYAH_HYPERCALL_MSGQ_TX_FLAGS_PUSH BIT(0)
+
+enum gunyah_error gunyah_hypercall_msgq_send(u64 capid, size_t size, void *buff,
+ u64 tx_flags, bool *ready);
+enum gunyah_error gunyah_hypercall_msgq_recv(u64 capid, void *buff, size_t size,
+ size_t *recv_size, bool *ready);
+
#endif
--
2.39.5
Powered by blists - more mailing lists