Merge branch 'akpm' (patches from Andrew)
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Jun 2020 16:54:46 +0000 (09:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Jun 2020 16:54:46 +0000 (09:54 -0700)
Merge even more updates from Andrew Morton:

 - a kernel-wide sweep of show_stack()

 - pagetable cleanups

 - abstract out accesses to mmap_sem - prep for mmap_sem scalability work

 - hch's user acess work

Subsystems affected by this patch series: debug, mm/pagemap, mm/maccess,
mm/documentation.

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (93 commits)
  include/linux/cache.h: expand documentation over __read_mostly
  maccess: return -ERANGE when probe_kernel_read() fails
  x86: use non-set_fs based maccess routines
  maccess: allow architectures to provide kernel probing directly
  maccess: move user access routines together
  maccess: always use strict semantics for probe_kernel_read
  maccess: remove strncpy_from_unsafe
  tracing/kprobes: handle mixed kernel/userspace probes better
  bpf: rework the compat kernel probe handling
  bpf:bpf_seq_printf(): handle potentially unsafe format string better
  bpf: handle the compat string in bpf_trace_copy_string better
  bpf: factor out a bpf_trace_copy_string helper
  maccess: unify the probe kernel arch hooks
  maccess: remove probe_read_common and probe_write_common
  maccess: rename strnlen_unsafe_user to strnlen_user_nofault
  maccess: rename strncpy_from_unsafe_strict to strncpy_from_kernel_nofault
  maccess: rename strncpy_from_unsafe_user to strncpy_from_user_nofault
  maccess: update the top of file comment
  maccess: clarify kerneldoc comments
  maccess: remove duplicate kerneldoc comments
  ...

941 files changed:
Documentation/admin-guide/mm/numa_memory_policy.rst
Documentation/admin-guide/mm/userfaultfd.rst
Documentation/filesystems/locking.rst
Documentation/vm/hmm.rst
Documentation/vm/transhuge.rst
arch/alpha/boot/bootp.c
arch/alpha/boot/bootpz.c
arch/alpha/boot/main.c
arch/alpha/include/asm/io.h
arch/alpha/include/asm/pgtable.h
arch/alpha/kernel/process.c
arch/alpha/kernel/proto.h
arch/alpha/kernel/ptrace.c
arch/alpha/kernel/setup.c
arch/alpha/kernel/smp.c
arch/alpha/kernel/sys_alcor.c
arch/alpha/kernel/sys_cabriolet.c
arch/alpha/kernel/sys_dp264.c
arch/alpha/kernel/sys_eb64p.c
arch/alpha/kernel/sys_eiger.c
arch/alpha/kernel/sys_jensen.c
arch/alpha/kernel/sys_marvel.c
arch/alpha/kernel/sys_miata.c
arch/alpha/kernel/sys_mikasa.c
arch/alpha/kernel/sys_nautilus.c
arch/alpha/kernel/sys_noritake.c
arch/alpha/kernel/sys_rawhide.c
arch/alpha/kernel/sys_ruffian.c
arch/alpha/kernel/sys_rx164.c
arch/alpha/kernel/sys_sable.c
arch/alpha/kernel/sys_sio.c
arch/alpha/kernel/sys_sx164.c
arch/alpha/kernel/sys_takara.c
arch/alpha/kernel/sys_titan.c
arch/alpha/kernel/sys_wildfire.c
arch/alpha/kernel/traps.c
arch/alpha/mm/fault.c
arch/alpha/mm/init.c
arch/arc/include/asm/bug.h
arch/arc/include/asm/pgtable.h
arch/arc/kernel/process.c
arch/arc/kernel/stacktrace.c
arch/arc/kernel/troubleshoot.c
arch/arc/mm/fault.c
arch/arc/mm/highmem.c
arch/arc/mm/tlbex.S
arch/arm/include/asm/bug.h
arch/arm/include/asm/efi.h
arch/arm/include/asm/fixmap.h
arch/arm/include/asm/idmap.h
arch/arm/include/asm/pgtable-2level.h
arch/arm/include/asm/pgtable-3level.h
arch/arm/include/asm/pgtable-nommu.h
arch/arm/include/asm/pgtable.h
arch/arm/include/asm/traps.h
arch/arm/include/asm/unwind.h
arch/arm/kernel/head.S
arch/arm/kernel/machine_kexec.c
arch/arm/kernel/module.c
arch/arm/kernel/process.c
arch/arm/kernel/ptrace.c
arch/arm/kernel/smp.c
arch/arm/kernel/suspend.c
arch/arm/kernel/swp_emulate.c
arch/arm/kernel/traps.c
arch/arm/kernel/unwind.c
arch/arm/kernel/vdso.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/lib/backtrace-clang.S
arch/arm/lib/backtrace.S
arch/arm/lib/uaccess_with_memcpy.c
arch/arm/mach-ebsa110/core.c
arch/arm/mach-footbridge/common.c
arch/arm/mach-imx/mm-imx21.c
arch/arm/mach-imx/mm-imx27.c
arch/arm/mach-imx/mm-imx3.c
arch/arm/mach-integrator/core.c
arch/arm/mach-iop32x/i2c.c
arch/arm/mach-iop32x/iq31244.c
arch/arm/mach-iop32x/iq80321.c
arch/arm/mach-iop32x/n2100.c
arch/arm/mach-ixp4xx/common.c
arch/arm/mach-keystone/platsmp.c
arch/arm/mach-sa1100/assabet.c
arch/arm/mach-sa1100/hackkit.c
arch/arm/mach-tegra/iomap.h
arch/arm/mach-zynq/common.c
arch/arm/mm/copypage-v4mc.c
arch/arm/mm/copypage-v6.c
arch/arm/mm/copypage-xscale.c
arch/arm/mm/dump.c
arch/arm/mm/fault-armv.c
arch/arm/mm/fault.c
arch/arm/mm/highmem.c
arch/arm/mm/idmap.c
arch/arm/mm/ioremap.c
arch/arm/mm/mm.h
arch/arm/mm/mmu.c
arch/arm/mm/pageattr.c
arch/arm/mm/proc-arm1020.S
arch/arm/mm/proc-arm1020e.S
arch/arm/mm/proc-arm1022.S
arch/arm/mm/proc-arm1026.S
arch/arm/mm/proc-arm720.S
arch/arm/mm/proc-arm740.S
arch/arm/mm/proc-arm7tdmi.S
arch/arm/mm/proc-arm920.S
arch/arm/mm/proc-arm922.S
arch/arm/mm/proc-arm925.S
arch/arm/mm/proc-arm926.S
arch/arm/mm/proc-arm940.S
arch/arm/mm/proc-arm946.S
arch/arm/mm/proc-arm9tdmi.S
arch/arm/mm/proc-fa526.S
arch/arm/mm/proc-feroceon.S
arch/arm/mm/proc-mohawk.S
arch/arm/mm/proc-sa110.S
arch/arm/mm/proc-sa1100.S
arch/arm/mm/proc-v6.S
arch/arm/mm/proc-v7.S
arch/arm/mm/proc-xsc3.S
arch/arm/mm/proc-xscale.S
arch/arm/mm/pv-fixup-asm.S
arch/arm64/include/asm/io.h
arch/arm64/include/asm/kernel-pgtable.h
arch/arm64/include/asm/kvm_mmu.h
arch/arm64/include/asm/mmu_context.h
arch/arm64/include/asm/pgtable.h
arch/arm64/include/asm/stacktrace.h
arch/arm64/include/asm/stage2_pgtable.h
arch/arm64/include/asm/vmap_stack.h
arch/arm64/kernel/acpi.c
arch/arm64/kernel/head.S
arch/arm64/kernel/hibernate.c
arch/arm64/kernel/kaslr.c
arch/arm64/kernel/process.c
arch/arm64/kernel/ptrace.c
arch/arm64/kernel/smp.c
arch/arm64/kernel/suspend.c
arch/arm64/kernel/traps.c
arch/arm64/kernel/vdso.c
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/kvm/mmu.c
arch/arm64/mm/dump.c
arch/arm64/mm/fault.c
arch/arm64/mm/kasan_init.c
arch/arm64/mm/mmu.c
arch/arm64/mm/pageattr.c
arch/arm64/mm/proc.S
arch/c6x/include/asm/pgtable.h
arch/c6x/kernel/traps.c
arch/csky/include/asm/io.h
arch/csky/include/asm/pgtable.h
arch/csky/kernel/module.c
arch/csky/kernel/ptrace.c
arch/csky/kernel/stacktrace.c
arch/csky/kernel/vdso.c
arch/csky/mm/fault.c
arch/csky/mm/highmem.c
arch/csky/mm/init.c
arch/csky/mm/tlb.c
arch/h8300/include/asm/pgtable.h
arch/h8300/kernel/process.c
arch/h8300/kernel/setup.c
arch/h8300/kernel/signal.c
arch/h8300/kernel/traps.c
arch/h8300/mm/fault.c
arch/h8300/mm/init.c
arch/h8300/mm/memory.c
arch/hexagon/include/asm/fixmap.h
arch/hexagon/include/asm/pgtable.h
arch/hexagon/kernel/traps.c
arch/hexagon/kernel/vdso.c
arch/hexagon/mm/uaccess.c
arch/hexagon/mm/vm_fault.c
arch/ia64/include/asm/pgtable.h
arch/ia64/include/asm/ptrace.h
arch/ia64/include/asm/uaccess.h
arch/ia64/kernel/efi.c
arch/ia64/kernel/entry.S
arch/ia64/kernel/head.S
arch/ia64/kernel/irq_ia64.c
arch/ia64/kernel/ivt.S
arch/ia64/kernel/kprobes.c
arch/ia64/kernel/mca.c
arch/ia64/kernel/mca_asm.S
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/process.c
arch/ia64/kernel/ptrace.c
arch/ia64/kernel/relocate_kernel.S
arch/ia64/kernel/setup.c
arch/ia64/kernel/smp.c
arch/ia64/kernel/smpboot.c
arch/ia64/kernel/uncached.c
arch/ia64/kernel/vmlinux.lds.S
arch/ia64/mm/contig.c
arch/ia64/mm/fault.c
arch/ia64/mm/init.c
arch/m68k/68000/m68EZ328.c
arch/m68k/68000/m68VZ328.c
arch/m68k/68000/timers.c
arch/m68k/amiga/config.c
arch/m68k/apollo/config.c
arch/m68k/atari/atasound.c
arch/m68k/atari/stram.c
arch/m68k/bvme6000/config.c
arch/m68k/include/asm/mcf_pgtable.h
arch/m68k/include/asm/motorola_pgalloc.h
arch/m68k/include/asm/motorola_pgtable.h
arch/m68k/include/asm/pgtable_mm.h
arch/m68k/include/asm/pgtable_no.h
arch/m68k/include/asm/sun3_pgtable.h
arch/m68k/include/asm/sun3xflop.h
arch/m68k/kernel/head.S
arch/m68k/kernel/process.c
arch/m68k/kernel/ptrace.c
arch/m68k/kernel/setup_no.c
arch/m68k/kernel/signal.c
arch/m68k/kernel/sys_m68k.c
arch/m68k/kernel/traps.c
arch/m68k/kernel/uboot.c
arch/m68k/mac/config.c
arch/m68k/mm/fault.c
arch/m68k/mm/init.c
arch/m68k/mm/mcfmmu.c
arch/m68k/mm/motorola.c
arch/m68k/mm/sun3kmap.c
arch/m68k/mm/sun3mmu.c
arch/m68k/mvme147/config.c
arch/m68k/mvme16x/config.c
arch/m68k/q40/config.c
arch/m68k/sun3/config.c
arch/m68k/sun3/dvma.c
arch/m68k/sun3/mmu_emu.c
arch/m68k/sun3/sun3dvma.c
arch/m68k/sun3x/dvma.c
arch/m68k/sun3x/prom.c
arch/microblaze/include/asm/pgalloc.h
arch/microblaze/include/asm/pgtable.h
arch/microblaze/include/asm/uaccess.h
arch/microblaze/include/asm/unwind.h
arch/microblaze/kernel/hw_exception_handler.S
arch/microblaze/kernel/module.c
arch/microblaze/kernel/setup.c
arch/microblaze/kernel/signal.c
arch/microblaze/kernel/stacktrace.c
arch/microblaze/kernel/traps.c
arch/microblaze/kernel/unwind.c
arch/microblaze/mm/fault.c
arch/microblaze/mm/init.c
arch/microblaze/mm/pgtable.c
arch/mips/fw/arc/memory.c
arch/mips/include/asm/fixmap.h
arch/mips/include/asm/mach-generic/floppy.h
arch/mips/include/asm/mach-jazz/floppy.h
arch/mips/include/asm/pgtable-32.h
arch/mips/include/asm/pgtable-64.h
arch/mips/include/asm/pgtable.h
arch/mips/jazz/irq.c
arch/mips/jazz/jazzdma.c
arch/mips/jazz/setup.c
arch/mips/kernel/module.c
arch/mips/kernel/process.c
arch/mips/kernel/ptrace.c
arch/mips/kernel/ptrace32.c
arch/mips/kernel/smp-bmips.c
arch/mips/kernel/traps.c
arch/mips/kernel/vdso.c
arch/mips/kvm/mips.c
arch/mips/kvm/mmu.c
arch/mips/kvm/tlb.c
arch/mips/kvm/trap_emul.c
arch/mips/lib/dump_tlb.c
arch/mips/lib/r3k_dump_tlb.c
arch/mips/mm/c-octeon.c
arch/mips/mm/c-r3k.c
arch/mips/mm/c-r4k.c
arch/mips/mm/c-tx39.c
arch/mips/mm/fault.c
arch/mips/mm/highmem.c
arch/mips/mm/init.c
arch/mips/mm/page.c
arch/mips/mm/pgtable-32.c
arch/mips/mm/pgtable-64.c
arch/mips/mm/sc-ip22.c
arch/mips/mm/sc-mips.c
arch/mips/mm/sc-r5k.c
arch/mips/mm/tlb-r3k.c
arch/mips/mm/tlb-r4k.c
arch/mips/mm/tlbex.c
arch/mips/sgi-ip27/ip27-init.c
arch/mips/sgi-ip27/ip27-timer.c
arch/mips/sgi-ip32/ip32-memory.c
arch/nds32/include/asm/highmem.h
arch/nds32/include/asm/pgtable.h
arch/nds32/kernel/head.S
arch/nds32/kernel/module.c
arch/nds32/kernel/traps.c
arch/nds32/kernel/vdso.c
arch/nds32/mm/fault.c
arch/nds32/mm/init.c
arch/nds32/mm/proc.c
arch/nios2/include/asm/pgtable.h
arch/nios2/kernel/module.c
arch/nios2/kernel/nios2_ksyms.c
arch/nios2/kernel/traps.c
arch/nios2/mm/fault.c
arch/nios2/mm/init.c
arch/nios2/mm/pgtable.c
arch/nios2/mm/tlb.c
arch/openrisc/include/asm/io.h
arch/openrisc/include/asm/pgtable.h
arch/openrisc/include/asm/tlbflush.h
arch/openrisc/kernel/asm-offsets.c
arch/openrisc/kernel/entry.S
arch/openrisc/kernel/head.S
arch/openrisc/kernel/or32_ksyms.c
arch/openrisc/kernel/process.c
arch/openrisc/kernel/ptrace.c
arch/openrisc/kernel/setup.c
arch/openrisc/kernel/traps.c
arch/openrisc/mm/fault.c
arch/openrisc/mm/init.c
arch/openrisc/mm/ioremap.c
arch/openrisc/mm/tlb.c
arch/parisc/include/asm/io.h
arch/parisc/include/asm/mmu_context.h
arch/parisc/include/asm/pgtable.h
arch/parisc/kernel/asm-offsets.c
arch/parisc/kernel/entry.S
arch/parisc/kernel/head.S
arch/parisc/kernel/module.c
arch/parisc/kernel/pacache.S
arch/parisc/kernel/pci-dma.c
arch/parisc/kernel/pdt.c
arch/parisc/kernel/ptrace.c
arch/parisc/kernel/smp.c
arch/parisc/kernel/traps.c
arch/parisc/lib/memcpy.c
arch/parisc/mm/fault.c
arch/parisc/mm/fixmap.c
arch/parisc/mm/init.c
arch/powerpc/include/asm/book3s/32/pgtable.h
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/fixmap.h
arch/powerpc/include/asm/io.h
arch/powerpc/include/asm/kup.h
arch/powerpc/include/asm/nohash/32/pgtable.h
arch/powerpc/include/asm/nohash/64/pgtable-4k.h
arch/powerpc/include/asm/nohash/64/pgtable.h
arch/powerpc/include/asm/nohash/pgtable.h
arch/powerpc/include/asm/pgtable.h
arch/powerpc/include/asm/pkeys.h
arch/powerpc/include/asm/tlb.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kernel/btext.c
arch/powerpc/kernel/fpu.S
arch/powerpc/kernel/head_32.S
arch/powerpc/kernel/head_40x.S
arch/powerpc/kernel/head_44x.S
arch/powerpc/kernel/head_8xx.S
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/kernel/io-workarounds.c
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/mce_power.c
arch/powerpc/kernel/paca.c
arch/powerpc/kernel/process.c
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/prom_init.c
arch/powerpc/kernel/rtas_pci.c
arch/powerpc/kernel/setup-common.c
arch/powerpc/kernel/setup_32.c
arch/powerpc/kernel/setup_64.c
arch/powerpc/kernel/signal_32.c
arch/powerpc/kernel/signal_64.c
arch/powerpc/kernel/smp.c
arch/powerpc/kernel/stacktrace.c
arch/powerpc/kernel/traps.c
arch/powerpc/kernel/vdso.c
arch/powerpc/kvm/book3s_64_mmu_radix.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_nested.c
arch/powerpc/kvm/book3s_hv_rm_xics.c
arch/powerpc/kvm/book3s_hv_rm_xive.c
arch/powerpc/kvm/book3s_hv_uvmem.c
arch/powerpc/kvm/e500_mmu_host.c
arch/powerpc/kvm/fpu.S
arch/powerpc/lib/code-patching.c
arch/powerpc/mm/book3s32/hash_low.S
arch/powerpc/mm/book3s32/mmu.c
arch/powerpc/mm/book3s32/tlb.c
arch/powerpc/mm/book3s64/hash_hugetlbpage.c
arch/powerpc/mm/book3s64/hash_native.c
arch/powerpc/mm/book3s64/hash_pgtable.c
arch/powerpc/mm/book3s64/hash_utils.c
arch/powerpc/mm/book3s64/iommu_api.c
arch/powerpc/mm/book3s64/radix_hugetlbpage.c
arch/powerpc/mm/book3s64/radix_pgtable.c
arch/powerpc/mm/book3s64/slb.c
arch/powerpc/mm/book3s64/subpage_prot.c
arch/powerpc/mm/copro_fault.c
arch/powerpc/mm/fault.c
arch/powerpc/mm/hugetlbpage.c
arch/powerpc/mm/init-common.c
arch/powerpc/mm/init_32.c
arch/powerpc/mm/init_64.c
arch/powerpc/mm/kasan/8xx.c
arch/powerpc/mm/kasan/book3s_32.c
arch/powerpc/mm/kasan/kasan_init_32.c
arch/powerpc/mm/mem.c
arch/powerpc/mm/nohash/40x.c
arch/powerpc/mm/nohash/8xx.c
arch/powerpc/mm/nohash/fsl_booke.c
arch/powerpc/mm/nohash/tlb_low_64e.S
arch/powerpc/mm/pgtable.c
arch/powerpc/mm/pgtable_32.c
arch/powerpc/mm/pgtable_64.c
arch/powerpc/mm/ptdump/8xx.c
arch/powerpc/mm/ptdump/bats.c
arch/powerpc/mm/ptdump/book3s64.c
arch/powerpc/mm/ptdump/hashpagetable.c
arch/powerpc/mm/ptdump/ptdump.c
arch/powerpc/mm/ptdump/shared.c
arch/powerpc/oprofile/cell/spu_task_sync.c
arch/powerpc/perf/callchain.c
arch/powerpc/perf/callchain_32.c
arch/powerpc/perf/callchain_64.c
arch/powerpc/platforms/85xx/corenet_generic.c
arch/powerpc/platforms/85xx/mpc85xx_cds.c
arch/powerpc/platforms/85xx/qemu_e500.c
arch/powerpc/platforms/85xx/sbc8548.c
arch/powerpc/platforms/85xx/smp.c
arch/powerpc/platforms/86xx/mpc86xx_smp.c
arch/powerpc/platforms/8xx/cpm1.c
arch/powerpc/platforms/8xx/micropatch.c
arch/powerpc/platforms/cell/cbe_regs.c
arch/powerpc/platforms/cell/interrupt.c
arch/powerpc/platforms/cell/pervasive.c
arch/powerpc/platforms/cell/setup.c
arch/powerpc/platforms/cell/smp.c
arch/powerpc/platforms/cell/spider-pic.c
arch/powerpc/platforms/cell/spufs/file.c
arch/powerpc/platforms/chrp/pci.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/chrp/smp.c
arch/powerpc/platforms/maple/setup.c
arch/powerpc/platforms/maple/time.c
arch/powerpc/platforms/powermac/setup.c
arch/powerpc/platforms/powermac/smp.c
arch/powerpc/platforms/powermac/time.c
arch/powerpc/platforms/pseries/lpar.c
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/platforms/pseries/smp.c
arch/powerpc/sysdev/cpm2.c
arch/powerpc/sysdev/fsl_85xx_cache_sram.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/xmon/xmon.c
arch/riscv/include/asm/fixmap.h
arch/riscv/include/asm/io.h
arch/riscv/include/asm/kasan.h
arch/riscv/include/asm/pgtable-64.h
arch/riscv/include/asm/pgtable.h
arch/riscv/kernel/module.c
arch/riscv/kernel/setup.c
arch/riscv/kernel/soc.c
arch/riscv/kernel/stacktrace.c
arch/riscv/kernel/vdso.c
arch/riscv/mm/cacheflush.c
arch/riscv/mm/fault.c
arch/riscv/mm/init.c
arch/riscv/mm/kasan_init.c
arch/riscv/mm/pageattr.c
arch/riscv/mm/ptdump.c
arch/s390/boot/ipl_parm.c
arch/s390/boot/kaslr.c
arch/s390/include/asm/hugetlb.h
arch/s390/include/asm/kasan.h
arch/s390/include/asm/pgtable.h
arch/s390/include/asm/tlbflush.h
arch/s390/kernel/asm-offsets.c
arch/s390/kernel/dumpstack.c
arch/s390/kernel/machine_kexec.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/uv.c
arch/s390/kernel/vdso.c
arch/s390/kvm/gaccess.c
arch/s390/kvm/interrupt.c
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/priv.c
arch/s390/mm/dump_pagetables.c
arch/s390/mm/extmem.c
arch/s390/mm/fault.c
arch/s390/mm/gmap.c
arch/s390/mm/init.c
arch/s390/mm/kasan_init.c
arch/s390/mm/pageattr.c
arch/s390/mm/pgalloc.c
arch/s390/mm/pgtable.c
arch/s390/mm/vmem.c
arch/s390/pci/pci_mmio.c
arch/sh/include/asm/io.h
arch/sh/include/asm/kdebug.h
arch/sh/include/asm/pgtable-3level.h
arch/sh/include/asm/pgtable.h
arch/sh/include/asm/pgtable_32.h
arch/sh/include/asm/processor_32.h
arch/sh/kernel/dumpstack.c
arch/sh/kernel/machine_kexec.c
arch/sh/kernel/process_32.c
arch/sh/kernel/ptrace_32.c
arch/sh/kernel/signal_32.c
arch/sh/kernel/sys_sh.c
arch/sh/kernel/traps.c
arch/sh/kernel/vsyscall/vsyscall.c
arch/sh/mm/cache-sh3.c
arch/sh/mm/cache-sh4.c
arch/sh/mm/cache-sh7705.c
arch/sh/mm/fault.c
arch/sh/mm/kmap.c
arch/sh/mm/nommu.c
arch/sh/mm/pmb.c
arch/sparc/include/asm/floppy_32.h
arch/sparc/include/asm/highmem.h
arch/sparc/include/asm/ide.h
arch/sparc/include/asm/io-unit.h
arch/sparc/include/asm/pgalloc_32.h
arch/sparc/include/asm/pgalloc_64.h
arch/sparc/include/asm/pgtable_32.h
arch/sparc/include/asm/pgtable_64.h
arch/sparc/kernel/cpu.c
arch/sparc/kernel/entry.S
arch/sparc/kernel/head_64.S
arch/sparc/kernel/ktlb.S
arch/sparc/kernel/leon_smp.c
arch/sparc/kernel/pci.c
arch/sparc/kernel/process_32.c
arch/sparc/kernel/process_64.c
arch/sparc/kernel/ptrace_32.c
arch/sparc/kernel/ptrace_64.c
arch/sparc/kernel/setup_32.c
arch/sparc/kernel/setup_64.c
arch/sparc/kernel/signal32.c
arch/sparc/kernel/signal_32.c
arch/sparc/kernel/signal_64.c
arch/sparc/kernel/smp_32.c
arch/sparc/kernel/smp_64.c
arch/sparc/kernel/sun4m_irq.c
arch/sparc/kernel/trampoline_64.S
arch/sparc/kernel/traps_32.c
arch/sparc/kernel/traps_64.c
arch/sparc/lib/clear_page.S
arch/sparc/lib/copy_page.S
arch/sparc/mm/fault_32.c
arch/sparc/mm/fault_64.c
arch/sparc/mm/highmem.c
arch/sparc/mm/hugetlbpage.c
arch/sparc/mm/init_32.c
arch/sparc/mm/init_64.c
arch/sparc/mm/io-unit.c
arch/sparc/mm/iommu.c
arch/sparc/mm/tlb.c
arch/sparc/mm/tsb.c
arch/sparc/mm/ultra.S
arch/sparc/vdso/vma.c
arch/um/drivers/mconsole_kern.c
arch/um/include/asm/mmu_context.h
arch/um/include/asm/pgtable-3level.h
arch/um/include/asm/pgtable.h
arch/um/kernel/maccess.c
arch/um/kernel/mem.c
arch/um/kernel/process.c
arch/um/kernel/skas/mmu.c
arch/um/kernel/skas/uaccess.c
arch/um/kernel/sysrq.c
arch/um/kernel/tlb.c
arch/um/kernel/trap.c
arch/um/kernel/um_arch.c
arch/unicore32/include/asm/pgtable.h
arch/unicore32/kernel/hibernate.c
arch/unicore32/kernel/hibernate_asm.S
arch/unicore32/kernel/module.c
arch/unicore32/kernel/setup.h
arch/unicore32/kernel/traps.c
arch/unicore32/lib/backtrace.S
arch/unicore32/mm/alignment.c
arch/unicore32/mm/fault.c
arch/unicore32/mm/mm.h
arch/unicore32/mm/proc-ucv2.S
arch/x86/boot/compressed/kaslr_64.c
arch/x86/entry/vdso/vma.c
arch/x86/events/core.c
arch/x86/include/asm/agp.h
arch/x86/include/asm/asm-prototypes.h
arch/x86/include/asm/efi.h
arch/x86/include/asm/iomap.h
arch/x86/include/asm/kaslr.h
arch/x86/include/asm/mmu.h
arch/x86/include/asm/pgtable-3level.h
arch/x86/include/asm/pgtable.h
arch/x86/include/asm/pgtable_32.h
arch/x86/include/asm/pgtable_64.h
arch/x86/include/asm/setup.h
arch/x86/include/asm/stacktrace.h
arch/x86/include/asm/uaccess.h
arch/x86/include/asm/xen/hypercall.h
arch/x86/include/asm/xen/page.h
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/acpi/sleep.c
arch/x86/kernel/alternative.c
arch/x86/kernel/amd_gart_64.c
arch/x86/kernel/apic/apic_numachip.c
arch/x86/kernel/cpu/bugs.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/cpu/resctrl/pseudo_lock.c
arch/x86/kernel/cpu/resctrl/rdtgroup.c
arch/x86/kernel/crash_core_32.c
arch/x86/kernel/crash_core_64.c
arch/x86/kernel/doublefault_32.c
arch/x86/kernel/dumpstack.c
arch/x86/kernel/early_printk.c
arch/x86/kernel/espfix_64.c
arch/x86/kernel/head64.c
arch/x86/kernel/head_64.S
arch/x86/kernel/i8259.c
arch/x86/kernel/irqinit.c
arch/x86/kernel/kprobes/core.c
arch/x86/kernel/kprobes/opt.c
arch/x86/kernel/ldt.c
arch/x86/kernel/machine_kexec_32.c
arch/x86/kernel/machine_kexec_64.c
arch/x86/kernel/module.c
arch/x86/kernel/paravirt.c
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
arch/x86/kernel/ptrace.c
arch/x86/kernel/reboot.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/tboot.c
arch/x86/kernel/vm86_32.c
arch/x86/kvm/mmu/paging_tmpl.h
arch/x86/mm/cpu_entry_area.c
arch/x86/mm/debug_pagetables.c
arch/x86/mm/dump_pagetables.c
arch/x86/mm/fault.c
arch/x86/mm/init.c
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
arch/x86/mm/ioremap.c
arch/x86/mm/kasan_init_64.c
arch/x86/mm/kaslr.c
arch/x86/mm/maccess.c
arch/x86/mm/mem_encrypt_boot.S
arch/x86/mm/mmio-mod.c
arch/x86/mm/pat/cpa-test.c
arch/x86/mm/pat/memtype.c
arch/x86/mm/pat/memtype_interval.c
arch/x86/mm/pgtable.c
arch/x86/mm/pgtable_32.c
arch/x86/mm/pti.c
arch/x86/mm/setup_nx.c
arch/x86/platform/efi/efi_32.c
arch/x86/platform/efi/efi_64.c
arch/x86/platform/olpc/olpc_ofw.c
arch/x86/power/cpu.c
arch/x86/power/hibernate.c
arch/x86/power/hibernate_32.c
arch/x86/power/hibernate_64.c
arch/x86/realmode/init.c
arch/x86/um/vdso/vma.c
arch/x86/xen/enlighten_pv.c
arch/x86/xen/grant-table.c
arch/x86/xen/mmu_pv.c
arch/x86/xen/smp_pv.c
arch/xtensa/include/asm/fixmap.h
arch/xtensa/include/asm/highmem.h
arch/xtensa/include/asm/initialize_mmu.h
arch/xtensa/include/asm/mmu_context.h
arch/xtensa/include/asm/pgtable.h
arch/xtensa/kernel/entry.S
arch/xtensa/kernel/process.c
arch/xtensa/kernel/ptrace.c
arch/xtensa/kernel/setup.c
arch/xtensa/kernel/traps.c
arch/xtensa/kernel/vectors.S
arch/xtensa/mm/cache.c
arch/xtensa/mm/fault.c
arch/xtensa/mm/highmem.c
arch/xtensa/mm/ioremap.c
arch/xtensa/mm/kasan_init.c
arch/xtensa/mm/misc.S
arch/xtensa/mm/mmu.c
drivers/acpi/scan.c
drivers/android/binder_alloc.c
drivers/atm/fore200e.c
drivers/base/power/main.c
drivers/block/z2ram.c
drivers/char/agp/frontend.c
drivers/char/agp/generic.c
drivers/char/bsr.c
drivers/char/mspec.c
drivers/dma-buf/dma-resv.c
drivers/firmware/efi/arm-runtime.c
drivers/firmware/efi/efi.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdkfd/kfd_events.c
drivers/gpu/drm/drm_vm.c
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/gpu/drm/i915/gem/i915_gem_mman.c
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
drivers/gpu/drm/i915/i915_mm.c
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/nouveau/nouveau_svm.c
drivers/gpu/drm/radeon/radeon_cs.c
drivers/gpu/drm/radeon/radeon_gem.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
drivers/infiniband/core/umem_odp.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/hfi1/mmu_rb.c
drivers/infiniband/hw/mlx4/mr.c
drivers/infiniband/hw/qib/qib_file_ops.c
drivers/infiniband/hw/qib/qib_user_pages.c
drivers/infiniband/hw/usnic/usnic_uiom.c
drivers/infiniband/sw/rdmavt/mmap.c
drivers/infiniband/sw/rxe/rxe_mmap.c
drivers/infiniband/sw/siw/siw_mem.c
drivers/iommu/amd_iommu_v2.c
drivers/iommu/intel-svm.c
drivers/macintosh/macio-adb.c
drivers/macintosh/mediabay.c
drivers/macintosh/via-pmu.c
drivers/media/pci/bt8xx/bt878.c
drivers/media/pci/bt8xx/btcx-risc.c
drivers/media/pci/bt8xx/bttv-risc.c
drivers/media/platform/davinci/vpbe_display.c
drivers/media/v4l2-core/v4l2-common.c
drivers/media/v4l2-core/videobuf-core.c
drivers/media/v4l2-core/videobuf-dma-contig.c
drivers/media/v4l2-core/videobuf-dma-sg.c
drivers/media/v4l2-core/videobuf-vmalloc.c
drivers/misc/cxl/cxllib.c
drivers/misc/cxl/fault.c
drivers/misc/genwqe/card_utils.c
drivers/misc/sgi-gru/grufault.c
drivers/misc/sgi-gru/grufile.c
drivers/mtd/ubi/ubi.h
drivers/net/ethernet/amd/7990.c
drivers/net/ethernet/amd/hplance.c
drivers/net/ethernet/amd/mvme147.c
drivers/net/ethernet/amd/sun3lance.c
drivers/net/ethernet/amd/sunlance.c
drivers/net/ethernet/apple/bmac.c
drivers/net/ethernet/apple/mace.c
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
drivers/net/ethernet/freescale/fs_enet/mac-fcc.c
drivers/net/ethernet/freescale/fs_enet/mii-fec.c
drivers/net/ethernet/i825xx/82596.c
drivers/net/ethernet/korina.c
drivers/net/ethernet/marvell/pxa168_eth.c
drivers/net/ethernet/natsemi/jazzsonic.c
drivers/net/ethernet/natsemi/macsonic.c
drivers/net/ethernet/natsemi/xtsonic.c
drivers/net/ethernet/sun/sunbmac.c
drivers/net/ethernet/sun/sunhme.c
drivers/net/ethernet/sun/sunqe.c
drivers/oprofile/buffer_sync.c
drivers/sbus/char/flash.c
drivers/sbus/char/uctrl.c
drivers/scsi/53c700.c
drivers/scsi/a2091.c
drivers/scsi/a3000.c
drivers/scsi/arm/cumana_2.c
drivers/scsi/arm/eesox.c
drivers/scsi/arm/powertec.c
drivers/scsi/dpt_i2o.c
drivers/scsi/gvp11.c
drivers/scsi/lasi700.c
drivers/scsi/mac53c94.c
drivers/scsi/mesh.c
drivers/scsi/mvme147.c
drivers/scsi/qlogicpti.c
drivers/scsi/sni_53c710.c
drivers/scsi/zorro_esp.c
drivers/staging/android/ashmem.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/kpc2000/kpc_dma/fileops.c
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
drivers/tee/optee/call.c
drivers/tty/sysrq.c
drivers/tty/vt/consolemap.c
drivers/vfio/pci/vfio_pci.c
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/vdpa.c
drivers/video/console/newport_con.c
drivers/video/fbdev/acornfb.c
drivers/video/fbdev/atafb.c
drivers/video/fbdev/cirrusfb.c
drivers/video/fbdev/cyber2000fb.c
drivers/video/fbdev/fb-puv3.c
drivers/video/fbdev/hitfb.c
drivers/video/fbdev/neofb.c
drivers/video/fbdev/q40fb.c
drivers/video/fbdev/savage/savagefb_driver.c
drivers/xen/balloon.c
drivers/xen/gntdev.c
drivers/xen/grant-table.c
drivers/xen/privcmd.c
drivers/xen/xenbus/xenbus_probe.c
drivers/xen/xenbus/xenbus_probe_backend.c
drivers/xen/xenbus/xenbus_probe_frontend.c
fs/aio.c
fs/coredump.c
fs/exec.c
fs/ext2/file.c
fs/ext4/super.c
fs/hugetlbfs/inode.c
fs/io_uring.c
fs/kernfs/file.c
fs/proc/array.c
fs/proc/base.c
fs/proc/meminfo.c
fs/proc/nommu.c
fs/proc/task_mmu.c
fs/proc/task_nommu.c
fs/proc/vmcore.c
fs/userfaultfd.c
fs/xfs/xfs_file.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_iops.c
include/asm-generic/io.h
include/asm-generic/pgtable-nopmd.h
include/asm-generic/pgtable-nopud.h
include/linux/cache.h
include/linux/crash_dump.h
include/linux/dax.h
include/linux/dma-noncoherent.h
include/linux/fs.h
include/linux/hmm.h
include/linux/huge_mm.h
include/linux/hugetlb.h
include/linux/io-mapping.h
include/linux/kallsyms.h
include/linux/kasan.h
include/linux/mempolicy.h
include/linux/mm.h
include/linux/mm_types.h
include/linux/mmap_lock.h [new file with mode: 0644]
include/linux/mmu_notifier.h
include/linux/pagemap.h
include/linux/pgtable.h [moved from include/asm-generic/pgtable.h with 91% similarity]
include/linux/rmap.h
include/linux/sched/debug.h
include/linux/sched/mm.h
include/linux/uaccess.h
include/xen/arm/page.h
init/init_task.c
ipc/shm.c
kernel/acct.c
kernel/bpf/stackmap.c
kernel/bpf/syscall.c
kernel/cgroup/cpuset.c
kernel/debug/kdb/kdb_bt.c
kernel/events/core.c
kernel/events/uprobes.c
kernel/exit.c
kernel/fork.c
kernel/futex.c
kernel/locking/lockdep.c
kernel/locking/rtmutex-debug.c
kernel/power/snapshot.c
kernel/relay.c
kernel/sched/core.c
kernel/sched/fair.c
kernel/sys.c
kernel/trace/bpf_trace.c
kernel/trace/ftrace.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_output.c
lib/dump_stack.c
lib/ioremap.c
lib/test_hmm.c
lib/test_lockup.c
mm/debug.c
mm/debug_vm_pgtable.c
mm/filemap.c
mm/frame_vector.c
mm/gup.c
mm/hmm.c
mm/huge_memory.c
mm/hugetlb.c
mm/init-mm.c
mm/internal.h
mm/khugepaged.c
mm/ksm.c
mm/maccess.c
mm/madvise.c
mm/memcontrol.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/mincore.c
mm/mlock.c
mm/mmap.c
mm/mmu_gather.c
mm/mmu_notifier.c
mm/mprotect.c
mm/mremap.c
mm/msync.c
mm/nommu.c
mm/oom_kill.c
mm/page_io.c
mm/page_reporting.h
mm/pagewalk.c
mm/pgtable-generic.c
mm/process_vm_access.c
mm/ptdump.c
mm/rmap.c
mm/shmem.c
mm/sparse-vmemmap.c
mm/sparse.c
mm/swap_state.c
mm/swapfile.c
mm/userfaultfd.c
mm/util.c
mm/vmacache.c
mm/zsmalloc.c
net/ipv4/tcp.c
net/xdp/xdp_umem.c
security/keys/keyctl.c
sound/core/oss/pcm_oss.c
sound/core/sgbuf.c
sound/pci/hda/hda_intel.c
sound/soc/intel/common/sst-firmware.c
sound/soc/intel/haswell/sst-haswell-pcm.c
tools/include/linux/kallsyms.h
virt/kvm/async_pf.c
virt/kvm/kvm_main.c

index 8463f55..067a90a 100644 (file)
@@ -364,19 +364,19 @@ follows:
 
 2) for querying the policy, we do not need to take an extra reference on the
    target task's task policy nor vma policies because we always acquire the
-   task's mm's mmap_sem for read during the query.  The set_mempolicy() and
-   mbind() APIs [see below] always acquire the mmap_sem for write when
+   task's mm's mmap_lock for read during the query.  The set_mempolicy() and
+   mbind() APIs [see below] always acquire the mmap_lock for write when
    installing or replacing task or vma policies.  Thus, there is no possibility
    of a task or thread freeing a policy while another task or thread is
    querying it.
 
 3) Page allocation usage of task or vma policy occurs in the fault path where
-   we hold them mmap_sem for read.  Again, because replacing the task or vma
-   policy requires that the mmap_sem be held for write, the policy can't be
+   we hold them mmap_lock for read.  Again, because replacing the task or vma
+   policy requires that the mmap_lock be held for write, the policy can't be
    freed out from under us while we're using it for page allocation.
 
 4) Shared policies require special consideration.  One task can replace a
-   shared memory policy while another task, with a distinct mmap_sem, is
+   shared memory policy while another task, with a distinct mmap_lock, is
    querying or allocating a page based on the policy.  To resolve this
    potential race, the shared policy infrastructure adds an extra reference
    to the shared policy during lookup while holding a spin lock on the shared
index 0bf49d7..1dc2d5f 100644 (file)
@@ -33,7 +33,7 @@ memory ranges) provides two primary functionalities:
 The real advantage of userfaults if compared to regular virtual memory
 management of mremap/mprotect is that the userfaults in all their
 operations never involve heavyweight structures like vmas (in fact the
-``userfaultfd`` runtime load never takes the mmap_sem for writing).
+``userfaultfd`` runtime load never takes the mmap_lock for writing).
 
 Vmas are not suitable for page- (or hugepage) granular fault tracking
 when dealing with virtual address spaces that could span
index 0af2e0e..eb71156 100644 (file)
@@ -615,7 +615,7 @@ prototypes::
 locking rules:
 
 =============  ========        ===========================
-ops            mmap_sem        PageLocked(page)
+ops            mmap_lock       PageLocked(page)
 =============  ========        ===========================
 open:          yes
 close:         yes
index 5619697..6f9e000 100644 (file)
@@ -191,15 +191,15 @@ The usage pattern is::
 
  again:
       range.notifier_seq = mmu_interval_read_begin(&interval_sub);
-      down_read(&mm->mmap_sem);
+      mmap_read_lock(mm);
       ret = hmm_range_fault(&range);
       if (ret) {
-          up_read(&mm->mmap_sem);
+          mmap_read_unlock(mm);
           if (ret == -EBUSY)
                  goto again;
           return ret;
       }
-      up_read(&mm->mmap_sem);
+      mmap_read_unlock(mm);
 
       take_lock(driver->update);
       if (mmu_interval_read_retry(&ni, range.notifier_seq) {
index 37c57ca..0ed23e5 100644 (file)
@@ -98,9 +98,9 @@ split_huge_page() or split_huge_pmd() has a cost.
 
 To make pagetable walks huge pmd aware, all you need to do is to call
 pmd_trans_huge() on the pmd returned by pmd_offset. You must hold the
-mmap_sem in read (or write) mode to be sure a huge pmd cannot be
+mmap_lock in read (or write) mode to be sure a huge pmd cannot be
 created from under you by khugepaged (khugepaged collapse_huge_page
-takes the mmap_sem in write mode in addition to the anon_vma lock). If
+takes the mmap_lock in write mode in addition to the anon_vma lock). If
 pmd_trans_huge returns false, you just fallback in the old code
 paths. If instead pmd_trans_huge returns true, you have to take the
 page table lock (pmd_lock()) and re-run pmd_trans_huge. Taking the
index 95c0359..00266e6 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <asm/console.h>
 #include <asm/hwrpb.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 
 #include <stdarg.h>
index 99b8d7d..43af718 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <asm/console.h>
 #include <asm/hwrpb.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 
 #include <stdarg.h>
index 8f5ed86..e5347a0 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <asm/console.h>
 #include <asm/hwrpb.h>
-#include <asm/pgtable.h>
 
 #include <stdarg.h>
 
index d1ed5a8..13bea46 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <asm/compiler.h>
-#include <asm/pgtable.h>
 #include <asm/machvec.h>
 #include <asm/hwrpb.h>
 
index 0267aa8..162c17b 100644 (file)
@@ -276,15 +276,6 @@ extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_FOW; return
 extern inline pte_t pte_mkdirty(pte_t pte)     { pte_val(pte) |= __DIRTY_BITS; return pte; }
 extern inline pte_t pte_mkyoung(pte_t pte)     { pte_val(pte) |= __ACCESS_BITS; return pte; }
 
-#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, (address))
-
-/* to find an entry in a page-table-directory. */
-#define pgd_index(address)     (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-#define pgd_offset(mm, address)        ((mm)->pgd+pgd_index(address))
-
 /*
  * The smp_read_barrier_depends() in the following functions are required to
  * order the load of *dir (the pointer in the top level page table) with any
@@ -305,6 +296,7 @@ extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
        smp_read_barrier_depends(); /* see above */
        return ret;
 }
+#define pmd_offset pmd_offset
 
 /* Find an entry in the third-level page table.. */
 extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address)
@@ -314,9 +306,7 @@ extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address)
        smp_read_barrier_depends(); /* see above */
        return ret;
 }
-
-#define pte_offset_map(dir,addr)       pte_offset_kernel((dir),(addr))
-#define pte_unmap(pte)                 do { } while (0)
+#define pte_offset_kernel pte_offset_kernel
 
 extern pgd_t swapper_pg_dir[1024];
 
@@ -355,8 +345,6 @@ extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
 
 extern void paging_init(void);
 
-#include <asm-generic/pgtable.h>
-
 /* We have our own get_unmapped_area to cope with ADDR_LIMIT_32BIT.  */
 #define HAVE_ARCH_UNMAPPED_AREA
 
index 48b81d0..b45f0b0 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/reg.h>
 #include <linux/uaccess.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/hwrpb.h>
 #include <asm/fpu.h>
 
index f1fce94..701a050 100644 (file)
@@ -2,8 +2,6 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 
-#include <asm/pgtable.h>
-
 /* Prototypes of functions used across modules here in this directory.  */
 
 #define vucp   volatile unsigned char  *
index cb8d599..8c43212 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/audit.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/fpu.h>
 
 #include "proto.h"
index 6fa802c..f5c42a8 100644 (file)
@@ -55,7 +55,6 @@ static struct notifier_block alpha_panic_block = {
 };
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/hwrpb.h>
 #include <asm/dma.h>
 #include <asm/mmu_context.h>
index 52995bf..631cc17 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
 #include <asm/tlbflush.h>
index ce54300..e063b38 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/dma.h>
 #include <asm/mmu_context.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
 
index 0aa6a27..47459b7 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_apecs.h>
 #include <asm/core_cia.h>
 #include <asm/core_lca.h>
index d335086..9fb445d 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_tsunami.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index 1cdfe55..3c43fd3 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_apecs.h>
 #include <asm/core_lca.h>
 #include <asm/hwrpb.h>
index 016f792..bf99dcf 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_tsunami.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index d0d44f5..0a2ab6c 100644 (file)
@@ -25,7 +25,6 @@
 #include <asm/dma.h>
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 #include "proto.h"
index 533899a..83d6c53 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_marvel.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index 702292a..e1bee8f 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
 
index 3af4f94..7690dfd 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_apecs.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
index 32850e4..53adf43 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_irongate.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index b106f32..47f3ce4 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_apecs.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
index b76f65d..b5846ff 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_mcpcia.h>
 #include <asm/tlbflush.h>
 
index d330740..4b1c8d8 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
 
index 4d85eae..94046f9 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_polaris.h>
 #include <asm/tlbflush.h>
 
index 3cf0d32..930005b 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_t2.h>
 #include <asm/tlbflush.h>
 
index a6bdc1d..7c420d8 100644 (file)
@@ -25,7 +25,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_apecs.h>
 #include <asm/core_lca.h>
 #include <asm/tlbflush.h>
index 17cc203..dd9de84 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_cia.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index e230c68..9e2adb6 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_cia.h>
 #include <asm/tlbflush.h>
 
index c8390d8..b1f3b4f 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_titan.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index 2191bde..2c54d70 100644 (file)
@@ -20,7 +20,6 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/core_wildfire.h>
 #include <asm/hwrpb.h>
 #include <asm/tlbflush.h>
index f6b9664..49754e0 100644 (file)
@@ -121,10 +121,10 @@ dik_show_code(unsigned int *pc)
 }
 
 static void
-dik_show_trace(unsigned long *sp)
+dik_show_trace(unsigned long *sp, const char *loglvl)
 {
        long i = 0;
-       printk("Trace:\n");
+       printk("%sTrace:\n", loglvl);
        while (0x1ff8 & (unsigned long) sp) {
                extern char _stext[], _etext[];
                unsigned long tmp = *sp;
@@ -133,24 +133,24 @@ dik_show_trace(unsigned long *sp)
                        continue;
                if (tmp >= (unsigned long) &_etext)
                        continue;
-               printk("[<%lx>] %pSR\n", tmp, (void *)tmp);
+               printk("%s[<%lx>] %pSR\n", loglvl, tmp, (void *)tmp);
                if (i > 40) {
-                       printk(" ...");
+                       printk("%s ...", loglvl);
                        break;
                }
        }
-       printk("\n");
+       printk("%s\n", loglvl);
 }
 
 static int kstack_depth_to_print = 24;
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        unsigned long *stack;
        int i;
 
        /*
-        * debugging aid: "show_stack(NULL);" prints the
+        * debugging aid: "show_stack(NULL, NULL, KERN_EMERG);" prints the
         * back trace for this cpu.
         */
        if(sp==NULL)
@@ -163,14 +163,14 @@ void show_stack(struct task_struct *task, unsigned long *sp)
                if ((i % 4) == 0) {
                        if (i)
                                pr_cont("\n");
-                       printk("       ");
+                       printk("%s       ", loglvl);
                } else {
                        pr_cont(" ");
                }
                pr_cont("%016lx", *stack++);
        }
        pr_cont("\n");
-       dik_show_trace(sp);
+       dik_show_trace(sp, loglvl);
 }
 
 void
@@ -184,7 +184,7 @@ die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
        printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
        dik_show_regs(regs, r9_15);
        add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
-       dik_show_trace((unsigned long *)(regs+1));
+       dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
        dik_show_code((unsigned int *)regs->pc);
 
        if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
@@ -625,7 +625,7 @@ got_exception:
        printk("gp = %016lx  sp = %p\n", regs->gp, regs+1);
 
        dik_show_code((unsigned int *)pc);
-       dik_show_trace((unsigned long *)(regs+1));
+       dik_show_trace((unsigned long *)(regs+1), KERN_DEFAULT);
 
        if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
                printk("die_if_kernel recursion detected.\n");
@@ -957,12 +957,12 @@ give_sigsegv:
                si_code = SEGV_ACCERR;
        else {
                struct mm_struct *mm = current->mm;
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                if (find_vma(mm, (unsigned long)va))
                        si_code = SEGV_ACCERR;
                else
                        si_code = SEGV_MAPERR;
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        }
        send_sig_fault(SIGSEGV, si_code, va, 0, current);
        return;
index c2d7b6d..c2303a8 100644 (file)
@@ -117,7 +117,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto bad_area;
@@ -171,7 +171,7 @@ retry:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                        /* No need to up_read(&mm->mmap_sem) as we would
+                        /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -180,14 +180,14 @@ retry:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return;
 
        /* Something tried to access memory that isn't in our memory map.
           Fix it, but check if it's kernel or user first.  */
  bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        if (user_mode(regs))
                goto do_sigsegv;
@@ -211,14 +211,14 @@ retry:
        /* We ran out of memory, or some other thing happened to us that
           made us unable to handle the page fault gracefully.  */
  out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
  do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        /* Send a sigbus, regardless of whether we were in kernel
           or user mode.  */
        force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *) address, 0);
index 667cd21..3c42b31 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/gfp.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/hwrpb.h>
 #include <asm/dma.h>
index 0be19fd..4c453ba 100644 (file)
@@ -13,7 +13,8 @@
 struct task_struct;
 
 void show_regs(struct pt_regs *regs);
-void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs);
+void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs,
+                    const char *loglvl);
 void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
                            unsigned long address);
 void die(const char *str, struct pt_regs *regs, unsigned long address);
index 12be7e1..f1ed17e 100644 (file)
 extern char empty_zero_page[PAGE_SIZE];
 #define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
 
-#define pte_unmap(pte)         do { } while (0)
-#define pte_unmap_nested(pte)          do { } while (0)
-
 #define set_pte(pteptr, pteval)        ((*(pteptr)) = (pteval))
 #define set_pmd(pmdptr, pmdval)        (*(pmdptr) = pmdval)
 
@@ -282,18 +279,6 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
 
 /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/
 #define pte_pfn(pte)           (pte_val(pte) >> PAGE_SHIFT)
-#define __pte_index(addr)      (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
-/*
- * pte_offset gets a @ptr to PMD entry (PGD in our 2-tier paging system)
- * and returns ptr to PTE entry corresponding to @addr
- */
-#define pte_offset(dir, addr) ((pte_t *)(pmd_page_vaddr(*dir)) +\
-                                        __pte_index(addr))
-
-/* No mapping of Page Tables in high mem etc, so following same as above */
-#define pte_offset_kernel(dir, addr)           pte_offset(dir, addr)
-#define pte_offset_map(dir, addr)              pte_offset(dir, addr)
 
 /* Zoo of pte_xxx function */
 #define pte_read(pte)          (pte_val(pte) & _PAGE_READ)
@@ -332,13 +317,6 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
 }
 
 /*
- * All kernel related VM pages are in init's mm.
- */
-#define pgd_offset_k(address)  pgd_offset(&init_mm, address)
-#define pgd_index(addr)                ((addr) >> PGDIR_SHIFT)
-#define pgd_offset(mm, addr)   (((mm)->pgd)+pgd_index(addr))
-
-/*
  * Macro to quickly access the PGD entry, utlising the fact that some
  * arch may cache the pointer to Page Directory of "current" task
  * in a MMU register
@@ -390,8 +368,6 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
 #include <asm/hugepage.h>
 #endif
 
-#include <asm-generic/pgtable.h>
-
 /* to cope with aliasing VIPT cache */
 #define HAVE_ARCH_UNMAPPED_AREA
 
index 315528f..8c8e517 100644 (file)
@@ -90,10 +90,10 @@ fault:
        if (unlikely(ret != -EFAULT))
                 goto fail;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
                               FAULT_FLAG_WRITE, NULL);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        if (likely(!ret))
                 goto again;
index 1e440bb..feba91c 100644 (file)
@@ -158,9 +158,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
 /* Call-back which plugs into unwinding core to dump the stack in
  * case of panic/OOPs/BUG etc
  */
-static int __print_sym(unsigned int address, void *unused)
+static int __print_sym(unsigned int address, void *arg)
 {
-       printk("  %pS\n", (void *)address);
+       const char *loglvl = arg;
+
+       printk("%s  %pS\n", loglvl, (void *)address);
        return 0;
 }
 
@@ -217,17 +219,18 @@ static int __get_first_nonsched(unsigned int address, void *unused)
  *-------------------------------------------------------------------------
  */
 
-noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs)
+noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs,
+                             const char *loglvl)
 {
-       pr_info("\nStack Trace:\n");
-       arc_unwind_core(tsk, regs, __print_sym, NULL);
+       printk("%s\nStack Trace:\n", loglvl);
+       arc_unwind_core(tsk, regs, __print_sym, (void *)loglvl);
 }
 EXPORT_SYMBOL(show_stacktrace);
 
 /* Expected by sched Code */
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 {
-       show_stacktrace(tsk, NULL);
+       show_stacktrace(tsk, NULL, loglvl);
 }
 
 /* Another API expected by schedular, shows up in "ps" as Wait Channel
index 3393558..28e8bf0 100644 (file)
@@ -89,7 +89,7 @@ static void show_faulting_vma(unsigned long address)
        /* can't use print_vma_addr() yet as it doesn't check for
         * non-inclusive vma
         */
-       down_read(&active_mm->mmap_sem);
+       mmap_read_lock(active_mm);
        vma = find_vma(active_mm, address);
 
        /* check against the find_vma( ) behaviour which returns the next VMA
@@ -111,7 +111,7 @@ static void show_faulting_vma(unsigned long address)
        } else
                pr_info("    @No matching VMA found\n");
 
-       up_read(&active_mm->mmap_sem);
+       mmap_read_unlock(active_mm);
 }
 
 static void show_ecr_verbose(struct pt_regs *regs)
@@ -240,5 +240,5 @@ void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
 
        /* Show stack trace if this Fatality happened in kernel mode */
        if (!user_mode(regs))
-               show_stacktrace(current, regs);
+               show_stacktrace(current, regs, KERN_DEFAULT);
 }
index 92b339c..72f5405 100644 (file)
@@ -107,7 +107,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
                flags |= FAULT_FLAG_WRITE;
 
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma(mm, address);
        if (!vma)
@@ -141,7 +141,7 @@ retry:
        }
 
        /*
-        * Fault retry nuances, mmap_sem already relinquished by core mm
+        * Fault retry nuances, mmap_lock already relinquished by core mm
         */
        if (unlikely((fault & VM_FAULT_RETRY) &&
                     (flags & FAULT_FLAG_ALLOW_RETRY))) {
@@ -150,7 +150,7 @@ retry:
        }
 
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Major/minor page fault accounting
index 479b0d7..1b9f473 100644 (file)
@@ -6,8 +6,8 @@
 #include <linux/memblock.h>
 #include <linux/export.h>
 #include <linux/highmem.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 
@@ -92,17 +92,9 @@ EXPORT_SYMBOL(kunmap_atomic_high);
 
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
-       pgd_t *pgd_k;
-       p4d_t *p4d_k;
-       pud_t *pud_k;
-       pmd_t *pmd_k;
+       pmd_t *pmd_k = pmd_off_k(kvaddr);
        pte_t *pte_k;
 
-       pgd_k = pgd_offset_k(kvaddr);
-       p4d_k = p4d_offset(pgd_k, kvaddr);
-       pud_k = pud_offset(p4d_k, kvaddr);
-       pmd_k = pmd_offset(pud_k, kvaddr);
-
        pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
        if (!pte_k)
                panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
index 2efaf6c..31f54bd 100644 (file)
@@ -33,9 +33,9 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/entry.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/arcregs.h>
 #include <asm/cache.h>
 #include <asm/processor.h>
index deef4d0..673c7dd 100644 (file)
@@ -82,7 +82,8 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
                                       struct pt_regs *),
                     int sig, int code, const char *name);
 
-extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
+extern asmlinkage void c_backtrace(unsigned long fp, int pmode,
+                                  const char *loglvl);
 
 struct mm_struct;
 void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr);
index 9383f23..84dc0ba 100644 (file)
@@ -13,7 +13,6 @@
 #include <asm/highmem.h>
 #include <asm/mach/map.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #ifdef CONFIG_EFI
index 472c93d..fc56fc3 100644 (file)
@@ -6,8 +6,8 @@
 #define FIXADDR_END            0xfff00000UL
 #define FIXADDR_TOP            (FIXADDR_END - PAGE_SIZE)
 
+#include <linux/pgtable.h>
 #include <asm/kmap_types.h>
-#include <asm/pgtable.h>
 
 enum fixed_addresses {
        FIX_EARLYCON_MEM_BASE,
index 73ba956..aab7e83 100644 (file)
@@ -3,7 +3,7 @@
 #define __ASM_IDMAP_H
 
 #include <linux/compiler.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 /* Tag a function as requiring to be executed via an identity mapping. */
 #define __idmap __section(.idmap.text) noinline notrace
index 9e084a4..3502c2f 100644 (file)
@@ -187,6 +187,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
 {
        return (pmd_t *)pud;
 }
+#define pmd_offset pmd_offset
 
 #define pmd_large(pmd)         (pmd_val(pmd) & 2)
 #define pmd_leaf(pmd)          (pmd_val(pmd) & 2)
index 1933aed..fbb6693 100644 (file)
@@ -133,13 +133,6 @@ static inline pmd_t *pud_page_vaddr(pud_t pud)
        return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK);
 }
 
-/* Find an entry in the second-level page table.. */
-#define pmd_index(addr)                (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
-static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
-{
-       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr);
-}
-
 #define pmd_bad(pmd)           (!(pmd_val(pmd) & 2))
 
 #define copy_pmd(pmdpd,pmdps)          \
index 30fb233..d16aba4 100644 (file)
@@ -22,7 +22,6 @@
 #define pgd_bad(pgd)           (0)
 #define pgd_clear(pgdp)
 #define kern_addr_valid(addr)  (1)
-#define        pmd_offset(a, b)        ((void *)0)
 /* FIXME */
 /*
  * PMD_SHIFT determines the size of the area a second-level page table can map
@@ -73,8 +72,6 @@ extern unsigned int kobjsize(const void *objp);
 
 #define FIRST_USER_ADDRESS      0UL
 
-#include <asm-generic/pgtable.h>
-
 #else 
 
 /*
index fba2060..c02f244 100644 (file)
@@ -166,14 +166,6 @@ extern struct page *empty_zero_page;
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
-/* to find an entry in a page-table-directory */
-#define pgd_index(addr)                ((addr) >> PGDIR_SHIFT)
-
-#define pgd_offset(mm, addr)   ((mm)->pgd + pgd_index(addr))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)     pgd_offset(&init_mm, addr)
-
 #define pmd_none(pmd)          (!pmd_val(pmd))
 
 static inline pte_t *pmd_page_vaddr(pmd_t pmd)
@@ -183,21 +175,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
 
 #define pmd_page(pmd)          pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
 
-#ifndef CONFIG_HIGHPTE
-#define __pte_map(pmd)         pmd_page_vaddr(*(pmd))
-#define __pte_unmap(pte)       do { } while (0)
-#else
-#define __pte_map(pmd)         (pte_t *)kmap_atomic(pmd_page(*(pmd)))
-#define __pte_unmap(pte)       kunmap_atomic(pte)
-#endif
-
-#define pte_index(addr)                (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
-#define pte_offset_kernel(pmd,addr)    (pmd_page_vaddr(*(pmd)) + pte_index(addr))
-
-#define pte_offset_map(pmd,addr)       (__pte_map(pmd) + pte_index(addr))
-#define pte_unmap(pte)                 __pte_unmap(pte)
-
 #define pte_pfn(pte)           ((pte_val(pte) & PHYS_MASK) >> PAGE_SHIFT)
 #define pfn_pte(pfn,prot)      __pte(__pfn_to_phys(pfn) | pgprot_val(prot))
 
@@ -339,8 +316,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 /* FIXME: this is not correct */
 #define kern_addr_valid(addr)  (1)
 
-#include <asm-generic/pgtable.h>
-
 /*
  * We provide our own arch_get_unmapped_area to cope with VIPT caches.
  */
index 172b08f..987fefb 100644 (file)
@@ -29,7 +29,8 @@ static inline int __in_irqentry_text(unsigned long ptr)
 }
 
 extern void __init early_trap_init(void *);
-extern void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame);
+extern void dump_backtrace_entry(unsigned long where, unsigned long from,
+                                unsigned long frame, const char *loglvl);
 extern void ptrace_break(struct pt_regs *regs);
 
 extern void *vectors_page;
index 6e282c3..0f8a343 100644 (file)
@@ -36,7 +36,8 @@ extern struct unwind_table *unwind_table_add(unsigned long start,
                                             unsigned long text_addr,
                                             unsigned long text_size);
 extern void unwind_table_del(struct unwind_table *tab);
-extern void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk);
+extern void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                            const char *loglvl);
 
 #endif /* !__ASSEMBLY__ */
 
index c49b393..f890422 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
 #include <asm/assembler.h>
 #include <asm/cp15.h>
@@ -18,7 +19,6 @@
 #include <asm/asm-offsets.h>
 #include <asm/memory.h>
 #include <asm/thread_info.h>
-#include <asm/pgtable.h>
 
 #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_SEMIHOSTING)
 #include CONFIG_DEBUG_LL_INCLUDE
index 76300f3..974b6c6 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/memblock.h>
-#include <asm/pgtable.h>
 #include <linux/of_fdt.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
index af0a850..e15444b 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/gfp.h>
 
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/smp_plat.h>
 #include <asm/unwind.h>
index 46e478f..58eaa1f 100644 (file)
@@ -431,7 +431,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        npages = 1; /* for sigpage */
        npages += vdso_total_pages;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
        hint = sigpage_addr(mm, npages);
        addr = get_unmapped_area(NULL, hint, npages << PAGE_SHIFT, 0, 0);
@@ -458,7 +458,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        arm_install_vdso(mm, addr + PAGE_SIZE);
 
  up_fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 #endif
index 4cc6a7e..d0f7c88 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/tracehook.h>
 #include <linux/unistd.h>
 
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 
 #define CREATE_TRACE_POINTS
index 46e1be9..9a64325 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/idmap.h>
 #include <asm/topology.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/procinfo.h>
 #include <asm/processor.h>
index d080992..d2c9338 100644 (file)
@@ -2,12 +2,12 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/bugs.h>
 #include <asm/cacheflush.h>
 #include <asm/idmap.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/memory.h>
 #include <asm/smp_plat.h>
 #include <asm/suspend.h>
index e640871..6166ba3 100644 (file)
@@ -97,12 +97,12 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr)
 {
        int si_code;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        if (find_vma(current->mm, addr) == NULL)
                si_code = SEGV_MAPERR;
        else
                si_code = SEGV_ACCERR;
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        pr_debug("SWP{B} emulation: access caused memory abort!\n");
        arm_notify_die("Illegal memory access", regs,
index 316a768..65a3b1e 100644 (file)
@@ -62,21 +62,24 @@ __setup("user_debug=", user_debug_setup);
 
 static void dump_mem(const char *, const char *, unsigned long, unsigned long);
 
-void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
+void dump_backtrace_entry(unsigned long where, unsigned long from,
+                         unsigned long frame, const char *loglvl)
 {
        unsigned long end = frame + 4 + sizeof(struct pt_regs);
 
 #ifdef CONFIG_KALLSYMS
-       printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
+       printk("%s[<%08lx>] (%ps) from [<%08lx>] (%pS)\n",
+               loglvl, where, (void *)where, from, (void *)from);
 #else
-       printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
+       printk("%sFunction entered at [<%08lx>] from [<%08lx>]\n",
+               loglvl, where, from);
 #endif
 
        if (in_entry_text(from) && end <= ALIGN(frame, THREAD_SIZE))
-               dump_mem("", "Exception stack", frame + 4, end);
+               dump_mem(loglvl, "Exception stack", frame + 4, end);
 }
 
-void dump_backtrace_stm(u32 *stack, u32 instruction)
+void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl)
 {
        char str[80], *p;
        unsigned int x;
@@ -88,12 +91,12 @@ void dump_backtrace_stm(u32 *stack, u32 instruction)
                        if (++x == 6) {
                                x = 0;
                                p = str;
-                               printk("%s\n", str);
+                               printk("%s%s\n", loglvl, str);
                        }
                }
        }
        if (p != str)
-               printk("%s\n", str);
+               printk("%s%s\n", loglvl, str);
 }
 
 #ifndef CONFIG_ARM_UNWIND
@@ -201,17 +204,19 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
 }
 
 #ifdef CONFIG_ARM_UNWIND
-static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                                 const char *loglvl)
 {
-       unwind_backtrace(regs, tsk);
+       unwind_backtrace(regs, tsk, loglvl);
 }
 #else
-static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                          const char *loglvl)
 {
        unsigned int fp, mode;
        int ok = 1;
 
-       printk("Backtrace: ");
+       printk("%sBacktrace: ", loglvl);
 
        if (!tsk)
                tsk = current;
@@ -238,13 +243,13 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
        pr_cont("\n");
 
        if (ok)
-               c_backtrace(fp, mode);
+               c_backtrace(fp, mode, loglvl);
 }
 #endif
 
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 {
-       dump_backtrace(NULL, tsk);
+       dump_backtrace(NULL, tsk, loglvl);
        barrier();
 }
 
@@ -288,7 +293,7 @@ static int __die(const char *str, int err, struct pt_regs *regs)
        if (!user_mode(regs) || in_interrupt()) {
                dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
                         THREAD_SIZE + (unsigned long)task_stack_page(tsk));
-               dump_backtrace(regs, tsk);
+               dump_backtrace(regs, tsk, KERN_EMERG);
                dump_instr(KERN_EMERG, regs);
        }
 
@@ -663,10 +668,10 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
        if (user_debug & UDBG_SYSCALL) {
                pr_err("[%d] %s: arm syscall %d\n",
                       task_pid_nr(current), current->comm, no);
-               dump_instr("", regs);
+               dump_instr(KERN_ERR, regs);
                if (user_mode(regs)) {
                        __show_regs(regs);
-                       c_backtrace(frame_pointer(regs), processor_mode(regs));
+                       c_backtrace(frame_pointer(regs), processor_mode(regs), KERN_ERR);
                }
        }
 #endif
index 11a964f..d2bd0df 100644 (file)
@@ -455,7 +455,8 @@ int unwind_frame(struct stackframe *frame)
        return URC_OK;
 }
 
-void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                     const char *loglvl)
 {
        struct stackframe frame;
 
@@ -493,7 +494,7 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                urc = unwind_frame(&frame);
                if (urc < 0)
                        break;
-               dump_backtrace_entry(where, frame.pc, frame.sp - 4);
+               dump_backtrace_entry(where, frame.pc, frame.sp - 4, loglvl);
        }
 }
 
index e0330a2..6bfdca4 100644 (file)
@@ -240,7 +240,7 @@ static int install_vvar(struct mm_struct *mm, unsigned long addr)
        return PTR_ERR_OR_ZERO(vma);
 }
 
-/* assumes mmap_sem is write-locked */
+/* assumes mmap_lock is write-locked */
 void arm_install_vdso(struct mm_struct *mm, unsigned long addr)
 {
        struct vm_area_struct *vma;
index 88a720d..7f24bc0 100644 (file)
@@ -8,13 +8,13 @@
 #include "vmlinux-xip.lds.S"
 #else
 
+#include <linux/pgtable.h>
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
 #include <asm/memory.h>
 #include <asm/mpu.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "vmlinux.lds.h"
 
index 2ff3751..6174c45 100644 (file)
@@ -17,6 +17,7 @@
 #define sv_pc  r6
 #define mask   r7
 #define sv_lr  r8
+#define loglvl r9
 
 ENTRY(c_backtrace)
 
@@ -99,6 +100,7 @@ ENDPROC(c_backtrace)
                                                @ to ensure 8 byte alignment
                movs    frame, r0               @ if frame pointer is zero
                beq     no_frame                @ we have no stack frames
+               mov     loglvl, r2
                tst     r1, #0x10               @ 26 or 32-bit mode?
                moveq   mask, #0xfc000003
                movne   mask, #0                @ mask for 32-bit
@@ -167,6 +169,7 @@ finished_setup:
                mov     r1, sv_lr
                mov     r2, frame
                bic     r1, r1, mask            @ mask PC/LR for the mode
+               mov     r3, loglvl
                bl      dump_backtrace_entry
 
 /*
@@ -183,6 +186,7 @@ finished_setup:
                ldr     r0, [frame]             @ locals are stored in
                                                @ the preceding frame
                subeq   r0, r0, #4
+               mov     r2, loglvl
                bleq    dump_backtrace_stm      @ dump saved registers
 
 /*
@@ -196,7 +200,8 @@ finished_setup:
                bhi     for_each_frame
 
 1006:          adr     r0, .Lbad
-               mov     r1, frame
+               mov     r1, loglvl
+               mov     r2, frame
                bl      printk
 no_frame:      ldmfd   sp!, {r4 - r9, fp, pc}
 ENDPROC(c_backtrace)
@@ -209,7 +214,7 @@ ENDPROC(c_backtrace)
                .long   1005b, 1006b
                .popsection
 
-.Lbad:         .asciz  "Backtrace aborted due to bad frame pointer <%p>\n"
+.Lbad:         .asciz  "%sBacktrace aborted due to bad frame pointer <%p>\n"
                .align
 .Lopcode:      .word   0xe92d4800 >> 11        @ stmfd sp!, {... fp, lr}
                .word   0x0b000000              @ bl if these bits are set
index 5829252..872f658 100644 (file)
@@ -18,6 +18,7 @@
 #define sv_pc  r6
 #define mask   r7
 #define offset r8
+#define loglvl r9
 
 ENTRY(c_backtrace)
 
@@ -25,9 +26,10 @@ ENTRY(c_backtrace)
                ret     lr
 ENDPROC(c_backtrace)
 #else
-               stmfd   sp!, {r4 - r8, lr}      @ Save an extra register so we have a location...
+               stmfd   sp!, {r4 - r9, lr}      @ Save an extra register so we have a location...
                movs    frame, r0               @ if frame pointer is zero
                beq     no_frame                @ we have no stack frames
+               mov     loglvl, r2
 
                tst     r1, #0x10               @ 26 or 32-bit mode?
  ARM(          moveq   mask, #0xfc000003       )
@@ -73,6 +75,7 @@ for_each_frame:       tst     frame, mask             @ Check for address exceptions
                ldr     r1, [frame, #-4]        @ get saved lr
                mov     r2, frame
                bic     r1, r1, mask            @ mask PC/LR for the mode
+               mov     r3, loglvl
                bl      dump_backtrace_entry
 
                ldr     r1, [sv_pc, #-4]        @ if stmfd sp!, {args} exists,
@@ -80,12 +83,14 @@ for_each_frame:     tst     frame, mask             @ Check for address exceptions
                teq     r3, r1, lsr #11
                ldreq   r0, [frame, #-8]        @ get sp
                subeq   r0, r0, #4              @ point at the last arg
+               mov     r2, loglvl
                bleq    dump_backtrace_stm      @ dump saved registers
 
 1004:          ldr     r1, [sv_pc, #0]         @ if stmfd sp!, {..., fp, ip, lr, pc}
                ldr     r3, .Ldsi               @ instruction exists,
                teq     r3, r1, lsr #11
                subeq   r0, frame, #16
+               mov     r2, loglvl
                bleq    dump_backtrace_stm      @ dump saved registers
 
                teq     sv_fp, #0               @ zero saved fp means
@@ -96,9 +101,10 @@ for_each_frame:     tst     frame, mask             @ Check for address exceptions
                bhi     for_each_frame
 
 1006:          adr     r0, .Lbad
-               mov     r1, frame
+               mov     r1, loglvl
+               mov     r2, frame
                bl      printk
-no_frame:      ldmfd   sp!, {r4 - r8, pc}
+no_frame:      ldmfd   sp!, {r4 - r9, pc}
 ENDPROC(c_backtrace)
                
                .pushsection __ex_table,"a"
@@ -109,7 +115,7 @@ ENDPROC(c_backtrace)
                .long   1004b, 1006b
                .popsection
 
-.Lbad:         .asciz  "Backtrace aborted due to bad frame pointer <%p>\n"
+.Lbad:         .asciz  "%sBacktrace aborted due to bad frame pointer <%p>\n"
                .align
 .Ldsi:         .word   0xe92dd800 >> 11        @ stmfd sp!, {... fp, ip, lr, pc}
                .word   0xe92d0000 >> 11        @ stmfd sp!, {}
index d72b14c..106f83a 100644 (file)
@@ -101,7 +101,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
        atomic = faulthandler_disabled();
 
        if (!atomic)
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
        while (n) {
                pte_t *pte;
                spinlock_t *ptl;
@@ -109,11 +109,11 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
 
                while (!pin_page_for_write(to, &pte, &ptl)) {
                        if (!atomic)
-                               up_read(&current->mm->mmap_sem);
+                               mmap_read_unlock(current->mm);
                        if (__put_user(0, (char __user *)to))
                                goto out;
                        if (!atomic)
-                               down_read(&current->mm->mmap_sem);
+                               mmap_read_lock(current->mm);
                }
 
                tocopy = (~(unsigned long)to & ~PAGE_MASK) + 1;
@@ -133,7 +133,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n)
                        spin_unlock(ptl);
        }
        if (!atomic)
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
 out:
        return n;
@@ -170,17 +170,17 @@ __clear_user_memset(void __user *addr, unsigned long n)
                return 0;
        }
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        while (n) {
                pte_t *pte;
                spinlock_t *ptl;
                int tocopy;
 
                while (!pin_page_for_write(addr, &pte, &ptl)) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        if (__put_user(0, (char __user *)addr))
                                goto out;
-                       down_read(&current->mm->mmap_sem);
+                       mmap_read_lock(current->mm);
                }
 
                tocopy = (~(unsigned long)addr & ~PAGE_MASK) + 1;
@@ -198,7 +198,7 @@ __clear_user_memset(void __user *addr, unsigned long n)
                else
                        spin_unlock(ptl);
        }
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
 out:
        return n;
index 575b2e2..5960e3d 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/irq.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/system_misc.h>
 
index 015f75d..eee095f 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/spinlock.h>
 #include <video/vga.h>
 
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
index e117d28..50a2eda 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/pinctrl/machine.h>
-#include <asm/pgtable.h>
 #include <asm/mach/map.h>
 
 #include "common.h"
index dcbe7ec..4e41251 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/pinctrl/machine.h>
-#include <asm/pgtable.h>
 #include <asm/mach/map.h>
 
 #include "common.h"
index 67264c4..ea2d58a 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/io.h>
 #include <linux/pinctrl/machine.h>
 
-#include <asm/pgtable.h>
 #include <asm/system_misc.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/map.h>
index 9da3ae2..0fe5e1d 100644 (file)
 #include <linux/stat.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/pgtable.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/time.h>
-#include <asm/pgtable.h>
 
 #include "hardware.h"
 #include "cm.h"
index dc9f6a1..e422286 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/serial_core.h>
 #include <linux/io.h>
 #include <linux/gpio/machine.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/mach/map.h>
 #include <asm/setup.h>
index 04a7d38..49caaa7 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/mach/time.h>
 #include <asm/mach-types.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "hardware.h"
 #include "irqs.h"
index 4bd596d..b455d70 100644 (file)
@@ -27,7 +27,6 @@
 #include <asm/mach/time.h>
 #include <asm/mach-types.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "hardware.h"
 #include "irqs.h"
index 5382a93..78b9a5e 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/mach/time.h>
 #include <asm/mach-types.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "hardware.h"
 #include "irqs.h"
index 381f452..184262d 100644 (file)
@@ -33,7 +33,6 @@
 #include <mach/hardware.h>
 #include <mach/io.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/exception.h>
 #include <asm/irq.h>
index c810e23..673fcf3 100644 (file)
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/io.h>
+#include <linux/pgtable.h>
 
 #include <asm/smp_plat.h>
 #include <asm/prom.h>
 #include <asm/tlbflush.h>
-#include <asm/pgtable.h>
 
 #include "keystone.h"
 
index 0631a7b..aa265ed 100644 (file)
@@ -34,7 +34,6 @@
 #include <asm/setup.h>
 #include <asm/page.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 #include <asm/mach/arch.h>
@@ -633,7 +632,7 @@ static void __init map_sa1100_gpio_regs( void )
        int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
        pmd_t *pmd;
 
-       pmd = pmd_offset(pud_offset(p4d_offset(pgd_offset_k(virt), virt), virt), virt);
+       pmd = pmd_off_k(virt);
        *pmd = __pmd(phys | prot);
        flush_pmd_entry(pmd);
 }
index 6d37d26..3085f1c 100644 (file)
 #include <linux/gpio.h>
 #include <linux/leds.h>
 #include <linux/platform_device.h>
+#include <linux/pgtable.h>
 
 #include <asm/mach-types.h>
 #include <asm/setup.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
index 160cb18..4cb7e5f 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef __MACH_TEGRA_IOMAP_H
 #define __MACH_TEGRA_IOMAP_H
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <linux/sizes.h>
 
 #define TEGRA_IRAM_BASE                        0x40000000
index a9dd2f7..e1ca6a5 100644 (file)
 #include <linux/irqchip/arm-gic.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>
+#include <linux/pgtable.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/mach-types.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/smp_scu.h>
 #include <asm/system_info.h>
 #include <asm/hardware/cache-l2x0.h>
index a94bd08..44f7292 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
 
index a6488bb..6a769a6 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 
-#include <asm/pgtable.h>
 #include <asm/shmparam.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
index 382e1c2..eb5d338 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
 
index 677549d..c18d23a 100644 (file)
@@ -16,7 +16,6 @@
 #include <asm/domain.h>
 #include <asm/fixmap.h>
 #include <asm/memory.h>
-#include <asm/pgtable.h>
 #include <asm/ptdump.h>
 
 static struct addr_marker address_markers[] = {
index 489aaaf..0e49154 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/bugs.h>
 #include <asm/cacheflush.h>
 #include <asm/cachetype.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 #include "mm.h"
index ff230e9..c6550ed 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/highmem.h>
 #include <linux/perf_event.h>
 
-#include <asm/pgtable.h>
 #include <asm/system_misc.h>
 #include <asm/system_info.h>
 #include <asm/tlbflush.h>
@@ -272,11 +271,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
         * validly references user space from well defined areas of the code,
         * we can bug out early if this is from code which shouldn't.
         */
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
                        goto no_context;
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in
@@ -294,7 +293,7 @@ retry:
        fault = __do_page_fault(mm, addr, fsr, flags, tsk);
 
        /* If we need to retry but a fatal signal is pending, handle the
-        * signal first. We do not need to release the mmap_sem because
+        * signal first. We do not need to release the mmap_lock because
         * it would already be released in __lock_page_or_retry in
         * mm/filemap.c. */
        if (fault_signal_pending(fault, regs)) {
@@ -326,7 +325,7 @@ retry:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Handle the "normal" case first - VM_FAULT_MAJOR
index e013f6b..187fab2 100644 (file)
@@ -18,7 +18,7 @@
 static inline void set_fixmap_pte(int idx, pte_t pte)
 {
        unsigned long vaddr = __fix_to_virt(idx);
-       pte_t *ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+       pte_t *ptep = virt_to_kpte(vaddr);
 
        set_pte_ext(ptep, pte, 0);
        local_flush_tlb_kernel_page(vaddr);
@@ -26,7 +26,7 @@ static inline void set_fixmap_pte(int idx, pte_t pte)
 
 static inline pte_t get_fixmap_pte(unsigned long vaddr)
 {
-       pte_t *ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+       pte_t *ptep = virt_to_kpte(vaddr);
 
        return *ptep;
 }
index cd54411..448e57c 100644 (file)
@@ -3,12 +3,12 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/cputype.h>
 #include <asm/idmap.h>
 #include <asm/hwcap.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/system_info.h>
 
index 75529d7..000e821 100644 (file)
@@ -141,16 +141,8 @@ void __check_vmalloc_seq(struct mm_struct *mm)
 static void unmap_area_sections(unsigned long virt, unsigned long size)
 {
        unsigned long addr = virt, end = virt + (size & ~(SZ_1M - 1));
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmdp;
-
-       flush_cache_vunmap(addr, end);
-       pgd = pgd_offset_k(addr);
-       p4d = p4d_offset(pgd, addr);
-       pud = pud_offset(p4d, addr);
-       pmdp = pmd_offset(pud, addr);
+       pmd_t *pmdp = pmd_off_k(addr);
+
        do {
                pmd_t pmd = *pmdp;
 
@@ -191,10 +183,7 @@ remap_area_sections(unsigned long virt, unsigned long pfn,
                    size_t size, const struct mem_type *type)
 {
        unsigned long addr = virt, end = virt + size;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmd;
+       pmd_t *pmd = pmd_off_k(addr);
 
        /*
         * Remove and free any PTE-based mapping, and
@@ -202,10 +191,6 @@ remap_area_sections(unsigned long virt, unsigned long pfn,
         */
        unmap_area_sections(virt, size);
 
-       pgd = pgd_offset_k(addr);
-       p4d = p4d_offset(pgd, addr);
-       pud = pud_offset(p4d, addr);
-       pmd = pmd_offset(pud, addr);
        do {
                pmd[0] = __pmd(__pfn_to_phys(pfn) | type->prot_sect);
                pfn += SZ_1M >> PAGE_SHIFT;
@@ -225,21 +210,13 @@ remap_area_supersections(unsigned long virt, unsigned long pfn,
                         size_t size, const struct mem_type *type)
 {
        unsigned long addr = virt, end = virt + size;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmd;
+       pmd_t *pmd = pmd_off_k(addr);
 
        /*
         * Remove and free any PTE-based mapping, and
         * sync the current kernel mapping.
         */
        unmap_area_sections(virt, size);
-
-       pgd = pgd_offset_k(virt);
-       p4d = p4d_offset(pgd, addr);
-       pud = pud_offset(p4d, addr);
-       pmd = pmd_offset(pud, addr);
        do {
                unsigned long super_pmd_val, i;
 
index 4f1f72b..9ff6836 100644 (file)
@@ -2,8 +2,7 @@
 #ifdef CONFIG_MMU
 #include <linux/list.h>
 #include <linux/vmalloc.h>
-
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 /* the upper-most page table pointer */
 extern pmd_t *top_pmd;
@@ -36,11 +35,6 @@ static inline pte_t get_top_pte(unsigned long va)
        return *ptep;
 }
 
-static inline pmd_t *pmd_off_k(unsigned long virt)
-{
-       return pmd_offset(pud_offset(p4d_offset(pgd_offset_k(virt), virt), virt), virt);
-}
-
 struct mem_type {
        pteval_t prot_pte;
        pteval_t prot_pte_s2;
index c425288..628028b 100644 (file)
@@ -356,12 +356,7 @@ static pte_t *pte_offset_late_fixmap(pmd_t *dir, unsigned long addr)
 
 static inline pmd_t * __init fixmap_pmd(unsigned long addr)
 {
-       pgd_t *pgd = pgd_offset_k(addr);
-       p4d_t *p4d = p4d_offset(pgd, addr);
-       pud_t *pud = pud_offset(p4d, addr);
-       pmd_t *pmd = pmd_offset(pud, addr);
-
-       return pmd;
+       return pmd_off_k(addr);
 }
 
 void __init early_fixmap_init(void)
index d546efa..9790ae3 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/set_memory.h>
 
index 2785da3..6837cf7 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index e9ea237..df49b10 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 920c279..e89ce46 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 0bdf25a..7fdd1a2 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 39361e1..3b687e6 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 1a94bbf..f2ec3bc 100644 (file)
@@ -6,11 +6,11 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 52b66cf..01bbe75 100644 (file)
@@ -6,11 +6,11 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 31ac8ac..a234cd8 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index ca2c7ca..53c029d 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index a381a0c..0bfad62 100644 (file)
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 1ba253c..0487a2c 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index 4b8a002..cf9bfcc 100644 (file)
@@ -6,10 +6,10 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
 
index 555becf..6fb3898 100644 (file)
@@ -8,10 +8,10 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
 
index ef51753..a054c0e 100644 (file)
@@ -6,11 +6,11 @@
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index dddf833..2c73e0d 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 
index b12b76b..61ce82a 100644 (file)
@@ -8,10 +8,10 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index d47d6c5..1645cca 100644 (file)
@@ -9,10 +9,10 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
 #include "proc-macros.S"
index baba503..4071f7a 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <mach/hardware.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 #include "proc-macros.S"
index 75ebacc..e723bd4 100644 (file)
  */
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <mach/hardware.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 
 #include "proc-macros.S"
 
index 1dd0d5c..a0618f3 100644 (file)
@@ -9,11 +9,11 @@
  */
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 
 #include "proc-macros.S"
 
index 48e0ef6..28c9d32 100644 (file)
@@ -9,11 +9,11 @@
 #include <linux/arm-smccc.h>
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/memory.h>
 
 #include "proc-macros.S"
index 42eaecc..a17afe7 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
-#include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
index 18ac5a1..d82590a 100644 (file)
@@ -19,9 +19,9 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
-#include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
index 7697789..8eade04 100644 (file)
@@ -6,10 +6,10 @@
  * for Keystone 2
  */
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/asm-offsets.h>
 #include <asm/cp15.h>
 #include <asm/memory.h>
-#include <asm/pgtable.h>
 
        .section ".idmap.text", "ax"
 
index 6facd13..ff50dd7 100644 (file)
@@ -9,11 +9,11 @@
 #define __ASM_IO_H
 
 #include <linux/types.h>
+#include <linux/pgtable.h>
 
 #include <asm/byteorder.h>
 #include <asm/barrier.h>
 #include <asm/memory.h>
-#include <asm/pgtable.h>
 #include <asm/early_ioremap.h>
 #include <asm/alternative.h>
 #include <asm/cpufeature.h>
index a6e5da7..3bf626f 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef __ASM_KERNEL_PGTABLE_H
 #define __ASM_KERNEL_PGTABLE_H
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/sparsemem.h>
 
 /*
index f1a7416..094260a 100644 (file)
@@ -83,11 +83,11 @@ alternative_cb_end
 
 #else
 
+#include <linux/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/cache.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 
 void kvm_update_va_mask(struct alt_instr *alt,
                        __le32 *origptr, __le32 *updptr, int nr_inst);
index ab46187..b0bd9b5 100644 (file)
 #include <linux/sched.h>
 #include <linux/sched/hotplug.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
 #include <asm/proc-fns.h>
 #include <asm-generic/mm_hooks.h>
 #include <asm/cputype.h>
-#include <asm/pgtable.h>
 #include <asm/sysreg.h>
 #include <asm/tlbflush.h>
 
index 1f3218f..6dbd267 100644 (file)
@@ -340,7 +340,7 @@ static inline pgprot_t mk_pmd_sect_prot(pgprot_t prot)
 
 #ifdef CONFIG_NUMA_BALANCING
 /*
- * See the comment in include/asm-generic/pgtable.h
+ * See the comment in include/linux/pgtable.h
  */
 static inline int pte_protnone(pte_t pte)
 {
@@ -506,15 +506,13 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)
        return __pmd_to_phys(pmd);
 }
 
-static inline void pte_unmap(pte_t *pte) { }
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return (unsigned long)__va(pmd_page_paddr(pmd));
+}
 
 /* Find an entry in the third-level page table. */
-#define pte_index(addr)                (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
 #define pte_offset_phys(dir,addr)      (pmd_page_paddr(READ_ONCE(*(dir))) + pte_index(addr) * sizeof(pte_t))
-#define pte_offset_kernel(dir,addr)    ((pte_t *)__va(pte_offset_phys((dir), (addr))))
-
-#define pte_offset_map(dir,addr)       pte_offset_kernel((dir), (addr))
 
 #define pte_set_fixmap(addr)           ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
 #define pte_set_fixmap_offset(pmd, addr)       pte_set_fixmap(pte_offset_phys(pmd, addr))
@@ -568,11 +566,13 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
        return __pud_to_phys(pud);
 }
 
-/* Find an entry in the second-level page table. */
-#define pmd_index(addr)                (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
+static inline unsigned long pud_page_vaddr(pud_t pud)
+{
+       return (unsigned long)__va(pud_page_paddr(pud));
+}
 
+/* Find an entry in the second-level page table. */
 #define pmd_offset_phys(dir, addr)     (pud_page_paddr(READ_ONCE(*(dir))) + pmd_index(addr) * sizeof(pmd_t))
-#define pmd_offset(dir, addr)          ((pmd_t *)__va(pmd_offset_phys((dir), (addr))))
 
 #define pmd_set_fixmap(addr)           ((pmd_t *)set_fixmap_offset(FIX_PMD, addr))
 #define pmd_set_fixmap_offset(pud, addr)       pmd_set_fixmap(pmd_offset_phys(pud, addr))
@@ -626,11 +626,13 @@ static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
        return __p4d_to_phys(p4d);
 }
 
-/* Find an entry in the frst-level page table. */
-#define pud_index(addr)                (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
+static inline unsigned long p4d_page_vaddr(p4d_t p4d)
+{
+       return (unsigned long)__va(p4d_page_paddr(p4d));
+}
 
+/* Find an entry in the frst-level page table. */
 #define pud_offset_phys(dir, addr)     (p4d_page_paddr(READ_ONCE(*(dir))) + pud_index(addr) * sizeof(pud_t))
-#define pud_offset(dir, addr)          ((pud_t *)__va(pud_offset_phys((dir), (addr))))
 
 #define pud_set_fixmap(addr)           ((pud_t *)set_fixmap_offset(FIX_PUD, addr))
 #define pud_set_fixmap_offset(p4d, addr)       pud_set_fixmap(pud_offset_phys(p4d, addr))
@@ -657,16 +659,6 @@ static inline phys_addr_t p4d_page_paddr(p4d_t p4d)
 
 #define pgd_ERROR(pgd)         __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
 
-/* to find an entry in a page-table-directory */
-#define pgd_index(addr)                (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-
-#define pgd_offset_raw(pgd, addr)      ((pgd) + pgd_index(addr))
-
-#define pgd_offset(mm, addr)   (pgd_offset_raw((mm)->pgd, (addr)))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)     pgd_offset(&init_mm, addr)
-
 #define pgd_set_fixmap(addr)   ((pgd_t *)set_fixmap_offset(FIX_PGD, addr))
 #define pgd_clear_fixmap()     clear_fixmap(FIX_PGD)
 
@@ -853,8 +845,6 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma,
 
 extern int kern_addr_valid(unsigned long addr);
 
-#include <asm-generic/pgtable.h>
-
 /*
  * On AArch64, the cache coherency is handled via the set_pte_at() function.
  */
index 5017b53..fc76130 100644 (file)
@@ -64,7 +64,8 @@ struct stackframe {
 extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame);
 extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
                            int (*fn)(struct stackframe *, void *), void *data);
-extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk);
+extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                          const char *loglvl);
 
 DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
 
index 9a364ae..b767904 100644 (file)
@@ -9,7 +9,7 @@
 #define __ARM64_S2_PGTABLE_H_
 
 #include <linux/hugetlb.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 /*
  * PGDIR_SHIFT determines the size a top-level page table entry can map
index 0cc6636..894e031 100644 (file)
@@ -7,8 +7,8 @@
 #include <linux/gfp.h>
 #include <linux/kconfig.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 #include <asm/memory.h>
-#include <asm/pgtable.h>
 #include <asm/thread_info.h>
 
 /*
index 46ec402..a7586a4 100644 (file)
 #include <linux/of_fdt.h>
 #include <linux/smp.h>
 #include <linux/serial_core.h>
+#include <linux/pgtable.h>
 
 #include <acpi/ghes.h>
 #include <asm/cputype.h>
 #include <asm/cpu_ops.h>
 #include <asm/daifflags.h>
-#include <asm/pgtable.h>
 #include <asm/smp_plat.h>
 
 int acpi_noirq = 1;            /* skip ACPI IRQ initialization */
index 6327021..037421c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <linux/irqchip/arm-gic-v3.h>
+#include <linux/pgtable.h>
 
 #include <asm/asm_pointer_auth.h>
 #include <asm/assembler.h>
@@ -26,7 +27,6 @@
 #include <asm/kvm_arm.h>
 #include <asm/memory.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/scs.h>
 #include <asm/smp.h>
index a8a4b55..68e1415 100644 (file)
@@ -32,7 +32,6 @@
 #include <asm/memory.h>
 #include <asm/mmu_context.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/sections.h>
 #include <asm/smp.h>
@@ -189,7 +188,7 @@ static int trans_pgd_map_page(pgd_t *trans_pgd, void *page,
        pmd_t *pmdp;
        pte_t *ptep;
 
-       pgdp = pgd_offset_raw(trans_pgd, dst_addr);
+       pgdp = pgd_offset_pgd(trans_pgd, dst_addr);
        if (pgd_none(READ_ONCE(*pgdp))) {
                pudp = (void *)get_safe_page(GFP_ATOMIC);
                if (!pudp)
@@ -491,7 +490,7 @@ static int copy_page_tables(pgd_t *dst_pgdp, unsigned long start,
        unsigned long addr = start;
        pgd_t *src_pgdp = pgd_offset_k(start);
 
-       dst_pgdp = pgd_offset_raw(dst_pgdp, start);
+       dst_pgdp = pgd_offset_pgd(dst_pgdp, start);
        do {
                next = pgd_addr_end(addr, end);
                if (pgd_none(READ_ONCE(*src_pgdp)))
index 91a8310..07c4c8c 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mm_types.h>
 #include <linux/sched.h>
 #include <linux/types.h>
+#include <linux/pgtable.h>
 
 #include <asm/archrandom.h>
 #include <asm/cacheflush.h>
@@ -17,7 +18,6 @@
 #include <asm/kernel-pgtable.h>
 #include <asm/memory.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 
 enum kaslr_status {
index eade780..6089638 100644 (file)
@@ -306,7 +306,7 @@ void __show_regs(struct pt_regs *regs)
 void show_regs(struct pt_regs * regs)
 {
        __show_regs(regs);
-       dump_backtrace(regs, NULL);
+       dump_backtrace(regs, NULL, KERN_DEFAULT);
 }
 
 static void tls_thread_flush(void)
index 76790a5..68b7f34 100644 (file)
@@ -34,7 +34,6 @@
 #include <asm/cpufeature.h>
 #include <asm/debug-monitors.h>
 #include <asm/fpsimd.h>
-#include <asm/pgtable.h>
 #include <asm/pointer_auth.h>
 #include <asm/stacktrace.h>
 #include <asm/syscall.h>
index 4b6f499..e43a8ff 100644 (file)
@@ -43,7 +43,6 @@
 #include <asm/kvm_mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/numa.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/processor.h>
 #include <asm/smp_plat.h>
index 9405d1b..c1dee90 100644 (file)
@@ -3,13 +3,13 @@
 #include <linux/percpu.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/pgtable.h>
 #include <asm/alternative.h>
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
 #include <asm/daifflags.h>
 #include <asm/debug-monitors.h>
 #include <asm/exec.h>
-#include <asm/pgtable.h>
 #include <asm/memory.h>
 #include <asm/mmu_context.h>
 #include <asm/smp_plat.h>
index d332590..50cc30a 100644 (file)
@@ -53,9 +53,9 @@ static const char *handler[]= {
 
 int show_unhandled_signals = 0;
 
-static void dump_backtrace_entry(unsigned long where)
+static void dump_backtrace_entry(unsigned long where, const char *loglvl)
 {
-       printk(" %pS\n", (void *)where);
+       printk("%s %pS\n", loglvl, (void *)where);
 }
 
 static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
@@ -83,7 +83,8 @@ static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
        printk("%sCode: %s\n", lvl, str);
 }
 
-void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                   const char *loglvl)
 {
        struct stackframe frame;
        int skip = 0;
@@ -115,11 +116,11 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                                thread_saved_pc(tsk));
        }
 
-       printk("Call trace:\n");
+       printk("%sCall trace:\n", loglvl);
        do {
                /* skip until specified stack frame */
                if (!skip) {
-                       dump_backtrace_entry(frame.pc);
+                       dump_backtrace_entry(frame.pc, loglvl);
                } else if (frame.fp == regs->regs[29]) {
                        skip = 0;
                        /*
@@ -129,16 +130,16 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                         * at which an exception has taken place, use regs->pc
                         * instead.
                         */
-                       dump_backtrace_entry(regs->pc);
+                       dump_backtrace_entry(regs->pc, loglvl);
                }
        } while (!unwind_frame(tsk, &frame));
 
        put_task_stack(tsk);
 }
 
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 {
-       dump_backtrace(NULL, tsk);
+       dump_backtrace(NULL, tsk, loglvl);
        barrier();
 }
 
@@ -447,12 +448,12 @@ void arm64_notify_segfault(unsigned long addr)
 {
        int code;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        if (find_vma(current->mm, addr) == NULL)
                code = SEGV_MAPERR;
        else
                code = SEGV_ACCERR;
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        force_signal_inject(SIGSEGV, code, addr);
 }
index d51a898..4e01657 100644 (file)
@@ -340,7 +340,7 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        struct mm_struct *mm = current->mm;
        int ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        ret = aarch32_kuser_helpers_setup(mm);
@@ -357,7 +357,7 @@ int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
 #endif /* CONFIG_COMPAT_VDSO */
 
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 #endif /* CONFIG_COMPAT */
@@ -398,7 +398,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
        struct mm_struct *mm = current->mm;
        int ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        ret = __setup_additional_pages(VDSO_ABI_AA64,
@@ -406,7 +406,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                                       bprm,
                                       uses_interp);
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return ret;
 }
index 3be6321..6827da7 100644 (file)
@@ -13,7 +13,6 @@
 #include <asm/thread_info.h>
 #include <asm/memory.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "image.h"
 
index 290154e..8c0035c 100644 (file)
@@ -1084,7 +1084,7 @@ void stage2_unmap_vm(struct kvm *kvm)
        int idx;
 
        idx = srcu_read_lock(&kvm->srcu);
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        spin_lock(&kvm->mmu_lock);
 
        slots = kvm_memslots(kvm);
@@ -1092,7 +1092,7 @@ void stage2_unmap_vm(struct kvm *kvm)
                stage2_unmap_memslot(kvm, memslot);
 
        spin_unlock(&kvm->mmu_lock);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        srcu_read_unlock(&kvm->srcu, idx);
 }
 
@@ -1848,11 +1848,11 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
        }
 
        /* Let's check if we will get back a huge page backed by hugetlbfs */
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        vma = find_vma_intersection(current->mm, hva, hva + 1);
        if (unlikely(!vma)) {
                kvm_err("Failed to find VMA for hva 0x%lx\n", hva);
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                return -EFAULT;
        }
 
@@ -1879,7 +1879,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
        if (vma_pagesize == PMD_SIZE ||
            (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm)))
                gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        /* We need minimum second+third level pages */
        ret = mmu_topup_memory_cache(memcache, kvm_mmu_cache_min_pages(kvm),
@@ -2456,7 +2456,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
            (kvm_phys_size(kvm) >> PAGE_SHIFT))
                return -EFAULT;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        /*
         * A memory region could potentially cover multiple VMAs, and any holes
         * between them, so iterate over all of them to find out if we can map
@@ -2515,7 +2515,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
                stage2_flush_memslot(kvm, memslot);
        spin_unlock(&kvm->mmu_lock);
 out:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        return ret;
 }
 
index 0da020c..0b8da1c 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/fixmap.h>
 #include <asm/kasan.h>
 #include <asm/memory.h>
-#include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/ptdump.h>
 
index df8ae73..8afb238 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/processor.h>
 #include <asm/sysreg.h>
 #include <asm/system_misc.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/traps.h>
 
@@ -498,11 +497,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
         * validly references user space from well defined areas of the code,
         * we can bug out early if this is from code which shouldn't.
         */
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                if (!user_mode(regs) && !search_exception_tables(regs->pc))
                        goto no_context;
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in which
@@ -511,7 +510,7 @@ retry:
                might_sleep();
 #ifdef CONFIG_DEBUG_VM
                if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        goto no_context;
                }
 #endif
@@ -533,7 +532,7 @@ retry:
                        goto retry;
                }
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Handle the "normal" (no error) case first.
index 2339811..7291b26 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/kernel-pgtable.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
 
@@ -191,7 +190,7 @@ void __init kasan_copy_shadow(pgd_t *pgdir)
 
        pgdp = pgd_offset_k(KASAN_SHADOW_START);
        pgdp_end = pgd_offset_k(KASAN_SHADOW_END);
-       pgdp_new = pgd_offset_raw(pgdir, KASAN_SHADOW_START);
+       pgdp_new = pgd_offset_pgd(pgdir, KASAN_SHADOW_START);
        do {
                set_pgd(pgdp_new, READ_ONCE(*pgdp));
        } while (pgdp++, pgdp_new++, pgdp != pgdp_end);
index e7fbc62..990929c 100644 (file)
@@ -341,7 +341,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
                                 int flags)
 {
        unsigned long addr, end, next;
-       pgd_t *pgdp = pgd_offset_raw(pgdir, virt);
+       pgd_t *pgdp = pgd_offset_pgd(pgdir, virt);
 
        /*
         * If the virtual and physical address don't have the same offset
@@ -663,13 +663,13 @@ static void __init map_kernel(pgd_t *pgdp)
                           &vmlinux_initdata, 0, VM_NO_GUARD);
        map_kernel_segment(pgdp, _data, _end, PAGE_KERNEL, &vmlinux_data, 0, 0);
 
-       if (!READ_ONCE(pgd_val(*pgd_offset_raw(pgdp, FIXADDR_START)))) {
+       if (!READ_ONCE(pgd_val(*pgd_offset_pgd(pgdp, FIXADDR_START)))) {
                /*
                 * The fixmap falls in a separate pgd to the kernel, and doesn't
                 * live in the carveout for the swapper_pg_dir. We can simply
                 * re-use the existing dir for the fixmap.
                 */
-               set_pgd(pgd_offset_raw(pgdp, FIXADDR_START),
+               set_pgd(pgd_offset_pgd(pgdp, FIXADDR_START),
                        READ_ONCE(*pgd_offset_k(FIXADDR_START)));
        } else if (CONFIG_PGTABLE_LEVELS > 3) {
                pgd_t *bm_pgdp;
@@ -682,7 +682,7 @@ static void __init map_kernel(pgd_t *pgdp)
                 * entry instead.
                 */
                BUG_ON(!IS_ENABLED(CONFIG_ARM64_16K_PAGES));
-               bm_pgdp = pgd_offset_raw(pgdp, FIXADDR_START);
+               bm_pgdp = pgd_offset_pgd(pgdp, FIXADDR_START);
                bm_p4dp = p4d_offset(bm_pgdp, FIXADDR_START);
                bm_pudp = pud_set_fixmap_offset(bm_p4dp, FIXADDR_START);
                pud_populate(&init_mm, bm_pudp, lm_alias(bm_pmd));
index 4175bcb..23f648c 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/sched.h>
 #include <linux/vmalloc.h>
 
-#include <asm/pgtable.h>
 #include <asm/set_memory.h>
 #include <asm/tlbflush.h>
 
index b7bebb1..796e47a 100644 (file)
@@ -9,11 +9,11 @@
 
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/asm-offsets.h>
 #include <asm/asm_pointer_auth.h>
 #include <asm/hwcap.h>
-#include <asm/pgtable.h>
 #include <asm/pgtable-hwdef.h>
 #include <asm/cpufeature.h>
 #include <asm/alternative.h>
index 197c473..8a91ced 100644 (file)
@@ -26,7 +26,6 @@
 #define pgd_clear(pgdp)
 #define kern_addr_valid(addr) (1)
 
-#define pmd_offset(a, b)       ((void *)0)
 #define pmd_none(x)            (!pmd_val(x))
 #define pmd_present(x)         (pmd_val(x))
 #define pmd_clear(xp)          do { set_pmd(xp, __pmd(0)); } while (0)
@@ -64,6 +63,4 @@ extern unsigned long empty_zero_page;
  */
 #define pgprot_writecombine pgprot_noncached
 
-#include <asm-generic/pgtable.h>
-
 #endif /* _ASM_C6X_PGTABLE_H */
index ec61034..2b9121c 100644 (file)
@@ -344,12 +344,13 @@ asmlinkage int process_exception(struct pt_regs *regs)
 
 static int kstack_depth_to_print = 48;
 
-static void show_trace(unsigned long *stack, unsigned long *endstack)
+static void show_trace(unsigned long *stack, unsigned long *endstack,
+                      const char *loglvl)
 {
        unsigned long addr;
        int i;
 
-       pr_debug("Call trace:");
+       printk("%sCall trace:", loglvl);
        i = 0;
        while (stack + 1 <= endstack) {
                addr = *stack++;
@@ -364,16 +365,17 @@ static void show_trace(unsigned long *stack, unsigned long *endstack)
                if (__kernel_text_address(addr)) {
 #ifndef CONFIG_KALLSYMS
                        if (i % 5 == 0)
-                               pr_debug("\n        ");
+                               printk("%s\n        ", loglvl);
 #endif
-                       pr_debug(" [<%08lx>] %pS\n", addr, (void *)addr);
+                       printk("%s [<%08lx>] %pS\n", loglvl, addr, (void *)addr);
                        i++;
                }
        }
-       pr_debug("\n");
+       printk("%s\n", loglvl);
 }
 
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack(struct task_struct *task, unsigned long *stack,
+               const char *loglvl)
 {
        unsigned long *p, *endstack;
        int i;
@@ -398,7 +400,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)
                pr_cont(" %08lx", *p++);
        }
        pr_cont("\n");
-       show_trace(stack, endstack);
+       show_trace(stack, endstack, loglvl);
 }
 
 int is_valid_bugaddr(unsigned long addr)
index 332f51b..e909587 100644 (file)
@@ -4,7 +4,7 @@
 #ifndef __ASM_CSKY_IO_H
 #define __ASM_CSKY_IO_H
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <linux/types.h>
 #include <linux/version.h>
 
index 9ab4a44..2002cb7 100644 (file)
 #define pgd_ERROR(e) \
        pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
 
-/* Find an entry in the third-level page table.. */
-#define __pte_offset_t(address) \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address) \
-       (pmd_page_vaddr(*(dir)) + __pte_offset_t(address))
-#define pte_offset_map(dir, address) \
-       ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset_t(address))
 #define pmd_page(pmd)  (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 #define pte_clear(mm, addr, ptep)      set_pte((ptep), \
        (((unsigned int) addr & PAGE_OFFSET) ? __pte(_PAGE_GLOBAL) : __pte(0)))
@@ -54,8 +47,6 @@
 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | \
                         _CACHE_MASK)
 
-#define pte_unmap(pte) ((void)(pte))
-
 #define __swp_type(x)                  (((x).val >> 4) & 0xff)
 #define __swp_offset(x)                        ((x).val >> 12)
 #define __swp_entry(type, offset)      ((swp_entry_t) {((type) << 4) | \
@@ -229,15 +220,6 @@ static inline pte_t pte_mkyoung(pte_t pte)
        return pte;
 }
 
-#define __pgd_offset(address)  pgd_index(address)
-#define __pud_offset(address)  (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
-#define __pmd_offset(address)  (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address)  pgd_offset(&init_mm, address)
-
-#define pgd_index(address)     ((address) >> PGDIR_SHIFT)
-
 #define __HAVE_PHYS_MEM_ACCESS_PROT
 struct file;
 extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
@@ -281,19 +263,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
                     (pgprot_val(newprot)));
 }
 
-/* to find an entry in a page-table-directory */
-static inline pgd_t *pgd_offset(struct mm_struct *mm, unsigned long address)
-{
-       return mm->pgd + pgd_index(address);
-}
-
-/* Find an entry in the third-level page table.. */
-static inline pte_t *pte_offset(pmd_t *dir, unsigned long address)
-{
-       return (pte_t *) (pmd_page_vaddr(*dir)) +
-               ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
-}
-
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern void paging_init(void);
 
@@ -306,6 +275,4 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
        remap_pfn_range(vma, vaddr, pfn, size, prot)
 
-#include <asm-generic/pgtable.h>
-
 #endif /* __ASM_CSKY_PGTABLE_H */
index b5ad7d9..6cd82d6 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
-#include <asm/pgtable.h>
 
 #ifdef CONFIG_CPU_CK810
 #define IS_BSR32(hi16, lo16)           (((hi16) & 0xFC00) == 0xE000)
index 5a82230..944ca2f 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <asm/thread_info.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/asm-offsets.h>
 
@@ -344,7 +343,7 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
                trace_sys_exit(regs, syscall_get_return_value(current, regs));
 }
 
-extern void show_stack(struct task_struct *task, unsigned long *stack);
+extern void show_stack(struct task_struct *task, unsigned long *stack, const char *loglvl);
 void show_regs(struct pt_regs *fp)
 {
        unsigned long   *sp;
@@ -420,6 +419,6 @@ void show_regs(struct pt_regs *fp)
        }
        pr_cont("\n");
 
-       show_stack(NULL, (unsigned long *)fp->regs[4]);
+       show_stack(NULL, (unsigned long *)fp->regs[4], KERN_INFO);
        return;
 }
index 92809e1..16ae20a 100644 (file)
@@ -91,14 +91,14 @@ static void notrace walk_stackframe(struct task_struct *task,
 
 static bool print_trace_address(unsigned long pc, void *arg)
 {
-       print_ip_sym(pc);
+       print_ip_sym((const char *)arg, pc);
        return false;
 }
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        pr_cont("Call Trace:\n");
-       walk_stackframe(task, NULL, print_trace_address, NULL);
+       walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
 }
 
 static bool save_wchan(unsigned long pc, void *arg)
index 60ff7ad..abc3dbc 100644 (file)
@@ -50,7 +50,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        unsigned long addr;
        struct mm_struct *mm = current->mm;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        addr = get_unmapped_area(NULL, STACK_TOP, PAGE_SIZE, 0, 0);
        if (IS_ERR_VALUE(addr)) {
@@ -70,7 +70,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        mm->context.vdso = (void *)addr;
 
 up_fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index 4e6dc68..0b9cbf2 100644 (file)
@@ -78,7 +78,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
                 * Do _not_ use "tsk" here. We might be inside
                 * an interrupt in the middle of a task switch..
                 */
-               int offset = __pgd_offset(address);
+               int offset = pgd_index(address);
                pgd_t *pgd, *pgd_k;
                pud_t *pud, *pud_k;
                pmd_t *pmd, *pmd_k;
@@ -120,7 +120,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
        if (in_atomic() || !mm)
                goto bad_area_nosemaphore;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto bad_area;
@@ -170,7 +170,7 @@ good_area:
                              address);
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
        /*
@@ -178,7 +178,7 @@ good_area:
         * Fix it, but check if it's kernel or user first..
         */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
        /* User mode accesses just cause a SIGSEGV */
@@ -217,7 +217,7 @@ out_of_memory:
 do_sigbus:
        tsk->thread.trap_no = (regs->sr >> 16) & 0xff;
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Kernel mode? Handle exceptions or die */
        if (!user_mode(regs))
index 3b3f622..89ec32e 100644 (file)
@@ -92,7 +92,7 @@ static void __init kmap_pages_init(void)
        vaddr = PKMAP_BASE;
        fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir);
 
-       pgd = swapper_pg_dir + __pgd_offset(vaddr);
+       pgd = swapper_pg_dir + pgd_index(vaddr);
        pud = (pud_t *)pgd;
        pmd = pmd_offset(pud, vaddr);
        pte = pte_offset_kernel(pmd, vaddr);
index cb64d86..af62712 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/setup.h>
 #include <asm/cachectl.h>
 #include <asm/dma.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
 #include <asm/sections.h>
@@ -158,9 +157,9 @@ void __init fixrange_init(unsigned long start, unsigned long end,
        unsigned long vaddr;
 
        vaddr = start;
-       i = __pgd_offset(vaddr);
-       j = __pud_offset(vaddr);
-       k = __pmd_offset(vaddr);
+       i = pgd_index(vaddr);
+       j = pud_index(vaddr);
+       k = pmd_index(vaddr);
        pgd = pgd_base + i;
 
        for ( ; (i < PTRS_PER_PGD) && (vaddr != end); pgd++, i++) {
index eb3ba6c..ed15123 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/sched.h>
 
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 
 /*
index f008287..ea833a5 100644 (file)
@@ -2,7 +2,6 @@
 #ifndef _H8300_PGTABLE_H
 #define _H8300_PGTABLE_H
 #include <asm-generic/pgtable-nopud.h>
-#include <asm-generic/pgtable.h>
 extern void paging_init(void);
 #define PAGE_NONE              __pgprot(0)    /* these mean nothing to NO_MM */
 #define PAGE_SHARED            __pgprot(0)    /* these mean nothing to NO_MM */
index e35cdf0..0ef55e3 100644 (file)
@@ -45,7 +45,6 @@
 #include <linux/uaccess.h>
 #include <asm/traps.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 
 void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
index 23a979a..28ac883 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <asm/setup.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/page.h>
 
index ef7489b..38d3354 100644 (file)
@@ -43,7 +43,6 @@
 
 #include <asm/setup.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 #include <asm/ucontext.h>
 
index e47a9e0..5d8b969 100644 (file)
@@ -115,7 +115,7 @@ void die(const char *str, struct pt_regs *fp, unsigned long err)
 
 static int kstack_depth_to_print = 24;
 
-void show_stack(struct task_struct *task, unsigned long *esp)
+void show_stack(struct task_struct *task, unsigned long *esp, const char *loglvl)
 {
        unsigned long *stack,  addr;
        int i;
@@ -125,17 +125,17 @@ void show_stack(struct task_struct *task, unsigned long *esp)
 
        stack = esp;
 
-       pr_info("Stack from %08lx:", (unsigned long)stack);
+       printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
        for (i = 0; i < kstack_depth_to_print; i++) {
                if (((unsigned long)stack & (THREAD_SIZE - 1)) >=
                    THREAD_SIZE-4)
                        break;
                if (i % 8 == 0)
-                       pr_info(" ");
+                       printk("%s ", loglvl);
                pr_cont(" %08lx", *stack++);
        }
 
-       pr_info("\nCall Trace:\n");
+       printk("%s\nCall Trace:\n", loglvl);
        i = 0;
        stack = esp;
        while (((unsigned long)stack & (THREAD_SIZE - 1)) < THREAD_SIZE-4) {
@@ -150,10 +150,10 @@ void show_stack(struct task_struct *task, unsigned long *esp)
                 */
                if (check_kernel_text(addr)) {
                        if (i % 4 == 0)
-                               pr_info("       ");
+                               printk("%s       ", loglvl);
                        pr_cont(" [<%08lx>]", addr);
                        i++;
                }
        }
-       pr_info("\n");
+       printk("%s\n", loglvl);
 }
index fabffb8..d4bc9c1 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/ptrace.h>
 
-#include <asm/pgtable.h>
 
 void die(const char *str, struct pt_regs *fp, unsigned long err);
 
index 27a0020..1f3b345 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/setup.h>
 #include <asm/segment.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 
 /*
index 3785f72..4a60e2b 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/setup.h>
 #include <asm/segment.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 #include <asm/io.h>
 
index 97b1b06..920660a 100644 (file)
@@ -15,8 +15,4 @@
 
 #include <asm-generic/fixmap.h>
 
-#define kmap_get_fixmap_pte(vaddr) \
-       pte_offset_kernel(pmd_offset(pud_offset(p4d_offset(pgd_offset_k(vaddr), \
-                               (vaddr)), (vaddr)), (vaddr)), (vaddr))
-
 #endif
index 2a17d4e..dbb22b8 100644 (file)
@@ -206,33 +206,6 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
        pte_val(*ptep) = _NULL_PTE;
 }
 
-#ifdef NEED_PMD_INDEX_DESPITE_BEING_2_LEVEL
-/**
- * pmd_index - returns the index of the entry in the PMD page
- * which would control the given virtual address
- */
-#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-#endif
-
-/**
- * pgd_index - returns the index of the entry in the PGD page
- * which would control the given virtual address
- *
- * This returns the *index* for the address in the pgd_t
- */
-#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-
-/*
- * pgd_offset - find an offset in a page-table-directory
- */
-#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
-
-/*
- * pgd_offset_k - get kernel (init_mm) pgd entry pointer for addr
- */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
 /**
  * pmd_none - check if pmd_entry is mapped
  * @pmd_entry:  pmd entry
@@ -403,31 +376,14 @@ static inline int pte_exec(pte_t pte)
  */
 #define set_pte_at(mm, addr, ptep, pte) set_pte(ptep, pte)
 
-/*
- * May need to invoke the virtual machine as well...
- */
-#define pte_unmap(pte)         do { } while (0)
-#define pte_unmap_nested(pte)  do { } while (0)
-
-/*
- * pte_offset_map - returns the linear address of the page table entry
- * corresponding to an address
- */
-#define pte_offset_map(dir, address)                                    \
-       ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-
-#define pte_offset_map_nested(pmd, addr) pte_offset_map(pmd, addr)
-
-/* pte_offset_kernel - kernel version of pte_offset */
-#define pte_offset_kernel(dir, address) \
-       ((pte_t *) (unsigned long) __va(pmd_val(*dir) & PAGE_MASK) \
-                               +  __pte_offset(address))
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return (unsigned long)__va(pmd_val(pmd) & PAGE_MASK);
+}
 
 /* ZERO_PAGE - returns the globally shared zero page */
 #define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
 
-#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
 /*
  * Swap/file PTE definitions.  If _PAGE_PRESENT is zero, the rest of the PTE is
  * interpreted as swap information.  The remaining free bits are interpreted as
@@ -460,7 +416,4 @@ static inline int pte_exec(pte_t pte)
                ((type << 1) | \
                 ((offset & 0x7ffff0) << 9) | ((offset & 0xf) << 6)) })
 
-/*  Oh boy.  There are a lot of possible arch overrides found in this file.  */
-#include <asm-generic/pgtable.h>
-
 #endif
index 69c623b..904134b 100644 (file)
@@ -79,7 +79,7 @@ static const char *ex_name(int ex)
 }
 
 static void do_show_stack(struct task_struct *task, unsigned long *fp,
-                         unsigned long ip)
+                         unsigned long ip, const char *loglvl)
 {
        int kstack_depth_to_print = 24;
        unsigned long offset, size;
@@ -93,9 +93,8 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
        if (task == NULL)
                task = current;
 
-       printk(KERN_INFO "CPU#%d, %s/%d, Call Trace:\n",
-              raw_smp_processor_id(), task->comm,
-              task_pid_nr(task));
+       printk("%sCPU#%d, %s/%d, Call Trace:\n", loglvl, raw_smp_processor_id(),
+               task->comm, task_pid_nr(task));
 
        if (fp == NULL) {
                if (task == current) {
@@ -108,7 +107,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
        }
 
        if ((((unsigned long) fp) & 0x3) || ((unsigned long) fp < 0x1000)) {
-               printk(KERN_INFO "-- Corrupt frame pointer %p\n", fp);
+               printk("%s-- Corrupt frame pointer %p\n", loglvl, fp);
                return;
        }
 
@@ -125,8 +124,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
 
                name = kallsyms_lookup(ip, &size, &offset, &modname, tmpstr);
 
-               printk(KERN_INFO "[%p] 0x%lx: %s + 0x%lx", fp, ip, name,
-                       offset);
+               printk("%s[%p] 0x%lx: %s + 0x%lx", loglvl, fp, ip, name, offset);
                if (((unsigned long) fp < low) || (high < (unsigned long) fp))
                        printk(KERN_CONT " (FP out of bounds!)");
                if (modname)
@@ -136,8 +134,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
                newfp = (unsigned long *) *fp;
 
                if (((unsigned long) newfp) & 0x3) {
-                       printk(KERN_INFO "-- Corrupt frame pointer %p\n",
-                               newfp);
+                       printk("%s-- Corrupt frame pointer %p\n", loglvl, newfp);
                        break;
                }
 
@@ -147,7 +144,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
                                                + 8);
 
                        if (regs->syscall_nr != -1) {
-                               printk(KERN_INFO "-- trap0 -- syscall_nr: %ld",
+                               printk("%s-- trap0 -- syscall_nr: %ld", loglvl,
                                        regs->syscall_nr);
                                printk(KERN_CONT "  psp: %lx  elr: %lx\n",
                                         pt_psp(regs), pt_elr(regs));
@@ -155,7 +152,7 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
                        } else {
                                /* really want to see more ... */
                                kstack_depth_to_print += 6;
-                               printk(KERN_INFO "-- %s (0x%lx)  badva: %lx\n",
+                               printk("%s-- %s (0x%lx)  badva: %lx\n", loglvl,
                                        ex_name(pt_cause(regs)), pt_cause(regs),
                                        pt_badva(regs));
                        }
@@ -178,10 +175,10 @@ static void do_show_stack(struct task_struct *task, unsigned long *fp,
        }
 }
 
-void show_stack(struct task_struct *task, unsigned long *fp)
+void show_stack(struct task_struct *task, unsigned long *fp, const char *loglvl)
 {
        /* Saved link reg is one word above FP */
-       do_show_stack(task, fp, 0);
+       do_show_stack(task, fp, 0, loglvl);
 }
 
 int die(const char *str, struct pt_regs *regs, long err)
@@ -207,7 +204,7 @@ int die(const char *str, struct pt_regs *regs, long err)
 
        print_modules();
        show_regs(regs);
-       do_show_stack(current, &regs->r30, pt_elr(regs));
+       do_show_stack(current, &regs->r30, pt_elr(regs), KERN_EMERG);
 
        bust_spinlocks(0);
        add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
index 25a1d9c..b70970a 100644 (file)
@@ -52,7 +52,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        unsigned long vdso_base;
        struct mm_struct *mm = current->mm;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        /* Try to get it loaded right near ld.so/glibc. */
@@ -76,7 +76,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        mm->context.vdso = (void *)vdso_base;
 
 up_fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index f8ddc35..650bca9 100644 (file)
@@ -11,7 +11,7 @@
  */
 #include <linux/types.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 /*
  * For clear_user(), exploit previously defined copy_to_user function
index 72334b2..cd3808f 100644 (file)
@@ -11,7 +11,6 @@
  * execptions.
  */
 
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 #include <linux/uaccess.h>
 #include <linux/mm.h>
@@ -55,7 +54,7 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs)
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto bad_area;
@@ -107,11 +106,11 @@ good_area:
                        }
                }
 
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                return;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Handle copyin/out exception cases */
        if (!user_mode(regs))
@@ -138,7 +137,7 @@ good_area:
        return;
 
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        if (user_mode(regs)) {
                force_sig_fault(SIGSEGV, si_code, (void __user *)address);
index 787b0a9..1085089 100644 (file)
@@ -364,44 +364,13 @@ pgd_index (unsigned long address)
 
        return (region << (PAGE_SHIFT - 6)) | l1index;
 }
-
-/* The offset in the 1-level directory is given by the 3 region bits
-   (61..63) and the level-1 bits.  */
-static inline pgd_t*
-pgd_offset (const struct mm_struct *mm, unsigned long address)
-{
-       return mm->pgd + pgd_index(address);
-}
-
-/* In the kernel's mapped region we completely ignore the region number
-   (since we know it's in region number 5). */
-#define pgd_offset_k(addr) \
-       (init_mm.pgd + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)))
+#define pgd_index pgd_index
 
 /* Look up a pgd entry in the gate area.  On IA-64, the gate-area
    resides in the kernel-mapped segment, hence we use pgd_offset_k()
    here.  */
 #define pgd_offset_gate(mm, addr)      pgd_offset_k(addr)
 
-#if CONFIG_PGTABLE_LEVELS == 4
-/* Find an entry in the second-level page table.. */
-#define pud_offset(dir,addr) \
-       ((pud_t *) p4d_page_vaddr(*(dir)) + (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)))
-#endif
-
-/* Find an entry in the third-level page table.. */
-#define pmd_offset(dir,addr) \
-       ((pmd_t *) pud_page_vaddr(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
-
-/*
- * Find an entry in the third-level page table.  This looks more complicated than it
- * should be because some platforms place page tables in high memory.
- */
-#define pte_index(addr)                (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir,addr)    ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir,addr)       pte_offset_kernel(dir, addr)
-#define pte_unmap(pte)                 do { } while (0)
-
 /* atomic versions of the some PTE manipulations: */
 
 static inline int
@@ -583,6 +552,5 @@ extern struct page *zero_page_memmap_ptr;
 #include <asm-generic/pgtable-nopud.h>
 #endif
 #include <asm-generic/pgtable-nop4d.h>
-#include <asm-generic/pgtable.h>
 
 #endif /* _ASM_IA64_PGTABLE_H */
index 7ff574d..b3aa460 100644 (file)
@@ -114,7 +114,6 @@ static inline long regs_return_value(struct pt_regs *regs)
   struct task_struct;                  /* forward decl */
   struct unw_frame_info;               /* forward decl */
 
-  extern void ia64_do_show_stack (struct unw_frame_info *, void *);
   extern unsigned long ia64_get_user_rbs_end (struct task_struct *, struct pt_regs *,
                                              unsigned long *);
   extern long ia64_peek (struct task_struct *, struct switch_stack *, unsigned long,
index 5c7e79e..8aa473a 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/page-flags.h>
 
 #include <asm/intrinsics.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/io.h>
 #include <asm/extable.h>
 
index a54eacb..f932b25 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/io.h>
 #include <asm/kregs.h>
 #include <asm/meminit.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mca.h>
 #include <asm/setup.h>
index 2ac9263..c5efac2 100644 (file)
  */
 
 
+#include <linux/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/cache.h>
 #include <asm/errno.h>
 #include <asm/kregs.h>
 #include <asm/asm-offsets.h>
-#include <asm/pgtable.h>
 #include <asm/percpu.h>
 #include <asm/processor.h>
 #include <asm/thread_info.h>
index e6f4517..30f1ef7 100644 (file)
  */
 
 
+#include <linux/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/fpu.h>
 #include <asm/kregs.h>
 #include <asm/mmu_context.h>
 #include <asm/asm-offsets.h>
 #include <asm/pal.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/mca_asm.h>
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/export.h>
 
 #ifdef CONFIG_HOTPLUG_CPU
index e7862e4..6fff934 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/pgtable.h>
 
 #include <linux/jiffies.h>
 #include <linux/errno.h>
@@ -37,7 +38,6 @@
 #include <asm/intrinsics.h>
 #include <asm/io.h>
 #include <asm/hw_irq.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 #ifdef CONFIG_PERFMON
index 1efcbe5..d6d4229 100644 (file)
  */
 
 
+#include <linux/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/break.h>
 #include <asm/kregs.h>
 #include <asm/asm-offsets.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/thread_info.h>
index a6d6a05..7a7df94 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/preempt.h>
 #include <linux/extable.h>
 #include <linux/kdebug.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/exception.h>
 
index 6fb54df..2703f77 100644 (file)
@@ -1631,7 +1631,7 @@ default_monarch_init_process(struct notifier_block *self, unsigned long val, voi
        if (read_trylock(&tasklist_lock)) {
                do_each_thread (g, t) {
                        printk("\nBacktrace of pid %d (%s)\n", t->pid, t->comm);
-                       show_stack(t, NULL);
+                       show_stack(t, NULL, KERN_DEFAULT);
                } while_each_thread (g, t);
                read_unlock(&tasklist_lock);
        }
index 086cfa4..0d6b8cf 100644 (file)
@@ -25,9 +25,9 @@
  *             Use per cpu MCA/INIT stacks for all data.
  */
 #include <linux/threads.h>
+#include <linux/pgtable.h>
 
 #include <asm/asmmacro.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mca_asm.h>
 #include <asm/mca.h>
index df25700..971f166 100644 (file)
@@ -2260,13 +2260,13 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
         * now we atomically find some area in the address space and
         * remap the buffer in it.
         */
-       down_write(&task->mm->mmap_sem);
+       mmap_write_lock(task->mm);
 
        /* find some free area in address space, must have mmap sem held */
        vma->vm_start = get_unmapped_area(NULL, 0, size, 0, MAP_PRIVATE|MAP_ANONYMOUS);
        if (IS_ERR_VALUE(vma->vm_start)) {
                DPRINT(("Cannot find unmapped area for size %ld\n", size));
-               up_write(&task->mm->mmap_sem);
+               mmap_write_unlock(task->mm);
                goto error;
        }
        vma->vm_end = vma->vm_start + size;
@@ -2277,7 +2277,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
        /* can only be applied to current task, need to have the mm semaphore held when called */
        if (pfm_remap_buffer(vma, (unsigned long)smpl_buf, vma->vm_start, size)) {
                DPRINT(("Can't remap buffer\n"));
-               up_write(&task->mm->mmap_sem);
+               mmap_write_unlock(task->mm);
                goto error;
        }
 
@@ -2288,7 +2288,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
        insert_vm_struct(mm, vma);
 
        vm_stat_account(vma->vm_mm, vma->vm_flags, vma_pages(vma));
-       up_write(&task->mm->mmap_sem);
+       mmap_write_unlock(task->mm);
 
        /*
         * keep track of user level virtual address
index 10cb938..96dfb9e 100644 (file)
@@ -64,12 +64,13 @@ EXPORT_SYMBOL(boot_option_idle_override);
 void (*pm_power_off) (void);
 EXPORT_SYMBOL(pm_power_off);
 
-void
+static void
 ia64_do_show_stack (struct unw_frame_info *info, void *arg)
 {
        unsigned long ip, sp, bsp;
+       const char *loglvl = arg;
 
-       printk("\nCall Trace:\n");
+       printk("%s\nCall Trace:\n", loglvl);
        do {
                unw_get_ip(info, &ip);
                if (ip == 0)
@@ -77,22 +78,22 @@ ia64_do_show_stack (struct unw_frame_info *info, void *arg)
 
                unw_get_sp(info, &sp);
                unw_get_bsp(info, &bsp);
-               printk(" [<%016lx>] %pS\n"
+               printk("%s [<%016lx>] %pS\n"
                         "                                sp=%016lx bsp=%016lx\n",
-                        ip, (void *)ip, sp, bsp);
+                        loglvl, ip, (void *)ip, sp, bsp);
        } while (unw_unwind(info) >= 0);
 }
 
 void
-show_stack (struct task_struct *task, unsigned long *sp)
+show_stack (struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        if (!task)
-               unw_init_running(ia64_do_show_stack, NULL);
+               unw_init_running(ia64_do_show_stack, (void *)loglvl);
        else {
                struct unw_frame_info info;
 
                unw_init_from_blocked_task(&info, task);
-               ia64_do_show_stack(&info, NULL);
+               ia64_do_show_stack(&info, (void *)loglvl);
        }
 }
 
@@ -150,7 +151,7 @@ show_regs (struct pt_regs *regs)
                               ((i == sof - 1) || (i % 3) == 2) ? "\n" : " ");
                }
        } else
-               show_stack(NULL, NULL);
+               show_stack(NULL, NULL, KERN_DEFAULT);
 }
 
 /* local support for deprecated console_print */
index bf9c24d..82aaacf 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/elf.h>
 #include <linux/tracehook.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/ptrace_offsets.h>
 #include <asm/rse.h>
index 7124fe7..527a7b8 100644 (file)
@@ -8,10 +8,10 @@
  * Copyright (C) 2005 Khalid Aziz  <khalid.aziz@hp.com>
  * Copyright (C) 2005 Intel Corp,  Zou Nan hai <nanhai.zou@intel.com>
  */
+#include <linux/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/kregs.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mca_asm.h>
 
        /* Must be relocatable PIC code callable as a C function
@@ -319,5 +319,3 @@ GLOBAL_ENTRY(ia64_dump_cpu_regs)
         ;;
         br.ret.sptk.many rp
 END(ia64_dump_cpu_regs)
-
-
index 4009383..d2d440f 100644 (file)
@@ -25,6 +25,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
 #include <linux/acpi.h>
 #include <linux/console.h>
@@ -56,7 +57,6 @@
 #include <asm/meminit.h>
 #include <asm/page.h>
 #include <asm/patch.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/sal.h>
 #include <asm/sections.h>
index de35c54..bbfd421 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/sal.h>
index 6501d9a..016683b 100644 (file)
@@ -50,7 +50,6 @@
 #include <asm/mca.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
 #include <asm/sal.h>
index 3776ef2..0750f36 100644 (file)
@@ -19,9 +19,9 @@
 #include <linux/nmi.h>
 #include <linux/genalloc.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
 #include <asm/pal.h>
-#include <asm/pgtable.h>
 #include <linux/atomic.h>
 #include <asm/tlbflush.h>
 
index 6b5652e..d259690 100644 (file)
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
+#include <linux/pgtable.h>
 #include <asm/cache.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/thread_info.h>
 
 #define EMITS_PT_NOTE
index 8786fa5..d7d31c7 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <asm/meminit.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/mca.h>
 
index 12242aa..3a4dec3 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/prefetch.h>
 #include <linux/uaccess.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/exception.h>
 
@@ -75,8 +74,8 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
        mask = ((((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
                | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
 
-       /* mmap_sem is performance critical.... */
-       prefetchw(&mm->mmap_sem);
+       /* mmap_lock is performance critical.... */
+       prefetchw(&mm->mmap_lock);
 
        /*
         * If we're in an interrupt or have no user context, we must not take the fault..
@@ -87,7 +86,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 #ifdef CONFIG_VIRTUAL_MEM_MAP
        /*
         * If fault is in region 5 and we are in the kernel, we may already
-        * have the mmap_sem (pfn_valid macro is called during mmap). There
+        * have the mmap_lock (pfn_valid macro is called during mmap). There
         * is no vma for region 5 addr's anyway, so skip getting the semaphore
         * and go directly to the exception handling code.
         */
@@ -107,7 +106,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
        if (mask & VM_WRITE)
                flags |= FAULT_FLAG_WRITE;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma_prev(mm, address, &prev_vma);
        if (!vma && !prev_vma )
@@ -174,7 +173,7 @@ retry:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                        /* No need to up_read(&mm->mmap_sem) as we would
+                        /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -183,7 +182,7 @@ retry:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
   check_expansion:
@@ -214,7 +213,7 @@ retry:
        goto good_area;
 
   bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 #ifdef CONFIG_VIRTUAL_MEM_MAP
   bad_area_no_up:
 #endif
@@ -280,7 +279,7 @@ retry:
        return;
 
   out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
index ca760f6..0b3fb4c 100644 (file)
@@ -118,13 +118,13 @@ ia64_init_addr_space (void)
                vma->vm_end = vma->vm_start + PAGE_SIZE;
                vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
                vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-               down_write(&current->mm->mmap_sem);
+               mmap_write_lock(current->mm);
                if (insert_vm_struct(current->mm, vma)) {
-                       up_write(&current->mm->mmap_sem);
+                       mmap_write_unlock(current->mm);
                        vm_area_free(vma);
                        return;
                }
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
        }
 
        /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
@@ -136,13 +136,13 @@ ia64_init_addr_space (void)
                        vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
                        vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO |
                                        VM_DONTEXPAND | VM_DONTDUMP;
-                       down_write(&current->mm->mmap_sem);
+                       mmap_write_lock(current->mm);
                        if (insert_vm_struct(current->mm, vma)) {
-                               up_write(&current->mm->mmap_sem);
+                               mmap_write_unlock(current->mm);
                                vm_area_free(vma);
                                return;
                        }
-                       up_write(&current->mm->mmap_sem);
+                       mmap_write_unlock(current->mm);
                }
        }
 }
index 6a309a3..05f137d 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/rtc.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/MC68EZ328.h>
 #ifdef CONFIG_UCSIMM
index 81b5491..ada87b2 100644 (file)
@@ -22,8 +22,8 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/rtc.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/MC68VZ328.h>
 #include <asm/bootstd.h>
index 1c8e8a8..e8dfdd2 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/clocksource.h>
 #include <linux/rtc.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/MC68VZ328.h>
 
index 4eb911d..8f23b2f 100644 (file)
@@ -32,7 +32,6 @@
 #include <asm/bootinfo-amiga.h>
 #include <asm/byteorder.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
 #include <asm/irq.h>
index 7d168e6..762da5d 100644 (file)
@@ -13,7 +13,6 @@
 #include <asm/bootinfo.h>
 #include <asm/bootinfo-apollo.h>
 #include <asm/byteorder.h>
-#include <asm/pgtable.h>
 #include <asm/apollohw.h>
 #include <asm/irq.h>
 #include <asm/machdep.h>
index 1c1181e..a8724d9 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <asm/atarihw.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <asm/atariints.h>
 
 
index 6152f9f..ce79b32 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/setup.h>
 #include <asm/machdep.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/atarihw.h>
 #include <asm/atari_stram.h>
 #include <asm/io.h>
index 8ebaabc..50f4d01 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/bootinfo.h>
 #include <asm/bootinfo-vme.h>
 #include <asm/byteorder.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
index 0031cd3..8d4ec05 100644 (file)
@@ -170,7 +170,7 @@ static inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp)
 }
 
 #define __pte_page(pte)        ((unsigned long) (pte_val(pte) & PAGE_MASK))
-#define __pmd_page(pmd)        ((unsigned long) (pmd_val(pmd)))
+#define pmd_page_vaddr(pmd)    ((unsigned long) (pmd_val(pmd)))
 
 static inline int pte_none(pte_t pte)
 {
@@ -311,64 +311,6 @@ static inline pte_t pte_mkcache(pte_t pte)
 extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
 
 /*
- * Find an entry in a pagetable directory.
- */
-#define pgd_index(address)     ((address) >> PGDIR_SHIFT)
-#define pgd_offset(mm, address)        ((mm)->pgd + pgd_index(address))
-
-/*
- * Find an entry in a kernel pagetable directory.
- */
-#define pgd_offset_k(address)  pgd_offset(&init_mm, address)
-
-/*
- * Find an entry in the third-level pagetable.
- */
-#define __pte_offset(address)  ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address) \
-       ((pte_t *) __pmd_page(*(dir)) + __pte_offset(address))
-
-/*
- * Disable caching for page at given kernel virtual address.
- */
-static inline void nocache_page(void *vaddr)
-{
-       pgd_t *dir;
-       p4d_t *p4dp;
-       pud_t *pudp;
-       pmd_t *pmdp;
-       pte_t *ptep;
-       unsigned long addr = (unsigned long) vaddr;
-
-       dir = pgd_offset_k(addr);
-       p4dp = p4d_offset(dir, addr);
-       pudp = pud_offset(p4dp, addr);
-       pmdp = pmd_offset(pudp, addr);
-       ptep = pte_offset_kernel(pmdp, addr);
-       *ptep = pte_mknocache(*ptep);
-}
-
-/*
- * Enable caching for page at given kernel virtual address.
- */
-static inline void cache_page(void *vaddr)
-{
-       pgd_t *dir;
-       p4d_t *p4dp;
-       pud_t *pudp;
-       pmd_t *pmdp;
-       pte_t *ptep;
-       unsigned long addr = (unsigned long) vaddr;
-
-       dir = pgd_offset_k(addr);
-       p4dp = p4d_offset(dir, addr);
-       pudp = pud_offset(p4dp, addr);
-       pmdp = pmd_offset(pudp, addr);
-       ptep = pte_offset_kernel(pmdp, addr);
-       *ptep = pte_mkcache(*ptep);
-}
-
-/*
  * Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e))
  */
 #define __swp_type(x)          ((x).val & 0xFF)
@@ -380,9 +322,6 @@ static inline void cache_page(void *vaddr)
 
 #define pmd_page(pmd)          (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
 
-#define pte_offset_map(pmdp, addr) ((pte_t *)__pmd_page(*pmdp) + \
-                                      __pte_offset(addr))
-#define pte_unmap(pte)         ((void) 0)
 #define pfn_pte(pfn, prot)     __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 #define pte_pfn(pte)           (pte_val(pte) >> PAGE_SHIFT)
 
index c66e429..b4fc3b4 100644 (file)
@@ -18,6 +18,12 @@ extern void init_pointer_table(void *table, int type);
 extern void *get_pointer_table(int type);
 extern int free_pointer_table(void *table, int type);
 
+/*
+ * Allocate and free page tables. The xxx_kernel() versions are
+ * used to allocate a kernel page table - this turns on ASN bits
+ * if any.
+ */
+
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
 {
        return get_pointer_table(TABLE_PTE);
@@ -82,7 +88,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page
 {
        pmd_set(pmd, page);
 }
-#define pmd_pgtable(pmd) ((pgtable_t)__pmd_page(pmd))
+#define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
 
 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 {
index 48f19f0..8076467 100644 (file)
@@ -128,7 +128,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
 }
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
-#define __pmd_page(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
+#define pmd_page_vaddr(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
 #define pud_page_vaddr(pud) ((unsigned long)__va(pud_val(pud) & _TABLE_MASK))
 
 
@@ -192,91 +192,9 @@ static inline pte_t pte_mkcache(pte_t pte)
        return pte;
 }
 
-#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
-
-#define pgd_index(address)     ((address) >> PGDIR_SHIFT)
-
-/* to find an entry in a page-table-directory */
-static inline pgd_t *pgd_offset(const struct mm_struct *mm,
-                               unsigned long address)
-{
-       return mm->pgd + pgd_index(address);
-}
-
 #define swapper_pg_dir kernel_pg_dir
 extern pgd_t kernel_pg_dir[128];
 
-static inline pgd_t *pgd_offset_k(unsigned long address)
-{
-       return kernel_pg_dir + (address >> PGDIR_SHIFT);
-}
-
-
-/* Find an entry in the second-level page table.. */
-static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
-{
-       return (pmd_t *)pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PMD-1));
-}
-
-/* Find an entry in the third-level page table.. */
-static inline pte_t *pte_offset_kernel(pmd_t *pmdp, unsigned long address)
-{
-       return (pte_t *)__pmd_page(*pmdp) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
-}
-
-#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-#define pte_unmap(pte)         ((void)0)
-
-/*
- * Allocate and free page tables. The xxx_kernel() versions are
- * used to allocate a kernel page table - this turns on ASN bits
- * if any.
- */
-
-/* Prior to calling these routines, the page should have been flushed
- * from both the cache and ATC, or the CPU might not notice that the
- * cache setting for the page has been changed. -jskov
- */
-static inline void nocache_page(void *vaddr)
-{
-       unsigned long addr = (unsigned long)vaddr;
-
-       if (CPU_IS_040_OR_060) {
-               pgd_t *dir;
-               p4d_t *p4dp;
-               pud_t *pudp;
-               pmd_t *pmdp;
-               pte_t *ptep;
-
-               dir = pgd_offset_k(addr);
-               p4dp = p4d_offset(dir, addr);
-               pudp = pud_offset(p4dp, addr);
-               pmdp = pmd_offset(pudp, addr);
-               ptep = pte_offset_kernel(pmdp, addr);
-               *ptep = pte_mknocache(*ptep);
-       }
-}
-
-static inline void cache_page(void *vaddr)
-{
-       unsigned long addr = (unsigned long)vaddr;
-
-       if (CPU_IS_040_OR_060) {
-               pgd_t *dir;
-               p4d_t *p4dp;
-               pud_t *pudp;
-               pmd_t *pmdp;
-               pte_t *ptep;
-
-               dir = pgd_offset_k(addr);
-               p4dp = p4d_offset(dir, addr);
-               pudp = pud_offset(p4dp, addr);
-               pmdp = pmd_offset(pudp, addr);
-               ptep = pte_offset_kernel(pmdp, addr);
-               *ptep = pte_mkcache(*ptep);
-       }
-}
-
 /* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) */
 #define __swp_type(x)          (((x).val >> 4) & 0xff)
 #define __swp_offset(x)                ((x).val >> 12)
index f0e5167..aca22c2 100644 (file)
@@ -176,7 +176,6 @@ pgprot_t pgprot_dmacoherent(pgprot_t prot);
 #define pgprot_dmacoherent(prot)       pgprot_dmacoherent(prot)
 
 #endif /* CONFIG_COLDFIRE */
-#include <asm-generic/pgtable.h>
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _M68K_PGTABLE_H */
index ccc4568..87151d6 100644 (file)
@@ -53,6 +53,4 @@ extern void paging_init(void);
 #define        KMAP_START      0
 #define        KMAP_END        0xffffffff
 
-#include <asm-generic/pgtable.h>
-
 #endif /* _M68KNOMMU_PGTABLE_H */
index 0caa18a..5b24283 100644 (file)
@@ -112,8 +112,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 
 #define __pte_page(pte) \
 ((unsigned long) __va ((pte_val (pte) & SUN3_PAGE_PGNUM_MASK) << PAGE_SHIFT))
-#define __pmd_page(pmd) \
-((unsigned long) __va (pmd_val (pmd) & PAGE_MASK))
+
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return (unsigned long)__va(pmd_val(pmd) & PAGE_MASK);
+}
 
 static inline int pte_none (pte_t pte) { return !pte_val (pte); }
 static inline int pte_present (pte_t pte) { return pte_val (pte) & SUN3_PAGE_VALID; }
@@ -127,7 +130,7 @@ static inline void pte_clear (struct mm_struct *mm, unsigned long addr, pte_t *p
 ({ pte_t __pte; pte_val(__pte) = pfn | pgprot_val(pgprot); __pte; })
 
 #define pte_page(pte)          virt_to_page(__pte_page(pte))
-#define pmd_page(pmd)          virt_to_page(__pmd_page(pmd))
+#define pmd_page(pmd)          virt_to_page(pmd_page_vaddr(pmd))
 
 
 static inline int pmd_none2 (pmd_t *pmd) { return !pmd_val (*pmd); }
@@ -171,21 +174,6 @@ static inline pte_t pte_mkcache(pte_t pte) { return pte; }
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
 
-/* Find an entry in a pagetable directory. */
-#define pgd_index(address)     ((address) >> PGDIR_SHIFT)
-
-#define pgd_offset(mm, address) \
-((mm)->pgd + pgd_index(address))
-
-/* Find an entry in a kernel pagetable directory. */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/* Find an entry in the third-level pagetable. */
-#define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
-#define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address))
-#define pte_offset_map(pmd, address) ((pte_t *)page_address(pmd_page(*pmd)) + pte_index(address))
-#define pte_unmap(pte) do { } while (0)
-
 /* Macros to (de)construct the fake PTEs representing swap pages. */
 #define __swp_type(x)          ((x).val & 0x7F)
 #define __swp_offset(x)                (((x).val) >> 7)
index ef04c43..93f2a84 100644 (file)
@@ -10,8 +10,8 @@
 #ifndef __ASM_SUN3X_FLOPPY_H
 #define __ASM_SUN3X_FLOPPY_H
 
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/sun3x.h>
 
index a547884..29de2b3 100644 (file)
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/bootinfo.h>
 #include <asm/bootinfo-amiga.h>
 #include <asm/bootinfo-atari.h>
 #include <asm/bootinfo-vme.h>
 #include <asm/setup.h>
 #include <asm/entry.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #ifdef CONFIG_MAC
index 8f0d914..90ae376 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/traps.h>
 #include <asm/machdep.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 
 
 asmlinkage void ret_from_fork(void);
index 748c63b..94b3b27 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/uaccess.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 
 /*
index a63483d..e779b19 100644 (file)
@@ -38,7 +38,6 @@
 #include <asm/bootinfo.h>
 #include <asm/irq.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 
 unsigned long memory_start;
index 05610e6..b3ff395 100644 (file)
@@ -47,7 +47,6 @@
 
 #include <asm/setup.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 #include <asm/ucontext.h>
 #include <asm/cacheflush.h>
index 18a4de7..1c235d8 100644 (file)
@@ -399,7 +399,7 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
                 * Verify that the specified address region actually belongs
                 * to this process.
                 */
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                vma = find_vma(current->mm, addr);
                if (!vma || addr < vma->vm_start || addr + len > vma->vm_end)
                        goto out_unlock;
@@ -450,7 +450,7 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
            }
        }
 out_unlock:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 out:
        return ret;
 }
@@ -472,7 +472,7 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
                spinlock_t *ptl;
                unsigned long mem_value;
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                pgd = pgd_offset(mm, (unsigned long)mem);
                if (!pgd_present(*pgd))
                        goto bad_access;
@@ -501,11 +501,11 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
                        __put_user(newval, mem);
 
                pte_unmap_unlock(pte, ptl);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                return mem_value;
 
              bad_access:
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                /* This is not necessarily a bad access, we can get here if
                   a memory we're trying to write to should be copied-on-write.
                   Make the kernel do the necessary page stuff, then re-iterate.
@@ -545,13 +545,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
        struct mm_struct *mm = current->mm;
        unsigned long mem_value;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        mem_value = *mem;
        if (mem_value == oldval)
                *mem = newval;
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return mem_value;
 }
 
index 344f93d..df6fc78 100644 (file)
@@ -811,13 +811,13 @@ asmlinkage void buserr_c(struct frame *fp)
 
 static int kstack_depth_to_print = 48;
 
-void show_trace(unsigned long *stack)
+static void show_trace(unsigned long *stack, const char *loglvl)
 {
        unsigned long *endstack;
        unsigned long addr;
        int i;
 
-       pr_info("Call Trace:");
+       printk("%sCall Trace:", loglvl);
        addr = (unsigned long)stack + THREAD_SIZE - 1;
        endstack = (unsigned long *)(addr & -THREAD_SIZE);
        i = 0;
@@ -916,7 +916,7 @@ void show_registers(struct pt_regs *regs)
        default:
                pr_cont("\n");
        }
-       show_stack(NULL, (unsigned long *)addr);
+       show_stack(NULL, (unsigned long *)addr, KERN_INFO);
 
        pr_info("Code:");
        set_fs(KERNEL_DS);
@@ -935,7 +935,8 @@ void show_registers(struct pt_regs *regs)
        pr_cont("\n");
 }
 
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack(struct task_struct *task, unsigned long *stack,
+               const char *loglvl)
 {
        unsigned long *p;
        unsigned long *endstack;
@@ -949,7 +950,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)
        }
        endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
 
-       pr_info("Stack from %08lx:", (unsigned long)stack);
+       printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
        p = stack;
        for (i = 0; i < kstack_depth_to_print; i++) {
                if (p + 1 > endstack)
@@ -959,7 +960,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)
                pr_cont(" %08lx", *p++);
        }
        pr_cont("\n");
-       show_trace(stack);
+       show_trace(stack, loglvl);
 }
 
 /*
index 1b4c562..928dbd3 100644 (file)
@@ -26,7 +26,6 @@
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 
 /*
index d0126ab..5c9f3a2 100644 (file)
@@ -36,7 +36,6 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 
 #include <asm/macintosh.h>
index 3bfb5c8..a94a814 100644 (file)
@@ -86,7 +86,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma(mm, address);
        if (!vma)
@@ -165,7 +165,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -174,7 +174,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return 0;
 
 /*
@@ -182,7 +182,7 @@ good_area:
  * us unable to handle the page fault gracefully.
  */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
@@ -211,6 +211,6 @@ acc_err:
        current->thread.faddr = address;
 
 send_sig:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return send_fault_sig(regs);
 }
index 6d31476..5304085 100644 (file)
@@ -141,7 +141,7 @@ static inline void init_pointer_tables(void)
                        if (!pmd_present(*pmd))
                                continue;
 
-                       pte_dir = (pte_t *)__pmd_page(*pmd);
+                       pte_dir = (pte_t *)pmd_page_vaddr(*pmd);
                        init_pointer_table(pte_dir, TABLE_PTE);
                }
        }
index 80064e6..29f4792 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <asm/setup.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/mcf_pgalloc.h>
 #include <asm/tlbflush.h>
index 904c2a6..2bb006b 100644 (file)
@@ -45,6 +45,31 @@ unsigned long mm_cachebits;
 EXPORT_SYMBOL(mm_cachebits);
 #endif
 
+/* Prior to calling these routines, the page should have been flushed
+ * from both the cache and ATC, or the CPU might not notice that the
+ * cache setting for the page has been changed. -jskov
+ */
+static inline void nocache_page(void *vaddr)
+{
+       unsigned long addr = (unsigned long)vaddr;
+
+       if (CPU_IS_040_OR_060) {
+               pte_t *ptep = virt_to_kpte(addr);
+
+               *ptep = pte_mknocache(*ptep);
+       }
+}
+
+static inline void cache_page(void *vaddr)
+{
+       unsigned long addr = (unsigned long)vaddr;
+
+       if (CPU_IS_040_OR_060) {
+               pte_t *ptep = virt_to_kpte(addr);
+
+               *ptep = pte_mkcache(*ptep);
+       }
+}
 
 /*
  * Motorola 680x0 user's manual recommends using uncached memory for address
index ae03555..4f2a7ef 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/vmalloc.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/sun3mmu.h>
 
index 5d8d956..dad4942 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/setup.h>
 #include <linux/uaccess.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 
index 545a1fe..490700a 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/bootinfo.h>
 #include <asm/bootinfo-vme.h>
 #include <asm/byteorder.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
index 9bc2da6..5b86d10 100644 (file)
@@ -32,7 +32,6 @@
 #include <asm/bootinfo.h>
 #include <asm/bootinfo-vme.h>
 #include <asm/byteorder.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
index f318900..4627de3 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <asm/io.h>
 #include <asm/bootinfo.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/traps.h>
index 229ea37..7204c0e 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/setup.h>
 #include <asm/contregs.h>
 #include <asm/movs.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/sun3-head.h>
 #include <asm/sun3mmu.h>
index a2c1c93..f15ff16 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/memblock.h>
 #include <linux/list.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sun3mmu.h>
 #include <asm/dvma.h>
 
index 582a128..7aa879b 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/traps.h>
 #include <linux/uaccess.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sun3mmu.h>
 #include <asm/segment.h>
 #include <asm/oplib.h>
index 399f3d0..4b560f4 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/list.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/dvma.h>
 
 #undef DVMA_DEBUG
index c4b8aa1..fef52d2 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/dvma.h>
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 
 /* IOMMU support */
index be14c89..74d2fe5 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/string.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/traps.h>
 #include <asm/sun3xprom.h>
index 1d7a912..ebb6b79 100644 (file)
 
 #include <linux/kernel.h>      /* For min/max macros */
 #include <linux/highmem.h>
+#include <linux/pgtable.h>
 #include <asm/setup.h>
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/cache.h>
-#include <asm/pgtable.h>
 
 #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
 #include <asm-generic/pgalloc.h>
index 6b056f6..3fa1df9 100644 (file)
@@ -21,7 +21,6 @@ extern int mem_init_done;
 #define pgd_bad(pgd)           (0)
 #define pgd_clear(pgdp)
 #define kern_addr_valid(addr)  (1)
-#define        pmd_offset(a, b)        ((void *) 0)
 
 #define PAGE_NONE              __pgprot(0) /* these mean nothing to non MMU */
 #define PAGE_SHARED            __pgprot(0) /* these mean nothing to non MMU */
@@ -438,27 +437,15 @@ static inline void ptep_mkdirty(struct mm_struct *mm,
 /* Convert pmd entry to page */
 /* our pmd entry is an effective address of pte table*/
 /* returns effective address of the pmd entry*/
-#define pmd_page_kernel(pmd)   ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return ((unsigned long) (pmd_val(pmd) & PAGE_MASK));
+}
 
 /* returns struct *page of the pmd entry*/
 #define pmd_page(pmd)  (pfn_to_page(__pa(pmd_val(pmd)) >> PAGE_SHIFT))
 
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/* to find an entry in a page-table-directory */
-#define pgd_index(address)      ((address) >> PGDIR_SHIFT)
-#define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))
-
 /* Find an entry in the third-level page table.. */
-#define pte_index(address)             \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, addr)   \
-       ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir, addr)              \
-       ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
-
-#define pte_unmap(pte)         kunmap_atomic(pte)
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
@@ -507,8 +494,6 @@ void __init *early_get_page(void);
 #endif /* CONFIG_MMU */
 
 #ifndef __ASSEMBLY__
-#include <asm-generic/pgtable.h>
-
 extern unsigned long ioremap_bot, ioremap_base;
 
 void setup_memory(void);
index 070ba61..6723c56 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <asm/mmu.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/extable.h>
 #include <linux/string.h>
 
index c327d67..3db8177 100644 (file)
@@ -20,7 +20,8 @@ extern struct trap_handler_info microblaze_trap_handlers;
 extern const char _hw_exception_handler;
 extern const char ex_handler_unhandled;
 
-void microblaze_unwind(struct task_struct *task, struct stack_trace *trace);
+void microblaze_unwind(struct task_struct *task, struct stack_trace *trace,
+                      const char *loglvl);
 
 #endif /* __MICROBLAZE_UNWIND_H */
 
index 95558f3..54411de 100644 (file)
@@ -68,9 +68,9 @@
 #include <asm/entry.h>
 #include <asm/current.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/signal.h>
 #include <asm/registers.h>
 #include <asm/asm-offsets.h>
index d9a2014..9f12e3c 100644 (file)
@@ -11,8 +11,8 @@
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/string.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
 int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
index dd121e3..2310daf 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/console.h>
 #include <linux/debugfs.h>
 #include <linux/of_fdt.h>
+#include <linux/pgtable.h>
 
 #include <asm/setup.h>
 #include <asm/sections.h>
@@ -33,7 +34,6 @@
 #include <asm/entry.h>
 #include <asm/cpuinfo.h>
 
-#include <asm/pgtable.h>
 
 DEFINE_PER_CPU(unsigned int, KSP);     /* Saved kernel stack pointer */
 DEFINE_PER_CPU(unsigned int, KM);      /* Kernel/user mode */
index c9125c3..bdd6d0c 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/entry.h>
 #include <asm/ucontext.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <linux/syscalls.h>
 #include <asm/cacheflush.h>
@@ -160,9 +159,6 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
        int err = 0, sig = ksig->sig;
        unsigned long address = 0;
 #ifdef CONFIG_MMU
-       pgd_t *pgdp;
-       p4d_t *p4dp;
-       pud_t *pudp;
        pmd_t *pmdp;
        pte_t *ptep;
 #endif
@@ -198,10 +194,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
 
        address = ((unsigned long)frame->tramp);
 #ifdef CONFIG_MMU
-       pgdp = pgd_offset(current->mm, address);
-       p4dp = p4d_offset(pgdp, address);
-       pudp = pud_offset(p4dp, address);
-       pmdp = pmd_offset(pudp, address);
+       pmdp = pmd_off(current->mm, address);
 
        preempt_disable();
        ptep = pte_offset_map(pmdp, address);
index b4debe2..b266c4d 100644 (file)
@@ -20,12 +20,12 @@ void save_stack_trace(struct stack_trace *trace)
 {
        /* Exclude our helper functions from the trace*/
        trace->skip += 2;
-       microblaze_unwind(NULL, trace);
+       microblaze_unwind(NULL, trace, "");
 }
 EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
-       microblaze_unwind(tsk, trace);
+       microblaze_unwind(tsk, trace, "");
 }
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
index 45bbba9..94b6fe9 100644 (file)
@@ -31,7 +31,7 @@ static int __init kstack_setup(char *s)
 }
 __setup("kstack=", kstack_setup);
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        unsigned long words_to_show;
        u32 fp = (u32) sp;
@@ -50,7 +50,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)
        if (kstack_depth_to_print && (words_to_show > kstack_depth_to_print))
                words_to_show = kstack_depth_to_print;
 
-       pr_info("Kernel Stack:\n");
+       printk("%sKernel Stack:\n", loglvl);
 
        /*
         * Make the first line an 'odd' size if necessary to get
@@ -65,11 +65,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
                        words_to_show -= line1_words;
                }
        }
-       print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32, 4, (void *)fp,
+       print_hex_dump(loglvl, "", DUMP_PREFIX_ADDRESS, 32, 4, (void *)fp,
                       words_to_show << 2, 0);
-       pr_info("\n\nCall Trace:\n");
-       microblaze_unwind(task, NULL);
-       pr_info("\n");
+       printk("%s\n\nCall Trace:\n", loglvl);
+       microblaze_unwind(task, NULL, loglvl);
+       printk("%s\n", loglvl);
 
        if (!task)
                task = current;
index 34c270c..778a761 100644 (file)
@@ -154,7 +154,8 @@ static int lookup_prev_stack_frame(unsigned long fp, unsigned long pc,
 static void microblaze_unwind_inner(struct task_struct *task,
                                    unsigned long pc, unsigned long fp,
                                    unsigned long leaf_return,
-                                   struct stack_trace *trace);
+                                   struct stack_trace *trace,
+                                   const char *loglvl);
 
 /**
  * unwind_trap - Unwind through a system trap, that stored previous state
@@ -162,16 +163,18 @@ static void microblaze_unwind_inner(struct task_struct *task,
  */
 #ifdef CONFIG_MMU
 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
-                               unsigned long fp, struct stack_trace *trace)
+                               unsigned long fp, struct stack_trace *trace,
+                               const char *loglvl)
 {
        /* To be implemented */
 }
 #else
 static inline void unwind_trap(struct task_struct *task, unsigned long pc,
-                               unsigned long fp, struct stack_trace *trace)
+                               unsigned long fp, struct stack_trace *trace,
+                               const char *loglvl)
 {
        const struct pt_regs *regs = (const struct pt_regs *) fp;
-       microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace);
+       microblaze_unwind_inner(task, regs->pc, regs->r1, regs->r15, trace, loglvl);
 }
 #endif
 
@@ -184,11 +187,13 @@ static inline void unwind_trap(struct task_struct *task, unsigned long pc,
  *                               the caller's return address.
  * @trace : Where to store stack backtrace (PC values).
  *         NULL == print backtrace to kernel log
+ * @loglvl : Used for printk log level if (trace == NULL).
  */
 static void microblaze_unwind_inner(struct task_struct *task,
                             unsigned long pc, unsigned long fp,
                             unsigned long leaf_return,
-                            struct stack_trace *trace)
+                            struct stack_trace *trace,
+                            const char *loglvl)
 {
        int ofs = 0;
 
@@ -214,11 +219,11 @@ static void microblaze_unwind_inner(struct task_struct *task,
                        const struct pt_regs *regs =
                                (const struct pt_regs *) fp;
 #endif
-                       pr_info("HW EXCEPTION\n");
+                       printk("%sHW EXCEPTION\n", loglvl);
 #ifndef CONFIG_MMU
                        microblaze_unwind_inner(task, regs->r17 - 4,
                                                fp + EX_HANDLER_STACK_SIZ,
-                                               regs->r15, trace);
+                                               regs->r15, trace, loglvl);
 #endif
                        return;
                }
@@ -228,8 +233,8 @@ static void microblaze_unwind_inner(struct task_struct *task,
                        if ((return_to >= handler->start_addr)
                            && (return_to <= handler->end_addr)) {
                                if (!trace)
-                                       pr_info("%s\n", handler->trap_name);
-                               unwind_trap(task, pc, fp, trace);
+                                       printk("%s%s\n", loglvl, handler->trap_name);
+                               unwind_trap(task, pc, fp, trace, loglvl);
                                return;
                        }
                }
@@ -248,13 +253,13 @@ static void microblaze_unwind_inner(struct task_struct *task,
                } else {
                        /* Have we reached userland? */
                        if (unlikely(pc == task_pt_regs(task)->pc)) {
-                               pr_info("[<%p>] PID %lu [%s]\n",
-                                       (void *) pc,
+                               printk("%s[<%p>] PID %lu [%s]\n",
+                                       loglvl, (void *) pc,
                                        (unsigned long) task->pid,
                                        task->comm);
                                break;
                        } else
-                               print_ip_sym(pc);
+                               print_ip_sym(loglvl, pc);
                }
 
                /* Stop when we reach anything not part of the kernel */
@@ -282,14 +287,16 @@ static void microblaze_unwind_inner(struct task_struct *task,
  * @task  : Task whose stack we are to unwind (NULL == current)
  * @trace : Where to store stack backtrace (PC values).
  *         NULL == print backtrace to kernel log
+ * @loglvl : Used for printk log level if (trace == NULL).
  */
-void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)
+void microblaze_unwind(struct task_struct *task, struct stack_trace *trace,
+                      const char *loglvl)
 {
        if (task) {
                if (task == current) {
                        const struct pt_regs *regs = task_pt_regs(task);
                        microblaze_unwind_inner(task, regs->pc, regs->r1,
-                                               regs->r15, trace);
+                                               regs->r15, trace, loglvl);
                } else {
                        struct thread_info *thread_info =
                                (struct thread_info *)(task->stack);
@@ -299,7 +306,8 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)
                        microblaze_unwind_inner(task,
                                                (unsigned long) &_switch_to,
                                                cpu_context->r1,
-                                               cpu_context->r15, trace);
+                                               cpu_context->r15,
+                                               trace, loglvl);
                }
        } else {
                unsigned long pc, fp;
@@ -314,7 +322,7 @@ void microblaze_unwind(struct task_struct *task, struct stack_trace *trace)
                );
 
                /* Since we are not a leaf function, use leaf_return = 0 */
-               microblaze_unwind_inner(current, pc, fp, 0, trace);
+               microblaze_unwind_inner(current, pc, fp, 0, trace, loglvl);
        }
 }
 
index 3248141..a2bfe58 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/interrupt.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <linux/mmu_context.h>
 #include <linux/uaccess.h>
@@ -125,7 +124,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
        /* When running in the kernel we expect faults to occur only to
         * addresses in user space.  All other faults represent errors in the
         * kernel and should generate an OOPS.  Unfortunately, in the case of an
-        * erroneous fault occurring in a code path which already holds mmap_sem
+        * erroneous fault occurring in a code path which already holds mmap_lock
         * we will deadlock attempting to validate the fault against the
         * address space.  Luckily the kernel only validly references user
         * space from well defined areas of code, which are listed in the
@@ -137,12 +136,12 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
         * source.  If this is invalid we can skip the address space check,
         * thus avoiding the deadlock.
         */
-       if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
+       if (unlikely(!mmap_read_trylock(mm))) {
                if (kernel_mode(regs) && !search_exception_tables(regs->pc))
                        goto bad_area_nosemaphore;
 
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        }
 
        vma = find_vma(mm, address);
@@ -239,7 +238,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -248,7 +247,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * keep track of tlb+htab misses that are good addrs but
@@ -259,7 +258,7 @@ good_area:
        return;
 
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
        pte_errors++;
@@ -278,7 +277,7 @@ bad_area_nosemaphore:
  * us unable to handle the page fault gracefully.
  */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                bad_page_fault(regs, address, SIGKILL);
        else
@@ -286,7 +285,7 @@ out_of_memory:
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (user_mode(regs)) {
                force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
                return;
index d943f69..521b59b 100644 (file)
@@ -50,15 +50,6 @@ unsigned long lowmem_size;
 pte_t *kmap_pte;
 EXPORT_SYMBOL(kmap_pte);
 
-static inline pte_t *virt_to_kpte(unsigned long vaddr)
-{
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-
-       return pte_offset_kernel(pmd_offset(pud, vaddr), vaddr);
-}
-
 static void __init highmem_init(void)
 {
        pr_debug("%x\n", (u32)PKMAP_BASE);
index 68c26ca..38ccb90 100644 (file)
@@ -32,8 +32,8 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <linux/io.h>
 #include <asm/mmu.h>
index 89fa6e6..da0712a 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <asm/sgialib.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/bootinfo.h>
 
 #undef DEBUG
index 1784d43..743535b 100644 (file)
@@ -69,9 +69,6 @@ enum fixed_addresses {
 
 #include <asm-generic/fixmap.h>
 
-#define kmap_get_fixmap_pte(vaddr)                                     \
-       pte_offset_kernel(pmd_offset(pud_offset(p4d_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr)), (vaddr))
-
 /*
  * Called from pgtable_init()
  */
index e3f446d..e0c9cd4 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/floppy.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 
 /*
  * How to access the FDC's registers.
index 095000c..294ebb8 100644 (file)
@@ -15,7 +15,6 @@
 #include <asm/addrspace.h>
 #include <asm/jazz.h>
 #include <asm/jazzdma.h>
-#include <asm/pgtable.h>
 
 static inline unsigned char fd_inb(unsigned int base, unsigned int reg)
 {
index 1945c89..a950fc1 100644 (file)
@@ -195,28 +195,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
 
 #define pte_page(x)            pfn_to_page(pte_pfn(x))
 
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-#define pgd_index(address)     (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-#define pud_index(address)     (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
-#define pmd_index(address)     (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-/* to find an entry in a page-table-directory */
-#define pgd_offset(mm, addr)   ((mm)->pgd + pgd_index(addr))
-
-/* Find an entry in the third-level page table.. */
-#define __pte_offset(address)                                          \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset(dir, address)                                       \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_kernel(dir, address)                                        \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-
-#define pte_offset_map(dir, address)                                   \
-       ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-
 #if defined(CONFIG_CPU_R3K_TLB)
 
 /* Swap entries must have VALID bit cleared. */
index ee5dc0c..1e7d6ce 100644 (file)
 
 extern pte_t invalid_pte_table[PTRS_PER_PTE];
 
-#define pud_index(address)     (((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
-
 #ifndef __PAGETABLE_PUD_FOLDED
 /*
  * For 4-level pagetables we defines these ourselves, for 3-level the
@@ -222,11 +220,6 @@ static inline unsigned long p4d_page_vaddr(p4d_t p4d)
 
 #define p4d_index(address)     (((address) >> P4D_SHIFT) & (PTRS_PER_P4D - 1))
 
-static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
-{
-       return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
-}
-
 static inline void set_p4d(p4d_t *p4d, p4d_t p4dval)
 {
        *p4d = p4dval;
@@ -320,15 +313,6 @@ static inline void pud_clear(pud_t *pudp)
 #define pfn_pmd(pfn, prot)     __pmd(((pfn) << _PFN_SHIFT) | pgprot_val(prot))
 #endif
 
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-#define pgd_index(address)     (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-#define pmd_index(address)     (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-/* to find an entry in a page-table-directory */
-#define pgd_offset(mm, addr)   ((mm)->pgd + pgd_index(addr))
-
 #ifndef __PAGETABLE_PMD_FOLDED
 static inline unsigned long pud_page_vaddr(pud_t pud)
 {
@@ -337,24 +321,8 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
 #define pud_phys(pud)          virt_to_phys((void *)pud_val(pud))
 #define pud_page(pud)          (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT))
 
-/* Find an entry in the second-level page table.. */
-static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
-{
-       return (pmd_t *) pud_page_vaddr(*pud) + pmd_index(address);
-}
 #endif
 
-/* Find an entry in the third-level page table.. */
-#define __pte_offset(address)                                          \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset(dir, address)                                       \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_kernel(dir, address)                                        \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_map(dir, address)                                   \
-       ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-
 /*
  * Initialize a new pgd / pmd table with invalid pointers.
  */
index 32760b4..dd7a0f5 100644 (file)
@@ -736,8 +736,6 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
 
 #define gup_fast_permitted(start, end) (!cpu_has_dc_aliases)
 
-#include <asm-generic/pgtable.h>
-
 /*
  * We provide our own get_unmapped area to cope with the virtual aliasing
  * constraints placed on us by the cache architecture.
index 04b9c40..495ba7c 100644 (file)
 #include <linux/smp.h>
 #include <linux/spinlock.h>
 #include <linux/irq.h>
+#include <linux/pgtable.h>
 
 #include <asm/irq_cpu.h>
 #include <asm/i8259.h>
 #include <asm/io.h>
 #include <asm/jazz.h>
-#include <asm/pgtable.h>
 #include <asm/tlbmisc.h>
 
 static DEFINE_RAW_SPINLOCK(r4030_lock);
index c64a297..014773f 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/uaccess.h>
 #include <asm/dma.h>
 #include <asm/jazzdma.h>
-#include <asm/pgtable.h>
 
 /*
  * Set this to one to enable additional vdma debug code.
index 1b5e121..04aab41 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 #include <asm/jazz.h>
 #include <asm/jazzdma.h>
 #include <asm/reboot.h>
-#include <asm/pgtable.h>
 #include <asm/tlbmisc.h>
 
 extern asmlinkage void jazz_handle_int(void);
index 8713b69..3c0c3d1 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/spinlock.h>
 #include <linux/jump_label.h>
 
-#include <asm/pgtable.h>       /* MODULE_START */
 
 struct mips_hi16 {
        struct mips_hi16 *next;
index b2a7975..ff5320b 100644 (file)
@@ -42,7 +42,6 @@
 #include <asm/irq.h>
 #include <asm/mips-cps.h>
 #include <asm/msa.h>
-#include <asm/pgtable.h>
 #include <asm/mipsregs.h>
 #include <asm/processor.h>
 #include <asm/reg.h>
index 414b6e9..2a61641 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/fpu.h>
 #include <asm/mipsregs.h>
 #include <asm/mipsmtregs.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/processor.h>
 #include <asm/syscall.h>
index 2525eca..afcf27a 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/fpu.h>
 #include <asm/mipsregs.h>
 #include <asm/mipsmtregs.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/reg.h>
 #include <asm/syscall.h>
index 9058e9d..2f51350 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/kexec.h>
 
 #include <asm/time.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/bootinfo.h>
 #include <asm/cacheflush.h>
index 22f805a..7c32c95 100644 (file)
@@ -57,7 +57,6 @@
 #include <asm/mipsmtregs.h>
 #include <asm/module.h>
 #include <asm/msa.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 #include <asm/sections.h>
 #include <asm/siginfo.h>
@@ -108,26 +107,26 @@ void (*board_bind_eic_interrupt)(int irq, int regset);
 void (*board_ebase_setup)(void);
 void(*board_cache_error_setup)(void);
 
-static void show_raw_backtrace(unsigned long reg29)
+static void show_raw_backtrace(unsigned long reg29, const char *loglvl)
 {
        unsigned long *sp = (unsigned long *)(reg29 & ~3);
        unsigned long addr;
 
-       printk("Call Trace:");
+       printk("%sCall Trace:", loglvl);
 #ifdef CONFIG_KALLSYMS
-       printk("\n");
+       printk("%s\n", loglvl);
 #endif
        while (!kstack_end(sp)) {
                unsigned long __user *p =
                        (unsigned long __user *)(unsigned long)sp++;
                if (__get_user(addr, p)) {
-                       printk(" (Bad stack address)");
+                       printk("%s (Bad stack address)", loglvl);
                        break;
                }
                if (__kernel_text_address(addr))
-                       print_ip_sym(addr);
+                       print_ip_sym(loglvl, addr);
        }
-       printk("\n");
+       printk("%s\n", loglvl);
 }
 
 #ifdef CONFIG_KALLSYMS
@@ -140,7 +139,8 @@ static int __init set_raw_show_trace(char *str)
 __setup("raw_show_trace", set_raw_show_trace);
 #endif
 
-static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
+static void show_backtrace(struct task_struct *task, const struct pt_regs *regs,
+                          const char *loglvl)
 {
        unsigned long sp = regs->regs[29];
        unsigned long ra = regs->regs[31];
@@ -150,12 +150,12 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
                task = current;
 
        if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) {
-               show_raw_backtrace(sp);
+               show_raw_backtrace(sp, loglvl);
                return;
        }
-       printk("Call Trace:\n");
+       printk("%sCall Trace:\n", loglvl);
        do {
-               print_ip_sym(pc);
+               print_ip_sym(loglvl, pc);
                pc = unwind_stack(task, &sp, pc, &ra);
        } while (pc);
        pr_cont("\n");
@@ -166,19 +166,19 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs)
  * with at least a bit of error checking ...
  */
 static void show_stacktrace(struct task_struct *task,
-       const struct pt_regs *regs)
+       const struct pt_regs *regs, const char *loglvl)
 {
        const int field = 2 * sizeof(unsigned long);
        long stackdata;
        int i;
        unsigned long __user *sp = (unsigned long __user *)regs->regs[29];
 
-       printk("Stack :");
+       printk("%sStack :", loglvl);
        i = 0;
        while ((unsigned long) sp & (PAGE_SIZE - 1)) {
                if (i && ((i % (64 / field)) == 0)) {
                        pr_cont("\n");
-                       printk("       ");
+                       printk("%s       ", loglvl);
                }
                if (i > 39) {
                        pr_cont(" ...");
@@ -194,10 +194,10 @@ static void show_stacktrace(struct task_struct *task,
                i++;
        }
        pr_cont("\n");
-       show_backtrace(task, regs);
+       show_backtrace(task, regs, loglvl);
 }
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        struct pt_regs regs;
        mm_segment_t old_fs = get_fs();
@@ -221,7 +221,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)
         * the stack in the kernel (not user) address space.
         */
        set_fs(KERNEL_DS);
-       show_stacktrace(task, &regs);
+       show_stacktrace(task, &regs, loglvl);
        set_fs(old_fs);
 }
 
@@ -373,7 +373,7 @@ void show_registers(struct pt_regs *regs)
        if (!user_mode(regs))
                /* Necessary for getting the correct stack content */
                set_fs(KERNEL_DS);
-       show_stacktrace(current, regs);
+       show_stacktrace(current, regs, KERN_DEFAULT);
        show_code((unsigned int __user *) regs->cp0_epc);
        printk("\n");
        set_fs(old_fs);
@@ -793,13 +793,13 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)
                return 1;
 
        case SIGSEGV:
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                vma = find_vma(current->mm, (unsigned long)fault_addr);
                if (vma && (vma->vm_start <= (unsigned long)fault_addr))
                        si_code = SEGV_ACCERR;
                else
                        si_code = SEGV_MAPERR;
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                force_sig_fault(SIGSEGV, si_code, fault_addr);
                return 1;
 
index 3adb735..242dc5e 100644 (file)
@@ -94,7 +94,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        struct vm_area_struct *vma;
        int ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        if (IS_ENABLED(CONFIG_MIPS_FP_SUPPORT)) {
@@ -187,6 +187,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        ret = 0;
 
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
index 3b0148c..2416fa4 100644 (file)
 #include <linux/sched/signal.h>
 #include <linux/fs.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 
 #include <asm/fpu.h>
 #include <asm/page.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 #include <linux/kvm_host.h>
 
index 7dad7a2..49bd160 100644 (file)
@@ -168,7 +168,7 @@ static pte_t *kvm_mips_walk_pgd(pgd_t *pgd, struct kvm_mmu_memory_cache *cache,
                clear_page(new_pte);
                pmd_populate_kernel(NULL, pmd, new_pte);
        }
-       return pte_offset(pmd, addr);
+       return pte_offset_kernel(pmd, addr);
 }
 
 /* Caller must hold kvm->mm_lock */
@@ -187,8 +187,8 @@ static pte_t *kvm_mips_pte_for_gpa(struct kvm *kvm,
 static bool kvm_mips_flush_gpa_pte(pte_t *pte, unsigned long start_gpa,
                                   unsigned long end_gpa)
 {
-       int i_min = __pte_offset(start_gpa);
-       int i_max = __pte_offset(end_gpa);
+       int i_min = pte_index(start_gpa);
+       int i_max = pte_index(end_gpa);
        bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PTE - 1);
        int i;
 
@@ -215,7 +215,7 @@ static bool kvm_mips_flush_gpa_pmd(pmd_t *pmd, unsigned long start_gpa,
                if (!pmd_present(pmd[i]))
                        continue;
 
-               pte = pte_offset(pmd + i, 0);
+               pte = pte_offset_kernel(pmd + i, 0);
                if (i == i_max)
                        end = end_gpa;
 
@@ -312,8 +312,8 @@ static int kvm_mips_##name##_pte(pte_t *pte, unsigned long start,   \
                                 unsigned long end)                     \
 {                                                                      \
        int ret = 0;                                                    \
-       int i_min = __pte_offset(start);                                \
-       int i_max = __pte_offset(end);                                  \
+       int i_min = pte_index(start);                           \
+       int i_max = pte_index(end);                                     \
        int i;                                                          \
        pte_t old, new;                                                 \
                                                                        \
@@ -346,7 +346,7 @@ static int kvm_mips_##name##_pmd(pmd_t *pmd, unsigned long start,   \
                if (!pmd_present(pmd[i]))                               \
                        continue;                                       \
                                                                        \
-               pte = pte_offset(pmd + i, 0);                           \
+               pte = pte_offset_kernel(pmd + i, 0);                            \
                if (i == i_max)                                         \
                        cur_end = end;                                  \
                                                                        \
@@ -842,8 +842,8 @@ void kvm_trap_emul_invalidate_gva(struct kvm_vcpu *vcpu, unsigned long addr,
 static bool kvm_mips_flush_gva_pte(pte_t *pte, unsigned long start_gva,
                                   unsigned long end_gva)
 {
-       int i_min = __pte_offset(start_gva);
-       int i_max = __pte_offset(end_gva);
+       int i_min = pte_index(start_gva);
+       int i_max = pte_index(end_gva);
        bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PTE - 1);
        int i;
 
@@ -877,7 +877,7 @@ static bool kvm_mips_flush_gva_pmd(pmd_t *pmd, unsigned long start_gva,
                if (!pmd_present(pmd[i]))
                        continue;
 
-               pte = pte_offset(pmd + i, 0);
+               pte = pte_offset_kernel(pmd + i, 0);
                if (i == i_max)
                        end = end_gva;
 
index 5d436c5..fc8aee0 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/cpu.h>
 #include <asm/bootinfo.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/tlb.h>
 #include <asm/tlbdebug.h>
index 5a11e83..60763ef 100644 (file)
@@ -594,7 +594,7 @@ static void kvm_mips_emul_free_gva_pt(pgd_t *pgd)
                                pmd_va = pud_va | (k << PMD_SHIFT);
                                if (pmd_va >= end)
                                        break;
-                               pte = pte_offset(pmd + k, 0);
+                               pte = pte_offset_kernel(pmd + k, 0);
                                pte_free_kernel(NULL, pte);
                        }
                        pmd_free(NULL, pmd);
index 83ed372..5a418ba 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/mipsregs.h>
 #include <asm/mmu_context.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/tlbdebug.h>
 
 void dump_tlb_regs(void)
index b97d9c5..10b4bf7 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/mipsregs.h>
 #include <asm/mmu_context.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/tlbdebug.h>
 
 extern int r3k_have_wired_reg;
index 4baf965..8ae181e 100644 (file)
@@ -20,7 +20,6 @@
 #include <asm/cpu-features.h>
 #include <asm/cpu-type.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/r4kcache.h>
 #include <asm/traps.h>
 #include <asm/mmu_context.h>
index 780dd2a..df6755c 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/isadep.h>
 #include <asm/io.h>
@@ -240,9 +239,6 @@ static void r3k_flush_cache_page(struct vm_area_struct *vma,
        unsigned long kaddr = KSEG0ADDR(pfn << PAGE_SHIFT);
        int exec = vma->vm_flags & VM_EXEC;
        struct mm_struct *mm = vma->vm_mm;
-       pgd_t *pgdp;
-       p4d_t *p4dp;
-       pud_t *pudp;
        pmd_t *pmdp;
        pte_t *ptep;
 
@@ -253,11 +249,8 @@ static void r3k_flush_cache_page(struct vm_area_struct *vma,
        if (cpu_context(smp_processor_id(), mm) == 0)
                return;
 
-       pgdp = pgd_offset(mm, addr);
-       p4dp = p4d_offset(pgdp, addr);
-       pudp = pud_offset(p4dp, addr);
-       pmdp = pmd_offset(pudp, addr);
-       ptep = pte_offset(pmdp, addr);
+       pmdp = pmd_off(mm, addr);
+       ptep = pte_offset_kernel(pmdp, addr);
 
        /* Invalid => no such page in the cache.  */
        if (!(pte_val(*ptep) & _PAGE_PRESENT))
index 6fb83ac..49569e5 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/cpu-type.h>
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/r4kcache.h>
 #include <asm/sections.h>
 #include <asm/mmu_context.h>
@@ -653,9 +652,6 @@ static inline void local_r4k_flush_cache_page(void *args)
        int exec = vma->vm_flags & VM_EXEC;
        struct mm_struct *mm = vma->vm_mm;
        int map_coherent = 0;
-       pgd_t *pgdp;
-       p4d_t *p4dp;
-       pud_t *pudp;
        pmd_t *pmdp;
        pte_t *ptep;
        void *vaddr;
@@ -668,11 +664,8 @@ static inline void local_r4k_flush_cache_page(void *args)
                return;
 
        addr &= PAGE_MASK;
-       pgdp = pgd_offset(mm, addr);
-       p4dp = p4d_offset(pgdp, addr);
-       pudp = pud_offset(p4dp, addr);
-       pmdp = pmd_offset(pudp, addr);
-       ptep = pte_offset(pmdp, addr);
+       pmdp = pmd_off(mm, addr);
+       ptep = pte_offset_kernel(pmdp, addr);
 
        /*
         * If the page isn't marked valid, the page cannot possibly be
index 2d479cc..03dfbb4 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <asm/cacheops.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/isadep.h>
 #include <asm/io.h>
@@ -169,9 +168,6 @@ static void tx39_flush_cache_page(struct vm_area_struct *vma, unsigned long page
 {
        int exec = vma->vm_flags & VM_EXEC;
        struct mm_struct *mm = vma->vm_mm;
-       pgd_t *pgdp;
-       p4d_t *p4dp;
-       pud_t *pudp;
        pmd_t *pmdp;
        pte_t *ptep;
 
@@ -183,11 +179,8 @@ static void tx39_flush_cache_page(struct vm_area_struct *vma, unsigned long page
                return;
 
        page &= PAGE_MASK;
-       pgdp = pgd_offset(mm, page);
-       p4dp = p4d_offset(pgdp, page);
-       pudp = pud_offset(p4dp, page);
-       pmdp = pmd_offset(pudp, page);
-       ptep = pte_offset(pmdp, page);
+       pmdp = pmd_off(mm, page);
+       ptep = pte_offset_kernel(pmdp, page);
 
        /*
         * If the page isn't marked valid, the page cannot possibly be
index f8d62cd..01b168a 100644 (file)
@@ -97,7 +97,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto bad_area;
@@ -181,7 +181,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -190,7 +190,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
 /*
@@ -198,7 +198,7 @@ good_area:
  * Fix it, but check if it's kernel or user first..
  */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
        /* User mode accesses just cause a SIGSEGV */
@@ -250,14 +250,14 @@ out_of_memory:
         * We ran out of memory, call the OOM killer, and return the userspace
         * (which will retry the fault, or kill us if we got oom-killed).
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Kernel mode? Handle exceptions or die */
        if (!user_mode(regs))
index 8e87269..5fec7f4 100644 (file)
@@ -90,5 +90,5 @@ void __init kmap_init(void)
 
        /* cache the first kmap pte */
        kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
-       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
+       kmap_pte = virt_to_kpte(kmap_vstart);
 }
index 7c9f0c0..336b581 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/maar.h>
 #include <asm/mmu_context.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/fixmap.h>
index c557889..cd805b0 100644 (file)
@@ -20,7 +20,6 @@
 #include <asm/inst.h>
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/prefetch.h>
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
index 37c7a01..bd4b065 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/memblock.h>
 #include <linux/highmem.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 
index 6fd6e96..183ff9f 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 
index ea059cd..d723868 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <asm/bcache.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/bootinfo.h>
 #include <asm/sgi/ip22.h>
 #include <asm/sgi/mc.h>
index eedad47..97dc051 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/bcache.h>
 #include <asm/cacheops.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/r4kcache.h>
 #include <asm/mips-cps.h>
index c7b94c9..736615d 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/bcache.h>
 #include <asm/cacheops.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/r4kcache.h>
 
index 50f2075..a36622e 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/mm.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/tlbmisc.h>
 #include <asm/isadep.h>
index d7a9d5f..6677dcb 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/bootinfo.h>
 #include <asm/hazards.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 #include <asm/tlbmisc.h>
 
index 38c2042..14f8ba9 100644 (file)
 #include <linux/smp.h>
 #include <linux/string.h>
 #include <linux/cache.h>
+#include <linux/pgtable.h>
 
 #include <asm/cacheflush.h>
 #include <asm/cpu-type.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/war.h>
 #include <asm/uasm.h>
 #include <asm/setup.h>
index 32bcb8d..a4daf8c 100644 (file)
@@ -16,7 +16,6 @@
 #include <asm/bootinfo.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/sgialib.h>
 #include <asm/time.h>
 #include <asm/sn/agent.h>
index c0e3363..79c434f 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/platform_device.h>
 
 #include <asm/time.h>
-#include <asm/pgtable.h>
 #include <asm/sgialib.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/arch.h>
index 828ce13..be1b2cf 100644 (file)
@@ -14,7 +14,6 @@
 #include <asm/ip32/crime.h>
 #include <asm/bootinfo.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 
 extern void crime_init(void);
index 5717647..fe986d0 100644 (file)
@@ -7,7 +7,6 @@
 #include <asm/proc-fns.h>
 #include <asm/kmap_types.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 
 /*
  * Right now we initialize only a single pte table. It can be extended
index 476cc4d..419f984 100644 (file)
@@ -186,16 +186,10 @@ extern void paging_init(void);
 #define pte_clear(mm,addr,ptep)        set_pte_at((mm),(addr),(ptep), __pte(0))
 #define pte_page(pte)          (pfn_to_page(pte_pfn(pte)))
 
-#define pte_index(address)                   (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address)             ((pte_t *)pmd_page_kernel(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address)        ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address)  pte_offset_map(dir, address)
-#define pmd_page_kernel(pmd)                ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
-
-#define pte_unmap(pte)         do { } while (0)
-#define pte_unmap_nested(pte)  do { } while (0)
-
-#define pmd_off_k(address)     pmd_offset(pud_offset(p4d_offset(pgd_offset_k(address), (address)), (address)), (address))
+static unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK));
+}
 
 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 /*
@@ -346,12 +340,6 @@ static inline pmd_t __mk_pmd(pte_t * ptep, unsigned long prot)
  *
 */
 
-/* to find an entry in a page-table-directory */
-#define pgd_index(address)      (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-#define pgd_offset(mm, address)        ((mm)->pgd + pgd_index(address))
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)      pgd_offset(&init_mm, addr)
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        const unsigned long mask = 0xfff;
@@ -374,8 +362,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
 #define kern_addr_valid(addr)  (1)
 
-#include <asm-generic/pgtable.h>
-
 /*
  * We provide our own arch_get_unmapped_area to cope with VIPT caches.
  */
index fcefb62..7347f00 100644 (file)
@@ -3,10 +3,10 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/ptrace.h>
 #include <asm/asm-offsets.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <linux/sizes.h>
 #include <asm/thread_info.h>
 
index 1e31829..3897fd1 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleloader.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 void *module_alloc(unsigned long size)
 {
index f4d386b..6a9772b 100644 (file)
@@ -97,18 +97,19 @@ static void dump_instr(struct pt_regs *regs)
 }
 
 #define LOOP_TIMES (100)
-static void __dump(struct task_struct *tsk, unsigned long *base_reg)
+static void __dump(struct task_struct *tsk, unsigned long *base_reg,
+                  const char *loglvl)
 {
        unsigned long ret_addr;
        int cnt = LOOP_TIMES, graph = 0;
-       pr_emerg("Call Trace:\n");
+       printk("%sCall Trace:\n", loglvl);
        if (!IS_ENABLED(CONFIG_FRAME_POINTER)) {
                while (!kstack_end(base_reg)) {
                        ret_addr = *base_reg++;
                        if (__kernel_text_address(ret_addr)) {
                                ret_addr = ftrace_graph_ret_addr(
                                                tsk, &graph, ret_addr, NULL);
-                               print_ip_sym(ret_addr);
+                               print_ip_sym(loglvl, ret_addr);
                        }
                        if (--cnt < 0)
                                break;
@@ -124,17 +125,17 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)
 
                                ret_addr = ftrace_graph_ret_addr(
                                                tsk, &graph, ret_addr, NULL);
-                               print_ip_sym(ret_addr);
+                               print_ip_sym(loglvl, ret_addr);
                        }
                        if (--cnt < 0)
                                break;
                        base_reg = (unsigned long *)next_fp;
                }
        }
-       pr_emerg("\n");
+       printk("%s\n", loglvl);
 }
 
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 {
        unsigned long *base_reg;
 
@@ -151,7 +152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
                else
                        __asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(base_reg));
        }
-       __dump(tsk, base_reg);
+       __dump(tsk, base_reg, loglvl);
        barrier();
 }
 
index 90bcae6..e16009a 100644 (file)
@@ -130,7 +130,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        vdso_mapping_len += L1_cache_info[DCACHE].aliasing_num - 1;
 #endif
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        addr = vdso_random_addr(vdso_mapping_len);
@@ -185,12 +185,12 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
                goto up_fail;
        }
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return 0;
 
 up_fail:
        mm->context.vdso = NULL;
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index f331e53..8fb73f6 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/uaccess.h>
 #include <linux/perf_event.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 extern void die(const char *str, struct pt_regs *regs, long err);
@@ -127,12 +126,12 @@ void do_page_fault(unsigned long entry, unsigned long addr,
         * validly references user space from well defined areas of the code,
         * we can bug out early if this is from code which shouldn't.
         */
-       if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
+       if (unlikely(!mmap_read_trylock(mm))) {
                if (!user_mode(regs) &&
                    !search_exception_tables(instruction_pointer(regs)))
                        goto no_context;
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in which
@@ -211,7 +210,7 @@ good_area:
 
        /*
         * If we need to retry but a fatal signal is pending, handle the
-        * signal first. We do not need to release the mmap_sem because it
+        * signal first. We do not need to release the mmap_lock because it
         * would already be released in __lock_page_or_retry in mm/filemap.c.
         */
        if (fault_signal_pending(fault, regs)) {
@@ -248,7 +247,7 @@ good_area:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                       /* No need to up_read(&mm->mmap_sem) as we would
+                       /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -256,7 +255,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
        /*
@@ -264,7 +263,7 @@ good_area:
         * Fix it, but check if it's kernel or user first..
         */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
 
@@ -324,14 +323,14 @@ no_context:
         */
 
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Kernel mode? Handle exceptions or die */
        if (!user_mode(regs))
index 91147cc..fa86f7b 100644 (file)
@@ -98,9 +98,6 @@ static pmd_t *fixmap_pmd_p;
 static void __init fixedrange_init(void)
 {
        unsigned long vaddr;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
        pmd_t *pmd;
 #ifdef CONFIG_HIGHMEM
        pte_t *pte;
@@ -110,10 +107,7 @@ static void __init fixedrange_init(void)
         * Fixed mappings:
         */
        vaddr = __fix_to_virt(__end_of_fixed_addresses - 1);
-       pgd = swapper_pg_dir + pgd_index(vaddr);
-       p4d = p4d_offset(pgd, vaddr);
-       pud = pud_offset(p4d, vaddr);
-       pmd = pmd_offset(pud, vaddr);
+       pmd = pmd_off_k(vaddr);
        fixmap_pmd_p = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
        if (!fixmap_pmd_p)
                panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
@@ -126,10 +120,7 @@ static void __init fixedrange_init(void)
         */
        vaddr = PKMAP_BASE;
 
-       pgd = swapper_pg_dir + pgd_index(vaddr);
-       p4d = p4d_offset(pgd, vaddr);
-       pud = pud_offset(p4d, vaddr);
-       pmd = pmd_offset(pud, vaddr);
+       pmd = pmd_off_k(vaddr);
        pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
        if (!pte)
                panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
index 837ae77..848c845 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <asm/nds32.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
 #include <asm/l2_cache.h>
@@ -16,14 +15,10 @@ extern struct cache_info L1_cache_info[2];
 
 int va_kernel_present(unsigned long addr)
 {
-       p4d_t *p4d;
-       pud_t *pud;
        pmd_t *pmd;
        pte_t *ptep, pte;
 
-       p4d = p4d_offset(pgd_offset_k(addr), addr);
-       pud = pud_offset(p4d, addr);
-       pmd = pmd_offset(pud, addr);
+       pmd = pmd_off_k(addr);
        if (!pmd_none(*pmd)) {
                ptep = pte_offset_map(pmd, addr);
                pte = *ptep;
index 47a1a3e..2600d76 100644 (file)
@@ -102,10 +102,6 @@ static inline void set_pmd(pmd_t *pmdptr, pmd_t pmdval)
        *pmdptr = pmdval;
 }
 
-/* to find an entry in a page-table-directory */
-#define pgd_index(addr)                (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-#define pgd_offset(mm, addr)   ((mm)->pgd + pgd_index(addr))
-
 static inline int pte_write(pte_t pte)         \
        { return pte_val(pte) & _PAGE_WRITE; }
 static inline int pte_dirty(pte_t pte)         \
@@ -236,27 +232,17 @@ static inline void pte_clear(struct mm_struct *mm,
  */
 #define mk_pte(page, prot)     (pfn_pte(page_to_pfn(page), prot))
 
-#define pte_unmap(pte) do { } while (0)
-
 /*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  */
 #define pmd_phys(pmd)          virt_to_phys((void *)pmd_val(pmd))
 #define pmd_page(pmd)          (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
-#define pmd_page_vaddr(pmd)    pmd_val(pmd)
-
-#define pte_offset_map(dir, addr)                      \
-       ((pte_t *) page_address(pmd_page(*dir)) +       \
-        (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)     pgd_offset(&init_mm, addr)
 
-/* Get the address to the PTE for a vaddr in specific directory */
-#define pte_offset_kernel(dir, addr)                   \
-       ((pte_t *) pmd_page_vaddr(*(dir)) +             \
-        (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return pmd_val(pmd);
+}
 
 #define pte_ERROR(e) \
        pr_err("%s:%d: bad pte %08lx.\n", \
@@ -285,8 +271,6 @@ static inline void pte_clear(struct mm_struct *mm,
 
 #define kern_addr_valid(addr)          (1)
 
-#include <asm-generic/pgtable.h>
-
 extern void __init paging_init(void);
 extern void __init mmu_init(void);
 
index e2e3f13..76e0a42 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
 /*
index 4e70404..54f7b23 100644 (file)
@@ -8,9 +8,9 @@
 
 #include <linux/export.h>
 #include <linux/string.h>
+#include <linux/pgtable.h>
 
 #include <asm/cacheflush.h>
-#include <asm/pgtable.h>
 
 /* string functions */
 
index 486db79..b172da4 100644 (file)
@@ -52,12 +52,13 @@ void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr)
 }
 
 /*
- * The show_stack is an external API which we do not use ourselves.
+ * The show_stack() is external API which we do not use ourselves.
  */
 
 int kstack_depth_to_print = 48;
 
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack(struct task_struct *task, unsigned long *stack,
+               const char *loglvl)
 {
        unsigned long *endstack, addr;
        int i;
@@ -72,16 +73,16 @@ void show_stack(struct task_struct *task, unsigned long *stack)
        addr = (unsigned long) stack;
        endstack = (unsigned long *) PAGE_ALIGN(addr);
 
-       pr_emerg("Stack from %08lx:", (unsigned long)stack);
+       printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
        for (i = 0; i < kstack_depth_to_print; i++) {
                if (stack + 1 > endstack)
                        break;
                if (i % 8 == 0)
-                       pr_emerg("\n       ");
-               pr_emerg(" %08lx", *stack++);
+                       printk("%s\n       ", loglvl);
+               printk("%s %08lx", loglvl, *stack++);
        }
 
-       pr_emerg("\nCall Trace:");
+       printk("%s\nCall Trace:", loglvl);
        i = 0;
        while (stack + 1 <= endstack) {
                addr = *stack++;
@@ -97,11 +98,11 @@ void show_stack(struct task_struct *task, unsigned long *stack)
                     (addr <= (unsigned long) _etext))) {
                        if (i % 4 == 0)
                                pr_emerg("\n       ");
-                       pr_emerg(" [<%08lx>]", addr);
+                       printk("%s [<%08lx>]", loglvl, addr);
                        i++;
                }
        }
-       pr_emerg("\n");
+       printk("%s\n", loglvl);
 }
 
 void __init trap_init(void)
index 964eac1..4112ef0 100644 (file)
@@ -83,11 +83,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                if (!user_mode(regs) && !search_exception_tables(regs->ea))
                        goto bad_area_nosemaphore;
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        }
 
        vma = find_vma(mm, address);
@@ -160,7 +160,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -169,7 +169,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
 /*
@@ -177,7 +177,7 @@ good_area:
  * Fix it, but check if it's kernel or user first..
  */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
        /* User mode accesses just cause a SIGSEGV */
@@ -215,14 +215,14 @@ no_context:
  * us unable to handle the page fault gracefully.
  */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Kernel mode? Handle exceptions or die */
        if (!user_mode(regs))
index 9afca77..61862db 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <asm/setup.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/tlb.h>
 #include <asm/mmu_context.h>
@@ -110,14 +109,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        struct mm_struct *mm = current->mm;
        int ret;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        /* Map kuser helpers to user space address */
        ret = install_special_mapping(mm, KUSER_BASE, KUSER_SIZE,
                                      VM_READ | VM_EXEC | VM_MAYREAD |
                                      VM_MAYEXEC, kuser_page);
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return ret;
 }
index 61e24a2..9b587fd 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 
-#include <asm/pgtable.h>
 #include <asm/cpuinfo.h>
 
 /* pteaddr:
index 7fea59e..f90ac35 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <asm/tlb.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/cpuinfo.h>
 
 #define TLB_INDEX_MASK         \
index e18f038..db02fb2 100644 (file)
@@ -26,7 +26,6 @@
 #define PIO_MASK               0
 
 #include <asm-generic/io.h>
-#include <asm/pgtable.h>
 
 void __iomem *ioremap(phys_addr_t offset, unsigned long size);
 extern void iounmap(void *addr);
index 219979e..9425bed 100644 (file)
@@ -363,38 +363,15 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
 }
 
 #define pmd_page(pmd)          (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
-#define pmd_page_kernel(pmd)    ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
 
-/* to find an entry in a page-table-directory. */
-#define pgd_index(address)      ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-
-#define __pgd_offset(address)   pgd_index(address)
-
-#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK));
+}
 
 #define __pmd_offset(address) \
        (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
 
-/*
- * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
- *
- * this macro returns the index of the entry in the pte page which would
- * control the given virtual address
- */
-#define __pte_offset(address)                   \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address)         \
-       ((pte_t *) pmd_page_kernel(*(dir)) +  __pte_offset(address))
-#define pte_offset_map(dir, address)           \
-       ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address)     \
-       pte_offset_map(dir, address)
-
-#define pte_unmap(pte)          do { } while (0)
-#define pte_unmap_nested(pte)   do { } while (0)
 #define pte_pfn(x)             ((unsigned long)(((x).pte)) >> PAGE_SHIFT)
 #define pfn_pte(pfn, prot)  __pte((((pfn) << PAGE_SHIFT)) | pgprot_val(prot))
 
@@ -438,8 +415,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
 
 #define kern_addr_valid(addr)           (1)
 
-#include <asm-generic/pgtable.h>
-
 typedef pte_t *pte_addr_t;
 
 #endif /* __ASSEMBLY__ */
index e9a7f0b..4a4639c 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <linux/mm.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/current.h>
 #include <linux/sched.h>
index e435ae0..18c703d 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/thread_info.h>
 #include <linux/kbuild.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 
 int main(void)
index e4a7857..a1d25c3 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 
 #include <asm/processor.h>
 #include <asm/unistd.h>
@@ -21,7 +22,6 @@
 #include <asm/spr_defs.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/asm-offsets.h>
 
 #define DISABLE_INTERRUPTS(t1,t2)                      \
index b0dc974..af355e3 100644 (file)
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/serial_reg.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/thread_info.h>
 #include <asm/cache.h>
 #include <asm/spr_defs.h>
index 7d6a62e..277ac7a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
 #include <linux/semaphore.h>
+#include <linux/pgtable.h>
 
 #include <asm/processor.h>
 #include <linux/uaccess.h>
@@ -26,7 +27,6 @@
 #include <asm/hardirq.h>
 #include <asm/delay.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 #define DECLARE_EXPORT(name) extern void name(void); EXPORT_SYMBOL(name)
 
index 6bcdca4..d7010e7 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/fs.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/spr_defs.h>
index 6a5a91c..c8f47a6 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <asm/thread_info.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 /*
  * Copy the thread state to a regset that can be interpreted by userspace.
index c0a774b..8aa438e 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/device.h>
 
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/types.h>
 #include <asm/setup.h>
 #include <asm/io.h>
index c11aa2e..206e532 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/uaccess.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/unwinder.h>
 #include <asm/sections.h>
 
@@ -41,18 +40,20 @@ unsigned long __user *lwa_addr;
 
 void print_trace(void *data, unsigned long addr, int reliable)
 {
-       pr_emerg("[<%p>] %s%pS\n", (void *) addr, reliable ? "" : "? ",
+       const char *loglvl = data;
+
+       printk("%s[<%p>] %s%pS\n", loglvl, (void *) addr, reliable ? "" : "? ",
               (void *) addr);
 }
 
 /* displays a short stack trace */
-void show_stack(struct task_struct *task, unsigned long *esp)
+void show_stack(struct task_struct *task, unsigned long *esp, const char *loglvl)
 {
        if (esp == NULL)
                esp = (unsigned long *)&esp;
 
-       pr_emerg("Call trace:\n");
-       unwind_stack(NULL, esp, print_trace);
+       printk("%sCall trace:\n", loglvl);
+       unwind_stack((void *)loglvl, esp, print_trace);
 }
 
 void show_registers(struct pt_regs *regs)
@@ -96,7 +97,7 @@ void show_registers(struct pt_regs *regs)
        if (in_kernel) {
 
                printk("\nStack: ");
-               show_stack(NULL, (unsigned long *)esp);
+               show_stack(NULL, (unsigned long *)esp, KERN_EMERG);
 
                printk("\nCode: ");
                if (regs->pc < PAGE_OFFSET)
index 6e0a11a..d2224cc 100644 (file)
@@ -104,7 +104,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
                goto no_context;
 
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
 
        if (!vma)
@@ -183,7 +183,7 @@ good_area:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                        /* No need to up_read(&mm->mmap_sem) as we would
+                        /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -192,7 +192,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
        /*
@@ -201,7 +201,7 @@ good_area:
         */
 
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
 
@@ -260,14 +260,14 @@ out_of_memory:
        __asm__ __volatile__("l.nop 42");
        __asm__ __volatile__("l.nop 1");
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Send a sigbus, regardless of whether we were in kernel
index 3bcdc1c..3d7c79c 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/pagemap.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/tlb.h>
index 8f8e97f..a978590 100644 (file)
 
 #include <linux/vmalloc.h>
 #include <linux/io.h>
+#include <linux/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/kmap_types.h>
 #include <asm/fixmap.h>
 #include <asm/bug.h>
-#include <asm/pgtable.h>
 #include <linux/sched.h>
 #include <asm/tlbflush.h>
 
index dd4f200..4b680ae 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 
 #include <asm/tlbflush.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/spr_defs.h>
 
index cab8f64..116effe 100644 (file)
@@ -3,7 +3,7 @@
 #define _ASM_IO_H
 
 #include <linux/types.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #define virt_to_phys(a) ((unsigned long)__pa(a))
 #define phys_to_virt(a) __va(a)
index 697a906..07b89c7 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/sched.h>
 #include <linux/atomic.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm-generic/mm_hooks.h>
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
index cd7df48..75cf840 100644 (file)
@@ -427,40 +427,16 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 
 #define pte_page(pte)          (pfn_to_page(pte_pfn(pte)))
 
-#define pmd_page_vaddr(pmd)    ((unsigned long) __va(pmd_address(pmd)))
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return ((unsigned long) __va(pmd_address(pmd)));
+}
 
 #define __pmd_page(pmd) ((unsigned long) __va(pmd_address(pmd)))
 #define pmd_page(pmd)  virt_to_page((void *)__pmd_page(pmd))
 
-#define pgd_index(address) ((address) >> PGDIR_SHIFT)
-
-/* to find an entry in a page-table-directory */
-#define pgd_offset(mm, address) \
-((mm)->pgd + ((address) >> PGDIR_SHIFT))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
 /* Find an entry in the second-level page table.. */
 
-#if CONFIG_PGTABLE_LEVELS == 3
-#define pmd_index(addr)         (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
-#define pmd_offset(dir,address) \
-((pmd_t *) pud_page_vaddr(*(dir)) + pmd_index(address))
-#else
-#define pmd_offset(dir,addr) ((pmd_t *) dir)
-#endif
-
-/* Find an entry in the third-level page table.. */ 
-#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
-#define pte_offset_kernel(pmd, address) \
-       ((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address))
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_unmap(pte) do { } while (0)
-
-#define pte_unmap(pte)                 do { } while (0)
-#define pte_unmap_nested(pte)          do { } while (0)
-
 extern void paging_init (void);
 
 /* Used for deferring calls to flush_dcache_page() */
@@ -571,6 +547,5 @@ extern void arch_report_meminfo(struct seq_file *m);
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
 #define __HAVE_ARCH_PTE_SAME
-#include <asm-generic/pgtable.h>
 
 #endif /* _PARISC_PGTABLE_H */
index aa79d35..305768a 100644 (file)
@@ -20,8 +20,8 @@
 #include <linux/ptrace.h>
 #include <linux/hardirq.h>
 #include <linux/kbuild.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 #include <asm/processor.h>
 #include <asm/pdc.h>
index 9a03e29..4b484ec 100644 (file)
@@ -19,7 +19,6 @@
 #include <asm/psw.h>
 #include <asm/cache.h>         /* for L1_CACHE_SHIFT */
 #include <asm/assembly.h>      /* for LDREG/STREG defines */
-#include <asm/pgtable.h>
 #include <asm/signal.h>
 #include <asm/unistd.h>
 #include <asm/ldcw.h>
@@ -28,6 +27,7 @@
 #include <asm/alternative.h>
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 
 #ifdef CONFIG_64BIT
        .level 2.0w
index 951a339..aa93d77 100644 (file)
 #include <asm/pdc.h>
        
 #include <asm/assembly.h>
-#include <asm/pgtable.h>
 
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
        .level  PA_ASM_LEVEL
 
index fac18c6..7df1405 100644 (file)
@@ -50,7 +50,6 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 
-#include <asm/pgtable.h>
 #include <asm/unwind.h>
 #include <asm/sections.h>
 
index fa092ed..b2ba6d6 100644 (file)
 
 #include <asm/psw.h>
 #include <asm/assembly.h>
-#include <asm/pgtable.h>
 #include <asm/cache.h>
 #include <asm/ldcw.h>
 #include <asm/alternative.h>
 #include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
        .section .text.hot
        .align  16
index 0f1b460..70cd24b 100644 (file)
@@ -201,7 +201,7 @@ static inline void unmap_uncached_pmd(pgd_t * dir, unsigned long vaddr,
                pgd_clear(dir);
                return;
        }
-       pmd = pmd_offset(dir, vaddr);
+       pmd = pmd_offset(pud_offset(p4d_offset(dir, vaddr), vaddr), vaddr);
        vaddr &= ~PGDIR_MASK;
        end = vaddr + size;
        if (end > PGDIR_SIZE)
index 749c457..6e8550f 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/kthread.h>
 #include <linux/initrd.h>
+#include <linux/pgtable.h>
 
 #include <asm/pdc.h>
 #include <asm/pdcpat.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 
 enum pdt_access_type {
        PDT_NONE,
index f8c07dc..b51418a 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/audit.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/asm-offsets.h>
 
index e202c37..f8a842d 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/irq.h>           /* for CPU_IRQ_REGION and friends */
 #include <asm/mmu_context.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/processor.h>
 #include <asm/ptrace.h>
index 82fc011..5400e23 100644 (file)
@@ -49,7 +49,7 @@
 #include "../math-emu/math-emu.h"      /* for handle_fpe() */
 
 static void parisc_show_stack(struct task_struct *task,
-       struct pt_regs *regs);
+       struct pt_regs *regs, const char *loglvl);
 
 static int printbinary(char *buf, unsigned long x, int nbits)
 {
@@ -155,7 +155,7 @@ void show_regs(struct pt_regs *regs)
                printk("%s IAOQ[1]: %pS\n", level, (void *) regs->iaoq[1]);
                printk("%s RP(r2): %pS\n", level, (void *) regs->gr[2]);
 
-               parisc_show_stack(current, regs);
+               parisc_show_stack(current, regs, KERN_DEFAULT);
        }
 }
 
@@ -170,37 +170,37 @@ static DEFINE_RATELIMIT_STATE(_hppa_rs,
 }
 
 
-static void do_show_stack(struct unwind_frame_info *info)
+static void do_show_stack(struct unwind_frame_info *info, const char *loglvl)
 {
        int i = 1;
 
-       printk(KERN_CRIT "Backtrace:\n");
+       printk("%sBacktrace:\n", loglvl);
        while (i <= MAX_UNWIND_ENTRIES) {
                if (unwind_once(info) < 0 || info->ip == 0)
                        break;
 
                if (__kernel_text_address(info->ip)) {
-                       printk(KERN_CRIT " [<" RFMT ">] %pS\n",
-                               info->ip, (void *) info->ip);
+                       printk("%s [<" RFMT ">] %pS\n",
+                               loglvl, info->ip, (void *) info->ip);
                        i++;
                }
        }
-       printk(KERN_CRIT "\n");
+       printk("%s\n", loglvl);
 }
 
 static void parisc_show_stack(struct task_struct *task,
-       struct pt_regs *regs)
+       struct pt_regs *regs, const char *loglvl)
 {
        struct unwind_frame_info info;
 
        unwind_frame_init_task(&info, task, regs);
 
-       do_show_stack(&info);
+       do_show_stack(&info, loglvl);
 }
 
-void show_stack(struct task_struct *t, unsigned long *sp)
+void show_stack(struct task_struct *t, unsigned long *sp, const char *loglvl)
 {
-       parisc_show_stack(t, NULL);
+       parisc_show_stack(t, NULL, loglvl);
 }
 
 int is_valid_bugaddr(unsigned long iaoq)
@@ -446,7 +446,7 @@ void parisc_terminate(char *msg, struct pt_regs *regs, int code, unsigned long o
                /* show_stack(NULL, (unsigned long *)regs->gr[30]); */
                struct unwind_frame_info info;
                unwind_frame_init(&info, current, regs);
-               do_show_stack(&info);
+               do_show_stack(&info, KERN_CRIT);
        }
 
        printk("\n");
@@ -717,7 +717,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
                if (user_mode(regs)) {
                        struct vm_area_struct *vma;
 
-                       down_read(&current->mm->mmap_sem);
+                       mmap_read_lock(current->mm);
                        vma = find_vma(current->mm,regs->iaoq[0]);
                        if (vma && (regs->iaoq[0] >= vma->vm_start)
                                && (vma->vm_flags & VM_EXEC)) {
@@ -725,10 +725,10 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
                                fault_address = regs->iaoq[0];
                                fault_space = regs->iasq[0];
 
-                               up_read(&current->mm->mmap_sem);
+                               mmap_read_unlock(current->mm);
                                break; /* call do_page_fault() */
                        }
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                }
                /* Fall Through */
        case 27: 
index beceaab..94a9fe2 100644 (file)
@@ -57,14 +57,10 @@ void * memcpy(void * dst,const void *src, size_t count)
 EXPORT_SYMBOL(raw_copy_in_user);
 EXPORT_SYMBOL(memcpy);
 
-long probe_kernel_read(void *dst, const void *src, size_t size)
+bool probe_kernel_read_allowed(const void *unsafe_src, size_t size)
 {
-       unsigned long addr = (unsigned long)src;
-
-       if (addr < PAGE_SIZE)
-               return -EFAULT;
-
+       if ((unsigned long)unsafe_src < PAGE_SIZE)
+               return false;
        /* check for I/O space F_EXTEND(0xfff00000) access as well? */
-
-       return __probe_kernel_read(dst, src, size);
+       return true;
 }
index 86e8c84..66ac071 100644 (file)
@@ -282,7 +282,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
        if (acc_type & VM_WRITE)
                flags |= FAULT_FLAG_WRITE;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma_prev(mm, address, &prev_vma);
        if (!vma || address < vma->vm_start)
                goto check_expansion;
@@ -329,7 +329,7 @@ good_area:
                        current->min_flt++;
                if (fault & VM_FAULT_RETRY) {
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -337,7 +337,7 @@ good_area:
                        goto retry;
                }
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
 check_expansion:
@@ -349,7 +349,7 @@ check_expansion:
  * Something tried to access memory that isn't in our memory map..
  */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        if (user_mode(regs)) {
                int signo, si_code;
@@ -421,7 +421,7 @@ no_context:
        parisc_terminate("Bad Address (null pointer deref?)", regs, code, address);
 
   out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
index e2d8b0a..24426a7 100644 (file)
@@ -33,11 +33,7 @@ void notrace set_fixmap(enum fixed_addresses idx, phys_addr_t phys)
 void notrace clear_fixmap(enum fixed_addresses idx)
 {
        unsigned long vaddr = __fix_to_virt(idx);
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-       pmd_t *pmd = pmd_offset(pud, vaddr);
-       pte_t *pte = pte_offset_kernel(pmd, vaddr);
+       pte_t *pte = virt_to_kpte(vaddr);
 
        if (WARN_ON(pte_none(*pte)))
                return;
index cdd760d..48d628a 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/compat.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 #include <asm/pdc_chassis.h>
 #include <asm/mmzone.h>
index d7978a5..2249124 100644 (file)
@@ -112,6 +112,9 @@ static inline bool pte_user(pte_t pte)
 #define PMD_TABLE_SIZE 0
 #define PUD_TABLE_SIZE 0
 #define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
+
+/* Bits to mask out from a PMD to get to the PTE page */
+#define PMD_MASKED_BITS                (PTE_TABLE_SIZE - 1)
 #endif /* __ASSEMBLY__ */
 
 #define PTRS_PER_PTE   (1 << PTE_INDEX_SIZE)
@@ -332,26 +335,9 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,
 #define __HAVE_ARCH_PTE_SAME
 #define pte_same(A,B)  (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HASHPTE) == 0)
 
-#define pmd_page_vaddr(pmd)    \
-       ((unsigned long)__va(pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
 #define pmd_page(pmd)          \
        pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)
 
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/* to find an entry in a page-table-directory */
-#define pgd_index(address)      ((address) >> PGDIR_SHIFT)
-#define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))
-
-/* Find an entry in the third-level page table.. */
-#define pte_index(address)             \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, addr)   \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir, addr)      pte_offset_kernel((dir), (addr))
-static inline void pte_unmap(pte_t *pte) { }
-
 /*
  * Encode and decode a swap entry.
  * Note that the bits we use in a PTE for representing a swap entry
index f17442c..25c3cb8 100644 (file)
@@ -1005,52 +1005,9 @@ extern struct page *p4d_page(p4d_t p4d);
 /* Pointers in the page table tree are physical addresses */
 #define __pgtable_ptr_val(ptr) __pa(ptr)
 
-#define pmd_page_vaddr(pmd)    __va(pmd_val(pmd) & ~PMD_MASKED_BITS)
 #define pud_page_vaddr(pud)    __va(pud_val(pud) & ~PUD_MASKED_BITS)
 #define p4d_page_vaddr(p4d)    __va(p4d_val(p4d) & ~P4D_MASKED_BITS)
 
-static inline unsigned long pgd_index(unsigned long address)
-{
-       return (address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1);
-}
-
-static inline unsigned long pud_index(unsigned long address)
-{
-       return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
-}
-
-static inline unsigned long pmd_index(unsigned long address)
-{
-       return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
-}
-
-static inline unsigned long pte_index(unsigned long address)
-{
-       return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
-}
-
-/*
- * Find an entry in a page-table-directory.  We combine the address region
- * (the high order N bits) and the pgd portion of the address.
- */
-
-#define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))
-
-#define pud_offset(p4dp, addr) \
-       (((pud_t *) p4d_page_vaddr(*(p4dp))) + pud_index(addr))
-#define pmd_offset(pudp,addr) \
-       (((pmd_t *) pud_page_vaddr(*(pudp))) + pmd_index(addr))
-#define pte_offset_kernel(dir,addr) \
-       (((pte_t *) pmd_page_vaddr(*(dir))) + pte_index(addr))
-
-#define pte_offset_map(dir,addr)       pte_offset_kernel((dir), (addr))
-
-static inline void pte_unmap(pte_t *pte) { }
-
-/* to find an entry in a kernel page-table-directory */
-/* This now only contains the vmalloc pages */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
 #define pte_ERROR(e) \
        pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
 #define pmd_ERROR(e) \
index ccbe2e8..2918881 100644 (file)
@@ -16,8 +16,8 @@
 
 #ifndef __ASSEMBLY__
 #include <linux/sizes.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
index 13f90dd..5863596 100644 (file)
@@ -34,7 +34,6 @@ extern struct pci_dev *isa_bridge_pcidev;
 #include <asm/mmiowb.h>
 #include <asm/mmu.h>
 #include <asm/ppc_asm.h>
-#include <asm/pgtable.h>
 
 #define SIO_CONFIG_RA  0x398
 #define SIO_CONFIG_RD  0x399
index c745ee4..1d0f7d8 100644 (file)
@@ -39,7 +39,7 @@
 
 #else /* !__ASSEMBLY__ */
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 void setup_kup(void);
 
index af7f13c..b56f141 100644 (file)
@@ -28,6 +28,8 @@ extern int icache_44x_need_flush;
 #define PMD_TABLE_SIZE 0
 #define PUD_TABLE_SIZE 0
 #define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
+
+#define PMD_MASKED_BITS (PTE_TABLE_SIZE - 1)
 #endif /* __ASSEMBLY__ */
 
 #define PTRS_PER_PTE   (1 << PTE_INDEX_SIZE)
@@ -203,10 +205,6 @@ static inline void pmd_clear(pmd_t *pmdp)
        *pmdp = __pmd(0);
 }
 
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
 /* to find an entry in a page-table-directory */
 #define pgd_index(address)      ((address) >> PGDIR_SHIFT)
 #define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))
@@ -330,8 +328,6 @@ static inline int pte_young(pte_t pte)
  * of the pte page.  -- paulus
  */
 #ifndef CONFIG_BOOKE
-#define pmd_page_vaddr(pmd)    \
-       ((unsigned long)__va(pmd_val(pmd) & ~(PTE_TABLE_SIZE - 1)))
 #define pmd_page(pmd)          \
        pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)
 #else
@@ -341,15 +337,6 @@ static inline int pte_young(pte_t pte)
        pfn_to_page((__pa(pmd_val(pmd)) >> PAGE_SHIFT))
 #endif
 
-/* Find an entry in the third-level page table.. */
-#define pte_index(address)             \
-       (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, addr)   \
-       (pmd_bad(*(dir)) ? NULL : (pte_t *)pmd_page_vaddr(*(dir)) + \
-                                 pte_index(addr))
-#define pte_offset_map(dir, addr)      pte_offset_kernel((dir), (addr))
-static inline void pte_unmap(pte_t *pte) { }
-
 /*
  * Encode and decode a swap entry.
  * Note that the bits we use in a PTE for representing a swap entry
index 81b1c54..fe2f4c9 100644 (file)
@@ -78,10 +78,6 @@ extern struct page *p4d_page(p4d_t p4d);
 
 #endif /* !__ASSEMBLY__ */
 
-#define pud_offset(p4dp, addr) \
-  (((pud_t *) p4d_page_vaddr(*(p4dp))) + \
-    (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)))
-
 #define pud_ERROR(e) \
        pr_err("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e))
 
index 3424381..6cb8aa3 100644 (file)
@@ -182,28 +182,6 @@ static inline void p4d_set(p4d_t *p4dp, unsigned long val)
        *p4dp = __p4d(val);
 }
 
-/*
- * Find an entry in a page-table-directory.  We combine the address region
- * (the high order N bits) and the pgd portion of the address.
- */
-#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
-
-#define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))
-
-#define pmd_offset(pudp,addr) \
-  (((pmd_t *) pud_page_vaddr(*(pudp))) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
-
-#define pte_offset_kernel(dir,addr) \
-  (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-
-#define pte_offset_map(dir,addr)       pte_offset_kernel((dir), (addr))
-
-static inline void pte_unmap(pte_t *pte) { }
-
-/* to find an entry in a kernel page-table-directory */
-/* This now only contains the vmalloc pages */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
 /* Atomic PTE updates */
 static inline unsigned long pte_update(struct mm_struct *mm,
                                       unsigned long addr,
index 50a4b0b..4b7c347 100644 (file)
@@ -56,7 +56,7 @@ static inline bool pte_exec(pte_t pte)                { return pte_val(pte) & _PAGE_EXEC; }
 #ifdef CONFIG_NUMA_BALANCING
 /*
  * These work without NUMA balancing but the kernel does not care. See the
- * comment in include/asm-generic/pgtable.h . On powerpc, this will only
+ * comment in include/linux/pgtable.h . On powerpc, this will only
  * work for user pages and always return true for kernel pages.
  */
 static inline int pte_protnone(pte_t pte)
index ae58b52..f7613f4 100644 (file)
@@ -41,25 +41,6 @@ struct mm_struct;
 
 #ifndef __ASSEMBLY__
 
-#ifdef CONFIG_PPC32
-static inline pmd_t *pmd_ptr(struct mm_struct *mm, unsigned long va)
-{
-       return pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, va), va), va), va);
-}
-
-static inline pmd_t *pmd_ptr_k(unsigned long va)
-{
-       return pmd_offset(pud_offset(p4d_offset(pgd_offset_k(va), va), va), va);
-}
-
-static inline pte_t *virt_to_kpte(unsigned long vaddr)
-{
-       pmd_t *pmd = pmd_ptr_k(vaddr);
-
-       return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
-}
-#endif
-
 #include <asm/tlbflush.h>
 
 /* Keep these as a macros to avoid include dependency mess */
@@ -76,6 +57,13 @@ static inline pgprot_t pte_pgprot(pte_t pte)
        return __pgprot(pte_flags);
 }
 
+#ifndef pmd_page_vaddr
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return ((unsigned long)__va(pmd_val(pmd) & ~PMD_MASKED_BITS));
+}
+#define pmd_page_vaddr pmd_page_vaddr
+#endif
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
@@ -96,8 +84,6 @@ extern unsigned long ioremap_bot;
  */
 #define kern_addr_valid(addr)  (1)
 
-#include <asm-generic/pgtable.h>
-
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
 #define pmd_large(pmd)         0
 #endif
index 20ebf15..2fe6cae 100644 (file)
@@ -101,7 +101,7 @@ static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
 
 /*
  * Returns a positive, 5-bit key on success, or -1 on failure.
- * Relies on the mmap_sem to protect against concurrency in mm_pkey_alloc() and
+ * Relies on the mmap_lock to protect against concurrency in mm_pkey_alloc() and
  * mm_pkey_free().
  */
 static inline int mm_pkey_alloc(struct mm_struct *mm)
index 7f3a8b9..862985c 100644 (file)
@@ -10,7 +10,7 @@
 #ifdef __KERNEL__
 
 #ifndef __powerpc64__
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #endif
 #include <asm/pgalloc.h>
 #ifndef __powerpc64__
index 9b9cde0..6657dc6 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
 #include <asm/thread_info.h>
index f57712a..02300ed 100644 (file)
@@ -9,13 +9,13 @@
 #include <linux/init.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/btext.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/udbg.h>
index 1dfccf5..cac22cb 100644 (file)
@@ -12,7 +12,6 @@
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
index e245955..705c042 100644 (file)
  */
 
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
index a22a820..926bfa7 100644 (file)
  */
 
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/thread_info.h>
 #include <asm/ppc_asm.h>
index 51dd01a..8e36718 100644 (file)
  */
 
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/thread_info.h>
 #include <asm/ppc_asm.h>
index abb71fa..9f359d3 100644 (file)
 
 #include <linux/init.h>
 #include <linux/magic.h>
+#include <linux/pgtable.h>
 #include <linux/sizes.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/thread_info.h>
 #include <asm/ppc_asm.h>
index 840af00..586a6ac 100644 (file)
 
 #include <linux/init.h>
 #include <linux/threads.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/thread_info.h>
 #include <asm/ppc_asm.h>
index 0276bc8..51bbaae 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/sched/mm.h>    /* for init_mm */
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/ppc-pci.h>
 #include <asm/io-workarounds.h>
 #include <asm/pte-walk.h>
index 112d150..05b1cc0 100644 (file)
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 
 #include <linux/uaccess.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/cache.h>
 #include <asm/prom.h>
index c32af49..c3b522b 100644 (file)
 #include <linux/types.h>
 #include <linux/ptrace.h>
 #include <linux/extable.h>
+#include <linux/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mce.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/pte-walk.h>
 #include <asm/sstep.h>
 #include <asm/exception-64s.h>
index 8d96169..2168372 100644 (file)
@@ -8,11 +8,11 @@
 #include <linux/memblock.h>
 #include <linux/sched/task.h>
 #include <linux/numa.h>
+#include <linux/pgtable.h>
 
 #include <asm/lppaca.h>
 #include <asm/paca.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/kexec.h>
 #include <asm/svm.h>
 #include <asm/ultravisor.h>
index 048d64c..7bb7faf 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/pkeys.h>
 #include <linux/seq_buf.h>
 
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
@@ -1456,7 +1455,7 @@ void show_regs(struct pt_regs * regs)
        printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
        printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
 #endif
-       show_stack(current, (unsigned long *) regs->gpr[1]);
+       show_stack(current, (unsigned long *) regs->gpr[1], KERN_DEFAULT);
        if (!user_mode(regs))
                show_instructions(regs);
 }
@@ -2063,7 +2062,8 @@ unsigned long get_wchan(struct task_struct *p)
 
 static int kstack_depth_to_print = CONFIG_PRINT_STACK_DEPTH;
 
-void show_stack(struct task_struct *tsk, unsigned long *stack)
+void show_stack(struct task_struct *tsk, unsigned long *stack,
+               const char *loglvl)
 {
        unsigned long sp, ip, lr, newsp;
        int count = 0;
@@ -2088,7 +2088,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
        }
 
        lr = 0;
-       printk("Call Trace:\n");
+       printk("%sCall Trace:\n", loglvl);
        do {
                if (!validate_sp(sp, tsk, STACK_FRAME_OVERHEAD))
                        break;
@@ -2097,7 +2097,8 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
                newsp = stack[0];
                ip = stack[STACK_FRAME_LR_SAVE];
                if (!firstframe || ip != lr) {
-                       printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
+                       printk("%s["REG"] ["REG"] %pS",
+                               loglvl, sp, ip, (void *)ip);
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
                        ret_addr = ftrace_graph_ret_addr(current,
                                                &ftrace_idx, ip, stack);
@@ -2119,8 +2120,9 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
                        struct pt_regs *regs = (struct pt_regs *)
                                (sp + STACK_FRAME_OVERHEAD);
                        lr = regs->link;
-                       printk("--- interrupt: %lx at %pS\n    LR = %pS\n",
-                              regs->trap, (void *)regs->nip, (void *)lr);
+                       printk("%s--- interrupt: %lx at %pS\n    LR = %pS\n",
+                              loglvl, regs->trap,
+                              (void *)regs->nip, (void *)lr);
                        firstframe = 1;
                }
 
index 6a3bac3..9cc49f2 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/of_fdt.h>
 #include <linux/libfdt.h>
 #include <linux/cpu.h>
+#include <linux/pgtable.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>
@@ -41,7 +42,6 @@
 #include <asm/smp.h>
 #include <asm/mmu.h>
 #include <asm/paca.h>
-#include <asm/pgtable.h>
 #include <asm/powernv.h>
 #include <asm/iommu.h>
 #include <asm/btext.h>
index 5f15b10..90c604d 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/delay.h>
 #include <linux/initrd.h>
 #include <linux/bitops.h>
+#include <linux/pgtable.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/page.h>
@@ -34,7 +35,6 @@
 #include <asm/io.h>
 #include <asm/smp.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/iommu.h>
 #include <asm/btext.h>
 #include <asm/sections.h>
index ae5e43e..781c186 100644 (file)
@@ -13,9 +13,9 @@
 #include <linux/pci.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
index c376a05..9d3faac 100644 (file)
 #include <linux/memblock.h>
 #include <linux/of_platform.h>
 #include <linux/hugetlb.h>
+#include <linux/pgtable.h>
 #include <asm/debugfs.h>
 #include <asm/io.h>
 #include <asm/paca.h>
 #include <asm/prom.h>
 #include <asm/processor.h>
 #include <asm/vdso_datapage.h>
-#include <asm/pgtable.h>
 #include <asm/smp.h>
 #include <asm/elf.h>
 #include <asm/machdep.h>
index d642e42..1823706 100644 (file)
 #include <linux/memblock.h>
 #include <linux/export.h>
 #include <linux/nvram.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/smp.h>
 #include <asm/elf.h>
index bb47555..0ba1ed7 100644 (file)
 #include <linux/lockdep.h>
 #include <linux/memory.h>
 #include <linux/nmi.h>
+#include <linux/pgtable.h>
 
 #include <asm/debugfs.h>
 #include <asm/io.h>
 #include <asm/kdump.h>
 #include <asm/prom.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/smp.h>
 #include <asm/elf.h>
 #include <asm/machdep.h>
index ae3da74..1415c16 100644 (file)
@@ -47,7 +47,6 @@
 #include <asm/unistd.h>
 #else
 #include <asm/ucontext.h>
-#include <asm/pgtable.h>
 #endif
 
 #include "signal.h"
index 7706191..55e5f76 100644 (file)
@@ -25,7 +25,6 @@
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/unistd.h>
 #include <asm/cacheflush.h>
 #include <asm/syscalls.h>
index c820c95..7319947 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/processor.h>
 #include <linux/random.h>
 #include <linux/stackprotector.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
@@ -41,7 +42,6 @@
 #include <asm/kvm_ppc.h>
 #include <asm/dbell.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
 #include <asm/time.h>
index c477b85..b644065 100644 (file)
@@ -260,7 +260,7 @@ static void raise_backtrace_ipi(cpumask_t *mask)
                        pr_cont(" current pointer corrupt? (%px)\n", p->__current);
 
                pr_warn("Back trace of paca->saved_r1 (0x%016llx) (possibly stale):\n", p->saved_r1);
-               show_stack(p->__current, (unsigned long *)p->saved_r1);
+               show_stack(p->__current, (unsigned long *)p->saved_r1, KERN_WARNING);
        }
 }
 
index 067e501..97413a3 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/kmsg_dump.h>
 
 #include <asm/emulated_ops.h>
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/debugfs.h>
 #include <asm/io.h>
index f38f26e..e0f4ba4 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/security.h>
 #include <linux/memblock.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
@@ -171,7 +170,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
         * and end up putting it elsewhere.
         * Add enough to the size so that the result can be aligned.
         */
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
        vdso_base = get_unmapped_area(NULL, vdso_base,
                                      (vdso_pages << PAGE_SHIFT) +
@@ -211,11 +210,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
                goto fail_mmapsem;
        }
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return 0;
 
  fail_mmapsem:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return rc;
 }
 
index a47fa8b..2a2fad9 100644 (file)
 #include <linux/anon_inodes.h>
 #include <linux/file.h>
 #include <linux/debugfs.h>
+#include <linux/pgtable.h>
 
 #include <asm/kvm_ppc.h>
 #include <asm/kvm_book3s.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/pte-walk.h>
 #include <asm/ultravisor.h>
index a07e12e..7f5d586 100644 (file)
@@ -4621,14 +4621,14 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 
        /* Look up the VMA for the start of this memory slot */
        hva = memslot->userspace_addr;
-       down_read(&kvm->mm->mmap_sem);
+       mmap_read_lock(kvm->mm);
        vma = find_vma(kvm->mm, hva);
        if (!vma || vma->vm_start > hva || (vma->vm_flags & VM_IO))
                goto up_out;
 
        psize = vma_kernel_pagesize(vma);
 
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
 
        /* We can handle 4k, 64k or 16M pages in the VRMA */
        if (psize >= 0x1000000)
@@ -4661,7 +4661,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
        return err;
 
  up_out:
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
        goto out_srcu;
 }
 
index 66c38ee..a221cae 100644 (file)
 #include <linux/kernel.h>
 #include <linux/kvm_host.h>
 #include <linux/llist.h>
+#include <linux/pgtable.h>
 
 #include <asm/kvm_ppc.h>
 #include <asm/kvm_book3s.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/pte-walk.h>
 #include <asm/reg.h>
index 287d591..4d7e561 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/kvm_host.h>
 #include <linux/err.h>
 #include <linux/kernel_stat.h>
+#include <linux/pgtable.h>
 
 #include <asm/kvm_book3s.h>
 #include <asm/kvm_ppc.h>
@@ -15,7 +16,6 @@
 #include <asm/xics.h>
 #include <asm/synch.h>
 #include <asm/cputhreads.h>
-#include <asm/pgtable.h>
 #include <asm/ppc-opcode.h>
 #include <asm/pnv-pci.h>
 #include <asm/opal.h>
index 174d75e..6f18632 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/kvm_host.h>
 #include <linux/err.h>
 #include <linux/kernel_stat.h>
+#include <linux/pgtable.h>
 
 #include <asm/kvm_book3s.h>
 #include <asm/kvm_ppc.h>
@@ -11,7 +12,6 @@
 #include <asm/debug.h>
 #include <asm/synch.h>
 #include <asm/cputhreads.h>
-#include <asm/pgtable.h>
 #include <asm/ppc-opcode.h>
 #include <asm/pnv-pci.h>
 #include <asm/opal.h>
index 76d05c7..f91224e 100644 (file)
@@ -47,7 +47,7 @@
  * Locking order
  *
  * 1. kvm->srcu - Protects KVM memslots
- * 2. kvm->mm->mmap_sem - find_vma, migrate_vma_pages and helpers, ksm_madvise
+ * 2. kvm->mm->mmap_lock - find_vma, migrate_vma_pages and helpers, ksm_madvise
  * 3. kvm->arch.uvmem_lock - protects read/writes to uvmem slots thus acting
  *                          as sync-points for page-in/out
  */
@@ -402,13 +402,13 @@ kvmppc_svm_page_in(struct vm_area_struct *vma, unsigned long start,
        mig.dst = &dst_pfn;
 
        /*
-        * We come here with mmap_sem write lock held just for
-        * ksm_madvise(), otherwise we only need read mmap_sem.
+        * We come here with mmap_lock write lock held just for
+        * ksm_madvise(), otherwise we only need read mmap_lock.
         * Hence downgrade to read lock once ksm_madvise() is done.
         */
        ret = ksm_madvise(vma, vma->vm_start, vma->vm_end,
                          MADV_UNMERGEABLE, &vma->vm_flags);
-       downgrade_write(&kvm->mm->mmap_sem);
+       mmap_write_downgrade(kvm->mm);
        *downgrade = true;
        if (ret)
                return ret;
@@ -525,7 +525,7 @@ kvmppc_h_svm_page_in(struct kvm *kvm, unsigned long gpa,
 
        ret = H_PARAMETER;
        srcu_idx = srcu_read_lock(&kvm->srcu);
-       down_write(&kvm->mm->mmap_sem);
+       mmap_write_lock(kvm->mm);
 
        start = gfn_to_hva(kvm, gfn);
        if (kvm_is_error_hva(start))
@@ -548,9 +548,9 @@ out_unlock:
        mutex_unlock(&kvm->arch.uvmem_lock);
 out:
        if (downgrade)
-               up_read(&kvm->mm->mmap_sem);
+               mmap_read_unlock(kvm->mm);
        else
-               up_write(&kvm->mm->mmap_sem);
+               mmap_write_unlock(kvm->mm);
        srcu_read_unlock(&kvm->srcu, srcu_idx);
        return ret;
 }
@@ -703,7 +703,7 @@ kvmppc_h_svm_page_out(struct kvm *kvm, unsigned long gpa,
 
        ret = H_PARAMETER;
        srcu_idx = srcu_read_lock(&kvm->srcu);
-       down_read(&kvm->mm->mmap_sem);
+       mmap_read_lock(kvm->mm);
        start = gfn_to_hva(kvm, gfn);
        if (kvm_is_error_hva(start))
                goto out;
@@ -716,7 +716,7 @@ kvmppc_h_svm_page_out(struct kvm *kvm, unsigned long gpa,
        if (!kvmppc_svm_page_out(vma, start, end, page_shift, kvm, gpa))
                ret = H_SUCCESS;
 out:
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
        srcu_read_unlock(&kvm->srcu, srcu_idx);
        return ret;
 }
index df9989c..d6c1069 100644 (file)
@@ -355,7 +355,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 
        if (tlbsel == 1) {
                struct vm_area_struct *vma;
-               down_read(&kvm->mm->mmap_sem);
+               mmap_read_lock(kvm->mm);
 
                vma = find_vma(kvm->mm, hva);
                if (vma && hva >= vma->vm_start &&
@@ -441,7 +441,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
                        tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
                }
 
-               up_read(&kvm->mm->mmap_sem);
+               mmap_read_unlock(kvm->mm);
        }
 
        if (likely(!pfnmap)) {
index 3dfae0c..315c949 100644 (file)
@@ -5,10 +5,10 @@
  *    Copyright (C) 2010 Alexander Graf (agraf@suse.de)
  */
 
+#include <linux/pgtable.h>
 #include <asm/reg.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
index e64546b..0a051df 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <asm/code-patching.h>
index 2702e87..923ad8f 100644 (file)
@@ -14,9 +14,9 @@
  *  hash table, so this file is not used on them.)
  */
 
+#include <linux/pgtable.h>
 #include <asm/reg.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/cputable.h>
 #include <asm/ppc_asm.h>
 #include <asm/thread_info.h>
index a6dcc70..03b6ba5 100644 (file)
@@ -320,7 +320,7 @@ void hash_preload(struct mm_struct *mm, unsigned long ea)
 
        if (!Hash)
                return;
-       pmd = pmd_ptr(mm, ea);
+       pmd = pmd_off(mm, ea);
        if (!pmd_none(*pmd))
                add_hash_page(mm->context.id, ea, pmd_val(*pmd));
 }
index dc9039a..b6c7427 100644 (file)
@@ -90,7 +90,7 @@ static void flush_range(struct mm_struct *mm, unsigned long start,
        if (start >= end)
                return;
        end = (end - 1) | ~PAGE_MASK;
-       pmd = pmd_ptr(mm, start);
+       pmd = pmd_off(mm, start);
        for (;;) {
                pmd_end = ((start + PGDIR_SIZE) & PGDIR_MASK) - 1;
                if (pmd_end > end)
@@ -129,7 +129,7 @@ void flush_tlb_mm(struct mm_struct *mm)
 
        /*
         * It is safe to go down the mm's list of vmas when called
-        * from dup_mmap, holding mmap_sem.  It would also be safe from
+        * from dup_mmap, holding mmap_lock.  It would also be safe from
         * unmap_region or exit_mmap, but not from vmtruncate on SMP -
         * but it seems dup_mmap is the only SMP case which gets here.
         */
@@ -148,7 +148,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
                return;
        }
        mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
-       pmd = pmd_ptr(mm, vmaddr);
+       pmd = pmd_off(mm, vmaddr);
        if (!pmd_none(*pmd))
                flush_hash_pages(mm->context.id, vmaddr, pmd_val(*pmd), 1);
 }
index eefa89c..25acb9c 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/machdep.h>
index d2d8237..cf20e52 100644 (file)
 #include <linux/processor.h>
 #include <linux/threads.h>
 #include <linux/smp.h>
+#include <linux/pgtable.h>
 
 #include <asm/machdep.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/trace.h>
 #include <asm/tlb.h>
 #include <asm/cputable.h>
index 8b4b0a6..2a99167 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/mmu.h>
 #include <asm/tlb.h>
@@ -238,7 +237,7 @@ pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addres
         * to hugepage, we first clear the pmd, then invalidate all
         * the PTE entries. The assumption here is that any low level
         * page fault will see a none pmd and take the slow path that
-        * will wait on mmap_sem. But we could very well be in a
+        * will wait on mmap_lock. But we could very well be in a
         * hash_page with local ptep pointer value. Such a hash page
         * can result in adding new HPTE entries for normal subpages.
         * That means we could be modifying the page content as we
@@ -252,7 +251,7 @@ pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long addres
         * Now invalidate the hpte entries in the range
         * covered by pmd. This make sure we take a
         * fault and will find the pmd as none, which will
-        * result in a major fault which takes mmap_sem and
+        * result in a major fault which takes mmap_lock and
         * hence wait for collapse to complete. Without this
         * the __collapse_huge_page_copy can result in copying
         * the old content.
index 0124003..468169e 100644 (file)
 #include <linux/pkeys.h>
 #include <linux/hugetlb.h>
 #include <linux/cpu.h>
+#include <linux/pgtable.h>
 
 #include <asm/debugfs.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/page.h>
index fa05bbd..563faa1 100644 (file)
@@ -96,7 +96,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua,
                goto unlock_exit;
        }
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        chunk = (1UL << (PAGE_SHIFT + MAX_ORDER - 1)) /
                        sizeof(struct vm_area_struct *);
        chunk = min(chunk, entries);
@@ -114,7 +114,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua,
                        pinned += ret;
                break;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (pinned != entries) {
                if (!ret)
                        ret = -EFAULT;
index cab0633..c812b40 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/security.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/machdep.h>
index 8acb96d..bb00e0c 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string_helpers.h>
 #include <linux/stop_machine.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
 #include <asm/dma.h>
index 8141e8b..156c38f 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <asm/asm-prototypes.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/paca.h>
@@ -21,6 +20,7 @@
 #include <linux/compiler.h>
 #include <linux/context_tracking.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/udbg.h>
 #include <asm/code-patching.h>
index 25a0c04..60c6ea1 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/hugetlb.h>
 #include <linux/syscalls.h>
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <linux/uaccess.h>
 
 /*
@@ -94,7 +94,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len)
        size_t nw;
        unsigned long next, limit;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        spt = mm_ctx_subpage_prot(&mm->context);
        if (!spt)
@@ -129,7 +129,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len)
        }
 
 err_out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -219,13 +219,13 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
        if (!access_ok(map, (len >> PAGE_SHIFT) * sizeof(u32)))
                return -EFAULT;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        spt = mm_ctx_subpage_prot(&mm->context);
        if (!spt) {
                /*
                 * Allocate subpage prot table if not already done.
-                * Do this with mmap_sem held
+                * Do this with mmap_lock held
                 */
                spt = kzalloc(sizeof(struct subpage_prot_table), GFP_KERNEL);
                if (!spt) {
@@ -269,11 +269,11 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
                if (addr + (nw << PAGE_SHIFT) > next)
                        nw = (next - addr) >> PAGE_SHIFT;
 
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
                if (__copy_from_user(spp, map, nw * sizeof(u32)))
                        return -EFAULT;
                map += nw;
-               down_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
 
                /* now flush any existing HPTEs for the range */
                hpte_flush_range(mm, addr, nw);
@@ -282,6 +282,6 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
                spt->maxaddr = limit;
        err = 0;
  out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return err;
 }
index beb060b..b83abbe 100644 (file)
@@ -33,7 +33,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
        if (mm->pgd == NULL)
                return -EFAULT;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        ret = -EFAULT;
        vma = find_vma(mm, ea);
        if (!vma)
@@ -82,7 +82,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
                current->min_flt++;
 
 out_unlock:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return ret;
 }
 EXPORT_SYMBOL_GPL(copro_handle_mm_fault);
index 2393ed9..641fc5f 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <asm/firmware.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/siginfo.h>
@@ -109,7 +108,7 @@ static int __bad_area(struct pt_regs *regs, unsigned long address, int si_code)
         * Something tried to access memory that isn't in our memory map..
         * Fix it, but check if it's kernel or user first..
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return __bad_area_nosemaphore(regs, address, si_code);
 }
@@ -139,13 +138,13 @@ static noinline int bad_access_pkey(struct pt_regs *regs, unsigned long address,
         * 2. T1   : set AMR to deny access to pkey=4, touches, page
         * 3. T1   : faults...
         * 4.    T2: mprotect_key(foo, PAGE_SIZE, pkey=5);
-        * 5. T1   : enters fault handler, takes mmap_sem, etc...
+        * 5. T1   : enters fault handler, takes mmap_lock, etc...
         * 6. T1   : reaches here, sees vma_pkey(vma)=5, when we really
         *           faulted on a pte with its pkey=4.
         */
        pkey = vma_pkey(vma);
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * If we are in kernel mode, bail out with a SEGV, this will
@@ -526,9 +525,9 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
 
        /*
-        * We want to do this outside mmap_sem, because reading code around nip
+        * We want to do this outside mmap_lock, because reading code around nip
         * can result in fault, which will cause a deadlock when called with
-        * mmap_sem held
+        * mmap_lock held
         */
        if (is_user)
                flags |= FAULT_FLAG_USER;
@@ -540,7 +539,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
        /* When running in the kernel we expect faults to occur only to
         * addresses in user space.  All other faults represent errors in the
         * kernel and should generate an OOPS.  Unfortunately, in the case of an
-        * erroneous fault occurring in a code path which already holds mmap_sem
+        * erroneous fault occurring in a code path which already holds mmap_lock
         * we will deadlock attempting to validate the fault against the
         * address space.  Luckily the kernel only validly references user
         * space from well defined areas of code, which are listed in the
@@ -552,12 +551,12 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
         * source.  If this is invalid we can skip the address space check,
         * thus avoiding the deadlock.
         */
-       if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
+       if (unlikely(!mmap_read_trylock(mm))) {
                if (!is_user && !search_exception_tables(regs->nip))
                        return bad_area_nosemaphore(regs, address);
 
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in
@@ -581,7 +580,7 @@ retry:
                if (!must_retry)
                        return bad_area(regs, address);
 
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                if (fault_in_pages_readable((const char __user *)regs->nip,
                                            sizeof(unsigned int)))
                        return bad_area_nosemaphore(regs, address);
@@ -616,7 +615,7 @@ good_area:
                return user_mode(regs) ? 0 : SIGBUS;
 
        /*
-        * Handle the retry right now, the mmap_sem has been released in that
+        * Handle the retry right now, the mmap_lock has been released in that
         * case.
         */
        if (unlikely(fault & VM_FAULT_RETRY)) {
@@ -626,7 +625,7 @@ good_area:
                }
        }
 
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        if (unlikely(fault & VM_FAULT_ERROR))
                return mm_fault_error(regs, address, fault);
index 5b3d014..e9bfbcc 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/kmemleak.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/setup.h>
index 42ef7a6..8e0d792 100644 (file)
@@ -17,8 +17,8 @@
 #undef DEBUG
 
 #include <linux/string.h>
+#include <linux/pgtable.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/kup.h>
 
 phys_addr_t memstart_addr __ro_after_init = (phys_addr_t)~0ull;
index 36c39bd..5a5469e 100644 (file)
@@ -32,7 +32,6 @@
 #include <asm/pgalloc.h>
 #include <asm/prom.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/smp.h>
 #include <asm/machdep.h>
index c7ce4ec..bc73abf 100644 (file)
@@ -47,7 +47,6 @@
 #include <asm/rtas.h>
 #include <asm/io.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <linux/uaccess.h>
 #include <asm/smp.h>
index db4ef44..569d98a 100644 (file)
@@ -10,7 +10,7 @@
 static int __init
 kasan_init_shadow_8M(unsigned long k_start, unsigned long k_end, void *block)
 {
-       pmd_t *pmd = pmd_ptr_k(k_start);
+       pmd_t *pmd = pmd_off_k(k_start);
        unsigned long k_cur, k_next;
 
        for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd += 2, block += SZ_8M) {
@@ -59,7 +59,7 @@ int __init kasan_init_region(void *start, size_t size)
                return ret;
 
        for (; k_cur < k_end; k_cur += PAGE_SIZE) {
-               pmd_t *pmd = pmd_ptr_k(k_cur);
+               pmd_t *pmd = pmd_off_k(k_cur);
                void *va = block + k_cur - k_start;
                pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
 
index 4bc491a..a32b464 100644 (file)
@@ -46,7 +46,7 @@ int __init kasan_init_region(void *start, size_t size)
        kasan_update_early_region(k_start, k_cur, __pte(0));
 
        for (; k_cur < k_end; k_cur += PAGE_SIZE) {
-               pmd_t *pmd = pmd_ptr_k(k_cur);
+               pmd_t *pmd = pmd_off_k(k_cur);
                void *va = block + k_cur - k_start;
                pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
 
index c420858..0760e1e 100644 (file)
@@ -33,7 +33,7 @@ int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_
        pmd_t *pmd;
        unsigned long k_cur, k_next;
 
-       pmd = pmd_ptr_k(k_start);
+       pmd = pmd_off_k(k_start);
 
        for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd++) {
                pte_t *new;
@@ -69,7 +69,7 @@ int __init __weak kasan_init_region(void *start, size_t size)
                return -ENOMEM;
 
        for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
-               pmd_t *pmd = pmd_ptr_k(k_cur);
+               pmd_t *pmd = pmd_off_k(k_cur);
                void *va = block + k_cur - k_start;
                pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
 
@@ -86,7 +86,7 @@ kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte)
        phys_addr_t pa = __pa(kasan_early_shadow_page);
 
        for (k_cur = k_start; k_cur != k_end; k_cur += PAGE_SIZE) {
-               pmd_t *pmd = pmd_ptr_k(k_cur);
+               pmd_t *pmd = pmd_off_k(k_cur);
                pte_t *ptep = pte_offset_kernel(pmd, k_cur);
 
                if ((pte_val(*ptep) & PTE_RPN_MASK) != pa)
@@ -184,7 +184,7 @@ void __init kasan_early_init(void)
        unsigned long addr = KASAN_SHADOW_START;
        unsigned long end = KASAN_SHADOW_END;
        unsigned long next;
-       pmd_t *pmd = pmd_ptr_k(addr);
+       pmd_t *pmd = pmd_off_k(addr);
 
        BUILD_BUG_ON(KASAN_SHADOW_START & ~PGDIR_MASK);
 
index e2d6a62..c2c11eb 100644 (file)
@@ -38,7 +38,6 @@
 #include <asm/prom.h>
 #include <asm/io.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/smp.h>
 #include <asm/machdep.h>
index 4eaf462..13e74bc 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/prom.h>
 #include <asm/io.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <linux/uaccess.h>
 #include <asm/smp.h>
@@ -104,7 +103,7 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
                pmd_t *pmdp;
                unsigned long val = p | _PMD_SIZE_16M | _PAGE_EXEC | _PAGE_RW;
 
-               pmdp = pmd_ptr_k(v);
+               pmdp = pmd_off_k(v);
                *pmdp++ = __pmd(val);
                *pmdp++ = __pmd(val);
                *pmdp++ = __pmd(val);
@@ -119,7 +118,7 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
                pmd_t *pmdp;
                unsigned long val = p | _PMD_SIZE_4M | _PAGE_EXEC | _PAGE_RW;
 
-               pmdp = pmd_ptr_k(v);
+               pmdp = pmd_off_k(v);
                *pmdp = __pmd(val);
 
                v += LARGE_PAGE_SIZE_4M;
index 286441b..92e8929 100644 (file)
@@ -74,7 +74,7 @@ static pte_t __init *early_hugepd_alloc_kernel(hugepd_t *pmdp, unsigned long va)
 static int __ref __early_map_kernel_hugepage(unsigned long va, phys_addr_t pa,
                                             pgprot_t prot, int psize, bool new)
 {
-       pmd_t *pmdp = pmd_ptr_k(va);
+       pmd_t *pmdp = pmd_off_k(va);
        pte_t *ptep;
 
        if (WARN_ON(psize != MMU_PAGE_512K && psize != MMU_PAGE_8M))
index b4eb06c..c06dfbb 100644 (file)
@@ -41,7 +41,6 @@
 #include <asm/prom.h>
 #include <asm/io.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <linux/uaccess.h>
 #include <asm/smp.h>
index 1f110c3..d5e2704 100644 (file)
@@ -6,6 +6,7 @@
  *      Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
  */
 
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/reg.h>
 #include <asm/page.h>
@@ -13,7 +14,6 @@
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 #include <asm/cputable.h>
-#include <asm/pgtable.h>
 #include <asm/exception-64e.h>
 #include <asm/ppc-opcode.h>
 #include <asm/kvm_asm.h>
index cea5b4e..45a0556 100644 (file)
@@ -306,7 +306,7 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
        pmd = pmd_offset(pud, addr);
        /*
         * khugepaged to collapse normal pages to hugepage, first set
-        * pmd to none to force page fault/gup to take mmap_sem. After
+        * pmd to none to force page fault/gup to take mmap_lock. After
         * pmd is set to none, we do a pte_clear which does this assertion
         * so if we find pmd none, return.
         */
index 05902bb..6eb4eab 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/memblock.h>
 #include <linux/slab.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/fixmap.h>
 #include <asm/setup.h>
@@ -41,7 +40,7 @@ notrace void __init early_ioremap_init(void)
 {
        unsigned long addr = ALIGN_DOWN(FIXADDR_START, PGDIR_SIZE);
        pte_t *ptep = (pte_t *)early_fixmap_pagetable;
-       pmd_t *pmdp = pmd_ptr_k(addr);
+       pmd_t *pmdp = pmd_off_k(addr);
 
        for (; (s32)(FIXADDR_TOP - addr) > 0;
             addr += PGDIR_SIZE, ptep += PTRS_PER_PTE, pmdp++)
@@ -79,7 +78,7 @@ int __ref map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot)
        int err = -ENOMEM;
 
        /* Use upper 10 bits of VA to index the first level map */
-       pd = pmd_ptr_k(va);
+       pd = pmd_off_k(va);
        /* Use middle 10 bits of VA to index the second-level map */
        if (likely(slab_is_available()))
                pg = pte_alloc_kernel(pd, va);
index 1f86a88..bb43a8c 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/page.h>
 #include <asm/prom.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/smp.h>
 #include <asm/machdep.h>
index 4bc3507..8a797dc 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 #include <linux/kernel.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "ptdump.h"
 
index cebb58c..e29b338 100644 (file)
@@ -6,8 +6,8 @@
  * This dumps the content of BATS
  */
 
+#include <linux/pgtable.h>
 #include <asm/debugfs.h>
-#include <asm/pgtable.h>
 #include <asm/cpu_has_feature.h>
 
 #include "ptdump.h"
index 0dfca72..14f7386 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 #include <linux/kernel.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "ptdump.h"
 
index 6aaeb1e..a2c33ef 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
-#include <asm/pgtable.h>
 #include <linux/const.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
index 3209f78..de6e05e 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 #include <linux/const.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
index 784f8df..c005fe0 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 #include <linux/kernel.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "ptdump.h"
 
index 0caec3d..df59d0b 100644 (file)
@@ -332,7 +332,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
                fput(exe_file);
        }
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                if (vma->vm_start > spu_ref || vma->vm_end <= spu_ref)
                        continue;
@@ -349,13 +349,13 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
        *spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path);
        pr_debug("got dcookie for %pD\n", vma->vm_file);
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 out:
        return app_cookie;
 
 fail_no_image_cookie:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        printk(KERN_ERR "SPU_PROF: "
                "%s, line %d: Cannot find dcookie for SPU binary\n",
index dd50510..6c028ee 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/uaccess.h>
 #include <linux/mm.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
 #include <asm/vdso.h>
index 8aa9510..f7d888d 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/uaccess.h>
 #include <linux/mm.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
 #include <asm/vdso.h>
index 9cc1a12..814d1c2 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/uaccess.h>
 #include <linux/mm.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/sigcontext.h>
 #include <asm/ucontext.h>
 #include <asm/vdso.h>
index 27ac38f..6aa8def 100644 (file)
 #include <linux/kdev_t.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 
 #include <asm/time.h>
 #include <asm/machdep.h>
 #include <asm/pci-bridge.h>
-#include <asm/pgtable.h>
 #include <asm/ppc-pci.h>
 #include <mm/mmu_decl.h>
 #include <asm/prom.h>
index 915ab67..172d2b7 100644 (file)
@@ -22,8 +22,8 @@
 #include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
 #include <linux/of_platform.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <linux/atomic.h>
 #include <asm/time.h>
index a43b8c3..a4127b0 100644 (file)
@@ -13,8 +13,8 @@
 
 #include <linux/kernel.h>
 #include <linux/of_fdt.h>
+#include <linux/pgtable.h>
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/time.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
index dd97ef2..e4acf5c 100644 (file)
@@ -24,8 +24,8 @@
 #include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
 #include <linux/of_platform.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <linux/atomic.h>
 #include <asm/time.h>
index 48f7d96..fda108b 100644 (file)
@@ -16,9 +16,9 @@
 #include <linux/highmem.h>
 #include <linux/cpu.h>
 #include <linux/fsl/guts.h>
+#include <linux/pgtable.h>
 
 #include <asm/machdep.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/mpic.h>
 #include <asm/cacheflush.h>
index dba3aa7..87f524e 100644 (file)
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/pgtable.h>
 
 #include <asm/code-patching.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pci-bridge.h>
 #include <asm/mpic.h>
 #include <asm/cacheflush.h>
index 4db4ca2..c58b6f1 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/8xx_immap.h>
 #include <asm/cpm1.h>
 #include <asm/io.h>
index c80bd7a..aed4bc7 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/interrupt.h>
 #include <asm/irq.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/8xx_immap.h>
 #include <asm/cpm.h>
 #include <asm/cpm1.h>
index 0be212a..c2a0678 100644 (file)
@@ -12,9 +12,9 @@
 #include <linux/export.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/ptrace.h>
 #include <asm/cell-regs.h>
index 5927ead..c0ab62b 100644 (file)
@@ -23,9 +23,9 @@
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/kernel_stat.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/ptrace.h>
 #include <asm/machdep.h>
index 6af3a6e..9068ede 100644 (file)
 #include <linux/percpu.h>
 #include <linux/types.h>
 #include <linux/kallsyms.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/machdep.h>
 #include <asm/prom.h>
-#include <asm/pgtable.h>
 #include <asm/reg.h>
 #include <asm/cell-regs.h>
 #include <asm/cpu_has_feature.h>
index 855eedb..edefa78 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/pci-bridge.h>
index 85d795d..c855a0a 100644 (file)
 #include <linux/err.h>
 #include <linux/device.h>
 #include <linux/cpu.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
 #include <asm/irq.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
index 026b72c..210785f 100644 (file)
@@ -10,8 +10,8 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/ioport.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/io.h>
 
index e44427c..62d90a5 100644 (file)
@@ -325,7 +325,7 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf,
                return VM_FAULT_SIGBUS;
 
        /*
-        * Because we release the mmap_sem, the context may be destroyed while
+        * Because we release the mmap_lock, the context may be destroyed while
         * we're in spu_wait. Grab an extra reference so it isn't destroyed
         * in the meantime.
         */
@@ -334,8 +334,8 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf,
        /*
         * We have to wait for context to be loaded before we have
         * pages to hand out to the user, but we don't want to wait
-        * with the mmap_sem held.
-        * It is possible to drop the mmap_sem here, but then we need
+        * with the mmap_lock held.
+        * It is possible to drop the mmap_lock here, but then we need
         * to return VM_FAULT_NOPAGE because the mappings may have
         * hanged.
         */
@@ -343,11 +343,11 @@ static vm_fault_t spufs_ps_fault(struct vm_fault *vmf,
                goto refault;
 
        if (ctx->state == SPU_STATE_SAVED) {
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                spu_context_nospu_trace(spufs_ps_fault__sleep, ctx);
                err = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE);
                spu_context_trace(spufs_ps_fault__wake, ctx, ctx->spu);
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
        } else {
                area = ctx->spu->problem_phys + ps_offs;
                ret = vmf_insert_pfn(vmf->vma, vmf->address,
index b020c75..b2c2bf3 100644 (file)
@@ -8,9 +8,9 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/hydra.h>
 #include <asm/prom.h>
index 65a7e01..c45435a 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/timer.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 #include <asm/dma.h>
index f7bb6cb..e30cd29 100644 (file)
 #include <linux/kernel_stat.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
 #include <asm/irq.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/prom.h>
index 15b2c6e..f7e66a2 100644 (file)
@@ -42,7 +42,6 @@
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/prom.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
 #include <asm/iommu.h>
index 701c4e0..78209bb 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/time.h>
 
index 95fb4fe..f002b0f 100644 (file)
@@ -51,7 +51,6 @@
 #include <asm/reg.h>
 #include <asm/sections.h>
 #include <asm/prom.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
 #include <asm/ohare.h>
index 9969c07..eb23264 100644 (file)
 #include <linux/hardirq.h>
 #include <linux/cpu.h>
 #include <linux/compiler.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
 #include <asm/code-patching.h>
 #include <asm/irq.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/io.h>
 #include <asm/prom.h>
index b36ddee..31d6213 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/time.h>
 #include <asm/nvram.h>
index e4ed531..fd26f3d 100644 (file)
 #include <linux/cpuhotplug.h>
 #include <linux/workqueue.h>
 #include <linux/proc_fs.h>
+#include <linux/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/mmu_context.h>
 #include <asm/iommu.h>
index 64d18f4..2db8469 100644 (file)
@@ -43,7 +43,6 @@
 #include <asm/mmu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/pci-bridge.h>
index ad61e90..6891710 100644 (file)
 #include <linux/err.h>
 #include <linux/device.h>
 #include <linux/cpu.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <linux/atomic.h>
 #include <asm/irq.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
index 07718b9..68538b8 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/irq.h>
 #include <asm/mpc8260.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/cpm2.h>
 #include <asm/rheap.h>
 #include <asm/fs_pd.h>
index f6c665d..a3aeaa5 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/of_platform.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/fsl_85xx_cache_sram.h>
 
 #include "fsl_85xx_cache_ctlr.h"
index a3a72b7..b0426f2 100644 (file)
 #include <linux/slab.h>
 #include <linux/syscore_ops.h>
 #include <linux/ratelimit.h>
+#include <linux/pgtable.h>
 
 #include <asm/ptrace.h>
 #include <asm/signal.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/machdep.h>
 #include <asm/mpic.h>
index bfd1529..7efe4bc 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/machdep.h>
 #include <asm/xmon.h>
 #include <asm/processor.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/plpar_wrappers.h>
index 2368d49..1ff075a 100644 (file)
@@ -8,8 +8,8 @@
 
 #include <linux/kernel.h>
 #include <linux/sizes.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #ifdef CONFIG_MMU
 /*
index 0f47720..3835c32 100644 (file)
@@ -12,8 +12,8 @@
 #define _ASM_RISCV_IO_H
 
 #include <linux/types.h>
+#include <linux/pgtable.h>
 #include <asm/mmiowb.h>
-#include <asm/pgtable.h>
 
 /*
  * MMIO access functions are separated out to break dependency cycles
index b47045c..b04028c 100644 (file)
@@ -8,8 +8,6 @@
 
 #ifdef CONFIG_KASAN
 
-#include <asm/pgtable.h>
-
 #define KASAN_SHADOW_SCALE_SHIFT       3
 
 #define KASAN_SHADOW_SIZE      (UL(1) << (38 - KASAN_SHADOW_SCALE_SHIFT))
index b15f70a..f3b0da6 100644 (file)
@@ -70,13 +70,6 @@ static inline struct page *pud_page(pud_t pud)
        return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT);
 }
 
-#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
-
-static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
-{
-       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr);
-}
-
 static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot)
 {
        return __pmd((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot));
index d50706e..eaea1f7 100644 (file)
@@ -173,16 +173,6 @@ static inline unsigned long _pgd_pfn(pgd_t pgd)
        return pgd_val(pgd) >> _PAGE_PFN_SHIFT;
 }
 
-#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-
-/* Locate an entry in the page global directory */
-static inline pgd_t *pgd_offset(const struct mm_struct *mm, unsigned long addr)
-{
-       return mm->pgd + pgd_index(addr);
-}
-/* Locate an entry in the kernel page global directory */
-#define pgd_offset_k(addr)      pgd_offset(&init_mm, (addr))
-
 static inline struct page *pmd_page(pmd_t pmd)
 {
        return pfn_to_page(pmd_val(pmd) >> _PAGE_PFN_SHIFT);
@@ -209,16 +199,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot)
 
 #define mk_pte(page, prot)       pfn_pte(page_to_pfn(page), prot)
 
-#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
-static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long addr)
-{
-       return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(addr);
-}
-
-#define pte_offset_map(dir, addr)      pte_offset_kernel((dir), (addr))
-#define pte_unmap(pte)                 ((void)(pte))
-
 static inline int pte_present(pte_t pte)
 {
        return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
@@ -496,8 +476,6 @@ void paging_init(void);
 extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 
-#include <asm-generic/pgtable.h>
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_RISCV_PGTABLE_H */
index 8bbe5db..7191342 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/moduleloader.h>
 #include <linux/vmalloc.h>
 #include <linux/sizes.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/sections.h>
 
 static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)
index 3e52831..f04373b 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/cpu_ops.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/sbi.h>
 #include <asm/tlbflush.h>
 #include <asm/thread_info.h>
index 1fc8762..c7b0a73 100644 (file)
@@ -4,7 +4,7 @@
  */
 #include <linux/init.h>
 #include <linux/libfdt.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/soc.h>
 
 /*
index 837b9b3..5953429 100644 (file)
@@ -99,17 +99,18 @@ void notrace walk_stackframe(struct task_struct *task,
 
 static bool print_trace_address(unsigned long pc, void *arg)
 {
-       print_ip_sym(pc);
+       const char *loglvl = arg;
+
+       print_ip_sym(loglvl, pc);
        return false;
 }
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        pr_cont("Call Trace:\n");
-       walk_stackframe(task, NULL, print_trace_address, NULL);
+       walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
 }
 
-
 static bool save_wchan(unsigned long pc, void *arg)
 {
        if (!in_sched_functions(pc)) {
index 484d95a..e827fae 100644 (file)
@@ -61,7 +61,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
 
        vdso_len = (vdso_pages + 1) << PAGE_SHIFT;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0);
        if (IS_ERR_VALUE(vdso_base)) {
                ret = vdso_base;
@@ -83,7 +83,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
                mm->context.vdso = NULL;
 
 end:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index 8930ab7..0941186 100644 (file)
@@ -3,7 +3,6 @@
  * Copyright (C) 2017 SiFive
  */
 
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
 #ifdef CONFIG_SMP
index be84e32..ae7b7fe 100644 (file)
@@ -69,7 +69,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
 
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, addr);
        if (unlikely(!vma))
                goto bad_area;
@@ -114,7 +114,7 @@ good_area:
 
        /*
         * If we need to retry but a fatal signal is pending, handle the
-        * signal first. We do not need to release the mmap_sem because it
+        * signal first. We do not need to release the mmap_lock because it
         * would already be released in __lock_page_or_retry in mm/filemap.c.
         */
        if (fault_signal_pending(fault, regs))
@@ -147,7 +147,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -155,7 +155,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
        /*
@@ -163,7 +163,7 @@ good_area:
         * Fix it, but check if it's kernel or user first.
         */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        /* User mode accesses just cause a SIGSEGV */
        if (user_mode(regs)) {
                do_trap(regs, SIGSEGV, code, addr);
@@ -191,14 +191,14 @@ no_context:
         * (which will retry the fault, or kill us if we got oom-killed).
         */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                goto no_context;
        pagefault_out_of_memory();
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        /* Kernel mode? Handle exceptions or die */
        if (!user_mode(regs))
                goto no_context;
index 3432740..9996f49 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
 #include <asm/soc.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/ptdump.h>
 
@@ -236,12 +235,12 @@ static void __init create_pte_mapping(pte_t *ptep,
                                      uintptr_t va, phys_addr_t pa,
                                      phys_addr_t sz, pgprot_t prot)
 {
-       uintptr_t pte_index = pte_index(va);
+       uintptr_t pte_idx = pte_index(va);
 
        BUG_ON(sz != PAGE_SIZE);
 
-       if (pte_none(ptep[pte_index]))
-               ptep[pte_index] = pfn_pte(PFN_DOWN(pa), prot);
+       if (pte_none(ptep[pte_idx]))
+               ptep[pte_idx] = pfn_pte(PFN_DOWN(pa), prot);
 }
 
 #ifndef __PAGETABLE_PMD_FOLDED
@@ -284,21 +283,21 @@ static void __init create_pmd_mapping(pmd_t *pmdp,
 {
        pte_t *ptep;
        phys_addr_t pte_phys;
-       uintptr_t pmd_index = pmd_index(va);
+       uintptr_t pmd_idx = pmd_index(va);
 
        if (sz == PMD_SIZE) {
-               if (pmd_none(pmdp[pmd_index]))
-                       pmdp[pmd_index] = pfn_pmd(PFN_DOWN(pa), prot);
+               if (pmd_none(pmdp[pmd_idx]))
+                       pmdp[pmd_idx] = pfn_pmd(PFN_DOWN(pa), prot);
                return;
        }
 
-       if (pmd_none(pmdp[pmd_index])) {
+       if (pmd_none(pmdp[pmd_idx])) {
                pte_phys = alloc_pte(va);
-               pmdp[pmd_index] = pfn_pmd(PFN_DOWN(pte_phys), PAGE_TABLE);
+               pmdp[pmd_idx] = pfn_pmd(PFN_DOWN(pte_phys), PAGE_TABLE);
                ptep = get_pte_virt(pte_phys);
                memset(ptep, 0, PAGE_SIZE);
        } else {
-               pte_phys = PFN_PHYS(_pmd_pfn(pmdp[pmd_index]));
+               pte_phys = PFN_PHYS(_pmd_pfn(pmdp[pmd_idx]));
                ptep = get_pte_virt(pte_phys);
        }
 
@@ -326,21 +325,21 @@ static void __init create_pgd_mapping(pgd_t *pgdp,
 {
        pgd_next_t *nextp;
        phys_addr_t next_phys;
-       uintptr_t pgd_index = pgd_index(va);
+       uintptr_t pgd_idx = pgd_index(va);
 
        if (sz == PGDIR_SIZE) {
-               if (pgd_val(pgdp[pgd_index]) == 0)
-                       pgdp[pgd_index] = pfn_pgd(PFN_DOWN(pa), prot);
+               if (pgd_val(pgdp[pgd_idx]) == 0)
+                       pgdp[pgd_idx] = pfn_pgd(PFN_DOWN(pa), prot);
                return;
        }
 
-       if (pgd_val(pgdp[pgd_index]) == 0) {
+       if (pgd_val(pgdp[pgd_idx]) == 0) {
                next_phys = alloc_pgd_next(va);
-               pgdp[pgd_index] = pfn_pgd(PFN_DOWN(next_phys), PAGE_TABLE);
+               pgdp[pgd_idx] = pfn_pgd(PFN_DOWN(next_phys), PAGE_TABLE);
                nextp = get_pgd_next_virt(next_phys);
                memset(nextp, 0, PAGE_SIZE);
        } else {
-               next_phys = PFN_PHYS(_pgd_pfn(pgdp[pgd_index]));
+               next_phys = PFN_PHYS(_pgd_pfn(pgdp[pgd_idx]));
                nextp = get_pgd_next_virt(next_phys);
        }
 
index ec0ca90..4a8b618 100644 (file)
@@ -6,8 +6,8 @@
 #include <linux/kasan.h>
 #include <linux/kernel.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 #include <asm/tlbflush.h>
-#include <asm/pgtable.h>
 #include <asm/fixmap.h>
 
 extern pgd_t early_pg_dir[PTRS_PER_PGD];
index 728759e..ec2c70f 100644 (file)
@@ -4,7 +4,7 @@
  */
 
 #include <linux/pagewalk.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/bitops.h>
 
@@ -117,10 +117,10 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask,
        if (!numpages)
                return 0;
 
-       down_read(&init_mm.mmap_sem);
+       mmap_read_lock(&init_mm);
        ret =  walk_page_range_novma(&init_mm, start, end, &pageattr_ops, NULL,
                                     &masks);
-       up_read(&init_mm.mmap_sem);
+       mmap_read_unlock(&init_mm);
 
        flush_tlb_kernel_range(start, end);
 
index 070505d..0831c2e 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/ptdump.h>
 
 #include <asm/ptdump.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/kasan.h>
 
 #define pt_dump_seq_printf(m, fmt, args...)    \
index 357adad..8e222a6 100644 (file)
@@ -2,12 +2,12 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ctype.h>
+#include <linux/pgtable.h>
 #include <asm/ebcdic.h>
 #include <asm/sclp.h>
 #include <asm/sections.h>
 #include <asm/boot_data.h>
 #include <asm/facility.h>
-#include <asm/pgtable.h>
 #include <asm/uv.h>
 #include "boot.h"
 
index 5591243..d444216 100644 (file)
@@ -2,8 +2,8 @@
 /*
  * Copyright IBM Corp. 2019
  */
+#include <linux/pgtable.h>
 #include <asm/mem_detect.h>
-#include <asm/pgtable.h>
 #include <asm/cpacf.h>
 #include <asm/timex.h>
 #include <asm/sclp.h>
index 9ddf4a4..60f9241 100644 (file)
@@ -9,8 +9,8 @@
 #ifndef _ASM_S390_HUGETLB_H
 #define _ASM_S390_HUGETLB_H
 
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #define hugetlb_free_pgd_range                 free_pgd_range
 #define hugepages_supported()                  (MACHINE_HAS_EDAT1)
index 70930fe..89d6886 100644 (file)
@@ -2,8 +2,6 @@
 #ifndef __ASM_KASAN_H
 #define __ASM_KASAN_H
 
-#include <asm/pgtable.h>
-
 #ifdef CONFIG_KASAN
 
 #define KASAN_SHADOW_SCALE_SHIFT 3
index e2528e0..19d603b 100644 (file)
@@ -1229,7 +1229,6 @@ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
 #define p4d_index(address) (((address) >> P4D_SHIFT) & (PTRS_PER_P4D-1))
 #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
 #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
 
 #define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
 #define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN)
@@ -1260,7 +1259,6 @@ static inline pgd_t *pgd_offset_raw(pgd_t *pgd, unsigned long address)
 }
 
 #define pgd_offset(mm, address) pgd_offset_raw(READ_ONCE((mm)->pgd), address)
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
 static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
 {
@@ -1275,6 +1273,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
                return (pud_t *) p4d_deref(*p4d) + pud_index(address);
        return (pud_t *) p4d;
 }
+#define pud_offset pud_offset
 
 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
 {
@@ -1282,17 +1281,13 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
                return (pmd_t *) pud_deref(*pud) + pmd_index(address);
        return (pmd_t *) pud;
 }
+#define pmd_offset pmd_offset
 
-static inline pte_t *pte_offset(pmd_t *pmd, unsigned long address)
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 {
-       return (pte_t *) pmd_deref(*pmd) + pte_index(address);
+       return (unsigned long) pmd_deref(pmd);
 }
 
-#define pte_offset_kernel(pmd, address) pte_offset(pmd, address)
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-
-static inline void pte_unmap(pte_t *pte) { }
-
 static inline bool gup_fast_permitted(unsigned long start, unsigned long end)
 {
        return end <= current->mm->context.asce_limit;
@@ -1683,6 +1678,4 @@ extern void s390_reset_cmma(struct mm_struct *mm);
 #define HAVE_ARCH_UNMAPPED_AREA
 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 
-#include <asm-generic/pgtable.h>
-
 #endif /* _S390_PAGE_H */
index 82703e0..2204704 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/sched.h>
 #include <asm/processor.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 /*
  * Flush all TLB entries on the local CPU.
index e80f0e6..165031b 100644 (file)
@@ -11,9 +11,9 @@
 #include <linux/kvm_host.h>
 #include <linux/sched.h>
 #include <linux/purgatory.h>
+#include <linux/pgtable.h>
 #include <asm/idle.h>
 #include <asm/vdso.h>
-#include <asm/pgtable.h>
 #include <asm/gmap.h>
 #include <asm/nmi.h>
 #include <asm/stacktrace.h>
index 2c122d8..0dc4b25 100644 (file)
@@ -126,15 +126,16 @@ unknown:
        return -EINVAL;
 }
 
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack(struct task_struct *task, unsigned long *stack,
+                      const char *loglvl)
 {
        struct unwind_state state;
 
-       printk("Call Trace:\n");
+       printk("%sCall Trace:\n", loglvl);
        unwind_for_each_frame(&state, task, NULL, (unsigned long) stack)
-               printk(state.reliable ? " [<%016lx>] %pSR \n" :
-                                       "([<%016lx>] %pSR)\n",
-                      state.ip, (void *) state.ip);
+               printk(state.reliable ? "%s [<%016lx>] %pSR \n" :
+                                       "%s([<%016lx>] %pSR)\n",
+                      loglvl, state.ip, (void *) state.ip);
        debug_show_held_locks(task ? : current);
 }
 
@@ -175,7 +176,7 @@ void show_regs(struct pt_regs *regs)
        show_registers(regs);
        /* Show stack backtrace if pt_regs is from kernel mode */
        if (!user_mode(regs))
-               show_stack(NULL, (unsigned long *) regs->gprs[15]);
+               show_stack(NULL, (unsigned long *) regs->gprs[15], KERN_DEFAULT);
        show_last_breaking_event(regs);
 }
 
index 3a854cb..93c6b89 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/debug_locks.h>
 #include <asm/cio.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/smp.h>
 #include <asm/ipl.h>
index 994a8b8..ce60a45 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/compat.h>
 #include <trace/syscall.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <linux/uaccess.h>
 #include <asm/unistd.h>
index 4c0677f..66e89b2 100644 (file)
@@ -205,7 +205,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
 
 again:
        rc = -EFAULT;
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
 
        uaddr = __gmap_translate(gmap, gaddr);
        if (IS_ERR_VALUE(uaddr))
@@ -234,7 +234,7 @@ again:
        pte_unmap_unlock(ptep, ptelock);
        unlock_page(page);
 out:
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
 
        if (rc == -EAGAIN) {
                wait_on_page_writeback(page);
index bcc9bdb..c4baefa 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/memblock.h>
 #include <linux/compat.h>
 #include <asm/asm-offsets.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
@@ -208,7 +207,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
         * it at vdso_base which is the "natural" base for it, but we might
         * fail and end up putting it elsewhere.
         */
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
        vdso_base = get_unmapped_area(NULL, 0, vdso_pages << PAGE_SHIFT, 0, 0);
        if (IS_ERR_VALUE(vdso_base)) {
@@ -239,7 +238,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        rc = 0;
 
 out_up:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return rc;
 }
 
index 47a67a9..6d6b570 100644 (file)
@@ -9,8 +9,8 @@
 #include <linux/vmalloc.h>
 #include <linux/mm_types.h>
 #include <linux/err.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/gmap.h>
 #include "kvm-s390.h"
 #include "gaccess.h"
@@ -1173,7 +1173,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg,
        int dat_protection, fake;
        int rc;
 
-       down_read(&sg->mm->mmap_sem);
+       mmap_read_lock(sg->mm);
        /*
         * We don't want any guest-2 tables to change - so the parent
         * tables/pointers we read stay valid - unshadowing is however
@@ -1202,6 +1202,6 @@ shadow_page:
        if (!rc)
                rc = gmap_shadow_page(sg, saddr, __pte(pte.val));
        ipte_unlock(vcpu);
-       up_read(&sg->mm->mmap_sem);
+       mmap_read_unlock(sg->mm);
        return rc;
 }
index a4d4ca2..1608fd9 100644 (file)
@@ -2767,10 +2767,10 @@ static struct page *get_map_page(struct kvm *kvm, u64 uaddr)
 {
        struct page *page = NULL;
 
-       down_read(&kvm->mm->mmap_sem);
+       mmap_read_lock(kvm->mm);
        get_user_pages_remote(NULL, kvm->mm, uaddr, 1, FOLL_WRITE,
                              &page, NULL, NULL);
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
        return page;
 }
 
index 22058ea..d0ff26d 100644 (file)
 #include <linux/bitmap.h>
 #include <linux/sched/signal.h>
 #include <linux/string.h>
+#include <linux/pgtable.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/lowcore.h>
 #include <asm/stp.h>
-#include <asm/pgtable.h>
 #include <asm/gmap.h>
 #include <asm/nmi.h>
 #include <asm/switch_to.h>
@@ -763,9 +763,9 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
                        r = -EINVAL;
                else {
                        r = 0;
-                       down_write(&kvm->mm->mmap_sem);
+                       mmap_write_lock(kvm->mm);
                        kvm->mm->context.allow_gmap_hpage_1m = 1;
-                       up_write(&kvm->mm->mmap_sem);
+                       mmap_write_unlock(kvm->mm);
                        /*
                         * We might have to create fake 4k page
                         * tables. To avoid that the hardware works on
@@ -1815,7 +1815,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
        if (!keys)
                return -ENOMEM;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        srcu_idx = srcu_read_lock(&kvm->srcu);
        for (i = 0; i < args->count; i++) {
                hva = gfn_to_hva(kvm, args->start_gfn + i);
@@ -1829,7 +1829,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
                        break;
        }
        srcu_read_unlock(&kvm->srcu, srcu_idx);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        if (!r) {
                r = copy_to_user((uint8_t __user *)args->skeydata_addr, keys,
@@ -1873,7 +1873,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
                goto out;
 
        i = 0;
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        srcu_idx = srcu_read_lock(&kvm->srcu);
         while (i < args->count) {
                unlocked = false;
@@ -1900,7 +1900,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
                        i++;
        }
        srcu_read_unlock(&kvm->srcu, srcu_idx);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 out:
        kvfree(keys);
        return r;
@@ -2089,14 +2089,14 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,
        if (!values)
                return -ENOMEM;
 
-       down_read(&kvm->mm->mmap_sem);
+       mmap_read_lock(kvm->mm);
        srcu_idx = srcu_read_lock(&kvm->srcu);
        if (peek)
                ret = kvm_s390_peek_cmma(kvm, args, values, bufsize);
        else
                ret = kvm_s390_get_cmma(kvm, args, values, bufsize);
        srcu_read_unlock(&kvm->srcu, srcu_idx);
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
 
        if (kvm->arch.migration_mode)
                args->remaining = atomic64_read(&kvm->arch.cmma_dirty_pages);
@@ -2146,7 +2146,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
                goto out;
        }
 
-       down_read(&kvm->mm->mmap_sem);
+       mmap_read_lock(kvm->mm);
        srcu_idx = srcu_read_lock(&kvm->srcu);
        for (i = 0; i < args->count; i++) {
                hva = gfn_to_hva(kvm, args->start_gfn + i);
@@ -2161,12 +2161,12 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
                set_pgste_bits(kvm->mm, hva, mask, pgstev);
        }
        srcu_read_unlock(&kvm->srcu, srcu_idx);
-       up_read(&kvm->mm->mmap_sem);
+       mmap_read_unlock(kvm->mm);
 
        if (!kvm->mm->context.uses_cmm) {
-               down_write(&kvm->mm->mmap_sem);
+               mmap_write_lock(kvm->mm);
                kvm->mm->context.uses_cmm = 1;
-               up_write(&kvm->mm->mmap_sem);
+               mmap_write_unlock(kvm->mm);
        }
 out:
        vfree(bits);
@@ -2239,9 +2239,9 @@ static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd)
                if (r)
                        break;
 
-               down_write(&current->mm->mmap_sem);
+               mmap_write_lock(current->mm);
                r = gmap_mark_unmergeable();
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
                if (r)
                        break;
 
index 8938936..96ae368 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/compat.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/facility.h>
@@ -20,7 +21,6 @@
 #include <asm/debug.h>
 #include <asm/ebcdic.h>
 #include <asm/sysinfo.h>
-#include <asm/pgtable.h>
 #include <asm/page-states.h>
 #include <asm/pgalloc.h>
 #include <asm/gmap.h>
@@ -270,18 +270,18 @@ static int handle_iske(struct kvm_vcpu *vcpu)
                return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
 retry:
        unlocked = false;
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        rc = get_guest_storage_key(current->mm, vmaddr, &key);
 
        if (rc) {
                rc = fixup_user_fault(current, current->mm, vmaddr,
                                      FAULT_FLAG_WRITE, &unlocked);
                if (!rc) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        goto retry;
                }
        }
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        if (rc == -EFAULT)
                return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
        if (rc < 0)
@@ -317,17 +317,17 @@ static int handle_rrbe(struct kvm_vcpu *vcpu)
                return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
 retry:
        unlocked = false;
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        rc = reset_guest_reference_bit(current->mm, vmaddr);
        if (rc < 0) {
                rc = fixup_user_fault(current, current->mm, vmaddr,
                                      FAULT_FLAG_WRITE, &unlocked);
                if (!rc) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        goto retry;
                }
        }
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        if (rc == -EFAULT)
                return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
        if (rc < 0)
@@ -385,7 +385,7 @@ static int handle_sske(struct kvm_vcpu *vcpu)
                if (kvm_is_error_hva(vmaddr))
                        return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
 
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                rc = cond_set_guest_storage_key(current->mm, vmaddr, key, &oldkey,
                                                m3 & SSKE_NQ, m3 & SSKE_MR,
                                                m3 & SSKE_MC);
@@ -395,7 +395,7 @@ static int handle_sske(struct kvm_vcpu *vcpu)
                                              FAULT_FLAG_WRITE, &unlocked);
                        rc = !rc ? -EAGAIN : rc;
                }
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                if (rc == -EFAULT)
                        return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
                if (rc < 0)
@@ -1091,7 +1091,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
 
                        if (rc)
                                return rc;
-                       down_read(&current->mm->mmap_sem);
+                       mmap_read_lock(current->mm);
                        rc = cond_set_guest_storage_key(current->mm, vmaddr,
                                                        key, NULL, nq, mr, mc);
                        if (rc < 0) {
@@ -1099,7 +1099,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
                                                      FAULT_FLAG_WRITE, &unlocked);
                                rc = !rc ? -EAGAIN : rc;
                        }
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        if (rc == -EFAULT)
                                return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
                        if (rc == -EAGAIN)
@@ -1122,7 +1122,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
 }
 
 /*
- * Must be called with relevant read locks held (kvm->mm->mmap_sem, kvm->srcu)
+ * Must be called with relevant read locks held (kvm->mm->mmap_lock, kvm->srcu)
  */
 static inline int __do_essa(struct kvm_vcpu *vcpu, const int orc)
 {
@@ -1220,9 +1220,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)
                 * already correct, we do nothing and avoid the lock.
                 */
                if (vcpu->kvm->mm->context.uses_cmm == 0) {
-                       down_write(&vcpu->kvm->mm->mmap_sem);
+                       mmap_write_lock(vcpu->kvm->mm);
                        vcpu->kvm->mm->context.uses_cmm = 1;
-                       up_write(&vcpu->kvm->mm->mmap_sem);
+                       mmap_write_unlock(vcpu->kvm->mm);
                }
                /*
                 * If we are here, we are supposed to have CMMA enabled in
@@ -1239,11 +1239,11 @@ static int handle_essa(struct kvm_vcpu *vcpu)
        } else {
                int srcu_idx;
 
-               down_read(&vcpu->kvm->mm->mmap_sem);
+               mmap_read_lock(vcpu->kvm->mm);
                srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
                i = __do_essa(vcpu, orc);
                srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
-               up_read(&vcpu->kvm->mm->mmap_sem);
+               mmap_read_unlock(vcpu->kvm->mm);
                if (i < 0)
                        return i;
                /* Account for the possible extra cbrl entry */
@@ -1251,10 +1251,10 @@ static int handle_essa(struct kvm_vcpu *vcpu)
        }
        vcpu->arch.sie_block->cbrlo &= PAGE_MASK;       /* reset nceo */
        cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo);
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
        for (i = 0; i < entries; ++i)
                __gmap_zap(gmap, cbrlo[i]);
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
        return 0;
 }
 
index 5d67b81..c2ac9b8 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/kasan.h>
 #include <asm/kasan.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 
 static unsigned long max_addr;
 
index fd0dae9..9e0aa7a 100644 (file)
@@ -20,9 +20,9 @@
 #include <linux/ctype.h>
 #include <linux/ioport.h>
 #include <linux/refcount.h>
+#include <linux/pgtable.h>
 #include <asm/diag.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/ebcdic.h>
 #include <asm/errno.h>
 #include <asm/extmem.h>
index dedc28b..6a24751 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/hugetlb.h>
 #include <asm/asm-offsets.h>
 #include <asm/diag.h>
-#include <asm/pgtable.h>
 #include <asm/gmap.h>
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
@@ -434,7 +433,7 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
                flags |= FAULT_FLAG_USER;
        if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
                flags |= FAULT_FLAG_WRITE;
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        gmap = NULL;
        if (IS_ENABLED(CONFIG_PGSTE) && type == GMAP_FAULT) {
@@ -508,14 +507,14 @@ retry:
                        if (IS_ENABLED(CONFIG_PGSTE) && gmap &&
                            (flags & FAULT_FLAG_RETRY_NOWAIT)) {
                                /* FAULT_FLAG_RETRY_NOWAIT has been set,
-                                * mmap_sem has not been released */
+                                * mmap_lock has not been released */
                                current->thread.gmap_pfault = 1;
                                fault = VM_FAULT_PFAULT;
                                goto out_up;
                        }
                        flags &= ~FAULT_FLAG_RETRY_NOWAIT;
                        flags |= FAULT_FLAG_TRIED;
-                       down_read(&mm->mmap_sem);
+                       mmap_read_lock(mm);
                        goto retry;
                }
        }
@@ -533,7 +532,7 @@ retry:
        }
        fault = 0;
 out_up:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 out:
        return fault;
 }
@@ -825,22 +824,22 @@ void do_secure_storage_access(struct pt_regs *regs)
        switch (get_fault_type(regs)) {
        case USER_FAULT:
                mm = current->mm;
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = find_vma(mm, addr);
                if (!vma) {
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        do_fault_error(regs, VM_READ | VM_WRITE, VM_FAULT_BADMAP);
                        break;
                }
                page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
                if (IS_ERR_OR_NULL(page)) {
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        break;
                }
                if (arch_make_page_accessible(page))
                        send_sig(SIGSEGV, current, 0);
                put_page(page);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                break;
        case KERNEL_FAULT:
                page = phys_to_page(addr);
index 4b6903f..190357f 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/swapops.h>
 #include <linux/ksm.h>
 #include <linux/mman.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/gmap.h>
 #include <asm/tlb.h>
@@ -300,7 +300,7 @@ struct gmap *gmap_get_enabled(void)
 EXPORT_SYMBOL_GPL(gmap_get_enabled);
 
 /*
- * gmap_alloc_table is assumed to be called with mmap_sem held
+ * gmap_alloc_table is assumed to be called with mmap_lock held
  */
 static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
                            unsigned long init, unsigned long gaddr)
@@ -405,10 +405,10 @@ int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len)
                return -EINVAL;
 
        flush = 0;
-       down_write(&gmap->mm->mmap_sem);
+       mmap_write_lock(gmap->mm);
        for (off = 0; off < len; off += PMD_SIZE)
                flush |= __gmap_unmap_by_gaddr(gmap, to + off);
-       up_write(&gmap->mm->mmap_sem);
+       mmap_write_unlock(gmap->mm);
        if (flush)
                gmap_flush_tlb(gmap);
        return 0;
@@ -438,7 +438,7 @@ int gmap_map_segment(struct gmap *gmap, unsigned long from,
                return -EINVAL;
 
        flush = 0;
-       down_write(&gmap->mm->mmap_sem);
+       mmap_write_lock(gmap->mm);
        for (off = 0; off < len; off += PMD_SIZE) {
                /* Remove old translation */
                flush |= __gmap_unmap_by_gaddr(gmap, to + off);
@@ -448,7 +448,7 @@ int gmap_map_segment(struct gmap *gmap, unsigned long from,
                                      (void *) from + off))
                        break;
        }
-       up_write(&gmap->mm->mmap_sem);
+       mmap_write_unlock(gmap->mm);
        if (flush)
                gmap_flush_tlb(gmap);
        if (off >= len)
@@ -466,7 +466,7 @@ EXPORT_SYMBOL_GPL(gmap_map_segment);
  * Returns user space address which corresponds to the guest address or
  * -EFAULT if no such mapping exists.
  * This function does not establish potentially missing page table entries.
- * The mmap_sem of the mm that belongs to the address space must be held
+ * The mmap_lock of the mm that belongs to the address space must be held
  * when this function gets called.
  *
  * Note: Can also be called for shadow gmaps.
@@ -495,9 +495,9 @@ unsigned long gmap_translate(struct gmap *gmap, unsigned long gaddr)
 {
        unsigned long rc;
 
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
        rc = __gmap_translate(gmap, gaddr);
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
        return rc;
 }
 EXPORT_SYMBOL_GPL(gmap_translate);
@@ -534,7 +534,7 @@ static void gmap_pmdp_xchg(struct gmap *gmap, pmd_t *old, pmd_t new,
  *
  * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT
  * if the vm address is already mapped to a different guest segment.
- * The mmap_sem of the mm that belongs to the address space must be held
+ * The mmap_lock of the mm that belongs to the address space must be held
  * when this function gets called.
  */
 int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr)
@@ -640,7 +640,7 @@ int gmap_fault(struct gmap *gmap, unsigned long gaddr,
        int rc;
        bool unlocked;
 
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
 
 retry:
        unlocked = false;
@@ -655,7 +655,7 @@ retry:
                goto out_up;
        }
        /*
-        * In the case that fixup_user_fault unlocked the mmap_sem during
+        * In the case that fixup_user_fault unlocked the mmap_lock during
         * faultin redo __gmap_translate to not race with a map/unmap_segment.
         */
        if (unlocked)
@@ -663,13 +663,13 @@ retry:
 
        rc = __gmap_link(gmap, gaddr, vmaddr);
 out_up:
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
        return rc;
 }
 EXPORT_SYMBOL_GPL(gmap_fault);
 
 /*
- * this function is assumed to be called with mmap_sem held
+ * this function is assumed to be called with mmap_lock held
  */
 void __gmap_zap(struct gmap *gmap, unsigned long gaddr)
 {
@@ -696,7 +696,7 @@ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to)
        unsigned long gaddr, vmaddr, size;
        struct vm_area_struct *vma;
 
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
        for (gaddr = from; gaddr < to;
             gaddr = (gaddr + PMD_SIZE) & PMD_MASK) {
                /* Find the vm address for the guest address */
@@ -719,7 +719,7 @@ void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to)
                size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK));
                zap_page_range(vma, vmaddr, size);
        }
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
 }
 EXPORT_SYMBOL_GPL(gmap_discard);
 
@@ -882,7 +882,7 @@ static int gmap_pte_op_fixup(struct gmap *gmap, unsigned long gaddr,
        if (fixup_user_fault(current, mm, vmaddr, fault_flags, &unlocked))
                return -EFAULT;
        if (unlocked)
-               /* lost mmap_sem, caller has to retry __gmap_translate */
+               /* lost mmap_lock, caller has to retry __gmap_translate */
                return 0;
        /* Connect the page tables */
        return __gmap_link(gmap, gaddr, vmaddr);
@@ -953,7 +953,7 @@ static inline void gmap_pmd_op_end(struct gmap *gmap, pmd_t *pmdp)
  * -EAGAIN if a fixup is needed
  * -EINVAL if unsupported notifier bits have been specified
  *
- * Expected to be called with sg->mm->mmap_sem in read and
+ * Expected to be called with sg->mm->mmap_lock in read and
  * guest_table_lock held.
  */
 static int gmap_protect_pmd(struct gmap *gmap, unsigned long gaddr,
@@ -999,7 +999,7 @@ static int gmap_protect_pmd(struct gmap *gmap, unsigned long gaddr,
  * Returns 0 if successfully protected, -ENOMEM if out of memory and
  * -EAGAIN if a fixup is needed.
  *
- * Expected to be called with sg->mm->mmap_sem in read
+ * Expected to be called with sg->mm->mmap_lock in read
  */
 static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr,
                            pmd_t *pmdp, int prot, unsigned long bits)
@@ -1035,7 +1035,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr,
  * Returns 0 if successfully protected, -ENOMEM if out of memory and
  * -EFAULT if gaddr is invalid (or mapping for shadows is missing).
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 static int gmap_protect_range(struct gmap *gmap, unsigned long gaddr,
                              unsigned long len, int prot, unsigned long bits)
@@ -1106,9 +1106,9 @@ int gmap_mprotect_notify(struct gmap *gmap, unsigned long gaddr,
                return -EINVAL;
        if (!MACHINE_HAS_ESOP && prot == PROT_READ)
                return -EINVAL;
-       down_read(&gmap->mm->mmap_sem);
+       mmap_read_lock(gmap->mm);
        rc = gmap_protect_range(gmap, gaddr, len, prot, GMAP_NOTIFY_MPROT);
-       up_read(&gmap->mm->mmap_sem);
+       mmap_read_unlock(gmap->mm);
        return rc;
 }
 EXPORT_SYMBOL_GPL(gmap_mprotect_notify);
@@ -1124,7 +1124,7 @@ EXPORT_SYMBOL_GPL(gmap_mprotect_notify);
  * if reading using the virtual address failed. -EINVAL if called on a gmap
  * shadow.
  *
- * Called with gmap->mm->mmap_sem in read.
+ * Called with gmap->mm->mmap_lock in read.
  */
 int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val)
 {
@@ -1696,11 +1696,11 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
        }
        spin_unlock(&parent->shadow_lock);
        /* protect after insertion, so it will get properly invalidated */
-       down_read(&parent->mm->mmap_sem);
+       mmap_read_lock(parent->mm);
        rc = gmap_protect_range(parent, asce & _ASCE_ORIGIN,
                                ((asce & _ASCE_TABLE_LENGTH) + 1) * PAGE_SIZE,
                                PROT_READ, GMAP_NOTIFY_SHADOW);
-       up_read(&parent->mm->mmap_sem);
+       mmap_read_unlock(parent->mm);
        spin_lock(&parent->shadow_lock);
        new->initialized = true;
        if (rc) {
@@ -1729,7 +1729,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow);
  * shadow table structure is incomplete, -ENOMEM if out of memory and
  * -EFAULT if an address in the parent gmap could not be resolved.
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
                    int fake)
@@ -1813,7 +1813,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_r2t);
  * shadow table structure is incomplete, -ENOMEM if out of memory and
  * -EFAULT if an address in the parent gmap could not be resolved.
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
                    int fake)
@@ -1897,7 +1897,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_r3t);
  * shadow table structure is incomplete, -ENOMEM if out of memory and
  * -EFAULT if an address in the parent gmap could not be resolved.
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
                    int fake)
@@ -1981,7 +1981,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_sgt);
  * Returns 0 if the shadow page table was found and -EAGAIN if the page
  * table was not found.
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 int gmap_shadow_pgt_lookup(struct gmap *sg, unsigned long saddr,
                           unsigned long *pgt, int *dat_protection,
@@ -2021,7 +2021,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_pgt_lookup);
  * shadow table structure is incomplete, -ENOMEM if out of memory,
  * -EFAULT if an address in the parent gmap could not be resolved and
  *
- * Called with gmap->mm->mmap_sem in read
+ * Called with gmap->mm->mmap_lock in read
  */
 int gmap_shadow_pgt(struct gmap *sg, unsigned long saddr, unsigned long pgt,
                    int fake)
@@ -2100,7 +2100,7 @@ EXPORT_SYMBOL_GPL(gmap_shadow_pgt);
  * shadow table structure is incomplete, -ENOMEM if out of memory and
  * -EFAULT if an address in the parent gmap could not be resolved.
  *
- * Called with sg->mm->mmap_sem in read.
+ * Called with sg->mm->mmap_lock in read.
  */
 int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte)
 {
@@ -2543,12 +2543,12 @@ int s390_enable_sie(void)
        /* Fail if the page tables are 2K */
        if (!mm_alloc_pgste(mm))
                return -EINVAL;
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        mm->context.has_pgste = 1;
        /* split thp mappings and disable thp for future mappings */
        thp_split_mm(mm);
        walk_page_range(mm, 0, TASK_SIZE, &zap_zero_walk_ops, NULL);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return 0;
 }
 EXPORT_SYMBOL_GPL(s390_enable_sie);
@@ -2617,7 +2617,7 @@ int s390_enable_skey(void)
        struct mm_struct *mm = current->mm;
        int rc = 0;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        if (mm_uses_skeys(mm))
                goto out_up;
 
@@ -2630,7 +2630,7 @@ int s390_enable_skey(void)
        walk_page_range(mm, 0, TASK_SIZE, &enable_skey_walk_ops, NULL);
 
 out_up:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return rc;
 }
 EXPORT_SYMBOL_GPL(s390_enable_skey);
@@ -2651,9 +2651,9 @@ static const struct mm_walk_ops reset_cmma_walk_ops = {
 
 void s390_reset_cmma(struct mm_struct *mm)
 {
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        walk_page_range(mm, 0, TASK_SIZE, &reset_cmma_walk_ops, NULL);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 }
 EXPORT_SYMBOL_GPL(s390_reset_cmma);
 
@@ -2685,9 +2685,9 @@ void s390_reset_acc(struct mm_struct *mm)
         */
        if (!mmget_not_zero(mm))
                return;
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        walk_page_range(mm, 0, TASK_SIZE, &reset_acc_walk_ops, NULL);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 }
 EXPORT_SYMBOL_GPL(s390_reset_acc);
index b11bcf4..6dc7c3b 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/dma-direct.h>
 #include <asm/processor.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/dma.h>
 #include <asm/lowcore.h>
index 0634561..99dd1c6 100644 (file)
@@ -2,8 +2,8 @@
 #include <linux/kasan.h>
 #include <linux/sched/task.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/kasan.h>
 #include <asm/mem_detect.h>
 #include <asm/processor.h>
index e22c06d..c5c52ec 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/mm.h>
 #include <asm/cacheflush.h>
 #include <asm/facility.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/page.h>
 #include <asm/set_memory.h>
@@ -86,7 +85,7 @@ static int walk_pte_level(pmd_t *pmdp, unsigned long addr, unsigned long end,
 {
        pte_t *ptep, new;
 
-       ptep = pte_offset(pmdp, addr);
+       ptep = pte_offset_kernel(pmdp, addr);
        do {
                new = *ptep;
                if (pte_none(new))
@@ -338,19 +337,11 @@ void __kernel_map_pages(struct page *page, int numpages, int enable)
 {
        unsigned long address;
        int nr, i, j;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmd;
        pte_t *pte;
 
        for (i = 0; i < numpages;) {
                address = page_to_phys(page + i);
-               pgd = pgd_offset_k(address);
-               p4d = p4d_offset(pgd, address);
-               pud = pud_offset(p4d, address);
-               pmd = pmd_offset(pud, address);
-               pte = pte_offset_kernel(pmd, address);
+               pte = virt_to_kpte(address);
                nr = (unsigned long)pte >> ilog2(sizeof(long));
                nr = PTRS_PER_PTE - (nr & (PTRS_PER_PTE - 1));
                nr = min(numpages - i, nr);
index fff169d..11d2c83 100644 (file)
@@ -114,7 +114,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
        spin_lock_bh(&mm->page_table_lock);
 
        /*
-        * This routine gets called with mmap_sem lock held and there is
+        * This routine gets called with mmap_lock lock held and there is
         * no reason to optimize for the case of otherwise. However, if
         * that would ever change, the below check will let us know.
         */
index 9ebd012..2e0cc19 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ksm.h>
 #include <linux/mman.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
index f810930..8b6282c 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/slab.h>
 #include <asm/cacheflush.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
index 020a2c5..38efa3e 100644 (file)
@@ -125,7 +125,7 @@ static long get_pfn(unsigned long user_addr, unsigned long access,
        struct vm_area_struct *vma;
        long ret;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        ret = -EINVAL;
        vma = find_vma(current->mm, user_addr);
        if (!vma)
@@ -135,7 +135,7 @@ static long get_pfn(unsigned long user_addr, unsigned long access,
                goto out;
        ret = follow_pfn(vma, user_addr, pfn);
 out:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        return ret;
 }
 
index 3924d91..26f0f9b 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/cache.h>
 #include <asm/addrspace.h>
 #include <asm/machvec.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm-generic/iomap.h>
 
 #ifdef __KERNEL__
index 5212f5f..9605453 100644 (file)
@@ -12,7 +12,9 @@ enum die_val {
 };
 
 /* arch/sh/kernel/dumpstack.c */
-extern void printk_address(unsigned long address, int reliable);
-extern void dump_mem(const char *str, unsigned long bottom, unsigned long top);
+extern void printk_address(unsigned long address, int reliable,
+                          const char *loglvl);
+extern void dump_mem(const char *str, const char *loglvl,
+                    unsigned long bottom, unsigned long top);
 
 #endif /* __ASM_SH_KDEBUG_H */
index 0f80097..82d7447 100644 (file)
@@ -39,13 +39,6 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
 #define pud_page(pud)          NULL
-
-#define pmd_index(address)     (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
-{
-       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
-}
-
 #define pud_none(x)    (!pud_val(x))
 #define pud_present(x) (pud_val(x))
 #define pud_clear(xp)  do { set_pud(xp, __pud(0)); } while (0)
index 02d9364..27751e9 100644 (file)
@@ -168,6 +168,4 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
 #define HAVE_ARCH_UNMAPPED_AREA
 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
 
-#include <asm-generic/pgtable.h>
-
 #endif /* __ASM_SH_PGTABLE_H */
index 4acce5f..41be43e 100644 (file)
@@ -401,27 +401,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
        return pte;
 }
 
-#define pmd_page_vaddr(pmd)    ((unsigned long)pmd_val(pmd))
-#define pmd_page(pmd)          (virt_to_page(pmd_val(pmd)))
-
-/* to find an entry in a page-table-directory. */
-#define pgd_index(address)     (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-#define pgd_offset(mm, address)        ((mm)->pgd + pgd_index(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address)  pgd_offset(&init_mm, address)
-
-#define pud_index(address)     (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
-#define pmd_index(address)     (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-/* Find an entry in the third-level page table.. */
-#define pte_index(address)     ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define __pte_offset(address)  pte_index(address)
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       return (unsigned long)pmd_val(pmd);
+}
 
-#define pte_offset_kernel(dir, address) \
-       ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address)           pte_offset_kernel(dir, address)
-#define pte_unmap(pte)         do { } while (0)
+#define pmd_page(pmd)          (virt_to_page(pmd_val(pmd)))
 
 #ifdef CONFIG_X2TLB
 #define pte_ERROR(e) \
index 0e0ecc0..d444094 100644 (file)
@@ -171,7 +171,7 @@ static __inline__ void enable_fpu(void)
 #define thread_saved_pc(tsk)   (tsk->thread.pc)
 
 void show_trace(struct task_struct *tsk, unsigned long *sp,
-               struct pt_regs *regs);
+               struct pt_regs *regs, const char *loglvl);
 
 #ifdef CONFIG_DUMP_CODE
 void show_code(struct pt_regs *regs);
index 9f1c9c1..a13c045 100644 (file)
 #include <asm/unwinder.h>
 #include <asm/stacktrace.h>
 
-void dump_mem(const char *str, unsigned long bottom, unsigned long top)
+void dump_mem(const char *str, const char *loglvl,
+             unsigned long bottom, unsigned long top)
 {
        unsigned long p;
        int i;
 
-       printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
+       printk("%s%s(0x%08lx to 0x%08lx)\n", loglvl, str, bottom, top);
 
        for (p = bottom & ~31; p < top; ) {
-               printk("%04lx: ", p & 0xffff);
+               printk("%s%04lx: ", loglvl,  p & 0xffff);
 
                for (i = 0; i < 8; i++, p += 4) {
                        unsigned int val;
 
                        if (p < bottom || p >= top)
-                               printk("         ");
+                               printk("%s         ", loglvl);
                        else {
                                if (__get_user(val, (unsigned int __user *)p)) {
-                                       printk("\n");
+                                       printk("%s\n", loglvl);
                                        return;
                                }
-                               printk("%08x ", val);
+                               printk("%s%08x ", loglvl, val);
                        }
                }
-               printk("\n");
+               printk("%s\n", loglvl);
        }
 }
 
-void printk_address(unsigned long address, int reliable)
+void printk_address(unsigned long address, int reliable, const char *loglvl)
 {
-       printk(" [<%p>] %s%pS\n", (void *) address,
+       printk("%s [<%p>] %s%pS\n", loglvl, (void *) address,
                        reliable ? "" : "? ", (void *) address);
 }
 
@@ -117,8 +118,7 @@ static int print_trace_stack(void *data, char *name)
  */
 static void print_trace_address(void *data, unsigned long addr, int reliable)
 {
-       printk("%s", (char *)data);
-       printk_address(addr, reliable);
+       printk_address(addr, reliable, (char *)data);
 }
 
 static const struct stacktrace_ops print_trace_ops = {
@@ -127,16 +127,16 @@ static const struct stacktrace_ops print_trace_ops = {
 };
 
 void show_trace(struct task_struct *tsk, unsigned long *sp,
-               struct pt_regs *regs)
+               struct pt_regs *regs, const char *loglvl)
 {
        if (regs && user_mode(regs))
                return;
 
-       printk("\nCall trace:\n");
+       printk("%s\nCall trace:\n", loglvl);
 
-       unwind_stack(tsk, regs, sp, &print_trace_ops, "");
+       unwind_stack(tsk, regs, sp, &print_trace_ops, (void *)loglvl);
 
-       printk("\n");
+       printk("%s\n", loglvl);
 
        if (!tsk)
                tsk = current;
@@ -144,7 +144,7 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
        debug_show_held_locks(tsk);
 }
 
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
 {
        unsigned long stack;
 
@@ -156,7 +156,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
                sp = (unsigned long *)tsk->thread.sp;
 
        stack = (unsigned long)sp;
-       dump_mem("Stack: ", stack, THREAD_SIZE +
+       dump_mem("Stack: ", loglvl, stack, THREAD_SIZE +
                 (unsigned long)task_stack_page(tsk));
-       show_trace(tsk, sp, NULL);
+       show_trace(tsk, sp, NULL, loglvl);
 }
index 63d63a3..4a98980 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/ftrace.h>
 #include <linux/suspend.h>
 #include <linux/memblock.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/mmu_context.h>
 #include <asm/io.h>
index a094633..456cc8d 100644 (file)
@@ -59,7 +59,7 @@ void show_regs(struct pt_regs * regs)
        printk("MACH: %08lx MACL: %08lx GBR : %08lx PR  : %08lx\n",
               regs->mach, regs->macl, regs->gbr, regs->pr);
 
-       show_trace(NULL, (unsigned long *)regs->regs[15], regs);
+       show_trace(NULL, (unsigned long *)regs->regs[15], regs, KERN_DEFAULT);
        show_code(regs);
 }
 
index d5052c3..64bfb71 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/regset.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mmu_context.h>
 #include <asm/syscalls.h>
index 24473fa..a0fbb84 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/tracehook.h>
 #include <asm/ucontext.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/syscalls.h>
 #include <asm/fpu.h>
index f8afc01..a5a7b33 100644 (file)
@@ -69,10 +69,10 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
        if (addr + len < addr)
                return -EFAULT;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        vma = find_vma (current->mm, addr);
        if (vma == NULL || addr < vma->vm_start || addr + len > vma->vm_end) {
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                return -EFAULT;
        }
 
@@ -91,6 +91,6 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
        if (op & CACHEFLUSH_I)
                flush_icache_range(addr, addr+len);
 
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        return 0;
 }
index 2130381..a330254 100644 (file)
@@ -38,8 +38,8 @@ void die(const char *str, struct pt_regs *regs, long err)
                        task_pid_nr(current), task_stack_page(current) + 1);
 
        if (!user_mode(regs) || in_interrupt())
-               dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
-                        (unsigned long)task_stack_page(current));
+               dump_mem("Stack: ", KERN_DEFAULT, regs->regs[15],
+                       THREAD_SIZE + (unsigned long)task_stack_page(current));
 
        notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
 
index 9849448..1bd85a6 100644 (file)
@@ -61,7 +61,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        unsigned long addr;
        int ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
@@ -80,7 +80,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        current->mm->context.vdso = (void *)addr;
 
 up_fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index 8172a17..26f3bd4 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/threads.h>
 #include <asm/addrspace.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/cache.h>
 #include <asm/io.h>
index 45943bc..ddfa968 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/mutex.h>
 #include <linux/fs.h>
 #include <linux/highmem.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/cache_insns.h>
 #include <asm/cacheflush.h>
@@ -183,7 +182,7 @@ static void sh4_flush_cache_all(void *unused)
  * accessed with (hence cache set) is in accord with the physical
  * address (i.e. tag).  It's no different here.
  *
- * Caller takes mm->mmap_sem.
+ * Caller takes mm->mmap_lock.
  */
 static void sh4_flush_cache_mm(void *arg)
 {
@@ -208,9 +207,6 @@ static void sh4_flush_cache_page(void *args)
        struct page *page;
        unsigned long address, pfn, phys;
        int map_coherent = 0;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
        pmd_t *pmd;
        pte_t *pte;
        void *vaddr;
@@ -224,10 +220,7 @@ static void sh4_flush_cache_page(void *args)
        if (cpu_context(smp_processor_id(), vma->vm_mm) == NO_CONTEXT)
                return;
 
-       pgd = pgd_offset(vma->vm_mm, address);
-       p4d = p4d_offset(pgd, address);
-       pud = pud_offset(p4d, address);
-       pmd = pmd_offset(pud, address);
+       pmd = pmd_off(vma->vm_mm, address);
        pte = pte_offset_kernel(pmd, address);
 
        /* If the page isn't present, there is nothing to do here. */
index ed25eba..4897829 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/threads.h>
 #include <asm/addrspace.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/cache.h>
 #include <asm/io.h>
index 7260a1a..fbe1f2f 100644 (file)
@@ -214,7 +214,7 @@ show_fault_oops(struct pt_regs *regs, unsigned long address)
                                     : "paging request",
                 address);
        pr_alert("PC:");
-       printk_address(regs->pc, 1);
+       printk_address(regs->pc, 1, KERN_ALERT);
 
        show_pte(NULL, address);
 }
@@ -279,7 +279,7 @@ __bad_area(struct pt_regs *regs, unsigned long error_code,
         * Something tried to access memory that isn't in our memory map..
         * Fix it, but check if it's kernel or user first..
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        __bad_area_nosemaphore(regs, error_code, address, si_code);
 }
@@ -303,7 +303,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)
        struct task_struct *tsk = current;
        struct mm_struct *mm = tsk->mm;
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Kernel mode? Handle exceptions or die: */
        if (!user_mode(regs))
@@ -326,9 +326,9 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
                return 1;
        }
 
-       /* Release mmap_sem first if necessary */
+       /* Release mmap_lock first if necessary */
        if (!(fault & VM_FAULT_RETRY))
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
        if (!(fault & VM_FAULT_ERROR))
                return 0;
@@ -442,7 +442,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
        }
 
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma(mm, address);
        if (unlikely(!vma)) {
@@ -502,7 +502,7 @@ good_area:
                        flags |= FAULT_FLAG_TRIED;
 
                        /*
-                        * No need to up_read(&mm->mmap_sem) as we would
+                        * No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -510,5 +510,5 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 }
index 0e70391..73fd7cc 100644 (file)
@@ -14,9 +14,6 @@
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
 
-#define kmap_get_fixmap_pte(vaddr)                                     \
-       pte_offset_kernel(pmd_offset(pud_offset(p4d_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), (vaddr)), vaddr)
-
 static pte_t *kmap_coherent_pte;
 
 void __init kmap_coherent_init(void)
@@ -25,7 +22,7 @@ void __init kmap_coherent_init(void)
 
        /* cache the first coherent kmap pte */
        vaddr = __fix_to_virt(FIX_CMAP_BEGIN);
-       kmap_coherent_pte = kmap_get_fixmap_pte(vaddr);
+       kmap_coherent_pte = virt_to_kpte(vaddr);
 }
 
 void *kmap_coherent(struct page *page, unsigned long addr)
index dca946f..8b45044 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <linux/uaccess.h>
index b59bad8..b20aba6 100644 (file)
 #include <linux/io.h>
 #include <linux/spinlock.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 #include <linux/sizes.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 #include <asm/mmu_context.h>
index 946dbcb..e10ab9a 100644 (file)
@@ -9,8 +9,8 @@
 
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/idprom.h>
 #include <asm/oplib.h>
 #include <asm/auxio.h>
index ddb03c0..6c35f0d 100644 (file)
@@ -22,9 +22,9 @@
 #ifdef __KERNEL__
 
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 #include <asm/vaddrs.h>
 #include <asm/kmap_types.h>
-#include <asm/pgtable.h>
 #include <asm/pgtsrmmu.h>
 
 /* declarations for highmem.c */
index 09f0265..499aa2e 100644 (file)
@@ -18,7 +18,7 @@
 #include <asm/cacheflush.h>
 #include <asm/page.h>
 #else
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/psr.h>
 #endif
 
index 3ce96e8..8c38f5b 100644 (file)
@@ -7,8 +7,8 @@
 #define _SPARC_IO_UNIT_H
 
 #include <linux/spinlock.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 /* The io-unit handles all virtual to physical address translations
  * that occur between the SBUS and physical memory.  Access by
index b772384..9d353e6 100644 (file)
@@ -4,9 +4,9 @@
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/pgtable.h>
 
 #include <asm/pgtsrmmu.h>
-#include <asm/pgtable.h>
 #include <asm/vaddrs.h>
 #include <asm/page.h>
 
index 264e76c..a8dafc5 100644 (file)
@@ -67,7 +67,7 @@ void pte_free(struct mm_struct *mm, pgtable_t ptepage);
 
 #define pmd_populate_kernel(MM, PMD, PTE)      pmd_set(MM, PMD, PTE)
 #define pmd_populate(MM, PMD, PTE)             pmd_set(MM, PMD, PTE)
-#define pmd_pgtable(PMD)                       ((pte_t *)__pmd_page(PMD))
+#define pmd_pgtable(PMD)                       ((pte_t *)pmd_page_vaddr(PMD))
 
 void pgtable_free(void *table, bool is_page);
 
index c5625b2..632cdb9 100644 (file)
@@ -146,6 +146,12 @@ static inline unsigned long __pmd_page(pmd_t pmd)
        return (unsigned long)__nocache_va(v << 4);
 }
 
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
+{
+       unsigned long v = pmd_val(pmd) & SRMMU_PTD_PMASK;
+       return (unsigned long)__nocache_va(v << 4);
+}
+
 static inline unsigned long pud_page_vaddr(pud_t pud)
 {
        if (srmmu_device_memory(pud_val(pud))) {
@@ -315,30 +321,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
                pgprot_val(newprot));
 }
 
-#define pgd_index(address) ((address) >> PGDIR_SHIFT)
-
-/* to find an entry in a page-table-directory */
-#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/* Find an entry in the second-level page table.. */
-static inline pmd_t *pmd_offset(pud_t * dir, unsigned long address)
-{
-       return (pmd_t *) pud_page_vaddr(*dir) +
-               ((address >> PMD_SHIFT) & (PTRS_PER_PMD - 1));
-}
-
-/* Find an entry in the third-level page table.. */
-pte_t *pte_offset_kernel(pmd_t * dir, unsigned long address);
-
-/*
- * This shortcut works on sun4m (and sun4d) because the nocache area is static.
- */
-#define pte_offset_map(d, a)           pte_offset_kernel(d,a)
-#define pte_unmap(pte)         do{}while(0)
-
 struct seq_file;
 void mmu_info(struct seq_file *m);
 
@@ -427,7 +409,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
 
        return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot);
 }
-#define io_remap_pfn_range io_remap_pfn_range 
+#define io_remap_pfn_range io_remap_pfn_range
 
 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
 #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
@@ -440,8 +422,6 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
        __changed;                                                        \
 })
 
-#include <asm-generic/pgtable.h>
-
 #endif /* !(__ASSEMBLY__) */
 
 #define VMALLOC_START           _AC(0xfe600000,UL)
index da527b2..7ef6aff 100644 (file)
@@ -835,7 +835,7 @@ static inline void pmd_set(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
 
 #define pud_set(pudp, pmdp)    \
        (pud_val(*(pudp)) = (__pa((unsigned long) (pmdp))))
-static inline unsigned long __pmd_page(pmd_t pmd)
+static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 {
        pte_t pte = __pte(pmd_val(pmd));
        unsigned long pfn;
@@ -855,7 +855,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
        return ((unsigned long) __va(pfn << PAGE_SHIFT));
 }
 
-#define pmd_page(pmd)                  virt_to_page((void *)__pmd_page(pmd))
+#define pmd_page(pmd)                  virt_to_page((void *)pmd_page_vaddr(pmd))
 #define pud_page(pud)                  virt_to_page((void *)pud_page_vaddr(pud))
 #define pmd_clear(pmdp)                        (pmd_val(*(pmdp)) = 0UL)
 #define pud_present(pud)               (pud_val(pud) != 0U)
@@ -889,31 +889,6 @@ static inline unsigned long pud_pfn(pud_t pud)
 #define p4d_set(p4dp, pudp)    \
        (p4d_val(*(p4dp)) = (__pa((unsigned long) (pudp))))
 
-/* to find an entry in a page-table-directory. */
-#define pgd_index(address)     (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-#define pgd_offset(mm, address)        ((mm)->pgd + pgd_index(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/* Find an entry in the third-level page table.. */
-#define pud_index(address)     (((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
-#define pud_offset(p4dp, address)      \
-       ((pud_t *) p4d_page_vaddr(*(p4dp)) + pud_index(address))
-
-/* Find an entry in the second-level page table.. */
-#define pmd_offset(pudp, address)      \
-       ((pmd_t *) pud_page_vaddr(*(pudp)) + \
-        (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)))
-
-/* Find an entry in the third-level page table.. */
-#define pte_index(address)                     \
-        ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address)        \
-       ((pte_t *) __pmd_page(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address)   pte_offset_kernel((dir), (address))
-#define pte_unmap(pte)                 do { } while (0)
-
 /* We cannot include <linux/mm_types.h> at this point yet: */
 extern struct mm_struct init_mm;
 
@@ -1078,7 +1053,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
 
        return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot);
 }
-#define io_remap_pfn_range io_remap_pfn_range 
+#define io_remap_pfn_range io_remap_pfn_range
 
 static inline unsigned long __untagged_addr(unsigned long start)
 {
@@ -1122,7 +1097,6 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
 #define pte_access_permitted pte_access_permitted
 
 #include <asm/tlbflush.h>
-#include <asm-generic/pgtable.h>
 
 /* We provide our own get_unmapped_area to cope with VA holes and
  * SHM area cache aliasing for userland.
index 4401dee..79cd6cc 100644 (file)
@@ -11,9 +11,9 @@
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/threads.h>
+#include <linux/pgtable.h>
 
 #include <asm/spitfire.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <asm/setup.h>
 #include <asm/page.h>
index 4d36969..f636acf 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/linkage.h>
 #include <linux/errno.h>
+#include <linux/pgtable.h>
 
 #include <asm/head.h>
 #include <asm/asi.h>
@@ -20,7 +21,6 @@
 #include <asm/psr.h>
 #include <asm/vaddrs.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/winmacro.h>
 #include <asm/signal.h>
 #include <asm/obio.h>
index 540bfc9..c5ff247 100644 (file)
 #include <linux/threads.h>
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/thread_info.h>
 #include <asm/asi.h>
 #include <asm/pstate.h>
 #include <asm/ptrace.h>
 #include <asm/spitfire.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/errno.h>
 #include <asm/signal.h>
 #include <asm/processor.h>
index 1cf91c0..6bfaf73 100644 (file)
@@ -7,10 +7,10 @@
  * Copyright (C) 1996,98,99 Jakub Jelinek  (jj@sunsite.mff.cuni.cz)
  */
 
+#include <linux/pgtable.h>
 #include <asm/head.h>
 #include <asm/asi.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/tsb.h>
 
        .text
index da6f148..41829c0 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <asm/cpudata.h>
 #include <asm/asi.h>
index a41ad56..5d45b6d 100644 (file)
@@ -21,9 +21,9 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pgtable.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
 #include <asm/apb.h>
index 26cca65..13cb563 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/uaccess.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/delay.h>
 #include <asm/processor.h>
 #include <asm/psr.h>
@@ -145,10 +144,10 @@ void show_regs(struct pt_regs *r)
 }
 
 /*
- * The show_stack is an external API which we do not use ourselves.
+ * The show_stack() is external API which we do not use ourselves.
  * The oops is printed in die_if_kernel.
  */
-void show_stack(struct task_struct *tsk, unsigned long *_ksp)
+void show_stack(struct task_struct *tsk, unsigned long *_ksp, const char *loglvl)
 {
        unsigned long pc, fp;
        unsigned long task_base;
@@ -170,11 +169,11 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
                        break;
                rw = (struct reg_window32 *) fp;
                pc = rw->ins[7];
-               printk("[%08lx : ", pc);
-               printk("%pS ] ", (void *) pc);
+               printk("%s[%08lx : ", loglvl, pc);
+               printk("%s%pS ] ", loglvl, (void *) pc);
                fp = rw->ins[6];
        } while (++count < 16);
-       printk("\n");
+       printk("%s\n", loglvl);
 }
 
 /*
index 423011e..54945ea 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/uaccess.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/pstate.h>
 #include <asm/elf.h>
@@ -195,7 +194,7 @@ void show_regs(struct pt_regs *regs)
               regs->u_regs[15]);
        printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
        show_regwindow(regs);
-       show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
+       show_stack(current, (unsigned long *)regs->u_regs[UREG_FP], KERN_DEFAULT);
 }
 
 union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
index 646dd58..47eb315 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/elf.h>
 #include <linux/tracehook.h>
 
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/cacheflush.h>
 
index 3f5930b..7122efb 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/context_tracking.h>
 
 #include <asm/asi.h>
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/psrcompat.h>
 #include <asm/visasm.h>
index 5d1bcfc..6d07b85 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/processor.h>
 #include <asm/oplib.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/traps.h>
 #include <asm/vaddrs.h>
 #include <asm/mbus.h>
index 75e3992..f765fda 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/processor.h>
 #include <asm/oplib.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/idprom.h>
 #include <asm/head.h>
 #include <asm/starfire.h>
index 2a734ec..e2c6f0a 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/psrcompat.h>
 #include <asm/fpumacro.h>
 #include <asm/visasm.h>
index 42c3de3..3b005b6 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>    /* flush_sig_insns */
 #include <asm/switch_to.h>
 
index 69ae814..6937339 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/fpumacro.h>
 #include <asm/uctx.h>
 #include <asm/siginfo.h>
index e078680..76ce290 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
index 80f20b3..0085e28 100644 (file)
@@ -43,7 +43,6 @@
 #include <asm/irq.h>
 #include <asm/irq_regs.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <linux/uaccess.h>
 #include <asm/starfire.h>
index c01767a..91b61f0 100644 (file)
 
 #include <linux/slab.h>
 #include <linux/sched/debug.h>
+#include <linux/pgtable.h>
 
 #include <asm/timer.h>
 #include <asm/traps.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <asm/cacheflush.h>
index fe59122..51bf1eb 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 
+#include <linux/pgtable.h>
 #include <asm/head.h>
 #include <asm/asi.h>
 #include <asm/lsu.h>
@@ -13,7 +14,6 @@
 #include <asm/dcu.h>
 #include <asm/pstate.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/spitfire.h>
 #include <asm/processor.h>
 #include <asm/thread_info.h>
index 4ceecad..247a0d9 100644 (file)
 #include <linux/smp.h>
 #include <linux/kdebug.h>
 #include <linux/export.h>
+#include <linux/pgtable.h>
 
 #include <asm/delay.h>
 #include <asm/ptrace.h>
 #include <asm/oplib.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/unistd.h>
 #include <asm/traps.h>
 
index 27778b6..d92e5ea 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/smp.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/kallsyms.h>
 #include <linux/kdebug.h>
 #include <linux/ftrace.h>
 #include <linux/reboot.h>
@@ -29,7 +30,6 @@
 #include <asm/ptrace.h>
 #include <asm/oplib.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/unistd.h>
 #include <linux/uaccess.h>
 #include <asm/fpumacro.h>
@@ -2452,7 +2452,7 @@ static void user_instruction_dump(unsigned int __user *pc)
        printk("\n");
 }
 
-void show_stack(struct task_struct *tsk, unsigned long *_ksp)
+void show_stack(struct task_struct *tsk, unsigned long *_ksp, const char *loglvl)
 {
        unsigned long fp, ksp;
        struct thread_info *tp;
@@ -2476,7 +2476,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
 
        fp = ksp + STACK_BIAS;
 
-       printk("Call Trace:\n");
+       printk("%sCall Trace:\n", loglvl);
        do {
                struct sparc_stackf *sf;
                struct pt_regs *regs;
@@ -2497,14 +2497,14 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
                        fp = (unsigned long)sf->fp + STACK_BIAS;
                }
 
-               printk(" [%016lx] %pS\n", pc, (void *) pc);
+               print_ip_sym(loglvl, pc);
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
                if ((pc + 8UL) == (unsigned long) &return_to_handler) {
                        struct ftrace_ret_stack *ret_stack;
                        ret_stack = ftrace_graph_get_ret_stack(tsk, graph);
                        if (ret_stack) {
                                pc = ret_stack->ret;
-                               printk(" [%016lx] %pS\n", pc, (void *) pc);
+                               print_ip_sym(loglvl, pc);
                                graph++;
                        }
                }
index 8a6c783..302d345 100644 (file)
@@ -5,10 +5,10 @@
  * Copyright (C) 1997 Jakub Jelinek (jakub@redhat.com)
  */
 
+#include <linux/pgtable.h>
 #include <asm/visasm.h>
 #include <asm/thread_info.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/spitfire.h>
 #include <asm/head.h>
 #include <asm/export.h>
index c088e87..5ebcfd4 100644 (file)
@@ -8,7 +8,7 @@
 #include <asm/visasm.h>
 #include <asm/thread_info.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/spitfire.h>
 #include <asm/head.h>
 #include <asm/export.h>
index f6e0e60..cfef656 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/uaccess.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/openprom.h>
 #include <asm/oplib.h>
 #include <asm/setup.h>
@@ -196,7 +195,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
 
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        if (!from_user && address >= PAGE_OFFSET)
                goto bad_area;
@@ -263,7 +262,7 @@ good_area:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                       /* No need to up_read(&mm->mmap_sem) as we would
+                       /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -272,7 +271,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 
        /*
@@ -280,7 +279,7 @@ good_area:
         * Fix it, but check if it's kernel or user first..
         */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 bad_area_nosemaphore:
        /* User mode accesses just cause a SIGSEGV */
@@ -329,7 +328,7 @@ no_context:
  * us unable to handle the page fault gracefully.
  */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (from_user) {
                pagefault_out_of_memory();
                return;
@@ -337,7 +336,7 @@ out_of_memory:
        goto no_context;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, text_fault);
        if (!from_user)
                goto no_context;
@@ -391,7 +390,7 @@ static void force_user_fault(unsigned long address, int write)
 
        code = SEGV_MAPERR;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto bad_area;
@@ -416,15 +415,15 @@ good_area:
        case VM_FAULT_OOM:
                goto do_sigbus;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return;
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        __do_fault_siginfo(code, SIGSEGV, tsk->thread.kregs, address);
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address);
 }
 
index c0c0dd4..a380661 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/uaccess.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/openprom.h>
 #include <asm/oplib.h>
 #include <asm/asi.h>
@@ -71,7 +70,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
 }
 
 /*
- * We now make sure that mmap_sem is held in all paths that call 
+ * We now make sure that mmap_lock is held in all paths that call
  * this. Additionally, to prevent kswapd from ripping ptes from
  * under us, raise interrupts around the time that we look at the
  * pte, kswapd will have to wait to get his smp ipi response from
@@ -319,7 +318,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
 
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
 
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                if ((regs->tstate & TSTATE_PRIV) &&
                    !search_exception_tables(regs->tpc)) {
                        insn = get_fault_insn(regs, insn);
@@ -327,7 +326,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
                }
 
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        }
 
        if (fault_code & FAULT_CODE_BAD_RA)
@@ -451,7 +450,7 @@ good_area:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                       /* No need to up_read(&mm->mmap_sem) as we would
+                       /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -459,7 +458,7 @@ good_area:
                        goto retry;
                }
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        mm_rss = get_mm_rss(mm);
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE)
@@ -490,7 +489,7 @@ exit_exception:
         */
 bad_area:
        insn = get_fault_insn(regs, insn);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 handle_kernel_fault:
        do_kernel_fault(regs, si_code, fault_code, insn, address);
@@ -502,7 +501,7 @@ handle_kernel_fault:
  */
 out_of_memory:
        insn = get_fault_insn(regs, insn);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!(regs->tstate & TSTATE_PRIV)) {
                pagefault_out_of_memory();
                goto exit_exception;
@@ -515,7 +514,7 @@ intr_or_no_mm:
 
 do_sigbus:
        insn = get_fault_insn(regs, insn);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Send a sigbus, regardless of whether we were in kernel
index 6ff6e2a..d1fc9a7 100644 (file)
@@ -36,18 +36,10 @@ static pte_t *kmap_pte;
 
 void __init kmap_init(void)
 {
-       unsigned long address;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *dir;
-
-       address = __fix_to_virt(FIX_KMAP_BEGIN);
-       p4d = p4d_offset(pgd_offset_k(address), address);
-       pud = pud_offset(p4d, address);
-       dir = pmd_offset(pud, address);
+       unsigned long address = __fix_to_virt(FIX_KMAP_BEGIN);
 
         /* cache the first kmap pte */
-        kmap_pte = pte_offset_kernel(dir, address);
+        kmap_pte = virt_to_kpte(address);
 }
 
 void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
index 7b9fa86..ec423b5 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
index 3cb3dff..eb2946b 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <asm/sections.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/vaddrs.h>
 #include <asm/setup.h>
 #include <asm/tlb.h>
index 2ef6826..02e6e5e 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/head.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <asm/iommu.h>
 #include <asm/io.h>
@@ -504,11 +503,7 @@ void __kprobes flush_icache_range(unsigned long start, unsigned long end)
                        if (kaddr >= PAGE_OFFSET)
                                paddr = kaddr & mask;
                        else {
-                               pgd_t *pgdp = pgd_offset_k(kaddr);
-                               p4d_t *p4dp = p4d_offset(pgdp, kaddr);
-                               pud_t *pudp = pud_offset(p4dp, kaddr);
-                               pmd_t *pmdp = pmd_offset(pudp, kaddr);
-                               pte_t *ptep = pte_offset_kernel(pmdp, kaddr);
+                               pte_t *ptep = virt_to_kpte(kaddr);
 
                                paddr = pte_val(*ptep) & mask;
                        }
index 08238d9..bfcc04b 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/of_device.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/io-unit.h>
 #include <asm/mxcc.h>
@@ -241,21 +240,15 @@ static void *iounit_alloc(struct device *dev, size_t len,
        while(addr < end) {
                page = va;
                {
-                       pgd_t *pgdp;
-                       p4d_t *p4dp;
-                       pud_t *pudp;
                        pmd_t *pmdp;
                        pte_t *ptep;
                        long i;
 
-                       pgdp = pgd_offset(&init_mm, addr);
-                       p4dp = p4d_offset(pgdp, addr);
-                       pudp = pud_offset(p4dp, addr);
-                       pmdp = pmd_offset(pudp, addr);
+                       pmdp = pmd_off_k(addr);
                        ptep = pte_offset_map(pmdp, addr);
 
                        set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot));
-                       
+
                        i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
 
                        iopte = iounit->page_table + i;
index f1e08e3..35b002e 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/of_device.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/mxcc.h>
 #include <asm/mbus.h>
@@ -349,9 +348,6 @@ static void *sbus_iommu_alloc(struct device *dev, size_t len,
        while(addr < end) {
                page = va;
                {
-                       pgd_t *pgdp;
-                       p4d_t *p4dp;
-                       pud_t *pudp;
                        pmd_t *pmdp;
                        pte_t *ptep;
 
@@ -362,10 +358,7 @@ static void *sbus_iommu_alloc(struct device *dev, size_t len,
                        else
                                __flush_page_to_ram(page);
 
-                       pgdp = pgd_offset(&init_mm, addr);
-                       p4dp = p4d_offset(pgdp, addr);
-                       pudp = pud_offset(p4dp, addr);
-                       pmdp = pmd_offset(pudp, addr);
+                       pmdp = pmd_off_k(addr);
                        ptep = pte_offset_map(pmdp, addr);
 
                        set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot));
index 3d72d2d..a32a16c 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/swap.h>
 #include <linux/preempt.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
index f5edc28..0dce4b7 100644 (file)
@@ -8,9 +8,9 @@
 #include <linux/preempt.h>
 #include <linux/slab.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <asm/setup.h>
 #include <asm/tsb.h>
index d220b68..70e658d 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (C) 1997, 2000, 2008 David S. Miller (davem@davemloft.net)
  */
 
+#include <linux/pgtable.h>
 #include <asm/asi.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/spitfire.h>
 #include <asm/mmu_context.h>
index 9961b0f..cc19e09 100644 (file)
@@ -366,7 +366,7 @@ static int map_vdso(const struct vdso_image *image,
        unsigned long text_start, addr = 0;
        int ret = 0;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        /*
         * First, get an unmapped region: then randomize it, and make sure that
@@ -422,7 +422,7 @@ up_fail:
        if (ret)
                current->mm->context.vdso = NULL;
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
index 30575bd..a2e680f 100644 (file)
@@ -648,7 +648,7 @@ static void stack_proc(void *arg)
 {
        struct task_struct *task = arg;
 
-       show_stack(task, NULL);
+       show_stack(task, NULL, KERN_INFO);
 }
 
 /*
index b4deb1b..17ddd4e 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/sched.h>
 #include <linux/mm_types.h>
+#include <linux/mmap_lock.h>
 
 #include <asm/mmu.h>
 
@@ -47,9 +48,9 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
         * when the new ->mm is used for the first time.
         */
        __switch_mm(&new->context.id);
-       down_write_nested(&new->mmap_sem, 1);
+       mmap_write_lock_nested(new, SINGLE_DEPTH_NESTING);
        uml_setup_stubs(new);
-       up_write(&new->mmap_sem);
+       mmap_write_unlock(new);
 }
 
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
index 8a3b689..36f4529 100644 (file)
@@ -89,10 +89,6 @@ static inline void pud_clear (pud_t *pud)
 #define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
 #define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
 
-/* Find an entry in the second-level page table.. */
-#define pmd_offset(pud, address) ((pmd_t *) pud_page_vaddr(*(pud)) + \
-                       pmd_index(address))
-
 static inline unsigned long pte_pfn(pte_t pte)
 {
        return phys_to_pfn(pte_val(pte));
index b5ddf5d..def3761 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/* 
+/*
  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright 2003 PathScale, Inc.
  * Derived from include/asm-i386/pgtable.h
@@ -131,7 +131,7 @@ static inline int pte_none(pte_t pte)
  * Undefined behaviour if not..
  */
 static inline int pte_read(pte_t pte)
-{ 
+{
        return((pte_get_bits(pte, _PAGE_USER)) &&
               !(pte_get_bits(pte, _PAGE_PROTNONE)));
 }
@@ -163,7 +163,7 @@ static inline int pte_newpage(pte_t pte)
 }
 
 static inline int pte_newprot(pte_t pte)
-{ 
+{
        return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT)));
 }
 
@@ -185,31 +185,31 @@ static inline pte_t pte_mkclean(pte_t pte)
        return(pte);
 }
 
-static inline pte_t pte_mkold(pte_t pte)       
-{ 
+static inline pte_t pte_mkold(pte_t pte)
+{
        pte_clear_bits(pte, _PAGE_ACCESSED);
        return(pte);
 }
 
 static inline pte_t pte_wrprotect(pte_t pte)
-{ 
+{
        if (likely(pte_get_bits(pte, _PAGE_RW)))
                pte_clear_bits(pte, _PAGE_RW);
        else
                return pte;
-       return(pte_mknewprot(pte)); 
+       return(pte_mknewprot(pte));
 }
 
 static inline pte_t pte_mkread(pte_t pte)
-{ 
+{
        if (unlikely(pte_get_bits(pte, _PAGE_USER)))
                return pte;
        pte_set_bits(pte, _PAGE_USER);
-       return(pte_mknewprot(pte)); 
+       return(pte_mknewprot(pte));
 }
 
 static inline pte_t pte_mkdirty(pte_t pte)
-{ 
+{
        pte_set_bits(pte, _PAGE_DIRTY);
        return(pte);
 }
@@ -220,20 +220,20 @@ static inline pte_t pte_mkyoung(pte_t pte)
        return(pte);
 }
 
-static inline pte_t pte_mkwrite(pte_t pte)     
+static inline pte_t pte_mkwrite(pte_t pte)
 {
        if (unlikely(pte_get_bits(pte,  _PAGE_RW)))
                return pte;
        pte_set_bits(pte, _PAGE_RW);
-       return(pte_mknewprot(pte)); 
+       return(pte_mknewprot(pte));
 }
 
-static inline pte_t pte_mkuptodate(pte_t pte)  
+static inline pte_t pte_mkuptodate(pte_t pte)
 {
        pte_clear_bits(pte, _PAGE_NEWPAGE);
        if(pte_present(pte))
                pte_clear_bits(pte, _PAGE_NEWPROT);
-       return(pte); 
+       return(pte);
 }
 
 static inline pte_t pte_mknewpage(pte_t pte)
@@ -288,53 +288,16 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b)
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot);
-       return pte; 
+       return pte;
 }
 
 /*
- * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
- *
- * this macro returns the index of the entry in the pgd page which would
- * control the given virtual address
- */
-#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-
-/*
- * pgd_offset() returns a (pgd_t *)
- * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
- */
-#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
-
-/*
- * a shortcut which implies the use of the kernel's pgd, instead
- * of a process's
- */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
-
-/*
  * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD]
  *
  * this macro returns the index of the entry in the pmd page which would
  * control the given virtual address
  */
 #define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
-#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
-#define pmd_page_vaddr(pmd) \
-       ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
-
-/*
- * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
- *
- * this macro returns the index of the entry in the pte page which would
- * control the given virtual address
- */
-#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir, address) \
-       ((pte_t *) pmd_page_vaddr(*(dir)) +  pte_index(address))
-#define pte_offset_map(dir, address) \
-       ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_unmap(pte) do { } while (0)
 
 struct mm_struct;
 extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
@@ -353,8 +316,6 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
 
 #define kern_addr_valid(addr) (1)
 
-#include <asm-generic/pgtable.h>
-
 /* Clear a kernel PTE and flush it from the TLB */
 #define kpte_clear_flush(ptep, vaddr)          \
 do {                                           \
index 67b2e0f..e929c09 100644 (file)
@@ -7,15 +7,13 @@
 #include <linux/kernel.h>
 #include <os.h>
 
-long probe_kernel_read(void *dst, const void *src, size_t size)
+bool probe_kernel_read_allowed(const void *src, size_t size)
 {
        void *psrc = (void *)rounddown((unsigned long)src, PAGE_SIZE);
 
        if ((unsigned long)src < PAGE_SIZE || size <= 0)
-               return -EFAULT;
-
+               return false;
        if (os_mincore(psrc, size + src - psrc) <= 0)
-               return -EFAULT;
-
-       return __probe_kernel_read(dst, src, size);
+               return false;
+       return true;
 }
index 401b22f..c2ff76c 100644 (file)
@@ -125,10 +125,6 @@ static void __init fixaddr_user_init( void)
 {
 #ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
        long size = FIXADDR_USER_END - FIXADDR_USER_START;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmd;
        pte_t *pte;
        phys_t p;
        unsigned long v, vaddr = FIXADDR_USER_START;
@@ -146,11 +142,7 @@ static void __init fixaddr_user_init( void)
        p = __pa(v);
        for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
                      p += PAGE_SIZE) {
-               pgd = swapper_pg_dir + pgd_index(vaddr);
-               p4d = p4d_offset(pgd, vaddr);
-               pud = pud_offset(p4d, vaddr);
-               pmd = pmd_offset(pud, vaddr);
-               pte = pte_offset_kernel(pmd, vaddr);
+               pte = virt_to_kpte(vaddr);
                pte_set_val(*pte, p, PAGE_READONLY);
        }
 #endif
index cbe33af..e3a2cf9 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/threads.h>
 #include <linux/tracehook.h>
 #include <asm/current.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 #include <linux/uaccess.h>
 #include <as-layout.h>
index 3f0d9a5..d996116 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/slab.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <as-layout.h>
 #include <os.h>
@@ -115,7 +114,7 @@ void uml_setup_stubs(struct mm_struct *mm)
        mm->context.stub_pages[0] = virt_to_page(__syscall_stub_start);
        mm->context.stub_pages[1] = virt_to_page(mm->context.id.stack);
 
-       /* dup_mmap already holds mmap_sem */
+       /* dup_mmap already holds mmap_lock */
        err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
                                      VM_READ | VM_MAYREAD | VM_EXEC |
                                      VM_MAYEXEC | VM_DONTCOPY | VM_PFNMAP,
index d617f8d..2dec915 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/sched.h>
 #include <asm/current.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <kern_util.h>
 #include <os.h>
 
index c71b5ef..acbc879 100644 (file)
@@ -17,7 +17,9 @@
 
 static void _print_addr(void *data, unsigned long address, int reliable)
 {
-       pr_info(" [<%08lx>] %s%pS\n", address, reliable ? "" : "? ",
+       const char *loglvl = data;
+
+       printk("%s [<%08lx>] %s%pS\n", loglvl, address, reliable ? "" : "? ",
                (void *)address);
 }
 
@@ -25,9 +27,9 @@ static const struct stacktrace_ops stackops = {
        .address = _print_addr
 };
 
-void show_stack(struct task_struct *task, unsigned long *stack)
+void show_stack(struct task_struct *task, unsigned long *stack,
+                      const char *loglvl)
 {
-       unsigned long *sp = stack;
        struct pt_regs *segv_regs = current->thread.segv_regs;
        int i;
 
@@ -38,20 +40,19 @@ void show_stack(struct task_struct *task, unsigned long *stack)
        }
 
        if (!stack)
-               sp = get_stack_pointer(task, segv_regs);
+               stack = get_stack_pointer(task, segv_regs);
 
-       pr_info("Stack:\n");
-       stack = sp;
+       printk("%sStack:\n", loglvl);
        for (i = 0; i < 3 * STACKSLOTS_PER_LINE; i++) {
                if (kstack_end(stack))
                        break;
                if (i && ((i % STACKSLOTS_PER_LINE) == 0))
-                       pr_cont("\n");
+                       printk("%s\n", loglvl);
                pr_cont(" %08lx", *stack++);
        }
-       pr_cont("\n");
+       printk("%s\n", loglvl);
 
-       pr_info("Call Trace:\n");
-       dump_trace(current, &stackops, NULL);
-       pr_info("\n");
+       printk("%sCall Trace:\n", loglvl);
+       dump_trace(current, &stackops, (void *)loglvl);
+       printk("%s\n", loglvl);
 }
index 80a358c..6177679 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/module.h>
 #include <linux/sched/signal.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <as-layout.h>
 #include <mem_user.h>
@@ -349,8 +348,8 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
        if (ret) {
                printk(KERN_ERR "fix_range_common: failed, killing current "
                       "process: %d\n", task_tgid_vnr(current));
-               /* We are under mmap_sem, release it such that current can terminate */
-               up_write(&current->mm->mmap_sem);
+               /* We are under mmap_lock, release it such that current can terminate */
+               mmap_write_unlock(current->mm);
                force_sig(SIGKILL);
                do_signal(&current->thread.regs);
        }
index 8f18cf5..2b3afa3 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/uaccess.h>
 #include <linux/sched/debug.h>
 #include <asm/current.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <arch.h>
 #include <as-layout.h>
@@ -27,9 +26,6 @@ int handle_page_fault(unsigned long address, unsigned long ip,
 {
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
        pmd_t *pmd;
        pte_t *pte;
        int err = -EFAULT;
@@ -47,7 +43,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        if (is_user)
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
        if (!vma)
                goto out;
@@ -103,10 +99,7 @@ good_area:
                        }
                }
 
-               pgd = pgd_offset(mm, address);
-               p4d = p4d_offset(pgd, address);
-               pud = pud_offset(p4d, address);
-               pmd = pmd_offset(pud, address);
+               pmd = pmd_off(mm, address);
                pte = pte_offset_kernel(pmd, address);
        } while (!pte_present(*pte));
        err = 0;
@@ -123,7 +116,7 @@ good_area:
 #endif
        flush_tlb_page(vma, address);
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 out_nosemaphore:
        return err;
 
@@ -132,7 +125,7 @@ out_of_memory:
         * We ran out of memory, call the OOM killer, and return the userspace
         * (which will retry the fault, or kill us if we got oom-killed).
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!is_user)
                goto out_nosemaphore;
        pagefault_out_of_memory();
index 375ab72..00141e7 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/sched/task.h>
 #include <linux/kmsg_dump.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
index 826f49e..97f564c 100644 (file)
@@ -153,12 +153,6 @@ extern struct page *empty_zero_page;
 #define pte_none(pte)                  (!pte_val(pte))
 #define pte_clear(mm, addr, ptep)      set_pte(ptep, __pte(0))
 #define pte_page(pte)                  (pfn_to_page(pte_pfn(pte)))
-#define pte_offset_kernel(dir, addr)   (pmd_page_vaddr(*(dir)) \
-                                               + __pte_index(addr))
-
-#define pte_offset_map(dir, addr)      (pmd_page_vaddr(*(dir)) \
-                                               + __pte_index(addr))
-#define pte_unmap(pte)                 do { } while (0)
 
 #define set_pte(ptep, pte)     cpu_set_pte(ptep, pte)
 
@@ -221,17 +215,6 @@ PTE_BIT_FUNC(mkyoung,   |= PTE_YOUNG);
  */
 #define mk_pte(page, prot)     pfn_pte(page_to_pfn(page), prot)
 
-/* to find an entry in a page-table-directory */
-#define pgd_index(addr)                ((addr) >> PGDIR_SHIFT)
-
-#define pgd_offset(mm, addr)   ((mm)->pgd+pgd_index(addr))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)     pgd_offset(&init_mm, addr)
-
-/* Find an entry in the third-level page table.. */
-#define __pte_index(addr)      (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        const unsigned long mask = PTE_EXEC | PTE_WRITE | PTE_READ;
@@ -279,8 +262,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 /* FIXME: this is not correct */
 #define kern_addr_valid(addr)  (1)
 
-#include <asm-generic/pgtable.h>
-
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __UNICORE_PGTABLE_H__ */
index ccad051..4cdf3c8 100644 (file)
@@ -11,9 +11,9 @@
 #include <linux/gfp.h>
 #include <linux/suspend.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/sections.h>
 #include <asm/suspend.h>
index 7e7499c..a589bc1 100644 (file)
@@ -11,9 +11,9 @@
 #include <linux/sys.h>
 #include <linux/errno.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <generated/asm-offsets.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/assembler.h>
 
 @ restore_image(pgd_t *resume_pg_dir, struct pbe *restore_pblist)
index 717ee1b..67c89ef 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/string.h>
 #include <linux/gfp.h>
 
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 
 void *module_alloc(unsigned long size)
index e40d360..9673523 100644 (file)
@@ -29,7 +29,7 @@ extern void kernel_thread_helper(void);
 extern void __init early_signal_init(void);
 
 extern asmlinkage void __backtrace(void);
-extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
+extern asmlinkage void c_backtrace(unsigned long fp, const char *loglvl);
 
 extern void __show_regs(struct pt_regs *);
 
index e24f672..a3ac01d 100644 (file)
@@ -135,44 +135,42 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
        set_fs(fs);
 }
 
-static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
+static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
+                          const char *loglvl)
 {
-       unsigned int fp, mode;
+       unsigned int fp;
        int ok = 1;
 
-       printk(KERN_DEFAULT "Backtrace: ");
+       printk("%sBacktrace: ", loglvl);
 
        if (!tsk)
                tsk = current;
 
-       if (regs) {
+       if (regs)
                fp = regs->UCreg_fp;
-               mode = processor_mode(regs);
-       } else if (tsk != current) {
+       else if (tsk != current)
                fp = thread_saved_fp(tsk);
-               mode = 0x10;
-       } else {
+       else
                asm("mov %0, fp" : "=r" (fp) : : "cc");
-               mode = 0x10;
-       }
 
        if (!fp) {
-               printk("no frame pointer");
+               printk("%sno frame pointer", loglvl);
                ok = 0;
        } else if (verify_stack(fp)) {
-               printk("invalid frame pointer 0x%08x", fp);
+               printk("%sinvalid frame pointer 0x%08x", loglvl, fp);
                ok = 0;
        } else if (fp < (unsigned long)end_of_stack(tsk))
-               printk("frame pointer underflow");
-       printk("\n");
+               printk("%sframe pointer underflow", loglvl);
+       printk("%s\n", loglvl);
 
        if (ok)
-               c_backtrace(fp, mode);
+               c_backtrace(fp, loglvl);
 }
 
-void show_stack(struct task_struct *tsk, unsigned long *sp)
+void show_stack(struct task_struct *tsk, unsigned long *sp,
+                      const char *loglvl)
 {
-       dump_backtrace(NULL, tsk);
+       dump_backtrace(NULL, tsk, loglvl);
        barrier();
 }
 
@@ -200,7 +198,7 @@ static int __die(const char *str, int err, struct thread_info *thread,
        if (!user_mode(regs) || in_interrupt()) {
                dump_mem(KERN_EMERG, "Stack: ", regs->UCreg_sp,
                         THREAD_SIZE + (unsigned long)task_stack_page(tsk));
-               dump_backtrace(regs, tsk);
+               dump_backtrace(regs, tsk, KERN_EMERG);
                dump_instr(KERN_EMERG, regs);
        }
 
index f303671..6221944 100644 (file)
@@ -16,6 +16,7 @@
 #define sv_fp  v5
 #define sv_pc  v6
 #define offset v8
+#define loglvl v9
 
 ENTRY(__backtrace)
                mov     r0, fp
@@ -27,10 +28,11 @@ ENTRY(c_backtrace)
 ENDPROC(__backtrace)
 ENDPROC(c_backtrace)
 #else
-               stm.w   (v4 - v8, lr), [sp-]    @ Save an extra register
+               stm.w   (v4 - v10, lr), [sp-]   @ Save an extra register
                                                @ so we have a location...
                mov.a   frame, r0               @ if frame pointer is zero
                beq     no_frame                @ we have no stack frames
+               mov     loglvl, r1
 
 1:             stm.w   (pc), [sp-]             @ calculate offset of PC stored
                ldw.w   r0, [sp]+, #4           @ by stmfd for this CPU
@@ -95,9 +97,10 @@ for_each_frame:
                bua     for_each_frame
 
 1006:          adr     r0, .Lbad
-               mov     r1, frame
+               mov     r1, loglvl
+               mov     r2, frame
                b.l     printk
-no_frame:      ldm.w   (v4 - v8, pc), [sp]+
+no_frame:      ldm.w   (v4 - v10, pc), [sp]+
 ENDPROC(__backtrace)
 ENDPROC(c_backtrace)
 
@@ -128,8 +131,11 @@ ENDPROC(c_backtrace)
                add     v7, v7, #1
                cxor.a  v7, #6
                cmoveq  v7, #1
-               cmoveq  r1, #'\n'
-               cmovne  r1, #' '
+               bne     201f
+               adr     r0, .Lcr
+               mov     r1, loglvl
+               b.l     printk
+201:
                ldw.w   r3, [stack]+, #-4
                mov     r2, reg
                csub.a  r2, #8
@@ -141,18 +147,20 @@ ENDPROC(c_backtrace)
                add     r2, r2, #0x10           @ so r2 need add 16
 201:
                adr     r0, .Lfp
+               mov     r1, loglvl
                b.l     printk
 2:             sub.a   reg, reg, #1
                bns     1b
                cxor.a  v7, #0
                beq     201f
                adr     r0, .Lcr
+               mov     r1, loglvl
                b.l     printk
 201:           ldm.w   (instr, reg, stack, v7, pc), [sp]+
 
-.Lfp:          .asciz  "%cr%d:%08x"
-.Lcr:          .asciz  "\n"
-.Lbad:         .asciz  "Backtrace aborted due to bad frame pointer <%p>\n"
+.Lfp:          .asciz  "%sr%d:%08x "
+.Lcr:          .asciz  "%s\n"
+.Lbad:         .asciz  "%sBacktrace aborted due to bad frame pointer <%p>\n"
                .align
 .Ldsi:         .word   0x92eec000 >> 14        @ stm.w sp, (... fp, ip, lr, pc)
                .word   0x92e10000 >> 14        @ stm.w sp, ()
index a07ae5c..2ea98f7 100644 (file)
@@ -18,8 +18,8 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/unaligned.h>
 
index 3022104..7654bdd 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/sched/signal.h>
 #include <linux/io.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 /*
@@ -224,12 +223,12 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
         * validly references user space from well defined areas of the code,
         * we can bug out early if this is from code which shouldn't.
         */
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                if (!user_mode(regs)
                    && !search_exception_tables(regs->UCreg_pc))
                        goto no_context;
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in
@@ -247,7 +246,7 @@ retry:
        fault = __do_pf(mm, addr, fsr, flags, tsk);
 
        /* If we need to retry but a fatal signal is pending, handle the
-        * signal first. We do not need to release the mmap_sem because
+        * signal first. We do not need to release the mmap_lock because
         * it would already be released in __lock_page_or_retry in
         * mm/filemap.c. */
        if (fault_signal_pending(fault, regs))
@@ -264,7 +263,7 @@ retry:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Handle the "normal" case first - VM_FAULT_MAJOR
index 27127ab..f157f5d 100644 (file)
@@ -14,16 +14,6 @@ extern int sysctl_overcommit_memory;
 
 #define TOP_PTE(x)     pte_offset_kernel(top_pmd, x)
 
-static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
-{
-       return pmd_offset((pud_t *)pgd, virt);
-}
-
-static inline pmd_t *pmd_off_k(unsigned long virt)
-{
-       return pmd_off(pgd_offset_k(virt), virt);
-}
-
 struct mem_type {
        unsigned int prot_pte;
        unsigned int prot_l1;
index 8cc9a1b..18f8c4f 100644 (file)
@@ -8,10 +8,10 @@
  */
 #include <linux/init.h>
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/assembler.h>
 #include <asm/hwcap.h>
 #include <asm/pgtable-hwdef.h>
-#include <asm/pgtable.h>
 
 #include "proc-macros.S"
 
index 9557c5a..f9c5c13 100644 (file)
@@ -22,8 +22,8 @@
 #include "misc.h"
 
 /* These actually do the work of building the kernel identity maps. */
+#include <linux/pgtable.h>
 #include <asm/init.h>
-#include <asm/pgtable.h>
 /* Use the static base for this part of the boot process */
 #undef __PAGE_OFFSET
 #define __PAGE_OFFSET __PAGE_OFFSET_BASE
index 43428cc..ea7c1f0 100644 (file)
@@ -144,7 +144,7 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
        struct mm_struct *mm = task->mm;
        struct vm_area_struct *vma;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
@@ -154,7 +154,7 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
                        zap_page_range(vma, vma->vm_start, size);
        }
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return 0;
 }
 #else
@@ -268,7 +268,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
        unsigned long text_start;
        int ret = 0;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        addr = get_unmapped_area(NULL, addr,
@@ -311,7 +311,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
        }
 
 up_fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 
@@ -373,7 +373,7 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        /*
         * Check if we have already mapped vdso blob - fail to prevent
         * abusing from userspace install_speciall_mapping, which may
@@ -384,11 +384,11 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                if (vma_is_special_mapping(vma, &vdso_mapping) ||
                                vma_is_special_mapping(vma, &vvar_mapping)) {
-                       up_write(&mm->mmap_sem);
+                       mmap_write_unlock(mm);
                        return -EEXIST;
                }
        }
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return map_vdso(image, addr);
 }
index ea2a3d1..4103665 100644 (file)
@@ -2178,10 +2178,10 @@ static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)
         * userspace with CR4.PCE clear while another task is still
         * doing on_each_cpu_mask() to propagate CR4.PCE.
         *
-        * For now, this can't happen because all callers hold mmap_sem
+        * For now, this can't happen because all callers hold mmap_lock
         * for write.  If this changes, we'll need a different solution.
         */
-       lockdep_assert_held_write(&mm->mmap_sem);
+       mmap_assert_write_locked(mm);
 
        if (atomic_inc_return(&mm->context.perf_rdpmc_allowed) == 1)
                on_each_cpu_mask(mm_cpumask(mm), cr4_update_pce, NULL, 1);
index 8e25bf4..62da760 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef _ASM_X86_AGP_H
 #define _ASM_X86_AGP_H
 
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 
 /*
index 9bf2620..5a42f92 100644 (file)
@@ -1,13 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <asm/ftrace.h>
 #include <linux/uaccess.h>
+#include <linux/pgtable.h>
 #include <asm/string.h>
 #include <asm/page.h>
 #include <asm/checksum.h>
 
 #include <asm-generic/asm-prototypes.h>
 
-#include <asm/pgtable.h>
 #include <asm/special_insns.h>
 #include <asm/preempt.h>
 #include <asm/asm.h>
index 89dcc7a..e7d2ccf 100644 (file)
@@ -3,13 +3,13 @@
 #define _ASM_X86_EFI_H
 
 #include <asm/fpu/api.h>
-#include <asm/pgtable.h>
 #include <asm/processor-flags.h>
 #include <asm/tlb.h>
 #include <asm/nospec-branch.h>
 #include <asm/mmu_context.h>
 #include <linux/build_bug.h>
 #include <linux/kernel.h>
+#include <linux/pgtable.h>
 
 extern unsigned long efi_fw_vendor, efi_config_table;
 
index 2a7b321..bacf68c 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 #include <linux/uaccess.h>
 #include <asm/cacheflush.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 void __iomem *
index db7ba2f..0648190 100644 (file)
@@ -6,8 +6,10 @@ unsigned long kaslr_get_random_long(const char *purpose);
 
 #ifdef CONFIG_RANDOMIZE_MEMORY
 void kernel_randomize_memory(void);
+void init_trampoline_kaslr(void);
 #else
 static inline void kernel_randomize_memory(void) { }
+static inline void init_trampoline_kaslr(void) {}
 #endif /* CONFIG_RANDOMIZE_MEMORY */
 
 #endif
index bdeae92..0a301ad 100644 (file)
@@ -45,7 +45,7 @@ typedef struct {
 #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
        /*
         * One bit per protection key says whether userspace can
-        * use it or not.  protected by mmap_sem.
+        * use it or not.  protected by mmap_lock.
         */
        u16 pkey_allocation_map;
        s16 execute_only_pkey;
index 5afb5e0..e896ebe 100644 (file)
@@ -39,23 +39,23 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
  * pte_offset_map_lock() on 32-bit PAE kernels was reading the pmd_t with
  * a "*pmdp" dereference done by GCC. Problem is, in certain places
  * where pte_offset_map_lock() is called, concurrent page faults are
- * allowed, if the mmap_sem is hold for reading. An example is mincore
+ * allowed, if the mmap_lock is hold for reading. An example is mincore
  * vs page faults vs MADV_DONTNEED. On the page fault side
  * pmd_populate() rightfully does a set_64bit(), but if we're reading the
  * pmd_t with a "*pmdp" on the mincore side, a SMP race can happen
  * because GCC will not read the 64-bit value of the pmd atomically.
  *
  * To fix this all places running pte_offset_map_lock() while holding the
- * mmap_sem in read mode, shall read the pmdp pointer using this
+ * mmap_lock in read mode, shall read the pmdp pointer using this
  * function to know if the pmd is null or not, and in turn to know if
  * they can run pte_offset_map_lock() or pmd_trans_huge() or other pmd
  * operations.
  *
- * Without THP if the mmap_sem is held for reading, the pmd can only
+ * Without THP if the mmap_lock is held for reading, the pmd can only
  * transition from null to not null while pmd_read_atomic() runs. So
  * we can always return atomic pmd values with this function.
  *
- * With THP if the mmap_sem is held for reading, the pmd can become
+ * With THP if the mmap_lock is held for reading, the pmd can become
  * trans_huge or none or point to a pte (and in turn become "stable")
  * at any time under pmd_read_atomic(). We could read it truly
  * atomically here with an atomic64_read() for the THP enabled case (and
index b8f46bb..76aa21e 100644 (file)
@@ -802,7 +802,7 @@ static inline int pmd_present(pmd_t pmd)
 #ifdef CONFIG_NUMA_BALANCING
 /*
  * These work without NUMA balancing but the kernel does not care. See the
- * comment in include/asm-generic/pgtable.h
+ * comment in include/linux/pgtable.h
  */
 static inline int pte_protnone(pte_t pte)
 {
@@ -837,17 +837,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
 #define pmd_page(pmd)  pfn_to_page(pmd_pfn(pmd))
 
 /*
- * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD]
- *
- * this macro returns the index of the entry in the pmd page which would
- * control the given virtual address
- */
-static inline unsigned long pmd_index(unsigned long address)
-{
-       return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
-}
-
-/*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  *
@@ -856,25 +845,6 @@ static inline unsigned long pmd_index(unsigned long address)
  */
 #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
 
-/*
- * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
- *
- * this function returns the index of the entry in the pte page which would
- * control the given virtual address
- *
- * Also define macro so we can test if pte_index is defined for arch.
- */
-#define pte_index pte_index
-static inline unsigned long pte_index(unsigned long address)
-{
-       return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
-}
-
-static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
-{
-       return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
-}
-
 static inline int pmd_bad(pmd_t pmd)
 {
        return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE;
@@ -907,12 +877,6 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
  */
 #define pud_page(pud)  pfn_to_page(pud_pfn(pud))
 
-/* Find an entry in the second-level page table.. */
-static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
-{
-       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
-}
-
 #define pud_leaf       pud_large
 static inline int pud_large(pud_t pud)
 {
@@ -932,11 +896,6 @@ static inline int pud_large(pud_t pud)
 }
 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
 
-static inline unsigned long pud_index(unsigned long address)
-{
-       return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
-}
-
 #if CONFIG_PGTABLE_LEVELS > 3
 static inline int p4d_none(p4d_t p4d)
 {
@@ -959,12 +918,6 @@ static inline unsigned long p4d_page_vaddr(p4d_t p4d)
  */
 #define p4d_page(p4d)  pfn_to_page(p4d_pfn(p4d))
 
-/* Find an entry in the third-level page table.. */
-static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
-{
-       return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
-}
-
 static inline int p4d_bad(p4d_t p4d)
 {
        unsigned long ignore_flags = _KERNPG_TABLE | _PAGE_USER;
@@ -1037,30 +990,6 @@ static inline int pgd_none(pgd_t pgd)
 
 #endif /* __ASSEMBLY__ */
 
-/*
- * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
- *
- * this macro returns the index of the entry in the pgd page which would
- * control the given virtual address
- */
-#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
-
-/*
- * pgd_offset() returns a (pgd_t *)
- * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
- */
-#define pgd_offset_pgd(pgd, address) (pgd + pgd_index((address)))
-/*
- * a shortcut to get a pgd_t in a given mm
- */
-#define pgd_offset(mm, address) pgd_offset_pgd((mm)->pgd, (address))
-/*
- * a shortcut which implies the use of the kernel's pgd, instead
- * of a process's
- */
-#define pgd_offset_k(address) pgd_offset(&init_mm, (address))
-
-
 #define KERNEL_PGD_BOUNDARY    pgd_index(PAGE_OFFSET)
 #define KERNEL_PGD_PTRS                (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
 
@@ -1071,27 +1000,14 @@ void init_mem_mapping(void);
 void early_alloc_pgt_buf(void);
 extern void memblock_find_dma_reserve(void);
 
+
 #ifdef CONFIG_X86_64
-/* Realmode trampoline initialization. */
 extern pgd_t trampoline_pgd_entry;
-static inline void __meminit init_trampoline_default(void)
-{
-       /* Default trampoline pgd value */
-       trampoline_pgd_entry = init_top_pgt[pgd_index(__PAGE_OFFSET)];
-}
 
 void __init poking_init(void);
 
 unsigned long init_memory_mapping(unsigned long start,
                                  unsigned long end, pgprot_t prot);
-
-# ifdef CONFIG_RANDOMIZE_MEMORY
-void __meminit init_trampoline(void);
-# else
-#  define init_trampoline init_trampoline_default
-# endif
-#else
-static inline void init_trampoline(void) { }
 #endif
 
 /* local pte updates need not use xchg for locking */
@@ -1546,7 +1462,6 @@ static inline bool arch_faults_on_old_pte(void)
        return false;
 }
 
-#include <asm-generic/pgtable.h>
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_X86_PGTABLE_H */
index 82dc0d8..ef76a04 100644 (file)
@@ -45,17 +45,6 @@ void sync_initial_page_table(void);
 # include <asm/pgtable-2level.h>
 #endif
 
-#if defined(CONFIG_HIGHPTE)
-#define pte_offset_map(dir, address)                                   \
-       ((pte_t *)kmap_atomic(pmd_page(*(dir))) +               \
-        pte_index((address)))
-#define pte_unmap(pte) kunmap_atomic((pte))
-#else
-#define pte_offset_map(dir, address)                                   \
-       ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
-#define pte_unmap(pte) do { } while (0)
-#endif
-
 /* Clear a kernel PTE and flush it from the TLB */
 #define kpte_clear_flush(ptep, vaddr)          \
 do {                                           \
index 8d03ffd..1b68d24 100644 (file)
@@ -186,10 +186,6 @@ extern void sync_global_pgds(unsigned long start, unsigned long end);
 
 /* PTE - Level 1 access. */
 
-/* x86-64 always has all page tables mapped. */
-#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte) ((void)(pte))/* NOP */
-
 /*
  * Encode and de-code a swap entry
  *
index ed8ec01..84b645c 100644 (file)
@@ -75,7 +75,17 @@ extern char _text[];
 
 static inline bool kaslr_enabled(void)
 {
-       return !!(boot_params.hdr.loadflags & KASLR_FLAG);
+       return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
+               !!(boot_params.hdr.loadflags & KASLR_FLAG);
+}
+
+/*
+ * Apply no randomization if KASLR was disabled at boot or if KASAN
+ * is enabled. KASAN shadow mappings rely on regions being PGD aligned.
+ */
+static inline bool kaslr_memory_enabled(void)
+{
+       return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN);
 }
 
 static inline unsigned long kaslr_offset(void)
index 14db050..5ae5a68 100644 (file)
@@ -87,7 +87,7 @@ get_stack_pointer(struct task_struct *task, struct pt_regs *regs)
 }
 
 void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
-                       unsigned long *stack, char *log_lvl);
+                       unsigned long *stack, const char *log_lvl);
 
 /* The form of the top of the frame on the stack */
 struct stack_frame {
index d8f283b..35b23b0 100644 (file)
@@ -523,5 +523,21 @@ do {                                                                       \
        unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label);   \
 } while (0)
 
+#define HAVE_GET_KERNEL_NOFAULT
+
+#define __get_kernel_nofault(dst, src, type, err_label)                        \
+do {                                                                   \
+       int __kr_err;                                                   \
+                                                                       \
+       __get_user_size(*((type *)dst), (__force type __user *)src,     \
+                       sizeof(type), __kr_err);                        \
+       if (unlikely(__kr_err))                                         \
+               goto err_label;                                         \
+} while (0)
+
+#define __put_kernel_nofault(dst, src, type, err_label)                        \
+       __put_user_size(*((type *)(src)), (__force type __user *)(dst), \
+                       sizeof(type), err_label)
+
 #endif /* _ASM_X86_UACCESS_H */
 
index d50c7b7..ba4c1b1 100644 (file)
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/pgtable.h>
 
 #include <trace/events/xen.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/smap.h>
 #include <asm/nospec-branch.h>
 
index 790ce08..5941e18 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <asm/extable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
index 683ed9e..7bdc023 100644 (file)
 #include <linux/pci.h>
 #include <linux/efi-bgrt.h>
 #include <linux/serial_core.h>
+#include <linux/pgtable.h>
 
 #include <asm/e820/api.h>
 #include <asm/irqdomain.h>
 #include <asm/pci_x86.h>
-#include <asm/pgtable.h>
 #include <asm/io_apic.h>
 #include <asm/apic.h>
 #include <asm/io.h>
index ed3b044..cc1fea7 100644 (file)
@@ -10,9 +10,9 @@
 #include <linux/memblock.h>
 #include <linux/dmi.h>
 #include <linux/cpumask.h>
+#include <linux/pgtable.h>
 #include <asm/segment.h>
 #include <asm/desc.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/realmode.h>
 
index cd61797..a9195ce 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/text-patching.h>
 #include <asm/alternative.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/mce.h>
 #include <asm/nmi.h>
 #include <asm/cacheflush.h>
index 1613381..17cb5b9 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/atomic.h>
 #include <linux/dma-direct.h>
 #include <asm/mtrr.h>
-#include <asm/pgtable.h>
 #include <asm/proto.h>
 #include <asm/iommu.h>
 #include <asm/gart.h>
@@ -159,7 +158,7 @@ static void dump_leak(void)
                return;
        dump = 1;
 
-       show_stack(NULL, NULL);
+       show_stack(NULL, NULL, KERN_ERR);
        debug_dma_dump_mappings(NULL);
 }
 #endif
index cdf45b4..35edd57 100644 (file)
  */
 #include <linux/types.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
 #include <asm/numachip/numachip.h>
 #include <asm/numachip/numachip_csr.h>
 
-#include <asm/pgtable.h>
 
 #include "local.h"
 
index 56978cb..b6f887b 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/nospec.h>
 #include <linux/prctl.h>
 #include <linux/sched/smt.h>
+#include <linux/pgtable.h>
 
 #include <asm/spec-ctrl.h>
 #include <asm/cmdline.h>
@@ -26,7 +27,6 @@
 #include <asm/vmx.h>
 #include <asm/paravirt.h>
 #include <asm/alternative.h>
-#include <asm/pgtable.h>
 #include <asm/set_memory.h>
 #include <asm/intel-family.h>
 #include <asm/e820/api.h>
index 40776ef..8be042d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/syscore_ops.h>
+#include <linux/pgtable.h>
 
 #include <asm/stackprotector.h>
 #include <asm/perf_event.h>
@@ -35,7 +36,6 @@
 #include <asm/vsyscall.h>
 #include <linux/topology.h>
 #include <linux/cpumask.h>
-#include <asm/pgtable.h>
 #include <linux/atomic.h>
 #include <asm/proto.h>
 #include <asm/setup.h>
index 166d7c3..63926c9 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/kernel.h>
+#include <linux/pgtable.h>
 
 #include <linux/string.h>
 #include <linux/bitops.h>
@@ -11,7 +12,6 @@
 #include <linux/uaccess.h>
 
 #include <asm/cpufeature.h>
-#include <asm/pgtable.h>
 #include <asm/msr.h>
 #include <asm/bugs.h>
 #include <asm/cpu.h>
index 4bd28b3..0daf2f1 100644 (file)
@@ -1326,9 +1326,9 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)
         * pseudo-locked region will still be here on return.
         *
         * The mutex has to be released temporarily to avoid a potential
-        * deadlock with the mm->mmap_sem semaphore which is obtained in
-        * the device_create() and debugfs_create_dir() callpath below
-        * as well as before the mmap() callback is called.
+        * deadlock with the mm->mmap_lock which is obtained in the
+        * device_create() and debugfs_create_dir() callpath below as well as
+        * before the mmap() callback is called.
         */
        mutex_unlock(&rdtgroup_mutex);
 
index d7cb5ab..23b4b61 100644 (file)
@@ -3199,10 +3199,10 @@ int __init rdtgroup_init(void)
         * during the debugfs directory creation also &sb->s_type->i_mutex_key
         * (the lockdep class of inode->i_rwsem). Other filesystem
         * interactions (eg. SyS_getdents) have the lock ordering:
-        * &sb->s_type->i_mutex_key --> &mm->mmap_sem
-        * During mmap(), called with &mm->mmap_sem, the rdtgroup_mutex
+        * &sb->s_type->i_mutex_key --> &mm->mmap_lock
+        * During mmap(), called with &mm->mmap_lock, the rdtgroup_mutex
         * is taken, thus creating dependency:
-        * &mm->mmap_sem --> rdtgroup_mutex for the latter that can cause
+        * &mm->mmap_lock --> rdtgroup_mutex for the latter that can cause
         * issues considering the other two lock dependencies.
         * By creating the debugfs directory here we avoid a dependency
         * that may cause deadlock (even though file operations cannot
index c0159a7..8a89c10 100644 (file)
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <linux/crash_core.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 
 void arch_crash_save_vmcoreinfo(void)
index 845a57e..7d255f8 100644 (file)
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <linux/crash_core.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 
 void arch_crash_save_vmcoreinfo(void)
index 3793646..2ccc57f 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/fs.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/desc.h>
 #include <asm/traps.h>
index ae64ec7..456511b 100644 (file)
@@ -65,7 +65,7 @@ bool in_entry_stack(unsigned long *stack, struct stack_info *info)
 }
 
 static void printk_stack_address(unsigned long address, int reliable,
-                                char *log_lvl)
+                                const char *log_lvl)
 {
        touch_nmi_watchdog();
        printk("%s %s%pB\n", log_lvl, reliable ? "" : "? ", (void *)address);
@@ -160,7 +160,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs,
 }
 
 void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
-                       unsigned long *stack, char *log_lvl)
+                       unsigned long *stack, const char *log_lvl)
 {
        struct unwind_state state;
        struct stack_info stack_info = {0};
@@ -279,7 +279,8 @@ next:
        }
 }
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp,
+                      const char *loglvl)
 {
        task = task ? : current;
 
@@ -290,7 +291,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)
        if (!sp && task == current)
                sp = get_stack_pointer(current, NULL);
 
-       show_trace_log_lvl(task, NULL, sp, KERN_DEFAULT);
+       show_trace_log_lvl(task, NULL, sp, loglvl);
 }
 
 void show_stack_regs(struct pt_regs *regs)
index 93fbdff..d3c531d 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/pci_regs.h>
 #include <linux/pci_ids.h>
 #include <linux/errno.h>
+#include <linux/pgtable.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/fcntl.h>
@@ -15,7 +16,6 @@
 #include <xen/hvc-console.h>
 #include <asm/pci-direct.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 #include <linux/usb/ehci_def.h>
 #include <linux/usb/xhci-dbgp.h>
 #include <asm/pci_x86.h>
index 12e7d44..4fe7af5 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/percpu.h>
 #include <linux/gfp.h>
 #include <linux/random.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/setup.h>
 #include <asm/espfix.h>
index 206a4b6..cbb71c1 100644 (file)
 #include <linux/io.h>
 #include <linux/memblock.h>
 #include <linux/mem_encrypt.h>
+#include <linux/pgtable.h>
 
 #include <asm/processor.h>
 #include <asm/proto.h>
 #include <asm/smp.h>
 #include <asm/setup.h>
 #include <asm/desc.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
 #include <asm/kdebug.h>
index 4bbc770..4fc33fd 100644 (file)
@@ -13,8 +13,8 @@
 #include <linux/linkage.h>
 #include <linux/threads.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/segment.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/msr.h>
 #include <asm/cache.h>
index 519649d..f3c7625 100644 (file)
 #include <linux/acpi.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/pgtable.h>
 
 #include <linux/atomic.h>
 #include <asm/timer.h>
 #include <asm/hw_irq.h>
-#include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
 #include <asm/i8259.h>
index 5aa523c..dd73135 100644 (file)
 #include <linux/acpi.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/pgtable.h>
 
 #include <linux/atomic.h>
 #include <asm/timer.h>
 #include <asm/hw_irq.h>
-#include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
 #include <asm/setup.h>
index 4d7022a..85de8fa 100644 (file)
 #include <linux/kasan.h>
 #include <linux/moduleloader.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 
 #include <asm/text-patching.h>
 #include <asm/cacheflush.h>
 #include <asm/desc.h>
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/alternative.h>
 #include <asm/insn.h>
index ea13f68..234f58e 100644 (file)
 #include <linux/kallsyms.h>
 #include <linux/ftrace.h>
 #include <linux/frame.h>
+#include <linux/pgtable.h>
 
 #include <asm/text-patching.h>
 #include <asm/cacheflush.h>
 #include <asm/desc.h>
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/alternative.h>
 #include <asm/insn.h>
index 84c3ba3..8748321 100644 (file)
@@ -8,7 +8,7 @@
  *
  * Lock order:
  *     contex.ldt_usr_sem
- *       mmap_sem
+ *       mmap_lock
  *         context.lock
  */
 
index 02bddfc..64b00b0 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/gfp.h>
 #include <linux/io.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/mmu_context.h>
index ad5cdd6..a29a44a 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/efi.h>
 
 #include <asm/init.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/mmu_context.h>
 #include <asm/io_apic.h>
index 23c95a5..34b153c 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <asm/text-patching.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/unwind.h>
 
index 5638e4a..674a7d6 100644 (file)
 #include <linux/bcd.h>
 #include <linux/highmem.h>
 #include <linux/kprobes.h>
+#include <linux/pgtable.h>
 
 #include <asm/bug.h>
 #include <asm/paravirt.h>
 #include <asm/debugreg.h>
 #include <asm/desc.h>
 #include <asm/setup.h>
-#include <asm/pgtable.h>
 #include <asm/time.h>
 #include <asm/pgalloc.h>
 #include <asm/irq.h>
index 538d4e8..acfd6d2 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/kdebug.h>
 #include <linux/syscalls.h>
 
-#include <asm/pgtable.h>
 #include <asm/ldt.h>
 #include <asm/processor.h>
 #include <asm/fpu/internal.h>
index 0c169a5..9a97415 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/ftrace.h>
 #include <linux/syscalls.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/fpu/internal.h>
 #include <asm/mmu_context.h>
index f0e1ddb..4413058 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/nospec.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/fpu/internal.h>
 #include <asm/fpu/signal.h>
index 3ca43be..e040ba6 100644 (file)
 #include <linux/tboot.h>
 #include <linux/delay.h>
 #include <linux/frame.h>
+#include <linux/pgtable.h>
 #include <acpi/reboot.h>
 #include <asm/io.h>
 #include <asm/apic.h>
 #include <asm/io_apic.h>
 #include <asm/desc.h>
 #include <asm/hpet.h>
-#include <asm/pgtable.h>
 #include <asm/proto.h>
 #include <asm/reboot_fixups.h>
 #include <asm/reboot.h>
index 2467f3d..ffbd9a3 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/gfp.h>
 #include <linux/cpuidle.h>
 #include <linux/numa.h>
+#include <linux/pgtable.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -63,7 +64,6 @@
 #include <asm/realmode.h>
 #include <asm/cpu.h>
 #include <asm/numa.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/mtrr.h>
 #include <asm/mwait.h>
index b2942b2..992fb14 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/realmode.h>
 #include <asm/processor.h>
 #include <asm/bootparam.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/swiotlb.h>
 #include <asm/fixmap.h>
@@ -94,7 +93,7 @@ static struct mm_struct tboot_mm = {
        .pgd            = swapper_pg_dir,
        .mm_users       = ATOMIC_INIT(2),
        .mm_count       = ATOMIC_INIT(1),
-       .mmap_sem       = __RWSEM_INITIALIZER(init_mm.mmap_sem),
+       MMAP_LOCK_INITIALIZER(init_mm)
        .page_table_lock =  __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
        .mmlist         = LIST_HEAD_INIT(init_mm.mmlist),
 };
index 47a8676..764573d 100644 (file)
@@ -171,7 +171,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)
        pte_t *pte;
        int i;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        pgd = pgd_offset(mm, 0xA0000);
        if (pgd_none_or_clear_bad(pgd))
                goto out;
@@ -197,7 +197,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)
        }
        pte_unmap_unlock(pte, ptl);
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        flush_tlb_mm_range(mm, 0xA0000, 0xA0000 + 32*PAGE_SIZE, PAGE_SHIFT, false);
 }
 
index 38c5764..a6d484e 100644 (file)
@@ -165,22 +165,22 @@ static int FNAME(cmpxchg_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
                unsigned long pfn;
                unsigned long paddr;
 
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                vma = find_vma_intersection(current->mm, vaddr, vaddr + PAGE_SIZE);
                if (!vma || !(vma->vm_flags & VM_PFNMAP)) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        return -EFAULT;
                }
                pfn = ((vaddr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
                paddr = pfn << PAGE_SHIFT;
                table = memremap(paddr, PAGE_SIZE, MEMREMAP_WB);
                if (!table) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        return -EFAULT;
                }
                ret = CMPXCHG(&table[index], orig_pte, new_pte);
                memunmap(table);
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
        }
 
        return (ret != orig_pte);
index 5199d8a..6f8b48f 100644 (file)
@@ -4,9 +4,9 @@
 #include <linux/percpu.h>
 #include <linux/kallsyms.h>
 #include <linux/kcore.h>
+#include <linux/pgtable.h>
 
 #include <asm/cpu_entry_area.h>
-#include <asm/pgtable.h>
 #include <asm/fixmap.h>
 #include <asm/desc.h>
 
index 4a3b62f..092ea43 100644 (file)
@@ -3,7 +3,7 @@
 #include <linux/efi.h>
 #include <linux/module.h>
 #include <linux/seq_file.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 static int ptdump_show(struct seq_file *m, void *v)
 {
index ea90101..e1b599e 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ptdump.h>
 
 #include <asm/e820/types.h>
-#include <asm/pgtable.h>
 
 /*
  * The dumper groups pagetable entries of the same type into one, and for
index c5437f2..0b03ae8 100644 (file)
@@ -811,7 +811,7 @@ __bad_area(struct pt_regs *regs, unsigned long error_code,
         * Something tried to access memory that isn't in our memory map..
         * Fix it, but check if it's kernel or user first..
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        __bad_area_nosemaphore(regs, error_code, address, pkey, si_code);
 }
@@ -865,7 +865,7 @@ bad_area_access_error(struct pt_regs *regs, unsigned long error_code,
                 * 2. T1   : set PKRU to deny access to pkey=4, touches page
                 * 3. T1   : faults...
                 * 4.    T2: mprotect_key(foo, PAGE_SIZE, pkey=5);
-                * 5. T1   : enters fault handler, takes mmap_sem, etc...
+                * 5. T1   : enters fault handler, takes mmap_lock, etc...
                 * 6. T1   : reaches here, sees vma_pkey(vma)=5, when we really
                 *           faulted on a pte with its pkey=4.
                 */
@@ -1231,15 +1231,15 @@ void do_user_addr_fault(struct pt_regs *regs,
         * Kernel-mode access to the user address space should only occur
         * on well-defined single instructions listed in the exception
         * tables.  But, an erroneous kernel fault occurring outside one of
-        * those areas which also holds mmap_sem might deadlock attempting
+        * those areas which also holds mmap_lock might deadlock attempting
         * to validate the fault against the address space.
         *
         * Only do the expensive exception table search when we might be at
         * risk of a deadlock.  This happens if we
-        * 1. Failed to acquire mmap_sem, and
+        * 1. Failed to acquire mmap_lock, and
         * 2. The access did not originate in userspace.
         */
-       if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
+       if (unlikely(!mmap_read_trylock(mm))) {
                if (!user_mode(regs) && !search_exception_tables(regs->ip)) {
                        /*
                         * Fault from code in kernel from
@@ -1249,7 +1249,7 @@ void do_user_addr_fault(struct pt_regs *regs,
                        return;
                }
 retry:
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        } else {
                /*
                 * The above down_read_trylock() might have succeeded in
@@ -1289,9 +1289,9 @@ good_area:
         * If for any reason at all we couldn't handle the fault,
         * make sure we exit gracefully rather than endlessly redo
         * the fault.  Since we never set FAULT_FLAG_RETRY_NOWAIT, if
-        * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked.
+        * we get VM_FAULT_RETRY back, the mmap_lock has been unlocked.
         *
-        * Note that handle_userfault() may also release and reacquire mmap_sem
+        * Note that handle_userfault() may also release and reacquire mmap_lock
         * (and not return with VM_FAULT_RETRY), when returning to userland to
         * repeat the page fault later with a VM_FAULT_NOPAGE retval
         * (potentially after handling any pending signal during the return to
@@ -1310,7 +1310,7 @@ good_area:
        }
 
        /*
-        * If we need to retry the mmap_sem has already been released,
+        * If we need to retry the mmap_lock has already been released,
         * and if there is a fatal signal pending there is no guarantee
         * that we made any progress. Handle this case first.
         */
@@ -1320,7 +1320,7 @@ good_area:
                goto retry;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (unlikely(fault & VM_FAULT_ERROR)) {
                mm_fault_error(regs, hw_error_code, address, fault);
                return;
@@ -1359,7 +1359,7 @@ dotraplinkage void
 do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
                unsigned long address)
 {
-       prefetchw(&current->mm->mmap_sem);
+       prefetchw(&current->mm->mmap_lock);
        /*
         * KVM has two types of events that are, logically, interrupts, but
         * are unfortunately delivered using the #PF vector.  These events are
index 112d3b9..001dd7d 100644 (file)
@@ -680,6 +680,28 @@ static void __init memory_map_bottom_up(unsigned long map_start,
        }
 }
 
+/*
+ * The real mode trampoline, which is required for bootstrapping CPUs
+ * occupies only a small area under the low 1MB.  See reserve_real_mode()
+ * for details.
+ *
+ * If KASLR is disabled the first PGD entry of the direct mapping is copied
+ * to map the real mode trampoline.
+ *
+ * If KASLR is enabled, copy only the PUD which covers the low 1MB
+ * area. This limits the randomization granularity to 1GB for both 4-level
+ * and 5-level paging.
+ */
+static void __init init_trampoline(void)
+{
+#ifdef CONFIG_X86_64
+       if (!kaslr_memory_enabled())
+               trampoline_pgd_entry = init_top_pgt[pgd_index(__PAGE_OFFSET)];
+       else
+               init_trampoline_kaslr();
+#endif
+}
+
 void __init init_mem_mapping(void)
 {
        unsigned long end;
index 4222a01..bda909e 100644 (file)
@@ -35,7 +35,6 @@
 #include <asm/bios_ebda.h>
 #include <asm/processor.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/dma.h>
 #include <asm/fixmap.h>
 #include <asm/e820/api.h>
@@ -396,15 +395,6 @@ repeat:
 
 pte_t *kmap_pte;
 
-static inline pte_t *kmap_get_fixmap_pte(unsigned long vaddr)
-{
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-       pmd_t *pmd = pmd_offset(pud, vaddr);
-       return pte_offset_kernel(pmd, vaddr);
-}
-
 static void __init kmap_init(void)
 {
        unsigned long kmap_vstart;
@@ -413,28 +403,17 @@ static void __init kmap_init(void)
         * Cache the first kmap pte:
         */
        kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
-       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
+       kmap_pte = virt_to_kpte(kmap_vstart);
 }
 
 #ifdef CONFIG_HIGHMEM
 static void __init permanent_kmaps_init(pgd_t *pgd_base)
 {
-       unsigned long vaddr;
-       pgd_t *pgd;
-       p4d_t *p4d;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
+       unsigned long vaddr = PKMAP_BASE;
 
-       vaddr = PKMAP_BASE;
        page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
 
-       pgd = swapper_pg_dir + pgd_index(vaddr);
-       p4d = p4d_offset(pgd, vaddr);
-       pud = pud_offset(p4d, vaddr);
-       pmd = pmd_offset(pud, vaddr);
-       pte = pte_offset_kernel(pmd, vaddr);
-       pkmap_page_table = pte;
+       pkmap_page_table = virt_to_kpte(vaddr);
 }
 
 void __init add_highpages_with_active_regions(int nid,
index add03c3..dbae185 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/processor.h>
 #include <asm/bios_ebda.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/dma.h>
 #include <asm/fixmap.h>
index 986d575..84d85db 100644 (file)
 #include <linux/mmiotrace.h>
 #include <linux/mem_encrypt.h>
 #include <linux/efi.h>
+#include <linux/pgtable.h>
 
 #include <asm/set_memory.h>
 #include <asm/e820/api.h>
 #include <asm/efi.h>
 #include <asm/fixmap.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/pgalloc.h>
 #include <asm/memtype.h>
index 763e71a..1a50434 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
-#include <asm/pgtable.h>
 #include <asm/cpu_entry_area.h>
 
 extern struct range pfn_mapped[E820_MAX_ENTRIES];
index dc6182e..fb620fd 100644 (file)
@@ -24,9 +24,9 @@
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/setup.h>
 #include <asm/kaslr.h>
 
@@ -61,15 +61,6 @@ static inline unsigned long get_padding(struct kaslr_memory_region *region)
        return (region->size_tb << TB_SHIFT);
 }
 
-/*
- * Apply no randomization if KASLR was disabled at boot or if KASAN
- * is enabled. KASAN shadow mappings rely on regions being PGD aligned.
- */
-static inline bool kaslr_memory_enabled(void)
-{
-       return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN);
-}
-
 /* Initialize base and padding for each memory region randomized with KASLR */
 void __init kernel_randomize_memory(void)
 {
@@ -148,7 +139,7 @@ void __init kernel_randomize_memory(void)
        }
 }
 
-static void __meminit init_trampoline_pud(void)
+void __meminit init_trampoline_kaslr(void)
 {
        pud_t *pud_page_tramp, *pud, *pud_tramp;
        p4d_t *p4d_page_tramp, *p4d, *p4d_tramp;
@@ -189,25 +180,3 @@ static void __meminit init_trampoline_pud(void)
                        __pgd(_KERNPG_TABLE | __pa(pud_page_tramp)));
        }
 }
-
-/*
- * The real mode trampoline, which is required for bootstrapping CPUs
- * occupies only a small area under the low 1MB.  See reserve_real_mode()
- * for details.
- *
- * If KASLR is disabled the first PGD entry of the direct mapping is copied
- * to map the real mode trampoline.
- *
- * If KASLR is enabled, copy only the PUD which covers the low 1MB
- * area. This limits the randomization granularity to 1GB for both 4-level
- * and 5-level paging.
- */
-void __meminit init_trampoline(void)
-{
-       if (!kaslr_memory_enabled()) {
-               init_trampoline_default();
-               return;
-       }
-
-       init_trampoline_pud();
-}
index f5b85bd..e1d7d74 100644 (file)
@@ -9,35 +9,21 @@ static __always_inline u64 canonical_address(u64 vaddr, u8 vaddr_bits)
        return ((s64)vaddr << (64 - vaddr_bits)) >> (64 - vaddr_bits);
 }
 
-static __always_inline bool invalid_probe_range(u64 vaddr)
+bool probe_kernel_read_allowed(const void *unsafe_src, size_t size)
 {
+       unsigned long vaddr = (unsigned long)unsafe_src;
+
        /*
         * Range covering the highest possible canonical userspace address
         * as well as non-canonical address range. For the canonical range
         * we also need to include the userspace guard page.
         */
-       return vaddr < TASK_SIZE_MAX + PAGE_SIZE ||
-              canonical_address(vaddr, boot_cpu_data.x86_virt_bits) != vaddr;
+       return vaddr >= TASK_SIZE_MAX + PAGE_SIZE &&
+              canonical_address(vaddr, boot_cpu_data.x86_virt_bits) == vaddr;
 }
 #else
-static __always_inline bool invalid_probe_range(u64 vaddr)
+bool probe_kernel_read_allowed(const void *unsafe_src, size_t size)
 {
-       return vaddr < TASK_SIZE_MAX;
+       return (unsigned long)unsafe_src >= TASK_SIZE_MAX;
 }
 #endif
-
-long probe_kernel_read_strict(void *dst, const void *src, size_t size)
-{
-       if (unlikely(invalid_probe_range((unsigned long)src)))
-               return -EFAULT;
-
-       return __probe_kernel_read(dst, src, size);
-}
-
-long strncpy_from_unsafe_strict(char *dst, const void *unsafe_addr, long count)
-{
-       if (unlikely(invalid_probe_range((unsigned long)unsafe_addr)))
-               return -EFAULT;
-
-       return __strncpy_from_unsafe(dst, unsafe_addr, count);
-}
index 106ead0..7a84fc8 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <linux/linkage.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
 #include <asm/processor-flags.h>
 #include <asm/msr-index.h>
index 43fd19b..bd7aff5 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
-#include <asm/pgtable.h>
 #include <linux/mmiotrace.h>
+#include <linux/pgtable.h>
 #include <asm/e820/api.h> /* for ISA_START_ADDRESS */
 #include <linux/atomic.h>
 #include <linux/percpu.h>
index facce27..0612a73 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/vmalloc.h>
 
 #include <asm/cacheflush.h>
-#include <asm/pgtable.h>
 #include <asm/kdebug.h>
 
 /*
index 394be86..8f665c3 100644 (file)
@@ -46,7 +46,6 @@
 #include <asm/processor.h>
 #include <asm/tlbflush.h>
 #include <asm/x86_init.h>
-#include <asm/pgtable.h>
 #include <asm/fcntl.h>
 #include <asm/e820/api.h>
 #include <asm/mtrr.h>
index a07e488..645613d 100644 (file)
@@ -14,8 +14,8 @@
 #include <linux/interval_tree_generic.h>
 #include <linux/sched.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/memtype.h>
 
 #include "memtype.h"
index d88e906..dfd82f5 100644 (file)
@@ -3,7 +3,6 @@
 #include <linux/gfp.h>
 #include <linux/hugetlb.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 #include <asm/fixmap.h>
 #include <asm/mtrr.h>
index e1ce59d..1953685 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/spinlock.h>
 
 #include <asm/cpu_entry_area.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/fixmap.h>
 #include <asm/e820/api.h>
index da0fb17..a3c6757 100644 (file)
@@ -34,7 +34,6 @@
 #include <asm/vsyscall.h>
 #include <asm/cmdline.h>
 #include <asm/pti.h>
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 #include <asm/desc.h>
index adb3c57..ed5667f 100644 (file)
@@ -2,8 +2,8 @@
 #include <linux/spinlock.h>
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/proto.h>
 #include <asm/cpufeature.h>
 
index c049c43..826ead6 100644 (file)
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/efi.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/desc.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/efi.h>
 
index c5e393f..8e364c4 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/setup.h>
 #include <asm/page.h>
 #include <asm/e820/api.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/proto.h>
 #include <asm/efi.h>
index 20a0645..6bab0f0 100644 (file)
@@ -3,12 +3,12 @@
 #include <linux/export.h>
 #include <linux/spinlock_types.h>
 #include <linux/init.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
 #include <asm/setup.h>
 #include <asm/io.h>
 #include <asm/cpufeature.h>
 #include <asm/special_insns.h>
-#include <asm/pgtable.h>
 #include <asm/olpc_ofw.h>
 
 /* address of OFW callback interface; will be NULL if OFW isn't found */
index fc3b757..7c65102 100644 (file)
@@ -13,8 +13,8 @@
 #include <linux/perf_event.h>
 #include <linux/tboot.h>
 #include <linux/dmi.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/proto.h>
 #include <asm/mtrr.h>
 #include <asm/page.h>
index fc41371..d147f1b 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/scatterlist.h>
 #include <linux/kdebug.h>
 #include <linux/cpu.h>
+#include <linux/pgtable.h>
 
 #include <crypto/hash.h>
 
@@ -19,7 +20,6 @@
 #include <asm/init.h>
 #include <asm/proto.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mtrr.h>
 #include <asm/sections.h>
 #include <asm/suspend.h>
index a1061d4..223d5bc 100644 (file)
@@ -8,9 +8,9 @@
 #include <linux/gfp.h>
 #include <linux/suspend.h>
 #include <linux/memblock.h>
+#include <linux/pgtable.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mmzone.h>
 #include <asm/sections.h>
 #include <asm/suspend.h>
index 0197095..a595953 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/suspend.h>
 #include <linux/scatterlist.h>
 #include <linux/kdebug.h>
+#include <linux/pgtable.h>
 
 #include <crypto/hash.h>
 
@@ -19,7 +20,6 @@
 #include <asm/init.h>
 #include <asm/proto.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mtrr.h>
 #include <asm/sections.h>
 #include <asm/suspend.h>
index 262f83c..1ed1208 100644 (file)
@@ -3,9 +3,9 @@
 #include <linux/slab.h>
 #include <linux/memblock.h>
 #include <linux/mem_encrypt.h>
+#include <linux/pgtable.h>
 
 #include <asm/set_memory.h>
-#include <asm/pgtable.h>
 #include <asm/realmode.h>
 #include <asm/tlbflush.h>
 #include <asm/crash.h>
index 9e7c4ab..76d9f6c 100644 (file)
@@ -58,7 +58,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
        if (!vdso_enabled)
                return 0;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE,
@@ -66,7 +66,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
                VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
                vdsop);
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return err;
 }
index 507f4fb..c2c97fa 100644 (file)
@@ -63,7 +63,6 @@
 #include <asm/setup.h>
 #include <asm/desc.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/reboot.h>
 #include <asm/stackprotector.h>
index ecb0d54..4988e19 100644 (file)
@@ -21,7 +21,6 @@
 #include <xen/grant_table.h>
 #include <xen/xen.h>
 
-#include <asm/pgtable.h>
 
 static struct gnttab_vm_area {
        struct vm_struct *area;
index bbba8b1..a58d9c6 100644 (file)
 #include <linux/memblock.h>
 #include <linux/seq_file.h>
 #include <linux/crash_dump.h>
+#include <linux/pgtable.h>
 #ifdef CONFIG_KEXEC_CORE
 #include <linux/kexec.h>
 #endif
 
 #include <trace/events/xen.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/fixmap.h>
 #include <asm/mmu_context.h>
index f2adb63..8fa01c5 100644 (file)
 #include <linux/nmi.h>
 #include <linux/cpuhotplug.h>
 #include <linux/stackprotector.h>
+#include <linux/pgtable.h>
 
 #include <asm/paravirt.h>
 #include <asm/desc.h>
-#include <asm/pgtable.h>
 #include <asm/cpu.h>
 
 #include <xen/interface/xen.h>
index cfb8696..a06ffb0 100644 (file)
@@ -13,9 +13,9 @@
 #ifndef _ASM_FIXMAP_H
 #define _ASM_FIXMAP_H
 
-#include <asm/pgtable.h>
 #ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
+#include <linux/pgtable.h>
 #include <asm/kmap_types.h>
 #endif
 
@@ -76,12 +76,4 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
 
 #endif
 
-#define kmap_get_fixmap_pte(vaddr) \
-       pte_offset_kernel( \
-               pmd_offset(pud_offset(p4d_offset(pgd_offset_k(vaddr), \
-                                                (vaddr)), \
-                                     (vaddr)), \
-                          (vaddr)), \
-               (vaddr))
-
 #endif
index d6a1070..eac5032 100644 (file)
 #define _XTENSA_HIGHMEM_H
 
 #include <linux/wait.h>
+#include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/fixmap.h>
 #include <asm/kmap_types.h>
-#include <asm/pgtable.h>
 
 #define PKMAP_BASE             ((FIXADDR_START - \
                                  (LAST_PKMAP + 1) * PAGE_SIZE) & PMD_MASK)
index e3e1d9a..9ee0c1d 100644 (file)
@@ -24,7 +24,7 @@
 #define _XTENSA_INITIALIZE_MMU_H
 
 #include <linux/init.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/vectors.h>
 
 #if XCHAL_HAVE_PTP_MMU
index de5e6cb..74923ef 100644 (file)
 #include <linux/stringify.h>
 #include <linux/sched.h>
 #include <linux/mm_types.h>
+#include <linux/pgtable.h>
 
 #include <asm/vectors.h>
 
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm-generic/mm_hooks.h>
index 8be0c05..fa054a1 100644 (file)
@@ -267,7 +267,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITABLE; }
 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
 
-static inline pte_t pte_wrprotect(pte_t pte)   
+static inline pte_t pte_wrprotect(pte_t pte)
        { pte_val(pte) &= ~(_PAGE_WRITABLE | _PAGE_HW_WRITE); return pte; }
 static inline pte_t pte_mkclean(pte_t pte)
        { pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HW_WRITE); return pte; }
@@ -359,22 +359,6 @@ ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
        update_pte(ptep, pte_wrprotect(pte));
 }
 
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address)  pgd_offset(&init_mm, address)
-
-/* to find an entry in a page-table-directory */
-#define pgd_offset(mm,address) ((mm)->pgd + pgd_index(address))
-
-#define pgd_index(address)     ((address) >> PGDIR_SHIFT)
-
-/* Find an entry in the third-level page table.. */
-#define pte_index(address)     (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
-#define pte_offset_kernel(dir,addr)                                    \
-       ((pte_t*) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir,addr)       pte_offset_kernel((dir),(addr))
-#define pte_unmap(pte)         do { } while (0)
-
-
 /*
  * Encode and decode a swap and file entry.
  */
@@ -438,6 +422,4 @@ typedef pte_t *pte_addr_t;
  */
 #define HAVE_ARCH_UNMAPPED_AREA
 
-#include <asm-generic/pgtable.h>
-
 #endif /* _XTENSA_PGTABLE_H */
index fae33dd..98515c2 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/asm-offsets.h>
 #include <asm/asmmacro.h>
 #include <asm/processor.h>
@@ -22,7 +23,6 @@
 #include <asm/unistd.h>
 #include <asm/ptrace.h>
 #include <asm/current.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <asm/signal.h>
 #include <asm/tlbflush.h>
index 3edecc4..b7fe6f4 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/slab.h>
 #include <linux/rcupdate.h>
 
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 #include <asm/io.h>
 #include <asm/processor.h>
index 145742d..b4c07bd 100644 (file)
@@ -33,7 +33,6 @@
 #include <asm/coprocessor.h>
 #include <asm/elf.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/ptrace.h>
 
 static int gpr_get(struct task_struct *target,
index 3880c76..d9204dc 100644 (file)
@@ -37,7 +37,6 @@
 #include <asm/bootparam.h>
 #include <asm/kasan.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/timex.h>
 #include <asm/platform.h>
index 0976e27..efc3a29 100644 (file)
 #include <linux/delay.h>
 #include <linux/hardirq.h>
 #include <linux/ratelimit.h>
+#include <linux/pgtable.h>
 
 #include <asm/stacktrace.h>
 #include <asm/ptrace.h>
 #include <asm/timex.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/traps.h>
 #include <asm/hw_breakpoint.h>
@@ -479,25 +479,29 @@ void show_regs(struct pt_regs * regs)
 
 static int show_trace_cb(struct stackframe *frame, void *data)
 {
+       const char *loglvl = data;
+
        if (kernel_text_address(frame->pc))
-               pr_cont(" [<%08lx>] %pB\n", frame->pc, (void *)frame->pc);
+               printk("%s [<%08lx>] %pB\n",
+                       loglvl, frame->pc, (void *)frame->pc);
        return 0;
 }
 
-void show_trace(struct task_struct *task, unsigned long *sp)
+static void show_trace(struct task_struct *task, unsigned long *sp,
+                      const char *loglvl)
 {
        if (!sp)
                sp = stack_pointer(task);
 
-       pr_info("Call Trace:\n");
-       walk_stackframe(sp, show_trace_cb, NULL);
+       printk("%sCall Trace:\n", loglvl);
+       walk_stackframe(sp, show_trace_cb, (void *)loglvl);
 }
 
 #define STACK_DUMP_ENTRY_SIZE 4
 #define STACK_DUMP_LINE_SIZE 32
 static size_t kstack_depth_to_print = CONFIG_PRINT_STACK_DEPTH;
 
-void show_stack(struct task_struct *task, unsigned long *sp)
+void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
 {
        size_t len;
 
@@ -507,11 +511,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
        len = min((-(size_t)sp) & (THREAD_SIZE - STACK_DUMP_ENTRY_SIZE),
                  kstack_depth_to_print * STACK_DUMP_ENTRY_SIZE);
 
-       pr_info("Stack:\n");
-       print_hex_dump(KERN_INFO, " ", DUMP_PREFIX_NONE,
+       printk("%sStack:\n", loglvl);
+       print_hex_dump(loglvl, " ", DUMP_PREFIX_NONE,
                       STACK_DUMP_LINE_SIZE, STACK_DUMP_ENTRY_SIZE,
                       sp, len, false);
-       show_trace(task, sp);
+       show_trace(task, sp, loglvl);
 }
 
 DEFINE_SPINLOCK(die_lock);
@@ -530,7 +534,7 @@ void die(const char * str, struct pt_regs * regs, long err)
        pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter, pr);
        show_regs(regs);
        if (!user_mode(regs))
-               show_stack(NULL, (unsigned long*)regs->areg[1]);
+               show_stack(NULL, (unsigned long *)regs->areg[1], KERN_INFO);
 
        add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
        spin_unlock_irq(&die_lock);
index 95ad1e7..1a7538c 100644 (file)
  */
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/ptrace.h>
 #include <asm/current.h>
 #include <asm/asm-offsets.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/thread_info.h>
index b27359e..2369433 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/memblock.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
+#include <linux/pgtable.h>
 
 #include <asm/bootparam.h>
 #include <asm/mmu_context.h>
@@ -31,7 +32,6 @@
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 /* 
  * Note:
index e7172bd..c4decc7 100644 (file)
@@ -74,7 +74,7 @@ void do_page_fault(struct pt_regs *regs)
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 retry:
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
 
        if (!vma)
@@ -130,7 +130,7 @@ good_area:
                if (fault & VM_FAULT_RETRY) {
                        flags |= FAULT_FLAG_TRIED;
 
-                        /* No need to up_read(&mm->mmap_sem) as we would
+                        /* No need to mmap_read_unlock(mm) as we would
                         * have already released it in __lock_page_or_retry
                         * in mm/filemap.c.
                         */
@@ -139,7 +139,7 @@ good_area:
                }
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
        if (flags & VM_FAULT_MAJOR)
                perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address);
@@ -152,7 +152,7 @@ good_area:
         * Fix it, but check if it's kernel or user first..
         */
 bad_area:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (user_mode(regs)) {
                current->thread.bad_vaddr = address;
                current->thread.error_code = is_write;
@@ -167,7 +167,7 @@ bad_area:
         * us unable to handle the page fault gracefully.
         */
 out_of_memory:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (!user_mode(regs))
                bad_page_fault(regs, address, SIGKILL);
        else
@@ -175,7 +175,7 @@ out_of_memory:
        return;
 
 do_sigbus:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Send a sigbus, regardless of whether we were in kernel
         * or user mode.
index 99b5ad1..673196f 100644 (file)
@@ -86,6 +86,6 @@ void __init kmap_init(void)
        BUILD_BUG_ON(PKMAP_BASE < TLBTEMP_BASE_1 + TLBTEMP_SIZE);
        /* cache the first kmap pte */
        kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
-       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
+       kmap_pte = virt_to_kpte(kmap_vstart);
        kmap_waitqueues_init();
 }
index 9ea3f21..a400188 100644 (file)
@@ -7,9 +7,9 @@
 
 #include <linux/io.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 
 static void __iomem *xtensa_ioremap(unsigned long paddr, unsigned long size,
                                    pgprot_t prot)
index e3baa21..1fef24d 100644 (file)
 void __init kasan_early_init(void)
 {
        unsigned long vaddr = KASAN_SHADOW_START;
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-       pmd_t *pmd = pmd_offset(pud, vaddr);
+       pmd_t *pmd = pmd_off_k(vaddr);
        int i;
 
        for (i = 0; i < PTRS_PER_PTE; ++i)
@@ -43,10 +40,7 @@ static void __init populate(void *start, void *end)
        unsigned long n_pmds = n_pages / PTRS_PER_PTE;
        unsigned long i, j;
        unsigned long vaddr = (unsigned long)start;
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-       pmd_t *pmd = pmd_offset(pud, vaddr);
+       pmd_t *pmd = pmd_off_k(vaddr);
        pte_t *pte = memblock_alloc(n_pages * sizeof(pte_t), PAGE_SIZE);
 
        if (!pte)
index 6aa036c..25cd67d 100644 (file)
@@ -14,8 +14,8 @@
 
 
 #include <linux/linkage.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/asmmacro.h>
 #include <asm/cacheasm.h>
 #include <asm/tlbflush.h>
index 37e478a..fd2193d 100644 (file)
 #if defined(CONFIG_HIGHMEM)
 static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages)
 {
-       pgd_t *pgd = pgd_offset_k(vaddr);
-       p4d_t *p4d = p4d_offset(pgd, vaddr);
-       pud_t *pud = pud_offset(p4d, vaddr);
-       pmd_t *pmd = pmd_offset(pud, vaddr);
+       pmd_t *pmd = pmd_off_k(vaddr);
        pte_t *pte;
        unsigned long i;
 
index 5287ab9..4da23e7 100644 (file)
@@ -15,8 +15,7 @@
 #include <linux/nls.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_data/x86/apple.h>
-
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "internal.h"
 
index 2d8b9b9..42c672f 100644 (file)
@@ -212,7 +212,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
                mm = alloc->vma_vm_mm;
 
        if (mm) {
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = alloc->vma;
        }
 
@@ -270,7 +270,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
                trace_binder_alloc_page_end(alloc, index);
        }
        if (mm) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                mmput(mm);
        }
        return 0;
@@ -303,7 +303,7 @@ err_page_ptr_cleared:
        }
 err_no_vma:
        if (mm) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                mmput(mm);
        }
        return vma ? -ENOMEM : -ESRCH;
@@ -932,8 +932,8 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
        mm = alloc->vma_vm_mm;
        if (!mmget_not_zero(mm))
                goto err_mmget;
-       if (!down_read_trylock(&mm->mmap_sem))
-               goto err_down_read_mmap_sem_failed;
+       if (!mmap_read_trylock(mm))
+               goto err_mmap_read_lock_failed;
        vma = binder_alloc_get_vma(alloc);
 
        list_lru_isolate(lru, item);
@@ -946,7 +946,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
 
                trace_binder_unmap_user_end(alloc, index);
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 
        trace_binder_unmap_kernel_start(alloc, index);
@@ -960,7 +960,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
        mutex_unlock(&alloc->mutex);
        return LRU_REMOVED_RETRY;
 
-err_down_read_mmap_sem_failed:
+err_mmap_read_lock_failed:
        mmput_async(mm);
 err_mmget:
 err_page_already_freed:
index 8fbd36e..f4ad7ce 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/pgtable.h>
 #include <asm/io.h>
 #include <asm/string.h>
 #include <asm/page.h>
@@ -40,7 +41,6 @@
 #include <asm/idprom.h>
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/pgtable.h>
 #endif
 
 #if defined(CONFIG_ATM_FORE200E_USE_TASKLET) /* defer interrupt work to a tasklet */
index bb98b81..9dd85be 100644 (file)
@@ -519,7 +519,7 @@ static void dpm_watchdog_handler(struct timer_list *t)
        struct dpm_watchdog *wd = from_timer(wd, t, timer);
 
        dev_emerg(wd->dev, "**** DPM device timeout ****\n");
-       show_stack(wd->tsk, NULL);
+       show_stack(wd->tsk, NULL, KERN_EMERG);
        panic("%s %s: unrecoverable failure\n",
                dev_driver_string(wd->dev), dev_name(wd->dev));
 }
index 6004306..0e73480 100644 (file)
 #include <linux/bitops.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 
 #include <asm/setup.h>
 #include <asm/amigahw.h>
-#include <asm/pgtable.h>
 
 #include <linux/zorro.h>
 
index 4709864..00ff5fc 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include "agp.h"
 
 struct agp_front_data agp_fe;
index 9e84239..3ffbb1c 100644 (file)
@@ -42,7 +42,6 @@
 #ifdef CONFIG_X86
 #include <asm/set_memory.h>
 #endif
-#include <asm/pgtable.h>
 #include "agp.h"
 
 __u32 *agp_gatt_table;
index e5e5333..cce2af5 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/list.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 
 /*
index 7d58322..0fae333 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/numa.h>
 #include <linux/refcount.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <linux/atomic.h>
 #include <asm/tlbflush.h>
 #include <asm/uncached.h>
@@ -65,7 +64,7 @@ enum mspec_page_type {
  * This structure is shared by all vma's that are split off from the
  * original vma when split_vma()'s are done.
  *
- * The refcnt is incremented atomically because mm->mmap_sem does not
+ * The refcnt is incremented atomically because mm->mmap_lock does not
  * protect in fork case where multiple tasks share the vma_data.
  */
 struct vma_data {
index 4264e64..b45f851 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <linux/dma-resv.h>
 #include <linux/export.h>
+#include <linux/mm.h>
 #include <linux/sched/mm.h>
 
 /**
@@ -109,7 +110,7 @@ static int __init dma_resv_lockdep(void)
 
        dma_resv_init(&obj);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        ww_acquire_init(&ctx, &reservation_ww_class);
        ret = dma_resv_lock(&obj, &ctx);
        if (ret == -EDEADLK)
@@ -118,7 +119,7 @@ static int __init dma_resv_lockdep(void)
        fs_reclaim_release(GFP_KERNEL);
        ww_mutex_unlock(&obj.lock);
        ww_acquire_fini(&ctx);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        
        mmput(mm);
 
index b876373..3359ae2 100644 (file)
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/pgtable.h>
 
 #include <asm/cacheflush.h>
 #include <asm/efi.h>
 #include <asm/mmu.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 #if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
 #include <asm/ptdump.h>
index 9357d6b..7f1657b 100644 (file)
@@ -54,7 +54,7 @@ struct mm_struct efi_mm = {
        .mm_rb                  = RB_ROOT,
        .mm_users               = ATOMIC_INIT(2),
        .mm_count               = ATOMIC_INIT(1),
-       .mmap_sem               = __RWSEM_INITIALIZER(efi_mm.mmap_sem),
+       MMAP_LOCK_INITIALIZER(efi_mm)
        .page_table_lock        = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
        .mmlist                 = LIST_HEAD_INIT(efi_mm.mmlist),
        .cpu_bitmap             = { [BITS_TO_LONGS(NR_CPUS)] = 0},
index 3f2b695..53b4126 100644 (file)
@@ -186,7 +186,7 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s
  * disabled. The memory must be pinned and mapped to the hardware when
  * this is called in hqd_load functions, so it should never fault in
  * the first place. This resolves a circular lock dependency involving
- * four locks, including the DQM lock and mmap_sem.
+ * four locks, including the DQM lock and mmap_lock.
  */
 #define read_user_wptr(mmptr, wptr, dst)                               \
        ({                                                              \
index 0b7e787..c694473 100644 (file)
@@ -237,7 +237,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
                             CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
        WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, data);
 
-       /* read_user_ptr may take the mm->mmap_sem.
+       /* read_user_ptr may take the mm->mmap_lock.
         * release srbm_mutex to avoid circular dependency between
         * srbm_mutex->mm_sem->reservation_ww_class_mutex->srbm_mutex.
         */
index ccd635b..2f4bdc8 100644 (file)
@@ -224,7 +224,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
                             CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
        WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, data);
 
-       /* read_user_ptr may take the mm->mmap_sem.
+       /* read_user_ptr may take the mm->mmap_lock.
         * release srbm_mutex to avoid circular dependency between
         * srbm_mutex->mm_sem->reservation_ww_class_mutex->srbm_mutex.
         */
index 68e6e1b..b91b517 100644 (file)
@@ -1393,9 +1393,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
         * concurrently and the queues are actually stopped
         */
        if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm)) {
-               down_write(&current->mm->mmap_sem);
+               mmap_write_lock(current->mm);
                is_invalid_userptr = atomic_read(&mem->invalid);
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
        }
 
        mutex_lock(&mem->lock);
index 9cbecd5..e59c01a 100644 (file)
@@ -910,7 +910,7 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)
                goto out_free_ranges;
        }
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, start);
        if (unlikely(!vma || start < vma->vm_start)) {
                r = -EFAULT;
@@ -921,15 +921,15 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, struct page **pages)
                r = -EPERM;
                goto out_unlock;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        timeout = jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
 
 retry:
        range->notifier_seq = mmu_interval_read_begin(&bo->notifier);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        r = hmm_range_fault(range);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (unlikely(r)) {
                /*
                 * FIXME: This timeout should encompass the retry from
@@ -954,7 +954,7 @@ retry:
        return 0;
 
 out_unlock:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 out_free_pfns:
        kvfree(range->hmm_pfns);
 out_free_ranges:
index 15476fc..a9583b9 100644 (file)
@@ -901,7 +901,7 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid,
 
        memset(&memory_exception_data, 0, sizeof(memory_exception_data));
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, address);
 
        memory_exception_data.gpu_id = dev->id;
@@ -924,7 +924,7 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid,
                        memory_exception_data.failure.NoExecute = 0;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 
        pr_debug("notpresent %d, noexecute %d, readonly %d\n",
index 56197ae..4391e24 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/pci.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
+#include <linux/pgtable.h>
 
 #if defined(__ia64__)
 #include <linux/efi.h>
@@ -44,7 +45,6 @@
 #endif
 #include <linux/mem_encrypt.h>
 
-#include <asm/pgtable.h>
 
 #include <drm/drm_agpsupport.h>
 #include <drm/drm_device.h>
index dc9ef30..701f399 100644 (file)
@@ -661,7 +661,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj)
        struct etnaviv_gem_userptr *userptr = &etnaviv_obj->userptr;
        int ret, pinned = 0, npages = etnaviv_obj->base.size >> PAGE_SHIFT;
 
-       might_lock_read(&current->mm->mmap_sem);
+       might_lock_read(&current->mm->mmap_lock);
 
        if (userptr->mm != current->mm)
                return -EPERM;
index 70f5f82..fe45bd4 100644 (file)
@@ -93,7 +93,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
                struct mm_struct *mm = current->mm;
                struct vm_area_struct *vma;
 
-               if (down_write_killable(&mm->mmap_sem)) {
+               if (mmap_write_lock_killable(mm)) {
                        addr = -EINTR;
                        goto err;
                }
@@ -103,7 +103,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
                                pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
                else
                        addr = -ENOMEM;
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
                if (IS_ERR_VALUE(addr))
                        goto err;
        }
index 33776b3..c31a674 100644 (file)
@@ -200,10 +200,10 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)
        if (IS_ERR(mn))
                err = PTR_ERR(mn);
 
-       down_write(&mm->mm->mmap_sem);
+       mmap_write_lock(mm->mm);
        mutex_lock(&mm->i915->mm_lock);
        if (mm->mn == NULL && !err) {
-               /* Protected by mmap_sem (write-lock) */
+               /* Protected by mmap_lock (write-lock) */
                err = __mmu_notifier_register(&mn->mn, mm->mm);
                if (!err) {
                        /* Protected by mm_lock */
@@ -217,7 +217,7 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)
                err = 0;
        }
        mutex_unlock(&mm->i915->mm_lock);
-       up_write(&mm->mm->mmap_sem);
+       mmap_write_unlock(mm->mm);
 
        if (mn && !IS_ERR(mn))
                kfree(mn);
@@ -468,7 +468,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
                if (mmget_not_zero(mm)) {
                        while (pinned < npages) {
                                if (!locked) {
-                                       down_read(&mm->mmap_sem);
+                                       mmap_read_lock(mm);
                                        locked = 1;
                                }
                                ret = pin_user_pages_remote
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
                                pinned += ret;
                        }
                        if (locked)
-                               up_read(&mm->mmap_sem);
+                               mmap_read_unlock(mm);
                        mmput(mm);
                }
        }
@@ -522,8 +522,8 @@ __i915_gem_userptr_get_pages_schedule(struct drm_i915_gem_object *obj)
 
        /* Spawn a worker so that we can acquire the
         * user pages without holding our mutex. Access
-        * to the user pages requires mmap_sem, and we have
-        * a strict lock ordering of mmap_sem, struct_mutex -
+        * to the user pages requires mmap_lock, and we have
+        * a strict lock ordering of mmap_lock, struct_mutex -
         * we already hold struct_mutex here and so cannot
         * call gup without encountering a lock inversion.
         *
index b6376b2..43039dc 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/mm.h>
 #include <linux/io-mapping.h>
 
-#include <asm/pgtable.h>
 
 #include "i915_drv.h"
 
index 75c60c2..665bb07 100644 (file)
@@ -3676,7 +3676,7 @@ static int read_properties_unlocked(struct i915_perf *perf,
  * buffered data written by the GPU besides periodic OA metrics.
  *
  * Note we copy the properties from userspace outside of the i915 perf
- * mutex to avoid an awkward lockdep with mmap_sem.
+ * mutex to avoid an awkward lockdep with mmap_lock.
  *
  * Most of the implementation details are handled by
  * i915_perf_open_ioctl_locked() after taking the &perf->lock
index 22f054f..ba9f935 100644 (file)
@@ -175,10 +175,10 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
         */
 
        mm = get_task_mm(current);
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        if (!cli->svm.svmm) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                return -EINVAL;
        }
 
@@ -205,7 +205,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
         */
        args->result = 0;
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 
        return 0;
@@ -355,7 +355,7 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
        if (ret)
                goto out_free;
 
-       down_write(&current->mm->mmap_sem);
+       mmap_write_lock(current->mm);
        svmm->notifier.ops = &nouveau_mn_ops;
        ret = __mmu_notifier_register(&svmm->notifier, current->mm);
        if (ret)
@@ -364,12 +364,12 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
 
        cli->svm.svmm = svmm;
        cli->svm.cli = cli;
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        mutex_unlock(&cli->mutex);
        return 0;
 
 out_mm_unlock:
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
 out_free:
        mutex_unlock(&cli->mutex);
        kfree(svmm);
@@ -571,9 +571,9 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
                        return -EBUSY;
 
                range.notifier_seq = mmu_interval_read_begin(range.notifier);
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                ret = hmm_range_fault(&range);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                if (ret) {
                        /*
                         * FIXME: the input PFN_REQ flags are destroyed on
@@ -705,18 +705,18 @@ nouveau_svm_fault(struct nvif_notify *notify)
                /* Intersect fault window with the CPU VMA, cancelling
                 * the fault if the address is invalid.
                 */
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = find_vma_intersection(mm, start, limit);
                if (!vma) {
                        SVMM_ERR(svmm, "wndw %016llx-%016llx", start, limit);
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        mmput(mm);
                        nouveau_svm_fault_cancel_fault(svm, buffer->fault[fi]);
                        continue;
                }
                start = max_t(u64, start, vma->vm_start);
                limit = min_t(u64, limit, vma->vm_end);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                SVMM_DBG(svmm, "wndw %016llx-%016llx", start, limit);
 
                if (buffer->fault[fi]->addr != start) {
index 0d0ab8e..cc31d18 100644 (file)
@@ -196,12 +196,12 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
                p->vm_bos = radeon_vm_get_bos(p->rdev, p->ib.vm,
                                              &p->validated);
        if (need_mmap_lock)
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
 
        r = radeon_bo_list_validate(p->rdev, &p->ticket, &p->validated, p->ring);
 
        if (need_mmap_lock)
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
        return r;
 }
index 068c3e5..3c8f570 100644 (file)
@@ -342,17 +342,17 @@ int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
        }
 
        if (args->flags & RADEON_GEM_USERPTR_VALIDATE) {
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                r = radeon_bo_reserve(bo, true);
                if (r) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        goto release_object;
                }
 
                radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_GTT);
                r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
                radeon_bo_unreserve(bo);
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                if (r)
                        goto release_object;
        }
index 0ad30b1..a43aa72 100644 (file)
@@ -58,7 +58,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
                goto out_clear;
 
        /*
-        * If possible, avoid waiting for GPU with mmap_sem
+        * If possible, avoid waiting for GPU with mmap_lock
         * held.  We only do this if the fault allows retry and this
         * is the first attempt.
         */
@@ -68,7 +68,7 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
                        goto out_unlock;
 
                ttm_bo_get(bo);
-               up_read(&vmf->vma->vm_mm->mmap_sem);
+               mmap_read_unlock(vmf->vma->vm_mm);
                (void) dma_fence_wait(bo->moving, true);
                dma_resv_unlock(bo->base.resv);
                ttm_bo_put(bo);
@@ -131,20 +131,20 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
 {
        /*
         * Work around locking order reversal in fault / nopfn
-        * between mmap_sem and bo_reserve: Perform a trylock operation
+        * between mmap_lock and bo_reserve: Perform a trylock operation
         * for reserve, and if it fails, retry the fault after waiting
         * for the buffer to become unreserved.
         */
        if (unlikely(!dma_resv_trylock(bo->base.resv))) {
                /*
                 * If the fault allows retry and this is the first
-                * fault attempt, we try to release the mmap_sem
+                * fault attempt, we try to release the mmap_lock
                 * before waiting
                 */
                if (fault_flag_allow_retry_first(vmf->flags)) {
                        if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
                                ttm_bo_get(bo);
-                               up_read(&vmf->vma->vm_mm->mmap_sem);
+                               mmap_read_unlock(vmf->vma->vm_mm);
                                if (!dma_resv_lock_interruptible(bo->base.resv,
                                                                 NULL))
                                        dma_resv_unlock(bo->base.resv);
index 3b1e627..ccd2840 100644 (file)
@@ -429,7 +429,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
                                ALIGN(bcnt, PAGE_SIZE) / PAGE_SIZE,
                                PAGE_SIZE / sizeof(struct page *));
 
-               down_read(&owning_mm->mmap_sem);
+               mmap_read_lock(owning_mm);
                /*
                 * Note: this might result in redundent page getting. We can
                 * avoid this by checking dma_list to be 0 before calling
@@ -440,7 +440,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
                npages = get_user_pages_remote(owning_process, owning_mm,
                                user_virt, gup_num_pages,
                                flags, local_page_list, NULL, NULL);
-               up_read(&owning_mm->mmap_sem);
+               mmap_read_unlock(owning_mm);
 
                if (npages < 0) {
                        if (npages != -EAGAIN)
index 47794c8..69e4755 100644 (file)
@@ -835,12 +835,12 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
                        return;
 
                /*
-                * The umap_lock is nested under mmap_sem since it used within
+                * The umap_lock is nested under mmap_lock since it used within
                 * the vma_ops callbacks, so we have to clean the list one mm
                 * at a time to get the lock ordering right. Typically there
                 * will only be one mm, so no big deal.
                 */
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                if (!mmget_still_valid(mm))
                        goto skip_mm;
                mutex_lock(&ufile->umap_lock);
@@ -862,7 +862,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
                }
                mutex_unlock(&ufile->umap_lock);
        skip_mm:
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                mmput(mm);
        }
 }
index 14d2a90..24ca17b 100644 (file)
@@ -333,7 +333,7 @@ static void do_remove(struct mmu_rb_handler *handler,
 
 /*
  * Work queue function to remove all nodes that have been queued up to
- * be removed.  The key feature is that mm->mmap_sem is not being held
+ * be removed.  The key feature is that mm->mmap_lock is not being held
  * and the remove callback can sleep while taking it, if needed.
  */
 static void handle_remove(struct work_struct *work)
index e2fb71b..7e0b205 100644 (file)
@@ -380,7 +380,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start,
                unsigned long untagged_start = untagged_addr(start);
                struct vm_area_struct *vma;
 
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                /*
                 * FIXME: Ideally this would iterate over all the vmas that
                 * cover the memory, but for now it requires a single vma to
@@ -395,7 +395,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start,
                        access_flags |= IB_ACCESS_LOCAL_WRITE;
                }
 
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
        }
 
        return ib_umem_get(device, start, length, access_flags);
index b014422..ff87a67 100644 (file)
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/jiffies.h>
-#include <asm/pgtable.h>
 #include <linux/delay.h>
 #include <linux/export.h>
 #include <linux/uio.h>
+#include <linux/pgtable.h>
 
 #include <rdma/ib.h>
 
index 342e317..4c24e83 100644 (file)
@@ -106,18 +106,18 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages,
                goto bail;
        }
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        for (got = 0; got < num_pages; got += ret) {
                ret = pin_user_pages(start_page + got * PAGE_SIZE,
                                     num_pages - got,
                                     FOLL_LONGTERM | FOLL_WRITE | FOLL_FORCE,
                                     p + got, NULL);
                if (ret < 0) {
-                       up_read(&current->mm->mmap_sem);
+                       mmap_read_unlock(current->mm);
                        goto bail_release;
                }
        }
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        return 0;
 bail_release:
index bd9f944..760b254 100644 (file)
@@ -123,7 +123,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
        npages = PAGE_ALIGN(size + (addr & ~PAGE_MASK)) >> PAGE_SHIFT;
 
        uiomr->owning_mm = mm = current->mm;
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        locked = atomic64_add_return(npages, &current->mm->pinned_vm);
        lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
@@ -187,7 +187,7 @@ out:
        } else
                mmgrab(uiomr->owning_mm);
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        free_page((unsigned long) page_list);
        return ret;
 }
index 37853aa..f5d0e33 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
-#include <asm/pgtable.h>
 #include <rdma/uverbs_ioctl.h>
 #include "mmap.h"
 
index 6a413d7..7887f62 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
-#include <asm/pgtable.h>
 #include <rdma/uverbs_ioctl.h>
 
 #include "rxe.h"
index 8711778..34a910c 100644 (file)
@@ -394,7 +394,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)
        if (!writable)
                foll_flags |= FOLL_FORCE;
 
-       down_read(&mm_s->mmap_sem);
+       mmap_read_lock(mm_s);
 
        mlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
 
@@ -438,7 +438,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)
                num_pages -= got;
        }
 out_sem_up:
-       up_read(&mm_s->mmap_sem);
+       mmap_read_unlock(mm_s);
 
        if (rv > 0)
                return umem;
index c8a7b6b..e4b025c 100644 (file)
@@ -485,7 +485,7 @@ static void do_fault(struct work_struct *work)
                flags |= FAULT_FLAG_WRITE;
        flags |= FAULT_FLAG_REMOTE;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_extend_vma(mm, address);
        if (!vma || address < vma->vm_start)
                /* failed to get a vma in the right range */
@@ -497,7 +497,7 @@ static void do_fault(struct work_struct *work)
 
        ret = handle_mm_fault(vma, address, flags);
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        if (ret & VM_FAULT_ERROR)
                /* failed to service fault */
index a035ef9..6c87c80 100644 (file)
@@ -863,7 +863,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
                if (!mmget_not_zero(svm->mm))
                        goto bad_req;
 
-               down_read(&svm->mm->mmap_sem);
+               mmap_read_lock(svm->mm);
                vma = find_extend_vma(svm->mm, address);
                if (!vma || address < vma->vm_start)
                        goto invalid;
@@ -878,7 +878,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
 
                result = QI_RESP_SUCCESS;
        invalid:
-               up_read(&svm->mm->mmap_sem);
+               mmap_read_unlock(svm->mm);
                mmput(svm->mm);
        bad_req:
                /* Accounting for major/minor faults? */
index eb3adfb..d4759db 100644 (file)
@@ -9,10 +9,10 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 #include <asm/prom.h>
 #include <linux/adb.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/hydra.h>
 #include <asm/irq.h>
 #include <linux/init.h>
index 74bf293..eab7e83 100644 (file)
@@ -16,8 +16,8 @@
 #include <linux/init.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
+#include <linux/pgtable.h>
 #include <asm/prom.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/machdep.h>
 #include <asm/pmac_feature.h>
index 8450d7c..73e6ae8 100644 (file)
@@ -50,9 +50,9 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/uaccess.h>
+#include <linux/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/sections.h>
 #include <asm/irq.h>
 #ifdef CONFIG_PPC_PMAC
index 53af26a..79ba15a 100644 (file)
@@ -13,9 +13,9 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/pgtable.h>
 #include <asm/io.h>
 #include <linux/ioport.h>
-#include <asm/pgtable.h>
 #include <asm/page.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
index 1139a5a..5125798 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/videodev2.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "btcx-risc.h"
 
index fc87080..4af7282 100644 (file)
@@ -20,8 +20,8 @@
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <media/v4l2-ioctl.h>
 
 #include "bttvp.h"
index 38d3088..7ab13eb 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/videodev2.h>
 #include <linux/slab.h>
 
-#include <asm/pgtable.h>
 
 #include <media/v4l2-dev.h>
 #include <media/v4l2-common.h>
index 9e8eb45..3dc17eb 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/div64.h>
 #include <media/v4l2-common.h>
index 2686f03..5c91fc3 100644 (file)
@@ -535,7 +535,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b)
        MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
 
        if (b->memory == V4L2_MEMORY_MMAP)
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
 
        videobuf_queue_lock(q);
        retval = -EBUSY;
@@ -622,7 +622,7 @@ done:
        videobuf_queue_unlock(q);
 
        if (b->memory == V4L2_MEMORY_MMAP)
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
        return retval;
 }
index aeb2f49..52312ce 100644 (file)
@@ -169,7 +169,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
        mem->size = PAGE_ALIGN(vb->size + offset);
        ret = -EINVAL;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma(mm, untagged_baddr);
        if (!vma)
@@ -201,7 +201,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
        }
 
 out_up:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        return ret;
 }
index 13b65ed..46ff19d 100644 (file)
 #include <linux/sched/mm.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 
 #include <linux/dma-mapping.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
 #include <linux/scatterlist.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include <media/videobuf-dma-sg.h>
 
@@ -200,9 +200,9 @@ static int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
 {
        int ret;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        ret = videobuf_dma_init_user_locked(dma, direction, data, size);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        return ret;
 }
@@ -533,7 +533,7 @@ static int __videobuf_iolock(struct videobuf_queue *q,
                } else {
                        /* NOTE: HACK: videobuf_iolock on V4L2_MEMORY_MMAP
                        buffers can only be called from videobuf_qbuf
-                       we take current->mm->mmap_sem there, to prevent
+                       we take current->mm->mmap_lock there, to prevent
                        locking inversion, so don't take it here */
 
                        err = videobuf_dma_init_user_locked(&mem->dma,
index f8bd5a3..9b24437 100644 (file)
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/pgtable.h>
 
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include <media/videobuf-vmalloc.h>
 
index 258c43a..2a1783f 100644 (file)
@@ -207,7 +207,7 @@ static int get_vma_info(struct mm_struct *mm, u64 addr,
        struct vm_area_struct *vma = NULL;
        int rc = 0;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        vma = find_vma(mm, addr);
        if (!vma) {
@@ -218,7 +218,7 @@ static int get_vma_info(struct mm_struct *mm, u64 addr,
        *vma_start = vma->vm_start;
        *vma_end = vma->vm_end;
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return rc;
 }
 
@@ -245,9 +245,8 @@ int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64 flags)
             dar += page_size) {
                if (dar < vma_start || dar >= vma_end) {
                        /*
-                        * We don't hold the mm->mmap_sem semaphore
-                        * while iterating, since the semaphore is
-                        * required by one of the lower-level page
+                        * We don't hold mm->mmap_lock while iterating, since
+                        * the lock is required by one of the lower-level page
                         * fault processing functions and it could
                         * create a deadlock.
                         *
index 2297e6f..01153b7 100644 (file)
@@ -321,7 +321,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx)
                return;
        }
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                for (ea = vma->vm_start; ea < vma->vm_end;
                                ea = next_segment(ea, slb.vsid)) {
@@ -336,7 +336,7 @@ static void cxl_prefault_vma(struct cxl_context *ctx)
                        last_esid = slb.esid;
                }
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        mmput(mm);
 }
index 60460a0..77c21ca 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "genwqe_driver.h"
 #include "card_base.h"
index 4b713a8..b152111 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/uaccess.h>
 #include <linux/security.h>
 #include <linux/prefetch.h>
-#include <asm/pgtable.h>
 #include "gru.h"
 #include "grutables.h"
 #include "grulib.h"
@@ -43,7 +42,7 @@ static inline int is_gru_paddr(unsigned long paddr)
 }
 
 /*
- * Find the vma of a GRU segment. Caller must hold mmap_sem.
+ * Find the vma of a GRU segment. Caller must hold mmap_lock.
  */
 struct vm_area_struct *gru_find_vma(unsigned long vaddr)
 {
@@ -59,7 +58,7 @@ struct vm_area_struct *gru_find_vma(unsigned long vaddr)
  * Find and lock the gts that contains the specified user vaddr.
  *
  * Returns:
- *     - *gts with the mmap_sem locked for read and the GTS locked.
+ *     - *gts with the mmap_lock locked for read and the GTS locked.
  *     - NULL if vaddr invalid OR is not a valid GSEG vaddr.
  */
 
@@ -69,14 +68,14 @@ static struct gru_thread_state *gru_find_lock_gts(unsigned long vaddr)
        struct vm_area_struct *vma;
        struct gru_thread_state *gts = NULL;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = gru_find_vma(vaddr);
        if (vma)
                gts = gru_find_thread_state(vma, TSID(vaddr, vma));
        if (gts)
                mutex_lock(&gts->ts_ctxlock);
        else
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        return gts;
 }
 
@@ -86,7 +85,7 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)
        struct vm_area_struct *vma;
        struct gru_thread_state *gts = ERR_PTR(-EINVAL);
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        vma = gru_find_vma(vaddr);
        if (!vma)
                goto err;
@@ -95,11 +94,11 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)
        if (IS_ERR(gts))
                goto err;
        mutex_lock(&gts->ts_ctxlock);
-       downgrade_write(&mm->mmap_sem);
+       mmap_write_downgrade(mm);
        return gts;
 
 err:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return gts;
 }
 
@@ -109,7 +108,7 @@ err:
 static void gru_unlock_gts(struct gru_thread_state *gts)
 {
        mutex_unlock(&gts->ts_ctxlock);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 }
 
 /*
@@ -199,7 +198,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
  * Only supports Intel large pages (2MB only) on x86_64.
  *     ZZZ - hugepage support is incomplete
  *
- * NOTE: mmap_sem is already held on entry to this function. This
+ * NOTE: mmap_lock is already held on entry to this function. This
  * guarantees existence of the page tables.
  */
 static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
@@ -570,14 +569,14 @@ static irqreturn_t gru_intr(int chiplet, int blade)
                }
 
                /*
-                * This is running in interrupt context. Trylock the mmap_sem.
+                * This is running in interrupt context. Trylock the mmap_lock.
                 * If it fails, retry the fault in user context.
                 */
                gts->ustats.fmm_tlbmiss++;
                if (!gts->ts_force_cch_reload &&
-                                       down_read_trylock(&gts->ts_mm->mmap_sem)) {
+                                       mmap_read_trylock(gts->ts_mm)) {
                        gru_try_dropin(gru, gts, tfh, NULL);
-                       up_read(&gts->ts_mm->mmap_sem);
+                       mmap_read_unlock(gts->ts_mm);
                } else {
                        tfh_user_polling_mode(tfh);
                        STAT(intr_mm_lock_failed);
index 9d04231..93bb49d 100644 (file)
@@ -135,7 +135,7 @@ static int gru_create_new_context(unsigned long arg)
        if (!(req.options & GRU_OPT_MISS_MASK))
                req.options |= GRU_OPT_MISS_FMM_INTR;
 
-       down_write(&current->mm->mmap_sem);
+       mmap_write_lock(current->mm);
        vma = gru_find_vma(req.gseg);
        if (vma) {
                vdata = vma->vm_private_data;
@@ -146,7 +146,7 @@ static int gru_create_new_context(unsigned long arg)
                vdata->vd_tlb_preload_count = req.tlb_preload_count;
                ret = 0;
        }
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
 
        return ret;
 }
index 73c67e5..da0bee1 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/notifier.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/ubi.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include "ubi-media.h"
 
index 50fb663..ef512cf 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/route.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
+#include <linux/pgtable.h>
 #include <asm/irq.h>
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
@@ -35,7 +36,6 @@
 
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/pgtable.h>
 #ifdef CONFIG_HP300
 #include <asm/blinken.h>
 #endif
index 1381a47..e10aceb 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/errno.h>
+#include <linux/pgtable.h>
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
 #include <linux/route.h>
@@ -24,7 +25,6 @@
 #include <linux/skbuff.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 
 #include "hplance.h"
 
index 72abd3f..3f2e4cd 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
 #include <linux/route.h>
@@ -24,7 +25,6 @@
 #include <linux/skbuff.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/mvme147hw.h>
 
 /* We have 32K of RAM for the init block and buffers. This places
index da7e3d4..e1fde58 100644 (file)
@@ -37,12 +37,12 @@ static const char version[] =
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
+#include <linux/pgtable.h>
 
 #include <asm/cacheflush.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/dvma.h>
 #include <asm/idprom.h>
 #include <asm/machines.h>
index a21b2e6..ddece27 100644 (file)
@@ -94,10 +94,10 @@ static char lancestr[] = "LANCE";
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/pgtable.h>
 #include <asm/byteorder.h>     /* Used by the checksum routines */
 #include <asm/idprom.h>
 #include <asm/prom.h>
index 3e3711b..1e4e402 100644 (file)
 #include <linux/bitrev.h>
 #include <linux/ethtool.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/machdep.h>
 #include <asm/pmac_feature.h>
 #include <asm/macio.h>
index b8ba2ab..9e5006e 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/bitrev.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/macio.h>
 
 #include "mace.h"
index ce85fea..b0d4b19 100644 (file)
@@ -40,9 +40,9 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/of_net.h>
+#include <linux/pgtable.h>
 
 #include <linux/vmalloc.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <linux/uaccess.h>
 
index 6e64989..b47490b 100644 (file)
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/mpc8260.h>
 #include <asm/cpm2.h>
 
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <linux/uaccess.h>
 
index 1582d82..8b51ee1 100644 (file)
@@ -32,8 +32,8 @@
 #include <linux/platform_device.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <linux/uaccess.h>
 #include <asm/mpc5xxx.h>
index bef676d..fc8c7cd 100644 (file)
 #include <linux/init.h>
 #include <linux/bitops.h>
 #include <linux/gfp.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
 static char version[] __initdata =
index f1d8492..03e0349 100644 (file)
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
+#include <linux/pgtable.h>
 
 #include <asm/bootinfo.h>
 #include <asm/bitops.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 
index 17243bb..eb8cf60 100644 (file)
@@ -31,8 +31,8 @@
 #include <linux/types.h>
 #include <linux/udp.h>
 #include <linux/workqueue.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
 #define DRIVER_NAME    "pxa168-eth"
index 8b018ed..ce3eca5 100644 (file)
@@ -36,9 +36,9 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 
 #include <asm/bootinfo.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/jazz.h>
index 1b5559a..776b7d2 100644 (file)
@@ -51,8 +51,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/bitrev.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/hwtest.h>
 #include <asm/dma.h>
index dda9ec7..afa166f 100644 (file)
@@ -35,9 +35,9 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/dma.h>
 
 static char xtsonic_string[] = "xtsonic";
index c5add0b..34fdbc6 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/pgtable.h>
 
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -34,7 +35,6 @@
 #include <asm/io.h>
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/pgtable.h>
 
 #include "sunbmac.h"
 
index f0fe7bb..54b53db 100644 (file)
@@ -52,7 +52,6 @@
 #endif
 #include <linux/uaccess.h>
 
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 
 #ifdef CONFIG_PCI
index 2102b95..577cd97 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
@@ -36,7 +37,6 @@
 #include <asm/openprom.h>
 #include <asm/oplib.h>
 #include <asm/auxio.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 
 #include "sunqe.h"
index ac27f3d..4d76952 100644 (file)
@@ -91,11 +91,11 @@ munmap_notify(struct notifier_block *self, unsigned long val, void *data)
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *mpnt;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        mpnt = find_vma(mm, addr);
        if (mpnt && mpnt->vm_file && (mpnt->vm_flags & VM_EXEC)) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                /* To avoid latency problems, we only process the current CPU,
                 * hoping that most samples for the task are on this CPU
                 */
@@ -103,7 +103,7 @@ munmap_notify(struct notifier_block *self, unsigned long val, void *data)
                return 0;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return 0;
 }
 
@@ -256,7 +256,7 @@ lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)
        unsigned long cookie = NO_COOKIE;
        struct vm_area_struct *vma;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) {
 
                if (addr < vma->vm_start || addr >= vma->vm_end)
@@ -276,7 +276,7 @@ lookup_dcookie(struct mm_struct *mm, unsigned long addr, off_t *offset)
 
        if (!vma)
                cookie = INVALID_COOKIE;
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return cookie;
 }
@@ -486,7 +486,7 @@ typedef enum {
 
 /* Sync one of the CPU's buffers into the global event buffer.
  * Here we need to go through each batch of samples punctuated
- * by context switch notes, taking the task's mmap_sem and doing
+ * by context switch notes, taking the task's mmap_lock and doing
  * lookup in task->mm->mmap to convert EIP into dcookie/offset
  * value.
  */
index 4147d22..3adfef2 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/of_device.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/upa.h>
 
index 37d252f..05de0ce 100644 (file)
@@ -21,7 +21,6 @@
 #include <asm/oplib.h>
 #include <asm/irq.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 
 #define DEBUG 1
 #ifdef DEBUG
index 0068963..461b3ba 100644 (file)
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
+#include <linux/pgtable.h>
 #include <asm/dma.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/byteorder.h>
 
 #include <scsi/scsi.h>
index 564b354..5853db3 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
 
index b6a0432..86f1da2 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
 
index a1f3e9e..65691c2 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 
 #include "../scsi.h"
 #include <scsi/scsi_host.h>
index 134f040..6e204a2 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/ecard.h>
-#include <asm/pgtable.h>
 
 #include "../scsi.h"
 #include <scsi/scsi_host.h>
index c795537..772a13e 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 
 #include "../scsi.h"
 #include <scsi/scsi_host.h>
index 2cf8895..0497ef6 100644 (file)
@@ -27,6 +27,7 @@
 /*#define UARTDELAY 1 */
 
 #include <linux/module.h>
+#include <linux/pgtable.h>
 
 MODULE_AUTHOR("Deanna Bonds, with _lots_ of help from Mark Salyzyn");
 MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
@@ -55,7 +56,6 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
 #include <linux/mutex.h>
 
 #include <asm/processor.h>     /* for boot_cpu_data */
-#include <asm/pgtable.h>
 #include <asm/io.h>            /* for virt_to_bus, etc. */
 
 #include <scsi/scsi.h>
index 11df0ec..727f8c8 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
 
index c48a73a..de71d24 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/slab.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/hardware.h>
 #include <asm/parisc-device.h>
index 35d3e32..43edf83 100644 (file)
@@ -20,9 +20,9 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/pgtable.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/macio.h>
 
index 74fb506..f9f8f49 100644 (file)
@@ -31,9 +31,9 @@
 #include <linux/reboot.h>
 #include <linux/spinlock.h>
 #include <linux/pci.h>
+#include <linux/pgtable.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
-#include <asm/pgtable.h>
 #include <asm/prom.h>
 #include <asm/irq.h>
 #include <asm/hydra.h>
index ca96d6d..869b8b0 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/mvme147hw.h>
 #include <asm/irq.h>
 
index d539bee..3790e8b 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/firmware.h>
+#include <linux/pgtable.h>
 
 #include <asm/byteorder.h>
 
@@ -37,7 +38,6 @@
 
 #include <asm/dma.h>
 #include <asm/ptrace.h>
-#include <asm/pgtable.h>
 #include <asm/oplib.h>
 #include <asm/io.h>
 #include <asm/irq.h>
index f839797..03d43f0 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/platform_device.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/delay.h>
 
index c6727bc..928c8ad 100644 (file)
@@ -34,9 +34,9 @@
 #include <linux/delay.h>
 #include <linux/zorro.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
index 8044510..c05a214 100644 (file)
@@ -555,7 +555,7 @@ static int set_name(struct ashmem_area *asma, void __user *name)
 
        /*
         * Holding the ashmem_mutex while doing a copy_from_user might cause
-        * an data abort which would try to access mmap_sem. If another
+        * an data abort which would try to access mmap_lock. If another
         * thread has invoked ashmem_mmap then it will be holding the
         * semaphore and will be waiting for ashmem_mutex, there by leading to
         * deadlock. We'll release the mutex and take the name to a local
@@ -586,7 +586,7 @@ static int get_name(struct ashmem_area *asma, void __user *name)
         * Have a local variable to which we'll copy the content
         * from asma with the lock held. Later we can copy this to the user
         * space safely without holding any locks. So even if we proceed to
-        * wait for mmap_sem, it won't lead to deadlock.
+        * wait for mmap_lock, it won't lead to deadlock.
         */
        char local_name[ASHMEM_NAME_LEN];
 
index a56c8f7..e85a99b 100644 (file)
@@ -2325,7 +2325,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
        int retval = 0;
 
        /*
-        * 'trylock' avoids circular dependency with current->mm->mmap_sem
+        * 'trylock' avoids circular dependency with current->mm->mmap_lock
         * and down-reading &dev->attach_lock should normally succeed without
         * contention unless the device is in the process of being attached
         * or detached.
index 7caabdd..8975346 100644 (file)
@@ -75,9 +75,9 @@ static int kpc_dma_transfer(struct dev_private_data *priv,
        }
 
        // Lock the user buffer pages in memory, and hold on to the page pointers (for the sglist)
-       down_read(&current->mm->mmap_sem);      /*  get memory map semaphore */
+       mmap_read_lock(current->mm);      /*  get memory map semaphore */
        rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL);
-       up_read(&current->mm->mmap_sem);        /*  release the semaphore */
+       mmap_read_unlock(current->mm);        /*  release the semaphore */
        if (rv != acd->page_count) {
                dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%ld)\n", rv);
                goto err_get_user_pages;
index 492b76c..c9e7df0 100644 (file)
@@ -982,9 +982,9 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
        }
 
        mutex_unlock(&bo->mutex);
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        vma = find_vma(current->mm, (unsigned long)userptr);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        if (!vma) {
                dev_err(atomisp_dev, "find_vma failed\n");
                kfree(bo->page_obj);
index dbed3f4..20b6fd7 100644 (file)
@@ -565,10 +565,10 @@ static int check_mem_type(unsigned long start, size_t num_pages)
        if (virt_addr_valid(start))
                return 0;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        rc = __check_mem_type(find_vma(mm, start),
                              start + num_pages * PAGE_SIZE);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return rc;
 }
index 477cdc1..7c95afa 100644 (file)
@@ -235,7 +235,7 @@ static void showacpu(void *dummy)
 
        raw_spin_lock_irqsave(&show_lock, flags);
        pr_info("CPU%d:\n", smp_processor_id());
-       show_stack(NULL, NULL);
+       show_stack(NULL, NULL, KERN_INFO);
        raw_spin_unlock_irqrestore(&show_lock, flags);
 }
 
index b28aa0d..c1be96b 100644 (file)
@@ -12,7 +12,7 @@
  * Fix bug in inverse translation. Stanislav Voronyi <stas@cnti.uanet.kharkov.ua>, Dec 1998
  *
  * In order to prevent the following circular lock dependency:
- *   &mm->mmap_sem --> cpu_hotplug.lock --> console_lock --> &mm->mmap_sem
+ *   &mm->mmap_lock --> cpu_hotplug.lock --> console_lock --> &mm->mmap_lock
  *
  * We cannot allow page fault to happen while holding the console_lock.
  * Therefore, all the userspace copy operations have to be done outside
index 3fc198f..7c07790 100644 (file)
@@ -1185,7 +1185,7 @@ reset_info_exit:
 
                /*
                 * We need to get memory_lock for each device, but devices
-                * can share mmap_sem, therefore we need to zap and hold
+                * can share mmap_lock, therefore we need to zap and hold
                 * the vma_lock for each device, and only then get each
                 * memory_lock.
                 */
@@ -1375,26 +1375,26 @@ static int vfio_pci_zap_and_vma_lock(struct vfio_pci_device *vdev, bool try)
 
        /*
         * Lock ordering:
-        * vma_lock is nested under mmap_sem for vm_ops callback paths.
+        * vma_lock is nested under mmap_lock for vm_ops callback paths.
         * The memory_lock semaphore is used by both code paths calling
         * into this function to zap vmas and the vm_ops.fault callback
         * to protect the memory enable state of the device.
         *
-        * When zapping vmas we need to maintain the mmap_sem => vma_lock
+        * When zapping vmas we need to maintain the mmap_lock => vma_lock
         * ordering, which requires using vma_lock to walk vma_list to
-        * acquire an mm, then dropping vma_lock to get the mmap_sem and
+        * acquire an mm, then dropping vma_lock to get the mmap_lock and
         * reacquiring vma_lock.  This logic is derived from similar
         * requirements in uverbs_user_mmap_disassociate().
         *
-        * mmap_sem must always be the top-level lock when it is taken.
+        * mmap_lock must always be the top-level lock when it is taken.
         * Therefore we can only hold the memory_lock write lock when
-        * vma_list is empty, as we'd need to take mmap_sem to clear
+        * vma_list is empty, as we'd need to take mmap_lock to clear
         * entries.  vma_list can only be guaranteed empty when holding
         * vma_lock, thus memory_lock is nested under vma_lock.
         *
         * This enables the vm_ops.fault callback to acquire vma_lock,
         * followed by memory_lock read lock, while already holding
-        * mmap_sem without risk of deadlock.
+        * mmap_lock without risk of deadlock.
         */
        while (1) {
                struct mm_struct *mm = NULL;
@@ -1422,17 +1422,17 @@ static int vfio_pci_zap_and_vma_lock(struct vfio_pci_device *vdev, bool try)
                mutex_unlock(&vdev->vma_lock);
 
                if (try) {
-                       if (!down_read_trylock(&mm->mmap_sem)) {
+                       if (!mmap_read_trylock(mm)) {
                                mmput(mm);
                                return 0;
                        }
                } else {
-                       down_read(&mm->mmap_sem);
+                       mmap_read_lock(mm);
                }
                if (mmget_still_valid(mm)) {
                        if (try) {
                                if (!mutex_trylock(&vdev->vma_lock)) {
-                                       up_read(&mm->mmap_sem);
+                                       mmap_read_unlock(mm);
                                        mmput(mm);
                                        return 0;
                                }
@@ -1454,7 +1454,7 @@ static int vfio_pci_zap_and_vma_lock(struct vfio_pci_device *vdev, bool try)
                        }
                        mutex_unlock(&vdev->vma_lock);
                }
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                mmput(mm);
        }
 }
index 391fafe..186acd8 100644 (file)
@@ -376,11 +376,11 @@ static int vfio_lock_acct(struct vfio_dma *dma, long npage, bool async)
        if (!mm)
                return -ESRCH; /* process exited */
 
-       ret = down_write_killable(&mm->mmap_sem);
+       ret = mmap_write_lock_killable(mm);
        if (!ret) {
                ret = __account_locked_vm(mm, abs(npage), npage > 0, dma->task,
                                          dma->lock_cap);
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
        }
 
        if (async)
@@ -452,7 +452,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
        if (prot & IOMMU_WRITE)
                flags |= FOLL_WRITE;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        ret = pin_user_pages_remote(NULL, mm, vaddr, 1, flags | FOLL_LONGTERM,
                                    page, NULL, NULL);
        if (ret == 1) {
@@ -475,7 +475,7 @@ retry:
                        ret = -EFAULT;
        }
 done:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return ret;
 }
 
index 0968361..40e2a57 100644 (file)
@@ -527,7 +527,7 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
        if (!npages)
                return -EINVAL;
 
-       down_read(&dev->mm->mmap_sem);
+       mmap_read_lock(dev->mm);
 
        locked = atomic64_add_return(npages, &dev->mm->pinned_vm);
        lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
@@ -580,7 +580,7 @@ out:
                vhost_vdpa_unmap(v, msg->iova, msg->size);
                atomic64_sub(npages, &dev->mm->pinned_vm);
        }
-       up_read(&dev->mm->mmap_sem);
+       mmap_read_unlock(dev->mm);
        free_page((unsigned long)page_list);
        return ret;
 }
index 00dddf6..504cda3 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/io.h>
 #include <linux/uaccess.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/gio_device.h>
 
 #include <video/newport.h>
index a3af495..09a9ad9 100644 (file)
@@ -30,7 +30,6 @@
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
-#include <asm/pgtable.h>
 
 #include "acornfb.h"
 
index 51f5d1c..f253daa 100644 (file)
@@ -58,7 +58,6 @@
 
 #include <asm/setup.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 
index c3a3e34..3df64a9 100644 (file)
@@ -42,7 +42,6 @@
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
-#include <asm/pgtable.h>
 
 #ifdef CONFIG_ZORRO
 #include <linux/zorro.h>
index 513f58f..42d37be 100644 (file)
@@ -47,7 +47,6 @@
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 
-#include <asm/pgtable.h>
 
 #ifdef __arm__
 #include <asm/mach-types.h>
index 75df6aa..030e85c 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/mm.h>
 
 #include <linux/sizes.h>
-#include <asm/pgtable.h>
 #include <mach/hardware.h>
 
 /* Platform_data reserved for unifb registers. */
index 009e5d2..bbb0f1d 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <asm/machvec.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include <asm/hd64461.h>
 #include <cpu/dac.h>
index e6ea853..f5a676b 100644 (file)
@@ -70,7 +70,6 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 #include <video/vga.h>
 #include <video/neomagic.h>
 
index 79ff14a..079a2a7 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/q40_master.h>
 #include <linux/fb.h>
 #include <linux/module.h>
-#include <asm/pgtable.h>
 
 #define Q40_PHYS_SCREEN_ADDR 0xFE800000
 
index aab312a..3c8ae87 100644 (file)
@@ -55,7 +55,6 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/pgtable.h>
 
 #include "savagefb.h"
 
index 0c142bc..77c5756 100644 (file)
@@ -59,7 +59,6 @@
 
 #include <asm/page.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 
 #include <asm/xen/hypervisor.h>
index 50651e5..64a9025 100644 (file)
@@ -625,7 +625,7 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,
                return -EFAULT;
        pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr);
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        vma = find_vma(current->mm, op.vaddr);
        if (!vma || vma->vm_ops != &gntdev_vmops)
                goto out_unlock;
@@ -639,7 +639,7 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,
        rv = 0;
 
  out_unlock:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        if (rv == 0 && copy_to_user(u, &op, sizeof(op)) != 0)
                return -EFAULT;
@@ -1014,7 +1014,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
                 * to the PTE from going stale.
                 *
                 * Since this vma's mappings can't be touched without the
-                * mmap_sem, and we are holding it now, there is no need for
+                * mmap_lock, and we are holding it now, there is no need for
                 * the notifier_range locking pattern.
                 */
                mmu_interval_read_begin(&map->notifier);
index 7b36b51..8d06bf1 100644 (file)
@@ -64,7 +64,6 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/interface.h>
 
-#include <asm/pgtable.h>
 #include <asm/sync_bitops.h>
 
 /* External tools reserve first few grant table entries. */
index b8ccb89..a250d11 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/moduleparam.h>
 
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 
@@ -277,7 +276,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
        if (rc || list_empty(&pagelist))
                goto out;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        {
                struct page *page = list_first_entry(&pagelist,
@@ -302,7 +301,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
 
 
 out_up:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
 out:
        free_page_list(&pagelist);
@@ -498,7 +497,7 @@ static long privcmd_ioctl_mmap_batch(
                }
        }
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        vma = find_vma(mm, m.addr);
        if (!vma ||
@@ -554,7 +553,7 @@ static long privcmd_ioctl_mmap_batch(
        BUG_ON(traverse_pages_block(m.num, sizeof(xen_pfn_t),
                                    &pagelist, mmap_batch_fn, &state));
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        if (state.global_error) {
                /* Write back errors in second pass. */
@@ -575,7 +574,7 @@ out:
        return ret;
 
 out_unlock:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        goto out;
 }
 
@@ -740,7 +739,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata)
        if (data->domid != DOMID_INVALID && data->domid != kdata.dom)
                return -EPERM;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
 
        vma = find_vma(mm, kdata.addr);
        if (!vma || vma->vm_ops != &privcmd_vm_ops) {
@@ -819,7 +818,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata)
        }
 
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        kfree(pfns);
 
        return rc;
index 8c4d05b..dc81e99 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/xen/hypervisor.h>
 
 #include <xen/xen.h>
index 9b2fbe6..2ba6998 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/semaphore.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/hypervisor.h>
 #include <xen/xenbus.h>
index 8a1650b..1537908 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/module.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/xen/hypervisor.h>
 #include <xen/xenbus.h>
 #include <xen/events.h>
index 6483f92..7e07913 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -520,7 +520,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
        ctx->mmap_size = nr_pages * PAGE_SIZE;
        pr_debug("attempting mmap of %lu bytes\n", ctx->mmap_size);
 
-       if (down_write_killable(&mm->mmap_sem)) {
+       if (mmap_write_lock_killable(mm)) {
                ctx->mmap_size = 0;
                aio_free_ring(ctx);
                return -EINTR;
@@ -529,7 +529,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
        ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size,
                                       PROT_READ | PROT_WRITE,
                                       MAP_SHARED, 0, &unused, NULL);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        if (IS_ERR((void *)ctx->mmap_base)) {
                ctx->mmap_size = 0;
                aio_free_ring(ctx);
index 478a0d8..7237f07 100644 (file)
@@ -393,7 +393,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
         *      of ->siglock provides a memory barrier.
         *
         * do_exit:
-        *      The caller holds mm->mmap_sem. This means that the task which
+        *      The caller holds mm->mmap_lock. This means that the task which
         *      uses this mm can't pass exit_mm(), so it can't exit or clear
         *      its ->mm.
         *
@@ -401,7 +401,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
         *      It does list_replace_rcu(&leader->tasks, &current->tasks),
         *      we must see either old or new leader, this does not matter.
         *      However, it can change p->sighand, so lock_task_sighand(p)
-        *      must be used. Since p->mm != NULL and we hold ->mmap_sem
+        *      must be used. Since p->mm != NULL and we hold ->mmap_lock
         *      it can't fail.
         *
         *      Note also that "g" can be the old leader with ->mm == NULL
@@ -445,12 +445,12 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
        core_state->dumper.task = tsk;
        core_state->dumper.next = NULL;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        if (!mm->core_state)
                core_waiters = zap_threads(tsk, mm, core_state, exit_code);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        if (core_waiters > 0) {
                struct core_thread *ptr;
index 02d0c5d..e6e8a9a 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -252,7 +252,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
                return -ENOMEM;
        vma_set_anonymous(vma);
 
-       if (down_write_killable(&mm->mmap_sem)) {
+       if (mmap_write_lock_killable(mm)) {
                err = -EINTR;
                goto err_free;
        }
@@ -274,11 +274,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
                goto err;
 
        mm->stack_vm = mm->total_vm = 1;
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        bprm->p = vma->vm_end - sizeof(void *);
        return 0;
 err:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 err_free:
        bprm->vma = NULL;
        vm_area_free(vma);
@@ -763,7 +763,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
                bprm->loader -= stack_shift;
        bprm->exec -= stack_shift;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        vm_flags = VM_STACK_FLAGS;
@@ -825,7 +825,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
                ret = -EFAULT;
 
 out_unlock:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 EXPORT_SYMBOL(setup_arg_pages);
@@ -1091,12 +1091,12 @@ static int exec_mmap(struct mm_struct *mm)
                /*
                 * Make sure that if there is a core dump in progress
                 * for the old mm, we get out and die instead of going
-                * through with the exec.  We must hold mmap_sem around
+                * through with the exec.  We must hold mmap_lock around
                 * checking core_state and changing tsk->mm.
                 */
-               down_read(&old_mm->mmap_sem);
+               mmap_read_lock(old_mm);
                if (unlikely(old_mm->core_state)) {
-                       up_read(&old_mm->mmap_sem);
+                       mmap_read_unlock(old_mm);
                        mutex_unlock(&tsk->signal->exec_update_mutex);
                        return -EINTR;
                }
@@ -1112,7 +1112,7 @@ static int exec_mmap(struct mm_struct *mm)
        vmacache_flush(tsk);
        task_unlock(tsk);
        if (old_mm) {
-               up_read(&old_mm->mmap_sem);
+               mmap_read_unlock(old_mm);
                BUG_ON(active_mm != old_mm);
                setmax_mm_hiwater_rss(&tsk->signal->maxrss, old_mm);
                mm_update_next_owner(old_mm);
index b4de9a0..60378dd 100644 (file)
@@ -79,7 +79,7 @@ out_unlock:
 /*
  * The lock ordering for ext2 DAX fault paths is:
  *
- * mmap_sem (MM)
+ * mmap_lock (MM)
  *   sb_start_pagefault (vfs, freeze)
  *     ext2_inode_info->dax_sem
  *       address_space->i_mmap_rwsem or page_lock (mutually exclusive in DAX)
index a29e8ea..c668f6b 100644 (file)
@@ -93,11 +93,11 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,
  * i_mmap_rwsem (inode->i_mmap_rwsem)!
  *
  * page fault path:
- * mmap_sem -> sb_start_pagefault -> i_mmap_sem (r) -> transaction start ->
+ * mmap_lock -> sb_start_pagefault -> i_mmap_sem (r) -> transaction start ->
  *   page lock -> i_data_sem (rw)
  *
  * buffered write path:
- * sb_start_write -> i_mutex -> mmap_sem
+ * sb_start_write -> i_mutex -> mmap_lock
  * sb_start_write -> i_mutex -> transaction start -> page lock ->
  *   i_data_sem (rw)
  *
@@ -107,7 +107,7 @@ static struct inode *ext4_get_journal_inode(struct super_block *sb,
  *   i_data_sem (rw)
  *
  * direct IO:
- * sb_start_write -> i_mutex -> mmap_sem
+ * sb_start_write -> i_mutex -> mmap_lock
  * sb_start_write -> i_mutex -> transaction start -> i_data_sem (rw)
  *
  * writepages:
index f3420a6..ef5313f 100644 (file)
@@ -187,7 +187,7 @@ out:
 }
 
 /*
- * Called under down_write(mmap_sem).
+ * Called under mmap_write_lock(mm).
  */
 
 #ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
index 9d4bd0d..9fb0dc6 100644 (file)
@@ -7186,7 +7186,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
                }
 
                ret = 0;
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                pret = pin_user_pages(ubuf, nr_pages,
                                      FOLL_WRITE | FOLL_LONGTERM,
                                      pages, vmas);
@@ -7204,7 +7204,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
                } else {
                        ret = pret < 0 ? pret : -EFAULT;
                }
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                if (ret) {
                        /*
                         * if we did partial map, or found file backed vmas,
index fd6ddfe..06b342d 100644 (file)
@@ -652,9 +652,9 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)
         * The following is done to give a different lockdep key to
         * @of->mutex for files which implement mmap.  This is a rather
         * crude way to avoid false positive lockdep warning around
-        * mm->mmap_sem - mmap nests @of->mutex under mm->mmap_sem and
+        * mm->mmap_lock - mmap nests @of->mutex under mm->mmap_lock and
         * reading /sys/block/sda/trace/act_mask grabs sr_mutex, under
-        * which mm->mmap_sem nests, while holding @of->mutex.  As each
+        * which mm->mmap_lock nests, while holding @of->mutex.  As each
         * open file has a separate mutex, it's okay as long as those don't
         * happen on the same file.  At this point, we can't easily give
         * each file a separate locking class.  Let's differentiate on
index 713ffac..55ecbeb 100644 (file)
@@ -92,7 +92,6 @@
 #include <linux/user_namespace.h>
 #include <linux/fs_struct.h>
 
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 #include "internal.h"
 
index 066d9c0..d86c0af 100644 (file)
@@ -2112,11 +2112,11 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)
                goto out;
 
        if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) {
-               status = down_read_killable(&mm->mmap_sem);
+               status = mmap_read_lock_killable(mm);
                if (!status) {
                        exact_vma_exists = !!find_exact_vma(mm, vm_start,
                                                            vm_end);
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                }
        }
 
@@ -2163,7 +2163,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
        if (rc)
                goto out_mmput;
 
-       rc = down_read_killable(&mm->mmap_sem);
+       rc = mmap_read_lock_killable(mm);
        if (rc)
                goto out_mmput;
 
@@ -2174,7 +2174,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
                path_get(path);
                rc = 0;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 out_mmput:
        mmput(mm);
@@ -2264,7 +2264,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
                goto out_put_task;
 
        result = ERR_PTR(-EINTR);
-       if (down_read_killable(&mm->mmap_sem))
+       if (mmap_read_lock_killable(mm))
                goto out_put_mm;
 
        result = ERR_PTR(-ENOENT);
@@ -2277,7 +2277,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
                                (void *)(unsigned long)vma->vm_file->f_mode);
 
 out_no_vma:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 out_put_mm:
        mmput(mm);
 out_put_task:
@@ -2322,7 +2322,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
        if (!mm)
                goto out_put_task;
 
-       ret = down_read_killable(&mm->mmap_sem);
+       ret = mmap_read_lock_killable(mm);
        if (ret) {
                mmput(mm);
                goto out_put_task;
@@ -2333,11 +2333,11 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
        /*
         * We need two passes here:
         *
-        *  1) Collect vmas of mapped files with mmap_sem taken
-        *  2) Release mmap_sem and instantiate entries
+        *  1) Collect vmas of mapped files with mmap_lock taken
+        *  2) Release mmap_lock and instantiate entries
         *
         * otherwise we get lockdep complained, since filldir()
-        * routine might require mmap_sem taken in might_fault().
+        * routine might require mmap_lock taken in might_fault().
         */
 
        for (vma = mm->mmap, pos = 2; vma; vma = vma->vm_next) {
@@ -2349,7 +2349,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
                p = genradix_ptr_alloc(&fa, nr_files++, GFP_KERNEL);
                if (!p) {
                        ret = -ENOMEM;
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        mmput(mm);
                        goto out_put_task;
                }
@@ -2358,7 +2358,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
                p->end = vma->vm_end;
                p->mode = vma->vm_file->f_mode;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 
        for (i = 0; i < nr_files; i++) {
index ecc63ce..e9a6841 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/cma.h>
 #endif
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include "internal.h"
 
 void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
index 14c2bad..13452b3 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/hugetlb.h>
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 #include <asm/div64.h>
 #include "internal.h"
index 6ad407d..dbda449 100644 (file)
@@ -145,7 +145,7 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
                return NULL;
        }
 
-       if (down_read_killable(&mm->mmap_sem)) {
+       if (mmap_read_lock_killable(mm)) {
                mmput(mm);
                put_task_struct(priv->task);
                priv->task = NULL;
@@ -188,7 +188,7 @@ static void m_stop(struct seq_file *m, void *v)
                return;
 
        release_task_mempolicy(priv);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
        put_task_struct(priv->task);
        priv->task = NULL;
@@ -593,7 +593,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
        if (pmd_trans_unstable(pmd))
                goto out;
        /*
-        * The mmap_sem held all the way back in m_start() is what
+        * The mmap_lock held all the way back in m_start() is what
         * keeps khugepaged out of here and from collapsing things
         * in here.
         */
@@ -752,7 +752,7 @@ static void smap_gather_stats(struct vm_area_struct *vma,
                }
        }
 #endif
-       /* mmap_sem is held in m_start */
+       /* mmap_lock is held in m_start */
        walk_page_vma(vma, &smaps_walk_ops, mss);
 }
 
@@ -847,7 +847,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
 
        memset(&mss, 0, sizeof(mss));
 
-       ret = down_read_killable(&mm->mmap_sem);
+       ret = mmap_read_lock_killable(mm);
        if (ret)
                goto out_put_mm;
 
@@ -866,7 +866,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
        __show_smap(m, &mss, true);
 
        release_task_mempolicy(priv);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
 out_put_mm:
        mmput(mm);
@@ -1140,7 +1140,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                };
 
                if (type == CLEAR_REFS_MM_HIWATER_RSS) {
-                       if (down_write_killable(&mm->mmap_sem)) {
+                       if (mmap_write_lock_killable(mm)) {
                                count = -EINTR;
                                goto out_mm;
                        }
@@ -1150,11 +1150,11 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                         * resident set size to this mm's current rss value.
                         */
                        reset_mm_hiwater_rss(mm);
-                       up_write(&mm->mmap_sem);
+                       mmap_write_unlock(mm);
                        goto out_mm;
                }
 
-               if (down_read_killable(&mm->mmap_sem)) {
+               if (mmap_read_lock_killable(mm)) {
                        count = -EINTR;
                        goto out_mm;
                }
@@ -1163,8 +1163,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                                if (!(vma->vm_flags & VM_SOFTDIRTY))
                                        continue;
-                               up_read(&mm->mmap_sem);
-                               if (down_write_killable(&mm->mmap_sem)) {
+                               mmap_read_unlock(mm);
+                               if (mmap_write_lock_killable(mm)) {
                                        count = -EINTR;
                                        goto out_mm;
                                }
@@ -1183,14 +1183,14 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                                         * failed like if
                                         * get_proc_task() fails?
                                         */
-                                       up_write(&mm->mmap_sem);
+                                       mmap_write_unlock(mm);
                                        goto out_mm;
                                }
                                for (vma = mm->mmap; vma; vma = vma->vm_next) {
                                        vma->vm_flags &= ~VM_SOFTDIRTY;
                                        vma_set_page_prot(vma);
                                }
-                               downgrade_write(&mm->mmap_sem);
+                               mmap_write_downgrade(mm);
                                break;
                        }
 
@@ -1203,7 +1203,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                if (type == CLEAR_REFS_SOFT_DIRTY)
                        mmu_notifier_invalidate_range_end(&range);
                tlb_finish_mmu(&tlb, 0, -1);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
 out_mm:
                mmput(mm);
        }
@@ -1564,11 +1564,11 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
                /* overflow ? */
                if (end < start_vaddr || end > end_vaddr)
                        end = end_vaddr;
-               ret = down_read_killable(&mm->mmap_sem);
+               ret = mmap_read_lock_killable(mm);
                if (ret)
                        goto out_free;
                ret = walk_page_range(mm, start_vaddr, end, &pagemap_ops, &pm);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                start_vaddr = end;
 
                len = min(count, PM_ENTRY_BYTES * pm.pos);
@@ -1827,7 +1827,7 @@ static int show_numa_map(struct seq_file *m, void *v)
        if (is_vm_hugetlb_page(vma))
                seq_puts(m, " huge");
 
-       /* mmap_sem is held by m_start */
+       /* mmap_lock is held by m_start */
        walk_page_vma(vma, &show_numa_ops, md);
 
        if (!md->pages)
index 7907e64..a6d21fc 100644 (file)
@@ -25,7 +25,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
        struct rb_node *p;
        unsigned long bytes = 0, sbytes = 0, slack = 0, size;
         
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
                vma = rb_entry(p, struct vm_area_struct, vm_rb);
 
@@ -77,7 +77,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
                "Shared:\t%8lu bytes\n",
                bytes, slack, sbytes);
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 }
 
 unsigned long task_vsize(struct mm_struct *mm)
@@ -86,12 +86,12 @@ unsigned long task_vsize(struct mm_struct *mm)
        struct rb_node *p;
        unsigned long vsize = 0;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
                vma = rb_entry(p, struct vm_area_struct, vm_rb);
                vsize += vma->vm_end - vma->vm_start;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return vsize;
 }
 
@@ -104,7 +104,7 @@ unsigned long task_statm(struct mm_struct *mm,
        struct rb_node *p;
        unsigned long size = kobjsize(mm);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
                vma = rb_entry(p, struct vm_area_struct, vm_rb);
                size += kobjsize(vma);
@@ -119,7 +119,7 @@ unsigned long task_statm(struct mm_struct *mm,
                >> PAGE_SHIFT;
        *data = (PAGE_ALIGN(mm->start_stack) - (mm->start_data & PAGE_MASK))
                >> PAGE_SHIFT;
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        size >>= PAGE_SHIFT;
        size += *text + *data;
        *resident = size;
@@ -211,7 +211,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        if (!mm || !mmget_not_zero(mm))
                return NULL;
 
-       if (down_read_killable(&mm->mmap_sem)) {
+       if (mmap_read_lock_killable(mm)) {
                mmput(mm);
                return ERR_PTR(-EINTR);
        }
@@ -221,7 +221,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
                if (n-- == 0)
                        return p;
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
        return NULL;
 }
@@ -231,7 +231,7 @@ static void m_stop(struct seq_file *m, void *_vml)
        struct proc_maps_private *priv = m->private;
 
        if (!IS_ERR_OR_NULL(_vml)) {
-               up_read(&priv->mm->mmap_sem);
+               mmap_read_unlock(priv->mm);
                mmput(priv->mm);
        }
        if (priv->task) {
index c663202..c3a345c 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/pagemap.h>
 #include <linux/uaccess.h>
 #include <linux/mem_encrypt.h>
-#include <asm/pgtable.h>
 #include <asm/io.h>
 #include "internal.h"
 
index e39fdec..52de290 100644 (file)
@@ -234,7 +234,7 @@ static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx,
        pte_t *ptep, pte;
        bool ret = true;
 
-       VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
+       mmap_assert_locked(mm);
 
        ptep = huge_pte_offset(mm, address, vma_mmu_pagesize(vma));
 
@@ -286,7 +286,7 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx,
        pte_t *pte;
        bool ret = true;
 
-       VM_BUG_ON(!rwsem_is_locked(&mm->mmap_sem));
+       mmap_assert_locked(mm);
 
        pgd = pgd_offset(mm, address);
        if (!pgd_present(*pgd))
@@ -369,13 +369,13 @@ static inline bool userfaultfd_signal_pending(unsigned int flags)
  * FAULT_FLAG_KILLABLE are not straightforward. The "Caution"
  * recommendation in __lock_page_or_retry is not an understatement.
  *
- * If FAULT_FLAG_ALLOW_RETRY is set, the mmap_sem must be released
+ * If FAULT_FLAG_ALLOW_RETRY is set, the mmap_lock must be released
  * before returning VM_FAULT_RETRY only if FAULT_FLAG_RETRY_NOWAIT is
  * not set.
  *
  * If FAULT_FLAG_ALLOW_RETRY is set but FAULT_FLAG_KILLABLE is not
  * set, VM_FAULT_RETRY can still be returned if and only if there are
- * fatal_signal_pending()s, and the mmap_sem must be released before
+ * fatal_signal_pending()s, and the mmap_lock must be released before
  * returning it.
  */
 vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
@@ -396,16 +396,16 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
         * FOLL_DUMP case, anon memory also checks for FOLL_DUMP with
         * the no_page_table() helper in follow_page_mask(), but the
         * shmem_vm_ops->fault method is invoked even during
-        * coredumping without mmap_sem and it ends up here.
+        * coredumping without mmap_lock and it ends up here.
         */
        if (current->flags & (PF_EXITING|PF_DUMPCORE))
                goto out;
 
        /*
-        * Coredumping runs without mmap_sem so we can only check that
-        * the mmap_sem is held, if PF_DUMPCORE was not set.
+        * Coredumping runs without mmap_lock so we can only check that
+        * the mmap_lock is held, if PF_DUMPCORE was not set.
         */
-       WARN_ON_ONCE(!rwsem_is_locked(&mm->mmap_sem));
+       mmap_assert_locked(mm);
 
        ctx = vmf->vma->vm_userfaultfd_ctx.ctx;
        if (!ctx)
@@ -422,7 +422,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
        /*
         * If it's already released don't get it. This avoids to loop
         * in __get_user_pages if userfaultfd_release waits on the
-        * caller of handle_userfault to release the mmap_sem.
+        * caller of handle_userfault to release the mmap_lock.
         */
        if (unlikely(READ_ONCE(ctx->released))) {
                /*
@@ -481,7 +481,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
        if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT)
                goto out;
 
-       /* take the reference before dropping the mmap_sem */
+       /* take the reference before dropping the mmap_lock */
        userfaultfd_ctx_get(ctx);
 
        init_waitqueue_func_entry(&uwq.wq, userfaultfd_wake_function);
@@ -514,7 +514,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
                must_wait = userfaultfd_huge_must_wait(ctx, vmf->vma,
                                                       vmf->address,
                                                       vmf->flags, reason);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        if (likely(must_wait && !READ_ONCE(ctx->released) &&
                   !userfaultfd_signal_pending(vmf->flags))) {
@@ -637,7 +637,7 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
                struct mm_struct *mm = release_new_ctx->mm;
 
                /* the various vma->vm_userfaultfd_ctx still points to it */
-               down_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
                /* no task can run (and in turn coredump) yet */
                VM_WARN_ON(!mmget_still_valid(mm));
                for (vma = mm->mmap; vma; vma = vma->vm_next)
@@ -645,7 +645,7 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
                                vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
                                vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING);
                        }
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
 
                userfaultfd_ctx_put(release_new_ctx);
        }
@@ -799,7 +799,7 @@ bool userfaultfd_remove(struct vm_area_struct *vma,
 
        userfaultfd_ctx_get(ctx);
        WRITE_ONCE(ctx->mmap_changing, true);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        msg_init(&ewq.msg);
 
@@ -890,11 +890,11 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
         * Flush page faults out of all CPUs. NOTE: all page faults
         * must be retried without returning VM_FAULT_SIGBUS if
         * userfaultfd_ctx_get() succeeds but vma->vma_userfault_ctx
-        * changes while handle_userfault released the mmap_sem. So
+        * changes while handle_userfault released the mmap_lock. So
         * it's critical that released is set to true (above), before
-        * taking the mmap_sem for writing.
+        * taking the mmap_lock for writing.
         */
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        still_valid = mmget_still_valid(mm);
        prev = NULL;
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
@@ -920,7 +920,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
                vma->vm_flags = new_flags;
                vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
        }
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        mmput(mm);
 wakeup:
        /*
@@ -1248,7 +1248,7 @@ static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx,
        /*
         * To be sure waitqueue_active() is not reordered by the CPU
         * before the pagetable update, use an explicit SMP memory
-        * barrier here. PT lock release or up_read(mmap_sem) still
+        * barrier here. PT lock release or mmap_read_unlock(mm) still
         * have release semantics that can allow the
         * waitqueue_active() to be reordered before the pte update.
         */
@@ -1345,7 +1345,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
        if (!mmget_not_zero(mm))
                goto out;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        if (!mmget_still_valid(mm))
                goto out_unlock;
        vma = find_vma_prev(mm, start, &prev);
@@ -1492,7 +1492,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
                vma = vma->vm_next;
        } while (vma && vma->vm_start < end);
 out_unlock:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        mmput(mm);
        if (!ret) {
                __u64 ioctls_out;
@@ -1547,7 +1547,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
        if (!mmget_not_zero(mm))
                goto out;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        if (!mmget_still_valid(mm))
                goto out_unlock;
        vma = find_vma_prev(mm, start, &prev);
@@ -1664,7 +1664,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
                vma = vma->vm_next;
        } while (vma && vma->vm_start < end);
 out_unlock:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        mmput(mm);
 out:
        return ret;
index 403c903..00db81e 100644 (file)
@@ -1173,7 +1173,7 @@ xfs_file_llseek(
  * Locking for serialisation of IO during page faults. This results in a lock
  * ordering of:
  *
- * mmap_sem (MM)
+ * mmap_lock (MM)
  *   sb_start_pagefault(vfs, freeze)
  *     i_mmaplock (XFS - truncate serialisation)
  *       page_lock (MM)
index 64f5f9a..4c91fb2 100644 (file)
@@ -145,17 +145,17 @@ xfs_ilock_attr_map_shared(
  *
  * i_rwsem -> i_mmap_lock -> page_lock -> i_ilock
  *
- * mmap_sem locking order:
+ * mmap_lock locking order:
  *
- * i_rwsem -> page lock -> mmap_sem
- * mmap_sem -> i_mmap_lock -> page_lock
+ * i_rwsem -> page lock -> mmap_lock
+ * mmap_lock -> i_mmap_lock -> page_lock
  *
- * The difference in mmap_sem locking order mean that we cannot hold the
+ * The difference in mmap_lock locking order mean that we cannot hold the
  * i_mmap_lock over syscall based read(2)/write(2) based IO. These IO paths can
- * fault in pages during copy in/out (for buffered IO) or require the mmap_sem
+ * fault in pages during copy in/out (for buffered IO) or require the mmap_lock
  * in get_user_pages() to map the user pages into the kernel address space for
  * direct IO. Similarly the i_rwsem cannot be taken inside a page fault because
- * page faults already hold the mmap_sem.
+ * page faults already hold the mmap_lock.
  *
  * Hence to serialise fully against both syscall and mmap based IO, we need to
  * take both the i_rwsem and the i_mmap_lock. These locks should *only* be both
@@ -1630,7 +1630,7 @@ xfs_release(
                        return 0;
                /*
                 * If we can't get the iolock just skip truncating the blocks
-                * past EOF because we could deadlock with the mmap_sem
+                * past EOF because we could deadlock with the mmap_lock
                 * otherwise. We'll get another chance to drop them once the
                 * last reference to the inode is dropped, so we'll never leak
                 * blocks permanently.
index 202b2c0..80a13c8 100644 (file)
 #include <linux/fiemap.h>
 
 /*
- * Directories have different lock order w.r.t. mmap_sem compared to regular
+ * Directories have different lock order w.r.t. mmap_lock compared to regular
  * files. This is due to readdir potentially triggering page faults on a user
  * buffer inside filldir(), and this happens with the ilock on the directory
  * held. For regular files, the lock order is the other way around - the
- * mmap_sem is taken during the page fault, and then we lock the ilock to do
+ * mmap_lock is taken during the page fault, and then we lock the ilock to do
  * block mapping. Hence we need a different class for the directory ilock so
  * that lockdep can tell them apart.
  */
index 3a78711..8b1e020 100644 (file)
@@ -972,7 +972,7 @@ static inline void iounmap(void __iomem *addr)
 }
 #endif
 #elif defined(CONFIG_GENERIC_IOREMAP)
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
 void iounmap(volatile void __iomem *addr);
index 0d9b28c..3e13acd 100644 (file)
@@ -45,6 +45,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
 {
        return (pmd_t *)pud;
 }
+#define pmd_offset pmd_offset
 
 #define pmd_val(x)                             (pud_val((x).pud))
 #define __pmd(x)                               ((pmd_t) { __pud(x) } )
index ad05c16..a9d751f 100644 (file)
@@ -43,6 +43,7 @@ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
 {
        return (pud_t *)p4d;
 }
+#define pud_offset pud_offset
 
 #define pud_val(x)                             (p4d_val((x).p4d))
 #define __pud(x)                               ((pud_t) { __p4d(x) })
index 750621e..1aa8009 100644 (file)
 
 /*
  * __read_mostly is used to keep rarely changing variables out of frequently
- * updated cachelines. If an architecture doesn't support it, ignore the
- * hint.
+ * updated cachelines. Its use should be reserved for data that is used
+ * frequently in hot paths. Performance traces can help decide when to use
+ * this. You want __read_mostly data to be tightly packed, so that in the
+ * best case multiple frequently read variables for a hot path will be next
+ * to each other in order to reduce the number of cachelines needed to
+ * execute a critical path. We should be mindful and selective of its use.
+ * ie: if you're going to use it please supply a *good* justification in your
+ * commit log
  */
 #ifndef __read_mostly
 #define __read_mostly
index bc15628..a5192b7 100644 (file)
@@ -5,9 +5,10 @@
 #include <linux/kexec.h>
 #include <linux/proc_fs.h>
 #include <linux/elf.h>
+#include <linux/pgtable.h>
 #include <uapi/linux/vmcore.h>
 
-#include <asm/pgtable.h> /* for pgprot_t */
+#include <linux/pgtable.h> /* for pgprot_t */
 
 #ifdef CONFIG_CRASH_DUMP
 #define ELFCORE_ADDR_MAX       (-1ULL)
index d7af5d2..6904d4e 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/radix-tree.h>
-#include <asm/pgtable.h>
 
 /* Flag for synchronous flush */
 #define DAXDEV_F_SYNC (1UL << 0)
index b59f1b6..ca09a4e 100644 (file)
@@ -3,7 +3,7 @@
 #define _LINUX_DMA_NONCOHERENT_H 1
 
 #include <linux/dma-mapping.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H
 #include <asm/dma-coherence.h>
index 01f5d29..0b02632 100644 (file)
@@ -1679,10 +1679,10 @@ static inline int sb_start_write_trylock(struct super_block *sb)
  *
  * Since page fault freeze protection behaves as a lock, users have to preserve
  * ordering of freeze protection and other filesystem locks. It is advised to
- * put sb_start_pagefault() close to mmap_sem in lock ordering. Page fault
+ * put sb_start_pagefault() close to mmap_lock in lock ordering. Page fault
  * handling code implies lock dependency:
  *
- * mmap_sem
+ * mmap_lock
  *   -> sb_start_pagefault
  */
 static inline void sb_start_pagefault(struct super_block *sb)
index e912b9d..f4a09ed 100644 (file)
@@ -10,7 +10,7 @@
 #define LINUX_HMM_H
 
 #include <linux/kconfig.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 #include <linux/device.h>
 #include <linux/migrate.h>
index cfbb0a8..71f2077 100644 (file)
@@ -248,7 +248,7 @@ static inline int is_swap_pmd(pmd_t pmd)
        return !pmd_none(pmd) && !pmd_present(pmd);
 }
 
-/* mmap_sem must be held on entry */
+/* mmap_lock must be held on entry */
 static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd,
                struct vm_area_struct *vma)
 {
index 0cced41..50650d0 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/cgroup.h>
 #include <linux/list.h>
 #include <linux/kref.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 
 struct ctl_table;
 struct user_struct;
index b336622..0beaa3e 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/bug.h>
 #include <linux/io.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
 
 /*
@@ -99,7 +100,6 @@ io_mapping_unmap(void __iomem *vaddr)
 #else
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 
 /* Create the io_mapping object*/
 static inline struct io_mapping *
index 657a83b..98338dc 100644 (file)
@@ -165,9 +165,9 @@ static inline int kallsyms_show_value(void)
 
 #endif /*CONFIG_KALLSYMS*/
 
-static inline void print_ip_sym(unsigned long ip)
+static inline void print_ip_sym(const char *loglvl, unsigned long ip)
 {
-       printk("[<%px>] %pS\n", (void *) ip, (void *) ip);
+       printk("%s[<%px>] %pS\n", loglvl, (void *) ip, (void *) ip);
 }
 
 #endif /*_LINUX_KALLSYMS_H*/
index 31314ca..82522e9 100644 (file)
@@ -11,8 +11,8 @@ struct task_struct;
 
 #ifdef CONFIG_KASAN
 
+#include <linux/pgtable.h>
 #include <asm/kasan.h>
-#include <asm/pgtable.h>
 
 extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
 extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
index 8165278..ea9c15b 100644 (file)
@@ -31,7 +31,7 @@ struct mm_struct;
  * Locking policy for interlave:
  * In process context there is no locking because only the process accesses
  * its own state. All vma manipulation is somewhat protected by a down_read on
- * mmap_sem.
+ * mmap_lock.
  *
  * Freeing policy:
  * Mempolicy objects are reference counted.  A mempolicy will be freed when
index 9d60421..dc7b873 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/atomic.h>
 #include <linux/debug_locks.h>
 #include <linux/mm_types.h>
+#include <linux/mmap_lock.h>
 #include <linux/range.h>
 #include <linux/pfn.h>
 #include <linux/percpu-refcount.h>
@@ -28,6 +29,7 @@
 #include <linux/overflow.h>
 #include <linux/sizes.h>
 #include <linux/sched.h>
+#include <linux/pgtable.h>
 
 struct mempolicy;
 struct anon_vma;
@@ -92,7 +94,6 @@ extern int mmap_rnd_compat_bits __read_mostly;
 #endif
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/processor.h>
 
 /*
@@ -401,7 +402,7 @@ extern pgprot_t protection_map[16];
  * @FAULT_FLAG_WRITE: Fault was a write fault.
  * @FAULT_FLAG_MKWRITE: Fault was mkwrite of existing PTE.
  * @FAULT_FLAG_ALLOW_RETRY: Allow to retry the fault if blocked.
- * @FAULT_FLAG_RETRY_NOWAIT: Don't drop mmap_sem and wait when retrying.
+ * @FAULT_FLAG_RETRY_NOWAIT: Don't drop mmap_lock and wait when retrying.
  * @FAULT_FLAG_KILLABLE: The fault task is in SIGKILL killable region.
  * @FAULT_FLAG_TRIED: The fault has been tried once.
  * @FAULT_FLAG_USER: The fault originated in userspace.
@@ -451,10 +452,10 @@ extern pgprot_t protection_map[16];
  * fault_flag_allow_retry_first - check ALLOW_RETRY the first time
  *
  * This is mostly used for places where we want to try to avoid taking
- * the mmap_sem for too long a time when waiting for another condition
+ * the mmap_lock for too long a time when waiting for another condition
  * to change, in which case we can try to be polite to release the
- * mmap_sem in the first round to avoid potential starvation of other
- * processes that would also want the mmap_sem.
+ * mmap_lock in the first round to avoid potential starvation of other
+ * processes that would also want the mmap_lock.
  *
  * Return: true if the page fault allows retry and this is the first
  * attempt of the fault handling; false otherwise.
@@ -581,7 +582,7 @@ struct vm_operations_struct {
         * (vma,addr) marked as MPOL_SHARED.  The shared policy infrastructure
         * in mm/mempolicy.c will do this automatically.
         * get_policy() must NOT add a ref if the policy at (vma,addr) is not
-        * marked as MPOL_SHARED. vma policies are protected by the mmap_sem.
+        * marked as MPOL_SHARED. vma policies are protected by the mmap_lock.
         * If no [shared/vma] mempolicy exists at the addr, get_policy() op
         * must return NULL--i.e., do not "fallback" to task or system default
         * policy.
index ef6d3af..64ede5f 100644 (file)
@@ -344,7 +344,7 @@ struct vm_area_struct {
         * can only be in the i_mmap tree.  An anonymous MAP_PRIVATE, stack
         * or brk vma (with NULL file) can only be in an anon_vma list.
         */
-       struct list_head anon_vma_chain; /* Serialized by mmap_sem &
+       struct list_head anon_vma_chain; /* Serialized by mmap_lock &
                                          * page_table_lock */
        struct anon_vma *anon_vma;      /* Serialized by page_table_lock */
 
@@ -440,7 +440,7 @@ struct mm_struct {
                spinlock_t page_table_lock; /* Protects page tables and some
                                             * counters
                                             */
-               struct rw_semaphore mmap_sem;
+               struct rw_semaphore mmap_lock;
 
                struct list_head mmlist; /* List of maybe swapped mm's. These
                                          * are globally strung together off
diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
new file mode 100644 (file)
index 0000000..0707671
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef _LINUX_MMAP_LOCK_H
+#define _LINUX_MMAP_LOCK_H
+
+#include <linux/mmdebug.h>
+
+#define MMAP_LOCK_INITIALIZER(name) \
+       .mmap_lock = __RWSEM_INITIALIZER((name).mmap_lock),
+
+static inline void mmap_init_lock(struct mm_struct *mm)
+{
+       init_rwsem(&mm->mmap_lock);
+}
+
+static inline void mmap_write_lock(struct mm_struct *mm)
+{
+       down_write(&mm->mmap_lock);
+}
+
+static inline void mmap_write_lock_nested(struct mm_struct *mm, int subclass)
+{
+       down_write_nested(&mm->mmap_lock, subclass);
+}
+
+static inline int mmap_write_lock_killable(struct mm_struct *mm)
+{
+       return down_write_killable(&mm->mmap_lock);
+}
+
+static inline bool mmap_write_trylock(struct mm_struct *mm)
+{
+       return down_write_trylock(&mm->mmap_lock) != 0;
+}
+
+static inline void mmap_write_unlock(struct mm_struct *mm)
+{
+       up_write(&mm->mmap_lock);
+}
+
+static inline void mmap_write_downgrade(struct mm_struct *mm)
+{
+       downgrade_write(&mm->mmap_lock);
+}
+
+static inline void mmap_read_lock(struct mm_struct *mm)
+{
+       down_read(&mm->mmap_lock);
+}
+
+static inline int mmap_read_lock_killable(struct mm_struct *mm)
+{
+       return down_read_killable(&mm->mmap_lock);
+}
+
+static inline bool mmap_read_trylock(struct mm_struct *mm)
+{
+       return down_read_trylock(&mm->mmap_lock) != 0;
+}
+
+static inline void mmap_read_unlock(struct mm_struct *mm)
+{
+       up_read(&mm->mmap_lock);
+}
+
+static inline bool mmap_read_trylock_non_owner(struct mm_struct *mm)
+{
+       if (down_read_trylock(&mm->mmap_lock)) {
+               rwsem_release(&mm->mmap_lock.dep_map, _RET_IP_);
+               return true;
+       }
+       return false;
+}
+
+static inline void mmap_read_unlock_non_owner(struct mm_struct *mm)
+{
+       up_read_non_owner(&mm->mmap_lock);
+}
+
+static inline void mmap_assert_locked(struct mm_struct *mm)
+{
+       lockdep_assert_held(&mm->mmap_lock);
+       VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm);
+}
+
+static inline void mmap_assert_write_locked(struct mm_struct *mm)
+{
+       lockdep_assert_held_write(&mm->mmap_lock);
+       VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm);
+}
+
+#endif /* _LINUX_MMAP_LOCK_H */
index 736f691..fc68f35 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/mm_types.h>
+#include <linux/mmap_lock.h>
 #include <linux/srcu.h>
 #include <linux/interval_tree.h>
 
@@ -121,7 +122,7 @@ struct mmu_notifier_ops {
 
        /*
         * invalidate_range_start() and invalidate_range_end() must be
-        * paired and are called only when the mmap_sem and/or the
+        * paired and are called only when the mmap_lock and/or the
         * locks protecting the reverse maps are held. If the subsystem
         * can't guarantee that no additional references are taken to
         * the pages in the range, it has to implement the
@@ -212,13 +213,13 @@ struct mmu_notifier_ops {
 };
 
 /*
- * The notifier chains are protected by mmap_sem and/or the reverse map
+ * The notifier chains are protected by mmap_lock and/or the reverse map
  * semaphores. Notifier chains are only changed when all reverse maps and
- * the mmap_sem locks are taken.
+ * the mmap_lock locks are taken.
  *
  * Therefore notifier chains can only be traversed when either
  *
- * 1. mmap_sem is held.
+ * 1. mmap_lock is held.
  * 2. One of the reverse map locks is held (i_mmap_rwsem or anon_vma->rwsem).
  * 3. No other concurrent thread can access the list (release)
  */
@@ -277,9 +278,9 @@ mmu_notifier_get(const struct mmu_notifier_ops *ops, struct mm_struct *mm)
 {
        struct mmu_notifier *ret;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        ret = mmu_notifier_get_locked(ops, mm);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 void mmu_notifier_put(struct mmu_notifier *subscription);
index 8e08571..cf2468d 100644 (file)
@@ -538,7 +538,7 @@ static inline int lock_page_killable(struct page *page)
  * lock_page_or_retry - Lock the page, unless this would block and the
  * caller indicated that it can handle a retry.
  *
- * Return value and mmap_sem implications depend on flags; see
+ * Return value and mmap_lock implications depend on flags; see
  * __lock_page_or_retry().
  */
 static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm,
similarity index 91%
rename from include/asm-generic/pgtable.h
rename to include/linux/pgtable.h
index 0a93296..32b6c52 100644 (file)
@@ -1,8 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_GENERIC_PGTABLE_H
-#define _ASM_GENERIC_PGTABLE_H
+#ifndef _LINUX_PGTABLE_H
+#define _LINUX_PGTABLE_H
 
 #include <linux/pfn.h>
+#include <asm/pgtable.h>
 
 #ifndef __ASSEMBLY__
 #ifdef CONFIG_MMU
 #define USER_PGTABLES_CEILING  0UL
 #endif
 
+/*
+ * A page table page can be thought of an array like this: pXd_t[PTRS_PER_PxD]
+ *
+ * The pXx_index() functions return the index of the entry in the page
+ * table page which would control the given virtual address
+ *
+ * As these functions may be used by the same code for different levels of
+ * the page table folding, they are always available, regardless of
+ * CONFIG_PGTABLE_LEVELS value. For the folded levels they simply return 0
+ * because in such cases PTRS_PER_PxD equals 1.
+ */
+
+static inline unsigned long pte_index(unsigned long address)
+{
+       return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
+}
+
+#ifndef pmd_index
+static inline unsigned long pmd_index(unsigned long address)
+{
+       return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
+}
+#define pmd_index pmd_index
+#endif
+
+#ifndef pud_index
+static inline unsigned long pud_index(unsigned long address)
+{
+       return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
+}
+#define pud_index pud_index
+#endif
+
+#ifndef pgd_index
+/* Must be a compile-time constant, so implement it as a macro */
+#define pgd_index(a)  (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
+#endif
+
+#ifndef pte_offset_kernel
+static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
+{
+       return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
+}
+#define pte_offset_kernel pte_offset_kernel
+#endif
+
+#if defined(CONFIG_HIGHPTE)
+#define pte_offset_map(dir, address)                           \
+       ((pte_t *)kmap_atomic(pmd_page(*(dir))) +               \
+        pte_index((address)))
+#define pte_unmap(pte) kunmap_atomic((pte))
+#else
+#define pte_offset_map(dir, address)   pte_offset_kernel((dir), (address))
+#define pte_unmap(pte) ((void)(pte))   /* NOP */
+#endif
+
+/* Find an entry in the second-level page table.. */
+#ifndef pmd_offset
+static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
+{
+       return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
+}
+#define pmd_offset pmd_offset
+#endif
+
+#ifndef pud_offset
+static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
+{
+       return (pud_t *)p4d_page_vaddr(*p4d) + pud_index(address);
+}
+#define pud_offset pud_offset
+#endif
+
+static inline pgd_t *pgd_offset_pgd(pgd_t *pgd, unsigned long address)
+{
+       return (pgd + pgd_index(address));
+};
+
+/*
+ * a shortcut to get a pgd_t in a given mm
+ */
+#ifndef pgd_offset
+#define pgd_offset(mm, address)                pgd_offset_pgd((mm)->pgd, (address))
+#endif
+
+/*
+ * a shortcut which implies the use of the kernel's pgd, instead
+ * of a process's
+ */
+#define pgd_offset_k(address)          pgd_offset(&init_mm, (address))
+
+/*
+ * In many cases it is known that a virtual address is mapped at PMD or PTE
+ * level, so instead of traversing all the page table levels, we can get a
+ * pointer to the PMD entry in user or kernel page table or translate a virtual
+ * address to the pointer in the PTE in the kernel page tables with simple
+ * helpers.
+ */
+static inline pmd_t *pmd_off(struct mm_struct *mm, unsigned long va)
+{
+       return pmd_offset(pud_offset(p4d_offset(pgd_offset(mm, va), va), va), va);
+}
+
+static inline pmd_t *pmd_off_k(unsigned long va)
+{
+       return pmd_offset(pud_offset(p4d_offset(pgd_offset_k(va), va), va), va);
+}
+
+static inline pte_t *virt_to_kpte(unsigned long vaddr)
+{
+       pmd_t *pmd = pmd_off_k(vaddr);
+
+       return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
+}
+
 #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
 extern int ptep_set_access_flags(struct vm_area_struct *vma,
                                 unsigned long address, pte_t *ptep,
@@ -1018,11 +1134,11 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
 #endif
 /*
  * This function is meant to be used by sites walking pagetables with
- * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
+ * the mmap_lock held in read mode to protect against MADV_DONTNEED and
  * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
  * into a null pmd and the transhuge page fault can convert a null pmd
  * into an hugepmd or into a regular pmd (if the hugepage allocation
- * fails). While holding the mmap_sem in read mode the pmd becomes
+ * fails). While holding the mmap_lock in read mode the pmd becomes
  * stable and stops changing under us only if it's not null and not a
  * transhuge pmd. When those races occurs and this function makes a
  * difference vs the standard pmd_none_or_clear_bad, the result is
@@ -1032,7 +1148,7 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
  *
  * For 32bit kernels with a 64bit large pmd_t this automatically takes
  * care of reading the pmd atomically to avoid SMP race conditions
- * against pmd_populate() when the mmap_sem is hold for reading by the
+ * against pmd_populate() when the mmap_lock is hold for reading by the
  * caller (a special atomic read not done by "gcc" as in the generic
  * version above, is also needed when THP is disabled because the page
  * fault can populate the pmd from under us).
@@ -1319,4 +1435,4 @@ typedef unsigned int pgtbl_mod_mask;
 #define pmd_leaf(x)    0
 #endif
 
-#endif /* _ASM_GENERIC_PGTABLE_H */
+#endif /* _LINUX_PGTABLE_H */
index 988d176..3a6adfa 100644 (file)
@@ -77,7 +77,7 @@ struct anon_vma {
 struct anon_vma_chain {
        struct vm_area_struct *vma;
        struct anon_vma *anon_vma;
-       struct list_head same_vma;   /* locked by mmap_sem & page_table_lock */
+       struct list_head same_vma;   /* locked by mmap_lock & page_table_lock */
        struct rb_node rb;                      /* locked by anon_vma->rwsem */
        unsigned long rb_subtree_last;
 #ifdef CONFIG_DEBUG_VM_RB
index 95fb9e0..00c45a0 100644 (file)
@@ -30,7 +30,8 @@ extern void show_regs(struct pt_regs *);
  * task), SP is the stack pointer of the first frame that should be shown in the back
  * trace (or NULL if the entire call-chain of the task should be shown).
  */
-extern void show_stack(struct task_struct *task, unsigned long *sp);
+extern void show_stack(struct task_struct *task, unsigned long *sp,
+                      const char *loglvl);
 
 extern void sched_show_task(struct task_struct *p);
 
index a132d87..480a4d1 100644 (file)
@@ -53,7 +53,7 @@ void mmdrop(struct mm_struct *mm);
 
 /*
  * This has to be called after a get_task_mm()/mmget_not_zero()
- * followed by taking the mmap_sem for writing before modifying the
+ * followed by taking the mmap_lock for writing before modifying the
  * vmas or anything the coredump pretends not to change from under it.
  *
  * It also has to be called when mmgrab() is used in the context of
@@ -61,14 +61,14 @@ void mmdrop(struct mm_struct *mm);
  * the context of the process to run down_write() on that pinned mm.
  *
  * NOTE: find_extend_vma() called from GUP context is the only place
- * that can modify the "mm" (notably the vm_start/end) under mmap_sem
+ * that can modify the "mm" (notably the vm_start/end) under mmap_lock
  * for reading and outside the context of the process, so it is also
- * the only case that holds the mmap_sem for reading that must call
- * this function. Generally if the mmap_sem is hold for reading
+ * the only case that holds the mmap_lock for reading that must call
+ * this function. Generally if the mmap_lock is hold for reading
  * there's no need of this check after get_task_mm()/mmget_not_zero().
  *
  * This function can be obsoleted and the check can be removed, after
- * the coredump code will hold the mmap_sem for writing before
+ * the coredump code will hold the mmap_lock for writing before
  * invoking the ->core_dump methods.
  */
 static inline bool mmget_still_valid(struct mm_struct *mm)
index 9861c89..dac1db0 100644 (file)
@@ -301,62 +301,20 @@ copy_struct_from_user(void *dst, size_t ksize, const void __user *src,
        return 0;
 }
 
-/*
- * probe_kernel_read(): safely attempt to read from a location
- * @dst: pointer to the buffer that shall take the data
- * @src: address to read from
- * @size: size of the data chunk
- *
- * Safely read from address @src to the buffer at @dst.  If a kernel fault
- * happens, handle that and return -EFAULT.
- */
-extern long probe_kernel_read(void *dst, const void *src, size_t size);
-extern long probe_kernel_read_strict(void *dst, const void *src, size_t size);
-extern long __probe_kernel_read(void *dst, const void *src, size_t size);
+bool probe_kernel_read_allowed(const void *unsafe_src, size_t size);
 
-/*
- * probe_user_read(): safely attempt to read from a location in user space
- * @dst: pointer to the buffer that shall take the data
- * @src: address to read from
- * @size: size of the data chunk
- *
- * Safely read from address @src to the buffer at @dst.  If a kernel fault
- * happens, handle that and return -EFAULT.
- */
+extern long probe_kernel_read(void *dst, const void *src, size_t size);
 extern long probe_user_read(void *dst, const void __user *src, size_t size);
-extern long __probe_user_read(void *dst, const void __user *src, size_t size);
 
-/*
- * probe_kernel_write(): safely attempt to write to a location
- * @dst: address to write to
- * @src: pointer to the data that shall be written
- * @size: size of the data chunk
- *
- * Safely write to address @dst from the buffer at @src.  If a kernel fault
- * happens, handle that and return -EFAULT.
- */
 extern long notrace probe_kernel_write(void *dst, const void *src, size_t size);
-extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size);
-
-/*
- * probe_user_write(): safely attempt to write to a location in user space
- * @dst: address to write to
- * @src: pointer to the data that shall be written
- * @size: size of the data chunk
- *
- * Safely write to address @dst from the buffer at @src.  If a kernel fault
- * happens, handle that and return -EFAULT.
- */
 extern long notrace probe_user_write(void __user *dst, const void *src, size_t size);
-extern long notrace __probe_user_write(void __user *dst, const void *src, size_t size);
-
-extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count);
-extern long strncpy_from_unsafe_strict(char *dst, const void *unsafe_addr,
-                                      long count);
-extern long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count);
-extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr,
-                                    long count);
-extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count);
+
+long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr,
+               long count);
+
+long strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr,
+               long count);
+long strnlen_user_nofault(const void __user *unsafe_addr, long count);
 
 /**
  * probe_kernel_address(): safely attempt to read from a location
index f77dcbc..d7f6af5 100644 (file)
@@ -3,11 +3,11 @@
 #define _ASM_ARM_XEN_PAGE_H
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include <linux/pfn.h>
 #include <linux/types.h>
 #include <linux/dma-mapping.h>
+#include <linux/pgtable.h>
 
 #include <xen/xen.h>
 #include <xen/interface/grant_table.h>
index 15303d5..a90ac70 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/numa.h>
 #include <linux/scs.h>
 
-#include <asm/pgtable.h>
 #include <linux/uaccess.h>
 
 static struct signal_struct init_signals = {
index 0ba6add..0a6dd94 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1544,7 +1544,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
        if (err)
                goto out_fput;
 
-       if (down_write_killable(&current->mm->mmap_sem)) {
+       if (mmap_write_lock_killable(current->mm)) {
                err = -EINTR;
                goto out_fput;
        }
@@ -1564,7 +1564,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
        if (IS_ERR_VALUE(addr))
                err = (long)addr;
 invalid:
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        if (populate)
                mm_populate(addr, populate);
 
@@ -1638,7 +1638,7 @@ long ksys_shmdt(char __user *shmaddr)
        if (addr & ~PAGE_MASK)
                return retval;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        /*
@@ -1726,7 +1726,7 @@ long ksys_shmdt(char __user *shmaddr)
 
 #endif
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return retval;
 }
 
index 11ff4a5..b0c5b3a 100644 (file)
@@ -40,7 +40,7 @@
  *  is one more bug... 10/11/98, AV.
  *
  *     Oh, fsck... Oopsable SMP race in do_process_acct() - we must hold
- * ->mmap_sem to walk the vma list of current->mm. Nasty, since it leaks
+ * ->mmap_lock to walk the vma list of current->mm. Nasty, since it leaks
  * a struct file opened for write. Fixed. 2/6/2000, AV.
  */
 
@@ -541,13 +541,13 @@ void acct_collect(long exitcode, int group_dead)
        if (group_dead && current->mm) {
                struct vm_area_struct *vma;
 
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                vma = current->mm->mmap;
                while (vma) {
                        vsize += vma->vm_end - vma->vm_start;
                        vma = vma->vm_next;
                }
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
        }
 
        spin_lock_irq(&current->sighand->siglock);
index 7b8381c..599488f 100644 (file)
@@ -33,7 +33,7 @@ struct bpf_stack_map {
 /* irq_work to run up_read() for build_id lookup in nmi context */
 struct stack_map_irq_work {
        struct irq_work irq_work;
-       struct rw_semaphore *sem;
+       struct mm_struct *mm;
 };
 
 static void do_up_read(struct irq_work *entry)
@@ -44,8 +44,7 @@ static void do_up_read(struct irq_work *entry)
                return;
 
        work = container_of(entry, struct stack_map_irq_work, irq_work);
-       up_read_non_owner(work->sem);
-       work->sem = NULL;
+       mmap_read_unlock_non_owner(work->mm);
 }
 
 static DEFINE_PER_CPU(struct stack_map_irq_work, up_read_work);
@@ -317,7 +316,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
         * with build_id.
         */
        if (!user || !current || !current->mm || irq_work_busy ||
-           down_read_trylock(&current->mm->mmap_sem) == 0) {
+           !mmap_read_trylock_non_owner(current->mm)) {
                /* cannot access current->mm, fall back to ips */
                for (i = 0; i < trace_nr; i++) {
                        id_offs[i].status = BPF_STACK_BUILD_ID_IP;
@@ -342,16 +341,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
        }
 
        if (!work) {
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock_non_owner(current->mm);
        } else {
-               work->sem = &current->mm->mmap_sem;
+               work->mm = current->mm;
                irq_work_queue(&work->irq_work);
-               /*
-                * The irq_work will release the mmap_sem with
-                * up_read_non_owner(). The rwsem_release() is called
-                * here to release the lock from lockdep's perspective.
-                */
-               rwsem_release(&current->mm->mmap_sem.dep_map, _RET_IP_);
        }
 }
 
index 4d530b1..c3ae2ad 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/nospec.h>
 #include <linux/audit.h>
 #include <uapi/linux/btf.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <linux/bpf_lsm.h>
 #include <linux/poll.h>
 #include <linux/bpf-netns.h>
index 729d3a5..642415b 100644 (file)
@@ -1655,7 +1655,7 @@ static void update_tasks_nodemask(struct cpuset *cs)
        guarantee_online_mems(cs, &newmems);
 
        /*
-        * The mpol_rebind_mm() call takes mmap_sem, which we couldn't
+        * The mpol_rebind_mm() call takes mmap_lock, which we couldn't
         * take while holding tasklist_lock.  Forks can happen - the
         * mpol_dup() cpuset_being_rebound check will catch such forks,
         * and rebind their vma mempolicies too.  Because we still hold
@@ -1760,7 +1760,7 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
  *
  * Call with cpuset_mutex held. May take callback_lock during call.
  * Will take tasklist_lock, scan tasklist for tasks in cpuset cs,
- * lock each such tasks mm->mmap_sem, scan its vma's and rebind
+ * lock each such tasks mm->mmap_lock, scan its vma's and rebind
  * their mempolicies to the cpusets new mems_allowed.
  */
 static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
index 3de0cc7..18e03ab 100644 (file)
 
 static void kdb_show_stack(struct task_struct *p, void *addr)
 {
-       int old_lvl = console_loglevel;
-
-       console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
        kdb_trap_printk++;
 
-       if (!addr && kdb_task_has_cpu(p))
+       if (!addr && kdb_task_has_cpu(p)) {
+               int old_lvl = console_loglevel;
+
+               console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
                kdb_dump_stack_on_cpu(kdb_process_cpu(p));
-       else
-               show_stack(p, addr);
+               console_loglevel = old_lvl;
+       } else {
+               show_stack(p, addr, KERN_EMERG);
+       }
 
-       console_loglevel = old_lvl;
        kdb_trap_printk--;
 }
 
index 63d66bb..856d98c 100644 (file)
@@ -1316,7 +1316,7 @@ static void put_ctx(struct perf_event_context *ctx)
  *         perf_event::child_mutex;
  *           perf_event_context::lock
  *         perf_event::mmap_mutex
- *         mmap_sem
+ *         mmap_lock
  *           perf_addr_filters_head::lock
  *
  *    cpu_hotplug_lock
@@ -3080,7 +3080,7 @@ static int perf_event_stop(struct perf_event *event, int restart)
  *     pre-existing mappings, called once when new filters arrive via SET_FILTER
  *     ioctl;
  * (2) perf_addr_filters_adjust(): adjusting filters' offsets based on newly
- *     registered mapping, called for every new mmap(), with mm::mmap_sem down
+ *     registered mapping, called for every new mmap(), with mm::mmap_lock down
  *     for reading;
  * (3) perf_event_addr_filters_exec(): clearing filters' offsets in the process
  *     of exec.
@@ -9742,7 +9742,7 @@ static void perf_addr_filters_splice(struct perf_event *event,
 /*
  * Scan through mm's vmas and see if one of them matches the
  * @filter; if so, adjust filter's address range.
- * Called with mm::mmap_sem down for reading.
+ * Called with mm::mmap_lock down for reading.
  */
 static void perf_addr_filter_apply(struct perf_addr_filter *filter,
                                   struct mm_struct *mm,
@@ -9784,7 +9784,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
                if (!mm)
                        goto restart;
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        }
 
        raw_spin_lock_irqsave(&ifh->lock, flags);
@@ -9810,7 +9810,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
        raw_spin_unlock_irqrestore(&ifh->lock, flags);
 
        if (ifh->nr_file_filters) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
 
                mmput(mm);
        }
index 5dc2f46..bb08628 100644 (file)
@@ -457,7 +457,7 @@ static int update_ref_ctr(struct uprobe *uprobe, struct mm_struct *mm,
  * @vaddr: the virtual address to store the opcode.
  * @opcode: opcode to be written at @vaddr.
  *
- * Called with mm->mmap_sem held for write.
+ * Called with mm->mmap_lock held for write.
  * Return 0 (success) or a negative errno.
  */
 int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
@@ -1054,7 +1054,7 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new)
                if (err && is_register)
                        goto free;
 
-               down_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
                vma = find_vma(mm, info->vaddr);
                if (!vma || !valid_vma(vma, is_register) ||
                    file_inode(vma->vm_file) != uprobe->inode)
@@ -1076,7 +1076,7 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new)
                }
 
  unlock:
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
  free:
                mmput(mm);
                info = free_map_info(info);
@@ -1240,7 +1240,7 @@ static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm)
        struct vm_area_struct *vma;
        int err = 0;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                unsigned long vaddr;
                loff_t offset;
@@ -1257,7 +1257,7 @@ static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm)
                vaddr = offset_to_vaddr(vma, uprobe->offset);
                err |= remove_breakpoint(uprobe, mm, vaddr);
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return err;
 }
@@ -1354,7 +1354,7 @@ static int delayed_ref_ctr_inc(struct vm_area_struct *vma)
 }
 
 /*
- * Called from mmap_region/vma_adjust with mm->mmap_sem acquired.
+ * Called from mmap_region/vma_adjust with mm->mmap_lock acquired.
  *
  * Currently we ignore all errors and always return 0, the callers
  * can't handle the failure anyway.
@@ -1444,7 +1444,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
        struct vm_area_struct *vma;
        int ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        if (mm->uprobes_state.xol_area) {
@@ -1474,7 +1474,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
        /* pairs with get_xol_area() */
        smp_store_release(&mm->uprobes_state.xol_area, area); /* ^^^ */
  fail:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return ret;
 }
@@ -2047,7 +2047,7 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp)
        struct uprobe *uprobe = NULL;
        struct vm_area_struct *vma;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, bp_vaddr);
        if (vma && vma->vm_start <= bp_vaddr) {
                if (valid_vma(vma, false)) {
@@ -2065,7 +2065,7 @@ static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp)
 
        if (!uprobe && test_and_clear_bit(MMF_RECALC_UPROBES, &mm->flags))
                mmf_recalc_uprobes(mm);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return uprobe;
 }
index c300253..727150f 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <linux/uaccess.h>
 #include <asm/unistd.h>
-#include <asm/pgtable.h>
 #include <asm/mmu_context.h>
 
 static void __unhash_process(struct task_struct *p, bool group_dead)
@@ -441,17 +440,17 @@ static void exit_mm(void)
        sync_mm_rss(mm);
        /*
         * Serialize with any possible pending coredump.
-        * We must hold mmap_sem around checking core_state
+        * We must hold mmap_lock around checking core_state
         * and clearing tsk->mm.  The core-inducing thread
         * will increment ->nr_threads for each thread in the
         * group with ->mm != NULL.
         */
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        core_state = mm->core_state;
        if (core_state) {
                struct core_thread self;
 
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
 
                self.task = current;
                self.next = xchg(&core_state->dumper.next, &self);
@@ -469,14 +468,14 @@ static void exit_mm(void)
                        freezable_schedule();
                }
                __set_current_state(TASK_RUNNING);
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
        }
        mmgrab(mm);
        BUG_ON(mm != current->active_mm);
        /* more a memory barrier than a real lock */
        task_lock(current);
        current->mm = NULL;
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        enter_lazy_tlb(mm, current);
        task_unlock(current);
        mm_update_next_owner(mm);
index cefe874..142b236 100644 (file)
@@ -96,7 +96,6 @@
 #include <linux/kasan.h>
 #include <linux/scs.h>
 
-#include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <linux/uaccess.h>
 #include <asm/mmu_context.h>
@@ -493,7 +492,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
        LIST_HEAD(uf);
 
        uprobe_start_dup_mmap();
-       if (down_write_killable(&oldmm->mmap_sem)) {
+       if (mmap_write_lock_killable(oldmm)) {
                retval = -EINTR;
                goto fail_uprobe_end;
        }
@@ -502,7 +501,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
        /*
         * Not linked in yet - no deadlock potential:
         */
-       down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
+       mmap_write_lock_nested(mm, SINGLE_DEPTH_NESTING);
 
        /* No ordering required: file already has been exposed. */
        RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm));
@@ -618,9 +617,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
        /* a new mm has just been created */
        retval = arch_dup_mmap(oldmm, mm);
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        flush_tlb_mm(oldmm);
-       up_write(&oldmm->mmap_sem);
+       mmap_write_unlock(oldmm);
        dup_userfaultfd_complete(&uf);
 fail_uprobe_end:
        uprobe_end_dup_mmap();
@@ -650,9 +649,9 @@ static inline void mm_free_pgd(struct mm_struct *mm)
 #else
 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
 {
-       down_write(&oldmm->mmap_sem);
+       mmap_write_lock(oldmm);
        RCU_INIT_POINTER(mm->exe_file, get_mm_exe_file(oldmm));
-       up_write(&oldmm->mmap_sem);
+       mmap_write_unlock(oldmm);
        return 0;
 }
 #define mm_alloc_pgd(mm)       (0)
@@ -1023,7 +1022,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
        mm->vmacache_seqnum = 0;
        atomic_set(&mm->mm_users, 1);
        atomic_set(&mm->mm_count, 1);
-       init_rwsem(&mm->mmap_sem);
+       mmap_init_lock(mm);
        INIT_LIST_HEAD(&mm->mmlist);
        mm->core_state = NULL;
        mm_pgtables_bytes_init(mm);
index b4b9f96..e646661 100644 (file)
@@ -698,10 +698,10 @@ static int fault_in_user_writeable(u32 __user *uaddr)
        struct mm_struct *mm = current->mm;
        int ret;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        ret = fixup_user_fault(current, mm, (unsigned long)uaddr,
                               FAULT_FLAG_WRITE, NULL);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return ret < 0 ? ret : 0;
 }
index 4c057dd..38cce34 100644 (file)
@@ -4424,7 +4424,7 @@ static void print_unlock_imbalance_bug(struct task_struct *curr,
                curr->comm, task_pid_nr(curr));
        print_lockdep_cache(lock);
        pr_cont(") at:\n");
-       print_ip_sym(ip);
+       print_ip_sym(KERN_WARNING, ip);
        pr_warn("but there are no more locks to release!\n");
        pr_warn("\nother info that might help us debug this:\n");
        lockdep_print_held_locks(curr);
@@ -5075,7 +5075,7 @@ static void print_lock_contention_bug(struct task_struct *curr,
                curr->comm, task_pid_nr(curr));
        print_lockdep_cache(lock);
        pr_cont(") at:\n");
-       print_ip_sym(ip);
+       print_ip_sym(KERN_WARNING, ip);
        pr_warn("but there are no locks held!\n");
        pr_warn("\nother info that might help us debug this:\n");
        lockdep_print_held_locks(curr);
index fd4fe1f..36e6910 100644 (file)
@@ -125,7 +125,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
 
        printk("\n%s/%d's [blocked] stackdump:\n\n",
                task->comm, task_pid_nr(task));
-       show_stack(task, NULL);
+       show_stack(task, NULL, KERN_DEFAULT);
        printk("\n%s/%d's [current] stackdump:\n\n",
                current->comm, task_pid_nr(current));
        dump_stack();
index 6598001..881128b 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <linux/uaccess.h>
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm/io.h>
 
index 2048672..72fe443 100644 (file)
@@ -91,7 +91,7 @@ static void relay_free_page_array(struct page **array)
  *
  *     Returns 0 if ok, negative on error
  *
- *     Caller should already have grabbed mmap_sem.
+ *     Caller should already have grabbed mmap_lock.
  */
 static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
 {
index 8298b2c..8f36032 100644 (file)
@@ -3922,8 +3922,7 @@ static noinline void __schedule_bug(struct task_struct *prev)
        if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)
            && in_atomic_preempt_off()) {
                pr_err("Preemption disabled at:");
-               print_ip_sym(preempt_disable_ip);
-               pr_cont("\n");
+               print_ip_sym(KERN_ERR, preempt_disable_ip);
        }
        if (panic_on_warn)
                panic("scheduling while atomic\n");
@@ -6026,7 +6025,7 @@ void sched_show_task(struct task_struct *p)
                (unsigned long)task_thread_info(p)->flags);
 
        print_worker_info(KERN_INFO, p);
-       show_stack(p, NULL);
+       show_stack(p, NULL, KERN_INFO);
        put_task_stack(p);
 }
 EXPORT_SYMBOL_GPL(sched_show_task);
@@ -6871,8 +6870,7 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
        if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)
            && !preempt_count_equals(preempt_offset)) {
                pr_err("Preemption disabled at:");
-               print_ip_sym(preempt_disable_ip);
-               pr_cont("\n");
+               print_ip_sym(KERN_ERR, preempt_disable_ip);
        }
        dump_stack();
        add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
index 35f4cc0..cbcb2f7 100644 (file)
@@ -2770,7 +2770,7 @@ static void task_numa_work(struct callback_head *work)
                return;
 
 
-       if (!down_read_trylock(&mm->mmap_sem))
+       if (!mmap_read_trylock(mm))
                return;
        vma = find_vma(mm, start);
        if (!vma) {
@@ -2838,7 +2838,7 @@ out:
                mm->numa_scan_offset = start;
        else
                reset_ptenuma_scan(p);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /*
         * Make sure tasks use at least 32x as much time to run other code
index 891667a..fd46865 100644 (file)
@@ -1846,7 +1846,7 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
        if (exe_file) {
                struct vm_area_struct *vma;
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                for (vma = mm->mmap; vma; vma = vma->vm_next) {
                        if (!vma->vm_file)
                                continue;
@@ -1855,7 +1855,7 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
                                goto exit_err;
                }
 
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                fput(exe_file);
        }
 
@@ -1869,7 +1869,7 @@ exit:
        fdput(exe);
        return err;
 exit_err:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        fput(exe_file);
        goto exit;
 }
@@ -2007,10 +2007,10 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data
        }
 
        /*
-        * arg_lock protects concurent updates but we still need mmap_sem for
+        * arg_lock protects concurent updates but we still need mmap_lock for
         * read to exclude races with sys_brk.
         */
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        /*
         * We don't validate if these members are pointing to
@@ -2049,7 +2049,7 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data
        if (prctl_map.auxv_size)
                memcpy(mm->saved_auxv, user_auxv, sizeof(user_auxv));
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return 0;
 }
 #endif /* CONFIG_CHECKPOINT_RESTORE */
@@ -2122,10 +2122,10 @@ static int prctl_set_mm(int opt, unsigned long addr,
 
        /*
         * arg_lock protects concurent updates of arg boundaries, we need
-        * mmap_sem for a) concurrent sys_brk, b) finding VMA for addr
+        * mmap_lock for a) concurrent sys_brk, b) finding VMA for addr
         * validation.
         */
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, addr);
 
        spin_lock(&mm->arg_lock);
@@ -2217,7 +2217,7 @@ static int prctl_set_mm(int opt, unsigned long addr,
        error = 0;
 out:
        spin_unlock(&mm->arg_lock);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return error;
 }
 
@@ -2442,13 +2442,13 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
        case PR_SET_THP_DISABLE:
                if (arg3 || arg4 || arg5)
                        return -EINVAL;
-               if (down_write_killable(&me->mm->mmap_sem))
+               if (mmap_write_lock_killable(me->mm))
                        return -EINTR;
                if (arg2)
                        set_bit(MMF_DISABLE_THP, &me->mm->flags);
                else
                        clear_bit(MMF_DISABLE_THP, &me->mm->flags);
-               up_write(&me->mm->mmap_sem);
+               mmap_write_unlock(me->mm);
                break;
        case PR_MPX_ENABLE_MANAGEMENT:
        case PR_MPX_DISABLE_MANAGEMENT:
index 3744372..e729c9e 100644 (file)
@@ -136,17 +136,23 @@ static const struct bpf_func_proto bpf_override_return_proto = {
 };
 #endif
 
-BPF_CALL_3(bpf_probe_read_user, void *, dst, u32, size,
-          const void __user *, unsafe_ptr)
+static __always_inline int
+bpf_probe_read_user_common(void *dst, u32 size, const void __user *unsafe_ptr)
 {
-       int ret = probe_user_read(dst, unsafe_ptr, size);
+       int ret;
 
+       ret = probe_user_read(dst, unsafe_ptr, size);
        if (unlikely(ret < 0))
                memset(dst, 0, size);
-
        return ret;
 }
 
+BPF_CALL_3(bpf_probe_read_user, void *, dst, u32, size,
+          const void __user *, unsafe_ptr)
+{
+       return bpf_probe_read_user_common(dst, size, unsafe_ptr);
+}
+
 const struct bpf_func_proto bpf_probe_read_user_proto = {
        .func           = bpf_probe_read_user,
        .gpl_only       = true,
@@ -156,17 +162,24 @@ const struct bpf_func_proto bpf_probe_read_user_proto = {
        .arg3_type      = ARG_ANYTHING,
 };
 
-BPF_CALL_3(bpf_probe_read_user_str, void *, dst, u32, size,
-          const void __user *, unsafe_ptr)
+static __always_inline int
+bpf_probe_read_user_str_common(void *dst, u32 size,
+                              const void __user *unsafe_ptr)
 {
-       int ret = strncpy_from_unsafe_user(dst, unsafe_ptr, size);
+       int ret;
 
+       ret = strncpy_from_user_nofault(dst, unsafe_ptr, size);
        if (unlikely(ret < 0))
                memset(dst, 0, size);
-
        return ret;
 }
 
+BPF_CALL_3(bpf_probe_read_user_str, void *, dst, u32, size,
+          const void __user *, unsafe_ptr)
+{
+       return bpf_probe_read_user_str_common(dst, size, unsafe_ptr);
+}
+
 const struct bpf_func_proto bpf_probe_read_user_str_proto = {
        .func           = bpf_probe_read_user_str,
        .gpl_only       = true,
@@ -177,25 +190,25 @@ const struct bpf_func_proto bpf_probe_read_user_str_proto = {
 };
 
 static __always_inline int
-bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr,
-                            const bool compat)
+bpf_probe_read_kernel_common(void *dst, u32 size, const void *unsafe_ptr)
 {
        int ret = security_locked_down(LOCKDOWN_BPF_READ);
 
        if (unlikely(ret < 0))
-               goto out;
-       ret = compat ? probe_kernel_read(dst, unsafe_ptr, size) :
-             probe_kernel_read_strict(dst, unsafe_ptr, size);
+               goto fail;
+       ret = probe_kernel_read(dst, unsafe_ptr, size);
        if (unlikely(ret < 0))
-out:
-               memset(dst, 0, size);
+               goto fail;
+       return ret;
+fail:
+       memset(dst, 0, size);
        return ret;
 }
 
 BPF_CALL_3(bpf_probe_read_kernel, void *, dst, u32, size,
           const void *, unsafe_ptr)
 {
-       return bpf_probe_read_kernel_common(dst, size, unsafe_ptr, false);
+       return bpf_probe_read_kernel_common(dst, size, unsafe_ptr);
 }
 
 const struct bpf_func_proto bpf_probe_read_kernel_proto = {
@@ -207,50 +220,37 @@ const struct bpf_func_proto bpf_probe_read_kernel_proto = {
        .arg3_type      = ARG_ANYTHING,
 };
 
-BPF_CALL_3(bpf_probe_read_compat, void *, dst, u32, size,
-          const void *, unsafe_ptr)
-{
-       return bpf_probe_read_kernel_common(dst, size, unsafe_ptr, true);
-}
-
-static const struct bpf_func_proto bpf_probe_read_compat_proto = {
-       .func           = bpf_probe_read_compat,
-       .gpl_only       = true,
-       .ret_type       = RET_INTEGER,
-       .arg1_type      = ARG_PTR_TO_UNINIT_MEM,
-       .arg2_type      = ARG_CONST_SIZE_OR_ZERO,
-       .arg3_type      = ARG_ANYTHING,
-};
-
 static __always_inline int
-bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr,
-                                const bool compat)
+bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr)
 {
        int ret = security_locked_down(LOCKDOWN_BPF_READ);
 
        if (unlikely(ret < 0))
-               goto out;
+               goto fail;
+
        /*
-        * The strncpy_from_unsafe_*() call will likely not fill the entire
-        * buffer, but that's okay in this circumstance as we're probing
+        * The strncpy_from_kernel_nofault() call will likely not fill the
+        * entire buffer, but that's okay in this circumstance as we're probing
         * arbitrary memory anyway similar to bpf_probe_read_*() and might
         * as well probe the stack. Thus, memory is explicitly cleared
         * only in error case, so that improper users ignoring return
         * code altogether don't copy garbage; otherwise length of string
         * is returned that can be used for bpf_perf_event_output() et al.
         */
-       ret = compat ? strncpy_from_unsafe(dst, unsafe_ptr, size) :
-             strncpy_from_unsafe_strict(dst, unsafe_ptr, size);
+       ret = strncpy_from_kernel_nofault(dst, unsafe_ptr, size);
        if (unlikely(ret < 0))
-out:
-               memset(dst, 0, size);
+               goto fail;
+
+       return 0;
+fail:
+       memset(dst, 0, size);
        return ret;
 }
 
 BPF_CALL_3(bpf_probe_read_kernel_str, void *, dst, u32, size,
           const void *, unsafe_ptr)
 {
-       return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr, false);
+       return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr);
 }
 
 const struct bpf_func_proto bpf_probe_read_kernel_str_proto = {
@@ -262,10 +262,34 @@ const struct bpf_func_proto bpf_probe_read_kernel_str_proto = {
        .arg3_type      = ARG_ANYTHING,
 };
 
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+BPF_CALL_3(bpf_probe_read_compat, void *, dst, u32, size,
+          const void *, unsafe_ptr)
+{
+       if ((unsigned long)unsafe_ptr < TASK_SIZE) {
+               return bpf_probe_read_user_common(dst, size,
+                               (__force void __user *)unsafe_ptr);
+       }
+       return bpf_probe_read_kernel_common(dst, size, unsafe_ptr);
+}
+
+static const struct bpf_func_proto bpf_probe_read_compat_proto = {
+       .func           = bpf_probe_read_compat,
+       .gpl_only       = true,
+       .ret_type       = RET_INTEGER,
+       .arg1_type      = ARG_PTR_TO_UNINIT_MEM,
+       .arg2_type      = ARG_CONST_SIZE_OR_ZERO,
+       .arg3_type      = ARG_ANYTHING,
+};
+
 BPF_CALL_3(bpf_probe_read_compat_str, void *, dst, u32, size,
           const void *, unsafe_ptr)
 {
-       return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr, true);
+       if ((unsigned long)unsafe_ptr < TASK_SIZE) {
+               return bpf_probe_read_user_str_common(dst, size,
+                               (__force void __user *)unsafe_ptr);
+       }
+       return bpf_probe_read_kernel_str_common(dst, size, unsafe_ptr);
 }
 
 static const struct bpf_func_proto bpf_probe_read_compat_str_proto = {
@@ -276,6 +300,7 @@ static const struct bpf_func_proto bpf_probe_read_compat_str_proto = {
        .arg2_type      = ARG_CONST_SIZE_OR_ZERO,
        .arg3_type      = ARG_ANYTHING,
 };
+#endif /* CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE */
 
 BPF_CALL_3(bpf_probe_write_user, void __user *, unsafe_ptr, const void *, src,
           u32, size)
@@ -324,6 +349,31 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void)
        return &bpf_probe_write_user_proto;
 }
 
+static void bpf_trace_copy_string(char *buf, void *unsafe_ptr, char fmt_ptype,
+               size_t bufsz)
+{
+       void __user *user_ptr = (__force void __user *)unsafe_ptr;
+
+       buf[0] = 0;
+
+       switch (fmt_ptype) {
+       case 's':
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+               if ((unsigned long)unsafe_ptr < TASK_SIZE) {
+                       strncpy_from_user_nofault(buf, user_ptr, bufsz);
+                       break;
+               }
+               fallthrough;
+#endif
+       case 'k':
+               strncpy_from_kernel_nofault(buf, unsafe_ptr, bufsz);
+               break;
+       case 'u':
+               strncpy_from_user_nofault(buf, user_ptr, bufsz);
+               break;
+       }
+}
+
 /*
  * Only limited trace_printk() conversion specifiers allowed:
  * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %pks %pus %s
@@ -406,24 +456,8 @@ fmt_str:
                                break;
                        }
 
-                       buf[0] = 0;
-                       switch (fmt_ptype) {
-                       case 's':
-#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
-                               strncpy_from_unsafe(buf, unsafe_ptr,
-                                                   sizeof(buf));
-                               break;
-#endif
-                       case 'k':
-                               strncpy_from_unsafe_strict(buf, unsafe_ptr,
-                                                          sizeof(buf));
-                               break;
-                       case 'u':
-                               strncpy_from_unsafe_user(buf,
-                                       (__force void __user *)unsafe_ptr,
-                                                        sizeof(buf));
-                               break;
-                       }
+                       bpf_trace_copy_string(buf, unsafe_ptr, fmt_ptype,
+                                       sizeof(buf));
                        goto fmt_next;
                }
 
@@ -579,15 +613,17 @@ BPF_CALL_5(bpf_seq_printf, struct seq_file *, m, char *, fmt, u32, fmt_size,
                }
 
                if (fmt[i] == 's') {
+                       void *unsafe_ptr;
+
                        /* try our best to copy */
                        if (memcpy_cnt >= MAX_SEQ_PRINTF_MAX_MEMCPY) {
                                err = -E2BIG;
                                goto out;
                        }
 
-                       err = strncpy_from_unsafe_strict(bufs->buf[memcpy_cnt],
-                                                        (void *) (long) args[fmt_cnt],
-                                                        MAX_SEQ_PRINTF_STR_LEN);
+                       unsafe_ptr = (void *)(long)args[fmt_cnt];
+                       err = strncpy_from_kernel_nofault(bufs->buf[memcpy_cnt],
+                                       unsafe_ptr, MAX_SEQ_PRINTF_STR_LEN);
                        if (err < 0)
                                bufs->buf[memcpy_cnt][0] = '\0';
                        params[fmt_cnt] = (u64)(long)bufs->buf[memcpy_cnt];
index b5765ae..7d0ebd1 100644 (file)
@@ -2020,12 +2020,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
        case -EFAULT:
                FTRACE_WARN_ON_ONCE(1);
                pr_info("ftrace faulted on modifying ");
-               print_ip_sym(ip);
+               print_ip_sym(KERN_INFO, ip);
                break;
        case -EINVAL:
                FTRACE_WARN_ON_ONCE(1);
                pr_info("ftrace failed to modify ");
-               print_ip_sym(ip);
+               print_ip_sym(KERN_INFO, ip);
                print_ip_ins(" actual:   ", (unsigned char *)ip);
                pr_cont("\n");
                if (ftrace_expected) {
@@ -2036,12 +2036,12 @@ void ftrace_bug(int failed, struct dyn_ftrace *rec)
        case -EPERM:
                FTRACE_WARN_ON_ONCE(1);
                pr_info("ftrace faulted on writing ");
-               print_ip_sym(ip);
+               print_ip_sym(KERN_INFO, ip);
                break;
        default:
                FTRACE_WARN_ON_ONCE(1);
                pr_info("ftrace faulted on unknown error ");
-               print_ip_sym(ip);
+               print_ip_sym(KERN_INFO, ip);
        }
        print_bug_type();
        if (rec) {
index 3598938..ea8d0b0 100644 (file)
@@ -1202,11 +1202,25 @@ static const struct file_operations kprobe_profile_ops = {
 
 /* Return the length of string -- including null terminal byte */
 static nokprobe_inline int
+fetch_store_strlen_user(unsigned long addr)
+{
+       const void __user *uaddr =  (__force const void __user *)addr;
+
+       return strnlen_user_nofault(uaddr, MAX_STRING_SIZE);
+}
+
+/* Return the length of string -- including null terminal byte */
+static nokprobe_inline int
 fetch_store_strlen(unsigned long addr)
 {
        int ret, len = 0;
        u8 c;
 
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       if (addr < TASK_SIZE)
+               return fetch_store_strlen_user(addr);
+#endif
+
        do {
                ret = probe_kernel_read(&c, (u8 *)addr + len, 1);
                len++;
@@ -1215,22 +1229,14 @@ fetch_store_strlen(unsigned long addr)
        return (ret < 0) ? ret : len;
 }
 
-/* Return the length of string -- including null terminal byte */
-static nokprobe_inline int
-fetch_store_strlen_user(unsigned long addr)
-{
-       const void __user *uaddr =  (__force const void __user *)addr;
-
-       return strnlen_unsafe_user(uaddr, MAX_STRING_SIZE);
-}
-
 /*
- * Fetch a null-terminated string. Caller MUST set *(u32 *)buf with max
- * length and relative data location.
+ * Fetch a null-terminated string from user. Caller MUST set *(u32 *)buf
+ * with max length and relative data location.
  */
 static nokprobe_inline int
-fetch_store_string(unsigned long addr, void *dest, void *base)
+fetch_store_string_user(unsigned long addr, void *dest, void *base)
 {
+       const void __user *uaddr =  (__force const void __user *)addr;
        int maxlen = get_loc_len(*(u32 *)dest);
        void *__dest;
        long ret;
@@ -1240,11 +1246,7 @@ fetch_store_string(unsigned long addr, void *dest, void *base)
 
        __dest = get_loc_data(dest, base);
 
-       /*
-        * Try to get string again, since the string can be changed while
-        * probing.
-        */
-       ret = strncpy_from_unsafe(__dest, (void *)addr, maxlen);
+       ret = strncpy_from_user_nofault(__dest, uaddr, maxlen);
        if (ret >= 0)
                *(u32 *)dest = make_data_loc(ret, __dest - base);
 
@@ -1252,23 +1254,31 @@ fetch_store_string(unsigned long addr, void *dest, void *base)
 }
 
 /*
- * Fetch a null-terminated string from user. Caller MUST set *(u32 *)buf
- * with max length and relative data location.
+ * Fetch a null-terminated string. Caller MUST set *(u32 *)buf with max
+ * length and relative data location.
  */
 static nokprobe_inline int
-fetch_store_string_user(unsigned long addr, void *dest, void *base)
+fetch_store_string(unsigned long addr, void *dest, void *base)
 {
-       const void __user *uaddr =  (__force const void __user *)addr;
        int maxlen = get_loc_len(*(u32 *)dest);
        void *__dest;
        long ret;
 
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       if ((unsigned long)addr < TASK_SIZE)
+               return fetch_store_string_user(addr, dest, base);
+#endif
+
        if (unlikely(!maxlen))
                return -ENOMEM;
 
        __dest = get_loc_data(dest, base);
 
-       ret = strncpy_from_unsafe_user(__dest, uaddr, maxlen);
+       /*
+        * Try to get string again, since the string can be changed while
+        * probing.
+        */
+       ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen);
        if (ret >= 0)
                *(u32 *)dest = make_data_loc(ret, __dest - base);
 
@@ -1276,12 +1286,6 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base)
 }
 
 static nokprobe_inline int
-probe_mem_read(void *dest, void *src, size_t size)
-{
-       return probe_kernel_read(dest, src, size);
-}
-
-static nokprobe_inline int
 probe_mem_read_user(void *dest, void *src, size_t size)
 {
        const void __user *uaddr =  (__force const void __user *)src;
@@ -1289,6 +1293,16 @@ probe_mem_read_user(void *dest, void *src, size_t size)
        return probe_user_read(dest, uaddr, size);
 }
 
+static nokprobe_inline int
+probe_mem_read(void *dest, void *src, size_t size)
+{
+#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
+       if ((unsigned long)src < TASK_SIZE)
+               return probe_mem_read_user(dest, src, size);
+#endif
+       return probe_kernel_read(dest, src, size);
+}
+
 /* Note that we don't verify it, since the code does not come from user space */
 static int
 process_fetch_insn(struct fetch_insn *code, struct pt_regs *regs, void *dest,
index 9a121e1..73976de 100644 (file)
@@ -393,7 +393,7 @@ static int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
        if (mm) {
                const struct vm_area_struct *vma;
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = find_vma(mm, ip);
                if (vma) {
                        file = vma->vm_file;
@@ -405,7 +405,7 @@ static int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
                                trace_seq_printf(s, "[+0x%lx]",
                                                 ip - vmstart);
                }
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        }
        if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
                trace_seq_printf(s, " <" IP_FMT ">", ip);
index 33ffbf3..a00ee6e 100644 (file)
@@ -74,7 +74,7 @@ void show_regs_print_info(const char *log_lvl)
 static void __dump_stack(void)
 {
        dump_stack_print_info(KERN_DEFAULT);
-       show_stack(NULL, NULL);
+       show_stack(NULL, NULL, KERN_DEFAULT);
 }
 
 /**
index ad485f0..5ee3526 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/io.h>
 #include <linux/export.h>
 #include <asm/cacheflush.h>
-#include <asm/pgtable.h>
 
 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
 static int __read_mostly ioremap_p4d_capable;
index 5c1858e..2852828 100644 (file)
@@ -245,9 +245,9 @@ static int dmirror_range_fault(struct dmirror *dmirror,
                }
 
                range->notifier_seq = mmu_interval_read_begin(range->notifier);
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                ret = hmm_range_fault(range);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                if (ret) {
                        if (ret == -EBUSY)
                                continue;
@@ -686,7 +686,7 @@ static int dmirror_migrate(struct dmirror *dmirror,
        if (!mmget_not_zero(mm))
                return -EINVAL;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (addr = start; addr < end; addr = next) {
                vma = find_vma(mm, addr);
                if (!vma || addr < vma->vm_start ||
@@ -713,7 +713,7 @@ static int dmirror_migrate(struct dmirror *dmirror,
                dmirror_migrate_finalize_and_map(&args, dmirror);
                migrate_vma_finalize(&args);
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
 
        /* Return the migrated data for verification. */
@@ -733,7 +733,7 @@ static int dmirror_migrate(struct dmirror *dmirror,
        return ret;
 
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        mmput(mm);
        return ret;
 }
@@ -825,9 +825,9 @@ static int dmirror_range_snapshot(struct dmirror *dmirror,
 
                range->notifier_seq = mmu_interval_read_begin(range->notifier);
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                ret = hmm_range_fault(range);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                if (ret) {
                        if (ret == -EBUSY)
                                continue;
index 419fbac..f258743 100644 (file)
@@ -103,7 +103,7 @@ MODULE_PARM_DESC(lock_rcu, "grab rcu_read_lock: generate rcu stalls");
 
 static bool lock_mmap_sem;
 module_param(lock_mmap_sem, bool, 0400);
-MODULE_PARM_DESC(lock_mmap_sem, "lock mm->mmap_sem: block procfs interfaces");
+MODULE_PARM_DESC(lock_mmap_sem, "lock mm->mmap_lock: block procfs interfaces");
 
 static unsigned long lock_rwsem_ptr;
 module_param_unsafe(lock_rwsem_ptr, ulong, 0400);
@@ -191,11 +191,11 @@ static void test_lock(bool master, bool verbose)
 
        if (lock_mmap_sem && master) {
                if (verbose)
-                       pr_notice("lock mmap_sem pid=%d\n", main_task->pid);
+                       pr_notice("lock mmap_lock pid=%d\n", main_task->pid);
                if (lock_read)
-                       down_read(&main_task->mm->mmap_sem);
+                       mmap_read_lock(main_task->mm);
                else
-                       down_write(&main_task->mm->mmap_sem);
+                       mmap_write_lock(main_task->mm);
        }
 
        if (test_disable_irq)
@@ -276,11 +276,11 @@ static void test_unlock(bool master, bool verbose)
 
        if (lock_mmap_sem && master) {
                if (lock_read)
-                       up_read(&main_task->mm->mmap_sem);
+                       mmap_read_unlock(main_task->mm);
                else
-                       up_write(&main_task->mm->mmap_sem);
+                       mmap_write_unlock(main_task->mm);
                if (verbose)
-                       pr_notice("unlock mmap_sem pid=%d\n", main_task->pid);
+                       pr_notice("unlock mmap_lock pid=%d\n", main_task->pid);
        }
 
        if (lock_rwsem_ptr && master) {
@@ -505,7 +505,7 @@ static int __init test_lockup_init(void)
        }
 
        if (lock_mmap_sem && !main_task->mm) {
-               pr_err("no mm to lock mmap_sem\n");
+               pr_err("no mm to lock mmap_lock\n");
                return -EINVAL;
        }
 
index f2ede2d..b5b1de8 100644 (file)
@@ -120,9 +120,9 @@ void __dump_page(struct page *page, const char *reason)
                 * mapping can be invalid pointer and we don't want to crash
                 * accessing it, so probe everything depending on it carefully
                 */
-               if (probe_kernel_read_strict(&host, &mapping->host,
-                                               sizeof(struct inode *)) ||
-                   probe_kernel_read_strict(&a_ops, &mapping->a_ops,
+               if (probe_kernel_read(&host, &mapping->host,
+                                       sizeof(struct inode *)) ||
+                   probe_kernel_read(&a_ops, &mapping->a_ops,
                                sizeof(struct address_space_operations *))) {
                        pr_warn("failed to read mapping->host or a_ops, mapping not a valid kernel address?\n");
                        goto out_mapping;
@@ -133,7 +133,7 @@ void __dump_page(struct page *page, const char *reason)
                        goto out_mapping;
                }
 
-               if (probe_kernel_read_strict(&dentry_first,
+               if (probe_kernel_read(&dentry_first,
                        &host->i_dentry.first, sizeof(struct hlist_node *))) {
                        pr_warn("mapping->a_ops:%ps with invalid mapping->host inode address %px\n",
                                a_ops, host);
@@ -146,7 +146,7 @@ void __dump_page(struct page *page, const char *reason)
                }
 
                dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias);
-               if (probe_kernel_read_strict(&dentry, dentry_ptr,
+               if (probe_kernel_read(&dentry, dentry_ptr,
                                                        sizeof(struct dentry))) {
                        pr_warn("mapping->aops:%ps with invalid mapping->host->i_dentry.first %px\n",
                                a_ops, dentry_ptr);
index 188c189..9ec59c3 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/start_kernel.h>
 #include <linux/sched/mm.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 #define VMFLAGS        (VM_READ|VM_WRITE|VM_EXEC)
 
index b1a4189..f0ae9a6 100644 (file)
  *  ->i_mutex
  *    ->i_mmap_rwsem           (truncate->unmap_mapping_range)
  *
- *  ->mmap_sem
+ *  ->mmap_lock
  *    ->i_mmap_rwsem
  *      ->page_table_lock or pte_lock  (various, mainly in memory.c)
  *        ->i_pages lock       (arch-dependent flush_dcache_mmap_lock)
  *
- *  ->mmap_sem
+ *  ->mmap_lock
  *    ->lock_page              (access_process_vm)
  *
  *  ->i_mutex                  (generic_perform_write)
- *    ->mmap_sem               (fault_in_pages_readable->do_page_fault)
+ *    ->mmap_lock              (fault_in_pages_readable->do_page_fault)
  *
  *  bdi->wb.list_lock
  *    sb_lock                  (fs/fs-writeback.c)
@@ -1371,27 +1371,27 @@ EXPORT_SYMBOL_GPL(__lock_page_killable);
 
 /*
  * Return values:
- * 1 - page is locked; mmap_sem is still held.
+ * 1 - page is locked; mmap_lock is still held.
  * 0 - page is not locked.
- *     mmap_sem has been released (up_read()), unless flags had both
+ *     mmap_lock has been released (mmap_read_unlock(), unless flags had both
  *     FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_RETRY_NOWAIT set, in
- *     which case mmap_sem is still held.
+ *     which case mmap_lock is still held.
  *
  * If neither ALLOW_RETRY nor KILLABLE are set, will always return 1
- * with the page locked and the mmap_sem unperturbed.
+ * with the page locked and the mmap_lock unperturbed.
  */
 int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
                         unsigned int flags)
 {
        if (fault_flag_allow_retry_first(flags)) {
                /*
-                * CAUTION! In this case, mmap_sem is not released
+                * CAUTION! In this case, mmap_lock is not released
                 * even though return 0.
                 */
                if (flags & FAULT_FLAG_RETRY_NOWAIT)
                        return 0;
 
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                if (flags & FAULT_FLAG_KILLABLE)
                        wait_on_page_locked_killable(page);
                else
@@ -1403,7 +1403,7 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
 
                        ret = __lock_page_killable(page);
                        if (ret) {
-                               up_read(&mm->mmap_sem);
+                               mmap_read_unlock(mm);
                                return 0;
                        }
                } else
@@ -2313,14 +2313,14 @@ EXPORT_SYMBOL(generic_file_read_iter);
 #ifdef CONFIG_MMU
 #define MMAP_LOTSAMISS  (100)
 /*
- * lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_sem
+ * lock_page_maybe_drop_mmap - lock the page, possibly dropping the mmap_lock
  * @vmf - the vm_fault for this fault.
  * @page - the page to lock.
  * @fpin - the pointer to the file we may pin (or is already pinned).
  *
- * This works similar to lock_page_or_retry in that it can drop the mmap_sem.
+ * This works similar to lock_page_or_retry in that it can drop the mmap_lock.
  * It differs in that it actually returns the page locked if it returns 1 and 0
- * if it couldn't lock the page.  If we did have to drop the mmap_sem then fpin
+ * if it couldn't lock the page.  If we did have to drop the mmap_lock then fpin
  * will point to the pinned file and needs to be fput()'ed at a later point.
  */
 static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,
@@ -2331,7 +2331,7 @@ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,
 
        /*
         * NOTE! This will make us return with VM_FAULT_RETRY, but with
-        * the mmap_sem still held. That's how FAULT_FLAG_RETRY_NOWAIT
+        * the mmap_lock still held. That's how FAULT_FLAG_RETRY_NOWAIT
         * is supposed to work. We have way too many special cases..
         */
        if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT)
@@ -2341,13 +2341,13 @@ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page,
        if (vmf->flags & FAULT_FLAG_KILLABLE) {
                if (__lock_page_killable(page)) {
                        /*
-                        * We didn't have the right flags to drop the mmap_sem,
+                        * We didn't have the right flags to drop the mmap_lock,
                         * but all fault_handlers only check for fatal signals
                         * if we return VM_FAULT_RETRY, so we need to drop the
-                        * mmap_sem here and return 0 if we don't have a fpin.
+                        * mmap_lock here and return 0 if we don't have a fpin.
                         */
                        if (*fpin == NULL)
-                               up_read(&vmf->vma->vm_mm->mmap_sem);
+                               mmap_read_unlock(vmf->vma->vm_mm);
                        return 0;
                }
        } else
@@ -2409,7 +2409,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
 /*
  * Asynchronous readahead happens when we find the page and PG_readahead,
  * so we want to possibly extend the readahead further.  We return the file that
- * was pinned if we have to drop the mmap_sem in order to do IO.
+ * was pinned if we have to drop the mmap_lock in order to do IO.
  */
 static struct file *do_async_mmap_readahead(struct vm_fault *vmf,
                                            struct page *page)
@@ -2444,12 +2444,12 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf,
  * it in the page cache, and handles the special cases reasonably without
  * having a lot of duplicated code.
  *
- * vma->vm_mm->mmap_sem must be held on entry.
+ * vma->vm_mm->mmap_lock must be held on entry.
  *
- * If our return value has VM_FAULT_RETRY set, it's because the mmap_sem
+ * If our return value has VM_FAULT_RETRY set, it's because the mmap_lock
  * may be dropped before doing I/O or by lock_page_maybe_drop_mmap().
  *
- * If our return value does not have VM_FAULT_RETRY set, the mmap_sem
+ * If our return value does not have VM_FAULT_RETRY set, the mmap_lock
  * has not been released.
  *
  * We never return with VM_FAULT_RETRY and a bit from VM_FAULT_ERROR set.
@@ -2519,7 +2519,7 @@ retry_find:
                goto page_not_uptodate;
 
        /*
-        * We've made it this far and we had to drop our mmap_sem, now is the
+        * We've made it this far and we had to drop our mmap_lock, now is the
         * time to return to the upper layer and have it re-find the vma and
         * redo the fault.
         */
@@ -2569,7 +2569,7 @@ page_not_uptodate:
 
 out_retry:
        /*
-        * We dropped the mmap_sem, we need to return to the fault handler to
+        * We dropped the mmap_lock, we need to return to the fault handler to
         * re-find the vma and come back and find our hopefully still populated
         * page.
         */
index 4107dbc..10f82d5 100644 (file)
@@ -29,7 +29,7 @@
  * different type underlying the specified range of virtual addresses.
  * When the function isn't able to map a single page, it returns error.
  *
- * This function takes care of grabbing mmap_sem as necessary.
+ * This function takes care of grabbing mmap_lock as necessary.
  */
 int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
                     unsigned int gup_flags, struct frame_vector *vec)
@@ -48,7 +48,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
 
        start = untagged_addr(start);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        locked = 1;
        vma = find_vma_intersection(mm, start, start + 1);
        if (!vma) {
@@ -102,7 +102,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
        } while (vma && vma->vm_flags & (VM_IO | VM_PFNMAP));
 out:
        if (locked)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        if (!ret)
                ret = -EFAULT;
        if (ret > 0)
index 8bd090b..de9e362 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -19,7 +19,6 @@
 #include <linux/sched/mm.h>
 
 #include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 
 #include "internal.h"
@@ -593,7 +592,7 @@ retry:
                pmdval = READ_ONCE(*pmd);
                /*
                 * MADV_DONTNEED may convert the pmd to null because
-                * mmap_sem is held in read mode
+                * mmap_lock is held in read mode
                 */
                if (pmd_none(pmdval))
                        return no_page_table(vma, flags);
@@ -856,8 +855,8 @@ unmap:
 }
 
 /*
- * mmap_sem must be held on entry.  If @locked != NULL and *@flags
- * does not include FOLL_NOWAIT, the mmap_sem may be released.  If it
+ * mmap_lock must be held on entry.  If @locked != NULL and *@flags
+ * does not include FOLL_NOWAIT, the mmap_lock may be released.  If it
  * is, *@locked will be set to 0 and -EBUSY returned.
  */
 static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma,
@@ -980,7 +979,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
  *             only intends to ensure the pages are faulted in.
  * @vmas:      array of pointers to vmas corresponding to each page.
  *             Or NULL if the caller does not require them.
- * @locked:     whether we're still with the mmap_sem held
+ * @locked:     whether we're still with the mmap_lock held
  *
  * Returns either number of pages pinned (which may be less than the
  * number requested), or an error. Details about the return value:
@@ -993,9 +992,9 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
  *
  * The caller is responsible for releasing returned @pages, via put_page().
  *
- * @vmas are valid only as long as mmap_sem is held.
+ * @vmas are valid only as long as mmap_lock is held.
  *
- * Must be called with mmap_sem held.  It may be released.  See below.
+ * Must be called with mmap_lock held.  It may be released.  See below.
  *
  * __get_user_pages walks a process's page tables and takes a reference to
  * each struct page that each user address corresponds to at a given
@@ -1016,12 +1015,12 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags)
  * appropriate) must be called after the page is finished with, and
  * before put_page is called.
  *
- * If @locked != NULL, *@locked will be set to 0 when mmap_sem is
+ * If @locked != NULL, *@locked will be set to 0 when mmap_lock is
  * released by an up_read().  That can happen if @gup_flags does not
  * have FOLL_NOWAIT.
  *
  * A caller using such a combination of @locked and @gup_flags
- * must therefore hold the mmap_sem for reading only, and recognize
+ * must therefore hold the mmap_lock for reading only, and recognize
  * when it's been released.  Otherwise, it must be held for either
  * reading or writing and will not be released.
  *
@@ -1084,7 +1083,7 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                                if (locked && *locked == 0) {
                                        /*
                                         * We've got a VM_FAULT_RETRY
-                                        * and we've lost mmap_sem.
+                                        * and we've lost mmap_lock.
                                         * We must stop here.
                                         */
                                        BUG_ON(gup_flags & FOLL_NOWAIT);
@@ -1191,7 +1190,7 @@ static bool vma_permits_fault(struct vm_area_struct *vma,
  * @mm:                mm_struct of target mm
  * @address:   user address
  * @fault_flags:flags to pass down to handle_mm_fault()
- * @unlocked:  did we unlock the mmap_sem while retrying, maybe NULL if caller
+ * @unlocked:  did we unlock the mmap_lock while retrying, maybe NULL if caller
  *             does not allow retry. If NULL, the caller must guarantee
  *             that fault_flags does not contain FAULT_FLAG_ALLOW_RETRY.
  *
@@ -1212,8 +1211,8 @@ static bool vma_permits_fault(struct vm_area_struct *vma,
  * such architectures, gup() will not be enough to make a subsequent access
  * succeed.
  *
- * This function will not return with an unlocked mmap_sem. So it has not the
- * same semantics wrt the @mm->mmap_sem as does filemap_fault().
+ * This function will not return with an unlocked mmap_lock. So it has not the
+ * same semantics wrt the @mm->mmap_lock as does filemap_fault().
  */
 int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
                     unsigned long address, unsigned int fault_flags,
@@ -1250,7 +1249,7 @@ retry:
        }
 
        if (ret & VM_FAULT_RETRY) {
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                *unlocked = true;
                fault_flags |= FAULT_FLAG_TRIED;
                goto retry;
@@ -1355,7 +1354,7 @@ retry:
                        break;
                }
 
-               ret = down_read_killable(&mm->mmap_sem);
+               ret = mmap_read_lock_killable(mm);
                if (ret) {
                        BUG_ON(ret > 0);
                        if (!pages_done)
@@ -1390,7 +1389,7 @@ retry:
                 * We must let the caller know we temporarily dropped the lock
                 * and so the critical section protected by it was lost.
                 */
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                *locked = 0;
        }
        return pages_done;
@@ -1401,13 +1400,13 @@ retry:
  * @vma:   target vma
  * @start: start address
  * @end:   end address
- * @locked: whether the mmap_sem is still held
+ * @locked: whether the mmap_lock is still held
  *
  * This takes care of mlocking the pages too if VM_LOCKED is set.
  *
  * return 0 on success, negative error code on error.
  *
- * vma->vm_mm->mmap_sem must be held.
+ * vma->vm_mm->mmap_lock must be held.
  *
  * If @locked is NULL, it may be held for read or write and will
  * be unperturbed.
@@ -1426,7 +1425,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
        VM_BUG_ON(end   & ~PAGE_MASK);
        VM_BUG_ON_VMA(start < vma->vm_start, vma);
        VM_BUG_ON_VMA(end   > vma->vm_end, vma);
-       VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
+       mmap_assert_locked(mm);
 
        gup_flags = FOLL_TOUCH | FOLL_POPULATE | FOLL_MLOCK;
        if (vma->vm_flags & VM_LOCKONFAULT)
@@ -1459,7 +1458,7 @@ long populate_vma_page_range(struct vm_area_struct *vma,
  *
  * This is used to implement mlock() and the MAP_POPULATE / MAP_LOCKED mmap
  * flags. VMAs must be already marked with the desired vm_flags, and
- * mmap_sem must not be held.
+ * mmap_lock must not be held.
  */
 int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
 {
@@ -1478,7 +1477,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
                 */
                if (!locked) {
                        locked = 1;
-                       down_read(&mm->mmap_sem);
+                       mmap_read_lock(mm);
                        vma = find_vma(mm, nstart);
                } else if (nstart >= vma->vm_end)
                        vma = vma->vm_next;
@@ -1510,7 +1509,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
                ret = 0;
        }
        if (locked)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        return ret;     /* 0 or negative error code */
 }
 
@@ -1526,7 +1525,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
  * NULL wherever the ZERO_PAGE, or an anonymous pte_none, has been found -
  * allowing a hole to be left in the corefile to save diskspace.
  *
- * Called without mmap_sem, but after all other threads have been killed.
+ * Called without mmap_lock, but after all other threads have been killed.
  */
 #ifdef CONFIG_ELF_CORE
 struct page *get_dump_page(unsigned long addr)
@@ -1887,9 +1886,9 @@ static long __get_user_pages_remote(struct task_struct *tsk,
  *
  * The caller is responsible for releasing returned @pages, via put_page().
  *
- * @vmas are valid only as long as mmap_sem is held.
+ * @vmas are valid only as long as mmap_lock is held.
  *
- * Must be called with mmap_sem held for read or write.
+ * Must be called with mmap_lock held for read or write.
  *
  * get_user_pages_remote walks a process's page tables and takes a reference
  * to each struct page that each user address corresponds to at a given
@@ -1994,19 +1993,19 @@ EXPORT_SYMBOL(get_user_pages);
 /**
  * get_user_pages_locked() is suitable to replace the form:
  *
- *      down_read(&mm->mmap_sem);
+ *      mmap_read_lock(mm);
  *      do_something()
  *      get_user_pages(tsk, mm, ..., pages, NULL);
- *      up_read(&mm->mmap_sem);
+ *      mmap_read_unlock(mm);
  *
  *  to:
  *
  *      int locked = 1;
- *      down_read(&mm->mmap_sem);
+ *      mmap_read_lock(mm);
  *      do_something()
  *      get_user_pages_locked(tsk, mm, ..., pages, &locked);
  *      if (locked)
- *          up_read(&mm->mmap_sem);
+ *          mmap_read_unlock(mm);
  *
  * @start:      starting user address
  * @nr_pages:   number of pages from start to pin
@@ -2051,9 +2050,9 @@ EXPORT_SYMBOL(get_user_pages_locked);
 /*
  * get_user_pages_unlocked() is suitable to replace the form:
  *
- *      down_read(&mm->mmap_sem);
+ *      mmap_read_lock(mm);
  *      get_user_pages(tsk, mm, ..., pages, NULL);
- *      up_read(&mm->mmap_sem);
+ *      mmap_read_unlock(mm);
  *
  *  with:
  *
@@ -2079,11 +2078,11 @@ long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
        if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM))
                return -EINVAL;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        ret = __get_user_pages_locked(current, mm, start, nr_pages, pages, NULL,
                                      &locked, gup_flags | FOLL_TOUCH);
        if (locked)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        return ret;
 }
 EXPORT_SYMBOL(get_user_pages_unlocked);
@@ -2724,11 +2723,11 @@ static int __gup_longterm_unlocked(unsigned long start, int nr_pages,
         * get_user_pages_unlocked() (see comments in that function)
         */
        if (gup_flags & FOLL_LONGTERM) {
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                ret = __gup_longterm_locked(current, current->mm,
                                            start, nr_pages,
                                            pages, NULL, gup_flags);
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
        } else {
                ret = get_user_pages_unlocked(start, nr_pages,
                                              pages, gup_flags);
@@ -2751,7 +2750,7 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages,
                return -EINVAL;
 
        if (!(gup_flags & FOLL_FAST_ONLY))
-               might_lock_read(&current->mm->mmap_sem);
+               might_lock_read(&current->mm->mmap_lock);
 
        start = untagged_addr(start) & PAGE_MASK;
        addr = start;
@@ -2874,7 +2873,7 @@ EXPORT_SYMBOL_GPL(get_user_pages_fast_only);
  * @pages:      array that receives pointers to the pages pinned.
  *              Should be at least nr_pages long.
  *
- * Attempt to pin user pages in memory without taking mm->mmap_sem.
+ * Attempt to pin user pages in memory without taking mm->mmap_lock.
  * If not successful, it will fall back to taking the lock and
  * calling get_user_pages().
  *
index 41673a6..e9a5457 100644 (file)
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -563,7 +563,7 @@ int hmm_range_fault(struct hmm_range *range)
        struct mm_struct *mm = range->notifier->mm;
        int ret;
 
-       lockdep_assert_held(&mm->mmap_sem);
+       mmap_assert_locked(mm);
 
        do {
                /* If range is no longer valid force retry. */
index d9b2e0e..78c84be 100644 (file)
@@ -1746,7 +1746,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
 
        /*
         * We don't have to worry about the ordering of src and dst
-        * ptlocks because exclusive mmap_sem prevents deadlock.
+        * ptlocks because exclusive mmap_lock prevents deadlock.
         */
        old_ptl = __pmd_trans_huge_lock(old_pmd, vma);
        if (old_ptl) {
@@ -1833,9 +1833,9 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
                goto unlock;
 
        /*
-        * In case prot_numa, we are under down_read(mmap_sem). It's critical
+        * In case prot_numa, we are under mmap_read_lock(mm). It's critical
         * to not clear pmd intermittently to avoid race with MADV_DONTNEED
-        * which is also under down_read(mmap_sem):
+        * which is also under mmap_read_lock(mm):
         *
         *      CPU0:                           CPU1:
         *                              change_huge_pmd(prot_numa=1)
@@ -2618,7 +2618,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list)
 
        if (PageAnon(head)) {
                /*
-                * The caller does not necessarily hold an mmap_sem that would
+                * The caller does not necessarily hold an mmap_lock that would
                 * prevent the anon_vma disappearing so we first we take a
                 * reference to it and then lock the anon_vma for write. This
                 * is similar to page_lock_anon_vma_read except the write lock
index dcb34d7..57ece74 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/cma.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/tlb.h>
 
 #include <linux/io.h>
@@ -4696,7 +4695,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
                                                (const void __user *) src_addr,
                                                pages_per_huge_page(h), false);
 
-               /* fallback to copy_from_user outside mmap_sem */
+               /* fallback to copy_from_user outside mmap_lock */
                if (unlikely(ret)) {
                        ret = -ENOENT;
                        *pagep = page;
index 1960330..3a613c8 100644 (file)
@@ -6,10 +6,10 @@
 #include <linux/list.h>
 #include <linux/cpumask.h>
 #include <linux/mman.h>
+#include <linux/pgtable.h>
 
 #include <linux/atomic.h>
 #include <linux/user_namespace.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
 
 #ifndef INIT_MM_CONTEXT
@@ -31,7 +31,7 @@ struct mm_struct init_mm = {
        .pgd            = swapper_pg_dir,
        .mm_users       = ATOMIC_INIT(2),
        .mm_count       = ATOMIC_INIT(1),
-       .mmap_sem       = __RWSEM_INITIALIZER(init_mm.mmap_sem),
+       MMAP_LOCK_INITIALIZER(init_mm)
        .page_table_lock =  __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
        .arg_lock       =  __SPIN_LOCK_UNLOCKED(init_mm.arg_lock),
        .mmlist         = LIST_HEAD_INIT(init_mm.mmlist),
index 791e4b5..9886db2 100644 (file)
@@ -344,7 +344,7 @@ static inline void munlock_vma_pages_all(struct vm_area_struct *vma)
 }
 
 /*
- * must be called with vma's mmap_sem held for read or write, and page locked.
+ * must be called with vma's mmap_lock held for read or write, and page locked.
  */
 extern void mlock_vma_page(struct page *page);
 extern unsigned int munlock_vma_page(struct page *page);
@@ -413,13 +413,13 @@ static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
 
        /*
         * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or
-        * anything, so we only pin the file and drop the mmap_sem if only
+        * anything, so we only pin the file and drop the mmap_lock if only
         * FAULT_FLAG_ALLOW_RETRY is set, while this is the first attempt.
         */
        if (fault_flag_allow_retry_first(flags) &&
            !(flags & FAULT_FLAG_RETRY_NOWAIT)) {
                fpin = get_file(vmf->vma->vm_file);
-               up_read(&vmf->vma->vm_mm->mmap_sem);
+               mmap_read_unlock(vmf->vma->vm_mm);
        }
        return fpin;
 }
index 3f03248..b043c40 100644 (file)
@@ -534,10 +534,10 @@ void __khugepaged_exit(struct mm_struct *mm)
                 * under mmap sem read mode). Stop here (after we
                 * return all pagetables will be destroyed) until
                 * khugepaged has finished working on the pagetables
-                * under the mmap_sem.
+                * under the mmap_lock.
                 */
-               down_write(&mm->mmap_sem);
-               up_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
+               mmap_write_unlock(mm);
        }
 }
 
@@ -933,8 +933,8 @@ khugepaged_alloc_page(struct page **hpage, gfp_t gfp, int node)
 #endif
 
 /*
- * If mmap_sem temporarily dropped, revalidate vma
- * before taking mmap_sem.
+ * If mmap_lock temporarily dropped, revalidate vma
+ * before taking mmap_lock.
  * Return 0 if succeeds, otherwise return none-zero
  * value (scan code).
  */
@@ -966,7 +966,7 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address,
  * Only done if khugepaged_scan_pmd believes it is worthwhile.
  *
  * Called and returns without pte mapped or spinlocks held,
- * but with mmap_sem held to protect against vma changes.
+ * but with mmap_lock held to protect against vma changes.
  */
 
 static bool __collapse_huge_page_swapin(struct mm_struct *mm,
@@ -993,9 +993,9 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
                swapped_in++;
                ret = do_swap_page(&vmf);
 
-               /* do_swap_page returns VM_FAULT_RETRY with released mmap_sem */
+               /* do_swap_page returns VM_FAULT_RETRY with released mmap_lock */
                if (ret & VM_FAULT_RETRY) {
-                       down_read(&mm->mmap_sem);
+                       mmap_read_lock(mm);
                        if (hugepage_vma_revalidate(mm, address, &vmf.vma)) {
                                /* vma is no longer available, don't continue to swapin */
                                trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0);
@@ -1047,12 +1047,12 @@ static void collapse_huge_page(struct mm_struct *mm,
        gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE;
 
        /*
-        * Before allocating the hugepage, release the mmap_sem read lock.
+        * Before allocating the hugepage, release the mmap_lock read lock.
         * The allocation can take potentially a long time if it involves
-        * sync compaction, and we do not need to hold the mmap_sem during
+        * sync compaction, and we do not need to hold the mmap_lock during
         * that. We will recheck the vma after taking it again in write mode.
         */
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        new_page = khugepaged_alloc_page(hpage, gfp, node);
        if (!new_page) {
                result = SCAN_ALLOC_HUGE_PAGE_FAIL;
@@ -1065,38 +1065,38 @@ static void collapse_huge_page(struct mm_struct *mm,
        }
        count_memcg_page_event(new_page, THP_COLLAPSE_ALLOC);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        result = hugepage_vma_revalidate(mm, address, &vma);
        if (result) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                goto out_nolock;
        }
 
        pmd = mm_find_pmd(mm, address);
        if (!pmd) {
                result = SCAN_PMD_NULL;
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                goto out_nolock;
        }
 
        /*
-        * __collapse_huge_page_swapin always returns with mmap_sem locked.
-        * If it fails, we release mmap_sem and jump out_nolock.
+        * __collapse_huge_page_swapin always returns with mmap_lock locked.
+        * If it fails, we release mmap_lock and jump out_nolock.
         * Continuing to collapse causes inconsistency.
         */
        if (unmapped && !__collapse_huge_page_swapin(mm, vma, address,
                                                     pmd, referenced)) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                goto out_nolock;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        /*
         * Prevent all access to pagetables with the exception of
         * gup_fast later handled by the ptep_clear_flush and the VM
         * handled by the anon_vma lock + PG_lock.
         */
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        result = SCAN_ANY_PROCESS;
        if (!mmget_still_valid(mm))
                goto out;
@@ -1184,7 +1184,7 @@ static void collapse_huge_page(struct mm_struct *mm,
        khugepaged_pages_collapsed++;
        result = SCAN_SUCCEED;
 out_up_write:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 out_nolock:
        if (!IS_ERR_OR_NULL(*hpage))
                mem_cgroup_uncharge(*hpage);
@@ -1345,7 +1345,7 @@ out_unmap:
        pte_unmap_unlock(pte, ptl);
        if (ret) {
                node = khugepaged_find_target_node();
-               /* collapse_huge_page will return with the mmap_sem released */
+               /* collapse_huge_page will return with the mmap_lock released */
                collapse_huge_page(mm, address, hpage, node,
                                referenced, unmapped);
        }
@@ -1517,7 +1517,7 @@ static int khugepaged_collapse_pte_mapped_thps(struct mm_slot *mm_slot)
        if (likely(mm_slot->nr_pte_mapped_thp == 0))
                return 0;
 
-       if (!down_write_trylock(&mm->mmap_sem))
+       if (!mmap_write_trylock(mm))
                return -EBUSY;
 
        if (unlikely(khugepaged_test_exit(mm)))
@@ -1528,7 +1528,7 @@ static int khugepaged_collapse_pte_mapped_thps(struct mm_slot *mm_slot)
 
 out:
        mm_slot->nr_pte_mapped_thp = 0;
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return 0;
 }
 
@@ -1543,11 +1543,11 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
                /*
                 * Check vma->anon_vma to exclude MAP_PRIVATE mappings that
                 * got written to. These VMAs are likely not worth investing
-                * down_write(mmap_sem) as PMD-mapping is likely to be split
+                * mmap_write_lock(mm) as PMD-mapping is likely to be split
                 * later.
                 *
                 * Not that vma->anon_vma check is racy: it can be set up after
-                * the check but before we took mmap_sem by the fault path.
+                * the check but before we took mmap_lock by the fault path.
                 * But page lock would prevent establishing any new ptes of the
                 * page, so we are safe.
                 *
@@ -1567,18 +1567,18 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
                if (!pmd)
                        continue;
                /*
-                * We need exclusive mmap_sem to retract page table.
+                * We need exclusive mmap_lock to retract page table.
                 *
                 * We use trylock due to lock inversion: we need to acquire
-                * mmap_sem while holding page lock. Fault path does it in
+                * mmap_lock while holding page lock. Fault path does it in
                 * reverse order. Trylock is a way to avoid deadlock.
                 */
-               if (down_write_trylock(&vma->vm_mm->mmap_sem)) {
+               if (mmap_write_trylock(vma->vm_mm)) {
                        spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd);
                        /* assume page table is clear */
                        _pmd = pmdp_collapse_flush(vma, addr, pmd);
                        spin_unlock(ptl);
-                       up_write(&vma->vm_mm->mmap_sem);
+                       mmap_write_unlock(vma->vm_mm);
                        mm_dec_nr_ptes(vma->vm_mm);
                        pte_free(vma->vm_mm, pmd_pgtable(_pmd));
                } else {
@@ -2057,8 +2057,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
         * the next mm on the list.
         */
        vma = NULL;
-       if (unlikely(!down_read_trylock(&mm->mmap_sem)))
-               goto breakouterloop_mmap_sem;
+       if (unlikely(!mmap_read_trylock(mm)))
+               goto breakouterloop_mmap_lock;
        if (likely(!khugepaged_test_exit(mm)))
                vma = find_vma(mm, khugepaged_scan.address);
 
@@ -2102,7 +2102,7 @@ skip:
                                pgoff_t pgoff = linear_page_index(vma,
                                                khugepaged_scan.address);
 
-                               up_read(&mm->mmap_sem);
+                               mmap_read_unlock(mm);
                                ret = 1;
                                khugepaged_scan_file(mm, file, pgoff, hpage);
                                fput(file);
@@ -2115,15 +2115,15 @@ skip:
                        khugepaged_scan.address += HPAGE_PMD_SIZE;
                        progress += HPAGE_PMD_NR;
                        if (ret)
-                               /* we released mmap_sem so break loop */
-                               goto breakouterloop_mmap_sem;
+                               /* we released mmap_lock so break loop */
+                               goto breakouterloop_mmap_lock;
                        if (progress >= pages)
                                goto breakouterloop;
                }
        }
 breakouterloop:
-       up_read(&mm->mmap_sem); /* exit_mmap will destroy ptes after this */
-breakouterloop_mmap_sem:
+       mmap_read_unlock(mm); /* exit_mmap will destroy ptes after this */
+breakouterloop_mmap_lock:
 
        spin_lock(&khugepaged_mm_lock);
        VM_BUG_ON(khugepaged_scan.mm_slot != mm_slot);
index 18c5d00..4102034 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -442,7 +442,7 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm,
 /*
  * ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's
  * page tables after it has passed through ksm_exit() - which, if necessary,
- * takes mmap_sem briefly to serialize against them.  ksm_exit() does not set
+ * takes mmap_lock briefly to serialize against them.  ksm_exit() does not set
  * a special flag: they can just back out as soon as mm_users goes to zero.
  * ksm_test_exit() is used throughout to make this test for exit: in some
  * places for correctness, in some places just to avoid unnecessary work.
@@ -542,11 +542,11 @@ static void break_cow(struct rmap_item *rmap_item)
         */
        put_anon_vma(rmap_item->anon_vma);
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_mergeable_vma(mm, addr);
        if (vma)
                break_ksm(vma, addr);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 }
 
 static struct page *get_mergeable_page(struct rmap_item *rmap_item)
@@ -556,7 +556,7 @@ static struct page *get_mergeable_page(struct rmap_item *rmap_item)
        struct vm_area_struct *vma;
        struct page *page;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_mergeable_vma(mm, addr);
        if (!vma)
                goto out;
@@ -572,7 +572,7 @@ static struct page *get_mergeable_page(struct rmap_item *rmap_item)
 out:
                page = NULL;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return page;
 }
 
@@ -831,7 +831,7 @@ static void remove_trailing_rmap_items(struct mm_slot *mm_slot,
  * Though it's very tempting to unmerge rmap_items from stable tree rather
  * than check every pte of a given vma, the locking doesn't quite work for
  * that - an rmap_item is assigned to the stable tree after inserting ksm
- * page and upping mmap_sem.  Nor does it fit with the way we skip dup'ing
+ * page and upping mmap_lock.  Nor does it fit with the way we skip dup'ing
  * rmap_items from parent to child at fork time (so as not to waste time
  * if exit comes before the next scan reaches it).
  *
@@ -976,7 +976,7 @@ static int unmerge_and_remove_all_rmap_items(void)
        for (mm_slot = ksm_scan.mm_slot;
                        mm_slot != &ksm_mm_head; mm_slot = ksm_scan.mm_slot) {
                mm = mm_slot->mm;
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                for (vma = mm->mmap; vma; vma = vma->vm_next) {
                        if (ksm_test_exit(mm))
                                break;
@@ -989,7 +989,7 @@ static int unmerge_and_remove_all_rmap_items(void)
                }
 
                remove_trailing_rmap_items(mm_slot, &mm_slot->rmap_list);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
 
                spin_lock(&ksm_mmlist_lock);
                ksm_scan.mm_slot = list_entry(mm_slot->mm_list.next,
@@ -1012,7 +1012,7 @@ static int unmerge_and_remove_all_rmap_items(void)
        return 0;
 
 error:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        spin_lock(&ksm_mmlist_lock);
        ksm_scan.mm_slot = &ksm_mm_head;
        spin_unlock(&ksm_mmlist_lock);
@@ -1280,7 +1280,7 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
        struct vm_area_struct *vma;
        int err = -EFAULT;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_mergeable_vma(mm, rmap_item->address);
        if (!vma)
                goto out;
@@ -1292,11 +1292,11 @@ static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
        /* Unstable nid is in union with stable anon_vma: remove first */
        remove_rmap_item_from_tree(rmap_item);
 
-       /* Must get reference to anon_vma while still holding mmap_sem */
+       /* Must get reference to anon_vma while still holding mmap_lock */
        rmap_item->anon_vma = vma->anon_vma;
        get_anon_vma(vma->anon_vma);
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return err;
 }
 
@@ -2110,7 +2110,7 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
        if (ksm_use_zero_pages && (checksum == zero_checksum)) {
                struct vm_area_struct *vma;
 
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = find_mergeable_vma(mm, rmap_item->address);
                if (vma) {
                        err = try_to_merge_one_page(vma, page,
@@ -2122,7 +2122,7 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
                         */
                        err = 0;
                }
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                /*
                 * In case of failure, the page was not really empty, so we
                 * need to continue. Otherwise we're done.
@@ -2285,7 +2285,7 @@ next_mm:
        }
 
        mm = slot->mm;
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        if (ksm_test_exit(mm))
                vma = NULL;
        else
@@ -2319,7 +2319,7 @@ next_mm:
                                        ksm_scan.address += PAGE_SIZE;
                                } else
                                        put_page(*page);
-                               up_read(&mm->mmap_sem);
+                               mmap_read_unlock(mm);
                                return rmap_item;
                        }
                        put_page(*page);
@@ -2343,13 +2343,13 @@ next_mm:
                                                struct mm_slot, mm_list);
        if (ksm_scan.address == 0) {
                /*
-                * We've completed a full scan of all vmas, holding mmap_sem
+                * We've completed a full scan of all vmas, holding mmap_lock
                 * throughout, and found no VM_MERGEABLE: so do the same as
                 * __ksm_exit does to remove this mm from all our lists now.
                 * This applies either when cleaning up after __ksm_exit
                 * (but beware: we can reach here even before __ksm_exit),
                 * or when all VM_MERGEABLE areas have been unmapped (and
-                * mmap_sem then protects against race with MADV_MERGEABLE).
+                * mmap_lock then protects against race with MADV_MERGEABLE).
                 */
                hash_del(&slot->link);
                list_del(&slot->mm_list);
@@ -2357,12 +2357,12 @@ next_mm:
 
                free_mm_slot(slot);
                clear_bit(MMF_VM_MERGEABLE, &mm->flags);
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                mmdrop(mm);
        } else {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                /*
-                * up_read(&mm->mmap_sem) first because after
+                * mmap_read_unlock(mm) first because after
                 * spin_unlock(&ksm_mmlist_lock) run, the "mm" may
                 * already have been freed under us by __ksm_exit()
                 * because the "mm_slot" is still hashed and
@@ -2536,7 +2536,7 @@ void __ksm_exit(struct mm_struct *mm)
         * This process is exiting: if it's straightforward (as is the
         * case when ksmd was never running), free mm_slot immediately.
         * But if it's at the cursor or has rmap_items linked to it, use
-        * mmap_sem to synchronize with any break_cows before pagetables
+        * mmap_lock to synchronize with any break_cows before pagetables
         * are freed, and leave the mm_slot on the list for ksmd to free.
         * Beware: ksm may already have noticed it exiting and freed the slot.
         */
@@ -2560,8 +2560,8 @@ void __ksm_exit(struct mm_struct *mm)
                clear_bit(MMF_VM_MERGEABLE, &mm->flags);
                mmdrop(mm);
        } else if (mm_slot) {
-               down_write(&mm->mmap_sem);
-               up_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
+               mmap_write_unlock(mm);
        }
 }
 
index 3ca8d97..88845ed 100644 (file)
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Access kernel memory without faulting.
+ * Access kernel or user memory without faulting.
  */
 #include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/uaccess.h>
 
-static __always_inline long
-probe_read_common(void *dst, const void __user *src, size_t size)
+bool __weak probe_kernel_read_allowed(const void *unsafe_src, size_t size)
 {
-       long ret;
+       return true;
+}
+
+#ifdef HAVE_GET_KERNEL_NOFAULT
+
+#define probe_kernel_read_loop(dst, src, len, type, err_label)         \
+       while (len >= sizeof(type)) {                                   \
+               __get_kernel_nofault(dst, src, type, err_label);                \
+               dst += sizeof(type);                                    \
+               src += sizeof(type);                                    \
+               len -= sizeof(type);                                    \
+       }
+
+long probe_kernel_read(void *dst, const void *src, size_t size)
+{
+       if (!probe_kernel_read_allowed(src, size))
+               return -ERANGE;
 
        pagefault_disable();
-       ret = __copy_from_user_inatomic(dst, src, size);
+       probe_kernel_read_loop(dst, src, size, u64, Efault);
+       probe_kernel_read_loop(dst, src, size, u32, Efault);
+       probe_kernel_read_loop(dst, src, size, u16, Efault);
+       probe_kernel_read_loop(dst, src, size, u8, Efault);
        pagefault_enable();
+       return 0;
+Efault:
+       pagefault_enable();
+       return -EFAULT;
+}
+EXPORT_SYMBOL_GPL(probe_kernel_read);
+
+#define probe_kernel_write_loop(dst, src, len, type, err_label)                \
+       while (len >= sizeof(type)) {                                   \
+               __put_kernel_nofault(dst, src, type, err_label);                \
+               dst += sizeof(type);                                    \
+               src += sizeof(type);                                    \
+               len -= sizeof(type);                                    \
+       }
 
-       return ret ? -EFAULT : 0;
+long probe_kernel_write(void *dst, const void *src, size_t size)
+{
+       pagefault_disable();
+       probe_kernel_write_loop(dst, src, size, u64, Efault);
+       probe_kernel_write_loop(dst, src, size, u32, Efault);
+       probe_kernel_write_loop(dst, src, size, u16, Efault);
+       probe_kernel_write_loop(dst, src, size, u8, Efault);
+       pagefault_enable();
+       return 0;
+Efault:
+       pagefault_enable();
+       return -EFAULT;
 }
 
-static __always_inline long
-probe_write_common(void __user *dst, const void *src, size_t size)
+long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
 {
-       long ret;
+       const void *src = unsafe_addr;
+
+       if (unlikely(count <= 0))
+               return 0;
+       if (!probe_kernel_read_allowed(unsafe_addr, count))
+               return -ERANGE;
 
        pagefault_disable();
-       ret = __copy_to_user_inatomic(dst, src, size);
+       do {
+               __get_kernel_nofault(dst, src, u8, Efault);
+               dst++;
+               src++;
+       } while (dst[-1] && src - unsafe_addr < count);
        pagefault_enable();
 
-       return ret ? -EFAULT : 0;
+       dst[-1] = '\0';
+       return src - unsafe_addr;
+Efault:
+       pagefault_enable();
+       dst[-1] = '\0';
+       return -EFAULT;
 }
-
+#else /* HAVE_GET_KERNEL_NOFAULT */
 /**
- * probe_kernel_read(): safely attempt to read from a kernel-space location
+ * probe_kernel_read(): safely attempt to read from kernel-space
  * @dst: pointer to the buffer that shall take the data
  * @src: address to read from
  * @size: size of the data chunk
  *
- * Safely read from address @src to the buffer at @dst.  If a kernel fault
- * happens, handle that and return -EFAULT.
+ * Safely read from kernel address @src to the buffer at @dst.  If a kernel
+ * fault happens, handle that and return -EFAULT.  If @src is not a valid kernel
+ * address, return -ERANGE.
  *
  * We ensure that the copy_from_user is executed in atomic context so that
- * do_page_fault() doesn't attempt to take mmap_sem.  This makes
+ * do_page_fault() doesn't attempt to take mmap_lock.  This makes
  * probe_kernel_read() suitable for use within regions where the caller
- * already holds mmap_sem, or other locks which nest inside mmap_sem.
- *
- * probe_kernel_read_strict() is the same as probe_kernel_read() except for
- * the case where architectures have non-overlapping user and kernel address
- * ranges: probe_kernel_read_strict() will additionally return -EFAULT for
- * probing memory on a user address range where probe_user_read() is supposed
- * to be used instead.
+ * already holds mmap_lock, or other locks which nest inside mmap_lock.
  */
-
-long __weak probe_kernel_read(void *dst, const void *src, size_t size)
-    __attribute__((alias("__probe_kernel_read")));
-
-long __weak probe_kernel_read_strict(void *dst, const void *src, size_t size)
-    __attribute__((alias("__probe_kernel_read")));
-
-long __probe_kernel_read(void *dst, const void *src, size_t size)
+long probe_kernel_read(void *dst, const void *src, size_t size)
 {
        long ret;
        mm_segment_t old_fs = get_fs();
 
+       if (!probe_kernel_read_allowed(src, size))
+               return -ERANGE;
+
        set_fs(KERNEL_DS);
-       ret = probe_read_common(dst, (__force const void __user *)src, size);
+       pagefault_disable();
+       ret = __copy_from_user_inatomic(dst, (__force const void __user *)src,
+                       size);
+       pagefault_enable();
        set_fs(old_fs);
 
-       return ret;
+       if (ret)
+               return -EFAULT;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(probe_kernel_read);
 
 /**
- * probe_user_read(): safely attempt to read from a user-space location
- * @dst: pointer to the buffer that shall take the data
- * @src: address to read from. This must be a user address.
- * @size: size of the data chunk
- *
- * Safely read from user address @src to the buffer at @dst. If a kernel fault
- * happens, handle that and return -EFAULT.
- */
-
-long __weak probe_user_read(void *dst, const void __user *src, size_t size)
-    __attribute__((alias("__probe_user_read")));
-
-long __probe_user_read(void *dst, const void __user *src, size_t size)
-{
-       long ret = -EFAULT;
-       mm_segment_t old_fs = get_fs();
-
-       set_fs(USER_DS);
-       if (access_ok(src, size))
-               ret = probe_read_common(dst, src, size);
-       set_fs(old_fs);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(probe_user_read);
-
-/**
  * probe_kernel_write(): safely attempt to write to a location
  * @dst: address to write to
  * @src: pointer to the data that shall be written
@@ -106,52 +131,25 @@ EXPORT_SYMBOL_GPL(probe_user_read);
  * Safely write to address @dst from the buffer at @src.  If a kernel fault
  * happens, handle that and return -EFAULT.
  */
-
-long __weak probe_kernel_write(void *dst, const void *src, size_t size)
-    __attribute__((alias("__probe_kernel_write")));
-
-long __probe_kernel_write(void *dst, const void *src, size_t size)
+long probe_kernel_write(void *dst, const void *src, size_t size)
 {
        long ret;
        mm_segment_t old_fs = get_fs();
 
        set_fs(KERNEL_DS);
-       ret = probe_write_common((__force void __user *)dst, src, size);
-       set_fs(old_fs);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(probe_kernel_write);
-
-/**
- * probe_user_write(): safely attempt to write to a user-space location
- * @dst: address to write to
- * @src: pointer to the data that shall be written
- * @size: size of the data chunk
- *
- * Safely write to address @dst from the buffer at @src.  If a kernel fault
- * happens, handle that and return -EFAULT.
- */
-
-long __weak probe_user_write(void __user *dst, const void *src, size_t size)
-    __attribute__((alias("__probe_user_write")));
-
-long __probe_user_write(void __user *dst, const void *src, size_t size)
-{
-       long ret = -EFAULT;
-       mm_segment_t old_fs = get_fs();
-
-       set_fs(USER_DS);
-       if (access_ok(dst, size))
-               ret = probe_write_common(dst, src, size);
+       pagefault_disable();
+       ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
+       pagefault_enable();
        set_fs(old_fs);
 
-       return ret;
+       if (ret)
+               return -EFAULT;
+       return 0;
 }
-EXPORT_SYMBOL_GPL(probe_user_write);
 
 /**
- * strncpy_from_unsafe: - Copy a NUL terminated string from unsafe address.
+ * strncpy_from_kernel_nofault: - Copy a NUL terminated string from unsafe
+ *                              address.
  * @dst:   Destination address, in kernel space.  This buffer must be at
  *         least @count bytes long.
  * @unsafe_addr: Unsafe address.
@@ -161,27 +159,14 @@ EXPORT_SYMBOL_GPL(probe_user_write);
  *
  * On success, returns the length of the string INCLUDING the trailing NUL.
  *
- * If access fails, returns -EFAULT (some data may have been copied
- * and the trailing NUL added).
+ * If access fails, returns -EFAULT (some data may have been copied and the
+ * trailing NUL added).  If @unsafe_addr is not a valid kernel address, return
+ * -ERANGE.
  *
  * If @count is smaller than the length of the string, copies @count-1 bytes,
  * sets the last byte of @dst buffer to NUL and returns @count.
- *
- * strncpy_from_unsafe_strict() is the same as strncpy_from_unsafe() except
- * for the case where architectures have non-overlapping user and kernel address
- * ranges: strncpy_from_unsafe_strict() will additionally return -EFAULT for
- * probing memory on a user address range where strncpy_from_unsafe_user() is
- * supposed to be used instead.
  */
-
-long __weak strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
-    __attribute__((alias("__strncpy_from_unsafe")));
-
-long __weak strncpy_from_unsafe_strict(char *dst, const void *unsafe_addr,
-                                      long count)
-    __attribute__((alias("__strncpy_from_unsafe")));
-
-long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
+long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
 {
        mm_segment_t old_fs = get_fs();
        const void *src = unsafe_addr;
@@ -189,6 +174,8 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
 
        if (unlikely(count <= 0))
                return 0;
+       if (!probe_kernel_read_allowed(unsafe_addr, count))
+               return -ERANGE;
 
        set_fs(KERNEL_DS);
        pagefault_disable();
@@ -203,9 +190,66 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
 
        return ret ? -EFAULT : src - unsafe_addr;
 }
+#endif /* HAVE_GET_KERNEL_NOFAULT */
+
+/**
+ * probe_user_read(): safely attempt to read from a user-space location
+ * @dst: pointer to the buffer that shall take the data
+ * @src: address to read from. This must be a user address.
+ * @size: size of the data chunk
+ *
+ * Safely read from user address @src to the buffer at @dst. If a kernel fault
+ * happens, handle that and return -EFAULT.
+ */
+long probe_user_read(void *dst, const void __user *src, size_t size)
+{
+       long ret = -EFAULT;
+       mm_segment_t old_fs = get_fs();
+
+       set_fs(USER_DS);
+       if (access_ok(src, size)) {
+               pagefault_disable();
+               ret = __copy_from_user_inatomic(dst, src, size);
+               pagefault_enable();
+       }
+       set_fs(old_fs);
+
+       if (ret)
+               return -EFAULT;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(probe_user_read);
+
+/**
+ * probe_user_write(): safely attempt to write to a user-space location
+ * @dst: address to write to
+ * @src: pointer to the data that shall be written
+ * @size: size of the data chunk
+ *
+ * Safely write to address @dst from the buffer at @src.  If a kernel fault
+ * happens, handle that and return -EFAULT.
+ */
+long probe_user_write(void __user *dst, const void *src, size_t size)
+{
+       long ret = -EFAULT;
+       mm_segment_t old_fs = get_fs();
+
+       set_fs(USER_DS);
+       if (access_ok(dst, size)) {
+               pagefault_disable();
+               ret = __copy_to_user_inatomic(dst, src, size);
+               pagefault_enable();
+       }
+       set_fs(old_fs);
+
+       if (ret)
+               return -EFAULT;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(probe_user_write);
 
 /**
- * strncpy_from_unsafe_user: - Copy a NUL terminated string from unsafe user
+ * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
  *                             address.
  * @dst:   Destination address, in kernel space.  This buffer must be at
  *         least @count bytes long.
@@ -222,7 +266,7 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
  * If @count is smaller than the length of the string, copies @count-1 bytes,
  * sets the last byte of @dst buffer to NUL and returns @count.
  */
-long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr,
+long strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr,
                              long count)
 {
        mm_segment_t old_fs = get_fs();
@@ -248,7 +292,7 @@ long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr,
 }
 
 /**
- * strnlen_unsafe_user: - Get the size of a user string INCLUDING final NUL.
+ * strnlen_user_nofault: - Get the size of a user string INCLUDING final NUL.
  * @unsafe_addr: The string to measure.
  * @count: Maximum count (including NUL)
  *
@@ -263,7 +307,7 @@ long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr,
  * Unlike strnlen_user, this can be used from IRQ handler etc. because
  * it disables pagefaults.
  */
-long strnlen_unsafe_user(const void __user *unsafe_addr, long count)
+long strnlen_user_nofault(const void __user *unsafe_addr, long count)
 {
        mm_segment_t old_fs = get_fs();
        int ret;
index 8cbd8c1..dd1d43c 100644 (file)
@@ -40,7 +40,7 @@ struct madvise_walk_private {
 
 /*
  * Any behaviour which results in changes to the vma->vm_flags needs to
- * take mmap_sem for writing. Others, which simply traverse vmas, need
+ * take mmap_lock for writing. Others, which simply traverse vmas, need
  * to only take it for reading.
  */
 static int madvise_need_mmap_write(int behavior)
@@ -165,7 +165,7 @@ static long madvise_behavior(struct vm_area_struct *vma,
 
 success:
        /*
-        * vm_flags is protected by the mmap_sem held in write mode.
+        * vm_flags is protected by the mmap_lock held in write mode.
         */
        vma->vm_flags = new_flags;
 
@@ -285,16 +285,16 @@ static long madvise_willneed(struct vm_area_struct *vma,
         * Filesystem's fadvise may need to take various locks.  We need to
         * explicitly grab a reference because the vma (and hence the
         * vma's reference to the file) can go away as soon as we drop
-        * mmap_sem.
+        * mmap_lock.
         */
-       *prev = NULL;   /* tell sys_madvise we drop mmap_sem */
+       *prev = NULL;   /* tell sys_madvise we drop mmap_lock */
        get_file(file);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        offset = (loff_t)(start - vma->vm_start)
                        + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
        vfs_fadvise(file, offset, end - start, POSIX_FADV_WILLNEED);
        fput(file);
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        return 0;
 }
 
@@ -768,9 +768,9 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
                return -EINVAL;
 
        if (!userfaultfd_remove(vma, start, end)) {
-               *prev = NULL; /* mmap_sem has been dropped, prev is stale */
+               *prev = NULL; /* mmap_lock has been dropped, prev is stale */
 
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                vma = find_vma(current->mm, start);
                if (!vma)
                        return -ENOMEM;
@@ -791,7 +791,7 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
                if (end > vma->vm_end) {
                        /*
                         * Don't fail if end > vma->vm_end. If the old
-                        * vma was splitted while the mmap_sem was
+                        * vma was splitted while the mmap_lock was
                         * released the effect of the concurrent
                         * operation may not cause madvise() to
                         * have an undefined result. There may be an
@@ -826,7 +826,7 @@ static long madvise_remove(struct vm_area_struct *vma,
        int error;
        struct file *f;
 
-       *prev = NULL;   /* tell sys_madvise we drop mmap_sem */
+       *prev = NULL;   /* tell sys_madvise we drop mmap_lock */
 
        if (vma->vm_flags & VM_LOCKED)
                return -EINVAL;
@@ -847,18 +847,18 @@ static long madvise_remove(struct vm_area_struct *vma,
         * Filesystem's fallocate may need to take i_mutex.  We need to
         * explicitly grab a reference because the vma (and hence the
         * vma's reference to the file) can go away as soon as we drop
-        * mmap_sem.
+        * mmap_lock.
         */
        get_file(f);
        if (userfaultfd_remove(vma, start, end)) {
-               /* mmap_sem was not released by userfaultfd_remove() */
-               up_read(&current->mm->mmap_sem);
+               /* mmap_lock was not released by userfaultfd_remove() */
+               mmap_read_unlock(current->mm);
        }
        error = vfs_fallocate(f,
                                FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                offset, end - start);
        fput(f);
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        return error;
 }
 
@@ -1089,7 +1089,7 @@ int do_madvise(unsigned long start, size_t len_in, int behavior)
 
        write = madvise_need_mmap_write(behavior);
        if (write) {
-               if (down_write_killable(&current->mm->mmap_sem))
+               if (mmap_write_lock_killable(current->mm))
                        return -EINTR;
 
                /*
@@ -1105,11 +1105,11 @@ int do_madvise(unsigned long start, size_t len_in, int behavior)
                 * model.
                 */
                if (!mmget_still_valid(current->mm)) {
-                       up_write(&current->mm->mmap_sem);
+                       mmap_write_unlock(current->mm);
                        return -EINTR;
                }
        } else {
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
        }
 
        /*
@@ -1153,15 +1153,15 @@ int do_madvise(unsigned long start, size_t len_in, int behavior)
                        goto out;
                if (prev)
                        vma = prev->vm_next;
-               else    /* madvise_remove dropped mmap_sem */
+               else    /* madvise_remove dropped mmap_lock */
                        vma = find_vma(current->mm, start);
        }
 out:
        blk_finish_plug(&plug);
        if (write)
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
        else
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
        return error;
 }
index 3dde78f..0b38b6a 100644 (file)
@@ -5614,9 +5614,9 @@ static unsigned long mem_cgroup_count_precharge(struct mm_struct *mm)
 {
        unsigned long precharge;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        walk_page_range(mm, 0, mm->highest_vm_end, &precharge_walk_ops, NULL);
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        precharge = mc.precharge;
        mc.precharge = 0;
@@ -5899,9 +5899,9 @@ static void mem_cgroup_move_charge(void)
        atomic_inc(&mc.from->moving_account);
        synchronize_rcu();
 retry:
-       if (unlikely(!down_read_trylock(&mc.mm->mmap_sem))) {
+       if (unlikely(!mmap_read_trylock(mc.mm))) {
                /*
-                * Someone who are holding the mmap_sem might be waiting in
+                * Someone who are holding the mmap_lock might be waiting in
                 * waitq. So we cancel all extra charges, wake up all waiters,
                 * and retry. Because we cancel precharges, we might not be able
                 * to move enough charges, but moving charge is a best-effort
@@ -5918,7 +5918,7 @@ retry:
        walk_page_range(mc.mm, 0, mc.mm->highest_vm_end, &charge_walk_ops,
                        NULL);
 
-       up_read(&mc.mm->mmap_sem);
+       mmap_read_unlock(mc.mm);
        atomic_dec(&mc.from->moving_account);
 }
 
index d97e884..dc7f354 100644 (file)
@@ -80,7 +80,6 @@
 #include <linux/uaccess.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
-#include <asm/pgtable.h>
 
 #include "internal.h"
 
@@ -1186,7 +1185,7 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
                 * Here there can be other concurrent MADV_DONTNEED or
                 * trans huge page faults running, and if the pmd is
                 * none or trans huge it can change under us. This is
-                * because MADV_DONTNEED holds the mmap_sem in read
+                * because MADV_DONTNEED holds the mmap_lock in read
                 * mode.
                 */
                if (pmd_none_or_trans_huge_or_clear_bad(pmd))
@@ -1212,7 +1211,7 @@ static inline unsigned long zap_pud_range(struct mmu_gather *tlb,
                next = pud_addr_end(addr, end);
                if (pud_trans_huge(*pud) || pud_devmap(*pud)) {
                        if (next - addr != HPAGE_PUD_SIZE) {
-                               VM_BUG_ON_VMA(!rwsem_is_locked(&tlb->mm->mmap_sem), vma);
+                               mmap_assert_locked(tlb->mm);
                                split_huge_pud(vma, pud, addr);
                        } else if (zap_huge_pud(tlb, vma, pud, addr))
                                goto next;
@@ -1593,7 +1592,7 @@ int vm_insert_pages(struct vm_area_struct *vma, unsigned long addr,
        if (addr < vma->vm_start || end_addr >= vma->vm_end)
                return -EFAULT;
        if (!(vma->vm_flags & VM_MIXEDMAP)) {
-               BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
+               BUG_ON(mmap_read_trylock(vma->vm_mm));
                BUG_ON(vma->vm_flags & VM_PFNMAP);
                vma->vm_flags |= VM_MIXEDMAP;
        }
@@ -1637,7 +1636,7 @@ EXPORT_SYMBOL(vm_insert_pages);
  * The page does not need to be reserved.
  *
  * Usually this function is called from f_op->mmap() handler
- * under mm->mmap_sem write-lock, so it can change vma->vm_flags.
+ * under mm->mmap_lock write-lock, so it can change vma->vm_flags.
  * Caller must set VM_MIXEDMAP on vma if it wants to call this
  * function from other places, for example from page-fault handler.
  *
@@ -1651,7 +1650,7 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
        if (!page_count(page))
                return -EINVAL;
        if (!(vma->vm_flags & VM_MIXEDMAP)) {
-               BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
+               BUG_ON(mmap_read_trylock(vma->vm_mm));
                BUG_ON(vma->vm_flags & VM_PFNMAP);
                vma->vm_flags |= VM_MIXEDMAP;
        }
@@ -2574,7 +2573,7 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf)
         * mapping may be NULL here because some device drivers do not
         * set page.mapping but still dirty their pages
         *
-        * Drop the mmap_sem before waiting on IO, if we can. The file
+        * Drop the mmap_lock before waiting on IO, if we can. The file
         * is pinning the mapping, as per above.
         */
        if ((dirtied || page_mkwrite) && mapping) {
@@ -2624,7 +2623,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf)
 /*
  * Handle the case of a page which we actually need to copy to a new page.
  *
- * Called with mmap_sem locked and the old page referenced, but
+ * Called with mmap_lock locked and the old page referenced, but
  * without the ptl held.
  *
  * High level logic flow:
@@ -2888,9 +2887,9 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf)
  * change only once the write actually happens. This avoids a few races,
  * and potentially makes it more efficient.
  *
- * We enter with non-exclusive mmap_sem (to exclude vma changes,
+ * We enter with non-exclusive mmap_lock (to exclude vma changes,
  * but allow concurrent faults), with pte both mapped and locked.
- * We return with mmap_sem still held, but pte unmapped and unlocked.
+ * We return with mmap_lock still held, but pte unmapped and unlocked.
  */
 static vm_fault_t do_wp_page(struct vm_fault *vmf)
        __releases(vmf->ptl)
@@ -3079,11 +3078,11 @@ void unmap_mapping_range(struct address_space *mapping,
 EXPORT_SYMBOL(unmap_mapping_range);
 
 /*
- * We enter with non-exclusive mmap_sem (to exclude vma changes,
+ * We enter with non-exclusive mmap_lock (to exclude vma changes,
  * but allow concurrent faults), and pte mapped but not yet locked.
  * We return with pte unmapped and unlocked.
  *
- * We return with the mmap_sem locked or unlocked in the same cases
+ * We return with the mmap_lock locked or unlocked in the same cases
  * as does filemap_fault().
  */
 vm_fault_t do_swap_page(struct vm_fault *vmf)
@@ -3304,9 +3303,9 @@ out_release:
 }
 
 /*
- * We enter with non-exclusive mmap_sem (to exclude vma changes,
+ * We enter with non-exclusive mmap_lock (to exclude vma changes,
  * but allow concurrent faults), and pte mapped but not yet locked.
- * We return with mmap_sem still held, but pte unmapped and unlocked.
+ * We return with mmap_lock still held, but pte unmapped and unlocked.
  */
 static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
 {
@@ -3324,10 +3323,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
         * pte_offset_map() on pmds where a huge pmd might be created
         * from a different thread.
         *
-        * pte_alloc_map() is safe to use under down_write(mmap_sem) or when
+        * pte_alloc_map() is safe to use under mmap_write_lock(mm) or when
         * parallel threads are excluded by other means.
         *
-        * Here we only have down_read(mmap_sem).
+        * Here we only have mmap_read_lock(mm).
         */
        if (pte_alloc(vma->vm_mm, vmf->pmd))
                return VM_FAULT_OOM;
@@ -3420,7 +3419,7 @@ oom:
 }
 
 /*
- * The mmap_sem must have been held on entry, and may have been
+ * The mmap_lock must have been held on entry, and may have been
  * released depending on flags and vma->vm_ops->fault() return value.
  * See filemap_fault() and __lock_page_retry().
  */
@@ -3929,11 +3928,11 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf)
 }
 
 /*
- * We enter with non-exclusive mmap_sem (to exclude vma changes,
+ * We enter with non-exclusive mmap_lock (to exclude vma changes,
  * but allow concurrent faults).
- * The mmap_sem may have been released depending on flags and our
+ * The mmap_lock may have been released depending on flags and our
  * return value.  See filemap_fault() and __lock_page_or_retry().
- * If mmap_sem is released, vma may become invalid (for example
+ * If mmap_lock is released, vma may become invalid (for example
  * by other thread calling munmap()).
  */
 static vm_fault_t do_fault(struct vm_fault *vmf)
@@ -4162,10 +4161,10 @@ static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud)
  * with external mmu caches can use to update those (ie the Sparc or
  * PowerPC hashed page tables that act as extended TLBs).
  *
- * We enter with non-exclusive mmap_sem (to exclude vma changes, but allow
+ * We enter with non-exclusive mmap_lock (to exclude vma changes, but allow
  * concurrent faults).
  *
- * The mmap_sem may have been released depending on flags and our return value.
+ * The mmap_lock may have been released depending on flags and our return value.
  * See filemap_fault() and __lock_page_or_retry().
  */
 static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
@@ -4187,7 +4186,7 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
                /*
                 * A regular pmd is established and it can't morph into a huge
                 * pmd from under us anymore at this point because we hold the
-                * mmap_sem read mode and khugepaged takes it in write mode.
+                * mmap_lock read mode and khugepaged takes it in write mode.
                 * So now it's safe to run pte_offset_map().
                 */
                vmf->pte = pte_offset_map(vmf->pmd, vmf->address);
@@ -4255,7 +4254,7 @@ unlock:
 /*
  * By the time we get here, we already hold the mm semaphore
  *
- * The mmap_sem may have been released depending on flags and our
+ * The mmap_lock may have been released depending on flags and our
  * return value.  See filemap_fault() and __lock_page_or_retry().
  */
 static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma,
@@ -4350,7 +4349,7 @@ retry_pud:
 /*
  * By the time we get here, we already hold the mm semaphore
  *
- * The mmap_sem may have been released depending on flags and our
+ * The mmap_lock may have been released depending on flags and our
  * return value.  See filemap_fault() and __lock_page_or_retry().
  */
 vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
@@ -4659,7 +4658,7 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
        void *old_buf = buf;
        int write = gup_flags & FOLL_WRITE;
 
-       if (down_read_killable(&mm->mmap_sem))
+       if (mmap_read_lock_killable(mm))
                return 0;
 
        /* ignore errors, just check how much was successfully transferred */
@@ -4710,7 +4709,7 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
                buf += bytes;
                addr += bytes;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return buf - old_buf;
 }
@@ -4767,7 +4766,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
        /*
         * we might be running from an atomic context so we cannot sleep
         */
-       if (!down_read_trylock(&mm->mmap_sem))
+       if (!mmap_read_trylock(mm))
                return;
 
        vma = find_vma(mm, ip);
@@ -4786,7 +4785,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
                        free_page((unsigned long)buf);
                }
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 }
 
 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)
@@ -4794,7 +4793,7 @@ void __might_fault(const char *file, int line)
 {
        /*
         * Some code (nfs/sunrpc) uses socket ops on kernel memory while
-        * holding the mmap_sem, this is safe because kernel memory doesn't
+        * holding the mmap_lock, this is safe because kernel memory doesn't
         * get paged out, therefore we'll never actually fault, and the
         * below annotations will generate false positives.
         */
@@ -4805,7 +4804,7 @@ void __might_fault(const char *file, int line)
        __might_sleep(file, line, 0);
 #if defined(CONFIG_DEBUG_ATOMIC_SLEEP)
        if (current->mm)
-               might_lock_read(&current->mm->mmap_sem);
+               might_lock_read(&current->mm->mmap_lock);
 #endif
 }
 EXPORT_SYMBOL(__might_fault);
index 1965e26..3813206 100644 (file)
@@ -224,7 +224,7 @@ static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
  * handle an empty nodemask with MPOL_PREFERRED here.
  *
  * Must be called holding task's alloc_lock to protect task's mems_allowed
- * and mempolicy.  May also be called holding the mmap_semaphore for write.
+ * and mempolicy.  May also be called holding the mmap_lock for write.
  */
 static int mpol_set_nodemask(struct mempolicy *pol,
                     const nodemask_t *nodes, struct nodemask_scratch *nsc)
@@ -368,7 +368,7 @@ static void mpol_rebind_preferred(struct mempolicy *pol,
 /*
  * mpol_rebind_policy - Migrate a policy to a different set of nodes
  *
- * Per-vma policies are protected by mmap_sem. Allocations using per-task
+ * Per-vma policies are protected by mmap_lock. Allocations using per-task
  * policies are protected by task->mems_allowed_seq to prevent a premature
  * OOM/allocation failure due to parallel nodemask modification.
  */
@@ -398,17 +398,17 @@ void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new)
 /*
  * Rebind each vma in mm to new nodemask.
  *
- * Call holding a reference to mm.  Takes mm->mmap_sem during call.
+ * Call holding a reference to mm.  Takes mm->mmap_lock during call.
  */
 
 void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
 {
        struct vm_area_struct *vma;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        for (vma = mm->mmap; vma; vma = vma->vm_next)
                mpol_rebind_policy(vma->vm_policy, new);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 }
 
 static const struct mempolicy_operations mpol_ops[MPOL_MAX] = {
@@ -764,7 +764,7 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 
 /*
  * Apply policy to a single VMA
- * This must be called with the mmap_sem held for writing.
+ * This must be called with the mmap_lock held for writing.
  */
 static int vma_replace_policy(struct vm_area_struct *vma,
                                                struct mempolicy *pol)
@@ -789,7 +789,7 @@ static int vma_replace_policy(struct vm_area_struct *vma,
        }
 
        old = vma->vm_policy;
-       vma->vm_policy = new; /* protected by mmap_sem */
+       vma->vm_policy = new; /* protected by mmap_lock */
        mpol_put(old);
 
        return 0;
@@ -932,7 +932,7 @@ static int lookup_node(struct mm_struct *mm, unsigned long addr)
                put_page(p);
        }
        if (locked)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        return err;
 }
 
@@ -965,10 +965,10 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
                 * vma/shared policy at addr is NULL.  We
                 * want to return MPOL_DEFAULT in this case.
                 */
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                vma = find_vma_intersection(mm, addr, addr+1);
                if (!vma) {
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        return -EFAULT;
                }
                if (vma->vm_ops && vma->vm_ops->get_policy)
@@ -985,7 +985,7 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
                if (flags & MPOL_F_ADDR) {
                        /*
                         * Take a refcount on the mpol, lookup_node()
-                        * wil drop the mmap_sem, so after calling
+                        * wil drop the mmap_lock, so after calling
                         * lookup_node() only "pol" remains valid, "vma"
                         * is stale.
                         */
@@ -1027,7 +1027,7 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
  out:
        mpol_cond_put(pol);
        if (vma)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        if (pol_refcount)
                mpol_put(pol_refcount);
        return err;
@@ -1136,7 +1136,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
        if (err)
                return err;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        /*
         * Find a 'source' bit set in 'tmp' whose corresponding 'dest'
@@ -1217,7 +1217,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
                if (err < 0)
                        break;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        if (err < 0)
                return err;
        return busy;
@@ -1340,12 +1340,12 @@ static long do_mbind(unsigned long start, unsigned long len,
        {
                NODEMASK_SCRATCH(scratch);
                if (scratch) {
-                       down_write(&mm->mmap_sem);
+                       mmap_write_lock(mm);
                        task_lock(current);
                        err = mpol_set_nodemask(new, nmask, scratch);
                        task_unlock(current);
                        if (err)
-                               up_write(&mm->mmap_sem);
+                               mmap_write_unlock(mm);
                } else
                        err = -ENOMEM;
                NODEMASK_SCRATCH_FREE(scratch);
@@ -1382,7 +1382,7 @@ up_out:
                        putback_movable_pages(&pagelist);
        }
 
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 mpol_out:
        mpol_put(new);
        return err;
@@ -2185,7 +2185,7 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order,
  *
  *     This function allocates a page from the kernel page pool and applies
  *     a NUMA policy associated with the VMA or the current process.
- *     When VMA is not NULL caller must hold down_read on the mmap_sem of the
+ *     When VMA is not NULL caller must read-lock the mmap_lock of the
  *     mm_struct of the VMA to prevent it from going away. Should be used for
  *     all allocations for pages that will be mapped into user space. Returns
  *     NULL when no page can be allocated.
index 7bfd096..f377296 100644 (file)
@@ -1555,7 +1555,7 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
        unsigned int follflags;
        int err;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        err = -EFAULT;
        vma = find_vma(mm, addr);
        if (!vma || addr < vma->vm_start || !vma_migratable(vma))
@@ -1608,7 +1608,7 @@ out_putpage:
         */
        put_page(page);
 out:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return err;
 }
 
@@ -1733,7 +1733,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
 {
        unsigned long i;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
 
        for (i = 0; i < nr_pages; i++) {
                unsigned long addr = (unsigned long)(*pages);
@@ -1760,7 +1760,7 @@ set_status:
                status++;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 }
 
 /*
@@ -2120,7 +2120,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
         * pmd before doing set_pmd_at(), nor to flush the TLB after
         * set_pmd_at().  Clearing the pmd here would introduce a race
         * condition against MADV_DONTNEED, because MADV_DONTNEED only holds the
-        * mmap_sem for reading.  If the pmd is set to NULL at any given time,
+        * mmap_lock for reading.  If the pmd is set to NULL at any given time,
         * MADV_DONTNEED won't wait on the pmd lock and it'll skip clearing this
         * pmd.
         */
@@ -2675,7 +2675,7 @@ restore:
  * have the MIGRATE_PFN_MIGRATE flag set for their src array entry.
  *
  * It is safe to update device page table after migrate_vma_pages() because
- * both destination and source page are still locked, and the mmap_sem is held
+ * both destination and source page are still locked, and the mmap_lock is held
  * in read mode (hence no one can unmap the range being migrated).
  *
  * Once the caller is done cleaning up things and updating its page table (if it
@@ -2772,10 +2772,10 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
         * pte_offset_map() on pmds where a huge pmd might be created
         * from a different thread.
         *
-        * pte_alloc_map() is safe to use under down_write(mmap_sem) or when
+        * pte_alloc_map() is safe to use under mmap_write_lock(mm) or when
         * parallel threads are excluded by other means.
         *
-        * Here we only have down_read(mmap_sem).
+        * Here we only have mmap_read_lock(mm).
         */
        if (pte_alloc(mm, pmdp))
                goto abort;
index 0e6dd99..453ff11 100644 (file)
@@ -17,9 +17,9 @@
 #include <linux/swapops.h>
 #include <linux/shmem_fs.h>
 #include <linux/hugetlb.h>
+#include <linux/pgtable.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 
 static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr,
                        unsigned long end, struct mm_walk *walk)
@@ -284,9 +284,9 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
                 * Do at most PAGE_SIZE entries per iteration, due to
                 * the temporary buffer size.
                 */
-               down_read(&current->mm->mmap_sem);
+               mmap_read_lock(current->mm);
                retval = do_mincore(start, min(pages, PAGE_SIZE), tmp);
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
 
                if (retval <= 0)
                        break;
index a72c1ee..f873613 100644 (file)
@@ -49,7 +49,7 @@ EXPORT_SYMBOL(can_do_mlock);
  * When lazy mlocking via vmscan, it is important to ensure that the
  * vma's VM_LOCKED status is not concurrently being modified, otherwise we
  * may have mlocked a page that is being munlocked. So lazy mlock must take
- * the mmap_sem for read, and verify that the vma really is locked
+ * the mmap_lock for read, and verify that the vma really is locked
  * (see mm/rmap.c).
  */
 
@@ -381,7 +381,7 @@ static unsigned long __munlock_pagevec_fill(struct pagevec *pvec,
        /*
         * Initialize pte walk starting at the already pinned page where we
         * are sure that there is a pte, as it was pinned under the same
-        * mmap_sem write op.
+        * mmap_lock write op.
         */
        pte = get_locked_pte(vma->vm_mm, start, &ptl);
        /* Make sure we do not cross the page table boundary */
@@ -565,7 +565,7 @@ success:
        mm->locked_vm += nr_pages;
 
        /*
-        * vm_flags is protected by the mmap_sem held in write mode.
+        * vm_flags is protected by the mmap_lock held in write mode.
         * It's okay if try_to_unmap_one unmaps a page just after we
         * set VM_LOCKED, populate_vma_page_range will bring it back.
         */
@@ -686,7 +686,7 @@ static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t fla
        lock_limit >>= PAGE_SHIFT;
        locked = len >> PAGE_SHIFT;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
 
        locked += current->mm->locked_vm;
@@ -705,7 +705,7 @@ static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t fla
        if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
                error = apply_vma_lock_flags(start, len, flags);
 
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        if (error)
                return error;
 
@@ -742,10 +742,10 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
        len = PAGE_ALIGN(len + (offset_in_page(start)));
        start &= PAGE_MASK;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
        ret = apply_vma_lock_flags(start, len, 0);
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
 
        return ret;
 }
@@ -811,14 +811,14 @@ SYSCALL_DEFINE1(mlockall, int, flags)
        lock_limit = rlimit(RLIMIT_MEMLOCK);
        lock_limit >>= PAGE_SHIFT;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
 
        ret = -ENOMEM;
        if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
            capable(CAP_IPC_LOCK))
                ret = apply_mlockall_flags(flags);
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        if (!ret && (flags & MCL_CURRENT))
                mm_populate(0, TASK_SIZE);
 
@@ -829,10 +829,10 @@ SYSCALL_DEFINE0(munlockall)
 {
        int ret;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
        ret = apply_mlockall_flags(0);
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        return ret;
 }
 
index 39bd60c..59a4682 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -132,7 +132,7 @@ void vma_set_page_prot(struct vm_area_struct *vma)
                vm_flags &= ~VM_SHARED;
                vm_page_prot = vm_pgprot_modify(vm_page_prot, vm_flags);
        }
-       /* remove_protection_ptes reads vma->vm_page_prot without mmap_sem */
+       /* remove_protection_ptes reads vma->vm_page_prot without mmap_lock */
        WRITE_ONCE(vma->vm_page_prot, vm_page_prot);
 }
 
@@ -198,7 +198,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
        bool downgraded = false;
        LIST_HEAD(uf);
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        origbrk = mm->brk;
@@ -238,14 +238,14 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
 
        /*
         * Always allow shrinking brk.
-        * __do_munmap() may downgrade mmap_sem to read.
+        * __do_munmap() may downgrade mmap_lock to read.
         */
        if (brk <= mm->brk) {
                int ret;
 
                /*
-                * mm->brk must to be protected by write mmap_sem so update it
-                * before downgrading mmap_sem. When __do_munmap() fails,
+                * mm->brk must to be protected by write mmap_lock so update it
+                * before downgrading mmap_lock. When __do_munmap() fails,
                 * mm->brk will be restored from origbrk.
                 */
                mm->brk = brk;
@@ -272,9 +272,9 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
 success:
        populate = newbrk > oldbrk && (mm->def_flags & VM_LOCKED) != 0;
        if (downgraded)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
        else
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
        userfaultfd_unmap_complete(mm, &uf);
        if (populate)
                mm_populate(oldbrk, newbrk - oldbrk);
@@ -282,7 +282,7 @@ success:
 
 out:
        retval = origbrk;
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return retval;
 }
 
@@ -505,7 +505,7 @@ static __always_inline void vma_rb_erase(struct vm_area_struct *vma,
  * After the update, the vma will be reinserted using
  * anon_vma_interval_tree_post_update_vma().
  *
- * The entire update must be protected by exclusive mmap_sem and by
+ * The entire update must be protected by exclusive mmap_lock and by
  * the root anon_vma's mutex.
  */
 static inline void
@@ -1361,7 +1361,7 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode,
 }
 
 /*
- * The caller must hold down_write(&current->mm->mmap_sem).
+ * The caller must write-lock current->mm->mmap_lock.
  */
 unsigned long do_mmap(struct file *file, unsigned long addr,
                        unsigned long len, unsigned long prot,
@@ -2371,7 +2371,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
 
        /*
         * vma->vm_start/vm_end cannot change under us because the caller
-        * is required to hold the mmap_sem in read mode.  We need the
+        * is required to hold the mmap_lock in read mode.  We need the
         * anon_vma lock to serialize against concurrent expand_stacks.
         */
        anon_vma_lock_write(vma->anon_vma);
@@ -2389,7 +2389,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
                        if (!error) {
                                /*
                                 * vma_gap_update() doesn't support concurrent
-                                * updates, but we only hold a shared mmap_sem
+                                * updates, but we only hold a shared mmap_lock
                                 * lock here, so we need to protect against
                                 * concurrent vma expansions.
                                 * anon_vma_lock_write() doesn't help here, as
@@ -2451,7 +2451,7 @@ int expand_downwards(struct vm_area_struct *vma,
 
        /*
         * vma->vm_start/vm_end cannot change under us because the caller
-        * is required to hold the mmap_sem in read mode.  We need the
+        * is required to hold the mmap_lock in read mode.  We need the
         * anon_vma lock to serialize against concurrent expand_stacks.
         */
        anon_vma_lock_write(vma->anon_vma);
@@ -2469,7 +2469,7 @@ int expand_downwards(struct vm_area_struct *vma,
                        if (!error) {
                                /*
                                 * vma_gap_update() doesn't support concurrent
-                                * updates, but we only hold a shared mmap_sem
+                                * updates, but we only hold a shared mmap_lock
                                 * lock here, so we need to protect against
                                 * concurrent vma expansions.
                                 * anon_vma_lock_write() doesn't help here, as
@@ -2828,7 +2828,7 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
        detach_vmas_to_be_unmapped(mm, vma, prev, end);
 
        if (downgrade)
-               downgrade_write(&mm->mmap_sem);
+               mmap_write_downgrade(mm);
 
        unmap_region(mm, vma, prev, start, end);
 
@@ -2850,20 +2850,20 @@ static int __vm_munmap(unsigned long start, size_t len, bool downgrade)
        struct mm_struct *mm = current->mm;
        LIST_HEAD(uf);
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        ret = __do_munmap(mm, start, len, &uf, downgrade);
        /*
-        * Returning 1 indicates mmap_sem is downgraded.
+        * Returning 1 indicates mmap_lock is downgraded.
         * But 1 is not legal return value of vm_munmap() and munmap(), reset
         * it to 0 before return.
         */
        if (ret == 1) {
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
                ret = 0;
        } else
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
 
        userfaultfd_unmap_complete(mm, &uf);
        return ret;
@@ -2911,7 +2911,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
        if (pgoff + (size >> PAGE_SHIFT) < pgoff)
                return ret;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        vma = find_vma(mm, start);
@@ -2974,7 +2974,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
                        prot, flags, pgoff, &populate, NULL);
        fput(file);
 out:
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        if (populate)
                mm_populate(ret, populate);
        if (!IS_ERR_VALUE(ret))
@@ -3074,12 +3074,12 @@ int vm_brk_flags(unsigned long addr, unsigned long request, unsigned long flags)
        if (!len)
                return 0;
 
-       if (down_write_killable(&mm->mmap_sem))
+       if (mmap_write_lock_killable(mm))
                return -EINTR;
 
        ret = do_brk_flags(addr, len, flags, &uf);
        populate = ((mm->def_flags & VM_LOCKED) != 0);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        userfaultfd_unmap_complete(mm, &uf);
        if (populate && !ret)
                mm_populate(addr, len);
@@ -3107,12 +3107,12 @@ void exit_mmap(struct mm_struct *mm)
                /*
                 * Manually reap the mm to free as much memory as possible.
                 * Then, as the oom reaper does, set MMF_OOM_SKIP to disregard
-                * this mm from further consideration.  Taking mm->mmap_sem for
+                * this mm from further consideration.  Taking mm->mmap_lock for
                 * write after setting MMF_OOM_SKIP will guarantee that the oom
-                * reaper will not run on this mm again after mmap_sem is
+                * reaper will not run on this mm again after mmap_lock is
                 * dropped.
                 *
-                * Nothing can be holding mm->mmap_sem here and the above call
+                * Nothing can be holding mm->mmap_lock here and the above call
                 * to mmu_notifier_release(mm) ensures mmu notifier callbacks in
                 * __oom_reap_task_mm() will not block.
                 *
@@ -3123,8 +3123,8 @@ void exit_mmap(struct mm_struct *mm)
                (void)__oom_reap_task_mm(mm);
 
                set_bit(MMF_OOM_SKIP, &mm->flags);
-               down_write(&mm->mmap_sem);
-               up_write(&mm->mmap_sem);
+               mmap_write_lock(mm);
+               mmap_write_unlock(mm);
        }
 
        if (mm->locked_vm) {
@@ -3437,7 +3437,7 @@ bool vma_is_special_mapping(const struct vm_area_struct *vma,
 }
 
 /*
- * Called with mm->mmap_sem held for writing.
+ * Called with mm->mmap_lock held for writing.
  * Insert a new vma covering the given region, with the given flags.
  * Its pages are supplied by the given array of struct page *.
  * The array can be shorter than len >> PAGE_SHIFT if it's null-terminated.
@@ -3474,7 +3474,7 @@ static void vm_lock_anon_vma(struct mm_struct *mm, struct anon_vma *anon_vma)
                 * The LSB of head.next can't change from under us
                 * because we hold the mm_all_locks_mutex.
                 */
-               down_write_nest_lock(&anon_vma->root->rwsem, &mm->mmap_sem);
+               down_write_nest_lock(&anon_vma->root->rwsem, &mm->mmap_lock);
                /*
                 * We can safely modify head.next after taking the
                 * anon_vma->root->rwsem. If some other vma in this mm shares
@@ -3504,7 +3504,7 @@ static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping)
                 */
                if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags))
                        BUG();
-               down_write_nest_lock(&mapping->i_mmap_rwsem, &mm->mmap_sem);
+               down_write_nest_lock(&mapping->i_mmap_rwsem, &mm->mmap_lock);
        }
 }
 
@@ -3513,11 +3513,11 @@ static void vm_lock_mapping(struct mm_struct *mm, struct address_space *mapping)
  * operations that could ever happen on a certain mm. This includes
  * vmtruncate, try_to_unmap, and all page faults.
  *
- * The caller must take the mmap_sem in write mode before calling
+ * The caller must take the mmap_lock in write mode before calling
  * mm_take_all_locks(). The caller isn't allowed to release the
- * mmap_sem until mm_drop_all_locks() returns.
+ * mmap_lock until mm_drop_all_locks() returns.
  *
- * mmap_sem in write mode is required in order to block all operations
+ * mmap_lock in write mode is required in order to block all operations
  * that could modify pagetables and free pages without need of
  * altering the vma layout. It's also needed in write mode to avoid new
  * anon_vmas to be associated with existing vmas.
@@ -3550,7 +3550,7 @@ int mm_take_all_locks(struct mm_struct *mm)
        struct vm_area_struct *vma;
        struct anon_vma_chain *avc;
 
-       BUG_ON(down_read_trylock(&mm->mmap_sem));
+       BUG_ON(mmap_read_trylock(mm));
 
        mutex_lock(&mm_all_locks_mutex);
 
@@ -3622,7 +3622,7 @@ static void vm_unlock_mapping(struct address_space *mapping)
 }
 
 /*
- * The mmap_sem cannot be released by the caller until
+ * The mmap_lock cannot be released by the caller until
  * mm_drop_all_locks() returns.
  */
 void mm_drop_all_locks(struct mm_struct *mm)
@@ -3630,7 +3630,7 @@ void mm_drop_all_locks(struct mm_struct *mm)
        struct vm_area_struct *vma;
        struct anon_vma_chain *avc;
 
-       BUG_ON(down_read_trylock(&mm->mmap_sem));
+       BUG_ON(mmap_read_trylock(mm));
        BUG_ON(!mutex_is_locked(&mm_all_locks_mutex));
 
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
index a3538cb..03c33c9 100644 (file)
@@ -301,7 +301,7 @@ void tlb_finish_mmu(struct mmu_gather *tlb,
 {
        /*
         * If there are parallel threads are doing PTE changes on same range
-        * under non-exclusive lock (e.g., mmap_sem read-side) but defer TLB
+        * under non-exclusive lock (e.g., mmap_lock read-side) but defer TLB
         * flush by batching, one thread may end up seeing inconsistent PTEs
         * and result in having stale TLB entries.  So flush TLB forcefully
         * if we detect parallel PTE batching threads.
index 06852b8..352bb9f 100644 (file)
@@ -599,7 +599,7 @@ void __mmu_notifier_invalidate_range(struct mm_struct *mm,
 }
 
 /*
- * Same as mmu_notifier_register but here the caller must hold the mmap_sem in
+ * Same as mmu_notifier_register but here the caller must hold the mmap_lock in
  * write mode. A NULL mn signals the notifier is being registered for itree
  * mode.
  */
@@ -609,7 +609,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
        struct mmu_notifier_subscriptions *subscriptions = NULL;
        int ret;
 
-       lockdep_assert_held_write(&mm->mmap_sem);
+       mmap_assert_write_locked(mm);
        BUG_ON(atomic_read(&mm->mm_users) <= 0);
 
        if (IS_ENABLED(CONFIG_LOCKDEP)) {
@@ -623,7 +623,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
                /*
                 * kmalloc cannot be called under mm_take_all_locks(), but we
                 * know that mm->notifier_subscriptions can't change while we
-                * hold the write side of the mmap_sem.
+                * hold the write side of the mmap_lock.
                 */
                subscriptions = kzalloc(
                        sizeof(struct mmu_notifier_subscriptions), GFP_KERNEL);
@@ -655,7 +655,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
         * readers.  acquire can only be used while holding the mmgrab or
         * mmget, and is safe because once created the
         * mmu_notifier_subscriptions is not freed until the mm is destroyed.
-        * As above, users holding the mmap_sem or one of the
+        * As above, users holding the mmap_lock or one of the
         * mm_take_all_locks() do not need to use acquire semantics.
         */
        if (subscriptions)
@@ -689,7 +689,7 @@ EXPORT_SYMBOL_GPL(__mmu_notifier_register);
  * @mn: The notifier to attach
  * @mm: The mm to attach the notifier to
  *
- * Must not hold mmap_sem nor any other VM related lock when calling
+ * Must not hold mmap_lock nor any other VM related lock when calling
  * this registration function. Must also ensure mm_users can't go down
  * to zero while this runs to avoid races with mmu_notifier_release,
  * so mm has to be current->mm or the mm should be pinned safely such
@@ -708,9 +708,9 @@ int mmu_notifier_register(struct mmu_notifier *subscription,
 {
        int ret;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        ret = __mmu_notifier_register(subscription, mm);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 EXPORT_SYMBOL_GPL(mmu_notifier_register);
@@ -750,7 +750,7 @@ find_get_mmu_notifier(struct mm_struct *mm, const struct mmu_notifier_ops *ops)
  * are the same.
  *
  * Each call to mmu_notifier_get() must be paired with a call to
- * mmu_notifier_put(). The caller must hold the write side of mm->mmap_sem.
+ * mmu_notifier_put(). The caller must hold the write side of mm->mmap_lock.
  *
  * While the caller has a mmu_notifier get the mm pointer will remain valid,
  * and can be converted to an active mm pointer via mmget_not_zero().
@@ -761,7 +761,7 @@ struct mmu_notifier *mmu_notifier_get_locked(const struct mmu_notifier_ops *ops,
        struct mmu_notifier *subscription;
        int ret;
 
-       lockdep_assert_held_write(&mm->mmap_sem);
+       mmap_assert_write_locked(mm);
 
        if (mm->notifier_subscriptions) {
                subscription = find_get_mmu_notifier(mm, ops);
@@ -983,7 +983,7 @@ int mmu_interval_notifier_insert(struct mmu_interval_notifier *interval_sub,
        struct mmu_notifier_subscriptions *subscriptions;
        int ret;
 
-       might_lock(&mm->mmap_sem);
+       might_lock(&mm->mmap_lock);
 
        subscriptions = smp_load_acquire(&mm->notifier_subscriptions);
        if (!subscriptions || !subscriptions->has_itree) {
@@ -1006,7 +1006,7 @@ int mmu_interval_notifier_insert_locked(
                mm->notifier_subscriptions;
        int ret;
 
-       lockdep_assert_held_write(&mm->mmap_sem);
+       mmap_assert_write_locked(mm);
 
        if (!subscriptions || !subscriptions->has_itree) {
                ret = __mmu_notifier_register(NULL, mm);
index 494192c..ce8b8a5 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/ksm.h>
 #include <linux/uaccess.h>
 #include <linux/mm_inline.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
 #include <asm/tlbflush.h>
@@ -49,7 +49,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
        bool uffd_wp_resolve = cp_flags & MM_CP_UFFD_WP_RESOLVE;
 
        /*
-        * Can be called with only the mmap_sem for reading by
+        * Can be called with only the mmap_lock for reading by
         * prot_numa so we must check the pmd isn't constantly
         * changing from under us from pmd_none to pmd_trans_huge
         * and/or the other way around.
@@ -59,7 +59,7 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 
        /*
         * The pmd points to a regular pte so the pmd can't change
-        * from under us even if the mmap_sem is only hold for
+        * from under us even if the mmap_lock is only hold for
         * reading.
         */
        pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
@@ -228,7 +228,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
                next = pmd_addr_end(addr, end);
 
                /*
-                * Automatic NUMA balancing walks the tables with mmap_sem
+                * Automatic NUMA balancing walks the tables with mmap_lock
                 * held for read. It's possible a parallel update to occur
                 * between pmd_trans_huge() and a pmd_none_or_clear_bad()
                 * check leading to a false positive and clearing.
@@ -477,7 +477,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
 
 success:
        /*
-        * vm_flags and vm_page_prot are protected by the mmap_sem
+        * vm_flags and vm_page_prot are protected by the mmap_lock
         * held in write mode.
         */
        vma->vm_flags = newflags;
@@ -538,7 +538,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 
        reqprot = prot;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
 
        /*
@@ -628,7 +628,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
                prot = reqprot;
        }
 out:
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        return error;
 }
 
@@ -658,7 +658,7 @@ SYSCALL_DEFINE2(pkey_alloc, unsigned long, flags, unsigned long, init_val)
        if (init_val & ~PKEY_ACCESS_MASK)
                return -EINVAL;
 
-       down_write(&current->mm->mmap_sem);
+       mmap_write_lock(current->mm);
        pkey = mm_pkey_alloc(current->mm);
 
        ret = -ENOSPC;
@@ -672,7 +672,7 @@ SYSCALL_DEFINE2(pkey_alloc, unsigned long, flags, unsigned long, init_val)
        }
        ret = pkey;
 out:
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        return ret;
 }
 
@@ -680,9 +680,9 @@ SYSCALL_DEFINE1(pkey_free, int, pkey)
 {
        int ret;
 
-       down_write(&current->mm->mmap_sem);
+       mmap_write_lock(current->mm);
        ret = mm_pkey_free(current->mm, pkey);
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
 
        /*
         * We could provie warnings or errors if any VMA still
index 7d69e3f..5dd572d 100644 (file)
@@ -146,7 +146,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
 
        /*
         * We don't have to worry about the ordering of src and dst
-        * pte locks because exclusive mmap_sem prevents deadlock.
+        * pte locks because exclusive mmap_lock prevents deadlock.
         */
        old_pte = pte_offset_map_lock(mm, old_pmd, old_addr, &old_ptl);
        new_pte = pte_offset_map(new_pmd, new_addr);
@@ -213,7 +213,7 @@ static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr,
 
        /*
         * We don't have to worry about the ordering of src and dst
-        * ptlocks because exclusive mmap_sem prevents deadlock.
+        * ptlocks because exclusive mmap_lock prevents deadlock.
         */
        old_ptl = pmd_lock(vma->vm_mm, old_pmd);
        new_ptl = pmd_lockptr(mm, new_pmd);
@@ -696,7 +696,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
        if (!new_len)
                return ret;
 
-       if (down_write_killable(&current->mm->mmap_sem))
+       if (mmap_write_lock_killable(current->mm))
                return -EINTR;
 
        if (flags & (MREMAP_FIXED | MREMAP_DONTUNMAP)) {
@@ -710,7 +710,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
         * Always allow a shrinking remap: that just unmaps
         * the unnecessary pages..
         * __do_munmap does all the needed commit accounting, and
-        * downgrades mmap_sem to read if so directed.
+        * downgrades mmap_lock to read if so directed.
         */
        if (old_len >= new_len) {
                int retval;
@@ -720,7 +720,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
                if (retval < 0 && old_len != new_len) {
                        ret = retval;
                        goto out;
-               /* Returning 1 indicates mmap_sem is downgraded to read. */
+               /* Returning 1 indicates mmap_lock is downgraded to read. */
                } else if (retval == 1)
                        downgraded = true;
                ret = addr;
@@ -788,9 +788,9 @@ out:
                locked = false;
        }
        if (downgraded)
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
        else
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
        if (locked && new_len > old_len)
                mm_populate(new_addr + old_len, new_len - old_len);
        userfaultfd_unmap_complete(mm, &uf_unmap_early);
index c3bd3e7..69c6d20 100644 (file)
@@ -57,7 +57,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
         * If the interval [start,end) covers some unmapped address ranges,
         * just ignore them, but return -ENOMEM at the end.
         */
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        vma = find_vma(mm, start);
        for (;;) {
                struct file *file;
@@ -88,12 +88,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
                if ((flags & MS_SYNC) && file &&
                                (vma->vm_flags & VM_SHARED)) {
                        get_file(file);
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                        error = vfs_fsync_range(file, fstart, fend, 1);
                        fput(file);
                        if (error || start >= end)
                                goto out;
-                       down_read(&mm->mmap_sem);
+                       mmap_read_lock(mm);
                        vma = find_vma(mm, start);
                } else {
                        if (start >= end) {
@@ -104,7 +104,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
                }
        }
 out_unlock:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 out:
        return error ? : unmapped_error;
 }
index 062dc1c..cdcad5d 100644 (file)
@@ -172,11 +172,11 @@ static void *__vmalloc_user_flags(unsigned long size, gfp_t flags)
        if (ret) {
                struct vm_area_struct *vma;
 
-               down_write(&current->mm->mmap_sem);
+               mmap_write_lock(current->mm);
                vma = find_vma(current->mm, (unsigned long)ret);
                if (vma)
                        vma->vm_flags |= VM_USERMAP;
-               up_write(&current->mm->mmap_sem);
+               mmap_write_unlock(current->mm);
        }
 
        return ret;
@@ -582,7 +582,7 @@ static void put_nommu_region(struct vm_region *region)
  * add a VMA into a process's mm_struct in the appropriate place in the list
  * and tree and add to the address space's page tree also if not an anonymous
  * page
- * - should be called with mm->mmap_sem held writelocked
+ * - should be called with mm->mmap_lock held writelocked
  */
 static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma)
 {
@@ -696,7 +696,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
 
 /*
  * look up the first VMA in which addr resides, NULL if none
- * - should be called with mm->mmap_sem at least held readlocked
+ * - should be called with mm->mmap_lock at least held readlocked
  */
 struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
 {
@@ -742,7 +742,7 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address)
 
 /*
  * look up the first VMA exactly that exactly matches addr
- * - should be called with mm->mmap_sem at least held readlocked
+ * - should be called with mm->mmap_lock at least held readlocked
  */
 static struct vm_area_struct *find_vma_exact(struct mm_struct *mm,
                                             unsigned long addr,
@@ -1542,9 +1542,9 @@ int vm_munmap(unsigned long addr, size_t len)
        struct mm_struct *mm = current->mm;
        int ret;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        ret = do_munmap(mm, addr, len, NULL);
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
        return ret;
 }
 EXPORT_SYMBOL(vm_munmap);
@@ -1631,9 +1631,9 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
 {
        unsigned long ret;
 
-       down_write(&current->mm->mmap_sem);
+       mmap_write_lock(current->mm);
        ret = do_mremap(addr, old_len, new_len, flags, new_addr);
-       up_write(&current->mm->mmap_sem);
+       mmap_write_unlock(current->mm);
        return ret;
 }
 
@@ -1705,7 +1705,7 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
        struct vm_area_struct *vma;
        int write = gup_flags & FOLL_WRITE;
 
-       if (down_read_killable(&mm->mmap_sem))
+       if (mmap_read_lock_killable(mm))
                return 0;
 
        /* the access must start within one of the target process's mappings */
@@ -1728,7 +1728,7 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
                len = 0;
        }
 
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return len;
 }
index 4daedf7..b4e9491 100644 (file)
@@ -569,7 +569,7 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
 {
        bool ret = true;
 
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (!mmap_read_trylock(mm)) {
                trace_skip_task_reaping(tsk->pid);
                return false;
        }
@@ -577,8 +577,8 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
        /*
         * MMF_OOM_SKIP is set by exit_mmap when the OOM reaper can't
         * work on the mm anymore. The check for MMF_OOM_SKIP must run
-        * under mmap_sem for reading because it serializes against the
-        * down_write();up_write() cycle in exit_mmap().
+        * under mmap_lock for reading because it serializes against the
+        * mmap_write_lock();mmap_write_unlock() cycle in exit_mmap().
         */
        if (test_bit(MMF_OOM_SKIP, &mm->flags)) {
                trace_skip_task_reaping(tsk->pid);
@@ -600,7 +600,7 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
 out_finish:
        trace_finish_task_reaping(tsk->pid);
 out_unlock:
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        return ret;
 }
@@ -611,7 +611,7 @@ static void oom_reap_task(struct task_struct *tsk)
        int attempts = 0;
        struct mm_struct *mm = tsk->signal->oom_mm;
 
-       /* Retry the down_read_trylock(mmap_sem) a few times */
+       /* Retry the mmap_read_trylock(mm) a few times */
        while (attempts++ < MAX_OOM_REAP_RETRIES && !oom_reap_task_mm(tsk, mm))
                schedule_timeout_idle(HZ/10);
 
@@ -629,7 +629,7 @@ done:
 
        /*
         * Hide this mm from OOM killer because it has been either reaped or
-        * somebody can't call up_write(mmap_sem).
+        * somebody can't call mmap_write_unlock(mm).
         */
        set_bit(MMF_OOM_SKIP, &mm->flags);
 
@@ -898,7 +898,7 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
        /*
         * Kill all user processes sharing victim->mm in other thread groups, if
         * any.  They don't get access to memory reserves, though, to avoid
-        * depletion of all memory.  This prevents mm->mmap_sem livelock when an
+        * depletion of all memory.  This prevents mm->mmap_lock livelock when an
         * oom killed thread cannot exit because it requires the semaphore and
         * its contended by another thread trying to allocate memory itself.
         * That thread will now get access to memory reserves since it has a
index 76965be..e8726f3 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/psi.h>
 #include <linux/uio.h>
 #include <linux/sched/task.h>
-#include <asm/pgtable.h>
 
 static struct bio *get_swap_bio(gfp_t gfp_flags,
                                struct page *page, bio_end_io_t end_io)
index aa6d37f..2c385dd 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/page-isolation.h>
 #include <linux/jump_label.h>
 #include <linux/slab.h>
-#include <asm/pgtable.h>
+#include <linux/pgtable.h>
 #include <linux/scatterlist.h>
 
 #define PAGE_REPORTING_MIN_ORDER       pageblock_order
index 928df16..e81640d 100644 (file)
@@ -373,7 +373,7 @@ static int __walk_page_range(unsigned long start, unsigned long end,
  * caller-specific data to callbacks, @private should be helpful.
  *
  * Locking:
- *   Callers of walk_page_range() and walk_page_vma() should hold @mm->mmap_sem,
+ *   Callers of walk_page_range() and walk_page_vma() should hold @mm->mmap_lock,
  *   because these function traverse vma list and/or access to vma's data.
  */
 int walk_page_range(struct mm_struct *mm, unsigned long start,
@@ -395,7 +395,7 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
        if (!walk.mm)
                return -EINVAL;
 
-       lockdep_assert_held(&walk.mm->mmap_sem);
+       mmap_assert_locked(walk.mm);
 
        vma = find_vma(walk.mm, start);
        do {
@@ -453,7 +453,7 @@ int walk_page_range_novma(struct mm_struct *mm, unsigned long start,
        if (start >= end || !walk.mm)
                return -EINVAL;
 
-       lockdep_assert_held(&walk.mm->mmap_sem);
+       mmap_assert_locked(walk.mm);
 
        return __walk_page_range(start, end, &walk);
 }
@@ -472,7 +472,7 @@ int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,
        if (!walk.mm)
                return -EINVAL;
 
-       lockdep_assert_held(&walk.mm->mmap_sem);
+       mmap_assert_locked(walk.mm);
 
        err = walk_page_test(vma->vm_start, vma->vm_end, &walk);
        if (err > 0)
@@ -498,11 +498,11 @@ int walk_page_vma(struct vm_area_struct *vma, const struct mm_walk_ops *ops,
  * Also see walk_page_range() for additional information.
  *
  * Locking:
- *   This function can't require that the struct mm_struct::mmap_sem is held,
+ *   This function can't require that the struct mm_struct::mmap_lock is held,
  *   since @mapping may be mapped by multiple processes. Instead
  *   @mapping->i_mmap_rwsem must be held. This might have implications in the
  *   callbacks, and it's up tho the caller to ensure that the
- *   struct mm_struct::mmap_sem is not needed.
+ *   struct mm_struct::mmap_lock is not needed.
  *
  *   Also this means that a caller can't rely on the struct
  *   vm_area_struct::vm_flags to be constant across a call,
index d18f0e1..9578db8 100644 (file)
@@ -2,15 +2,15 @@
 /*
  *  mm/pgtable-generic.c
  *
- *  Generic pgtable methods declared in asm-generic/pgtable.h
+ *  Generic pgtable methods declared in linux/pgtable.h
  *
  *  Copyright (C) 2010  Linus Torvalds
  */
 
 #include <linux/pagemap.h>
 #include <linux/hugetlb.h>
+#include <linux/pgtable.h>
 #include <asm/tlb.h>
-#include <asm-generic/pgtable.h>
 
 /*
  * If a p?d_bad entry is found while walking page tables, report
@@ -53,7 +53,7 @@ void pmd_clear_bad(pmd_t *pmd)
 
 #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
 /*
- * Only sets the access flags (dirty, accessed), as well as write 
+ * Only sets the access flags (dirty, accessed), as well as write
  * permission. Furthermore, we know it always gets set to a "more
  * permissive" setting, which allows most architectures to optimize
  * this. We return whether the PTE actually changed, which in turn
index 74e957e..cc85ce8 100644 (file)
@@ -104,12 +104,12 @@ static int process_vm_rw_single_vec(unsigned long addr,
                 * access remotely because task/mm might not
                 * current/current->mm
                 */
-               down_read(&mm->mmap_sem);
+               mmap_read_lock(mm);
                pinned_pages = pin_user_pages_remote(task, mm, pa, pinned_pages,
                                                     flags, process_pages,
                                                     NULL, &locked);
                if (locked)
-                       up_read(&mm->mmap_sem);
+                       mmap_read_unlock(mm);
                if (pinned_pages <= 0)
                        return -EFAULT;
 
index f4ce916..ba88ec4 100644 (file)
@@ -141,13 +141,13 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm_struct *mm, pgd_t *pgd)
 {
        const struct ptdump_range *range = st->range;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        while (range->start != range->end) {
                walk_page_range_novma(mm, range->start, range->end,
                                      &ptdump_ops, pgd, st);
                range++;
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
 
        /* Flush out the last page */
        st->note_page(st, 0, -1, 0);
index ad4a0fd..5fe2ded 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -21,7 +21,7 @@
  * Lock ordering in mm:
  *
  * inode->i_mutex      (while writing or truncating, not reading or faulting)
- *   mm->mmap_sem
+ *   mm->mmap_lock
  *     page->flags PG_locked (lock_page)   * (see huegtlbfs below)
  *       hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share)
  *         mapping->i_mmap_rwsem
@@ -177,7 +177,7 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
  * to do any locking for the common case of already having
  * an anon_vma.
  *
- * This must be called with the mmap_sem held for reading.
+ * This must be called with the mmap_lock held for reading.
  */
 int __anon_vma_prepare(struct vm_area_struct *vma)
 {
@@ -1444,7 +1444,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                                if (!PageTransCompound(page)) {
                                        /*
                                         * Holding pte lock, we do *not* need
-                                        * mmap_sem here
+                                        * mmap_lock here
                                         */
                                        mlock_vma_page(page);
                                }
@@ -1817,7 +1817,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page,
        /*
         * Note: remove_migration_ptes() cannot use page_lock_anon_vma_read()
         * because that depends on page_mapped(); but not all its usages
-        * are holding mmap_sem. Users without mmap_sem are required to
+        * are holding mmap_lock. Users without mmap_lock are required to
         * take a reference count to prevent the anon_vma disappearing
         */
        anon_vma = page_anon_vma(page);
@@ -1837,7 +1837,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page,
  * Find all the mappings of a page using the mapping pointer and the vma chains
  * contained in the anon_vma struct it points to.
  *
- * When called from try_to_munlock(), the mmap_sem of the mm containing the vma
+ * When called from try_to_munlock(), the mmap_lock of the mm containing the vma
  * where the page was found will be held for write.  So, we won't recheck
  * vm_flags for that VMA.  That should be OK, because that vma shouldn't be
  * LOCKED.
@@ -1889,7 +1889,7 @@ static void rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc,
  * Find all the mappings of a page using the mapping pointer and the vma chains
  * contained in the address_space struct it points to.
  *
- * When called from try_to_munlock(), the mmap_sem of the mm containing the vma
+ * When called from try_to_munlock(), the mmap_lock of the mm containing the vma
  * where the page was found will be held for write.  So, we won't recheck
  * vm_flags for that VMA.  That should be OK, because that vma shouldn't be
  * LOCKED.
index ea95a3e..a0dbe62 100644 (file)
@@ -82,7 +82,6 @@ static struct vfsmount *shm_mnt;
 #include <linux/uuid.h>
 
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 
 #include "internal.h"
 
@@ -2320,7 +2319,7 @@ static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
                                             PAGE_SIZE);
                        kunmap_atomic(page_kaddr);
 
-                       /* fallback to copy_from_user outside mmap_sem */
+                       /* fallback to copy_from_user outside mmap_lock */
                        if (unlikely(ret)) {
                                *pagep = page;
                                shmem_inode_unacct_blocks(inode, 1);
@@ -4137,7 +4136,7 @@ int shmem_zero_setup(struct vm_area_struct *vma)
        loff_t size = vma->vm_end - vma->vm_start;
 
        /*
-        * Cloning a new file under mmap_sem leads to a lock ordering conflict
+        * Cloning a new file under mmap_lock leads to a lock ordering conflict
         * between XFS directory reading and selinux: since this file is only
         * accessible to the user through its mapping, use S_PRIVATE flag to
         * bypass file security, in the same way as shmem_kernel_file_setup().
index 200aef6..0db7738 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/sched.h>
 #include <asm/dma.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 /*
  * Allocate a block of memory to be used to back the virtual memory map
index 6284328..b2b9a3e 100644 (file)
@@ -17,7 +17,6 @@
 #include "internal.h"
 #include <asm/dma.h>
 #include <asm/pgalloc.h>
-#include <asm/pgtable.h>
 
 /*
  * Permanent SPARSEMEM data:
index 9d20b00..e98ff46 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/swap_slots.h>
 #include <linux/huge_mm.h>
 
-#include <asm/pgtable.h>
 
 /*
  * swapper_space is a fiction, retained to simplify the path through
@@ -553,7 +552,7 @@ static unsigned long swapin_nr_pages(unsigned long offset)
  * This has been extended to use the NUMA policies from the mm triggering
  * the readahead.
  *
- * Caller must hold read mmap_sem if vmf->vma is not NULL.
+ * Caller must hold read mmap_lock if vmf->vma is not NULL.
  */
 struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
                                struct vm_fault *vmf)
@@ -735,7 +734,7 @@ static void swap_ra_info(struct vm_fault *vmf,
  * Primitive swap readahead code. We simply read in a few pages whoes
  * virtual addresses are around the fault address in the same vma.
  *
- * Caller must hold read mmap_sem if vmf->vma is not NULL.
+ * Caller must hold read mmap_lock if vmf->vma is not NULL.
  *
  */
 static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
index a3d191e..987276c 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/swap_slots.h>
 #include <linux/sort.h>
 
-#include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <linux/swapops.h>
 #include <linux/swap_cgroup.h>
@@ -2101,7 +2100,7 @@ static int unuse_mm(struct mm_struct *mm, unsigned int type,
        struct vm_area_struct *vma;
        int ret = 0;
 
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                if (vma->anon_vma) {
                        ret = unuse_vma(vma, type, frontswap,
@@ -2111,7 +2110,7 @@ static int unuse_mm(struct mm_struct *mm, unsigned int type,
                }
                cond_resched();
        }
-       up_read(&mm->mmap_sem);
+       mmap_read_unlock(mm);
        return ret;
 }
 
index 7f51940..b804193 100644 (file)
@@ -76,7 +76,7 @@ static int mcopy_atomic_pte(struct mm_struct *dst_mm,
                                     PAGE_SIZE);
                kunmap_atomic(page_kaddr);
 
-               /* fallback to copy_from_user outside mmap_sem */
+               /* fallback to copy_from_user outside mmap_lock */
                if (unlikely(ret)) {
                        ret = -ENOENT;
                        *pagep = page;
@@ -200,7 +200,7 @@ static pmd_t *mm_alloc_pmd(struct mm_struct *mm, unsigned long address)
 #ifdef CONFIG_HUGETLB_PAGE
 /*
  * __mcopy_atomic processing for HUGETLB vmas.  Note that this routine is
- * called with mmap_sem held, it will release mmap_sem before returning.
+ * called with mmap_lock held, it will release mmap_lock before returning.
  */
 static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
                                              struct vm_area_struct *dst_vma,
@@ -228,7 +228,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
         * feature is not supported.
         */
        if (zeropage) {
-               up_read(&dst_mm->mmap_sem);
+               mmap_read_unlock(dst_mm);
                return -EINVAL;
        }
 
@@ -247,7 +247,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
 
 retry:
        /*
-        * On routine entry dst_vma is set.  If we had to drop mmap_sem and
+        * On routine entry dst_vma is set.  If we had to drop mmap_lock and
         * retry, dst_vma will be set to NULL and we must lookup again.
         */
        if (!dst_vma) {
@@ -315,7 +315,7 @@ retry:
                cond_resched();
 
                if (unlikely(err == -ENOENT)) {
-                       up_read(&dst_mm->mmap_sem);
+                       mmap_read_unlock(dst_mm);
                        BUG_ON(!page);
 
                        err = copy_huge_page_from_user(page,
@@ -326,7 +326,7 @@ retry:
                                err = -EFAULT;
                                goto out;
                        }
-                       down_read(&dst_mm->mmap_sem);
+                       mmap_read_lock(dst_mm);
 
                        dst_vma = NULL;
                        goto retry;
@@ -346,7 +346,7 @@ retry:
        }
 
 out_unlock:
-       up_read(&dst_mm->mmap_sem);
+       mmap_read_unlock(dst_mm);
 out:
        if (page) {
                /*
@@ -357,7 +357,7 @@ out:
                 * private and shared mappings.  See the routine
                 * restore_reserve_on_error for details.  Unfortunately, we
                 * can not call restore_reserve_on_error now as it would
-                * require holding mmap_sem.
+                * require holding mmap_lock.
                 *
                 * If a reservation for the page existed in the reservation
                 * map of a private mapping, the map was modified to indicate
@@ -485,7 +485,7 @@ static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm,
        copied = 0;
        page = NULL;
 retry:
-       down_read(&dst_mm->mmap_sem);
+       mmap_read_lock(dst_mm);
 
        /*
         * If memory mappings are changing because of non-cooperative
@@ -583,7 +583,7 @@ retry:
                if (unlikely(err == -ENOENT)) {
                        void *page_kaddr;
 
-                       up_read(&dst_mm->mmap_sem);
+                       mmap_read_unlock(dst_mm);
                        BUG_ON(!page);
 
                        page_kaddr = kmap(page);
@@ -612,7 +612,7 @@ retry:
        }
 
 out_unlock:
-       up_read(&dst_mm->mmap_sem);
+       mmap_read_unlock(dst_mm);
 out:
        if (page)
                put_page(page);
@@ -652,7 +652,7 @@ int mwriteprotect_range(struct mm_struct *dst_mm, unsigned long start,
        /* Does the address range wrap, or is the span zero-sized? */
        BUG_ON(start + len <= start);
 
-       down_read(&dst_mm->mmap_sem);
+       mmap_read_lock(dst_mm);
 
        /*
         * If memory mappings are changing because of non-cooperative
@@ -686,6 +686,6 @@ int mwriteprotect_range(struct mm_struct *dst_mm, unsigned long start,
 
        err = 0;
 out_unlock:
-       up_read(&dst_mm->mmap_sem);
+       mmap_read_unlock(dst_mm);
        return err;
 }
index cd62e6f..c63c8e4 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -425,7 +425,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
  * @bypass_rlim: %true if checking RLIMIT_MEMLOCK should be skipped
  *
  * Assumes @task and @mm are valid (i.e. at least one reference on each), and
- * that mmap_sem is held as writer.
+ * that mmap_lock is held as writer.
  *
  * Return:
  * * 0       on success
@@ -437,7 +437,7 @@ int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc,
        unsigned long locked_vm, limit;
        int ret = 0;
 
-       lockdep_assert_held_write(&mm->mmap_sem);
+       mmap_assert_write_locked(mm);
 
        locked_vm = mm->locked_vm;
        if (inc) {
@@ -481,10 +481,10 @@ int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc)
        if (pages == 0 || !mm)
                return 0;
 
-       down_write(&mm->mmap_sem);
+       mmap_write_lock(mm);
        ret = __account_locked_vm(mm, pages, inc, current,
                                  capable(CAP_IPC_LOCK));
-       up_write(&mm->mmap_sem);
+       mmap_write_unlock(mm);
 
        return ret;
 }
@@ -501,11 +501,11 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
 
        ret = security_mmap_file(file, prot, flag);
        if (!ret) {
-               if (down_write_killable(&mm->mmap_sem))
+               if (mmap_write_lock_killable(mm))
                        return -EINTR;
                ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,
                                    &populate, &uf);
-               up_write(&mm->mmap_sem);
+               mmap_write_unlock(mm);
                userfaultfd_unmap_complete(mm, &uf);
                if (populate)
                        mm_populate(ret, populate);
index cdc32a3..d909281 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/sched/task.h>
 #include <linux/mm.h>
 #include <linux/vmacache.h>
-#include <asm/pgtable.h>
 
 /*
  * Hash based on the pmd of addr if configured with MMU, which provides a good
index f6dc067..952a01e 100644 (file)
@@ -39,8 +39,8 @@
 #include <linux/highmem.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/pgtable.h>
 #include <asm/tlbflush.h>
-#include <asm/pgtable.h>
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/vmalloc.h>
index 15d47d5..27716e4 100644 (file)
@@ -1734,7 +1734,7 @@ int tcp_mmap(struct file *file, struct socket *sock,
                return -EPERM;
        vma->vm_flags &= ~(VM_MAYWRITE | VM_MAYEXEC);
 
-       /* Instruct vm_insert_page() to not down_read(mmap_sem) */
+       /* Instruct vm_insert_page() to not mmap_read_lock(mm) */
        vma->vm_flags |= VM_MIXEDMAP;
 
        vma->vm_ops = &tcp_vm_ops;
@@ -1762,11 +1762,11 @@ static int tcp_zerocopy_receive(struct sock *sk,
 
        sock_rps_record_flow(sk);
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
 
        vma = find_vma(current->mm, address);
        if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops) {
-               up_read(&current->mm->mmap_sem);
+               mmap_read_unlock(current->mm);
                return -EINVAL;
        }
        zc->length = min_t(unsigned long, zc->length, vma->vm_end - address);
@@ -1827,7 +1827,7 @@ static int tcp_zerocopy_receive(struct sock *sk,
                frags++;
        }
 out:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        if (length) {
                WRITE_ONCE(tp->copied_seq, seq);
                tcp_rcv_space_adjust(sk);
index a0d2b75..e97db37 100644 (file)
@@ -254,10 +254,10 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
        if (!umem->pgs)
                return -ENOMEM;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        npgs = pin_user_pages(address, umem->npgs,
                              gup_flags | FOLL_LONGTERM, &umem->pgs[0], NULL);
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        if (npgs != umem->npgs) {
                if (npgs >= 0) {
index edde63a..e5ef20a 100644 (file)
@@ -875,7 +875,7 @@ can_read_key:
         *
         * Allocating a temporary buffer to hold the keys before
         * transferring them to user buffer to avoid potential
-        * deadlock involving page fault and mmap_sem.
+        * deadlock involving page fault and mmap_lock.
         *
         * key_data_len = (buflen <= PAGE_SIZE)
         *              ? buflen : actual length of key data
index 930def8..6863024 100644 (file)
@@ -2876,7 +2876,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area)
        
        if (runtime->oss.params) {
                /* use mutex_trylock() for params_lock for avoiding a deadlock
-                * between mmap_sem and params_lock taken by
+                * between mmap_lock and params_lock taken by
                 * copy_from/to_user() in snd_pcm_oss_write/read()
                 */
                err = snd_pcm_oss_change_params(substream, true);
index feefdfc..c42217e 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/export.h>
-#include <asm/pgtable.h>
 #include <sound/memalloc.h>
 
 
index 41a03c6..d20aedd 100644 (file)
 #include <linux/time.h>
 #include <linux/completion.h>
 #include <linux/acpi.h>
+#include <linux/pgtable.h>
 
 #ifdef CONFIG_X86
 /* for snoop control */
-#include <asm/pgtable.h>
 #include <asm/set_memory.h>
 #include <asm/cpufeature.h>
 #endif
index d27947a..0594f89 100644 (file)
 #include <linux/dmaengine.h>
 #include <linux/pci.h>
 #include <linux/acpi.h>
+#include <linux/pgtable.h>
 
 /* supported DMA engine drivers */
 #include <linux/dma/dw.h>
 
 #include <asm/page.h>
-#include <asm/pgtable.h>
 
 #include "sst-dsp.h"
 #include "sst-dsp-priv.h"
index c183f8e..16ac16f 100644 (file)
@@ -10,8 +10,8 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
+#include <linux/pgtable.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 89ca6fe..efb6c3f 100644 (file)
@@ -20,7 +20,7 @@ static inline const char *kallsyms_lookup(unsigned long addr,
 
 #include <execinfo.h>
 #include <stdlib.h>
-static inline void print_ip_sym(unsigned long ip)
+static inline void print_ip_sym(const char *loglvl, unsigned long ip)
 {
        char **name;
 
index f1e07fa..5f8f3e8 100644 (file)
@@ -60,11 +60,11 @@ static void async_pf_execute(struct work_struct *work)
         * mm and might be done in another context, so we must
         * access remotely.
         */
-       down_read(&mm->mmap_sem);
+       mmap_read_lock(mm);
        get_user_pages_remote(NULL, mm, addr, 1, FOLL_WRITE, NULL, NULL,
                        &locked);
        if (locked)
-               up_read(&mm->mmap_sem);
+               mmap_read_unlock(mm);
 
        if (IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC))
                kvm_arch_async_page_present(vcpu, apf);
index 7b0da1c..0dfee75 100644 (file)
@@ -55,7 +55,6 @@
 #include <asm/processor.h>
 #include <asm/ioctl.h>
 #include <linux/uaccess.h>
-#include <asm/pgtable.h>
 
 #include "coalesced_mmio.h"
 #include "async_pf.h"
@@ -1632,7 +1631,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn)
        if (kvm_is_error_hva(addr))
                return PAGE_SIZE;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        vma = find_vma(current->mm, addr);
        if (!vma)
                goto out;
@@ -1640,7 +1639,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn)
        size = vma_kernel_pagesize(vma);
 
 out:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
 
        return size;
 }
@@ -1893,7 +1892,7 @@ static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
        if (npages == 1)
                return pfn;
 
-       down_read(&current->mm->mmap_sem);
+       mmap_read_lock(current->mm);
        if (npages == -EHWPOISON ||
              (!async && check_user_page_hwpoison(addr))) {
                pfn = KVM_PFN_ERR_HWPOISON;
@@ -1917,7 +1916,7 @@ retry:
                pfn = KVM_PFN_ERR_FAULT;
        }
 exit:
-       up_read(&current->mm->mmap_sem);
+       mmap_read_unlock(current->mm);
        return pfn;
 }