* Re: [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot()
2026-11-13 19:38 [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot() Ivan Ezequiel Rodriguez
@ 2026-11-13 20:18 ` David Hildenbrand (Arm)
2026-11-15 6:47 ` Mike Rapoport
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-13 20:18 UTC (permalink / raw)
To: Ivan Ezequiel Rodriguez, Andrew Morton
Cc: Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Jann Horn, Pedro Falcato,
linux-mm, linux-kernel, stable
On 11/13/26 20:38, Ivan Ezequiel Rodriguez wrote:
> From: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
>
> phys_mem_access_prot() stores "pfn << PAGE_SHIFT" in a phys_addr_t.
> The shift is evaluated as unsigned long, so on a 32-bit kernel with
> CONFIG_PHYS_ADDR_T_64BIT an address above 4 GiB is truncated before
> uncached_access() compares it with __pa(high_memory).
>
> mmap_mem_prepare() already shifts in phys_addr_t, so the mapping is
> accepted and then left cacheable. PFN_PHYS() casts before the shift.
>
> On a MIPS32 XPA Malta guest, mmap of /dev/mem at 0xf00000000 without
> O_DSYNC used the boot CCA. The same mapping with O_DSYNC was uncached.
> With PFN_PHYS() both are uncached.
>
> Fixes: 7e6735c3578e ("/dev/mem: use phys_addr_t for physical addresses")
> Cc: stable@vger.kernel.org
> Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
> ---
> mm/char-mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/char-mem.c b/mm/char-mem.c
> index c5761ddedbd7..53ce0034a4c1 100644
> --- a/mm/char-mem.c
> +++ b/mm/char-mem.c
> @@ -272,7 +272,7 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> unsigned long size, pgprot_t vma_prot)
> {
> #ifdef pgprot_noncached
> - phys_addr_t offset = pfn << PAGE_SHIFT;
> + phys_addr_t offset = PFN_PHYS(pfn);
>
> if (uncached_access(file, offset))
> return pgprot_noncached(vma_prot);
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
I'm relying on Andrew to pick this up.
--
Cheers,
David
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot()
2026-11-13 19:38 [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot() Ivan Ezequiel Rodriguez
2026-11-13 20:18 ` David Hildenbrand (Arm)
@ 2026-11-15 6:47 ` Mike Rapoport
2026-11-15 12:27 ` Lorenzo Stoakes (ARM)
2026-11-23 6:25 ` [merged mm-hotfixes-stable] mm-use-pfn_phys-in-phys_mem_access_prot.patch removed from -mm tree Andrew Morton
3 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2026-11-15 6:47 UTC (permalink / raw)
To: Ivan Ezequiel Rodriguez
Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Suren Baghdasaryan,
Michal Hocko, Jann Horn, Pedro Falcato, linux-mm, linux-kernel,
stable
On Fri, Nov 13, 2026 at 04:38:12PM -0300, Ivan Ezequiel Rodriguez wrote:
> From: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
>
> phys_mem_access_prot() stores "pfn << PAGE_SHIFT" in a phys_addr_t.
> The shift is evaluated as unsigned long, so on a 32-bit kernel with
> CONFIG_PHYS_ADDR_T_64BIT an address above 4 GiB is truncated before
> uncached_access() compares it with __pa(high_memory).
>
> mmap_mem_prepare() already shifts in phys_addr_t, so the mapping is
> accepted and then left cacheable. PFN_PHYS() casts before the shift.
>
> On a MIPS32 XPA Malta guest, mmap of /dev/mem at 0xf00000000 without
> O_DSYNC used the boot CCA. The same mapping with O_DSYNC was uncached.
> With PFN_PHYS() both are uncached.
>
> Fixes: 7e6735c3578e ("/dev/mem: use phys_addr_t for physical addresses")
> Cc: stable@vger.kernel.org
> Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> mm/char-mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/char-mem.c b/mm/char-mem.c
> index c5761ddedbd7..53ce0034a4c1 100644
> --- a/mm/char-mem.c
> +++ b/mm/char-mem.c
> @@ -272,7 +272,7 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> unsigned long size, pgprot_t vma_prot)
> {
> #ifdef pgprot_noncached
> - phys_addr_t offset = pfn << PAGE_SHIFT;
> + phys_addr_t offset = PFN_PHYS(pfn);
>
> if (uncached_access(file, offset))
> return pgprot_noncached(vma_prot);
> --
> 2.43.0
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot()
2026-11-13 19:38 [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot() Ivan Ezequiel Rodriguez
2026-11-13 20:18 ` David Hildenbrand (Arm)
2026-11-15 6:47 ` Mike Rapoport
@ 2026-11-15 12:27 ` Lorenzo Stoakes (ARM)
2026-11-23 6:25 ` [merged mm-hotfixes-stable] mm-use-pfn_phys-in-phys_mem_access_prot.patch removed from -mm tree Andrew Morton
3 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-15 12:27 UTC (permalink / raw)
To: Ivan Ezequiel Rodriguez
Cc: Andrew Morton, David Hildenbrand, Liam R . Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jann Horn, Pedro Falcato, linux-mm, linux-kernel, stable
On Fri, Nov 13, 2026 at 04:38:12PM -0300, Ivan Ezequiel Rodriguez wrote:
> From: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
>
> phys_mem_access_prot() stores "pfn << PAGE_SHIFT" in a phys_addr_t.
> The shift is evaluated as unsigned long, so on a 32-bit kernel with
> CONFIG_PHYS_ADDR_T_64BIT an address above 4 GiB is truncated before
> uncached_access() compares it with __pa(high_memory).
>
> mmap_mem_prepare() already shifts in phys_addr_t, so the mapping is
> accepted and then left cacheable. PFN_PHYS() casts before the shift.
>
> On a MIPS32 XPA Malta guest, mmap of /dev/mem at 0xf00000000 without
> O_DSYNC used the boot CCA. The same mapping with O_DSYNC was uncached.
> With PFN_PHYS() both are uncached.
>
> Fixes: 7e6735c3578e ("/dev/mem: use phys_addr_t for physical addresses")
> Cc: stable@vger.kernel.org
> Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
LGTM so:
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> mm/char-mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/char-mem.c b/mm/char-mem.c
> index c5761ddedbd7..53ce0034a4c1 100644
> --- a/mm/char-mem.c
> +++ b/mm/char-mem.c
> @@ -272,7 +272,7 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
> unsigned long size, pgprot_t vma_prot)
> {
> #ifdef pgprot_noncached
> - phys_addr_t offset = pfn << PAGE_SHIFT;
> + phys_addr_t offset = PFN_PHYS(pfn);
>
> if (uncached_access(file, offset))
> return pgprot_noncached(vma_prot);
> --
> 2.43.0
>
--
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 5+ messages in thread* [merged mm-hotfixes-stable] mm-use-pfn_phys-in-phys_mem_access_prot.patch removed from -mm tree
2026-11-13 19:38 [PATCH] mm: use PFN_PHYS() in phys_mem_access_prot() Ivan Ezequiel Rodriguez
` (2 preceding siblings ...)
2026-11-15 12:27 ` Lorenzo Stoakes (ARM)
@ 2026-11-23 6:25 ` Andrew Morton
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2026-11-23 6:25 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, stable, rppt, pfalcato, mhocko, ljs,
liam, jannh, david, ivanrwcm25, akpm
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2323 bytes --]
The quilt patch titled
Subject: mm: use PFN_PHYS() in phys_mem_access_prot()
has been removed from the -mm tree. Its filename was
mm-use-pfn_phys-in-phys_mem_access_prot.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
Subject: mm: use PFN_PHYS() in phys_mem_access_prot()
Date: Fri, 13 Nov 2026 16:38:12 -0300
phys_mem_access_prot() stores "pfn << PAGE_SHIFT" in a phys_addr_t. The
shift is evaluated as unsigned long, so on a 32-bit kernel with
CONFIG_PHYS_ADDR_T_64BIT an address above 4 GiB is truncated before
uncached_access() compares it with __pa(high_memory).
mmap_mem_prepare() already shifts in phys_addr_t, so the mapping is
accepted and then left cacheable. PFN_PHYS() casts before the shift.
On a MIPS32 XPA Malta guest, mmap of /dev/mem at 0xf00000000 without
O_DSYNC used the boot CCA. The same mapping with O_DSYNC was uncached.
With PFN_PHYS() both are uncached.
Link: https://patch.msgid.link/20261113193812.1239880-1-ivanrwcm25@gmail.com
Fixes: 7e6735c3578e ("/dev/mem: use phys_addr_t for physical addresses")
Signed-off-by: Iván Ezequiel Rodriguez <ivanrwcm25@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: <stable@vger.kernel.org>
mm/char-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/char-mem.c~mm-use-pfn_phys-in-phys_mem_access_prot
+++ a/mm/char-mem.c
@@ -272,7 +272,7 @@ static pgprot_t phys_mem_access_prot(str
unsigned long size, pgprot_t vma_prot)
{
#ifdef pgprot_noncached
- phys_addr_t offset = pfn << PAGE_SHIFT;
+ phys_addr_t offset = PFN_PHYS(pfn);
if (uncached_access(file, offset))
return pgprot_noncached(vma_prot);
_
Patches currently in -mm which might be from ivanrwcm25@gmail.com are
^ permalink raw reply [flat|nested] 5+ messages in thread