KVM: arm64: Use FF-A 1.1 with pKVM
authorSebastian Ene <sebastianene@google.com>
Thu, 13 Jun 2024 13:20:35 +0000 (13:20 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Fri, 14 Jun 2024 20:28:30 +0000 (20:28 +0000)
Now that the layout of the structures is compatible with 1.1 it is time
to probe the 1.1 version of the FF-A protocol inside the hypervisor. If
the TEE doesn't support it, it should return the minimum supported
version.

Signed-off-by: Sebastian Ene <sebastianene@google.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20240613132035.1070360-5-sebastianene@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/hyp/nvhe/ffa.c

index 4eaef673e98d7785247898cee476396abcb142dc..fdb63b7857ecb98cb52f22c631832654b616fe24 100644 (file)
@@ -457,7 +457,7 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id,
        memcpy(buf, host_buffers.tx, fraglen);
 
        ep_mem_access = (void *)buf +
-                       ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0);
+                       ffa_mem_desc_offset(buf, 0, hyp_ffa_version);
        offset = ep_mem_access->composite_off;
        if (!offset || buf->ep_count != 1 || buf->sender_id != HOST_FFA_ID) {
                ret = FFA_RET_INVALID_PARAMETERS;
@@ -536,7 +536,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res,
        fraglen = res->a2;
 
        ep_mem_access = (void *)buf +
-                       ffa_mem_desc_offset(buf, 0, FFA_VERSION_1_0);
+                       ffa_mem_desc_offset(buf, 0, hyp_ffa_version);
        offset = ep_mem_access->composite_off;
        /*
         * We can trust the SPMD to get this right, but let's at least
@@ -844,7 +844,7 @@ int hyp_ffa_init(void *pages)
        if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2)
                return 0;
 
-       arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_0, 0, 0, 0, 0, 0, 0, &res);
+       arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_1, 0, 0, 0, 0, 0, 0, &res);
        if (res.a0 == FFA_RET_NOT_SUPPORTED)
                return 0;
 
@@ -864,7 +864,11 @@ int hyp_ffa_init(void *pages)
        if (FFA_MAJOR_VERSION(res.a0) != 1)
                return -EOPNOTSUPP;
 
-       hyp_ffa_version = FFA_VERSION_1_0;
+       if (FFA_MINOR_VERSION(res.a0) < FFA_MINOR_VERSION(FFA_VERSION_1_1))
+               hyp_ffa_version = res.a0;
+       else
+               hyp_ffa_version = FFA_VERSION_1_1;
+
        tx = pages;
        pages += KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE;
        rx = pages;