Re: [PATCH 1/2] mm: provide a sane PTE walking API for modules

From: Jason Gunthorpe
Date: Fri Feb 05 2021 - 08:53:40 EST


On Fri, Feb 05, 2021 at 05:32:58AM -0500, Paolo Bonzini wrote:
> Currently, the follow_pfn function is exported for modules but
> follow_pte is not. However, follow_pfn is very easy to misuse,
> because it does not provide protections (so most of its callers
> assume the page is writable!) and because it returns after having
> already unlocked the page table lock.
>
> Provide instead a simplified version of follow_pte that does
> not have the pmdpp and range arguments. The older version
> survives as follow_invalidate_pte() for use by fs/dax.c.
>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
> arch/s390/pci/pci_mmio.c | 2 +-
> fs/dax.c | 5 +++--
> include/linux/mm.h | 6 ++++--
> mm/memory.c | 35 ++++++++++++++++++++++++++++++-----
> 4 files changed, 38 insertions(+), 10 deletions(-)

Looks good to me, thanks

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason