Skip to content

Commit 582234b

Browse files
korneldulebaMarc Zyngier
authored andcommitted
KVM: arm64: Fix error checking for FFA_VERSION
According to section 13.2 of the DEN0077 FF-A specification, when firmware does not support the requested version, it should reply with FFA_RET_NOT_SUPPORTED(-1). Table 13.6 specifies the type of the error code as int32. Currently, the error checking logic compares the unsigned long return value it got from the SMC layer, against a "-1" literal. This fails due to a type mismatch: the literal is extended to 64 bits, whereas the register contains only 32 bits of ones(0x00000000ffffffff). Consequently, hyp_ffa_init misinterprets the "-1" return value as an invalid FF-A version. This prevents pKVM initialization on devices where FF-A is not supported in firmware. Fix this by explicitly casting res.a0 to s32. Signed-off-by: Kornel Dulęba <korneld@google.com> Acked-by: Will Deacon <will@kernel.org> Link: https://patch.msgid.link/20251114-pkvm_init_noffa-v1-1-87a82e87c345@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 4b16ad0 commit 582234b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • arch/arm64/kvm/hyp/nvhe

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ static void do_ffa_version(struct arm_smccc_1_2_regs *res,
792792
.a0 = FFA_VERSION,
793793
.a1 = ffa_req_version,
794794
}, res);
795-
if (res->a0 == FFA_RET_NOT_SUPPORTED)
795+
if ((s32)res->a0 == FFA_RET_NOT_SUPPORTED)
796796
goto unlock;
797797

798798
hyp_ffa_version = ffa_req_version;
@@ -943,7 +943,7 @@ int hyp_ffa_init(void *pages)
943943
.a0 = FFA_VERSION,
944944
.a1 = FFA_VERSION_1_2,
945945
}, &res);
946-
if (res.a0 == FFA_RET_NOT_SUPPORTED)
946+
if ((s32)res.a0 == FFA_RET_NOT_SUPPORTED)
947947
return 0;
948948

949949
/*

0 commit comments

Comments
 (0)