Hi OP-TEE maintainers,
I found an issue in optee_os related to FFA memory handling across different kernel page sizes.
File: core/arch/arm/mm/mobj_ffa.c Function: mobj_ffa_get_by_cookie()
At the beginning of this function there is a check:
if (internal_offs >= SMALL_PAGE_SIZE) return NULL;
Here, SMALL_PAGE_SIZE is fixed to 4KB. When running with a Linux kernel built with 16K or 64K page sizes (CONFIG_ARM64_16K_PAGES or CONFIG_ARM64_64K_PAGES), this check incorrectly rejects valid offsets. As a result, mobj_ffa_get_by_cookie() returns NULL, which leads to TEE_ERROR_BAD_PARAMETERS during FFA communication (for example when set_fmem_param() calls it).
Impact: - FFA communication fails on systems where the kernel uses 16K or 64K pages. - With 16K becoming more widely adopted (e.g. Google’s standardization), this problem will be more common.
Expected behavior: The function should not assume a fixed 4K page size, but adapt to the actual kernel page size.
Environment: - OP-TEE version: observed in multiple versions including latest master - Platform: ARM64 with FFA enabled - Kernel config: CONFIG_ARM64_16K_PAGES / CONFIG_ARM64_64K_PAGES
Possible fix: - Replace the SMALL_PAGE_SIZE check with a dynamic check based on the kernel’s actual page size, or make the validation configurable.
Please let me know if you need more details. I am happy to test or provide a patch suggestion if that helps.
Best regards, ddrdtdn