Skip to content

Commit 0d453ba

Browse files
Gerd Bayerhcahca
authored andcommitted
s390/Kconfig: Define non-zero ILLEGAL_POINTER_VALUE
Define CONFIG_ILLEGAL_POINTER_VALUE to the eye-catching non-zero value of 0xdead000000000000, consistent with other architectures. Assert at compile-time that the poison pointers that include/linux/poison.h defines based on this illegal pointer are beyond the largest useful virtual addresses. Also, assert at compile-time that the range of poison pointers per include/linux/poison.h (currently a range of less than 0x10000 addresses) does not overlap with the range used for address handles for s390's non-MIO PCI instructions. This enables s390 to track the DMA mappings by the network stack's page_pool that was introduced with [0]. Other functional changes are not intended. Other archictectures have introduced this for various other reasons with commit 5c17847 ("riscv: define ILLEGAL_POINTER_VALUE for 64bit") commit f6853eb ("powerpc/64: Define ILLEGAL_POINTER_VALUE for 64-bit") commit bf0c4e0 ("arm64: kconfig: Move LIST_POISON to a safe value") commit a29815a ("core, x86: make LIST_POISON less deadly") [0] https://lore.kernel.org/all/20250409-page-pool-track-dma-v9-0-6a9ef2e0cba8@redhat.com/ Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 0875816 commit 0d453ba

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

Documentation/arch/s390/mm.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ Virtual memory layout
109109
| KASAN shadow | KASAN untracked
110110
| |
111111
+------------------+ ASCE limit
112+
| |
113+
| CONFIG_ILLEGAL_POINTER_VALUE causes memory access fault
114+
| |
115+
+------------------+

arch/s390/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,10 @@ config ARCH_SPARSEMEM_ENABLE
719719
config ARCH_SPARSEMEM_DEFAULT
720720
def_bool y
721721

722+
config ILLEGAL_POINTER_VALUE
723+
hex
724+
default 0xdead000000000000
725+
722726
config MAX_PHYSMEM_BITS
723727
int "Maximum size of supported physical memory in bits (42-53)"
724728
range 42 53

arch/s390/boot/startup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static unsigned long setup_kernel_memory_layout(unsigned long kernel_size)
336336
BUILD_BUG_ON(!IS_ALIGNED(TEXT_OFFSET, THREAD_SIZE));
337337
BUILD_BUG_ON(!IS_ALIGNED(__NO_KASLR_START_KERNEL, THREAD_SIZE));
338338
BUILD_BUG_ON(__NO_KASLR_END_KERNEL > _REGION1_SIZE);
339+
BUILD_BUG_ON(CONFIG_ILLEGAL_POINTER_VALUE < _REGION1_SIZE);
339340
vsize = get_vmem_size(ident_map_size, vmemmap_size, vmalloc_size, _REGION3_SIZE);
340341
boot_debug("vmem size estimated: 0x%016lx\n", vsize);
341342
if (IS_ENABLED(CONFIG_KASAN) || __NO_KASLR_END_KERNEL > _REGION2_SIZE ||

arch/s390/include/asm/pci_io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define ZPCI_IOMAP_SHIFT 48
1919
#define ZPCI_IOMAP_ADDR_SHIFT 62
2020
#define ZPCI_IOMAP_ADDR_BASE (1UL << ZPCI_IOMAP_ADDR_SHIFT)
21+
#define ZPCI_IOMAP_ADDR_MAX ((1UL << (ZPCI_IOMAP_ADDR_SHIFT + 1)) - 1)
2122
#define ZPCI_IOMAP_ADDR_OFF_MASK ((1UL << ZPCI_IOMAP_SHIFT) - 1)
2223
#define ZPCI_IOMAP_MAX_ENTRIES \
2324
(1UL << (ZPCI_IOMAP_ADDR_SHIFT - ZPCI_IOMAP_SHIFT))

arch/s390/pci/pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,8 @@ static int zpci_mem_init(void)
10651065
{
10661066
BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) ||
10671067
__alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb));
1068+
BUILD_BUG_ON((CONFIG_ILLEGAL_POINTER_VALUE + 0x10000 > ZPCI_IOMAP_ADDR_BASE) &&
1069+
(CONFIG_ILLEGAL_POINTER_VALUE <= ZPCI_IOMAP_ADDR_MAX));
10681070

10691071
zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb),
10701072
__alignof__(struct zpci_fmb), 0, NULL);

0 commit comments

Comments
 (0)