Hey Vincent,
I failed to parse this
But I see
/* The base IPA of the constituent memory region, aligned to 4 kiB */
So it sounds fair to prevent oversharing when PAGE_SIZE > 4KiB
I think the problem is when you have a mismatch between FFA_PAGE_SIZE and the system PAGE_SIZE. We expect a fixed FFA_PAGE_SIZE of 4kb and this is enforced by : https://elixir.bootlin.com/linux/v7.1.2/source/arch/arm64/kvm/hyp/nvhe/ffa.c...
if FFA_PAGE_SIZE = 4kb and PAGE_SIZE = 16kb you can end up annotating more pages with FF-A then needed when the range->address is unaligned.
It took me a while to understand this so I guess it is better to rephrase the commit msg.
The problem here is that we only check alignment for size and not the address. And the code later (__pkvm_host_unshare_ffa()) uses pfn which truncates the extra bits. So, in case we have an unaligned address and an aligned the size, it will round down the address while the actual size spans an extra page.
For example if base = 0xFFF and size = 0x1000. pKVM will share (0-0x1000) while the actual range spans till 0x1FFF causing FFA to access an extra page that was not shared by pKVM.
Thanks, Mostafa