Hi Samarth,
There are 2 ways to map RXTX buffers which are both exercised by different cactus partitions. The first and second cactus partitions define the buffers in their manifest [1], whereas the third partition doesn't and then maps the buffer during it's initialisation, hence the if (ffa_id == (SPM_VM_ID_FIRST + 2)) condition [2]. This is why when you try map the buffers for SPM_VM_ID_FIRST it fails, these buffers have already been mapped when the partition manifest was parsed.
With regards to whether it is possible to map buffers from the secure world, it is, an SP can create a buffer pair with the SPMC. I believe the check you mentioned in spmd_main.c [3] is required to enforce rule 2 from the 6.2.2.2 Buffer Setup Section in the FF-A EAC0 spec [4]. 2) The Hypervisor allocates the buffer pair it shares with the SPM. It uses the FFA_RXTX_MAP ABI to map this buffer pair in the SPMC’s translation regime. Because of this FFA_RXTX_MAP_SMC64 should never be forwarded from the SPMC to SPMD.
I hope this helps, please let me know if you have any other questions. Kind Regards, Daniel
[1] https://review.trustedfirmware.org/plugins/gitiles/TF-A/tf-a-tests/+/refs/he... [2] https://review.trustedfirmware.org/plugins/gitiles/TF-A/tf-a-tests/+/refs/he... [3] https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+... [4] https://developer.arm.com/documentation/den0077/latest