KVM: arm64: Support FF-A 1.2 and SEND_DIRECT2 ABI
Subsystems (3)
v4 cover KVM: arm64: Support FF-A 1.2 and SEND_DIRECT2 ABI
Hi,
The FF-A 1.2 specification introduces a new SEND_DIRECT2 ABI which allows registers x4-x17 to be used for the message payload. This patch set prevents the host from using a lower FF-A version than what has already been negotiated with the hypervisor. This is necessary because the hypervisor does not have the necessary compatibility paths to translate from the hypervisor FF-A version to a previous version.
Support for FF-A 1.2 in the hypervisor is added as a precursor to the addition of the FFA_MSG_SEND_DIRECT_REQ2 messaging interface. The bulk of this change has to do with the upgrade to SMCCC 1.2 required by FF-A 1.2. Additionally, unimplemented FF-A 1.2 interfaces are added to the list of unsupported functions.
Tested by booting Android under QEMU and loading Trusty as the guest VM and observing the SEND_DIRECT2 ABI being used successfully during guest boot.
Changes since v3:
- all: Remove Signed-off-by: Per Larsen <[email protected]> - 2/5: Split out from 2/3, zero x4-x7 in set_ffa_retval - 3/5: Split out from 2/3, Mark FFA_NOTIFICATION_* calls as
unsupported
- 2/3 -> 4/5: Drop ffa_get_hypervisor_version, access hyp_ffa_version directly when version negotiation is complete.
- 3/3 -> 5/5: Call ffa_to_smccc_1_2_error directly in
do_do_ffa_direct_msg2
Push call to ffa_call_needs_smccc_1_2 lower down by adding ffa_get_func_id and ffa_set_retval_smccc_1_x.
Drop ffa_to_smccc_1_2_regs and ffa_to_smccc_1_2_regs_prop
as they are no longer used.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes since v2:
- 2/3: Removed files added by mistake.
Add and use ffa_get_hypervisor_version to access hyp_ffa_version
- 3/3: Use ffa_get_hypervisor_version to access hyp_ffa_version safely
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes since v1:
- 1/3: Simplify commit message; drop long comment in do_ffa_version
- 2/3: Correct use of Co-developed-by: footer s/arm_smccc_1_2_smc_fallback/arm_smccc_1_x_smc/ Always access hyp_ffa_version w/lock held
Remove superfluous comments in ffa_call_supported Add and use FFA_FEAT_RXTX_MIN_SZ_MASK instead of constant Add FFA_PARTITION_INFO_GET_REGS to calls that require SMCCC 1.2
- 3/3: Always access hyp_ffa_version w/lock held
Correct formatting
Thanks,
Per Larsen
--
2.49.0
---
To: Marc Zyngier <[email protected]>
To: Oliver Upton <[email protected]>
To: Joey Gouly <[email protected]>
To: Suzuki K Poulose <[email protected]>
To: Zenghui Yu <[email protected]>
To: Catalin Marinas <[email protected]>
To: Will Deacon <[email protected]>
To: Sudeep Holla <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
---
Per Larsen (5):
KVM: arm64: Restrict FF-A host version renegotiation
KVM: arm64: Zero x4-x7 in ffa_set_retval
KVM: arm64: Mark FFA_NOTIFICATION_* calls as unsupported
KVM: arm64: Bump the supported version of FF-A to 1.2
KVM: arm64: Support FFA_MSG_SEND_DIRECT_REQ2 in host handler
arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/ffa.c | 186 +++++++++++++++++++++++++++++++++++++-- include/linux/arm_ffa.h | 3 + 3 files changed, 182 insertions(+), 8 deletions(-)
---
base-commit: fee3e843b309444f48157e2188efa6818bae85cf
change-id: 20250506-virtio-msg-ffa-22af72c92150
Best regards,
Signature · 1 line
Per Larsen <[email protected]>
PATCH v4 1/5 KVM: arm64: Restrict FF-A host version renegotiation
Prevent the host from re-negotiating a lesser minor version with the hypervisor. Once the hypervisor negotiates a version, that should remain locked in. Fix the current behaviour by returning NOT_SUPPORTED to avoid the FF-A interoperability rules with lesser minor versions that allow the host version to downgrade.
--- arch/arm64/kvm/hyp/nvhe/ffa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +4 -1
@@ -712,7 +712,10 @@ static void do_ffa_version(struct arm_smccc_res *res,hyp_spin_lock (&version_lock);if (has_version_negotiated) { - res->a0 = hyp_ffa_version; +if (FFA_MINOR_VERSION (ffa_req_version) <FFA_MINOR_VERSION (hyp_ffa_version)) + res->a0 =FFA_RET_NOT_SUPPORTED ; +else + res->a0 = hyp_ffa_version; goto unlock; }
Signature · 1 line
2.49.0.1101.gccaa498523-goog
PATCH v4 2/5 KVM: arm64: Zero x4-x7 in ffa_set_retval
In reply to Per LarsenFF-A 1.0 references SMCCC 1.2 (reference [4] on page xi). The results of an SMC32/HVC32 are returned in W1-W7 in SMCCC 1.2. However, W4-W7 must be preserved unless they contain results according to the function definition.
ffa_set_retval is commonly used to report FFA_SUCCESS or FFA_ERROR back to the caller. FFA_SUCCESS requires that x2-x7 must be zero (MBZ) unless a register is explicitly used in the function response. FFA_ERROR requires x3-x7 MBZ.
ffa_set_retval is also used to return results of:
- FFA_VERSION which requires x1-x7 MBZ
- FFA_MEM_FRAG_TX which returns FFA_MEM_FRAG_RX or FFA_ERROR. FFA_MEM_FRAG_RAX always requires that x5-x7 MBZ and x4 MBZ at any virtual FF-A instance (applies to kvm).
Messaging interfaces such as FFA_MSG_SEND_DIRECT_{REQ,REQ2}, will not use ffa_set_retval.
Given the above, it is safe to zero x4-x7 in ffa_set_retval.
--- arch/arm64/kvm/hyp/nvhe/ffa.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/kvm/hyp/nvhe/ffa.c +4 -0
@@ -101,6 +101,10 @@ static void ffa_set_retval(struct kvm_cpu_context *ctxt,cpu_reg (ctxt,1 ) = res->a1;cpu_reg (ctxt,2 ) = res->a2;cpu_reg (ctxt,3 ) = res->a3; +cpu_reg (ctxt,4 ) =0 ; +cpu_reg (ctxt,5 ) =0 ; +cpu_reg (ctxt,6 ) =0 ; +cpu_reg (ctxt,7 ) =0 ; }static bool is_ffa_call (u64 func_id)
Signature · 1 line
2.49.0.1101.gccaa498523-goog
PATCH v4 3/5 KVM: arm64: Mark FFA_NOTIFICATION_* calls as unsupported
In reply to Per LarsenPrevent FFA_NOTIFICATION_* interfaces from being passed through to TZ.
--- arch/arm64/kvm/hyp/nvhe/ffa.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/kvm/hyp/nvhe/ffa.c +8 -0
@@ -632,6 +632,14 @@ 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_BITMAP_CREATE : +case FFA_NOTIFICATION_BITMAP_DESTROY : +case FFA_NOTIFICATION_BIND : +case FFA_NOTIFICATION_UNBIND : +case FFA_NOTIFICATION_SET : +case FFA_NOTIFICATION_GET : +case FFA_NOTIFICATION_INFO_GET :return false; }
Signature · 1 line
2.49.0.1101.gccaa498523-goog
PATCH v4 4/5 KVM: arm64: Bump the supported version of FF-A to 1.2
In reply to Per LarsenFF-A version 1.2 introduces the DIRECT_REQ2 ABI. Bump the FF-A version preferred by the hypervisor as a precursor to implementing the 1.2-only FFA_MSG_SEND_DIRECT_REQ2 and FFA_MSG_SEND_RESP2 messaging interfaces.
We must also use SMCCC 1.2 for 64-bit SMCs if hypervisor negotiated FF-A 1.2, so ffa_set_retval is updated and a new function to call 64-bit smcs using SMCCC 1.2 with fallback to SMCCC 1.1 is introduced.
Update ffa_call_supported to mark FF-A 1.2 interfaces as unsupported lest they get forwarded.
--- arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/ffa.c | 61 ++++++++++++++++++++++++++++++++++++---- include/linux/arm_ffa.h | 1 + 3 files changed, 57 insertions(+), 6 deletions(-)
arch/arm64/kvm/hyp/nvhe/Makefile +1 -0
@@ -27,6 +27,7 @@ hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../fpsimd.o ../hyp-entry.o ../exception.o ../pgtable.o +hyp-obj-y += ../../../kernel/smccc-call.o hyp-obj-$(CONFIG_LIST_HARDENED) += list_debug.o hyp-obj-y += $(lib-objs)
arch/arm64/kvm/hyp/nvhe/ffa.c +55 -6
105 lines not on this page · raw message
include/linux/arm_ffa.h +1 -0
@@ -128,6 +128,7 @@#define FFA_FEAT_RXTX_MIN_SZ_4K 0#define FFA_FEAT_RXTX_MIN_SZ_64K 1#define FFA_FEAT_RXTX_MIN_SZ_16K 2 +#define FFA_FEAT_RXTX_MIN_SZ_MASK 3/* FFA Bus/Device/Driver related */ struct ffa_device {
Signature · 1 line
2.49.0.1101.gccaa498523-goog
PATCH v4 5/5 KVM: arm64: Support FFA_MSG_SEND_DIRECT_REQ2 in host handler
In reply to Per LarsenFF-A 1.2 adds the DIRECT_REQ2 messaging interface which is similar to the existing FFA_MSG_SEND_DIRECT_{REQ,RESP} functions except that it uses the SMC calling convention v1.2 which allows calls to use x4-x17 as argument and return registers. Add support for FFA_MSG_SEND_DIRECT_REQ2 in the host ffa handler.
--- arch/arm64/kvm/hyp/nvhe/ffa.c | 110 +++++++++++++++++++++++++++++++++++++++++- include/linux/arm_ffa.h | 2 + 2 files changed, 110 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/ffa.c +108 -2
@@ -79,6 +79,14 @@ static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) }; } +static void ffa_to_smccc_1_2_error (struct arm_smccc_1_2_regs *regs,u64 ffa_errno) +{ + *regs = (struct arm_smccc_1_2_regs ) { + .a0 =FFA_ERROR , + .a2 = ffa_errno, + }; +} +static void ffa_to_smccc_res_prop (struct arm_smccc_res *res,int ret,u64 prop) {if (ret ==FFA_RET_SUCCESS ) {
@@ -94,6 +102,12 @@ static void ffa_to_smccc_res(struct arm_smccc_res *res, int ret)ffa_to_smccc_res_prop (res, ret,0 ); } +static u32 ffa_get_func_id (struct kvm_cpu_context *ctxt) +{ +DECLARE_REG (u32, func_id, ctxt,0 ); +return func_id; +} +static void ffa_set_retval (struct kvm_cpu_context *ctxt,struct arm_smccc_res *res) {
@@ -128,6 +142,54 @@ static void ffa_set_retval(struct kvm_cpu_context *ctxt, } } +static void ffa_set_retval_smccc_1_2 (struct kvm_cpu_context *ctxt, +struct arm_smccc_1_2_regs *regs) +{ +cpu_reg (ctxt,0 ) = regs->a0; +cpu_reg (ctxt,1 ) = regs->a1; +cpu_reg (ctxt,2 ) = regs->a2; +cpu_reg (ctxt,3 ) = regs->a3; +cpu_reg (ctxt,4 ) = regs->a4; +cpu_reg (ctxt,5 ) = regs->a5; +cpu_reg (ctxt,6 ) = regs->a6; +cpu_reg (ctxt,7 ) = regs->a7; +cpu_reg (ctxt,8 ) = regs->a8; +cpu_reg (ctxt,9 ) = regs->a9; +cpu_reg (ctxt,10 ) = regs->a10; +cpu_reg (ctxt,11 ) = regs->a11; +cpu_reg (ctxt,12 ) = regs->a12; +cpu_reg (ctxt,13 ) = regs->a13; +cpu_reg (ctxt,14 ) = regs->a14; +cpu_reg (ctxt,15 ) = regs->a15; +cpu_reg (ctxt,16 ) = regs->a16; +cpu_reg (ctxt,17 ) = regs->a17; +} + +/* +* Must a given FFA function use the SMC calling convention v1.2? +*/ +static bool ffa_call_needs_smccc_1_2 (u64 func_id) +{ +switch (func_id) { +case FFA_MSG_SEND_DIRECT_REQ2 : +case FFA_MSG_SEND_DIRECT_RESP2 : +case FFA_PARTITION_INFO_GET_REGS : +return true; + } + +return false; +} + +static void ffa_set_retval_smccc_1_x (struct kvm_cpu_context *ctxt, +struct arm_smccc_res *res, +struct arm_smccc_1_2_regs *regs) +{ +if (ffa_call_needs_smccc_1_2 (ffa_get_func_id (ctxt))) +ffa_set_retval_smccc_1_2 (ctxt, regs); +else +ffa_set_retval (ctxt, res); +} +/* Call SMC64 using SMCCC 1.2 if hyp negotiated FF-A 1.2 falling back to 1.1 */ static void arm_smccc_1_x_smc(u64 func_id, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6, u64 a7,
@@ -683,7 +745,6 @@ static bool ffa_call_supported(u64 func_id)case FFA_NOTIFICATION_GET :case FFA_NOTIFICATION_INFO_GET :/* Unimplemented interfaces added in FF-A 1.2 */ -case FFA_MSG_SEND_DIRECT_REQ2 :case FFA_MSG_SEND_DIRECT_RESP2 :case FFA_CONSOLE_LOG :case FFA_PARTITION_INFO_GET_REGS :
@@ -852,9 +913,47 @@ static void do_ffa_part_get(struct arm_smccc_res *res,hyp_spin_unlock (&host_buffers.lock); } +static void do_ffa_direct_msg2 (struct arm_smccc_1_2_regs *regs, +struct kvm_cpu_context *ctxt, +u64 vm_handle) +{ +DECLARE_REG (u32, func_id, ctxt,0 ); +DECLARE_REG (u32, endp, ctxt,1 ); +DECLARE_REG (u64, uuid_lo, ctxt,2 ); +DECLARE_REG (u64, uuid_hi, ctxt,3 ); +DECLARE_REG (u64, x4, ctxt,4 ); +DECLARE_REG (u64, x5, ctxt,5 ); +DECLARE_REG (u64, x6, ctxt,6 ); +DECLARE_REG (u64, x7, ctxt,7 ); +DECLARE_REG (u64, x8, ctxt,8 ); +DECLARE_REG (u64, x9, ctxt,9 ); +DECLARE_REG (u64, x10, ctxt,10 ); +DECLARE_REG (u64, x11, ctxt,11 ); +DECLARE_REG (u64, x12, ctxt,12 ); +DECLARE_REG (u64, x13, ctxt,13 ); +DECLARE_REG (u64, x14, ctxt,14 ); +DECLARE_REG (u64, x15, ctxt,15 ); +DECLARE_REG (u64, x16, ctxt,16 ); +DECLARE_REG (u64, x17, ctxt,17 ); + +if (FIELD_GET (FFA_SRC_ENDPOINT_MASK , endp) != vm_handle) { +ffa_to_smccc_1_2_error (regs,FFA_RET_INVALID_PARAMETERS ); +return ; + } + +struct arm_smccc_1_2_regs args = { + func_id, endp, uuid_lo, uuid_hi, + x4, x5, x6, x7, x8, x9, x10, + x11, x12, x13, x14, x15, x16, x17 + }; + +arm_smccc_1_2_smc (&args, regs); +} +bool kvm_host_ffa_handler (struct kvm_cpu_context *host_ctxt,u32 func_id) {struct arm_smccc_res res; +struct arm_smccc_1_2_regs regs;/* * There's no way we can tell what a non-standard SMC call might
@@ -910,14 +1009,21 @@ 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_MSG_SEND_DIRECT_REQ2 : +if (hyp_ffa_version >=FFA_VERSION_1_2 ) { +do_ffa_direct_msg2 (®s, host_ctxt,HOST_FFA_ID ); + goto out_handled; + } + goto out_not_supported; }if (ffa_call_supported (func_id))return false;/* Pass through */ +out_not_supported:ffa_to_smccc_error (&res,FFA_RET_NOT_SUPPORTED ); out_handled: -ffa_set_retval (host_ctxt, &res); +ffa_set_retval_smccc_1_x (host_ctxt, &res, ®s);return true; }
include/linux/arm_ffa.h +2 -0
@@ -269,6 +269,8 @@ bool ffa_partition_check_property(struct ffa_device *dev, u32 property) (ffa_partition_check_property (dev,FFA_PARTITION_DIRECT_REQ2_RECV ) && \ !dev->mode_32bit) +#define FFA_SRC_ENDPOINT_MASK GENMASK(31, 16) +/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ struct ffa_send_direct_data {unsigned long data0;/* w3/x3 */
Signature · 1 line
2.49.0.1101.gccaa498523-goog
Re: [PATCH v4 1/5] KVM: arm64: Restrict FF-A host version renegotiation
In reply to Per LarsenQuoted 18 lines · On Fri, May 16, 2025 at 12:14:00PM +0000, Per Larsen via B4 Relay wrote:
From: Per Larsen <[email protected]>
Prevent the host from re-negotiating a lesser minor version with the hypervisor. Once the hypervisor negotiates a version, that should remain locked in. Fix the current behaviour by returning
NOT_SUPPORTEDto avoid the FF-A interoperability rules with lesser minor versions that allow the host version to downgrade.Signed-off-by Per Larsen <[email protected]>--- arch/arm64/kvm/hyp/nvhe/ffa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/arm64/kvm/hyp/nvhe/ffa.c +0
-0
arch/arm64/kvm/hyp/nvhe/ffa.c static void do_ffa_version(struct arm_smccc_res *res, · line 720
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +4
-1@@ -712,7 +712,10 @@ static void do_ffa_version(struct arm_smccc_res *res,hyp_spin_lock (&version_lock);if (has_version_negotiated) { - res->a0 = hyp_ffa_version; +if (FFA_MINOR_VERSION (ffa_req_version) <FFA_MINOR_VERSION (hyp_ffa_version)) + res->a0 =FFA_RET_NOT_SUPPORTED ; +else + res->a0 = hyp_ffa_version; goto unlock; }
I already Acked this one:
https://lore.kernel.org/all/20250513142113.GA9443@willie-the-truck/
So please add the tag to the patch if/when you post a new version of the series without any changes to this patch.
For the bots:
Will
Re: [PATCH v4 3/5] KVM: arm64: Mark FFA_NOTIFICATION_* calls as unsupported
In reply to Per LarsenQuoted 16 lines · On Fri, May 16, 2025 at 12:14:02PM +0000, Per Larsen via B4 Relay wrote:
From: Per Larsen <[email protected]>
Prevent FFA_NOTIFICATION_* interfaces from being passed through to TZ.
Signed-off-by Per Larsen <[email protected]>--- arch/arm64/kvm/hyp/nvhe/ffa.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/arm64/kvm/hyp/nvhe/ffa.c +0
-0@@ -632,6 +632,14 @@ static bool ffa_call_supported(u64 func_id)case FFA_RXTX_MAP :case FFA_MEM_DONATE :
arch/arm64/kvm/hyp/nvhe/ffa.c static bool ffa_call_supported(u64 func_id) · line 643
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +8
-0case 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 : +case FFA_NOTIFICATION_SET : +case FFA_NOTIFICATION_GET : +case FFA_NOTIFICATION_INFO_GET :return false;
That said, I wonder if we should revisit this denylist along the lines of the discussion with Oliver on the initial FF-A proxy series:
https://lore.kernel.org/kvmarm/[email protected]/
We check for is_ffa_call() already, so we could invert the above to be an allow-list for calls within the FF-A range rather than a deny-list.
What do you think?
Will
Will Deacon
maintainerRe: [PATCH v4 2/5] KVM: arm64: Zero x4-x7 in ffa_set_retval
In reply to Per LarsenQuoted 32 lines · On Fri, May 16, 2025 at 12:14:01PM +0000, Per Larsen via B4 Relay wrote:
From: Per Larsen <[email protected]>
FF-A 1.0 references SMCCC 1.2 (reference [4] on page xi). The results of an SMC32/HVC32 are returned in W1-W7 in SMCCC 1.2. However, W4-W7 must be preserved unless they contain results according to the function definition.
ffa_set_retvalis commonly used to reportFFA_SUCCESSorFFA_ERRORback to the caller.FFA_SUCCESSrequires that x2-x7 must be zero (MBZ) unless a register is explicitly used in the function response.FFA_ERRORrequires x3-x7 MBZ.
ffa_set_retvalis also used to return results of:
-FFA_VERSIONwhich requires x1-x7 MBZ
-FFA_MEM_FRAG_TXwhich returnsFFA_MEM_FRAG_RXorFFA_ERROR.FFA_MEM_FRAG_RAXalways requires that x5-x7 MBZ and x4 MBZ at any virtual FF-A instance (applies to kvm).Messaging interfaces such as FFA_MSG_SEND_DIRECT_{REQ,REQ2}, will not use
ffa_set_retval.Given the above, it is safe to zero x4-x7 in
ffa_set_retval.Signed-off-by Per Larsen <[email protected]>--- arch/arm64/kvm/hyp/nvhe/ffa.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/kvm/hyp/nvhe/ffa.c +0
-0
arch/arm64/kvm/hyp/nvhe/ffa.c static void ffa_set_retval(struct kvm_cpu_context *ctxt, · line 108
Quoted 8 lines
arch/arm64/kvm/hyp/nvhe/ffa.c +4
-0@@ -101,6 +101,10 @@ static void ffa_set_retval(struct kvm_cpu_context *ctxt,cpu_reg (ctxt,1 ) = res->a1;cpu_reg (ctxt,2 ) = res->a2;cpu_reg (ctxt,3 ) = res->a3; +cpu_reg (ctxt,4 ) =0 ; +cpu_reg (ctxt,5 ) =0 ; +cpu_reg (ctxt,6 ) =0 ; +cpu_reg (ctxt,7 ) =0 ; }
Hmm. On reflection, isn't the root of the problem actually that we're using SMCCC 1.1 to communicate with TZ, whereas FF-A requires SMCCC 1.2 (and we even enforce that in hyp_ffa_init())?
If we moved all of the hyp FF-A code over to SMCCC 1.2 unconditionally, then we could just assign everything from res back to the CPU context without having to worry about zeroing. That would also simplify your later patches because we wouldn't have to deal with SMCCC 1.1 at all.
I'm aware that we're carrying a patch in Android to permit SMCCC 1.1, but that's only for Pixel 6 iirc and we shouldn't worry about that upstream.
Will