linux/arch/riscv/include/asm
Palmer Dabbelt 3088483336 RISC-V: Don't have MAX_PHYSMEM_BITS exceed phys_addr_t
[ Upstream commit ad380f6a0a ]

I recently ended up with a warning on some compilers along the lines of

      CC      kernel/resource.o
    In file included from include/linux/ioport.h:16,
                     from kernel/resource.c:15:
    kernel/resource.c: In function 'gfr_start':
    include/linux/minmax.h:49:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '17179869183' to '4294967295' [-Werror=overflow]
       49 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
          |                                     ^
    include/linux/minmax.h:52:9: note: in expansion of macro '__cmp_once_unique'
       52 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
          |         ^~~~~~~~~~~~~~~~~
    include/linux/minmax.h:161:27: note: in expansion of macro '__cmp_once'
      161 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
          |                           ^~~~~~~~~~
    kernel/resource.c:1829:23: note: in expansion of macro 'min_t'
     1829 |                 end = min_t(resource_size_t, base->end,
          |                       ^~~~~
    kernel/resource.c: In function 'gfr_continue':
    include/linux/minmax.h:49:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '17179869183' to '4294967295' [-Werror=overflow]
       49 |         ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
          |                                     ^
    include/linux/minmax.h:52:9: note: in expansion of macro '__cmp_once_unique'
       52 |         __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
          |         ^~~~~~~~~~~~~~~~~
    include/linux/minmax.h:161:27: note: in expansion of macro '__cmp_once'
      161 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
          |                           ^~~~~~~~~~
    kernel/resource.c:1847:24: note: in expansion of macro 'min_t'
     1847 |                addr <= min_t(resource_size_t, base->end,
          |                        ^~~~~
    cc1: all warnings being treated as errors

which looks like a real problem: our phys_addr_t is only 32 bits now, so
having 34-bit masks is just going to result in overflows.

Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20240731162159.9235-2-palmer@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-17 15:24:17 +02:00
..
vdso riscv: Using TOOLCHAIN_HAS_ZIHINTPAUSE marco replace zihintpause 2023-11-28 17:20:13 +00:00
acenv.h RISC-V: Add support to build the ACPI core 2023-06-01 08:45:01 -07:00
acpi.h RISC-V: ACPI: Fix acpi_os_ioremap to return iomem address 2023-08-02 13:49:43 -07:00
alternative-macros.h riscv: alternatives: fix a typo in comment 2023-08-02 13:49:07 -07:00
alternative.h Merge patch series "Add non-coherent DMA support for AX45MP" 2023-09-08 11:24:34 -07:00
asm-extable.h riscv: mm: stub extable related functions/macros for !MMU 2023-06-14 07:17:45 -07:00
asm-offsets.h
asm-prototypes.h riscv: VMAP_STACK overflow detection thread-safe 2023-11-28 17:19:47 +00:00
asm.h riscv: blacklist assembly symbols for kprobe 2024-08-29 17:33:33 +02:00
assembler.h RISC-V: Add arch functions to support hibernation/suspend-to-disk 2023-04-29 11:25:13 -07:00
atomic.h locking/atomic: make atomic*_{cmp,}xchg optional 2023-06-05 09:57:14 +02:00
barrier.h riscv: introduce nops and __nops macros for NOP sequences 2022-07-21 17:17:29 -07:00
bitops.h include: move find.h from asm_generic to linux 2022-01-15 08:47:31 -08:00
bug.h bug: Use normal relative pointers in 'struct bug_entry' 2022-05-19 23:46:10 +02:00
cache.h riscv: allow kmalloc() caches aligned to the smallest value 2023-08-23 14:22:00 -07:00
cacheflush.h mm: Introduce flush_cache_vmap_early() 2024-02-16 19:10:52 +01:00
cacheinfo.h riscv: Add cache information in AUX vector 2020-09-15 18:46:08 -07:00
cfi.h riscv: Add CFI error handling 2023-08-23 14:16:39 -07:00
clint.h RISC-V: Resurrect the MMIO timer implementation for M-mode systems 2020-09-19 13:21:11 -07:00
clocksource.h
cmpxchg.h locking/arch: Rename all internal __xchg() names to __arch_xchg() 2023-04-29 09:08:44 +02:00
compat.h riscv: compat: Add basic compat data type implementation 2022-04-26 13:36:12 -07:00
cpu_ops_sbi.h riscv: ensure cpu_ops_sbi is declared 2022-08-11 13:46:51 -07:00
cpu_ops.h RISC-V: Declare cpu_ops_spinwait in <asm/cpu_ops.h> 2022-08-11 13:06:47 -07:00
cpu.h RISC-V: Add support to build the ACPI core 2023-06-01 08:45:01 -07:00
cpufeature.h RISC-V: Probe for unaligned access speed 2023-09-01 09:06:25 -07:00
cpuidle.h RISC-V: Enable CPU_IDLE drivers 2022-03-10 09:29:21 -08:00
csr.h RISC-V: KVM: provide UAPI for host SATP mode 2023-08-08 17:25:40 +05:30
current.h riscv: Rename "sp_in_global" to "current_stack_pointer" 2022-03-30 15:15:27 -07:00
delay.h
dma-noncoherent.h riscv: mm: dma-noncoherent: nonstandard cache operations support 2023-09-01 09:08:57 -07:00
efi.h Merge patch series "riscv: Introduce KASLR" 2023-09-08 11:25:13 -07:00
elf.h Merge patch series "RISC-V: mm: Make SV48 the default address space" 2023-08-31 00:18:36 -07:00
entry-common.h riscv: entry: Convert to generic entry 2023-03-23 08:47:00 -07:00
errata_list.h riscv: Apply SiFive CIP-1200 workaround to single-ASID sfence.vma 2024-07-11 12:49:06 +02:00
extable.h riscv: mm: stub extable related functions/macros for !MMU 2023-06-14 07:17:45 -07:00
fence.h
fixmap.h riscv: Move early dtb mapping into the fixmap region 2023-04-13 18:14:26 -07:00
ftrace.h riscv: add CALLER_ADDRx support 2024-03-06 14:48:41 +00:00
futex.h riscv: extable: add a dedicated uaccess handler 2022-01-05 17:53:29 -08:00
gdb_xml.h
gpr-num.h riscv: Add X register names to gpr-nums 2022-10-02 10:17:58 +05:30
hugetlb.h riscv: Fix build error if !CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION 2024-03-06 14:48:37 +00:00
hwcap.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
hwprobe.h RISC-V: hwprobe: Fix vDSO SIGSEGV 2023-11-28 17:19:49 +00:00
image.h
insn-def.h RISC-V: Use Zicboz in clear_page when available 2023-03-14 21:26:06 -07:00
insn.h RISC-V: fix vector insn load/store width mask 2024-07-05 09:33:53 +02:00
io.h RISC-V: Fix MEMREMAP_WB for systems with Svpbmt 2022-12-08 15:43:58 -08:00
irq_stack.h riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK 2023-06-22 10:38:35 -07:00
irq_work.h arch: consolidate arch_irq_work_raise prototypes 2024-02-05 20:14:17 +00:00
irq.h init: consolidate prototypes in linux/init.h 2023-06-09 17:44:16 -07:00
irqflags.h
jump_label.h work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:24:47 +01:00
kasan.h riscv: Implement sv48 support 2022-01-19 17:54:09 -08:00
Kbuild RISC-V: Move to queued RW locks 2022-05-11 11:50:10 -07:00
kdebug.h
kexec.h RISC-V: kexec: Fix memory leak of fdt buffer 2022-12-05 10:59:51 -08:00
kfence.h riscv: Use accessors to page table entries instead of direct dereference 2024-09-12 11:11:40 +02:00
kgdb.h
kprobes.h riscv: Only consider swbp/ss handlers for correct privileged mode 2023-09-20 06:45:27 -07:00
kvm_aia_aplic.h RISC-V: KVM: Add APLIC related defines 2023-06-18 21:24:36 +05:30
kvm_aia_imsic.h RISC-V: KVM: Add IMSIC related defines 2023-06-18 21:24:34 +05:30
kvm_aia.h RISC-V: KVM: Expose IMSIC registers as attributes of AIA irqchip 2023-06-19 22:27:58 +05:30
kvm_host.h KVM: riscv: Add KVM_GET_REG_LIST API support 2023-08-09 12:15:25 +05:30
kvm_types.h KVM: RISC-V: Use common KVM implementation of MMU memory caches 2022-01-06 14:38:50 +05:30
kvm_vcpu_fp.h RISC-V: KVM: Improve ISA extension by using a bitmap 2022-07-29 17:14:11 +05:30
kvm_vcpu_insn.h RISC-V: KVM: Add extensible CSR emulation framework 2022-07-29 17:14:53 +05:30
kvm_vcpu_pmu.h RISC-V: KVM: Fix to allow hpmcounter31 from the guest 2024-10-04 16:28:51 +02:00
kvm_vcpu_sbi.h riscv: kvm: define vcpu_sbi_ext_pmu in header 2023-06-19 22:28:00 +05:30
kvm_vcpu_timer.h RISC-V: KVM: Fix kvm_riscv_vcpu_timer_pending() for Sstc 2022-10-21 11:52:45 +05:30
kvm_vcpu_vector.h RISC-V: KVM: Improve vector save/restore functions 2023-08-08 17:26:05 +05:30
linkage.h
membarrier.h membarrier: riscv: Add full memory barrier in switch_mm() 2024-09-12 11:11:45 +02:00
mmio.h riscv,mmio: Fix readX()-to-delay() ordering 2023-08-08 15:28:37 -07:00
mmiowb.h
mmu_context.h riscv: add ASID-based tlbflushing methods 2021-06-30 20:55:39 -07:00
mmu.h riscv: support the elf-fdpic binfmt loader 2023-08-23 14:17:43 -07:00
mmzone.h riscv: Add numa support for riscv64 platform 2021-01-14 15:08:58 -08:00
module.h riscv: module: move find_section to module.h 2023-01-31 23:29:39 -08:00
module.lds.h riscv module: remove (NOLOAD) 2022-03-29 14:31:07 -07:00
numa.h riscv: Add numa support for riscv64 platform 2021-01-14 15:08:58 -08:00
page.h riscv: Fix loading 64-bit NOMMU kernels past the start of RAM 2024-05-02 16:32:49 +02:00
patch.h riscv: implement a memset like function for text 2023-09-06 06:26:06 -07:00
pci.h RISC-V Patches for the 5.20 Merge Window, Part 1 2022-08-06 15:04:48 -07:00
perf_event.h riscv: perf: Fix callchain parse error with kernel tracepoint events 2023-06-01 10:09:22 -07:00
pgalloc.h riscv: convert alloc_{pmd, pte}_late() to use ptdescs 2023-08-21 13:37:57 -07:00
pgtable-32.h riscv: add RISC-V Svpbmt extension support 2022-05-11 21:36:33 -07:00
pgtable-64.h riscv: Use accessors to page table entries instead of direct dereference 2024-09-12 11:11:40 +02:00
pgtable-bits.h riscv/mm: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE 2023-02-02 22:33:09 -08:00
pgtable.h riscv: Use accessors to page table entries instead of direct dereference 2024-09-12 11:11:40 +02:00
probes.h riscv: Add kprobes supported 2021-01-14 15:09:06 -08:00
processor.h riscv: mm: Fixup compat arch_get_mmap_end 2024-01-31 16:18:55 -08:00
ptdump.h
ptrace.h riscv: entry: Convert to generic entry 2023-03-23 08:47:00 -07:00
sbi.h riscv: cpufeature: Fix thead vector hwcap removal 2024-10-17 15:24:11 +02:00
seccomp.h riscv: Enable seccomp architecture tracking 2020-11-20 11:16:35 -08:00
sections.h riscv: Check if the code to patch lies in the exit section 2024-01-25 15:35:50 -08:00
semihost.h riscv: Implement semihost.h for earlycon semihost driver 2023-01-19 14:58:19 +01:00
set_memory.h riscv: Prepare EFI header for relocatable kernels 2023-04-19 07:46:28 -07:00
signal32.h riscv: compat: signal: Add rt_frame implementation 2022-05-17 16:37:21 -07:00
signal.h RISC-V: Fix do_notify_resume / do_work_pending prototype 2023-01-24 22:13:15 -08:00
smp.h riscv: Switch to hotplug core state synchronization 2023-05-15 13:44:59 +02:00
soc.h riscv: Fix builtin DTB handling 2021-01-07 19:00:50 -08:00
sparsemem.h RISC-V: Don't have MAX_PHYSMEM_BITS exceed phys_addr_t 2024-10-17 15:24:17 +02:00
stackprotector.h stackprotector: actually use get_random_canary() 2022-11-18 02:18:10 +01:00
stacktrace.h riscv: declare overflow_stack as exported from traps.c 2024-02-16 19:10:53 +01:00
string.h RISC-V: add infrastructure to allow different str* implementations 2023-01-31 11:43:23 -08:00
suspend.h RISC-V: Add arch functions to support hibernation/suspend-to-disk 2023-04-29 11:25:13 -07:00
switch_to.h riscv: Add task switch support for vector 2023-06-08 07:16:43 -07:00
syscall_wrapper.h posix-timers: Get rid of [COMPAT_]SYS_NI() uses 2024-01-20 11:51:46 +01:00
syscall.h riscv: Implement syscall wrappers 2023-08-23 14:16:36 -07:00
thread_info.h riscv: Remove SHADOW_OVERFLOW_STACK_SIZE macro 2024-10-17 15:24:08 +02:00
timex.h init: consolidate prototypes in linux/init.h 2023-06-09 17:44:16 -07:00
tlb.h riscv: Flush the tlb when a page directory is freed 2024-02-16 19:10:53 +01:00
tlbflush.h riscv: Apply SiFive CIP-1200 workaround to single-ASID sfence.vma 2024-07-11 12:49:06 +02:00
topology.h Merge patch series "Introduce 64b relocatable kernel" 2023-04-19 07:47:45 -07:00
uaccess.h riscv: Fix spurious errors from __get/put_kernel_nofault 2024-04-10 16:36:04 +02:00
unistd.h riscv: Wire up memfd_secret in UAPI header 2022-06-01 21:46:36 -07:00
uprobes.h riscv: Only consider swbp/ss handlers for correct privileged mode 2023-09-20 06:45:27 -07:00
vdso.h riscv: alternative: patch alternatives in the vDSO 2023-01-31 23:29:42 -08:00
vector.h RISC-V: vector: export VLENB csr in __sc_riscv_v_state 2023-08-22 13:55:12 -07:00
vendorid_list.h riscv: asm: vendorid_list: Add Andes Technology to the vendors list 2023-09-01 09:08:55 -07:00
vermagic.h
vmalloc.h Revert "riscv: mm: support Svnapot in huge vmap" 2024-03-06 14:48:38 +00:00
word-at-a-time.h
xip_fixup.h riscv: Fixed wrong register in XIP_FIXUP_FLASH_OFFSET macro 2024-01-25 15:35:50 -08:00