Re: [PATCH v3 1/1] KVM: arm64: Allow cacheable stage 2 mapping using VMA flags
From: Jason Gunthorpe
Date: Tue Mar 18 2025 - 19:17:54 EST
On Tue, Mar 18, 2025 at 07:27:27PM +0000, Catalin Marinas wrote:
> Thinking some more about a KVM capability that the VMM can check, I'm
> not sure what it can do with this. The VMM simply maps something from a
> device and cannot probe the cacheability
KVM is mirroring the MM's PTEs to the S2's PTEs.
You can think about this differently - KVM currently has a little bug
where the MM's PTE's can say cachable but KVM will mirror it to a S2
PTE that is forced non-cachable. KVM will not do any cache flushing to
make this safe.
Fundamentally that discrepancy is what is being addressed
here. Cachable PTEs in the MM should be mirrored to cachable PTEs in
the S2.
That the issue only arises with non-struct page memory is just part of
the triggering condition..
> I assume with the cacheable pfn mapping, the whole range covered by the
> vma is entirely safe to be mapped as such in user space.
Yes
Jason