[PATCH v8 5/6] KVM: arm64: Allow cacheable stage 2 mapping using VMA flags

Ankit Agrawal ankita at nvidia.com
Fri Jun 20 06:07:11 PDT 2025


>> -             s2_force_noncacheable = true;
>> +             bool cacheable_pfnmap = false;
>> +
>> +             if (vm_flags & VM_PFNMAP) {
>
> I think this same logic works equally well for MIXEDMAP. A cachable
> MIXEDMAP should follow the same rules for PFNMAP for the non-normal
> pages within it. IOW, just remove this if, it was already done above.

I see. Sure, I'll update to remove the check.


>> +                     /*
>> +                      * COW VM_PFNMAP is possible when doing a MAP_PRIVATE
>> +                      * /dev/mem mapping on systems that allow such mapping.
>> +                      * Reject such case.
>> +                      */
>
> This is where a COW mapping come from, but it doesn't explain why KVM
> has a problem here?

Actually I am not entirely sure of the reason. My read on that was that COW of
PFNMAP is a normal page backed by struct page that doesn't follow linearity.
Not sure if that conflicts with user_mem_abort() assumptions. Will need
David's take on that.

>> +                     if (is_vma_cacheable)
>> +                             cacheable_pfnmap = true;
>> +             }
>> +
>> +             if (cacheable_pfnmap) {
>
> If the vm_flags test is removed then this is just is_vma_cacheable

Thanks for catching that. We shouldn't need this variable.

>> +                      * ARM64 KVM relies on kernel VA mapping to the PFN to
>> +                      * perform cache maintenance as the CMO instructions work on
>> +                      * virtual addresses. VM_PFNMAP region are not necessarily
>> +                      * mapped to a KVA and hence the presence of hardware features
>> +                      * S2FWB and CACHE DIC is mandatory for cache maintenance.
>
> "are mandatory to avoid any cache maintenance"

Right, thanks.

> Jason


More information about the linux-arm-kernel mailing list