Skip to contentSkip to conversation

KVM: arm64: Forward FFA_NOTIFICATION* calls to TrustZone

PATCH Superseded Sebastian Ene 3 participants 25 messages Jun 8 – Jun 16

Subsystems (2)

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v2 cover KVM: arm64: Forward FFA_NOTIFICATION* calls to TrustZone

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

---
Changes in v2:
- enforce the MBZ/SBZ fields
- split the calls into separate patches
- rebase on 7.1-rc7

Link to v1:
https://lore.kernel.org/all/[email protected]/

Sebastian Ene (7):
KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler
KVM: arm64: Support FFA_NOTIFICATION_BITMAP_DESTROY in host handler
KVM: arm64: Support FFA_NOTIFICATION_BIND in host handler
KVM: arm64: Support FFA_NOTIFICATION_UNBIND in host handler
KVM: arm64: Support FFA_NOTIFICATION_SET in host handler
KVM: arm64: Support FFA_NOTIFICATION_GET in host handler
KVM: arm64: Support FFA_NOTIFICATION_INFO_GET in host handler

 arch/arm64/kvm/hyp/nvhe/ffa.c | 190 ++++++++++++++++++++++++++++++++--
 1 file changed, 182 insertions(+), 8 deletions(-)
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#1 lore raw

PATCH v2 1/7 KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler

Allow FF-A notification bitmap creation messages to be forwarded to Trustzone from the host and introduce a helper to check for SBZ register fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +35 -1
index 1af722771178..c20d45191085 100644
@@ -71,6 +71,18 @@ static u32 hyp_ffa_version;
 static bool has_version_negotiated;
 static hyp_spinlock_t version_lock;
 
+static bool ffa_check_unused_args_sbz(struct kvm_cpu_context *ctxt, int first_reg)
+{
+	int reg;
+
+	for (reg = first_reg; reg < 17; reg++) {
+		if (cpu_reg(ctxt, reg))
+			return true;
+	}
+
+	return false;
+}
+
 static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_errno)
 {
 	*res = (struct arm_smccc_1_2_regs) {
@@ -676,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_CREATE:
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
@@ -862,6 +873,26 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res,
 	hyp_spin_unlock(&host_buffers.lock);
 }
 
+static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
+				       struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 3)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -920,6 +951,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_PARTITION_INFO_GET:
 		do_ffa_part_get(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_CREATE:
+		do_ffa_notif_bitmap_create(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#2 lore raw

Re: [PATCH v2 1/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler

Hi Seb,

Quoted 14 lines · Sebastian Ene

Allow FF-A notification bitmap creation messages to be forwarded to Trustzone from the host and introduce a helper to check for SBZ register fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
index 1af722771178..c20d45191085 100644

arch/arm64/kvm/hyp/nvhe/ffa.c static u32 hyp_ffa_version; · line 78

Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
@@ -71,6 +71,18 @@ static u32 hyp_ffa_version;
 static bool has_version_negotiated;
 static hyp_spinlock_t version_lock;
 
+static bool ffa_check_unused_args_sbz(struct kvm_cpu_context *ctxt, int first_reg)
+{
+	int reg;
+
+	for (reg = first_reg; reg < 17; reg++) {

The upper limit should probably be something like ARRAY_SIZE(ctx->regs.regs) - first_reg?

Quoted 19 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -1
+		if (cpu_reg(ctxt, reg))
+			return true;
+	}
+
+	return false;
+}
+
 static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_errno)
 {
 	*res = (struct arm_smccc_1_2_regs) {
@@ -676,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_CREATE:
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 882

Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -0
@@ -862,6 +873,26 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res,
 	hyp_spin_unlock(&host_buffers.lock);
 }
 
+static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
+				       struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 3)) {

Is that expected we start at 3 but only read 0 and 1?

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 893

Quoted 11 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +11 -0
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);

Should be hyp_smccc_1_2_smc()

Quoted 18 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -920,6 +951,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_PARTITION_INFO_GET:
 		do_ffa_part_get(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_CREATE:
+		do_ffa_notif_bitmap_create(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#3 lore raw

Re: [PATCH v2 1/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler

Quoted 20 lines · Vincent Donnefort

Hi Seb,

Quoted 17 lines · Sebastian Ene

Allow FF-A notification bitmap creation messages to be forwarded to Trustzone from the host and introduce a helper to check for SBZ register fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
index 1af722771178..c20d45191085 100644
@@ -71,6 +71,18 @@ static u32 hyp_ffa_version;
 static bool has_version_negotiated;
 static hyp_spinlock_t version_lock;
 
Quoted 7 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static u32 hyp_ffa_version; · line 78

Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+static bool ffa_check_unused_args_sbz(struct kvm_cpu_context *ctxt, int first_reg)
+{
+	int reg;
+
+	for (reg = first_reg; reg < 17; reg++) {

The upper limit should probably be something like ARRAY_SIZE(ctx->regs.regs) - first_reg?

I wasn't really inspired this morning on the cruiser...

But nonetheless, that 17 should probably be a #define somewhere?

Quoted 23 lines
Quoted 23 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -1
+		if (cpu_reg(ctxt, reg))
+			return true;
+	}
+
+	return false;
+}
+
 static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_errno)
 {
 	*res = (struct arm_smccc_1_2_regs) {
@@ -676,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_CREATE:
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
@@ -862,6 +873,26 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res,
 	hyp_spin_unlock(&host_buffers.lock);
 }
 
Quoted 9 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 882

Quoted 7 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -0
+static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
+				       struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 3)) {

Is that expected we start at 3 but only read 0 and 1?

Ha, we do not read 2 but nonetheless it is useful!

Quoted 33 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 893

Quoted 12 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +11 -0
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);

Should be hyp_smccc_1_2_smc()

Quoted 18 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -920,6 +951,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_PARTITION_INFO_GET:
 		do_ffa_part_get(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_CREATE:
+		do_ffa_notif_bitmap_create(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#4 lore raw

Re: [PATCH v2 1/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler

In reply to Vincent Donnefort
Quoted 20 lines · Vincent Donnefort

Hi Seb,

Quoted 17 lines · Sebastian Ene

Allow FF-A notification bitmap creation messages to be forwarded to Trustzone from the host and introduce a helper to check for SBZ register fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
index 1af722771178..c20d45191085 100644
@@ -71,6 +71,18 @@ static u32 hyp_ffa_version;
 static bool has_version_negotiated;
 static hyp_spinlock_t version_lock;
 
Quoted 8 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static u32 hyp_ffa_version; · line 78

Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+static bool ffa_check_unused_args_sbz(struct kvm_cpu_context *ctxt, int first_reg)
+{
+	int reg;
+
+	for (reg = first_reg; reg < 17; reg++) {

The upper limit should probably be something like ARRAY_SIZE(ctx->regs.regs) - first_reg?

The upper limit is 17 since the smc64 uses x1-x17 as arguments and w0 as a function identifier. ARRAY_SIZE(ctx->regs.regs) is 31

Quoted 22 lines
Quoted 22 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -1
+		if (cpu_reg(ctxt, reg))
+			return true;
+	}
+
+	return false;
+}
+
 static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_errno)
 {
 	*res = (struct arm_smccc_1_2_regs) {
@@ -676,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_CREATE:
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
@@ -862,6 +873,26 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs *res,
 	hyp_spin_unlock(&host_buffers.lock);
 }
 
Quoted 10 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 882

Quoted 7 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +7 -0
+static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
+				       struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 3)) {

Is that expected we start at 3 but only read 0 and 1?

That's what they are saying in the ffa doc (16.1 FFA_NOTIFICATION_BITMAP_CREATE). They use w2 to hold the number of vcpus, that's why they start at 3.

Quoted 5 lines
Quoted 5 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (vmid != HOST_FFA_ID) {
Quoted 9 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, · line 893

Quoted 6 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +6 -0
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);

Should be hyp_smccc_1_2_smc()

Yes, replaced it with this.

Quoted 14 lines
Quoted 14 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -920,6 +951,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_PARTITION_INFO_GET:
 		do_ffa_part_get(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_CREATE:
+		do_ffa_notif_bitmap_create(&res, host_ctxt);
+		goto out_handled;
 	}
 
Quoted 4 lines
Quoted 4 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog

Thanks,
Sebastian

#5 lore raw

PATCH v2 2/7 KVM: arm64: Support FFA_NOTIFICATION_BITMAP_DESTROY in host handler

In reply to Sebastian Ene

Allow FF-A notification bitmap destruction messages to be forwarded to Trustzone from the host.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +23 -1
index c20d45191085..91e89d889c44 100644
@@ -688,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
@@ -893,6 +892,26 @@ static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
+					struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 2)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -954,6 +973,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_CREATE:
 		do_ffa_notif_bitmap_create(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_DESTROY:
+		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#6 lore raw

Re: [PATCH v2 2/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_DESTROY in host handler

Quoted 33 lines · Sebastian Ene

Allow FF-A notification bitmap destruction messages to be forwarded to Trustzone from the host.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +9 -1
index c20d45191085..91e89d889c44 100644
@@ -688,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
@@ -893,6 +892,26 @@ static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
+					struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 2)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res, · line 913

Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +10 -0
+	}
+
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}

Sounds exactly like do_ffa_notif_bitmap_create. Could we use a single one "do_ffa_notif_bitmap" ?

Quoted 17 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +4 -0
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -954,6 +973,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_CREATE:
 		do_ffa_notif_bitmap_create(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_DESTROY:
+		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#7 lore raw

Re: [PATCH v2 2/7] KVM: arm64: Support FFA_NOTIFICATION_BITMAP_DESTROY in host handler

Quoted 36 lines · Vincent Donnefort
Quoted 35 lines · Sebastian Ene

Allow FF-A notification bitmap destruction messages to be forwarded to Trustzone from the host.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +11 -1
index c20d45191085..91e89d889c44 100644
@@ -688,7 +688,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BITMAP_DESTROY:
 	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
@@ -893,6 +892,26 @@ static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
+					struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, vmid, ctxt, 1);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 2)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
Quoted 8 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_create(struct arm_smccc_1_2_regs *res, · line 913

Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +8 -0
+	if (vmid != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}

Hello Vincent,

Quoted 4 lines

Sounds exactly like do_ffa_notif_bitmap_create. Could we use a single one "do_ffa_notif_bitmap" ?

Yes, I guess we can have only one method since the only difference between them is in the number of unused args.

Quoted 13 lines
Quoted 13 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +4 -0
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -954,6 +973,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_CREATE:
 		do_ffa_notif_bitmap_create(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BITMAP_DESTROY:
+		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
+		goto out_handled;
 	}
 
Quoted 4 lines
Quoted 4 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog

Thanks,
Sebastian

#8 lore raw

PATCH v2 3/7 KVM: arm64: Support FFA_NOTIFICATION_BIND in host handler

In reply to Sebastian Ene

Verify the arguments of the FF-A notification bind call and forward the message to Trustzone.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +31 -1
index 91e89d889c44..eedb01955a45 100644
@@ -42,6 +42,8 @@
  */
 #define HOST_FFA_ID	0
 
+#define FFA_NOTIF_SENDER_ENDP_MASK	GENMASK(31, 16)
+
 /*
  * A buffer to hold the maximum descriptor size we can see from the host,
  * which is required when the SPMD returns a fragmented FFA_MEM_RETRIEVE_RESP
@@ -688,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
 	case FFA_NOTIFICATION_GET:
@@ -912,6 +913,32 @@ static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bind(struct arm_smccc_1_2_regs *res,
+			      struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, endp_id, ctxt, 1);
+	DECLARE_REG(u32, flags, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 5)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (FIELD_GET(FFA_NOTIF_SENDER_ENDP_MASK, endp_id) != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (flags & GENMASK(31, 1)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -976,6 +1003,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BIND:
+		do_ffa_notif_bind(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#9 lore raw

Re: [PATCH v2 3/7] KVM: arm64: Support FFA_NOTIFICATION_BIND in host handler

Quoted 13 lines · Sebastian Ene

Verify the arguments of the FF-A notification bind call and forward the message to Trustzone.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
index 91e89d889c44..eedb01955a45 100644

arch/arm64/kvm/hyp/nvhe/ffa.c line 45

Quoted 4 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +1 -0
@@ -42,6 +42,8 @@
  */
 #define HOST_FFA_ID	0
 
+#define FFA_NOTIF_SENDER_ENDP_MASK	GENMASK(31, 16)

Could we move the MASK definitions form arm_ffa to include/linux/arm_ffa.h?

Quoted 27 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +12 -1
+
 /*
  * A buffer to hold the maximum descriptor size we can see from the host,
  * which is required when the SPMD returns a fragmented FFA_MEM_RETRIEVE_RESP
@@ -688,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
 	case FFA_NOTIFICATION_GET:
@@ -912,6 +913,32 @@ static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bind(struct arm_smccc_1_2_regs *res,
+			      struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, endp_id, ctxt, 1);
+	DECLARE_REG(u32, flags, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 5)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res, · line 936

Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +10 -0
+
+	if (FIELD_GET(FFA_NOTIF_SENDER_ENDP_MASK, endp_id) != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (flags & GENMASK(31, 1)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
	if (flags > 1) ?

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res, · line 939

Quoted 3 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +3 -0
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);

And of course just like all the other functions, it should use the hyp_ prefix.

Quoted 18 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -976,6 +1003,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BIND:
+		do_ffa_notif_bind(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#10 lore raw

Re: [PATCH v2 3/7] KVM: arm64: Support FFA_NOTIFICATION_BIND in host handler

Quoted 17 lines · Vincent Donnefort
Quoted 16 lines · Sebastian Ene

Verify the arguments of the FF-A notification bind call and forward the message to Trustzone.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
index 91e89d889c44..eedb01955a45 100644
@@ -42,6 +42,8 @@
  */
 #define HOST_FFA_ID	0
 
Quoted 4 lines

arch/arm64/kvm/hyp/nvhe/ffa.c line 45

Quoted 1 line
arch/arm64/kvm/hyp/nvhe/ffa.c +1 -0
+#define FFA_NOTIF_SENDER_ENDP_MASK	GENMASK(31, 16)

Could we move the MASK definitions form arm_ffa to include/linux/arm_ffa.h?

I wanted to keep it here since it is not used anywhere else other than this file.

Quoted 31 lines
Quoted 31 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +16 -1
+
 /*
  * A buffer to hold the maximum descriptor size we can see from the host,
  * which is required when the SPMD returns a fragmented FFA_MEM_RETRIEVE_RESP
@@ -688,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_BIND:
 	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
 	case FFA_NOTIFICATION_GET:
@@ -912,6 +913,32 @@ static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_bind(struct arm_smccc_1_2_regs *res,
+			      struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, endp_id, ctxt, 1);
+	DECLARE_REG(u32, flags, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 5)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (FIELD_GET(FFA_NOTIF_SENDER_ENDP_MASK, endp_id) != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
Quoted 9 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res, · line 936

Quoted 6 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +6 -0
+	}
+
+	if (flags & GENMASK(31, 1)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
	if (flags > 1) ?

sure, I can replace it with this.

Quoted 7 lines

arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_notif_bitmap_destroy(struct arm_smccc_1_2_regs *res, · line 939

Quoted 3 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +3 -0
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);

And of course just like all the other functions, it should use the hyp_ prefix.

Added this.

Quoted 14 lines
Quoted 14 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +5 -0
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -976,6 +1003,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BITMAP_DESTROY:
 		do_ffa_notif_bitmap_destroy(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_BIND:
+		do_ffa_notif_bind(&res, host_ctxt);
+		goto out_handled;
 	}
 
Quoted 4 lines
Quoted 4 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +0 -0
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog

Thanks,
Sebastian

#11 lore raw

PATCH v2 4/7 KVM: arm64: Support FFA_NOTIFICATION_UNBIND in host handler

In reply to Sebastian Ene

Verify the arguments of the FF-A notification unbind call and forward the message to Trustzone.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +24 -1
index eedb01955a45..ca285e89516e 100644
@@ -690,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_UNBIND:
 	case FFA_NOTIFICATION_SET:
 	case FFA_NOTIFICATION_GET:
 	case FFA_NOTIFICATION_INFO_GET:
@@ -939,6 +938,27 @@ static void do_ffa_notif_bind(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_unbind(struct arm_smccc_1_2_regs *res,
+				struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, endp_id, ctxt, 1);
+	DECLARE_REG(u32, reserved, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 5) || reserved) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (FIELD_GET(FFA_NOTIF_SENDER_ENDP_MASK, endp_id) != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -1006,6 +1026,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_BIND:
 		do_ffa_notif_bind(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_UNBIND:
+		do_ffa_notif_unbind(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#12 lore raw

PATCH v2 5/7 KVM: arm64: Support FFA_NOTIFICATION_SET in host handler

In reply to Sebastian Ene

Allow FF-A notification SET messages to be proxied from the pKVM hypervisor to Trustzone and enforce MBZ/SBZ fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +29 -1
index ca285e89516e..3270381679b4 100644
@@ -690,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_SET:
 	case FFA_NOTIFICATION_GET:
 	case FFA_NOTIFICATION_INFO_GET:
 	/* Optional interfaces added in FF-A 1.2 */
@@ -959,6 +958,32 @@ static void do_ffa_notif_unbind(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_set(struct arm_smccc_1_2_regs *res,
+			     struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, endp_id, ctxt, 1);
+	DECLARE_REG(u32, flags, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (FIELD_GET(FFA_NOTIF_SENDER_ENDP_MASK, endp_id) != HOST_FFA_ID) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (ffa_check_unused_args_sbz(ctxt, 5)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (flags & GENMASK(15, 2)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -1029,6 +1054,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_UNBIND:
 		do_ffa_notif_unbind(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_SET:
+		do_ffa_notif_set(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#13 lore raw

PATCH v2 6/7 KVM: arm64: Support FFA_NOTIFICATION_GET in host handler

In reply to Sebastian Ene

Allow FF-A notification GET messages to be proxied from the pKVM hypervisor to Trustzone and enforce MBZ/SBZ fields.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +23 -1
index 3270381679b4..28b6cb0e14c4 100644
@@ -690,7 +690,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
        /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_GET:
 	case FFA_NOTIFICATION_INFO_GET:
 	/* Optional interfaces added in FF-A 1.2 */
 	case FFA_MSG_SEND_DIRECT_REQ2:		/* Optional per 7.5.1 */
@@ -984,6 +983,26 @@ static void do_ffa_notif_set(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_get(struct arm_smccc_1_2_regs *res,
+			     struct kvm_cpu_context *ctxt)
+{
+	DECLARE_REG(u32, flags, ctxt, 2);
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 3)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	if (flags & GENMASK(31, 4)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -1057,6 +1076,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_SET:
 		do_ffa_notif_set(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_GET:
+		do_ffa_notif_get(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#14 lore raw

PATCH v2 7/7 KVM: arm64: Support FFA_NOTIFICATION_INFO_GET in host handler

In reply to Sebastian Ene

Allow the host to query the FF-A notifiction status and proxy the info get message to Trustzone. Make sure that the SBZ fields are enforced.

---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +17 -2
index 28b6cb0e14c4..463a845557f9 100644
@@ -689,8 +689,6 @@ static bool ffa_call_supported(u64 func_id)
 	case FFA_RXTX_MAP:
 	case FFA_MEM_DONATE:
 	case FFA_MEM_RETRIEVE_REQ:
-       /* Optional notification interfaces added in FF-A 1.1 */
-	case FFA_NOTIFICATION_INFO_GET:
 	/* Optional interfaces added in FF-A 1.2 */
 	case FFA_MSG_SEND_DIRECT_REQ2:		/* Optional per 7.5.1 */
 	case FFA_MSG_SEND_DIRECT_RESP2:		/* Optional per 7.5.1 */
@@ -1003,6 +1001,20 @@ static void do_ffa_notif_get(struct arm_smccc_1_2_regs *res,
 	arm_smccc_1_2_smc(args, res);
 }
 
+static void do_ffa_notif_info_get(struct arm_smccc_1_2_regs *res,
+				  struct kvm_cpu_context *ctxt)
+{
+	struct arm_smccc_1_2_regs *args;
+
+	if (ffa_check_unused_args_sbz(ctxt, 1)) {
+		ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
+		return;
+	}
+
+	args = (void *)&ctxt->regs.regs[0];
+	arm_smccc_1_2_smc(args, res);
+}
+
 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 {
 	struct arm_smccc_1_2_regs res;
@@ -1079,6 +1091,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
 	case FFA_NOTIFICATION_GET:
 		do_ffa_notif_get(&res, host_ctxt);
 		goto out_handled;
+	case FFA_NOTIFICATION_INFO_GET:
+		do_ffa_notif_info_get(&res, host_ctxt);
+		goto out_handled;
 	}
 
 	if (ffa_call_supported(func_id))
Signature · 1 line
2.54.0.1064.gd145956f57-goog
#15 lore raw
In reply to Sebastian Ene
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 25 lines

---
Changes in v2:
- enforce the MBZ/SBZ fields
- split the calls into separate patches
- rebase on 7.1-rc7

Link to v1:
https://lore.kernel.org/all/[email protected]/

Sebastian Ene (7):
KVM: arm64: Support FFA_NOTIFICATION_BITMAP_CREATE in host handler
KVM: arm64: Support FFA_NOTIFICATION_BITMAP_DESTROY in host handler
KVM: arm64: Support FFA_NOTIFICATION_BIND in host handler
KVM: arm64: Support FFA_NOTIFICATION_UNBIND in host handler
KVM: arm64: Support FFA_NOTIFICATION_SET in host handler
KVM: arm64: Support FFA_NOTIFICATION_GET in host handler
KVM: arm64: Support FFA_NOTIFICATION_INFO_GET in host handler

 arch/arm64/kvm/hyp/nvhe/ffa.c | 190 ++++++++++++++++++++++++++++++++--
 1 file changed, 182 insertions(+), 8 deletions(-)
Signature · 1 line
2.54.0.1064.gd145956f57-goog
maintainer
#16 lore raw
Quoted 21 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 8 lines
Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

Will

#17 lore raw
Quoted 27 lines · Will Deacon
Quoted 26 lines · Vincent Donnefort
Quoted 24 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

Quoted 7 lines
Quoted 3 lines

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

* Do we really want to also look into the !SBZ arguments to verify what we can? (I'm thinking about the checks on flags)

Quoted 2 lines

Will

maintainer
#18 lore raw
Quoted 32 lines · Vincent Donnefort
Quoted 31 lines · Will Deacon
Quoted 29 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 5 lines
Quoted 3 lines

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

Maybe? I don't think they'd _have_ to bump the version number.

Quoted 3 lines

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

yes, that's what the diff was doing in the reply here:

https://lore.kernel.org/all/[email protected]/

but, as I said here:

https://lore.kernel.org/all/ahmxiFXXTupafbXw@willie-the-truck/

I don't particularly like the table-driven indirection (the checks should just be inlined).

Quoted 2 lines

* Do we really want to also look into the !SBZ arguments to verify what we can? (I'm thinking about the checks on flags)

For known arguments, we only need to verify things that can affect EL2. I suspect we don't care about a bunch of it.

Will

#19 lore raw
Quoted 47 lines · Will Deacon
Quoted 32 lines · Vincent Donnefort
Quoted 31 lines · Will Deacon
Quoted 29 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 5 lines
Quoted 3 lines

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

Maybe? I don't think they'd _have_ to bump the version number.

Quoted 3 lines

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

yes, that's what the diff was doing in the reply here:

Quoted 8 lines

https://lore.kernel.org/all/[email protected]/

but, as I said here:

https://lore.kernel.org/all/ahmxiFXXTupafbXw@willie-the-truck/

I don't particularly like the table-driven indirection (the checks should just be inlined).

Ha, sorry I'm late to the party.

Perhaps this series should start with adding ffa_check_unused_args_sbz() to the existing allowed FF-A invocations?

Quoted 8 lines
Quoted 3 lines

* Do we really want to also look into the !SBZ arguments to verify what we can? (I'm thinking about the checks on flags)

For known arguments, we only need to verify things that can affect EL2. I suspect we don't care about a bunch of it.

Will

maintainer
#20 lore raw
Quoted 54 lines · Vincent Donnefort
Quoted 53 lines · Will Deacon
Quoted 32 lines · Vincent Donnefort
Quoted 31 lines · Will Deacon
Quoted 29 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 5 lines
Quoted 3 lines

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

Maybe? I don't think they'd _have_ to bump the version number.

Quoted 3 lines

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

yes, that's what the diff was doing in the reply here:

https://lore.kernel.org/all/[email protected]/

but, as I said here:

https://lore.kernel.org/all/ahmxiFXXTupafbXw@willie-the-truck/

Quoted 7 lines
Quoted 2 lines

I don't particularly like the table-driven indirection (the checks should just be inlined).

Ha, sorry I'm late to the party.

Perhaps this series should start with adding ffa_check_unused_args_sbz() to the existing allowed FF-A invocations?

Yes, that part now seems to be missing.

Seb, please can you respin with that included?

Will

#21 lore raw
Quoted 55 lines · Will Deacon
Quoted 54 lines · Vincent Donnefort
Quoted 53 lines · Will Deacon
Quoted 32 lines · Vincent Donnefort
Quoted 31 lines · Will Deacon
Quoted 29 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 5 lines
Quoted 3 lines

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

Maybe? I don't think they'd _have_ to bump the version number.

Quoted 3 lines

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

yes, that's what the diff was doing in the reply here:

https://lore.kernel.org/all/[email protected]/

but, as I said here:

https://lore.kernel.org/all/ahmxiFXXTupafbXw@willie-the-truck/

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

I don't particularly like the table-driven indirection (the checks should just be inlined).

Ha, sorry I'm late to the party.

Perhaps this series should start with adding ffa_check_unused_args_sbz() to the existing allowed FF-A invocations?

Hi Will,

Quoted 2 lines

Yes, that part now seems to be missing.

I am a bit worried to apply for all of them the check from the relayer (ffa_check_unused_args_sbz) because of how it's written in the spec in (11.2 Reserved parameter convention). To be more specific, there is no mention of what the relayer is expected to do here (which is what hyp does). It says 2 things:
1. the caller (in this case the host driver) is expected to zero out unused args
2. the callee (Trustzone) ignores the values in these registers.

If we enforce SBZ in the relayer but (1) doesn't comply with it, we will introduce a regression. I left it on purpose without enforcing ffa_check_unused_args_sbz for the others.

Quoted 4 lines

Seb, please can you respin with that included?

Will

Thanks,
Sebastian

maintainer
#22 lore raw
Quoted 12 lines · Sebastian Ene
Quoted 1 line · Will Deacon

Yes, that part now seems to be missing.

I am a bit worried to apply for all of them the check from the relayer (ffa_check_unused_args_sbz) because of how it's written in the spec in (11.2 Reserved parameter convention). To be more specific, there is no mention of what the relayer is expected to do here (which is what hyp does). It says 2 things:
1. the caller (in this case the host driver) is expected to zero out unused args
2. the callee (Trustzone) ignores the values in these registers.

Quoted 3 lines

If we enforce SBZ in the relayer but (1) doesn't comply with it, we will introduce a regression. I left it on purpose without enforcing ffa_check_unused_args_sbz for the others.

I think that's ok -- if the caller isn't passing zeroes when it should, then it's already on borrowed (no pun intended!) time and it will need to be fixed.

Will

#23 lore raw
Quoted 13 lines · Will Deacon
Quoted 12 lines · Sebastian Ene
Quoted 1 line · Will Deacon

Yes, that part now seems to be missing.

I am a bit worried to apply for all of them the check from the relayer (ffa_check_unused_args_sbz) because of how it's written in the spec in (11.2 Reserved parameter convention). To be more specific, there is no mention of what the relayer is expected to do here (which is what hyp does). It says 2 things:
1. the caller (in this case the host driver) is expected to zero out unused args
2. the callee (Trustzone) ignores the values in these registers.

Quoted 7 lines
Quoted 3 lines

If we enforce SBZ in the relayer but (1) doesn't comply with it, we will introduce a regression. I left it on purpose without enforcing ffa_check_unused_args_sbz for the others.

I think that's ok -- if the caller isn't passing zeroes when it should, then it's already on borrowed (no pun intended!) time and it will need to be fixed.

Ok, thanks for the confirmation. Will include this and then spin a new version of the patches.

Quoted 2 lines

Will

Thanks,
Sebastian

#24 lore raw
In reply to Vincent Donnefort
Quoted 54 lines · Vincent Donnefort
Quoted 53 lines · Will Deacon
Quoted 32 lines · Vincent Donnefort
Quoted 31 lines · Will Deacon
Quoted 29 lines · Vincent Donnefort
Quoted 20 lines · Sebastian Ene

Remove the FFA_NOTIFICATION* calls from the blocklist used by the pKVM FF-A proxy. This restriction was preventing the use of asynchronous signaling mechanisms defined by the Arm FF-A specification to communicate with the secure services.
While these calls are markes as optional, there is no reason why the hypervisor proxy would block them because:

1. Host is the Sole Non-Secure Endpoint: The Host operates as the only Non-Secure VM ID (VM ID 0) recognized by the Secure World. Because all forwarded notifications are inherently attributed to the Host by the SPMC, there is no risk of VM ID spoofing originating from the Normal World.

2. No Memory Pointers or Addresses: The FFA_NOTIFICATION_* ABIs operate strictly via register-based parameters, passing only VM IDs, VCPU IDs, flags, and bitmaps. Because these calls do not contain memory addresses, offsets, or pointers, forwarding them doesn't pose a risk of memory-based confused deputy attack (e.g., tricking the SPMC into overwriting protected memory).

Quoted 4 lines

While the pKVM proxy behaves as a relayer, it doesn't currently have its own FF-A ID(only the host has the ID 0). The behavior of the setup flow is covered by the spec in the: '10.9 Notification support without a Hypervisor'.

As it is only a relayer. Is it really important to check SBZ arguments and fields on behalf of Trustzone? It doesn't feel it brings any security. If the host passes broken arguments, I don't believe this puts pKVM at risk. Does it?

Quoted 5 lines
Quoted 3 lines

I think the problem would be if an update to FF-A allocated some of the currently SBZ bits to implement some functionality that we would want to filter at EL2.

I suppose that would bump the FF-A version and the proxy would reject it?

Maybe? I don't think they'd _have_ to bump the version number.

Quoted 3 lines

If we really want to check for those arguments to be 0:

* Shouldn't we extend this check to other FF-A invocations?

yes, that's what the diff was doing in the reply here:

https://lore.kernel.org/all/[email protected]/

but, as I said here:

https://lore.kernel.org/all/ahmxiFXXTupafbXw@willie-the-truck/

Quoted 7 lines
Quoted 2 lines

I don't particularly like the table-driven indirection (the checks should just be inlined).

Ha, sorry I'm late to the party.

Perhaps this series should start with adding ffa_check_unused_args_sbz() to the existing allowed FF-A invocations?

Right, after talking to Will a bit more on this I will add ffa_check_unused_args_sbz() to the existing calls in the first part of the series.

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

* Do we really want to also look into the !SBZ arguments to verify what we can? (I'm thinking about the checks on flags)

For known arguments, we only need to verify things that can affect EL2. I suspect we don't care about a bunch of it.

Will

Thanks,
Sebastian