[PATCH v9 2/6] KVM: arm64: Update the check to detect device memory

Jason Gunthorpe jgg at nvidia.com
Fri Jul 4 06:43:07 PDT 2025


On Sat, Jun 21, 2025 at 04:21:07AM +0000, ankita at nvidia.com wrote:
> From: Ankit Agrawal <ankita at nvidia.com>
> 
> Currently, the kvm_is_device_pfn() detects if the memory is kernel
> mapped through pfn_is_map_memory. It thus implies whether KVM can
> use Cache Maintenance Operations (CMOs) on that PFN. It is a bit
> of a misnomer as it does not necessarily detect whether a PFN
> is for a device memory. Moreover, the function is only used at
> one place.
> 
> It would be better to directly call pfn_is_map_memory. Moreover
> we should restrict this call to VM_PFNMAP or VM_MIXEDMAP. Otherwise
> the VMA has struct pages in it and mapped in the kernel VA.
> 
> Suggested-by: Jason Gunthorpe <jgg at nvidia.com>
> Signed-off-by: Ankit Agrawal <ankita at nvidia.com>
> ---
>  arch/arm64/kvm/mmu.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg at nvidia.com>

Non PFMAP or MIXEDMAP VMA's must always contain normal pages which are
struct page backed, have KVA's and are cachable.

So we should always be able to go from phys to KVA to do a CMO.

Jason



More information about the linux-arm-kernel mailing list