parisc: Set valid bit in high byte of 64‑bit physical address
PATCH 1/1 parisc: Set valid bit in high byte of 64‑bit physical address
From: Leon Romanovsky <[email protected]>
On 32‑bit systems, phys_addr_t is defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
Resolve this mismatch by casting the physical address to unsigned long, ensuring it is treated as a 64‑bit value where required. This fixes the failure to start block device drivers on the C3700 platform, as reported by Guenter.
Also remove the now‑obsolete macro.
QEMU command line to reproduce the issue (with Debian SID as rootfs):
qemu-system-hppa -machine C3700 \ -kernel arch/parisc/boot/bzImage \ -append "console=ttyS0 \ root=/dev/sda rw rootwait panic=-1" \ -nographic \ -device lsi53c895a \ -drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \ -device scsi-hd,drive=hd0
--- arch/parisc/include/asm/special_insns.h | 15 --------------- drivers/parisc/sba_iommu.c | 4 ++-- 2 files changed, 2 insertions(+), 17 deletions(-)
arch/parisc/include/asm/special_insns.h +0 -15
@@ -2,21 +2,6 @@#ifndef __PARISC_SPECIAL_INSNS_H#define __PARISC_SPECIAL_INSNS_H -#define lpa (va) ({ \ - unsigned long pa; \ - __asm__ __volatile__( \ - "copy %%r0,%0\n" \ - "8:\tlpa %%r0(%1),%0\n" \ - "9:\n" \ - ASM_EXCEPTIONTABLE_ENTRY(8b, 9b, \ - "or %%r0,%%r0,%%r0") \ - : "=&r" (pa) \ - : "r" (va) \ - : "memory" \ - ); \ - pa; \ -}) -#define lpa_user (va) ({ \ unsigned long pa; \ __asm__ __volatile__( \
drivers/parisc/sba_iommu.c +2 -2
@@ -578,8 +578,8 @@ sba_io_pdir_entry(__le64 *pdir_ptr, space_t sid, phys_addr_t pba, pba &=IOVP_MASK ; pba |= (ci >>PAGE_SHIFT ) &0xff ;/* move CI (8 bits) into lowest byte */ - pba |=SBA_PDIR_VALID_BIT ;/* set "valid" bit */ - *pdir_ptr =cpu_to_le64 (pba);/* swap and store into I/O Pdir */ +/* set "valid" bit, swap and store into I/O Pdir */ + *pdir_ptr =cpu_to_le64 ((unsigned long )pba |SBA_PDIR_VALID_BIT );/* * If the PDC_MODEL capabilities has Non-coherent IO-PDIR bit set
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251218-fix-parisc-conversion-37e31197a291
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>
Quoted 23 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.Resolve this mismatch by casting the physical address to unsigned long, ensuring it is treated as a 64‑bit value where required. This fixes the failure to start block device drivers on the C3700 platform, as reported by Guenter.
Also remove the now‑obsolete macro.
QEMU command line to reproduce the issue (with Debian SID as rootfs):
qemu-system-hppa -machine C3700 \ -kernel arch/parisc/boot/bzImage \ -append "console=ttyS0 \ root=/dev/sda rw rootwait panic=-1" \ -nographic \ -device lsi53c895a \ -drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \ -device scsi-hd,drive=hd0
Quoted 4 lines
Fixes 96ddf2ef58ec ("parisc: Convert DMA map_page to map_phys interface")Reported-by Guenter Roeck <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
Quoted 24 lines · Guenter Roeck
Quoted 23 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.Resolve this mismatch by casting the physical address to unsigned long, ensuring it is treated as a 64‑bit value where required. This fixes the failure to start block device drivers on the C3700 platform, as reported by Guenter.
Also remove the now‑obsolete macro.
QEMU command line to reproduce the issue (with Debian SID as rootfs):
qemu-system-hppa -machine C3700 \
-kernelarch/parisc/boot/bzImage\
-append "console=ttyS0 \
root=/dev/sda rw rootwait panic=-1" \
-nographic \
-device lsi53c895a \
-drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \
-device scsi-hd,drive=hd0
Quoted 8 lines
Quoted 6 lines
Fixes 96ddf2ef58ec ("parisc: Convert DMA map_page to map_physinterface")
Reported-by Guenter Roeck <[email protected]>Closes:
https://lore.kernel.org/all/[email protected]/Signed-off-by Leon Romanovsky <[email protected]>Tested-by Guenter Roeck <[email protected]>
Thanks for the initial report and a quick fix. I'm sorry that this issue slipped through the review and tests in linux-next. I've applied it to dma-mapping-fixes branch.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Helge Deller
maintainerHi Leon,
Quoted 5 lines · Leon Romanovsky
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
...
Also remove the now‑obsolete macro.
Your patch is OK, but could you please keep the lpa() macro? It's unrelated to your patch, and sometimes we need the lpa() e.g. when adding debug code, so I'd prefer to keep it.
Thanks,
Helge
...
Quoted 22 lines
arch/parisc/include/asm/special_insns.h +0
-14@@ -2,21 +2,6 @@#ifndef __PARISC_SPECIAL_INSNS_H#define __PARISC_SPECIAL_INSNS_H -#define lpa (va) ({ \ - unsigned long pa; \ - __asm__ __volatile__( \ - "copy %%r0,%0\n" \ - "8:\tlpa %%r0(%1),%0\n" \ - "9:\n" \ - ASM_EXCEPTIONTABLE_ENTRY(8b, 9b, \ - "or %%r0,%%r0,%%r0") \ - : "=&r" (pa) \ - : "r" (va) \ - : "memory" \ - ); \ - pa; \ -})
Quoted 9 lines · Helge Deller
Hi Leon,
Quoted 5 lines · Leon Romanovsky
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
...
Also remove the now‑obsolete macro.
Quoted 3 lines
Your patch is OK, but could you please keep the
lpa()macro? It's unrelated to your patch, and sometimes we need thelpa()e.g. when adding debug code, so I'd prefer to keep it.
The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.
However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.
Isn't lpa(x/) equal to virt_to_phys(x)?
Thanks
Quoted 27 lines
Thanks,
Helge...
Quoted 22 lines
arch/parisc/include/asm/special_insns.h +0
-14@@ -2,21 +2,6 @@#ifndef __PARISC_SPECIAL_INSNS_H#define __PARISC_SPECIAL_INSNS_H -#define lpa (va) ({ \ - unsigned long pa; \ - __asm__ __volatile__( \ - "copy %%r0,%0\n" \ - "8:\tlpa %%r0(%1),%0\n" \ - "9:\n" \ - ASM_EXCEPTIONTABLE_ENTRY(8b, 9b, \ - "or %%r0,%%r0,%%r0") \ - : "=&r" (pa) \ - : "r" (va) \ - : "memory" \ - ); \ - pa; \ -})
Quoted 7 lines · Leon Romanovsky
Quoted 6 lines · Helge Deller
Quoted 5 lines · Leon Romanovsky
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
...
Also remove the now‑obsolete macro.
Quoted 8 lines
Quoted 3 lines
Your patch is OK, but could you please keep the
lpa()macro? It's unrelated to your patch, and sometimes we need thelpa()e.g. when adding debug code, so I'd prefer to keep it.The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.
However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.
Isn't lpa(x/) equal to
virt_to_phys(x)?
I can drop the lpa() related change, but let us know what is the advantage of it compared to virt_to_phys()?
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
James Bottomley
maintainerQuoted 14 lines · Marek Szyprowski
Quoted 13 lines · Leon Romanovsky
Quoted 9 lines · Helge Deller
Quoted 5 lines · Leon Romanovsky
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
...
Also remove the now‑obsolete macro.Your patch is OK, but could you please keep the
lpa()macro? It's unrelated to your patch, and sometimes we need thelpa()e.g. when adding debug code, so I'd prefer to keep it.The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.
Quoted 8 lines
Quoted 5 lines
However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.
Isn't lpa(x/) equal to
virt_to_phys(x)?I can drop the
lpa()related change, but let us know what is the advantage of it compared tovirt_to_phys()?
Um, well same as on every architecture: virt_to_phys only gives correct results on the offset map since it's defined as an offset map subtraction; lpa() gives the the CPU view of the mapping through the page table entries, so is correct even in the vmap (and iomap, etc) range.
Regards,
James
Quoted 19 lines · James Bottomley
Quoted 18 lines · Marek Szyprowski
Quoted 17 lines · Leon Romanovsky
Quoted 9 lines · Helge Deller
Quoted 5 lines · Leon Romanovsky
On 32‑bit systems,
phys_addr_tis defined as u32. However, parisc expects physical addresses to be 64‑bit values so it can store a validity bit in the upper byte.
...
Also remove the now‑obsolete macro.Your patch is OK, but could you please keep the
lpa()macro? It's unrelated to your patch, and sometimes we need thelpa()e.g. when adding debug code, so I'd prefer to keep it.The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.
However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Isn't lpa(x/) equal to
virt_to_phys(x)?I can drop the
lpa()related change, but let us know what is the advantage of it compared tovirt_to_phys()?Um, well same as on every architecture:
virt_to_physonly gives correct results on the offset map since it's defined as an offset map subtraction;lpa()gives the the CPU view of the mapping through the page table entries, so is correct even in the vmap (and iomap, etc) range.
Thanks for the explanation. I will drop the lpa() removal chunk from dma-mapping-fixes branch then.
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland