Re: [PATCH v13 36/48] arm64: RMI: Always use 4k pages for realms
From: Steven Price
Date: Thu Mar 19 2026 - 12:10:31 EST
On 19/03/2026 10:24, Joey Gouly wrote:
> Hi,
>
> On Wed, Mar 18, 2026 at 03:54:00PM +0000, Steven Price wrote:
>> Guest_memfd doesn't yet natively support huge pages, and there are
>> currently difficulties for a VMM to manage huge pages efficiently so for
>> now always split up mappings to PTE (4k).
>>
>> The two issues that need progressing before supporting huge pages for
>> realms are:
>>
>> 1. guest_memfd needs to be able to allocate from an appropriate
>> allocator which can provide huge pages.
>>
>> 2. The VMM needs to be able to repurpose private memory for a shared
>> mapping when the guest VM requests memory is transitioned. Because
>> this can happen at a 4k granularity it isn't possible to
>> free/reallocate while huge pages are in use. Allowing the VMM to
>> mmap() the shared portion of a huge page would allow the huge page
>> to be recreated when the memory is unshared and made protected again.
>>
>> These two issues are not specific to realms and don't affect the realm
>> API, so for now just break everything down to 4k pages in the RMM
>> controlled stage 2. Future work can add huge page support without
>> changing the uAPI.
>
> The commit title/message mention 4K, but should probably say PAGE_SIZE or
> something now that RMM isn't fixed to 4K.
Indeed - this is all PAGE_SIZE not 4k any more. Also hopefully the
reasons for this patch are also going to disappear soon. (2) above isn't
really very true any more (we do support mmap() from guest_memfd).
Thanks,
Steve
> Thanks,
> Joey
>
>>
>> Signed-off-by: Steven Price <steven.price@xxxxxxx>
>> Reviewed-by: Gavin Shan <gshan@xxxxxxxxxx>
>> Reviewed-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
>> ---
>> Changes since v7:
>> * Rewritten commit message
>> ---
>> arch/arm64/kvm/mmu.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
>> index 73c18c2861a2..ad1300f366df 100644
>> --- a/arch/arm64/kvm/mmu.c
>> +++ b/arch/arm64/kvm/mmu.c
>> @@ -1761,11 +1761,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>> write_fault = kvm_is_write_fault(vcpu);
>>
>> /*
>> - * Realms cannot map protected pages read-only
>> + * Realms cannot map protected pages read-only, also force PTE mappings
>> + * for Realms.
>> * FIXME: It should be possible to map unprotected pages read-only
>> */
>> - if (vcpu_is_rec(vcpu))
>> + if (vcpu_is_rec(vcpu)) {
>> write_fault = true;
>> + force_pte = true;
>> + }
>>
>> exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu);
>> VM_WARN_ON_ONCE(write_fault && exec_fault);
>> --
>> 2.43.0
>>
>>