@@ -719,6 +719,55 @@ static void do_ffa_version(struct arm_smccc_res *res,
719
719
hyp_spin_unlock (& version_lock );
720
720
}
721
721
722
+ static void do_ffa_part_get (struct arm_smccc_res * res ,
723
+ struct kvm_cpu_context * ctxt )
724
+ {
725
+ DECLARE_REG (u32 , uuid0 , ctxt , 1 );
726
+ DECLARE_REG (u32 , uuid1 , ctxt , 2 );
727
+ DECLARE_REG (u32 , uuid2 , ctxt , 3 );
728
+ DECLARE_REG (u32 , uuid3 , ctxt , 4 );
729
+ DECLARE_REG (u32 , flags , ctxt , 5 );
730
+ u32 count , partition_sz , copy_sz ;
731
+
732
+ hyp_spin_lock (& host_buffers .lock );
733
+ if (!host_buffers .rx ) {
734
+ ffa_to_smccc_res (res , FFA_RET_BUSY );
735
+ goto out_unlock ;
736
+ }
737
+
738
+ arm_smccc_1_1_smc (FFA_PARTITION_INFO_GET , uuid0 , uuid1 ,
739
+ uuid2 , uuid3 , flags , 0 , 0 ,
740
+ res );
741
+
742
+ if (res -> a0 != FFA_SUCCESS )
743
+ goto out_unlock ;
744
+
745
+ count = res -> a2 ;
746
+ if (!count )
747
+ goto out_unlock ;
748
+
749
+ if (hyp_ffa_version > FFA_VERSION_1_0 ) {
750
+ /* Get the number of partitions deployed in the system */
751
+ if (flags & 0x1 )
752
+ goto out_unlock ;
753
+
754
+ partition_sz = res -> a3 ;
755
+ } else {
756
+ /* FFA_VERSION_1_0 lacks the size in the response */
757
+ partition_sz = FFA_1_0_PARTITON_INFO_SZ ;
758
+ }
759
+
760
+ copy_sz = partition_sz * count ;
761
+ if (copy_sz > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE ) {
762
+ ffa_to_smccc_res (res , FFA_RET_ABORTED );
763
+ goto out_unlock ;
764
+ }
765
+
766
+ memcpy (host_buffers .rx , hyp_buffers .rx , copy_sz );
767
+ out_unlock :
768
+ hyp_spin_unlock (& host_buffers .lock );
769
+ }
770
+
722
771
bool kvm_host_ffa_handler (struct kvm_cpu_context * host_ctxt , u32 func_id )
723
772
{
724
773
struct arm_smccc_res res ;
@@ -773,6 +822,9 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id)
773
822
case FFA_VERSION :
774
823
do_ffa_version (& res , host_ctxt );
775
824
goto out_handled ;
825
+ case FFA_PARTITION_INFO_GET :
826
+ do_ffa_part_get (& res , host_ctxt );
827
+ goto out_handled ;
776
828
}
777
829
778
830
if (ffa_call_supported (func_id ))
0 commit comments