lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d8d83bfc-7f23-4ab1-a589-db33d2d3824e@suse.cz>
Date: Tue, 20 Jan 2026 11:03:37 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Mostafa Saleh <smostafa@...gle.com>, linux-mm@...ck.org,
 iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
 linux-doc@...r.kernel.org
Cc: corbet@....net, joro@...tes.org, will@...nel.org, robin.murphy@....com,
 akpm@...ux-foundation.org, surenb@...gle.com, mhocko@...e.com,
 jackmanb@...gle.com, hannes@...xchg.org, ziy@...dia.com, david@...hat.com,
 lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com, rppt@...nel.org,
 xiaqinxin@...wei.com, baolu.lu@...ux.intel.com, rdunlap@...radead.org
Subject: Re: [PATCH v2 1/2] mm/page_ext: Add page_ext_get_from_phys()

On 1/20/26 10:19, Mostafa Saleh wrote:
> The IOMMU code operates on physical addresses which can be outside
> of system RAM.
> 
> Add a new function page_ext_get_from_phys() to abstract the logic of
> checking the address and returning the page_ext.
> 
> Signed-off-by: Mostafa Saleh <smostafa@...gle.com>

Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  include/linux/page_ext.h |  6 ++++++
>  mm/page_ext.c            | 23 +++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
> index 76c817162d2f..61e876e255e8 100644
> --- a/include/linux/page_ext.h
> +++ b/include/linux/page_ext.h
> @@ -93,6 +93,7 @@ static inline bool page_ext_iter_next_fast_possible(unsigned long next_pfn)
>  #endif
>  
>  extern struct page_ext *page_ext_get(const struct page *page);
> +extern struct page_ext *page_ext_from_phys(phys_addr_t phys);
>  extern void page_ext_put(struct page_ext *page_ext);
>  extern struct page_ext *page_ext_lookup(unsigned long pfn);
>  
> @@ -215,6 +216,11 @@ static inline struct page_ext *page_ext_get(const struct page *page)
>  	return NULL;
>  }
>  
> +static inline struct page_ext *page_ext_from_phys(phys_addr_t phys)
> +{
> +	return NULL;
> +}
> +
>  static inline void page_ext_put(struct page_ext *page_ext)
>  {
>  }
> diff --git a/mm/page_ext.c b/mm/page_ext.c
> index 297e4cd8ce90..e2e92bd27ebd 100644
> --- a/mm/page_ext.c
> +++ b/mm/page_ext.c
> @@ -538,6 +538,29 @@ struct page_ext *page_ext_get(const struct page *page)
>  	return page_ext;
>  }
>  
> +/**
> + * page_ext_from_phys() - Get the page_ext structure for a physical address.
> + * @phys: The physical address to query.
> + *
> + * This function safely gets the `struct page_ext` associated with a given
> + * physical address. It performs validation to ensure the address corresponds
> + * to a valid, online struct page before attempting to access it.
> + * It returns NULL for MMIO, ZONE_DEVICE, holes and offline memory.
> + *
> + * Return: NULL if no page_ext exists for this physical address.
> + * Context: Any context.  Caller may not sleep until they have called
> + * page_ext_put().
> + */
> +struct page_ext *page_ext_from_phys(phys_addr_t phys)
> +{
> +	struct page *page = pfn_to_online_page(__phys_to_pfn(phys));
> +
> +	if (!page)
> +		return NULL;
> +
> +	return page_ext_get(page);
> +}
> +
>  /**
>   * page_ext_put() - Working with page extended information is done.
>   * @page_ext: Page extended information received from page_ext_get().


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ