All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Wiklander <jens.wiklander@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: patches@linaro.org, Jens Wiklander <jens.wiklander@linaro.org>,
	Volodymyr Babchuk <volodymyr_babchuk@epam.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>
Subject: [XEN PATCH] xen/arm: ffa: return fpi size from FFA_PARTITION_INFO_GET
Date: Wed, 13 Dec 2023 11:31:35 +0100	[thread overview]
Message-ID: <20231213103135.2346238-1-jens.wiklander@linaro.org> (raw)

Until now has FFA_PARTITION_INFO_GET always returned zero in w3, but
FF-A v1.1 requires FFA_PARTITION_INFO_GET to return the size of each
partition information descriptor returned if
FFA_PARTITION_INFO_GET_COUNT_FLAG isn't set.

The SPMC queried with FFA_PARTITION_INFO_GET must also return the each
partition information descriptor returned so fix this by passing along
the same value.

Fixes: caf6491e95a9 ("xen/arm: ffa: support guest FFA_PARTITION_INFO_GET")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
---
 xen/arch/arm/tee/ffa.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
index 183528d13388..1d4e0a083006 100644
--- a/xen/arch/arm/tee/ffa.c
+++ b/xen/arch/arm/tee/ffa.c
@@ -514,7 +514,7 @@ static int32_t ffa_rxtx_map(paddr_t tx_addr, paddr_t rx_addr,
 
 static int32_t ffa_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
                                       uint32_t w4, uint32_t w5,
-                                      uint32_t *count)
+                                      uint32_t *count, uint32_t *fpi_size)
 {
     const struct arm_smccc_1_2_regs arg = {
         .a0 = FFA_PARTITION_INFO_GET,
@@ -531,7 +531,10 @@ static int32_t ffa_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
 
     ret = get_ffa_ret_code(&resp);
     if ( !ret )
+    {
         *count = resp.a2;
+        *fpi_size = resp.a3;
+    }
 
     return ret;
 }
@@ -784,7 +787,7 @@ static uint32_t handle_rxtx_unmap(void)
 
 static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
                                          uint32_t w4, uint32_t w5,
-                                         uint32_t *count)
+                                         uint32_t *count, uint32_t *fpi_size)
 {
     int32_t ret = FFA_RET_DENIED;
     struct domain *d = current->domain;
@@ -799,7 +802,7 @@ static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
      */
     if ( w5 == FFA_PARTITION_INFO_GET_COUNT_FLAG &&
          ctx->guest_vers == FFA_VERSION_1_1 )
-        return ffa_partition_info_get(w1, w2, w3, w4, w5, count);
+        return ffa_partition_info_get(w1, w2, w3, w4, w5, count, fpi_size);
     if ( w5 )
         return FFA_RET_INVALID_PARAMETERS;
 
@@ -812,7 +815,7 @@ static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
     if ( !ctx->page_count || !ctx->rx_is_free )
         goto out;
     spin_lock(&ffa_rx_buffer_lock);
-    ret = ffa_partition_info_get(w1, w2, w3, w4, w5, count);
+    ret = ffa_partition_info_get(w1, w2, w3, w4, w5, count, fpi_size);
     if ( ret )
         goto out_rx_buf_unlock;
     /*
@@ -842,7 +845,7 @@ static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
     }
     else
     {
-        size_t sz = *count * sizeof(struct ffa_partition_info_1_1);
+        size_t sz = *count * *fpi_size;
 
         if ( ctx->page_count * FFA_PAGE_SIZE < sz )
         {
@@ -1409,6 +1412,7 @@ static bool ffa_handle_call(struct cpu_user_regs *regs)
     uint32_t fid = get_user_reg(regs, 0);
     struct domain *d = current->domain;
     struct ffa_ctx *ctx = d->arch.tee;
+    uint32_t fpi_size;
     uint32_t count;
     int e;
 
@@ -1444,11 +1448,11 @@ static bool ffa_handle_call(struct cpu_user_regs *regs)
                                       get_user_reg(regs, 2),
                                       get_user_reg(regs, 3),
                                       get_user_reg(regs, 4),
-                                      get_user_reg(regs, 5), &count);
+                                      get_user_reg(regs, 5), &count, &fpi_size);
         if ( e )
             set_regs_error(regs, e);
         else
-            set_regs_success(regs, count, 0);
+            set_regs_success(regs, count, fpi_size);
         return true;
     case FFA_RX_RELEASE:
         e = handle_rx_release();
@@ -1629,10 +1633,11 @@ static bool init_subscribers(struct ffa_partition_info_1_1 *fpi, uint16_t count)
 static bool init_sps(void)
 {
     bool ret = false;
+    uint32_t fpi_size;
     uint32_t count;
     int e;
 
-    e = ffa_partition_info_get(0, 0, 0, 0, 0, &count);
+    e = ffa_partition_info_get(0, 0, 0, 0, 0, &count, &fpi_size);
     if ( e )
     {
         printk(XENLOG_ERR "ffa: Failed to get list of SPs: %d\n", e);
-- 
2.34.1



             reply	other threads:[~2023-12-13 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 10:31 Jens Wiklander [this message]
2023-12-18 14:33 ` [XEN PATCH] xen/arm: ffa: return fpi size from FFA_PARTITION_INFO_GET Bertrand Marquis
2023-12-19 18:35   ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231213103135.2346238-1-jens.wiklander@linaro.org \
    --to=jens.wiklander@linaro.org \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=patches@linaro.org \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.