mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-19 06:21:10 +00:00
* refs/heads/tmp-a483478:
UPSTREAM: arm64: vdso: Build vDSO with -ffixed-x18
Revert "drm/dsi: Fix byte order of DCS set/get brightness"
Reverting below patches from android-4.19-stable.125
Linux 4.19.125
rxrpc: Fix ack discard
rxrpc: Trace discarded ACKs
iio: adc: stm32-dfsdm: fix device used to request dma
iio: adc: stm32-dfsdm: Use dma_request_chan() instead dma_request_slave_channel()
iio: adc: stm32-adc: fix device used to request dma
iio: adc: stm32-adc: Use dma_request_chan() instead dma_request_slave_channel()
x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks
rxrpc: Fix a memory leak in rxkad_verify_response()
rapidio: fix an error in get_user_pages_fast() error handling
ipack: tpci200: fix error return code in tpci200_register()
mei: release me_cl object reference
misc: rtsx: Add short delay after exit from ASPM
iio: dac: vf610: Fix an error handling path in 'vf610_dac_probe()'
iio: sca3000: Remove an erroneous 'get_device()'
staging: greybus: Fix uninitialized scalar variable
staging: iio: ad2s1210: Fix SPI reading
Revert "gfs2: Don't demote a glock until its revokes are written"
brcmfmac: abort and release host after error
tty: serial: qcom_geni_serial: Fix wrap around of TX buffer
cxgb4/cxgb4vf: Fix mac_hlist initialization and free
cxgb4: free mac_hlist properly
net: bcmgenet: abort suspend on error
net: bcmgenet: code movement
Revert "net/ibmvnic: Fix EOI when running in XIVE mode"
media: fdp1: Fix R-Car M3-N naming in debug message
thunderbolt: Drop duplicated get_switch_at_route()
staging: most: core: replace strcpy() by strscpy()
libnvdimm/btt: Fix LBA masking during 'free list' population
libnvdimm/btt: Remove unnecessary code in btt_freelist_init
nfit: Add Hyper-V NVDIMM DSM command set to white list
powerpc/64s: Disable STRICT_KERNEL_RWX
powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE
drm/i915/gvt: Init DPLL/DDI vreg for virtual display instead of inheritance.
dmaengine: owl: Use correct lock in owl_dma_get_pchan()
dmaengine: tegra210-adma: Fix an error handling path in 'tegra_adma_probe()'
apparmor: Fix aa_label refcnt leak in policy_update
apparmor: fix potential label refcnt leak in aa_change_profile
apparmor: Fix use-after-free in aa_audit_rule_init
drm/etnaviv: fix perfmon domain interation
ALSA: hda/realtek - Add more fixup entries for Clevo machines
ALSA: hda/realtek - Fix silent output on Gigabyte X570 Aorus Xtreme
ALSA: pcm: fix incorrect hw_base increase
ALSA: iec1712: Initialize STDSP24 properly when using the model=staudio option
padata: purge get_cpu and reorder_via_wq from padata_do_serial
padata: initialize pd->cpu with effective cpumask
padata: Replace delayed timer with immediate workqueue in padata_reorder
ARM: futex: Address build warning
platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA
USB: core: Fix misleading driver bug report
stmmac: fix pointer check after utilization in stmmac_interrupt
ceph: fix double unlock in handle_cap_export()
HID: quirks: Add HID_QUIRK_NO_INIT_REPORTS quirk for Dell K12A keyboard-dock
gtp: set NLM_F_MULTI flag in gtp_genl_dump_pdp()
x86/apic: Move TSC deadline timer debug printk
HID: i2c-hid: reset Synaptics SYNA2393 on resume
scsi: ibmvscsi: Fix WARN_ON during event pool release
component: Silence bind error on -EPROBE_DEFER
aquantia: Fix the media type of AQC100 ethernet controller in the driver
vhost/vsock: fix packet delivery order to monitoring devices
configfs: fix config_item refcnt leak in configfs_rmdir()
scsi: qla2xxx: Delete all sessions before unregister local nvme port
scsi: qla2xxx: Fix hang when issuing nvme disconnect-all in NPIV
HID: alps: ALPS_1657 is too specific; use U1_UNICORN_LEGACY instead
HID: alps: Add AUI1657 device ID
HID: multitouch: add eGalaxTouch P80H84 support
gcc-common.h: Update for GCC 10
ubi: Fix seq_file usage in detailed_erase_block_info debugfs file
i2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()'
iommu/amd: Fix over-read of ACPI UID from IVRS table
ubifs: remove broken lazytime support
fix multiplication overflow in copy_fdtable()
mtd: spinand: Propagate ECC information to the MTD structure
ima: Fix return value of ima_write_policy()
evm: Check also if *tfm is an error pointer in init_desc()
ima: Set file->f_mode instead of file->f_flags in ima_calc_file_hash()
riscv: set max_pfn to the PFN of the last page
KVM: SVM: Fix potential memory leak in svm_cpu_init()
i2c: dev: Fix the race between the release of i2c_dev and cdev
ubsan: build ubsan.c more conservatively
x86/uaccess, ubsan: Fix UBSAN vs. SMAP
ANDROID: scsi: ufs: Handle clocks when lrbp fails
ANDROID: fscrypt: handle direct I/O with IV_INO_LBLK_32
BACKPORT: FROMLIST: fscrypt: add support for IV_INO_LBLK_32 policies
ANDROID: Update the ABI xml and qcom whitelist
ANDROID: Fix build.config.gki-debug
Linux 4.19.124
Makefile: disallow data races on gcc-10 as well
KVM: x86: Fix off-by-one error in kvm_vcpu_ioctl_x86_setup_mce
ARM: dts: r8a7740: Add missing extal2 to CPG node
arm64: dts: renesas: r8a77980: Fix IPMMU VIP[01] nodes
ARM: dts: r8a73a4: Add missing CMT1 interrupts
arm64: dts: rockchip: Rename dwc3 device nodes on rk3399 to make dtc happy
arm64: dts: rockchip: Replace RK805 PMIC node name with "pmic" on rk3328 boards
clk: Unlink clock if failed to prepare or enable
Revert "ALSA: hda/realtek: Fix pop noise on ALC225"
usb: gadget: legacy: fix error return code in cdc_bind()
usb: gadget: legacy: fix error return code in gncm_bind()
usb: gadget: audio: Fix a missing error return value in audio_bind()
usb: gadget: net2272: Fix a memory leak in an error handling path in 'net2272_plat_probe()'
dwc3: Remove check for HWO flag in dwc3_gadget_ep_reclaim_trb_sg()
clk: rockchip: fix incorrect configuration of rk3228 aclk_gpu* clocks
exec: Move would_dump into flush_old_exec
x86/unwind/orc: Fix error handling in __unwind_start()
x86: Fix early boot crash on gcc-10, third try
cifs: fix leaked reference on requeued write
ARM: dts: imx27-phytec-phycard-s-rdk: Fix the I2C1 pinctrl entries
ARM: dts: dra7: Fix bus_dma_limit for PCIe
usb: xhci: Fix NULL pointer dereference when enqueuing trbs from urb sg list
USB: gadget: fix illegal array access in binding with UDC
usb: host: xhci-plat: keep runtime active when removing host
usb: core: hub: limit HUB_QUIRK_DISABLE_AUTOSUSPEND to USB5534B
ALSA: usb-audio: Add control message quirk delay for Kingston HyperX headset
ALSA: rawmidi: Fix racy buffer resize under concurrent accesses
ALSA: hda/realtek - Limit int mic boost for Thinkpad T530
gcc-10: avoid shadowing standard library 'free()' in crypto
gcc-10: disable 'restrict' warning for now
gcc-10: disable 'stringop-overflow' warning for now
gcc-10: disable 'array-bounds' warning for now
gcc-10: disable 'zero-length-bounds' warning for now
Stop the ad-hoc games with -Wno-maybe-initialized
kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
gcc-10 warnings: fix low-hanging fruit
pnp: Use list_for_each_entry() instead of open coding
hwmon: (da9052) Synchronize access with mfd
IB/mlx4: Test return value of calls to ib_get_cached_pkey
netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start()
arm64: fix the flush_icache_range arguments in machine_kexec
netfilter: conntrack: avoid gcc-10 zero-length-bounds warning
NFSv4: Fix fscache cookie aux_data to ensure change_attr is included
nfs: fscache: use timespec64 in inode auxdata
NFS: Fix fscache super_cookie index_key from changing after umount
mmc: block: Fix request completion in the CQE timeout path
mmc: core: Check request type before completing the request
i40iw: Fix error handling in i40iw_manage_arp_cache()
pinctrl: cherryview: Add missing spinlock usage in chv_gpio_irq_handler
pinctrl: baytrail: Enable pin configuration setting for GPIO chip
gfs2: Another gfs2_walk_metadata fix
ALSA: hda/realtek - Fix S3 pop noise on Dell Wyse
ipc/util.c: sysvipc_find_ipc() incorrectly updates position index
drm/qxl: lost qxl_bo_kunmap_atomic_page in qxl_image_init_helper()
ALSA: hda/hdmi: fix race in monitor detection during probe
cpufreq: intel_pstate: Only mention the BIOS disabling turbo mode once
dmaengine: mmp_tdma: Reset channel error on release
dmaengine: pch_dma.c: Avoid data race between probe and irq handler
riscv: fix vdso build with lld
tcp: fix SO_RCVLOWAT hangs with fat skbs
net: tcp: fix rx timestamp behavior for tcp_recvmsg
netprio_cgroup: Fix unlimited memory leak of v2 cgroups
net: ipv4: really enforce backoff for redirects
net: dsa: loop: Add module soft dependency
hinic: fix a bug of ndo_stop
virtio_net: fix lockdep warning on 32 bit
tcp: fix error recovery in tcp_zerocopy_receive()
Revert "ipv6: add mtu lock check in __ip6_rt_update_pmtu"
pppoe: only process PADT targeted at local interfaces
net: phy: fix aneg restart in phy_ethtool_set_eee
netlabel: cope with NULL catmap
net: fix a potential recursive NETDEV_FEAT_CHANGE
mmc: sdhci-acpi: Add SDHCI_QUIRK2_BROKEN_64_BIT_DMA for AMDI0040
scsi: sg: add sg_remove_request in sg_write
virtio-blk: handle block_device_operations callbacks after hot unplug
drop_monitor: work around gcc-10 stringop-overflow warning
net: moxa: Fix a potential double 'free_irq()'
net/sonic: Fix a resource leak in an error handling path in 'jazz_sonic_probe()'
shmem: fix possible deadlocks on shmlock_user_lock
net: dsa: Do not make user port errors fatal
ANDROID: rtc: class: call hctosys in resource managed registration
ANDROID: GKI: Update the ABI xml and whitelist
ANDROID: power_supply: Add RTX power-supply property
f2fs: flush dirty meta pages when flushing them
f2fs: fix checkpoint=disable:%u%%
f2fs: rework filename handling
f2fs: split f2fs_d_compare() from f2fs_match_name()
f2fs: don't leak filename in f2fs_try_convert_inline_dir()
ANDROID: clang: update to 11.0.1
FROMLIST: x86_64: fix jiffies ODR violation
ANDROID: arm64: vdso: Fix removing SCS flags
ANDROID: GKI: Update the ABI xml and whitelist
ANDROID: Incremental fs: wake up log pollers less often
ANDROID: Incremental fs: Fix scheduling while atomic error
ANDROID: Incremental fs: Avoid continually recalculating hashes
ANDROID: export: Disable symbol trimming on modules
ANDROID: GKI: Update the ABI xml and whitelist
ANDROID: fscrypt: set dun_bytes more precisely
ANDROID: dm-default-key: set dun_bytes more precisely
ANDROID: block: backport the ability to specify max_dun_bytes
ANDROID: Revert "ANDROID: GKI: gki_defconfig: CONFIG_DM_DEFAULT_KEY=m"
Linux 4.19.123
ipc/mqueue.c: change __do_notify() to bypass check_kill_permission()
scripts/decodecode: fix trapping instruction formatting
objtool: Fix stack offset tracking for indirect CFAs
netfilter: nf_osf: avoid passing pointer to local var
netfilter: nat: never update the UDP checksum when it's 0
x86/unwind/orc: Fix premature unwind stoppage due to IRET frames
x86/unwind/orc: Fix error path for bad ORC entry type
x86/unwind/orc: Prevent unwinding before ORC initialization
x86/unwind/orc: Don't skip the first frame for inactive tasks
x86/entry/64: Fix unwind hints in rewind_stack_do_exit()
x86/entry/64: Fix unwind hints in kernel exit path
x86/entry/64: Fix unwind hints in register clearing code
batman-adv: Fix refcnt leak in batadv_v_ogm_process
batman-adv: Fix refcnt leak in batadv_store_throughput_override
batman-adv: Fix refcnt leak in batadv_show_throughput_override
batman-adv: fix batadv_nc_random_weight_tq
KVM: VMX: Mark RCX, RDX and RSI as clobbered in vmx_vcpu_run()'s asm blob
KVM: VMX: Explicitly reference RCX as the vmx_vcpu pointer in asm blobs
coredump: fix crash when umh is disabled
staging: gasket: Check the return value of gasket_get_bar_index()
mm/page_alloc: fix watchdog soft lockups during set_zone_contiguous()
arm64: hugetlb: avoid potential NULL dereference
KVM: arm64: Fix 32bit PC wrap-around
KVM: arm: vgic: Fix limit condition when writing to GICD_I[CS]ACTIVER
tracing: Add a vmalloc_sync_mappings() for safe measure
USB: serial: garmin_gps: add sanity checking for data length
USB: uas: add quirk for LaCie 2Big Quadra
HID: usbhid: Fix race between usbhid_close() and usbhid_stop()
sctp: Fix bundling of SHUTDOWN with COOKIE-ACK
HID: wacom: Read HID_DG_CONTACTMAX directly for non-generic devices
net: stricter validation of untrusted gso packets
bnxt_en: Fix VF anti-spoof filter setup.
bnxt_en: Improve AER slot reset.
net/mlx5: Fix command entry leak in Internal Error State
net/mlx5: Fix forced completion access non initialized command entry
bnxt_en: Fix VLAN acceleration handling in bnxt_fix_features().
tipc: fix partial topology connection closure
sch_sfq: validate silly quantum values
sch_choke: avoid potential panic in choke_reset()
net: usb: qmi_wwan: add support for DW5816e
net_sched: sch_skbprio: add message validation to skbprio_change()
net/mlx4_core: Fix use of ENOSPC around mlx4_counter_alloc()
net: macsec: preserve ingress frame ordering
fq_codel: fix TCA_FQ_CODEL_DROP_BATCH_SIZE sanity checks
dp83640: reverse arguments to list_add_tail
vt: fix unicode console freeing with a common interface
tracing/kprobes: Fix a double initialization typo
USB: serial: qcserial: Add DW5816e support
ANDROID: usb: gadget: Add missing inline qualifier to stub functions
ANDROID: Drop ABI monitoring from KASAN build config
ANDROID: Rename build.config.gki.arch_kasan
ANDROID: GKI: Enable CONFIG_STATIC_USERMODEHELPER
ANDROID: dm-default-key: Update key size for wrapped keys
ANDROID: gki_defconfig: enable CONFIG_MMC_CRYPTO
ANDROID: mmc: MMC crypto API
ANDROID: GKI: Update the ABI xml and whitelist
ANDROID: GKI: add missing exports for cam_smmu_api.ko
Linux 4.19.122
drm/atomic: Take the atomic toys away from X
cgroup, netclassid: remove double cond_resched
mac80211: add ieee80211_is_any_nullfunc()
platform/x86: GPD pocket fan: Fix error message when temp-limits are out of range
ALSA: hda: Match both PCI ID and SSID for driver blacklist
hexagon: define ioremap_uc
hexagon: clean up ioremap
mfd: intel-lpss: Use devm_ioremap_uc for MMIO
lib: devres: add a helper function for ioremap_uc
drm/amdgpu: Fix oops when pp_funcs is unset in ACPI event
sctp: Fix SHUTDOWN CTSN Ack in the peer restart case
net: systemport: suppress warnings on failed Rx SKB allocations
net: bcmgenet: suppress warnings on failed Rx SKB allocations
lib/mpi: Fix building for powerpc with clang
scripts/config: allow colons in option strings for sed
s390/ftrace: fix potential crashes when switching tracers
cifs: protect updating server->dstaddr with a spinlock
ASoC: rsnd: Fix "status check failed" spam for multi-SSI
ASoC: rsnd: Don't treat master SSI in multi SSI setup as parent
net: stmmac: Fix sub-second increment
net: stmmac: fix enabling socfpga's ptp_ref_clock
wimax/i2400m: Fix potential urb refcnt leak
drm/amdgpu: Correctly initialize thermal controller for GPUs with Powerplay table v0 (e.g Hawaii)
ASoC: codecs: hdac_hdmi: Fix incorrect use of list_for_each_entry
ASoC: rsnd: Fix HDMI channel mapping for multi-SSI mode
ASoC: rsnd: Fix parent SSI start/stop in multi-SSI mode
usb: dwc3: gadget: Properly set maxpacket limit
ASoC: sgtl5000: Fix VAG power-on handling
selftests/ipc: Fix test failure seen after initial test run
ASoC: topology: Check return value of pcm_new_ver
powerpc/pci/of: Parse unassigned resources
vhost: vsock: kick send_pkt worker once device is started
ANDROID: GKI: fix build warning on 32bits due to ASoC msm change
ANDROID: GKI: fix build error on 32bits due to ASoC msm change
ANDROID: GKI: update abi definition due to FAIR_GROUP_SCHED removal
ANDROID: GKI: Remove FAIR_GROUP_SCHED
ANDROID: GKI: BULK update ABI XML representation and qcom whitelist
ANDROID: build.config.gki.aarch64: Enable WHITELIST_STRICT_MODE
ANDROID: GKI: Update the ABI xml and qcom whitelist
ANDROID: remove unused variable
ANDROID: Drop ABI monitoring from KASAN build config
Linux 4.19.121
mmc: meson-mx-sdio: remove the broken ->card_busy() op
mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY
mmc: sdhci-msm: Enable host capabilities pertains to R1b response
mmc: sdhci-pci: Fix eMMC driver strength for BYT-based controllers
mmc: sdhci-xenon: fix annoying 1.8V regulator warning
mmc: cqhci: Avoid false "cqhci: CQE stuck on" by not open-coding timeout loop
btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info
btrfs: fix partial loss of prealloc extent past i_size after fsync
selinux: properly handle multiple messages in selinux_netlink_send()
dmaengine: dmatest: Fix iteration non-stop logic
nfs: Fix potential posix_acl refcnt leak in nfs3_set_acl
ALSA: opti9xx: shut up gcc-10 range warning
iommu/amd: Fix legacy interrupt remapping for x2APIC-enabled system
scsi: target/iblock: fix WRITE SAME zeroing
iommu/qcom: Fix local_base status check
vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn()
vfio: avoid possible overflow in vfio_iommu_type1_pin_pages
RDMA/core: Fix race between destroy and release FD object
RDMA/core: Prevent mixed use of FDs between shared ufiles
RDMA/mlx4: Initialize ib_spec on the stack
RDMA/mlx5: Set GRH fields in query QP on RoCE
scsi: qla2xxx: check UNLOADING before posting async work
scsi: qla2xxx: set UNLOADING before waiting for session deletion
dm multipath: use updated MPATHF_QUEUE_IO on mapping for bio-based mpath
dm writecache: fix data corruption when reloading the target
dm verity fec: fix hash block number in verity_fec_decode
PM: hibernate: Freeze kernel threads in software_resume()
PM: ACPI: Output correct message on target power state
ALSA: pcm: oss: Place the plugin buffer overflow checks correctly
ALSA: hda/hdmi: fix without unlocked before return
ALSA: usb-audio: Correct a typo of NuPrime DAC-10 USB ID
ALSA: hda/realtek - Two front mics on a Lenovo ThinkCenter
btrfs: fix block group leak when removing fails
drm/qxl: qxl_release use after free
drm/qxl: qxl_release leak in qxl_hw_surface_alloc()
drm/qxl: qxl_release leak in qxl_draw_dirty_fb()
drm/edid: Fix off-by-one in DispID DTD pixel clock
ANDROID: GKI: Bulk update ABI XML representation
ANDROID: GKI: Enable net testing options
ANDROID: gki_defconfig: Enable CONFIG_REMOTEPROC
ANDROID: Rename build.config.gki.arch_kasan
ANDROID: GKI: Update ABI for IOMMU
ANDROID: Incremental fs: Fix issues with very large files
ANDROID: Correct build.config branch name
ANDROID: GKI: Bulk update ABI XML representation and whitelist.
UPSTREAM: vdso: Fix clocksource.h macro detection
ANDROID: GKI: update abi definition due to added padding
ANDROID: GKI: networking: add Android ABI padding to a lot of networking structures
ANDROID: GKI: dma-mapping.h: add Android ABI padding to a structure
ANDROID: GKI: ioport.h: add Android ABI padding to a structure
ANDROID: GKI: iomap.h: add Android ABI padding to a structure
ANDROID: GKI: genhd.h: add Android ABI padding to some structures
ANDROID: GKI: hrtimer.h: add Android ABI padding to a structure
ANDROID: GKI: ethtool.h: add Android ABI padding to a structure
ANDROID: GKI: sched: add Android ABI padding to some structures
ANDROID: GKI: kernfs.h: add Android ABI padding to some structures
ANDROID: GKI: kobject.h: add Android ABI padding to some structures
ANDROID: GKI: mm.h: add Android ABI padding to a structure
ANDROID: GKI: mmu_notifier.h: add Android ABI padding to some structures
ANDROID: GKI: pci: add Android ABI padding to some structures
ANDROID: GKI: irqdomain.h: add Android ABI padding to a structure
ANDROID: GKI: blk_types.h: add Android ABI padding to a structure
ANDROID: GKI: scsi.h: add Android ABI padding to a structure
ANDROID: GKI: quota.h: add Android ABI padding to some structures
ANDROID: GKI: timer.h: add Android ABI padding to a structure
ANDROID: GKI: user_namespace.h: add Android ABI padding to a structure
FROMGIT: f2fs: fix missing check for f2fs_unlock_op
Linux 4.19.120
propagate_one(): mnt_set_mountpoint() needs mount_lock
ext4: check for non-zero journal inum in ext4_calculate_overhead
qed: Fix use after free in qed_chain_free
bpf, x86_32: Fix clobbering of dst for BPF_JSET
hwmon: (jc42) Fix name to have no illegal characters
ext4: convert BUG_ON's to WARN_ON's in mballoc.c
ext4: increase wait time needed before reuse of deleted inode numbers
ext4: use matching invalidatepage in ext4_writepage
arm64: Delete the space separator in __emit_inst
ALSA: hda: call runtime_allow() for all hda controllers
xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status
objtool: Support Clang non-section symbols in ORC dump
objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings
scsi: target: tcmu: reset_ring should reset TCMU_DEV_BIT_BROKEN
scsi: target: fix PR IN / READ FULL STATUS for FC
ALSA: hda: Explicitly permit using autosuspend if runtime PM is supported
ALSA: hda: Keep the controller initialization even if no codecs found
xfs: fix partially uninitialized structure in xfs_reflink_remap_extent
x86: hyperv: report value of misc_features
net: fec: set GPR bit on suspend by DT configuration.
bpf, x86: Fix encoding for lower 8-bit registers in BPF_STX BPF_B
xfs: clear PF_MEMALLOC before exiting xfsaild thread
mm: shmem: disable interrupt when acquiring info->lock in userfaultfd_copy path
bpf, x86_32: Fix incorrect encoding in BPF_LDX zero-extension
perf/core: fix parent pid/tid in task exit events
net/mlx5: Fix failing fw tracer allocation on s390
cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled
ARM: dts: bcm283x: Disable dsi0 node
PCI: Move Apex Edge TPU class quirk to fix BAR assignment
PCI: Avoid ASMedia XHCI USB PME# from D0 defect
svcrdma: Fix leak of svc_rdma_recv_ctxt objects
svcrdma: Fix trace point use-after-free race
xfs: acquire superblock freeze protection on eofblocks scans
net/cxgb4: Check the return from t4_query_params properly
rxrpc: Fix DATA Tx to disable nofrag for UDP on AF_INET6 socket
i2c: altera: use proper variable to hold errno
nfsd: memory corruption in nfsd4_lock()
ASoC: wm8960: Fix wrong clock after suspend & resume
ASoC: tas571x: disable regulators on failed probe
ASoC: q6dsp6: q6afe-dai: add missing channels to MI2S DAIs
iio:ad7797: Use correct attribute_group
usb: gadget: udc: bdc: Remove unnecessary NULL checks in bdc_req_complete
usb: dwc3: gadget: Do link recovery for SS and SSP
binder: take read mode of mmap_sem in binder_alloc_free_page()
include/uapi/linux/swab.h: fix userspace breakage, use __BITS_PER_LONG for swap
mtd: cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer
remoteproc: Fix wrong rvring index computation
FROMLIST: PM / devfreq: Restart previous governor if new governor fails to start
ANDROID: GKI: arm64: Enable GZIP and LZ4 kernel compression modes
ANDROID: GKI: arm64: gki_defconfig: Set arm_smmu configuration
ANDROID: GKI: iommu/arm-smmu: Modularize ARM SMMU driver
ANDROID: GKI: iommu: Snapshot of vendor changes
ANDROID: GKI: Additions to ARM SMMU register definitions
ANDROID: GKI: iommu/io-pgtable-arm: LPAE related updates by vendor
ANDROID: GKI: common: dma-mapping: make dma_common_contiguous_remap more robust
ANDROID: GKI: dma-coherent: Expose device base address and size
ANDROID: GKI: arm64: add support for NO_KERNEL_MAPPING and STRONGLY_ORDERED
ANDROID: GKI: dma-mapping: Add dma_remap functions
ANDROID: GKI: arm64: Support early fixup for CMA
ANDROID: GKI: iommu: dma-mapping-fast: Fast ARMv7/v8 Long Descriptor Format
ANDROID: GKI: arm64: dma-mapping: add support for IOMMU mapper
ANDROID: GKI: add ARCH_NR_GPIO for ABI match
ANDROID: GKI: kernel: Export symbol of `cpu_do_idle`
ANDROID: GKI: kernel: Export symbols needed by msm_minidump.ko and minidump_log.ko (again)
ANDROID: GKI: add missing exports for __flush_dcache_area
ANDROID: GKI: arm64: Export caching APIs
ANDROID: GKI: arm64: provide dma cache routines with same API as 32 bit
ANDROID: gki_defconfig: add FORTIFY_SOURCE, remove SPMI_MSM_PMIC_ARB
Revert "ANDROID: GKI: spmi: pmic-arb: don't enable SPMI_MSM_PMIC_ARB by default"
ANDROID: GKI: update abi definitions after adding padding
ANDROID: GKI: elevator: add Android ABI padding to some structures
ANDROID: GKI: dentry: add Android ABI padding to some structures
ANDROID: GKI: bio: add Android ABI padding to some structures
ANDROID: GKI: scsi: add Android ABI padding to some structures
ANDROID: GKI: ufs: add Android ABI padding to some structures
ANDROID: GKI: workqueue.h: add Android ABI padding to some structures
ANDROID: GKI: fs.h: add Android ABI padding to some structures
ANDROID: GKI: USB: add Android ABI padding to some structures
ANDROID: GKI: mm: add Android ABI padding to some structures
ANDROID: GKI: mount.h: add Android ABI padding to some structures
ANDROID: GKI: sched.h: add Android ABI padding to some structures
ANDROID: GKI: sock.h: add Android ABI padding to some structures
ANDROID: GKI: module.h: add Android ABI padding to some structures
ANDROID: GKI: device.h: add Android ABI padding to some structures
ANDROID: GKI: phy: add Android ABI padding to some structures
ANDROID: GKI: add android_kabi.h
ANDROID: ABI: update due to previous changes in the tree
BACKPORT: sched/core: Fix reset-on-fork from RT with uclamp
ANDROID: GKI: Add support for missing V4L2 symbols
ANDROID: GKI: Bulk update ABI XML representation
ANDROID: GKI: arm64: psci: Support for OS initiated scheme
ANDROID: GKI: net: add counter for number of frames coalesced in GRO
ANDROID: GKI: cfg80211: Include length of kek in rekey data
BACKPORT: loop: change queue block size to match when using DIO
ANDROID: Incremental fs: Add setattr call
ANDROID: GKI: enable CONFIG_RTC_SYSTOHC
ANDROID: GKI: ipv4: add vendor padding to __IPV4_DEVCONF_* enums
Revert "ANDROID: GKI: ipv4: increase __IPV4_DEVCONF_MAX to 64"
ANDROID: driver: gpu: drm: fix export symbol types
ANDROID: SoC: core: fix export symbol type
ANDROID: ufshcd-crypto: fix export symbol type
ANDROID: GKI: drivers: mailbox: fix race resulting in multiple message submission
ANDROID: GKI: arm64: gki_defconfig: Enable a few thermal configs
Revert "ANDROID: GKI: add base.h include to match MODULE_VERSIONS"
FROMLIST: thermal: Make cooling device trip point writable from sysfs
ANDROID: GKI: drivers: thermal: cpu_cooling: Use CPU ID as cooling device ID
ANDROID: GKI: PM / devfreq: Allow min freq to be 0
ANDROID: GKI: arm64: gki_defconfig: Enable REGULATOR_PROXY_CONSUMER
ANDROID: GKI: Bulk Update ABI XML representation
ANDROID: KASAN support for GKI remove CONFIG_CC_WERROR
ANDROID: KASAN support for GKI
ANDROID: virt_wifi: fix export symbol types
ANDROID: vfs: fix export symbol type
ANDROID: vfs: fix export symbol types
ANDROID: fscrypt: fix export symbol type
ANDROID: cfi: fix export symbol types
ANDROID: bpf: fix export symbol type
Linux 4.19.119
s390/mm: fix page table upgrade vs 2ndary address mode accesses
xfs: Fix deadlock between AGI and AGF with RENAME_WHITEOUT
serial: sh-sci: Make sure status register SCxSR is read in correct sequence
xhci: prevent bus suspend if a roothub port detected a over-current condition
usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
usb: dwc3: gadget: Fix request completion check
UAS: fix deadlock in error handling and PM flushing work
UAS: no use logging any details in case of ENODEV
cdc-acm: introduce a cool down
cdc-acm: close race betrween suspend() and acm_softint
staging: vt6656: Power save stop wake_up_count wrap around.
staging: vt6656: Fix pairwise key entry save.
staging: vt6656: Fix drivers TBTT timing counter.
staging: vt6656: Fix calling conditions of vnt_set_bss_mode
staging: vt6656: Don't set RCR_MULTICAST or RCR_BROADCAST by default.
vt: don't use kmalloc() for the unicode screen buffer
vt: don't hardcode the mem allocation upper bound
staging: comedi: Fix comedi_device refcnt leak in comedi_open
staging: comedi: dt2815: fix writing hi byte of analog output
powerpc/setup_64: Set cache-line-size based on cache-block-size
ARM: imx: provide v7_cpu_resume() only on ARM_CPU_SUSPEND=y
iwlwifi: mvm: beacon statistics shouldn't go backwards
iwlwifi: pcie: actually release queue memory in TVQM
ASoC: dapm: fixup dapm kcontrol widget
audit: check the length of userspace generated audit records
usb-storage: Add unusual_devs entry for JMicron JMS566
tty: rocket, avoid OOB access
tty: hvc: fix buffer overflow during hvc_alloc().
KVM: VMX: Enable machine check support for 32bit targets
KVM: Check validity of resolved slot when searching memslots
KVM: s390: Return last valid slot if approx index is out-of-bounds
tpm: ibmvtpm: retry on H_CLOSED in tpm_ibmvtpm_send()
tpm/tpm_tis: Free IRQ if probing fails
ALSA: usb-audio: Filter out unsupported sample rates on Focusrite devices
ALSA: usb-audio: Fix usb audio refcnt leak when getting spdif
ALSA: hda/realtek - Add new codec supported for ALC245
ALSA: hda/realtek - Fix unexpected init_amp override
ALSA: usx2y: Fix potential NULL dereference
tools/vm: fix cross-compile build
mm/ksm: fix NULL pointer dereference when KSM zero page is enabled
mm/hugetlb: fix a addressing exception caused by huge_pte_offset
vmalloc: fix remap_vmalloc_range() bounds checks
USB: hub: Fix handling of connect changes during sleep
USB: core: Fix free-while-in-use bug in the USB S-Glibrary
USB: early: Handle AMD's spec-compliant identifiers, too
USB: Add USB_QUIRK_DELAY_CTRL_MSG and USB_QUIRK_DELAY_INIT for Corsair K70 RGB RAPIDFIRE
USB: sisusbvga: Change port variable from signed to unsigned
fs/namespace.c: fix mountpoint reference counter race
iio: xilinx-xadc: Make sure not exceed maximum samplerate
iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode
iio: xilinx-xadc: Fix clearing interrupt when enabling trigger
iio: xilinx-xadc: Fix ADC-B powerdown
iio: adc: stm32-adc: fix sleep in atomic context
iio: st_sensors: rely on odr mask to know if odr can be set
iio: core: remove extra semi-colon from devm_iio_device_register() macro
ALSA: usb-audio: Add connector notifier delegation
ALSA: usb-audio: Add static mapping table for ALC1220-VB-based mobos
ALSA: hda: Remove ASUS ROG Zenith from the blacklist
KEYS: Avoid false positive ENOMEM error on key read
mlxsw: Fix some IS_ERR() vs NULL bugs
vrf: Check skb for XFRM_TRANSFORMED flag
xfrm: Always set XFRM_TRANSFORMED in xfrm{4,6}_output_finish
net: dsa: b53: b53_arl_rw_op() needs to select IVL or SVL
net: dsa: b53: Rework ARL bin logic
net: dsa: b53: Fix ARL register definitions
net: dsa: b53: Lookup VID in ARL searches when VLAN is enabled
vrf: Fix IPv6 with qdisc and xfrm
team: fix hang in team_mode_get()
tcp: cache line align MAX_TCP_HEADER
sched: etf: do not assume all sockets are full blown
net/x25: Fix x25_neigh refcnt leak when receiving frame
net: stmmac: dwmac-meson8b: Add missing boundary to RGMII TX clock array
net: netrom: Fix potential nr_neigh refcnt leak in nr_add_node
net: bcmgenet: correct per TX/RX ring statistics
macvlan: fix null dereference in macvlan_device_event()
macsec: avoid to set wrong mtu
ipv6: fix restrict IPV6_ADDRFORM operation
cxgb4: fix large delays in PTP synchronization
cxgb4: fix adapter crash due to wrong MC size
x86/KVM: Clean up host's steal time structure
x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
x86/kvm: Cache gfn to pfn translation
x86/kvm: Introduce kvm_(un)map_gfn()
KVM: Properly check if "page" is valid in kvm_vcpu_unmap
kvm: fix compile on s390 part 2
kvm: fix compilation on s390
kvm: fix compilation on aarch64
KVM: Introduce a new guest mapping API
KVM: nVMX: Always sync GUEST_BNDCFGS when it comes from vmcs01
KVM: VMX: Zero out *all* general purpose registers after VM-Exit
f2fs: fix to avoid memory leakage in f2fs_listxattr
blktrace: fix dereference after null check
blktrace: Protect q->blk_trace with RCU
net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup
net: ipv6: add net argument to ip6_dst_lookup_flow
PCI/ASPM: Allow re-enabling Clock PM
scsi: smartpqi: fix call trace in device discovery
virtio-blk: improve virtqueue error to BLK_STS
tracing/selftests: Turn off timeout setting
drm/amd/display: Not doing optimize bandwidth if flip pending.
xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3
ASoC: Intel: bytcr_rt5640: Add quirk for MPMAN MPWIN895CL tablet
perf/core: Disable page faults when getting phys address
pwm: bcm2835: Dynamically allocate base
pwm: renesas-tpu: Fix late Runtime PM enablement
Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled"
loop: Better discard support for block devices
s390/cio: avoid duplicated 'ADD' uevents
kconfig: qconf: Fix a few alignment issues
ipc/util.c: sysvipc_find_ipc() should increase position index
selftests: kmod: fix handling test numbers above 9
kernel/gcov/fs.c: gcov_seq_next() should increase position index
nvme: fix deadlock caused by ANA update wrong locking
ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()
scsi: iscsi: Report unbind session event when the target has been removed
pwm: rcar: Fix late Runtime PM enablement
ceph: don't skip updating wanted caps when cap is stale
ceph: return ceph_mdsc_do_request() errors from __get_parent()
scsi: lpfc: Fix crash in target side cable pulls hitting WAIT_FOR_UNREG
scsi: lpfc: Fix kasan slab-out-of-bounds error in lpfc_unreg_login
watchdog: reset last_hw_keepalive time at start
arm64: Silence clang warning on mismatched value/register sizes
arm64: compat: Workaround Neoverse-N1 #1542419 for compat user-space
arm64: Fake the IminLine size on systems affected by Neoverse-N1 #1542419
arm64: errata: Hide CTR_EL0.DIC on systems affected by Neoverse-N1 #1542419
arm64: Add part number for Neoverse N1
vti4: removed duplicate log message.
crypto: mxs-dcp - make symbols 'sha1_null_hash' and 'sha256_null_hash' static
bpftool: Fix printing incorrect pointer in btf_dump_ptr
drm/msm: Use the correct dma_sync calls harder
ext4: fix extent_status fragmentation for plain files
ANDROID: abi_gki_aarch64_cuttlefish_whitelist: remove stale symbols
ANDROID: GKI: ipv4: increase __IPV4_DEVCONF_MAX to 64
ANDROID: GKI: power: add missing export for POWER_RESET_QCOM=m
BACKPORT: cfg80211: Support key configuration for Beacon protection (BIGTK)
BACKPORT: cfg80211: Enhance the AKM advertizement to support per interface.
UPSTREAM: sysrq: Use panic() to force a crash
ANDROID: GKI: kernel: sound: update codec options with block size
ANDROID: add compat cross compiler
ANDROID: x86/vdso: disable LTO only for VDSO
BACKPORT: arm64: vdso32: Enable Clang Compilation
UPSTREAM: arm64: compat: vdso: Expose BUILD_VDSO32
BACKPORT: lib/vdso: Enable common headers
BACKPORT: arm: vdso: Enable arm to use common headers
BACKPORT: x86/vdso: Enable x86 to use common headers
BACKPORT: mips: vdso: Enable mips to use common headers
UPSTREAM: arm64: vdso32: Include common headers in the vdso library
UPSTREAM: arm64: vdso: Include common headers in the vdso library
UPSTREAM: arm64: Introduce asm/vdso/processor.h
BACKPORT: arm64: vdso32: Code clean up
UPSTREAM: linux/elfnote.h: Replace elf.h with UAPI equivalent
UPSTREAM: scripts: Fix the inclusion order in modpost
UPSTREAM: common: Introduce processor.h
UPSTREAM: linux/ktime.h: Extract common header for vDSO
UPSTREAM: linux/jiffies.h: Extract common header for vDSO
UPSTREAM: linux/time64.h: Extract common header for vDSO
BACKPORT: linux/time32.h: Extract common header for vDSO
BACKPORT: linux/time.h: Extract common header for vDSO
UPSTREAM: linux/math64.h: Extract common header for vDSO
BACKPORT: linux/clocksource.h: Extract common header for vDSO
BACKPORT: mips: Introduce asm/vdso/clocksource.h
BACKPORT: arm64: Introduce asm/vdso/clocksource.h
BACKPORT: arm: Introduce asm/vdso/clocksource.h
BACKPORT: x86: Introduce asm/vdso/clocksource.h
UPSTREAM: linux/limits.h: Extract common header for vDSO
BACKPORT: linux/kernel.h: split *_MAX and *_MIN macros into <linux/limits.h>
BACKPORT: linux/bits.h: Extract common header for vDSO
UPSTREAM: linux/const.h: Extract common header for vDSO
BACKPORT: arm64: vdso: fix flip/flop vdso build bug
UPSTREAM: lib/vdso: Allow the high resolution parts to be compiled out
UPSTREAM: lib/vdso: Only read hrtimer_res when needed in __cvdso_clock_getres()
UPSTREAM: lib/vdso: Mark do_hres() and do_coarse() as __always_inline
UPSTREAM: lib/vdso: Avoid duplication in __cvdso_clock_getres()
UPSTREAM: lib/vdso: Let do_coarse() return 0 to simplify the callsite
UPSTREAM: lib/vdso: Remove checks on return value for 32 bit vDSO
UPSTREAM: lib/vdso: Build 32 bit specific functions in the right context
UPSTREAM: lib/vdso: Make __cvdso_clock_getres() static
UPSTREAM: lib/vdso: Make clock_getres() POSIX compliant again
UPSTREAM: lib/vdso/32: Provide legacy syscall fallbacks
UPSTREAM: lib/vdso: Move fallback invocation to the callers
UPSTREAM: lib/vdso/32: Remove inconsistent NULL pointer checks
UPSTREAM: lib/vdso: Make delta calculation work correctly
UPSTREAM: arm64: compat: Fix syscall number of compat_clock_getres
BACKPORT: arm64: lse: Fix LSE atomics with LLVM
UPSTREAM: mips: Fix gettimeofday() in the vdso library
UPSTREAM: mips: vdso: Fix __arch_get_hw_counter()
BACKPORT: arm64: Kconfig: Make CONFIG_COMPAT_VDSO a proper Kconfig option
UPSTREAM: arm64: vdso32: Rename COMPATCC to CC_COMPAT
UPSTREAM: arm64: vdso32: Pass '--target' option to clang via VDSO_CAFLAGS
UPSTREAM: arm64: vdso32: Don't use KBUILD_CPPFLAGS unconditionally
UPSTREAM: arm64: vdso32: Move definition of COMPATCC into vdso32/Makefile
UPSTREAM: arm64: Default to building compat vDSO with clang when CONFIG_CC_IS_CLANG
UPSTREAM: lib: vdso: Remove CROSS_COMPILE_COMPAT_VDSO
UPSTREAM: arm64: vdso32: Remove jump label config option in Makefile
UPSTREAM: arm64: vdso32: Detect binutils support for dmb ishld
BACKPORT: arm64: vdso: Remove stale files from old assembly implementation
UPSTREAM: arm64: vdso32: Fix broken compat vDSO build warnings
UPSTREAM: mips: compat: vdso: Use legacy syscalls as fallback
BACKPORT: arm64: Relax Documentation/arm64/tagged-pointers.rst
BACKPORT: arm64: Add tagged-address-abi.rst to index.rst
UPSTREAM: arm64: vdso: Fix Makefile regression
UPSTREAM: mips: vdso: Fix flip/flop vdso building bug
UPSTREAM: mips: vdso: Fix source path
UPSTREAM: mips: Add clock_gettime64 entry point
UPSTREAM: mips: Add clock_getres entry point
BACKPORT: mips: Add support for generic vDSO
BACKPORT: arm64: vdso: Explicitly add build-id option
BACKPORT: arm64: vdso: use $(LD) instead of $(CC) to link VDSO
BACKPORT: arm64: vdso: Cleanup Makefiles
UPSTREAM: arm64: vdso: Fix population of AT_SYSINFO_EHDR for compat vdso
UPSTREAM: arm64: vdso: Fix compilation with clang older than 8
UPSTREAM: arm64: compat: Fix __arch_get_hw_counter() implementation
UPSTREAM: arm64: Fix __arch_get_hw_counter() implementation
UPSTREAM: x86/vdso/32: Use 32bit syscall fallback
UPSTREAM: x86/vdso: Fix flip/flop vdso build bug
UPSTREAM: x86/vdso: Give the [ph]vclock_page declarations real types
UPSTREAM: x86/vdso: Add clock_gettime64() entry point
BACKPORT: x86/vdso: Add clock_getres() entry point
BACKPORT: x86/vdso: Switch to generic vDSO implementation
UPSTREAM: x86/segments: Introduce the 'CPUNODE' naming to better document the segment limit CPU/node NR trick
UPSTREAM: x86/vdso: Initialize the CPU/node NR segment descriptor earlier
UPSTREAM: x86/vdso: Introduce helper functions for CPU and node number
UPSTREAM: x86/segments/64: Rename the GDT PER_CPU entry to CPU_NUMBER
BACKPORT: arm64: vdso: Enable vDSO compat support
UPSTREAM: arm64: compat: Get sigreturn trampolines from vDSO
UPSTREAM: arm64: elf: VDSO code page discovery
UPSTREAM: arm64: compat: VDSO setup for compat layer
UPSTREAM: arm64: vdso: Refactor vDSO code
BACKPORT: arm64: compat: Add vDSO
UPSTREAM: arm64: compat: Generate asm offsets for signals
UPSTREAM: arm64: compat: Expose signal related structures
UPSTREAM: arm64: compat: Add missing syscall numbers
BACKPORT: arm64: vdso: Substitute gettimeofday() with C implementation
UPSTREAM: timekeeping: Provide a generic update_vsyscall() implementation
UPSTREAM: lib/vdso: Add compat support
UPSTREAM: lib/vdso: Provide generic VDSO implementation
UPSTREAM: vdso: Define standardized vdso_datapage
UPSTREAM: hrtimer: Split out hrtimer defines into separate header
UPSTREAM: nds32: Fix vDSO clock_getres()
UPSTREAM: arm64: compat: Reduce address limit for 64K pages
BACKPORT: arm64: compat: Add KUSER_HELPERS config option
UPSTREAM: arm64: compat: Refactor aarch32_alloc_vdso_pages()
BACKPORT: arm64: compat: Split kuser32
UPSTREAM: arm64: compat: Alloc separate pages for vectors and sigpage
ANDROID: GKI: Update ABI XML representation
ANDROID: GKI: Enable GENERIC_IRQ_CHIP
ANDROID: GKI: power_supply: Add FG_TYPE power-supply property
ANDROID: GKI: mm: export mm_trace_rss_stat for modules to report RSS changes
ANDROID: GKI: gki_defconfig: Enable CONFIG_LEDS_TRIGGER_TRANSIENT
ANDROID: GKI: gki_defconfig: Enable CONFIG_CPU_FREQ_STAT
ANDROID: GKI: arm64: gki_defconfig: Disable HW tracing features
ANDROID: GKI: gki_defconfig: Enable CONFIG_I2C_CHARDEV
ANDROID: Incremental fs: Use simple compression in log buffer
ANDROID: GKI: usb: core: Add support to parse config summary capability descriptors
ANDROID: GKI: Update ABI XML representation
ANDROID: dm-bow: Fix not to skip trim at framented range
ANDROID: Remove VLA from uid_sys_stats.c
f2fs: fix missing check for f2fs_unlock_op
ANDROID: fix wakeup reason findings
UPSTREAM: cfg80211: fix and clean up cfg80211_gen_new_bssid()
UPSTREAM: cfg80211: save multi-bssid properties
UPSTREAM: cfg80211: make BSSID generation function inline
UPSTREAM: cfg80211: parse multi-bssid only if HW supports it
UPSTREAM: cfg80211: Move Multiple BSS info to struct cfg80211_bss to be visible
UPSTREAM: cfg80211: Properly track transmitting and non-transmitting BSS
UPSTREAM: cfg80211: use for_each_element() for multi-bssid parsing
UPSTREAM: cfg80211: Parsing of Multiple BSSID information in scanning
UPSTREAM: cfg80211/nl80211: Offload OWE processing to user space in AP mode
ANDROID: GKI: cfg80211: Sync nl80211 commands/feature with upstream
ANDROID: GKI: gki_defconfig: Enable FW_LOADER_USER_HELPER*
ANDROID: GKI: arm64: gki_defconfig: Disable CONFIG_ARM64_TAGGED_ADDR_ABI
ANDROID: GKI: gki_defconfig: CONFIG_CHR_DEV_SG=y
ANDROID: GKI: gki_defconfig: CONFIG_DM_DEFAULT_KEY=m
ANDROID: update the ABI xml representation
ANDROID: init: GKI: enable hidden configs for GPU
Linux 4.19.118
bpf: fix buggy r0 retval refinement for tracing helpers
KEYS: Don't write out to userspace while holding key semaphore
mtd: phram: fix a double free issue in error path
mtd: lpddr: Fix a double free in probe()
mtd: spinand: Explicitly use MTD_OPS_RAW to write the bad block marker to OOB
locktorture: Print ratio of acquisitions, not failures
tty: evh_bytechan: Fix out of bounds accesses
iio: si1133: read 24-bit signed integer for measurement
fbdev: potential information leak in do_fb_ioctl()
net: dsa: bcm_sf2: Fix overflow checks
f2fs: fix to wait all node page writeback
iommu/amd: Fix the configuration of GCR3 table root pointer
libnvdimm: Out of bounds read in __nd_ioctl()
power: supply: axp288_fuel_gauge: Broaden vendor check for Intel Compute Sticks.
ext2: fix debug reference to ext2_xattr_cache
ext2: fix empty body warnings when -Wextra is used
iommu/vt-d: Fix mm reference leak
drm/vc4: Fix HDMI mode validation
f2fs: fix NULL pointer dereference in f2fs_write_begin()
NFS: Fix memory leaks in nfs_pageio_stop_mirroring()
drm/amdkfd: kfree the wrong pointer
x86: ACPI: fix CPU hotplug deadlock
KVM: s390: vsie: Fix possible race when shadowing region 3 tables
compiler.h: fix error in BUILD_BUG_ON() reporting
percpu_counter: fix a data race at vm_committed_as
include/linux/swapops.h: correct guards for non_swap_entry()
cifs: Allocate encryption header through kmalloc
um: ubd: Prevent buffer overrun on command completion
ext4: do not commit super on read-only bdev
s390/cpum_sf: Fix wrong page count in error message
powerpc/maple: Fix declaration made after definition
s390/cpuinfo: fix wrong output when CPU0 is offline
NFS: direct.c: Fix memory leak of dreq when nfs_get_lock_context fails
NFSv4/pnfs: Return valid stateids in nfs_layout_find_inode_by_stateid()
rtc: 88pm860x: fix possible race condition
soc: imx: gpc: fix power up sequencing
clk: tegra: Fix Tegra PMC clock out parents
power: supply: bq27xxx_battery: Silence deferred-probe error
clk: at91: usb: continue if clk_hw_round_rate() return zero
x86/Hyper-V: Report crash data in die() when panic_on_oops is set
x86/Hyper-V: Report crash register data when sysctl_record_panic_msg is not set
x86/Hyper-V: Trigger crash enlightenment only once during system crash.
x86/Hyper-V: Free hv_panic_page when fail to register kmsg dump
x86/Hyper-V: Unload vmbus channel in hv panic callback
xsk: Add missing check on user supplied headroom size
rbd: call rbd_dev_unprobe() after unwatching and flushing notifies
rbd: avoid a deadlock on header_rwsem when flushing notifies
video: fbdev: sis: Remove unnecessary parentheses and commented code
lib/raid6: use vdupq_n_u8 to avoid endianness warnings
x86/Hyper-V: Report crash register data or kmsg before running crash kernel
of: overlay: kmemleak in dup_and_fixup_symbol_prop()
of: unittest: kmemleak in of_unittest_overlay_high_level()
of: unittest: kmemleak in of_unittest_platform_populate()
of: unittest: kmemleak on changeset destroy
ALSA: hda: Don't release card at firmware loading error
irqchip/mbigen: Free msi_desc on device teardown
netfilter: nf_tables: report EOPNOTSUPP on unsupported flags/object type
ARM: dts: imx6: Use gpc for FEC interrupt controller to fix wake on LAN.
arm, bpf: Fix bugs with ALU64 {RSH, ARSH} BPF_K shift by 0
watchdog: sp805: fix restart handler
ext4: use non-movable memory for superblock readahead
scsi: sg: add sg_remove_request in sg_common_write
objtool: Fix switch table detection in .text.unlikely
arm, bpf: Fix offset overflow for BPF_MEM BPF_DW
ANDROID: GKI: Bulk update ABI report.
ANDROID: GKI: qos: Register irq notify after adding the qos request
ANDROID: GKI: Add dual role mode to usb_dr_modes array
UPSTREAM: virtio-gpu api: comment feature flags
ANDROID: arch:arm64: Increase kernel command line size
ANDROID: GKI: Add special linux_banner_ptr for modules
Revert "ANDROID: GKI: Make linux_banner a C pointer"
ANDROID: GKI: PM / devfreq: Add new flag to do simple clock scaling
ANDROID: GKI: Resolve ABI diff for struct snd_usb_audio
ANDROID: GKI: Bulk update ABI
ANDROID: GKI: Update the whitelist for qcom SoCs
ANDROID: GKI: arm64: gki_defconfig: Set CONFIG_SCSI_UFSHCD=m
ANDROID: GKI: scsi: add option to override the command timeout
ANDROID: GKI: scsi: Adjust DBD setting in mode sense for caching mode page per LLD
ANDROID: add ion_stat tracepoint to common kernel
UPSTREAM: gpu/trace: add a gpu total memory usage tracepoint
Linux 4.19.117
mm/vmalloc.c: move 'area->pages' after if statement
wil6210: remove reset file from debugfs
wil6210: make sure Rx ring sizes are correlated
wil6210: add general initialization/size checks
wil6210: ignore HALP ICR if already handled
wil6210: check rx_buff_mgmt before accessing it
x86/resctrl: Fix invalid attempt at removing the default resource group
x86/resctrl: Preserve CDP enable over CPU hotplug
x86/microcode/AMD: Increase microcode PATCH_MAX_SIZE
scsi: target: fix hang when multiple threads try to destroy the same iscsi session
scsi: target: remove boilerplate code
kvm: x86: Host feature SSBD doesn't imply guest feature SPEC_CTRL_SSBD
ext4: do not zeroout extents beyond i_disksize
drm/amd/powerplay: force the trim of the mclk dpm_levels if OD is enabled
usb: dwc3: gadget: Don't clear flags before transfer ended
usb: dwc3: gadget: don't enable interrupt when disabling endpoint
mac80211_hwsim: Use kstrndup() in place of kasprintf()
btrfs: check commit root generation in should_ignore_root
tracing: Fix the race between registering 'snapshot' event trigger and triggering 'snapshot' operation
keys: Fix proc_keys_next to increase position index
ALSA: usb-audio: Check mapping at creating connector controls, too
ALSA: usb-audio: Don't create jack controls for PCM terminals
ALSA: usb-audio: Don't override ignore_ctl_error value from the map
ALSA: usb-audio: Filter error from connector kctl ops, too
ASoC: Intel: mrfld: return error codes when an error occurs
ASoC: Intel: mrfld: fix incorrect check on p->sink
ext4: fix incorrect inodes per group in error message
ext4: fix incorrect group count in ext4_fill_super error message
pwm: pca9685: Fix PWM/GPIO inter-operation
jbd2: improve comments about freeing data buffers whose page mapping is NULL
scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic
ovl: fix value of i_ino for lower hardlink corner case
net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode
net: stmmac: dwmac-sunxi: Provide TX and RX fifo sizes
net: revert default NAPI poll timeout to 2 jiffies
net: qrtr: send msgs from local of same id as broadcast
net: ipv6: do not consider routes via gateways for anycast address check
net: ipv4: devinet: Fix crash when add/del multicast IP with autojoin
hsr: check protocol version in hsr_newlink()
amd-xgbe: Use __napi_schedule() in BH context
ANDROID: GKI: drivers: of-thermal: Relate thermal zones using same sensor
ANDROID: GKI: Bulk ABI update
ANDROID: GKI: dma: Add set_dma_mask hook to struct dma_map_ops
ANDROID: GKI: ABI update due to recent patches
FROMLIST: drm/prime: add support for virtio exported objects
FROMLIST: dma-buf: add support for virtio exported objects
UPSTREAM: drm/virtio: module_param_named() requires linux/moduleparam.h
UPSTREAM: drm/virtio: fix resource id creation race
UPSTREAM: drm/virtio: make resource id workaround runtime switchable.
BACKPORT: drm/virtio: Drop deprecated load/unload initialization
ANDROID: GKI: Add DRM_TTM config to GKI
ANDROID: Bulk update the ABI xml representation
ANDROID: GKI: spmi: pmic-arb: don't enable SPMI_MSM_PMIC_ARB by default
ANDROID: GKI: attribute page lock and waitqueue functions as sched
ANDROID: GKI: extcon: Fix Add usage of blocking notifier chain
ANDROID: GKI: USB: pd: Extcon fix for C current
ANDROID: drm/dsi: Fix byte order of DCS set/get brightness
ANDROID: GKI: mm: Export symbols to modularize CONFIG_MSM_DRM
ANDROID: GKI: ALSA: compress: Add support to send codec specific data
ANDROID: GKI: ALSA: Compress - dont use lock for all ioctls
ANDROID: GKI: ASoC: msm: qdsp6v2: add support for AMR_WB_PLUS offload
ANDROID: GKI: msm: dolby: MAT and THD audiocodec name modification
ANDROID: GKI: asoc: msm: Add support for compressed perf mode
ANDROID: GKI: msm: audio: support for gapless_pcm
ANDROID: GKI: uapi: msm: dolby: Support for TrueHD and MAT decoders
ANDROID: GKI: ASoC: msm: qdsp6v2: Add TrueHD HDMI compress pass-though
ANDROID: GKI: ALSA: compress: Add APTX format support in ALSA
ANDROID: GKI: msm: qdsp6v2: Add timestamp support for compress capture
ANDROID: GKI: SoC: msm: Add support for meta data in compressed TX
ANDROID: GKI: ALSA: compress: Add DSD format support for ALSA
ANDROID: GKI: ASoC: msm: qdsp6v2: add support for ALAC and APE offload
ANDROID: GKI: SoC: msm: Add compressed TX and passthrough support
ANDROID: GKI: ASoC: msm: qdsp6v2: Add FLAC in compress offload path
ANDROID: GKI: ASoC: msm: add support for different compressed formats
ANDROID: GKI: ASoC: msm: Update the encode option and sample rate
ANDROID: GKI: Enable CONFIG_SND_VERBOSE_PROCFS in gki_defconfig
ANDROID: GKI: Add hidden CONFIG_SND_SOC_COMPRESS to gki_defconfig
ANDROID: GKI: ALSA: pcm: add locks for accessing runtime resource
ANDROID: GKI: Update ABI for DRM changes
ANDROID: GKI: Add drm_dp_send_dpcd_{read,write} accessor functions
ANDROID: GKI: drm: Add drm_dp_mst_get_max_sdp_streams_supported accessor function
ANDROID: GKI: drm: Add drm_dp_mst_has_fec accessor function
ANDROID: GKI: Add 'dsc_info' to struct drm_dp_mst_port
ANDROID: GKI: usb: Add support to handle USB SMMU S1 address
ANDROID: GKI: usb: Add helper APIs to return xhci phys addresses
ANDROID: Add C protos for dma_buf/drm_prime get_uuid
ANDROID: GKI: Make linux_banner a C pointer
ANDROID: GKI: Add 'refresh_rate', 'id' to struct drm_panel_notifier
ANDROID: GKI: Add 'i2c_mutex' to struct drm_dp_aux
ANDROID: GKI: Add 'checksum' to struct drm_connector
Revert "BACKPORT: drm: Add HDR source metadata property"
Revert "BACKPORT: drm: Parse HDR metadata info from EDID"
ANDROID: drm: Add DP colorspace property
ANDROID: GKI: drm: Initialize display->hdmi when parsing vsdb
ANDROID: drivers: gpu: drm: add support to batch commands
ANDROID: ABI: update the qcom whitelist
ANDROID: GKI: ARM64: smp: add vendor field pending_ipi
ANDROID: gki_defconfig: enable msm serial early console
ANDROID: serial: msm_geni_serial_console : Add Earlycon support
ANDROID: GKI: serial: core: export uart_console_device
f2fs: fix quota_sync failure due to f2fs_lock_op
f2fs: support read iostat
f2fs: Fix the accounting of dcc->undiscard_blks
f2fs: fix to handle error path of f2fs_ra_meta_pages()
f2fs: report the discard cmd errors properly
f2fs: fix long latency due to discard during umount
f2fs: add tracepoint for f2fs iostat
f2fs: introduce sysfs/data_io_flag to attach REQ_META/FUA
ANDROID: GKI: update abi definition due to previous changes in the tree
Linux 4.19.116
efi/x86: Fix the deletion of variables in mixed mode
mfd: dln2: Fix sanity checking for endpoints
etnaviv: perfmon: fix total and idle HI cyleces readout
misc: echo: Remove unnecessary parentheses and simplify check for zero
powerpc/fsl_booke: Avoid creating duplicate tlb1 entry
ftrace/kprobe: Show the maxactive number on kprobe_events
drm: Remove PageReserved manipulation from drm_pci_alloc
drm/dp_mst: Fix clearing payload state on topology disable
Revert "drm/dp_mst: Remove VCPI while disabling topology mgr"
crypto: ccree - only try to map auth tag if needed
crypto: ccree - dec auth tag size from cryptlen map
crypto: ccree - don't mangle the request assoclen
crypto: ccree - zero out internal struct before use
crypto: ccree - improve error handling
crypto: caam - update xts sector size for large input length
dm zoned: remove duplicate nr_rnd_zones increase in dmz_init_zone()
btrfs: use nofs allocations for running delayed items
powerpc: Make setjmp/longjmp signature standard
powerpc: Add attributes for setjmp/longjmp
scsi: mpt3sas: Fix kernel panic observed on soft HBA unplug
powerpc/kprobes: Ignore traps that happened in real mode
powerpc/xive: Use XIVE_BAD_IRQ instead of zero to catch non configured IPIs
powerpc/hash64/devmap: Use H_PAGE_THP_HUGE when setting up huge devmap PTE entries
powerpc/64/tm: Don't let userspace set regs->trap via sigreturn
powerpc/powernv/idle: Restore AMR/UAMOR/AMOR after idle
xen/blkfront: fix memory allocation flags in blkfront_setup_indirect()
ipmi: fix hung processes in __get_guid()
libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set
hfsplus: fix crash and filesystem corruption when deleting files
cpufreq: powernv: Fix use-after-free
kmod: make request_module() return an error when autoloading is disabled
clk: ingenic/jz4770: Exit with error if CGU init failed
Input: i8042 - add Acer Aspire 5738z to nomux list
s390/diag: fix display of diagnose call statistics
perf tools: Support Python 3.8+ in Makefile
ocfs2: no need try to truncate file beyond i_size
fs/filesystems.c: downgrade user-reachable WARN_ONCE() to pr_warn_once()
ext4: fix a data race at inode->i_blocks
NFS: Fix a page leak in nfs_destroy_unlinked_subrequests()
powerpc/pseries: Avoid NULL pointer dereference when drmem is unavailable
drm/etnaviv: rework perfmon query infrastructure
rtc: omap: Use define directive for PIN_CONFIG_ACTIVE_HIGH
selftests: vm: drop dependencies on page flags from mlock2 tests
arm64: armv8_deprecated: Fix undef_hook mask for thumb setend
scsi: zfcp: fix missing erp_lock in port recovery trigger for point-to-point
dm verity fec: fix memory leak in verity_fec_dtr
dm writecache: add cond_resched to avoid CPU hangs
arm64: dts: allwinner: h6: Fix PMU compatible
net: qualcomm: rmnet: Allow configuration updates to existing devices
mm: Use fixed constant in page_frag_alloc instead of size + 1
tools: gpio: Fix out-of-tree build regression
x86/speculation: Remove redundant arch_smt_update() invocation
powerpc/pseries: Drop pointless static qualifier in vpa_debugfs_init()
erofs: correct the remaining shrink objects
crypto: mxs-dcp - fix scatterlist linearization for hash
btrfs: fix missing semaphore unlock in btrfs_sync_file
btrfs: fix missing file extent item for hole after ranged fsync
btrfs: drop block from cache on error in relocation
btrfs: set update the uuid generation as soon as possible
Btrfs: fix crash during unmount due to race with delayed inode workers
mtd: spinand: Do not erase the block before writing a bad block marker
mtd: spinand: Stop using spinand->oobbuf for buffering bad block markers
CIFS: Fix bug which the return value by asynchronous read is error
KVM: VMX: fix crash cleanup when KVM wasn't used
KVM: x86: Gracefully handle __vmalloc() failure during VM allocation
KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support
KVM: x86: Allocate new rmap and large page tracking when moving memslot
KVM: s390: vsie: Fix delivery of addressing exceptions
KVM: s390: vsie: Fix region 1 ASCE sanity shadow address checks
KVM: nVMX: Properly handle userspace interrupt window request
x86/entry/32: Add missing ASM_CLAC to general_protection entry
signal: Extend exec_id to 64bits
ath9k: Handle txpower changes even when TPC is disabled
MIPS: OCTEON: irq: Fix potential NULL pointer dereference
MIPS/tlbex: Fix LDDIR usage in setup_pw() for Loongson-3
pstore: pstore_ftrace_seq_next should increase position index
irqchip/versatile-fpga: Apply clear-mask earlier
KEYS: reaching the keys quotas correctly
tpm: tpm2_bios_measurements_next should increase position index
tpm: tpm1_bios_measurements_next should increase position index
tpm: Don't make log failures fatal
PCI: endpoint: Fix for concurrent memory allocation in OB address region
PCI: Add boot interrupt quirk mechanism for Xeon chipsets
PCI/ASPM: Clear the correct bits when enabling L1 substates
PCI: pciehp: Fix indefinite wait on sysfs requests
nvme: Treat discovery subsystems as unique subsystems
nvme-fc: Revert "add module to ops template to allow module references"
thermal: devfreq_cooling: inline all stubs for CONFIG_DEVFREQ_THERMAL=n
acpi/x86: ignore unspecified bit positions in the ACPI global lock field
media: ti-vpe: cal: fix disable_irqs to only the intended target
ALSA: hda/realtek - Add quirk for MSI GL63
ALSA: hda/realtek - Remove now-unnecessary XPS 13 headphone noise fixups
ALSA: hda/realtek - Set principled PC Beep configuration for ALC256
ALSA: doc: Document PC Beep Hidden Register on Realtek ALC256
ALSA: pcm: oss: Fix regression by buffer overflow fix
ALSA: ice1724: Fix invalid access for enumerated ctl items
ALSA: hda: Fix potential access overflow in beep helper
ALSA: hda: Add driver blacklist
ALSA: usb-audio: Add mixer workaround for TRX40 and co
usb: gadget: composite: Inform controller driver of self-powered
usb: gadget: f_fs: Fix use after free issue as part of queue failure
ASoC: topology: use name_prefix for new kcontrol
ASoC: dpcm: allow start or stop during pause for backend
ASoC: dapm: connect virtual mux with default value
ASoC: fix regwmask
slub: improve bit diffusion for freelist ptr obfuscation
uapi: rename ext2_swab() to swab() and share globally in swab.h
IB/mlx5: Replace tunnel mpls capability bits for tunnel_offloads
btrfs: track reloc roots based on their commit root bytenr
btrfs: remove a BUG_ON() from merge_reloc_roots()
btrfs: qgroup: ensure qgroup_rescan_running is only set when the worker is at least queued
block, bfq: fix use-after-free in bfq_idle_slice_timer_body
locking/lockdep: Avoid recursion in lockdep_count_{for,back}ward_deps()
firmware: fix a double abort case with fw_load_sysfs_fallback
md: check arrays is suspended in mddev_detach before call quiesce operations
irqchip/gic-v4: Provide irq_retrigger to avoid circular locking dependency
usb: dwc3: core: add support for disabling SS instances in park mode
media: i2c: ov5695: Fix power on and off sequences
block: Fix use-after-free issue accessing struct io_cq
genirq/irqdomain: Check pointer in irq_domain_alloc_irqs_hierarchy()
efi/x86: Ignore the memory attributes table on i386
x86/boot: Use unsigned comparison for addresses
gfs2: Don't demote a glock until its revokes are written
pstore/platform: fix potential mem leak if pstore_init_fs failed
libata: Remove extra scsi_host_put() in ata_scsi_add_hosts()
media: i2c: video-i2c: fix build errors due to 'imply hwmon'
PCI/switchtec: Fix init_completion race condition with poll_wait()
selftests/x86/ptrace_syscall_32: Fix no-vDSO segfault
sched: Avoid scale real weight down to zero
irqchip/versatile-fpga: Handle chained IRQs properly
block: keep bdi->io_pages in sync with max_sectors_kb for stacked devices
x86: Don't let pgprot_modify() change the page encryption bit
xhci: bail out early if driver can't accress host in resume
null_blk: fix spurious IO errors after failed past-wp access
null_blk: Handle null_add_dev() failures properly
null_blk: Fix the null_add_dev() error path
firmware: arm_sdei: fix double-lock on hibernate with shared events
media: venus: hfi_parser: Ignore HEVC encoding for V1
cpufreq: imx6q: Fixes unwanted cpu overclocking on i.MX6ULL
i2c: st: fix missing struct parameter description
qlcnic: Fix bad kzalloc null test
cxgb4/ptp: pass the sign of offset delta in FW CMD
hinic: fix wrong para of wait_for_completion_timeout
hinic: fix a bug of waitting for IO stopped
net: vxge: fix wrong __VA_ARGS__ usage
bus: sunxi-rsb: Return correct data when mixing 16-bit and 8-bit reads
ARM: dts: sun8i-a83t-tbs-a711: HM5065 doesn't like such a high voltage
ANDROID: build.config.allmodconfig: Re-enable XFS_FS
FROMGIT: of: property: Add device link support for extcon
ANDROID: GKI: arm64: gki_defconfig: enable CONFIG_MM_EVENT_STAT
ANDROID: GKI: add fields from per-process mm event tracking feature
ANDROID: GKI: fix ABI diffs caused by ION heap and pool vmstat additions
UPSTREAM: GKI: panic/reboot: allow specifying reboot_mode for panic only
ANDROID: GKI: of: property: Add device link support for phys property
ANDROID: GKI: usb: phy: Fix ABI diff for usb_otg_state
ANDROID: GKI: usb: phy: Fix ABI diff due to usb_phy.drive_dp_pulse
ANDROID: GKI: usb: phy: Fix ABI diff for usb_phy_type and usb_phy.reset
ANDROID: gki_defconfig: enable CONFIG_GPIO_SYSFS
ANDROID: GKI: qcom: Fix compile issue when setting msm_lmh_dcvs as a module
ANDROID: GKI: drivers: cpu_cooling: allow platform freq mitigation
ANDROID: GKI: ASoC: Add locking in DAPM widget power update
ANDROID: GKI: ASoC: jack: Fix buttons enum value
ANDROID: GKI: ALSA: jack: Add support to report second microphone
ANDROID: GKI: ALSA: jack: Update supported jack switch types
ANDROID: GKI: ALSA: jack: update jack types
ANDROID: GKI: Export symbols arm_cpuidle_suspend, cpuidle_dev and cpuidle_register_governor
ANDROID: GKI: usb: hcd: Add USB atomic notifier callback for HC died error
ANDROID: media: increase video max frame number
BACKPORT: nvmem: core: add NVMEM_SYSFS Kconfig
UPSTREAM: nvmem: add support for cell info
UPSTREAM: nvmem: remove the global cell list
UPSTREAM: nvmem: use kref
UPSTREAM: nvmem: use list_for_each_entry_safe in nvmem_device_remove_all_cells()
UPSTREAM: nvmem: provide nvmem_dev_name()
ANDROID: GKI: Bulk ABI update
ANDROID: GKI: cpuhotplug: adding hotplug enums for vendor code
ANDROID: Incremental fs: Fix create_file performance
ANDROID: build.config.common: Add BUILDTOOLS_PREBUILT_BIN
UPSTREAM: kheaders: include only headers into kheaders_data.tar.xz
UPSTREAM: kheaders: remove meaningless -R option of 'ls'
ANDROID: GKI: of: platform: initialize of_reserved_mem
ANDROID: driver: gpu: drm: add notifier for panel related events
ANDROID: include: drm: support unicasting mipi cmds to dsi ctrls
ANDROID: include: drm: increase DRM max property count to 64
BACKPORT: drm: Add HDMI colorspace property
ANDROID: drm: edid: add support for additional CEA extension blocks
BACKPORT: drm: Parse HDR metadata info from EDID
BACKPORT: drm: Add HDR source metadata property
BACKPORT: drm/dp_mst: Parse FEC capability on MST ports
ANDROID: GKI: ABI update for DRM changes
ANDROID: ABI: add missing elf variables to representation
ANDROID: GKI: power_supply: Add PROP_MOISTURE_DETECTION_ENABLED
ANDROID: include: drm: add the definitions for DP Link Compliance tests
ANDROID: drivers: gpu: drm: fix bugs encountered while fuzzing
FROMLIST: power_supply: Add additional health properties to the header
UPSTREAM: power: supply: core: Update sysfs-class-power ABI document
UPSTREAM: Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-4.19.y' into android-4.19 (v5.7-rc1)
ANDROID: drivers: gpu: drm: add support for secure framebuffer
ANDROID: include: uapi: drm: add additional QCOM modifiers
ANDROID: drm: dsi: add two DSI mode flags for BLLP
ANDROID: include: uapi: drm: add additional drm mode flags
UPSTREAM: drm: plug memory leak on drm_setup() failure
UPSTREAM: drm: factor out drm_close_helper() function
ANDROID: GKI: Bulk ABI update
BACKPORT: nl80211: Add per peer statistics to compute FCS error rate
ANDROID: GKI: sound: usb: Add snd_usb_enable_audio_stream/find_snd_usb_substream
ANDROID: GKI: add dma-buf includes
ANDROID: GKI: sched: struct fields for Per-Sched-domain over utilization
ANDROID: GKI: Add vendor fields to root_domain
ANDROID: gki_defconfig: Enable CONFIG_IRQ_TIME_ACCOUNTING
ANDROID: fix allmodconfig build to use the right toolchain
ANDROID: fix allmodconfig build to use the right toolchain
ANDROID: GKI: Update ABI
Revert "UPSTREAM: mm, page_alloc: spread allocations across zones before introducing fragmentation"
Revert "UPSTREAM: mm: use alloc_flags to record if kswapd can wake"
Revert "BACKPORT: mm: move zone watermark accesses behind an accessor"
Revert "BACKPORT: mm: reclaim small amounts of memory when an external fragmentation event occurs"
Revert "BACKPORT: mm, compaction: be selective about what pageblocks to clear skip hints"
ANDROID: GKI: panic: add vendor callback function in panic()
UPSTREAM: GKI: thermal: make device_register's type argument const
ANDROID: GKI: add base.h include to match MODULE_VERSIONS
ANDROID: update the ABI based on the new whitelist
ANDROID: GKI: fdt: export symbols required by modules
ANDROID: GKI: drivers: of: Add APIs to find DDR device rank, HBB
ANDROID: GKI: security: Add mmap export symbols for modules
ANDROID: GKI: arch: add stub symbols for boot_reason and cold_boot
ANDROID: GKI: USB: Fix ABI diff for struct usb_bus
ANDROID: GKI: USB: Resolve ABI diff for usb_gadget and usb_gadget_ops
ANDROID: GKI: add hidden V4L2_MEM2MEM_DEV
ANDROID: GKI: enable VIDEO_V4L2_SUBDEV_API
ANDROID: GKI: export symbols from abi_gki_aarch64_qcom_whitelist
ANDROID: Update the whitelist for qcom SoCs
ANDROID: Incremental fs: Fix compound page usercopy crash
ANDROID: Incremental fs: Clean up incfs_test build process
ANDROID: Incremental fs: make remount log buffer change atomic
ANDROID: Incremental fs: Optimize get_filled_block
ANDROID: Incremental fs: Fix mislabeled __user ptrs
ANDROID: Incremental fs: Use 64-bit int for file_size when writing hash blocks
Linux 4.19.115
drm/msm: Use the correct dma_sync calls in msm_gem
drm_dp_mst_topology: fix broken drm_dp_sideband_parse_remote_dpcd_read()
usb: dwc3: don't set gadget->is_otg flag
rpmsg: glink: Remove chunk size word align warning
arm64: Fix size of __early_cpu_boot_status
drm/msm: stop abusing dma_map/unmap for cache
clk: qcom: rcg: Return failure for RCG update
fbcon: fix null-ptr-deref in fbcon_switch
RDMA/cm: Update num_paths in cma_resolve_iboe_route error flow
Bluetooth: RFCOMM: fix ODEBUG bug in rfcomm_dev_ioctl
RDMA/cma: Teach lockdep about the order of rtnl and lock
RDMA/ucma: Put a lock around every call to the rdma_cm layer
ceph: canonicalize server path in place
ceph: remove the extra slashes in the server path
IB/hfi1: Fix memory leaks in sysfs registration and unregistration
IB/hfi1: Call kobject_put() when kobject_init_and_add() fails
ASoC: jz4740-i2s: Fix divider written at incorrect offset in register
hwrng: imx-rngc - fix an error path
tools/accounting/getdelays.c: fix netlink attribute length
usb: dwc3: gadget: Wrap around when skip TRBs
random: always use batched entropy for get_random_u{32,64}
mlxsw: spectrum_flower: Do not stop at FLOW_ACTION_VLAN_MANGLE
slcan: Don't transmit uninitialized stack data in padding
net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting
net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers
net: dsa: bcm_sf2: Ensure correct sub-node is parsed
net: dsa: bcm_sf2: Do not register slave MDIO bus with OF
ipv6: don't auto-add link-local address to lag ports
mm: mempolicy: require at least one nodeid for MPOL_PREFERRED
include/linux/notifier.h: SRCU: fix ctags
bitops: protect variables in set_mask_bits() macro
padata: always acquire cpu_hotplug_lock before pinst->lock
net: Fix Tx hash bound checking
rxrpc: Fix sendmsg(MSG_WAITALL) handling
ALSA: hda/ca0132 - Add Recon3Di quirk to handle integrated sound on EVGA X99 Classified motherboard
power: supply: axp288_charger: Add special handling for HP Pavilion x2 10
extcon: axp288: Add wakeup support
mei: me: add cedar fork device ids
coresight: do not use the BIT() macro in the UAPI header
misc: pci_endpoint_test: Avoid using module parameter to determine irqtype
misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices
misc: rtsx: set correct pcr_ops for rts522A
media: rc: IR signal for Panasonic air conditioner too long
drm/etnaviv: replace MMU flush marker with flush sequence
tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks
tools/power turbostat: Fix gcc build warnings
drm/amdgpu: fix typo for vcn1 idle check
initramfs: restore default compression behavior
drm/bochs: downgrade pci_request_region failure from error to warning
drm/amd/display: Add link_rate quirk for Apple 15" MBP 2017
nvme-rdma: Avoid double freeing of async event data
sctp: fix possibly using a bad saddr with a given dst
sctp: fix refcount bug in sctp_wfree
net, ip_tunnel: fix interface lookup with no key
ipv4: fix a RCU-list lock in fib_triestat_seq_show
ANDROID: GKI: export symbols required by SPECTRA_CAMERA
ANDROID: GKI: ARM/ARM64: Introduce arch_read_hardware_id
ANDROID: GKI: drivers: base: soc: export symbols for socinfo
ANDROID: GKI: Update ABI
ANDROID: GKI: ASoC: msm: fix integer overflow for long duration offload playback
ANDROID: GKI: Bulk ABI update
Revert "ANDROID: GKI: mm: add struct/enum fields for SPECULATIVE_PAGE_FAULTS"
ANDROID: GKI: Revert "arm64: kill flush_cache_all()"
ANDROID: GKI: Revert "arm64: Remove unused macros from assembler.h"
ANDROID: GKI: kernel/dma, mm/cma: Export symbols needed by vendor modules
ANDROID: GKI: mm: Export symbols __next_zones_zonelist and zone_watermark_ok_safe
ANDROID: GKI: mm/memblock: export memblock_overlaps_memory
ANDROID: GKI: net, skbuff: export symbols needed by vendor drivers
ANDROID: GKI: Add stub __cpu_isolated_mask symbol
ANDROID: GKI: sched: stub sched_isolate symbols
ANDROID: GKI: export saved_command_line
ANDROID: GKI: Update ABI
ANDROID: GKI: ASoC: core: Update ALSA core to issue restart in underrun.
ANDROID: GKI: SoC: pcm: Add a restart callback field to struct snd_pcm_ops
ANDROID: GKI: SoC: pcm: Add fields to struct snd_pcm_ops and struct snd_soc_component_driver
ANDROID: GKI: ASoC: core: Add compat_ioctl callback to struct snd_pcm_ops
ANDROID: GKI: ALSA: core: modify, rename and export create_subdir API
ANDROID: GKI: usb: Add helper API to issue stop endpoint command
ANDROID: GKI: Thermal: thermal_zone_get_cdev_by_name added
ANDROID: GKI: add missing exports for CONFIG_ARM_SMMU=m
ANDROID: power: wakeup_reason: wake reason enhancements
BACKPORT: FROMGIT: kbuild: mkcompile_h: Include $LD version in /proc/version
ANDROID: GKI: kernel: Export symbols needed by msm_minidump.ko and minidump_log.ko
ubifs: wire up FS_IOC_GET_ENCRYPTION_NONCE
f2fs: wire up FS_IOC_GET_ENCRYPTION_NONCE
ext4: wire up FS_IOC_GET_ENCRYPTION_NONCE
fscrypt: add FS_IOC_GET_ENCRYPTION_NONCE ioctl
ANDROID: Bulk update the ABI xml
ANDROID: gki_defconfig: add CONFIG_IPV6_SUBTREES
ANDROID: GKI: arm64: reserve space in cpu_hwcaps and cpu_hwcap_keys arrays
ANDROID: GKI: of: reserved_mem: Fix kmemleak crash on no-map region
ANDROID: GKI: sched: add task boost vendor fields to task_struct
ANDROID: GKI: mm: add rss counter for unreclaimable pages
ANDROID: GKI: irqdomain: add bus token DOMAIN_BUS_WAKEUP
ANDROID: GKI: arm64: fault: do_tlb_conf_fault_cb register fault callback
ANDROID: GKI: QoS: Enhance framework to support cpu/irq specific QoS requests
ANDROID: GKI: Bulk ABI update
ANDROID: GKI: PM/devfreq: Do not switch governors from sysfs when device is suspended
ANDROID: GKI: PM / devfreq: Fix race condition between suspend/resume and governor_store
ANDROID: GKI: PM / devfreq: Introduce a sysfs lock
ANDROID: GKI: regmap: irq: Add support to clear ack registers
ANDROID: GKI: Remove SCHED_AUTOGROUP
ANDROID: ignore compiler tag __must_check for GENKSYMS
ANDROID: GKI: Bulk update ABI
ANDROID: GKI: Fix ABI diff for struct thermal_cooling_device_ops
ANDROID: GKI: ASoC: soc-core: export function to find components
ANDROID: GKI: thermal: thermal_sys: Add configurable thermal trip points.
ANDROID: fscrypt: fall back to filesystem-layer crypto when needed
ANDROID: block: require drivers to declare supported crypto key type(s)
ANDROID: block: make blk_crypto_start_using_mode() properly check for support
ANDROID: GKI: power: supply: format regression
ANDROID: GKI: kobject: increase number of kobject uevent pointers to 64
ANDROID: GKI: drivers: video: backlight: Fix ABI diff for struct backlight_device
ANDROID: GKI: usb: xhci: Add support for secondary interrupters
ANDROID: GKI: usb: host: xhci: Add support for usb core indexing
ANDROID: gki_defconfig: enable USB_XHCI_HCD
ANDROID: gki_defconfig: enable CONFIG_BRIDGE
ANDROID: GKI: Update ABI report
ANDROID: GKI: arm64: smp: Add set_update_ipi_history_callback
ANDROID: kbuild: ensure __cfi_check is correctly aligned
f2fs: keep inline_data when compression conversion
f2fs: fix to disable compression on directory
f2fs: add missing CONFIG_F2FS_FS_COMPRESSION
f2fs: switch discard_policy.timeout to bool type
f2fs: fix to verify tpage before releasing in f2fs_free_dic()
f2fs: show compression in statx
f2fs: clean up dic->tpages assignment
f2fs: compress: support zstd compress algorithm
f2fs: compress: add .{init,destroy}_decompress_ctx callback
f2fs: compress: fix to call missing destroy_compress_ctx()
f2fs: change default compression algorithm
f2fs: clean up {cic,dic}.ref handling
f2fs: fix to use f2fs_readpage_limit() in f2fs_read_multi_pages()
f2fs: xattr.h: Make stub helpers inline
f2fs: fix to avoid double unlock
f2fs: fix potential .flags overflow on 32bit architecture
f2fs: fix NULL pointer dereference in f2fs_verity_work()
f2fs: fix to clear PG_error if fsverity failed
f2fs: don't call fscrypt_get_encryption_info() explicitly in f2fs_tmpfile()
f2fs: don't trigger data flush in foreground operation
f2fs: fix NULL pointer dereference in f2fs_write_begin()
f2fs: clean up f2fs_may_encrypt()
f2fs: fix to avoid potential deadlock
f2fs: don't change inode status under page lock
f2fs: fix potential deadlock on compressed quota file
f2fs: delete DIO read lock
f2fs: don't mark compressed inode dirty during f2fs_iget()
f2fs: fix to account compressed blocks in f2fs_compressed_blocks()
f2fs: xattr.h: Replace zero-length array with flexible-array member
f2fs: fix to update f2fs_super_block fields under sb_lock
f2fs: Add a new CP flag to help fsck fix resize SPO issues
f2fs: Fix mount failure due to SPO after a successful online resize FS
f2fs: use kmem_cache pool during inline xattr lookups
f2fs: skip migration only when BG_GC is called
f2fs: fix to show tracepoint correctly
f2fs: avoid __GFP_NOFAIL in f2fs_bio_alloc
f2fs: introduce F2FS_IOC_GET_COMPRESS_BLOCKS
f2fs: fix to avoid triggering IO in write path
f2fs: add prefix for f2fs slab cache name
f2fs: introduce DEFAULT_IO_TIMEOUT
f2fs: skip GC when section is full
f2fs: add migration count iff migration happens
f2fs: clean up bggc mount option
f2fs: clean up lfs/adaptive mount option
f2fs: fix to show norecovery mount option
f2fs: clean up parameter of macro XATTR_SIZE()
f2fs: clean up codes with {f2fs_,}data_blkaddr()
f2fs: show mounted time
f2fs: Use scnprintf() for avoiding potential buffer overflow
f2fs: allow to clear F2FS_COMPR_FL flag
f2fs: fix to check dirty pages during compressed inode conversion
f2fs: fix to account compressed inode correctly
f2fs: fix wrong check on F2FS_IOC_FSSETXATTR
f2fs: fix to avoid use-after-free in f2fs_write_multi_pages()
f2fs: fix to avoid using uninitialized variable
f2fs: fix inconsistent comments
f2fs: remove i_sem lock coverage in f2fs_setxattr()
f2fs: cover last_disk_size update with spinlock
f2fs: fix to check i_compr_blocks correctly
FROMLIST: kmod: make request_module() return an error when autoloading is disabled
ANDROID: GKI: Update ABI report
ANDROID: GKI: ARM64: dma-mapping: export symbol arch_setup_dma_ops
ANDROID: GKI: ARM: dma-mapping: export symbol arch_setup_dma_ops
ANDROID: GKI: ASoC: dapm: Avoid static route b/w cpu and codec dai
ANDROID: GKI: ASoC: pcm: Add support for hostless playback/capture
ANDROID: GKI: ASoC: core - add hostless DAI support
ANDROID: GKI: drivers: thermal: Resolve ABI diff for struct thermal_zone_device_ops
ANDROID: GKI: drivers: thermal: Add support for getting trip temperature
ANDROID: GKI: Add functions of_thermal_handle_trip/of_thermal_handle_trip_temp
ANDROID: GKI: drivers: thermal: Add post suspend evaluate flag to thermal zone devicetree
UPSTREAM: loop: Only freeze block queue when needed.
UPSTREAM: loop: Only change blocksize when needed.
ANDROID: Fix wq fp check for CFI builds
ANDROID: GKI: update abi definition after CONFIG_DEBUG_LIST was enabled
ANDROID: gki_defconfig: enable CONFIG_DEBUG_LIST
ANDROID: GKI: Update ABI definition
ANDROID: GKI: remove condition causing sk_buff struct ABI differences
ANDROID: GKI: Export symbol arch_timer_mem_get_cval
ANDROID: GKI: pwm: core: Add option to config PWM duty/period with u64 data length
ANDROID: Update ABI whitelist for qcom SoCs
ANDROID: Incremental fs: Fix remount
ANDROID: Incremental fs: Protect get_fill_block, and add a field
ANDROID: Incremental fs: Fix crash polling 0 size read_log
ANDROID: Incremental fs: get_filled_blocks: better index_out
ANDROID: GKI: of: property: Add device links support for "qcom,wrapper-dev"
ANDROID: GKI: update abi definitions due to recent changes
ANDROID: GKI: clk: Initialize in stack clk_init_data to 0 in all drivers
ANDROID: GKI: drivers: clksource: Add API to return cval
ANDROID: GKI: clk: Add support for voltage voting
ANDROID: GKI: kernel: Export task and IRQ affinity symbols
ANDROID: GKI: regulator: core: Add support for regulator providers with sync state
ANDROID: GKI: regulator: Call proxy-consumer functions for each regulator registered
ANDROID: GKI: regulator: Add proxy consumer driver
ANDROID: GKI: regulator: core: allow long device tree supply regulator property names
ANDROID: GKI: Revert "regulator: Enable supply regulator if child rail is enabled."
ANDROID: GKI: regulator: Remove redundant set_mode call in drms_uA_update
ANDROID: GKI: net: Add the get current NAPI context API
ANDROID: GKI: remove DRM_KMS_CMA_HELPER from GKI configuration
ANDROID: GKI: edac: Fix ABI diffs in edac_device_ctl_info struct
ANDROID: GKI: pwm: Add different PWM output types support
UPSTREAM: cfg80211: Authentication offload to user space in AP mode
Linux 4.19.114
arm64: dts: ls1046ardb: set RGMII interfaces to RGMII_ID mode
arm64: dts: ls1043a-rdb: correct RGMII delay mode to rgmii-id
ARM: dts: N900: fix onenand timings
ARM: dts: imx6: phycore-som: fix arm and soc minimum voltage
ARM: bcm2835-rpi-zero-w: Add missing pinctrl name
ARM: dts: oxnas: Fix clear-mask property
perf map: Fix off by one in strncpy() size argument
arm64: alternative: fix build with clang integrated assembler
net: ks8851-ml: Fix IO operations, again
gpiolib: acpi: Add quirk to ignore EC wakeups on HP x2 10 CHT + AXP288 model
bpf: Explicitly memset some bpf info structures declared on the stack
bpf: Explicitly memset the bpf_attr structure
platform/x86: pmc_atom: Add Lex 2I385SW to critclk_systems DMI table
vt: vt_ioctl: fix use-after-free in vt_in_use()
vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console
vt: vt_ioctl: remove unnecessary console allocation checks
vt: switch vt_dont_switch to bool
vt: ioctl, switch VT_IS_IN_USE and VT_BUSY to inlines
vt: selection, introduce vc_is_sel
mac80211: fix authentication with iwlwifi/mvm
mac80211: Check port authorization in the ieee80211_tx_dequeue() case
media: xirlink_cit: add missing descriptor sanity checks
media: stv06xx: add missing descriptor sanity checks
media: dib0700: fix rc endpoint lookup
media: ov519: add missing endpoint sanity checks
libfs: fix infoleak in simple_attr_read()
ahci: Add Intel Comet Lake H RAID PCI ID
staging: wlan-ng: fix use-after-free Read in hfa384x_usbin_callback
staging: wlan-ng: fix ODEBUG bug in prism2sta_disconnect_usb
staging: rtl8188eu: Add ASUS USB-N10 Nano B1 to device table
media: usbtv: fix control-message timeouts
media: flexcop-usb: fix endpoint sanity check
usb: musb: fix crash with highmen PIO and usbmon
USB: serial: io_edgeport: fix slab-out-of-bounds read in edge_interrupt_callback
USB: cdc-acm: restore capability check order
USB: serial: option: add Wistron Neweb D19Q1
USB: serial: option: add BroadMobi BM806U
USB: serial: option: add support for ASKEY WWHC050
mac80211: set IEEE80211_TX_CTRL_PORT_CTRL_PROTO for nl80211 TX
mac80211: add option for setting control flags
Revert "r8169: check that Realtek PHY driver module is loaded"
vti6: Fix memory leak of skb if input policy check fails
bpf/btf: Fix BTF verification of enum members in struct/union
netfilter: nft_fwd_netdev: validate family and chain type
netfilter: flowtable: reload ip{v6}h in nf_flow_tuple_ip{v6}
afs: Fix some tracing details
xfrm: policy: Fix doulbe free in xfrm_policy_timer
xfrm: add the missing verify_sec_ctx_len check in xfrm_add_acquire
xfrm: fix uctx len check in verify_sec_ctx_len
RDMA/mlx5: Block delay drop to unprivileged users
vti[6]: fix packet tx through bpf_redirect() in XinY cases
xfrm: handle NETDEV_UNREGISTER for xfrm device
genirq: Fix reference leaks on irq affinity notifiers
RDMA/core: Ensure security pkey modify is not lost
gpiolib: acpi: Add quirk to ignore EC wakeups on HP x2 10 BYT + AXP288 model
gpiolib: acpi: Rework honor_wakeup option into an ignore_wake option
gpiolib: acpi: Correct comment for HP x2 10 honor_wakeup quirk
mac80211: mark station unauthorized before key removal
nl80211: fix NL80211_ATTR_CHANNEL_WIDTH attribute type
scsi: sd: Fix optimal I/O size for devices that change reported values
scripts/dtc: Remove redundant YYLOC global declaration
tools: Let O= makes handle a relative path with -C option
perf probe: Do not depend on dwfl_module_addrsym()
ARM: dts: omap5: Add bus_dma_limit for L3 bus
ARM: dts: dra7: Add bus_dma_limit for L3 bus
ceph: check POOL_FLAG_FULL/NEARFULL in addition to OSDMAP_FULL/NEARFULL
Input: avoid BIT() macro usage in the serio.h UAPI header
Input: synaptics - enable RMI on HP Envy 13-ad105ng
Input: raydium_i2c_ts - fix error codes in raydium_i2c_boot_trigger()
i2c: hix5hd2: add missed clk_disable_unprepare in remove
ftrace/x86: Anotate text_mutex split between ftrace_arch_code_modify_post_process() and ftrace_arch_code_modify_prepare()
sxgbe: Fix off by one in samsung driver strncpy size arg
dpaa_eth: Remove unnecessary boolean expression in dpaa_get_headroom
mac80211: Do not send mesh HWMP PREQ if HWMP is disabled
scsi: ipr: Fix softlockup when rescanning devices in petitboot
s390/qeth: handle error when backing RX buffer
fsl/fman: detect FMan erratum A050385
arm64: dts: ls1043a: FMan erratum A050385
dt-bindings: net: FMan erratum A050385
cgroup1: don't call release_agent when it is ""
drivers/of/of_mdio.c:fix of_mdiobus_register()
cpupower: avoid multiple definition with gcc -fno-common
nfs: add minor version to nfs_server_key for fscache
cgroup-v1: cgroup_pidlist_next should update position index
hsr: set .netnsok flag
hsr: add restart routine into hsr_get_node_list()
hsr: use rcu_read_lock() in hsr_get_node_{list/status}()
vxlan: check return value of gro_cells_init()
tcp: repair: fix TCP_QUEUE_SEQ implementation
r8169: re-enable MSI on RTL8168c
net: phy: mdio-mux-bcm-iproc: check clk_prepare_enable() return value
net: dsa: mt7530: Change the LINK bit to reflect the link status
net: ip_gre: Accept IFLA_INFO_DATA-less configuration
net: ip_gre: Separate ERSPAN newlink / changelink callbacks
bnxt_en: Reset rings if ring reservation fails during open()
bnxt_en: fix memory leaks in bnxt_dcbnl_ieee_getets()
slcan: not call free_netdev before rtnl_unlock in slcan_open
NFC: fdp: Fix a signedness bug in fdp_nci_send_patch()
net: stmmac: dwmac-rk: fix error path in rk_gmac_probe
net_sched: keep alloc_hash updated after hash allocation
net_sched: cls_route: remove the right filter from hashtable
net: qmi_wwan: add support for ASKEY WWHC050
net/packet: tpacket_rcv: avoid a producer race condition
net: mvneta: Fix the case where the last poll did not process all rx
net: dsa: Fix duplicate frames flooded by learning
net: cbs: Fix software cbs to consider packet sending time
mlxsw: spectrum_mr: Fix list iteration in error path
macsec: restrict to ethernet devices
hsr: fix general protection fault in hsr_addr_is_self()
geneve: move debug check after netdev unregister
Revert "drm/dp_mst: Skip validating ports during destruction, just ref"
mmc: sdhci-tegra: Fix busy detection by enabling MMC_CAP_NEED_RSP_BUSY
mmc: sdhci-omap: Fix busy detection by enabling MMC_CAP_NEED_RSP_BUSY
mmc: core: Respect MMC_CAP_NEED_RSP_BUSY for eMMC sleep command
mmc: core: Respect MMC_CAP_NEED_RSP_BUSY for erase/trim/discard
mmc: core: Allow host controllers to require R1B for CMD6
f2fs: fix to avoid potential deadlock
f2fs: add missing function name in kernel message
f2fs: recycle unused compress_data.chksum feild
f2fs: fix to avoid NULL pointer dereference
f2fs: fix leaking uninitialized memory in compressed clusters
f2fs: fix the panic in do_checkpoint()
f2fs: fix to wait all node page writeback
mm/swapfile.c: move inode_lock out of claim_swapfile
fscrypt: don't evict dirty inodes after removing key
Conflicts:
Documentation/arm64/silicon-errata.txt
Documentation/devicetree/bindings
Documentation/devicetree/bindings/net/fsl-fman.txt
arch/arm/kernel/setup.c
arch/arm/kernel/smp.c
arch/arm/mm/dma-mapping.c
arch/arm64/Kconfig
arch/arm64/Makefile
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/cputype.h
arch/arm64/include/asm/proc-fns.h
arch/arm64/include/asm/traps.h
arch/arm64/kernel/arm64ksyms.c
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/setup.c
arch/arm64/kernel/smp.c
arch/arm64/mm/dma-mapping.c
arch/arm64/mm/fault.c
arch/arm64/mm/proc.S
drivers/base/power/wakeup.c
drivers/clk/clk.c
drivers/clk/qcom/clk-rcg2.c
drivers/clocksource/arm_arch_timer.c
drivers/devfreq/devfreq.c
drivers/devfreq/governor_simpleondemand.c
drivers/dma-buf/dma-buf.c
drivers/extcon/extcon.c
drivers/gpu/Makefile
drivers/gpu/drm/drm_connector.c
drivers/gpu/drm/drm_dp_mst_topology.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_file.c
drivers/gpu/drm/drm_panel.c
drivers/gpu/drm/drm_property.c
drivers/iommu/Kconfig
drivers/iommu/Makefile
drivers/iommu/arm-smmu.c
drivers/iommu/dma-iommu.c
drivers/iommu/dma-mapping-fast.c
drivers/iommu/io-pgtable-arm.c
drivers/iommu/io-pgtable-fast.c
drivers/iommu/io-pgtable.c
drivers/iommu/iommu.c
drivers/irqchip/irq-gic-v3.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/mmc/core/Kconfig
drivers/mmc/core/block.c
drivers/mmc/core/queue.c
drivers/mmc/host/cqhci.c
drivers/mmc/host/sdhci-msm.c
drivers/net/wireless/ath/wil6210/interrupt.c
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/wil6210.h
drivers/net/wireless/ath/wil6210/wmi.c
drivers/nvmem/core.c
drivers/nvmem/nvmem-sysfs.c
drivers/of/fdt.c
drivers/power/supply/power_supply_sysfs.c
drivers/pwm/sysfs.c
drivers/regulator/core.c
drivers/scsi/sd.c
drivers/scsi/ufs/ufshcd.c
drivers/tty/serial/Kconfig
drivers/tty/serial/Makefile
drivers/usb/common/common.c
fs/crypto/crypto.c
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
include/drm/drm_connector.h
include/drm/drm_dp_mst_helper.h
include/drm/drm_panel.h
include/linux/clk-provider.h
include/linux/dma-buf.h
include/linux/dma-mapping-fast.h
include/linux/dma-mapping.h
include/linux/extcon.h
include/linux/io-pgtable.h
include/linux/iommu.h
include/linux/kobject.h
include/linux/mm.h
include/linux/mm_types.h
include/linux/mmc/host.h
include/linux/netdevice.h
include/linux/power_supply.h
include/linux/pwm.h
include/linux/regulator/driver.h
include/linux/thermal.h
include/linux/vm_event_item.h
include/net/cfg80211.h
include/scsi/scsi_device.h
include/sound/pcm.h
include/sound/soc.h
include/uapi/drm/drm_mode.h
include/uapi/linux/coresight-stm.h
include/uapi/linux/ip.h
include/uapi/linux/nl80211.h
include/uapi/linux/videodev2.h
include/uapi/sound/compress_offload.h
kernel/dma/coherent.c
kernel/dma/mapping.c
kernel/panic.c
kernel/power/qos.c
kernel/sched/sched.h
mm/Kconfig
mm/filemap.c
mm/swapfile.c
mm/vmalloc.c
mm/vmstat.c
net/qrtr/qrtr.c
net/wireless/nl80211.c
net/wireless/scan.c
sound/core/compress_offload.c
sound/soc/soc-core.c
sound/usb/card.c
sound/usb/pcm.c
sound/usb/pcm.h
sound/usb/usbaudio.h
Fixed build errors:
drivers/base/power/main.c
drivers/thermal/thermal_core.c
drivers/cpuidle/lpm-levels.c
include/soc/qcom/lpm_levels.h
Change-Id: Idf25b239f53681bdfa2ef371a91720fadf1a3f01
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
5376 lines
144 KiB
C
5376 lines
144 KiB
C
/*
|
|
* linux/mm/memory.c
|
|
*
|
|
* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
|
|
*/
|
|
|
|
/*
|
|
* demand-loading started 01.12.91 - seems it is high on the list of
|
|
* things wanted, and it should be easy to implement. - Linus
|
|
*/
|
|
|
|
/*
|
|
* Ok, demand-loading was easy, shared pages a little bit tricker. Shared
|
|
* pages started 02.12.91, seems to work. - Linus.
|
|
*
|
|
* Tested sharing by executing about 30 /bin/sh: under the old kernel it
|
|
* would have taken more than the 6M I have free, but it worked well as
|
|
* far as I could see.
|
|
*
|
|
* Also corrected some "invalidate()"s - I wasn't doing enough of them.
|
|
*/
|
|
|
|
/*
|
|
* Real VM (paging to/from disk) started 18.12.91. Much more work and
|
|
* thought has to go into this. Oh, well..
|
|
* 19.12.91 - works, somewhat. Sometimes I get faults, don't know why.
|
|
* Found it. Everything seems to work now.
|
|
* 20.12.91 - Ok, making the swap-device changeable like the root.
|
|
*/
|
|
|
|
/*
|
|
* 05.04.94 - Multi-page memory management added for v1.1.
|
|
* Idea by Alex Bligh (alex@cconcepts.co.uk)
|
|
*
|
|
* 16.07.99 - Support of BIGMEM added by Gerhard Wichert, Siemens AG
|
|
* (Gerhard.Wichert@pdb.siemens.de)
|
|
*
|
|
* Aug/Sep 2004 Changed to four level page tables (Andi Kleen)
|
|
*/
|
|
|
|
#include <linux/kernel_stat.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/sched/mm.h>
|
|
#include <linux/sched/coredump.h>
|
|
#include <linux/sched/numa_balancing.h>
|
|
#include <linux/sched/task.h>
|
|
#include <linux/hugetlb.h>
|
|
#include <linux/mman.h>
|
|
#include <linux/swap.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/memremap.h>
|
|
#include <linux/ksm.h>
|
|
#include <linux/rmap.h>
|
|
#include <linux/export.h>
|
|
#include <linux/delayacct.h>
|
|
#include <linux/init.h>
|
|
#include <linux/pfn_t.h>
|
|
#include <linux/writeback.h>
|
|
#include <linux/memcontrol.h>
|
|
#include <linux/mmu_notifier.h>
|
|
#include <linux/swapops.h>
|
|
#include <linux/elf.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/migrate.h>
|
|
#include <linux/string.h>
|
|
#include <linux/dma-debug.h>
|
|
#include <linux/debugfs.h>
|
|
#include <linux/userfaultfd_k.h>
|
|
#include <linux/dax.h>
|
|
#include <linux/oom.h>
|
|
|
|
#include <trace/events/kmem.h>
|
|
|
|
#include <asm/io.h>
|
|
#include <asm/mmu_context.h>
|
|
#include <asm/pgalloc.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/tlb.h>
|
|
#include <asm/tlbflush.h>
|
|
#include <asm/pgtable.h>
|
|
|
|
#include "internal.h"
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
#include <trace/events/pagefault.h>
|
|
|
|
#if defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) && !defined(CONFIG_COMPILE_TEST)
|
|
#warning Unfortunate NUMA and NUMA Balancing config, growing page-frame for last_cpupid.
|
|
#endif
|
|
|
|
#ifndef CONFIG_NEED_MULTIPLE_NODES
|
|
/* use the per-pgdat data instead for discontigmem - mbligh */
|
|
unsigned long max_mapnr;
|
|
EXPORT_SYMBOL(max_mapnr);
|
|
|
|
struct page *mem_map;
|
|
EXPORT_SYMBOL(mem_map);
|
|
#endif
|
|
|
|
/*
|
|
* A number of key systems in x86 including ioremap() rely on the assumption
|
|
* that high_memory defines the upper bound on direct map memory, then end
|
|
* of ZONE_NORMAL. Under CONFIG_DISCONTIG this means that max_low_pfn and
|
|
* highstart_pfn must be the same; there must be no gap between ZONE_NORMAL
|
|
* and ZONE_HIGHMEM.
|
|
*/
|
|
void *high_memory;
|
|
EXPORT_SYMBOL(high_memory);
|
|
|
|
/*
|
|
* Randomize the address space (stacks, mmaps, brk, etc.).
|
|
*
|
|
* ( When CONFIG_COMPAT_BRK=y we exclude brk from randomization,
|
|
* as ancient (libc5 based) binaries can segfault. )
|
|
*/
|
|
int randomize_va_space __read_mostly =
|
|
#ifdef CONFIG_COMPAT_BRK
|
|
1;
|
|
#else
|
|
2;
|
|
#endif
|
|
|
|
static int __init disable_randmaps(char *s)
|
|
{
|
|
randomize_va_space = 0;
|
|
return 1;
|
|
}
|
|
__setup("norandmaps", disable_randmaps);
|
|
|
|
unsigned long zero_pfn __read_mostly;
|
|
EXPORT_SYMBOL(zero_pfn);
|
|
|
|
unsigned long highest_memmap_pfn __read_mostly;
|
|
|
|
/*
|
|
* CONFIG_MMU architectures set up ZERO_PAGE in their paging_init()
|
|
*/
|
|
static int __init init_zero_pfn(void)
|
|
{
|
|
zero_pfn = page_to_pfn(ZERO_PAGE(0));
|
|
return 0;
|
|
}
|
|
core_initcall(init_zero_pfn);
|
|
|
|
/*
|
|
* Only trace rss_stat when there is a 512kb cross over.
|
|
* Smaller changes may be lost unless every small change is
|
|
* crossing into or returning to a 512kb boundary.
|
|
*/
|
|
#define TRACE_MM_COUNTER_THRESHOLD 128
|
|
|
|
void mm_trace_rss_stat(struct mm_struct *mm, int member, long count,
|
|
long value)
|
|
{
|
|
long thresh_mask = ~(TRACE_MM_COUNTER_THRESHOLD - 1);
|
|
|
|
/* Threshold roll-over, trace it */
|
|
if ((count & thresh_mask) != ((count - value) & thresh_mask))
|
|
trace_rss_stat(mm, member, count);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mm_trace_rss_stat);
|
|
|
|
#if defined(SPLIT_RSS_COUNTING)
|
|
|
|
void sync_mm_rss(struct mm_struct *mm)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < NR_MM_COUNTERS; i++) {
|
|
if (current->rss_stat.count[i]) {
|
|
add_mm_counter(mm, i, current->rss_stat.count[i]);
|
|
current->rss_stat.count[i] = 0;
|
|
}
|
|
}
|
|
current->rss_stat.events = 0;
|
|
}
|
|
|
|
static void add_mm_counter_fast(struct mm_struct *mm, int member, int val)
|
|
{
|
|
struct task_struct *task = current;
|
|
|
|
if (likely(task->mm == mm))
|
|
task->rss_stat.count[member] += val;
|
|
else
|
|
add_mm_counter(mm, member, val);
|
|
}
|
|
#define inc_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member, 1)
|
|
#define dec_mm_counter_fast(mm, member) add_mm_counter_fast(mm, member, -1)
|
|
|
|
/* sync counter once per 64 page faults */
|
|
#define TASK_RSS_EVENTS_THRESH (64)
|
|
static void check_sync_rss_stat(struct task_struct *task)
|
|
{
|
|
if (unlikely(task != current))
|
|
return;
|
|
if (unlikely(task->rss_stat.events++ > TASK_RSS_EVENTS_THRESH))
|
|
sync_mm_rss(task->mm);
|
|
}
|
|
#else /* SPLIT_RSS_COUNTING */
|
|
|
|
#define inc_mm_counter_fast(mm, member) inc_mm_counter(mm, member)
|
|
#define dec_mm_counter_fast(mm, member) dec_mm_counter(mm, member)
|
|
|
|
static void check_sync_rss_stat(struct task_struct *task)
|
|
{
|
|
}
|
|
|
|
#endif /* SPLIT_RSS_COUNTING */
|
|
|
|
#ifdef HAVE_GENERIC_MMU_GATHER
|
|
|
|
static bool tlb_next_batch(struct mmu_gather *tlb)
|
|
{
|
|
struct mmu_gather_batch *batch;
|
|
|
|
batch = tlb->active;
|
|
if (batch->next) {
|
|
tlb->active = batch->next;
|
|
return true;
|
|
}
|
|
|
|
if (tlb->batch_count == MAX_GATHER_BATCH_COUNT)
|
|
return false;
|
|
|
|
batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
|
|
if (!batch)
|
|
return false;
|
|
|
|
tlb->batch_count++;
|
|
batch->next = NULL;
|
|
batch->nr = 0;
|
|
batch->max = MAX_GATHER_BATCH;
|
|
|
|
tlb->active->next = batch;
|
|
tlb->active = batch;
|
|
|
|
return true;
|
|
}
|
|
|
|
void arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
|
|
unsigned long start, unsigned long end)
|
|
{
|
|
tlb->mm = mm;
|
|
|
|
/* Is it from 0 to ~0? */
|
|
tlb->fullmm = !(start | (end+1));
|
|
tlb->need_flush_all = 0;
|
|
tlb->local.next = NULL;
|
|
tlb->local.nr = 0;
|
|
tlb->local.max = ARRAY_SIZE(tlb->__pages);
|
|
tlb->active = &tlb->local;
|
|
tlb->batch_count = 0;
|
|
|
|
#ifdef CONFIG_HAVE_RCU_TABLE_FREE
|
|
tlb->batch = NULL;
|
|
#endif
|
|
tlb->page_size = 0;
|
|
|
|
__tlb_reset_range(tlb);
|
|
}
|
|
|
|
static void tlb_flush_mmu_free(struct mmu_gather *tlb)
|
|
{
|
|
struct mmu_gather_batch *batch;
|
|
|
|
#ifdef CONFIG_HAVE_RCU_TABLE_FREE
|
|
tlb_table_flush(tlb);
|
|
#endif
|
|
for (batch = &tlb->local; batch && batch->nr; batch = batch->next) {
|
|
free_pages_and_swap_cache(batch->pages, batch->nr);
|
|
batch->nr = 0;
|
|
}
|
|
tlb->active = &tlb->local;
|
|
}
|
|
|
|
void tlb_flush_mmu(struct mmu_gather *tlb)
|
|
{
|
|
tlb_flush_mmu_tlbonly(tlb);
|
|
tlb_flush_mmu_free(tlb);
|
|
}
|
|
|
|
/* tlb_finish_mmu
|
|
* Called at the end of the shootdown operation to free up any resources
|
|
* that were required.
|
|
*/
|
|
void arch_tlb_finish_mmu(struct mmu_gather *tlb,
|
|
unsigned long start, unsigned long end, bool force)
|
|
{
|
|
struct mmu_gather_batch *batch, *next;
|
|
|
|
if (force)
|
|
__tlb_adjust_range(tlb, start, end - start);
|
|
|
|
tlb_flush_mmu(tlb);
|
|
|
|
/* keep the page table cache within bounds */
|
|
check_pgt_cache();
|
|
|
|
for (batch = tlb->local.next; batch; batch = next) {
|
|
next = batch->next;
|
|
free_pages((unsigned long)batch, 0);
|
|
}
|
|
tlb->local.next = NULL;
|
|
}
|
|
|
|
/* __tlb_remove_page
|
|
* Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), while
|
|
* handling the additional races in SMP caused by other CPUs caching valid
|
|
* mappings in their TLBs. Returns the number of free page slots left.
|
|
* When out of page slots we must call tlb_flush_mmu().
|
|
*returns true if the caller should flush.
|
|
*/
|
|
bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_size)
|
|
{
|
|
struct mmu_gather_batch *batch;
|
|
|
|
VM_BUG_ON(!tlb->end);
|
|
VM_WARN_ON(tlb->page_size != page_size);
|
|
|
|
batch = tlb->active;
|
|
/*
|
|
* Add the page and check if we are full. If so
|
|
* force a flush.
|
|
*/
|
|
batch->pages[batch->nr++] = page;
|
|
if (batch->nr == batch->max) {
|
|
if (!tlb_next_batch(tlb))
|
|
return true;
|
|
batch = tlb->active;
|
|
}
|
|
VM_BUG_ON_PAGE(batch->nr > batch->max, page);
|
|
|
|
return false;
|
|
}
|
|
|
|
#endif /* HAVE_GENERIC_MMU_GATHER */
|
|
|
|
#ifdef CONFIG_HAVE_RCU_TABLE_FREE
|
|
|
|
/*
|
|
* See the comment near struct mmu_table_batch.
|
|
*/
|
|
|
|
/*
|
|
* If we want tlb_remove_table() to imply TLB invalidates.
|
|
*/
|
|
static inline void tlb_table_invalidate(struct mmu_gather *tlb)
|
|
{
|
|
#ifdef CONFIG_HAVE_RCU_TABLE_INVALIDATE
|
|
/*
|
|
* Invalidate page-table caches used by hardware walkers. Then we still
|
|
* need to RCU-sched wait while freeing the pages because software
|
|
* walkers can still be in-flight.
|
|
*/
|
|
tlb_flush_mmu_tlbonly(tlb);
|
|
#endif
|
|
}
|
|
|
|
static void tlb_remove_table_smp_sync(void *arg)
|
|
{
|
|
/* Simply deliver the interrupt */
|
|
}
|
|
|
|
static void tlb_remove_table_one(void *table)
|
|
{
|
|
/*
|
|
* This isn't an RCU grace period and hence the page-tables cannot be
|
|
* assumed to be actually RCU-freed.
|
|
*
|
|
* It is however sufficient for software page-table walkers that rely on
|
|
* IRQ disabling. See the comment near struct mmu_table_batch.
|
|
*/
|
|
smp_call_function(tlb_remove_table_smp_sync, NULL, 1);
|
|
__tlb_remove_table(table);
|
|
}
|
|
|
|
static void tlb_remove_table_rcu(struct rcu_head *head)
|
|
{
|
|
struct mmu_table_batch *batch;
|
|
int i;
|
|
|
|
batch = container_of(head, struct mmu_table_batch, rcu);
|
|
|
|
for (i = 0; i < batch->nr; i++)
|
|
__tlb_remove_table(batch->tables[i]);
|
|
|
|
free_page((unsigned long)batch);
|
|
}
|
|
|
|
void tlb_table_flush(struct mmu_gather *tlb)
|
|
{
|
|
struct mmu_table_batch **batch = &tlb->batch;
|
|
|
|
if (*batch) {
|
|
tlb_table_invalidate(tlb);
|
|
call_rcu_sched(&(*batch)->rcu, tlb_remove_table_rcu);
|
|
*batch = NULL;
|
|
}
|
|
}
|
|
|
|
void tlb_remove_table(struct mmu_gather *tlb, void *table)
|
|
{
|
|
struct mmu_table_batch **batch = &tlb->batch;
|
|
|
|
if (*batch == NULL) {
|
|
*batch = (struct mmu_table_batch *)__get_free_page(GFP_NOWAIT | __GFP_NOWARN);
|
|
if (*batch == NULL) {
|
|
tlb_table_invalidate(tlb);
|
|
tlb_remove_table_one(table);
|
|
return;
|
|
}
|
|
(*batch)->nr = 0;
|
|
}
|
|
|
|
(*batch)->tables[(*batch)->nr++] = table;
|
|
if ((*batch)->nr == MAX_TABLE_BATCH)
|
|
tlb_table_flush(tlb);
|
|
}
|
|
|
|
#endif /* CONFIG_HAVE_RCU_TABLE_FREE */
|
|
|
|
/**
|
|
* tlb_gather_mmu - initialize an mmu_gather structure for page-table tear-down
|
|
* @tlb: the mmu_gather structure to initialize
|
|
* @mm: the mm_struct of the target address space
|
|
* @start: start of the region that will be removed from the page-table
|
|
* @end: end of the region that will be removed from the page-table
|
|
*
|
|
* Called to initialize an (on-stack) mmu_gather structure for page-table
|
|
* tear-down from @mm. The @start and @end are set to 0 and -1
|
|
* respectively when @mm is without users and we're going to destroy
|
|
* the full address space (exit/execve).
|
|
*/
|
|
void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
|
|
unsigned long start, unsigned long end)
|
|
{
|
|
arch_tlb_gather_mmu(tlb, mm, start, end);
|
|
inc_tlb_flush_pending(tlb->mm);
|
|
}
|
|
|
|
void tlb_finish_mmu(struct mmu_gather *tlb,
|
|
unsigned long start, unsigned long end)
|
|
{
|
|
/*
|
|
* 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
|
|
* flush by batching, a thread has stable TLB entry can fail to flush
|
|
* the TLB by observing pte_none|!pte_dirty, for example so flush TLB
|
|
* forcefully if we detect parallel PTE batching threads.
|
|
*/
|
|
bool force = mm_tlb_flush_nested(tlb->mm);
|
|
|
|
arch_tlb_finish_mmu(tlb, start, end, force);
|
|
dec_tlb_flush_pending(tlb->mm);
|
|
}
|
|
|
|
/*
|
|
* Note: this doesn't free the actual pages themselves. That
|
|
* has been handled earlier when unmapping all the memory regions.
|
|
*/
|
|
static void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,
|
|
unsigned long addr)
|
|
{
|
|
pgtable_t token = pmd_pgtable(*pmd);
|
|
pmd_clear(pmd);
|
|
pte_free_tlb(tlb, token, addr);
|
|
mm_dec_nr_ptes(tlb->mm);
|
|
}
|
|
|
|
static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long floor, unsigned long ceiling)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
unsigned long start;
|
|
|
|
start = addr;
|
|
pmd = pmd_offset(pud, addr);
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
if (pmd_none_or_clear_bad(pmd))
|
|
continue;
|
|
free_pte_range(tlb, pmd, addr);
|
|
} while (pmd++, addr = next, addr != end);
|
|
|
|
start &= PUD_MASK;
|
|
if (start < floor)
|
|
return;
|
|
if (ceiling) {
|
|
ceiling &= PUD_MASK;
|
|
if (!ceiling)
|
|
return;
|
|
}
|
|
if (end - 1 > ceiling - 1)
|
|
return;
|
|
|
|
pmd = pmd_offset(pud, start);
|
|
pud_clear(pud);
|
|
pmd_free_tlb(tlb, pmd, start);
|
|
mm_dec_nr_pmds(tlb->mm);
|
|
}
|
|
|
|
static inline void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long floor, unsigned long ceiling)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
unsigned long start;
|
|
|
|
start = addr;
|
|
pud = pud_offset(p4d, addr);
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
if (pud_none_or_clear_bad(pud))
|
|
continue;
|
|
free_pmd_range(tlb, pud, addr, next, floor, ceiling);
|
|
} while (pud++, addr = next, addr != end);
|
|
|
|
start &= P4D_MASK;
|
|
if (start < floor)
|
|
return;
|
|
if (ceiling) {
|
|
ceiling &= P4D_MASK;
|
|
if (!ceiling)
|
|
return;
|
|
}
|
|
if (end - 1 > ceiling - 1)
|
|
return;
|
|
|
|
pud = pud_offset(p4d, start);
|
|
p4d_clear(p4d);
|
|
pud_free_tlb(tlb, pud, start);
|
|
mm_dec_nr_puds(tlb->mm);
|
|
}
|
|
|
|
static inline void free_p4d_range(struct mmu_gather *tlb, pgd_t *pgd,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long floor, unsigned long ceiling)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
unsigned long start;
|
|
|
|
start = addr;
|
|
p4d = p4d_offset(pgd, addr);
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
if (p4d_none_or_clear_bad(p4d))
|
|
continue;
|
|
free_pud_range(tlb, p4d, addr, next, floor, ceiling);
|
|
} while (p4d++, addr = next, addr != end);
|
|
|
|
start &= PGDIR_MASK;
|
|
if (start < floor)
|
|
return;
|
|
if (ceiling) {
|
|
ceiling &= PGDIR_MASK;
|
|
if (!ceiling)
|
|
return;
|
|
}
|
|
if (end - 1 > ceiling - 1)
|
|
return;
|
|
|
|
p4d = p4d_offset(pgd, start);
|
|
pgd_clear(pgd);
|
|
p4d_free_tlb(tlb, p4d, start);
|
|
}
|
|
|
|
/*
|
|
* This function frees user-level page tables of a process.
|
|
*/
|
|
void free_pgd_range(struct mmu_gather *tlb,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long floor, unsigned long ceiling)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
|
|
/*
|
|
* The next few lines have given us lots of grief...
|
|
*
|
|
* Why are we testing PMD* at this top level? Because often
|
|
* there will be no work to do at all, and we'd prefer not to
|
|
* go all the way down to the bottom just to discover that.
|
|
*
|
|
* Why all these "- 1"s? Because 0 represents both the bottom
|
|
* of the address space and the top of it (using -1 for the
|
|
* top wouldn't help much: the masks would do the wrong thing).
|
|
* The rule is that addr 0 and floor 0 refer to the bottom of
|
|
* the address space, but end 0 and ceiling 0 refer to the top
|
|
* Comparisons need to use "end - 1" and "ceiling - 1" (though
|
|
* that end 0 case should be mythical).
|
|
*
|
|
* Wherever addr is brought up or ceiling brought down, we must
|
|
* be careful to reject "the opposite 0" before it confuses the
|
|
* subsequent tests. But what about where end is brought down
|
|
* by PMD_SIZE below? no, end can't go down to 0 there.
|
|
*
|
|
* Whereas we round start (addr) and ceiling down, by different
|
|
* masks at different levels, in order to test whether a table
|
|
* now has no other vmas using it, so can be freed, we don't
|
|
* bother to round floor or end up - the tests don't need that.
|
|
*/
|
|
|
|
addr &= PMD_MASK;
|
|
if (addr < floor) {
|
|
addr += PMD_SIZE;
|
|
if (!addr)
|
|
return;
|
|
}
|
|
if (ceiling) {
|
|
ceiling &= PMD_MASK;
|
|
if (!ceiling)
|
|
return;
|
|
}
|
|
if (end - 1 > ceiling - 1)
|
|
end -= PMD_SIZE;
|
|
if (addr > end - 1)
|
|
return;
|
|
/*
|
|
* We add page table cache pages with PAGE_SIZE,
|
|
* (see pte_free_tlb()), flush the tlb if we need
|
|
*/
|
|
tlb_remove_check_page_size_change(tlb, PAGE_SIZE);
|
|
pgd = pgd_offset(tlb->mm, addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
if (pgd_none_or_clear_bad(pgd))
|
|
continue;
|
|
free_p4d_range(tlb, pgd, addr, next, floor, ceiling);
|
|
} while (pgd++, addr = next, addr != end);
|
|
}
|
|
|
|
void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma,
|
|
unsigned long floor, unsigned long ceiling)
|
|
{
|
|
while (vma) {
|
|
struct vm_area_struct *next = vma->vm_next;
|
|
unsigned long addr = vma->vm_start;
|
|
|
|
/*
|
|
* Hide vma from rmap and truncate_pagecache before freeing
|
|
* pgtables
|
|
*/
|
|
vm_write_begin(vma);
|
|
unlink_anon_vmas(vma);
|
|
vm_write_end(vma);
|
|
unlink_file_vma(vma);
|
|
|
|
if (is_vm_hugetlb_page(vma)) {
|
|
hugetlb_free_pgd_range(tlb, addr, vma->vm_end,
|
|
floor, next ? next->vm_start : ceiling);
|
|
} else {
|
|
/*
|
|
* Optimization: gather nearby vmas into one call down
|
|
*/
|
|
while (next && next->vm_start <= vma->vm_end + PMD_SIZE
|
|
&& !is_vm_hugetlb_page(next)) {
|
|
vma = next;
|
|
next = vma->vm_next;
|
|
vm_write_begin(vma);
|
|
unlink_anon_vmas(vma);
|
|
vm_write_end(vma);
|
|
unlink_file_vma(vma);
|
|
}
|
|
free_pgd_range(tlb, addr, vma->vm_end,
|
|
floor, next ? next->vm_start : ceiling);
|
|
}
|
|
vma = next;
|
|
}
|
|
}
|
|
|
|
int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
|
|
{
|
|
spinlock_t *ptl;
|
|
pgtable_t new = pte_alloc_one(mm, address);
|
|
if (!new)
|
|
return -ENOMEM;
|
|
|
|
/*
|
|
* Ensure all pte setup (eg. pte page lock and page clearing) are
|
|
* visible before the pte is made visible to other CPUs by being
|
|
* put into page tables.
|
|
*
|
|
* The other side of the story is the pointer chasing in the page
|
|
* table walking code (when walking the page table without locking;
|
|
* ie. most of the time). Fortunately, these data accesses consist
|
|
* of a chain of data-dependent loads, meaning most CPUs (alpha
|
|
* being the notable exception) will already guarantee loads are
|
|
* seen in-order. See the alpha page table accessors for the
|
|
* smp_read_barrier_depends() barriers in page table walking code.
|
|
*/
|
|
smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
|
|
|
|
ptl = pmd_lock(mm, pmd);
|
|
if (likely(pmd_none(*pmd))) { /* Has another populated it ? */
|
|
mm_inc_nr_ptes(mm);
|
|
pmd_populate(mm, pmd, new);
|
|
new = NULL;
|
|
}
|
|
spin_unlock(ptl);
|
|
if (new)
|
|
pte_free(mm, new);
|
|
return 0;
|
|
}
|
|
|
|
int __pte_alloc_kernel(pmd_t *pmd, unsigned long address)
|
|
{
|
|
pte_t *new = pte_alloc_one_kernel(&init_mm, address);
|
|
if (!new)
|
|
return -ENOMEM;
|
|
|
|
smp_wmb(); /* See comment in __pte_alloc */
|
|
|
|
spin_lock(&init_mm.page_table_lock);
|
|
if (likely(pmd_none(*pmd))) { /* Has another populated it ? */
|
|
pmd_populate_kernel(&init_mm, pmd, new);
|
|
new = NULL;
|
|
}
|
|
spin_unlock(&init_mm.page_table_lock);
|
|
if (new)
|
|
pte_free_kernel(&init_mm, new);
|
|
return 0;
|
|
}
|
|
|
|
static inline void init_rss_vec(int *rss)
|
|
{
|
|
memset(rss, 0, sizeof(int) * NR_MM_COUNTERS);
|
|
}
|
|
|
|
static inline void add_mm_rss_vec(struct mm_struct *mm, int *rss)
|
|
{
|
|
int i;
|
|
|
|
if (current->mm == mm)
|
|
sync_mm_rss(mm);
|
|
for (i = 0; i < NR_MM_COUNTERS; i++)
|
|
if (rss[i])
|
|
add_mm_counter(mm, i, rss[i]);
|
|
}
|
|
|
|
/*
|
|
* This function is called to print an error when a bad pte
|
|
* is found. For example, we might have a PFN-mapped pte in
|
|
* a region that doesn't allow it.
|
|
*
|
|
* The calling function must still handle the error.
|
|
*/
|
|
static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
|
|
pte_t pte, struct page *page)
|
|
{
|
|
pgd_t *pgd = pgd_offset(vma->vm_mm, addr);
|
|
p4d_t *p4d = p4d_offset(pgd, addr);
|
|
pud_t *pud = pud_offset(p4d, addr);
|
|
pmd_t *pmd = pmd_offset(pud, addr);
|
|
struct address_space *mapping;
|
|
pgoff_t index;
|
|
static unsigned long resume;
|
|
static unsigned long nr_shown;
|
|
static unsigned long nr_unshown;
|
|
|
|
/*
|
|
* Allow a burst of 60 reports, then keep quiet for that minute;
|
|
* or allow a steady drip of one report per second.
|
|
*/
|
|
if (nr_shown == 60) {
|
|
if (time_before(jiffies, resume)) {
|
|
nr_unshown++;
|
|
return;
|
|
}
|
|
if (nr_unshown) {
|
|
pr_alert("BUG: Bad page map: %lu messages suppressed\n",
|
|
nr_unshown);
|
|
nr_unshown = 0;
|
|
}
|
|
nr_shown = 0;
|
|
}
|
|
if (nr_shown++ == 0)
|
|
resume = jiffies + 60 * HZ;
|
|
|
|
mapping = vma->vm_file ? vma->vm_file->f_mapping : NULL;
|
|
index = linear_page_index(vma, addr);
|
|
|
|
pr_alert("BUG: Bad page map in process %s pte:%08llx pmd:%08llx\n",
|
|
current->comm,
|
|
(long long)pte_val(pte), (long long)pmd_val(*pmd));
|
|
if (page)
|
|
dump_page(page, "bad pte");
|
|
pr_alert("addr:%p vm_flags:%08lx anon_vma:%p mapping:%p index:%lx\n",
|
|
(void *)addr, READ_ONCE(vma->vm_flags), vma->anon_vma,
|
|
mapping, index);
|
|
pr_alert("file:%pD fault:%pf mmap:%pf readpage:%pf\n",
|
|
vma->vm_file,
|
|
vma->vm_ops ? vma->vm_ops->fault : NULL,
|
|
vma->vm_file ? vma->vm_file->f_op->mmap : NULL,
|
|
mapping ? mapping->a_ops->readpage : NULL);
|
|
dump_stack();
|
|
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
|
|
}
|
|
|
|
/*
|
|
* __vm_normal_page -- This function gets the "struct page" associated with
|
|
* a pte.
|
|
*
|
|
* "Special" mappings do not wish to be associated with a "struct page" (either
|
|
* it doesn't exist, or it exists but they don't want to touch it). In this
|
|
* case, NULL is returned here. "Normal" mappings do have a struct page.
|
|
*
|
|
* There are 2 broad cases. Firstly, an architecture may define a pte_special()
|
|
* pte bit, in which case this function is trivial. Secondly, an architecture
|
|
* may not have a spare pte bit, which requires a more complicated scheme,
|
|
* described below.
|
|
*
|
|
* A raw VM_PFNMAP mapping (ie. one that is not COWed) is always considered a
|
|
* special mapping (even if there are underlying and valid "struct pages").
|
|
* COWed pages of a VM_PFNMAP are always normal.
|
|
*
|
|
* The way we recognize COWed pages within VM_PFNMAP mappings is through the
|
|
* rules set up by "remap_pfn_range()": the vma will have the VM_PFNMAP bit
|
|
* set, and the vm_pgoff will point to the first PFN mapped: thus every special
|
|
* mapping will always honor the rule
|
|
*
|
|
* pfn_of_page == vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT)
|
|
*
|
|
* And for normal mappings this is false.
|
|
*
|
|
* This restricts such mappings to be a linear translation from virtual address
|
|
* to pfn. To get around this restriction, we allow arbitrary mappings so long
|
|
* as the vma is not a COW mapping; in that case, we know that all ptes are
|
|
* special (because none can have been COWed).
|
|
*
|
|
*
|
|
* In order to support COW of arbitrary special mappings, we have VM_MIXEDMAP.
|
|
*
|
|
* VM_MIXEDMAP mappings can likewise contain memory with or without "struct
|
|
* page" backing, however the difference is that _all_ pages with a struct
|
|
* page (that is, those where pfn_valid is true) are refcounted and considered
|
|
* normal pages by the VM. The disadvantage is that pages are refcounted
|
|
* (which can be slower and simply not an option for some PFNMAP users). The
|
|
* advantage is that we don't have to follow the strict linearity rule of
|
|
* PFNMAP mappings in order to support COWable mappings.
|
|
*
|
|
*/
|
|
struct page *__vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
|
|
pte_t pte, bool with_public_device,
|
|
unsigned long vma_flags)
|
|
{
|
|
unsigned long pfn = pte_pfn(pte);
|
|
|
|
if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL)) {
|
|
if (likely(!pte_special(pte)))
|
|
goto check_pfn;
|
|
if (vma->vm_ops && vma->vm_ops->find_special_page)
|
|
return vma->vm_ops->find_special_page(vma, addr);
|
|
if (vma_flags & (VM_PFNMAP | VM_MIXEDMAP))
|
|
return NULL;
|
|
if (is_zero_pfn(pfn))
|
|
return NULL;
|
|
|
|
/*
|
|
* Device public pages are special pages (they are ZONE_DEVICE
|
|
* pages but different from persistent memory). They behave
|
|
* allmost like normal pages. The difference is that they are
|
|
* not on the lru and thus should never be involve with any-
|
|
* thing that involve lru manipulation (mlock, numa balancing,
|
|
* ...).
|
|
*
|
|
* This is why we still want to return NULL for such page from
|
|
* vm_normal_page() so that we do not have to special case all
|
|
* call site of vm_normal_page().
|
|
*/
|
|
if (likely(pfn <= highest_memmap_pfn)) {
|
|
struct page *page = pfn_to_page(pfn);
|
|
|
|
if (is_device_public_page(page)) {
|
|
if (with_public_device)
|
|
return page;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
if (pte_devmap(pte))
|
|
return NULL;
|
|
|
|
print_bad_pte(vma, addr, pte, NULL);
|
|
return NULL;
|
|
}
|
|
|
|
/* !CONFIG_ARCH_HAS_PTE_SPECIAL case follows: */
|
|
/*
|
|
* This part should never get called when CONFIG_SPECULATIVE_PAGE_FAULT
|
|
* is set. This is mainly because we can't rely on vm_start.
|
|
*/
|
|
|
|
if (unlikely(vma_flags & (VM_PFNMAP|VM_MIXEDMAP))) {
|
|
if (vma_flags & VM_MIXEDMAP) {
|
|
if (!pfn_valid(pfn))
|
|
return NULL;
|
|
goto out;
|
|
} else {
|
|
unsigned long off;
|
|
off = (addr - vma->vm_start) >> PAGE_SHIFT;
|
|
if (pfn == vma->vm_pgoff + off)
|
|
return NULL;
|
|
if (!is_cow_mapping(vma_flags))
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
if (is_zero_pfn(pfn))
|
|
return NULL;
|
|
|
|
check_pfn:
|
|
if (unlikely(pfn > highest_memmap_pfn)) {
|
|
print_bad_pte(vma, addr, pte, NULL);
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* NOTE! We still have PageReserved() pages in the page tables.
|
|
* eg. VDSO mappings can cause them to exist.
|
|
*/
|
|
out:
|
|
return pfn_to_page(pfn);
|
|
}
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
|
|
pmd_t pmd)
|
|
{
|
|
unsigned long pfn = pmd_pfn(pmd);
|
|
|
|
/*
|
|
* There is no pmd_special() but there may be special pmds, e.g.
|
|
* in a direct-access (dax) mapping, so let's just replicate the
|
|
* !CONFIG_ARCH_HAS_PTE_SPECIAL case from vm_normal_page() here.
|
|
*/
|
|
if (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) {
|
|
if (vma->vm_flags & VM_MIXEDMAP) {
|
|
if (!pfn_valid(pfn))
|
|
return NULL;
|
|
goto out;
|
|
} else {
|
|
unsigned long off;
|
|
off = (addr - vma->vm_start) >> PAGE_SHIFT;
|
|
if (pfn == vma->vm_pgoff + off)
|
|
return NULL;
|
|
if (!is_cow_mapping(vma->vm_flags))
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
if (pmd_devmap(pmd))
|
|
return NULL;
|
|
if (is_zero_pfn(pfn))
|
|
return NULL;
|
|
if (unlikely(pfn > highest_memmap_pfn))
|
|
return NULL;
|
|
|
|
/*
|
|
* NOTE! We still have PageReserved() pages in the page tables.
|
|
* eg. VDSO mappings can cause them to exist.
|
|
*/
|
|
out:
|
|
return pfn_to_page(pfn);
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* copy one vm_area from one task to the other. Assumes the page tables
|
|
* already present in the new task to be cleared in the whole range
|
|
* covered by this vma.
|
|
*/
|
|
|
|
static inline unsigned long
|
|
copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,
|
|
unsigned long addr, int *rss)
|
|
{
|
|
unsigned long vm_flags = vma->vm_flags;
|
|
pte_t pte = *src_pte;
|
|
struct page *page;
|
|
|
|
/* pte contains position in swap or file, so copy. */
|
|
if (unlikely(!pte_present(pte))) {
|
|
swp_entry_t entry = pte_to_swp_entry(pte);
|
|
|
|
if (likely(!non_swap_entry(entry))) {
|
|
if (swap_duplicate(entry) < 0)
|
|
return entry.val;
|
|
|
|
/* make sure dst_mm is on swapoff's mmlist. */
|
|
if (unlikely(list_empty(&dst_mm->mmlist))) {
|
|
spin_lock(&mmlist_lock);
|
|
if (list_empty(&dst_mm->mmlist))
|
|
list_add(&dst_mm->mmlist,
|
|
&src_mm->mmlist);
|
|
spin_unlock(&mmlist_lock);
|
|
}
|
|
rss[MM_SWAPENTS]++;
|
|
} else if (is_migration_entry(entry)) {
|
|
page = migration_entry_to_page(entry);
|
|
|
|
rss[mm_counter(page)]++;
|
|
|
|
if (is_write_migration_entry(entry) &&
|
|
is_cow_mapping(vm_flags)) {
|
|
/*
|
|
* COW mappings require pages in both
|
|
* parent and child to be set to read.
|
|
*/
|
|
make_migration_entry_read(&entry);
|
|
pte = swp_entry_to_pte(entry);
|
|
if (pte_swp_soft_dirty(*src_pte))
|
|
pte = pte_swp_mksoft_dirty(pte);
|
|
set_pte_at(src_mm, addr, src_pte, pte);
|
|
}
|
|
} else if (is_device_private_entry(entry)) {
|
|
page = device_private_entry_to_page(entry);
|
|
|
|
/*
|
|
* Update rss count even for unaddressable pages, as
|
|
* they should treated just like normal pages in this
|
|
* respect.
|
|
*
|
|
* We will likely want to have some new rss counters
|
|
* for unaddressable pages, at some point. But for now
|
|
* keep things as they are.
|
|
*/
|
|
get_page(page);
|
|
rss[mm_counter(page)]++;
|
|
page_dup_rmap(page, false);
|
|
|
|
/*
|
|
* We do not preserve soft-dirty information, because so
|
|
* far, checkpoint/restore is the only feature that
|
|
* requires that. And checkpoint/restore does not work
|
|
* when a device driver is involved (you cannot easily
|
|
* save and restore device driver state).
|
|
*/
|
|
if (is_write_device_private_entry(entry) &&
|
|
is_cow_mapping(vm_flags)) {
|
|
make_device_private_entry_read(&entry);
|
|
pte = swp_entry_to_pte(entry);
|
|
set_pte_at(src_mm, addr, src_pte, pte);
|
|
}
|
|
}
|
|
goto out_set_pte;
|
|
}
|
|
|
|
/*
|
|
* If it's a COW mapping, write protect it both
|
|
* in the parent and the child
|
|
*/
|
|
if (is_cow_mapping(vm_flags) && pte_write(pte)) {
|
|
ptep_set_wrprotect(src_mm, addr, src_pte);
|
|
pte = pte_wrprotect(pte);
|
|
}
|
|
|
|
/*
|
|
* If it's a shared mapping, mark it clean in
|
|
* the child
|
|
*/
|
|
if (vm_flags & VM_SHARED)
|
|
pte = pte_mkclean(pte);
|
|
pte = pte_mkold(pte);
|
|
|
|
page = vm_normal_page(vma, addr, pte);
|
|
if (page) {
|
|
get_page(page);
|
|
page_dup_rmap(page, false);
|
|
rss[mm_counter(page)]++;
|
|
} else if (pte_devmap(pte)) {
|
|
page = pte_page(pte);
|
|
|
|
/*
|
|
* Cache coherent device memory behave like regular page and
|
|
* not like persistent memory page. For more informations see
|
|
* MEMORY_DEVICE_CACHE_COHERENT in memory_hotplug.h
|
|
*/
|
|
if (is_device_public_page(page)) {
|
|
get_page(page);
|
|
page_dup_rmap(page, false);
|
|
rss[mm_counter(page)]++;
|
|
}
|
|
}
|
|
|
|
out_set_pte:
|
|
set_pte_at(dst_mm, addr, dst_pte, pte);
|
|
return 0;
|
|
}
|
|
|
|
static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
pmd_t *dst_pmd, pmd_t *src_pmd, struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long end)
|
|
{
|
|
pte_t *orig_src_pte, *orig_dst_pte;
|
|
pte_t *src_pte, *dst_pte;
|
|
spinlock_t *src_ptl, *dst_ptl;
|
|
int progress = 0;
|
|
int rss[NR_MM_COUNTERS];
|
|
swp_entry_t entry = (swp_entry_t){0};
|
|
|
|
again:
|
|
init_rss_vec(rss);
|
|
|
|
dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
|
|
if (!dst_pte)
|
|
return -ENOMEM;
|
|
src_pte = pte_offset_map(src_pmd, addr);
|
|
src_ptl = pte_lockptr(src_mm, src_pmd);
|
|
spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);
|
|
orig_src_pte = src_pte;
|
|
orig_dst_pte = dst_pte;
|
|
arch_enter_lazy_mmu_mode();
|
|
|
|
do {
|
|
/*
|
|
* We are holding two locks at this point - either of them
|
|
* could generate latencies in another task on another CPU.
|
|
*/
|
|
if (progress >= 32) {
|
|
progress = 0;
|
|
if (need_resched() ||
|
|
spin_needbreak(src_ptl) || spin_needbreak(dst_ptl))
|
|
break;
|
|
}
|
|
if (pte_none(*src_pte)) {
|
|
progress++;
|
|
continue;
|
|
}
|
|
entry.val = copy_one_pte(dst_mm, src_mm, dst_pte, src_pte,
|
|
vma, addr, rss);
|
|
if (entry.val)
|
|
break;
|
|
progress += 8;
|
|
} while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end);
|
|
|
|
arch_leave_lazy_mmu_mode();
|
|
spin_unlock(src_ptl);
|
|
pte_unmap(orig_src_pte);
|
|
add_mm_rss_vec(dst_mm, rss);
|
|
pte_unmap_unlock(orig_dst_pte, dst_ptl);
|
|
cond_resched();
|
|
|
|
if (entry.val) {
|
|
if (add_swap_count_continuation(entry, GFP_KERNEL) < 0)
|
|
return -ENOMEM;
|
|
progress = 0;
|
|
}
|
|
if (addr != end)
|
|
goto again;
|
|
return 0;
|
|
}
|
|
|
|
static inline int copy_pmd_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
pud_t *dst_pud, pud_t *src_pud, struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long end)
|
|
{
|
|
pmd_t *src_pmd, *dst_pmd;
|
|
unsigned long next;
|
|
|
|
dst_pmd = pmd_alloc(dst_mm, dst_pud, addr);
|
|
if (!dst_pmd)
|
|
return -ENOMEM;
|
|
src_pmd = pmd_offset(src_pud, addr);
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
if (is_swap_pmd(*src_pmd) || pmd_trans_huge(*src_pmd)
|
|
|| pmd_devmap(*src_pmd)) {
|
|
int err;
|
|
VM_BUG_ON_VMA(next-addr != HPAGE_PMD_SIZE, vma);
|
|
err = copy_huge_pmd(dst_mm, src_mm,
|
|
dst_pmd, src_pmd, addr, vma);
|
|
if (err == -ENOMEM)
|
|
return -ENOMEM;
|
|
if (!err)
|
|
continue;
|
|
/* fall through */
|
|
}
|
|
if (pmd_none_or_clear_bad(src_pmd))
|
|
continue;
|
|
if (copy_pte_range(dst_mm, src_mm, dst_pmd, src_pmd,
|
|
vma, addr, next))
|
|
return -ENOMEM;
|
|
} while (dst_pmd++, src_pmd++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static inline int copy_pud_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
p4d_t *dst_p4d, p4d_t *src_p4d, struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long end)
|
|
{
|
|
pud_t *src_pud, *dst_pud;
|
|
unsigned long next;
|
|
|
|
dst_pud = pud_alloc(dst_mm, dst_p4d, addr);
|
|
if (!dst_pud)
|
|
return -ENOMEM;
|
|
src_pud = pud_offset(src_p4d, addr);
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
if (pud_trans_huge(*src_pud) || pud_devmap(*src_pud)) {
|
|
int err;
|
|
|
|
VM_BUG_ON_VMA(next-addr != HPAGE_PUD_SIZE, vma);
|
|
err = copy_huge_pud(dst_mm, src_mm,
|
|
dst_pud, src_pud, addr, vma);
|
|
if (err == -ENOMEM)
|
|
return -ENOMEM;
|
|
if (!err)
|
|
continue;
|
|
/* fall through */
|
|
}
|
|
if (pud_none_or_clear_bad(src_pud))
|
|
continue;
|
|
if (copy_pmd_range(dst_mm, src_mm, dst_pud, src_pud,
|
|
vma, addr, next))
|
|
return -ENOMEM;
|
|
} while (dst_pud++, src_pud++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static inline int copy_p4d_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
pgd_t *dst_pgd, pgd_t *src_pgd, struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long end)
|
|
{
|
|
p4d_t *src_p4d, *dst_p4d;
|
|
unsigned long next;
|
|
|
|
dst_p4d = p4d_alloc(dst_mm, dst_pgd, addr);
|
|
if (!dst_p4d)
|
|
return -ENOMEM;
|
|
src_p4d = p4d_offset(src_pgd, addr);
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
if (p4d_none_or_clear_bad(src_p4d))
|
|
continue;
|
|
if (copy_pud_range(dst_mm, src_mm, dst_p4d, src_p4d,
|
|
vma, addr, next))
|
|
return -ENOMEM;
|
|
} while (dst_p4d++, src_p4d++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
|
|
struct vm_area_struct *vma)
|
|
{
|
|
pgd_t *src_pgd, *dst_pgd;
|
|
unsigned long next;
|
|
unsigned long addr = vma->vm_start;
|
|
unsigned long end = vma->vm_end;
|
|
unsigned long mmun_start; /* For mmu_notifiers */
|
|
unsigned long mmun_end; /* For mmu_notifiers */
|
|
bool is_cow;
|
|
int ret;
|
|
|
|
/*
|
|
* Don't copy ptes where a page fault will fill them correctly.
|
|
* Fork becomes much lighter when there are big shared or private
|
|
* readonly mappings. The tradeoff is that copy_page_range is more
|
|
* efficient than faulting.
|
|
*/
|
|
if (!(vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP)) &&
|
|
!vma->anon_vma)
|
|
return 0;
|
|
|
|
if (is_vm_hugetlb_page(vma))
|
|
return copy_hugetlb_page_range(dst_mm, src_mm, vma);
|
|
|
|
if (unlikely(vma->vm_flags & VM_PFNMAP)) {
|
|
/*
|
|
* We do not free on error cases below as remove_vma
|
|
* gets called on error from higher level routine
|
|
*/
|
|
ret = track_pfn_copy(vma);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* We need to invalidate the secondary MMU mappings only when
|
|
* there could be a permission downgrade on the ptes of the
|
|
* parent mm. And a permission downgrade will only happen if
|
|
* is_cow_mapping() returns true.
|
|
*/
|
|
is_cow = is_cow_mapping(vma->vm_flags);
|
|
mmun_start = addr;
|
|
mmun_end = end;
|
|
if (is_cow)
|
|
mmu_notifier_invalidate_range_start(src_mm, mmun_start,
|
|
mmun_end);
|
|
|
|
ret = 0;
|
|
dst_pgd = pgd_offset(dst_mm, addr);
|
|
src_pgd = pgd_offset(src_mm, addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
if (pgd_none_or_clear_bad(src_pgd))
|
|
continue;
|
|
if (unlikely(copy_p4d_range(dst_mm, src_mm, dst_pgd, src_pgd,
|
|
vma, addr, next))) {
|
|
ret = -ENOMEM;
|
|
break;
|
|
}
|
|
} while (dst_pgd++, src_pgd++, addr = next, addr != end);
|
|
|
|
if (is_cow)
|
|
mmu_notifier_invalidate_range_end(src_mm, mmun_start, mmun_end);
|
|
return ret;
|
|
}
|
|
|
|
static unsigned long zap_pte_range(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, pmd_t *pmd,
|
|
unsigned long addr, unsigned long end,
|
|
struct zap_details *details)
|
|
{
|
|
struct mm_struct *mm = tlb->mm;
|
|
int force_flush = 0;
|
|
int rss[NR_MM_COUNTERS];
|
|
spinlock_t *ptl;
|
|
pte_t *start_pte;
|
|
pte_t *pte;
|
|
swp_entry_t entry;
|
|
|
|
tlb_remove_check_page_size_change(tlb, PAGE_SIZE);
|
|
again:
|
|
init_rss_vec(rss);
|
|
start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
|
|
pte = start_pte;
|
|
flush_tlb_batched_pending(mm);
|
|
arch_enter_lazy_mmu_mode();
|
|
do {
|
|
pte_t ptent = *pte;
|
|
if (pte_none(ptent))
|
|
continue;
|
|
|
|
if (need_resched())
|
|
break;
|
|
|
|
if (pte_present(ptent)) {
|
|
struct page *page;
|
|
|
|
page = _vm_normal_page(vma, addr, ptent, true);
|
|
if (unlikely(details) && page) {
|
|
/*
|
|
* unmap_shared_mapping_pages() wants to
|
|
* invalidate cache without truncating:
|
|
* unmap shared but keep private pages.
|
|
*/
|
|
if (details->check_mapping &&
|
|
details->check_mapping != page_rmapping(page))
|
|
continue;
|
|
}
|
|
ptent = ptep_get_and_clear_full(mm, addr, pte,
|
|
tlb->fullmm);
|
|
tlb_remove_tlb_entry(tlb, pte, addr);
|
|
if (unlikely(!page))
|
|
continue;
|
|
|
|
if (!PageAnon(page)) {
|
|
if (pte_dirty(ptent)) {
|
|
force_flush = 1;
|
|
set_page_dirty(page);
|
|
}
|
|
if (pte_young(ptent) &&
|
|
likely(!(vma->vm_flags & VM_SEQ_READ)))
|
|
mark_page_accessed(page);
|
|
}
|
|
rss[mm_counter(page)]--;
|
|
page_remove_rmap(page, false);
|
|
if (unlikely(page_mapcount(page) < 0))
|
|
print_bad_pte(vma, addr, ptent, page);
|
|
if (unlikely(__tlb_remove_page(tlb, page))) {
|
|
force_flush = 1;
|
|
addr += PAGE_SIZE;
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
entry = pte_to_swp_entry(ptent);
|
|
if (non_swap_entry(entry) && is_device_private_entry(entry)) {
|
|
struct page *page = device_private_entry_to_page(entry);
|
|
|
|
if (unlikely(details && details->check_mapping)) {
|
|
/*
|
|
* unmap_shared_mapping_pages() wants to
|
|
* invalidate cache without truncating:
|
|
* unmap shared but keep private pages.
|
|
*/
|
|
if (details->check_mapping !=
|
|
page_rmapping(page))
|
|
continue;
|
|
}
|
|
|
|
pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
|
|
rss[mm_counter(page)]--;
|
|
page_remove_rmap(page, false);
|
|
put_page(page);
|
|
continue;
|
|
}
|
|
|
|
/* If details->check_mapping, we leave swap entries. */
|
|
if (unlikely(details))
|
|
continue;
|
|
|
|
entry = pte_to_swp_entry(ptent);
|
|
if (!non_swap_entry(entry))
|
|
rss[MM_SWAPENTS]--;
|
|
else if (is_migration_entry(entry)) {
|
|
struct page *page;
|
|
|
|
page = migration_entry_to_page(entry);
|
|
rss[mm_counter(page)]--;
|
|
}
|
|
if (unlikely(!free_swap_and_cache(entry)))
|
|
print_bad_pte(vma, addr, ptent, NULL);
|
|
pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
|
|
} while (pte++, addr += PAGE_SIZE, addr != end);
|
|
|
|
add_mm_rss_vec(mm, rss);
|
|
arch_leave_lazy_mmu_mode();
|
|
|
|
/* Do the actual TLB flush before dropping ptl */
|
|
if (force_flush)
|
|
tlb_flush_mmu_tlbonly(tlb);
|
|
pte_unmap_unlock(start_pte, ptl);
|
|
|
|
/*
|
|
* If we forced a TLB flush (either due to running out of
|
|
* batch buffers or because we needed to flush dirty TLB
|
|
* entries before releasing the ptl), free the batched
|
|
* memory too. Restart if we didn't do everything.
|
|
*/
|
|
if (force_flush) {
|
|
force_flush = 0;
|
|
tlb_flush_mmu_free(tlb);
|
|
}
|
|
|
|
if (addr != end) {
|
|
cond_resched();
|
|
goto again;
|
|
}
|
|
|
|
return addr;
|
|
}
|
|
|
|
static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, pud_t *pud,
|
|
unsigned long addr, unsigned long end,
|
|
struct zap_details *details)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
|
|
pmd = pmd_offset(pud, addr);
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
|
|
if (next - addr != HPAGE_PMD_SIZE)
|
|
__split_huge_pmd(vma, pmd, addr, false, NULL);
|
|
else if (zap_huge_pmd(tlb, vma, pmd, addr))
|
|
goto next;
|
|
/* fall through */
|
|
}
|
|
/*
|
|
* 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
|
|
* mode.
|
|
*/
|
|
if (pmd_none_or_trans_huge_or_clear_bad(pmd))
|
|
goto next;
|
|
next = zap_pte_range(tlb, vma, pmd, addr, next, details);
|
|
next:
|
|
cond_resched();
|
|
} while (pmd++, addr = next, addr != end);
|
|
|
|
return addr;
|
|
}
|
|
|
|
static inline unsigned long zap_pud_range(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, p4d_t *p4d,
|
|
unsigned long addr, unsigned long end,
|
|
struct zap_details *details)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
|
|
pud = pud_offset(p4d, addr);
|
|
do {
|
|
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);
|
|
split_huge_pud(vma, pud, addr);
|
|
} else if (zap_huge_pud(tlb, vma, pud, addr))
|
|
goto next;
|
|
/* fall through */
|
|
}
|
|
if (pud_none_or_clear_bad(pud))
|
|
continue;
|
|
next = zap_pmd_range(tlb, vma, pud, addr, next, details);
|
|
next:
|
|
cond_resched();
|
|
} while (pud++, addr = next, addr != end);
|
|
|
|
return addr;
|
|
}
|
|
|
|
static inline unsigned long zap_p4d_range(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, pgd_t *pgd,
|
|
unsigned long addr, unsigned long end,
|
|
struct zap_details *details)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
|
|
p4d = p4d_offset(pgd, addr);
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
if (p4d_none_or_clear_bad(p4d))
|
|
continue;
|
|
next = zap_pud_range(tlb, vma, p4d, addr, next, details);
|
|
} while (p4d++, addr = next, addr != end);
|
|
|
|
return addr;
|
|
}
|
|
|
|
void unmap_page_range(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long end,
|
|
struct zap_details *details)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
|
|
BUG_ON(addr >= end);
|
|
vm_write_begin(vma);
|
|
tlb_start_vma(tlb, vma);
|
|
pgd = pgd_offset(vma->vm_mm, addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
if (pgd_none_or_clear_bad(pgd))
|
|
continue;
|
|
next = zap_p4d_range(tlb, vma, pgd, addr, next, details);
|
|
} while (pgd++, addr = next, addr != end);
|
|
tlb_end_vma(tlb, vma);
|
|
vm_write_end(vma);
|
|
}
|
|
|
|
|
|
static void unmap_single_vma(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, unsigned long start_addr,
|
|
unsigned long end_addr,
|
|
struct zap_details *details)
|
|
{
|
|
unsigned long start = max(vma->vm_start, start_addr);
|
|
unsigned long end;
|
|
|
|
if (start >= vma->vm_end)
|
|
return;
|
|
end = min(vma->vm_end, end_addr);
|
|
if (end <= vma->vm_start)
|
|
return;
|
|
|
|
if (vma->vm_file)
|
|
uprobe_munmap(vma, start, end);
|
|
|
|
if (unlikely(vma->vm_flags & VM_PFNMAP))
|
|
untrack_pfn(vma, 0, 0);
|
|
|
|
if (start != end) {
|
|
if (unlikely(is_vm_hugetlb_page(vma))) {
|
|
/*
|
|
* It is undesirable to test vma->vm_file as it
|
|
* should be non-null for valid hugetlb area.
|
|
* However, vm_file will be NULL in the error
|
|
* cleanup path of mmap_region. When
|
|
* hugetlbfs ->mmap method fails,
|
|
* mmap_region() nullifies vma->vm_file
|
|
* before calling this function to clean up.
|
|
* Since no pte has actually been setup, it is
|
|
* safe to do nothing in this case.
|
|
*/
|
|
if (vma->vm_file) {
|
|
i_mmap_lock_write(vma->vm_file->f_mapping);
|
|
__unmap_hugepage_range_final(tlb, vma, start, end, NULL);
|
|
i_mmap_unlock_write(vma->vm_file->f_mapping);
|
|
}
|
|
} else
|
|
unmap_page_range(tlb, vma, start, end, details);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* unmap_vmas - unmap a range of memory covered by a list of vma's
|
|
* @tlb: address of the caller's struct mmu_gather
|
|
* @vma: the starting vma
|
|
* @start_addr: virtual address at which to start unmapping
|
|
* @end_addr: virtual address at which to end unmapping
|
|
*
|
|
* Unmap all pages in the vma list.
|
|
*
|
|
* Only addresses between `start' and `end' will be unmapped.
|
|
*
|
|
* The VMA list must be sorted in ascending virtual address order.
|
|
*
|
|
* unmap_vmas() assumes that the caller will flush the whole unmapped address
|
|
* range after unmap_vmas() returns. So the only responsibility here is to
|
|
* ensure that any thus-far unmapped pages are flushed before unmap_vmas()
|
|
* drops the lock and schedules.
|
|
*/
|
|
void unmap_vmas(struct mmu_gather *tlb,
|
|
struct vm_area_struct *vma, unsigned long start_addr,
|
|
unsigned long end_addr)
|
|
{
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
|
|
mmu_notifier_invalidate_range_start(mm, start_addr, end_addr);
|
|
for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next)
|
|
unmap_single_vma(tlb, vma, start_addr, end_addr, NULL);
|
|
mmu_notifier_invalidate_range_end(mm, start_addr, end_addr);
|
|
}
|
|
|
|
/**
|
|
* zap_page_range - remove user pages in a given range
|
|
* @vma: vm_area_struct holding the applicable pages
|
|
* @start: starting address of pages to zap
|
|
* @size: number of bytes to zap
|
|
*
|
|
* Caller must protect the VMA list
|
|
*/
|
|
void zap_page_range(struct vm_area_struct *vma, unsigned long start,
|
|
unsigned long size)
|
|
{
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
struct mmu_gather tlb;
|
|
unsigned long end = start + size;
|
|
|
|
lru_add_drain();
|
|
tlb_gather_mmu(&tlb, mm, start, end);
|
|
update_hiwater_rss(mm);
|
|
mmu_notifier_invalidate_range_start(mm, start, end);
|
|
for ( ; vma && vma->vm_start < end; vma = vma->vm_next)
|
|
unmap_single_vma(&tlb, vma, start, end, NULL);
|
|
mmu_notifier_invalidate_range_end(mm, start, end);
|
|
tlb_finish_mmu(&tlb, start, end);
|
|
}
|
|
|
|
/**
|
|
* zap_page_range_single - remove user pages in a given range
|
|
* @vma: vm_area_struct holding the applicable pages
|
|
* @address: starting address of pages to zap
|
|
* @size: number of bytes to zap
|
|
* @details: details of shared cache invalidation
|
|
*
|
|
* The range must fit into one VMA.
|
|
*/
|
|
static void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,
|
|
unsigned long size, struct zap_details *details)
|
|
{
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
struct mmu_gather tlb;
|
|
unsigned long end = address + size;
|
|
|
|
lru_add_drain();
|
|
tlb_gather_mmu(&tlb, mm, address, end);
|
|
update_hiwater_rss(mm);
|
|
mmu_notifier_invalidate_range_start(mm, address, end);
|
|
unmap_single_vma(&tlb, vma, address, end, details);
|
|
mmu_notifier_invalidate_range_end(mm, address, end);
|
|
tlb_finish_mmu(&tlb, address, end);
|
|
}
|
|
|
|
/**
|
|
* zap_vma_ptes - remove ptes mapping the vma
|
|
* @vma: vm_area_struct holding ptes to be zapped
|
|
* @address: starting address of pages to zap
|
|
* @size: number of bytes to zap
|
|
*
|
|
* This function only unmaps ptes assigned to VM_PFNMAP vmas.
|
|
*
|
|
* The entire address range must be fully contained within the vma.
|
|
*
|
|
*/
|
|
void zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
|
|
unsigned long size)
|
|
{
|
|
if (address < vma->vm_start || address + size > vma->vm_end ||
|
|
!(vma->vm_flags & VM_PFNMAP))
|
|
return;
|
|
|
|
zap_page_range_single(vma, address, size, NULL);
|
|
}
|
|
EXPORT_SYMBOL_GPL(zap_vma_ptes);
|
|
|
|
pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
|
|
spinlock_t **ptl)
|
|
{
|
|
pgd_t *pgd;
|
|
p4d_t *p4d;
|
|
pud_t *pud;
|
|
pmd_t *pmd;
|
|
|
|
pgd = pgd_offset(mm, addr);
|
|
p4d = p4d_alloc(mm, pgd, addr);
|
|
if (!p4d)
|
|
return NULL;
|
|
pud = pud_alloc(mm, p4d, addr);
|
|
if (!pud)
|
|
return NULL;
|
|
pmd = pmd_alloc(mm, pud, addr);
|
|
if (!pmd)
|
|
return NULL;
|
|
|
|
VM_BUG_ON(pmd_trans_huge(*pmd));
|
|
return pte_alloc_map_lock(mm, pmd, addr, ptl);
|
|
}
|
|
|
|
/*
|
|
* This is the old fallback for page remapping.
|
|
*
|
|
* For historical reasons, it only allows reserved pages. Only
|
|
* old drivers should use this, and they needed to mark their
|
|
* pages reserved for the old functions anyway.
|
|
*/
|
|
static int insert_page(struct vm_area_struct *vma, unsigned long addr,
|
|
struct page *page, pgprot_t prot)
|
|
{
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
int retval;
|
|
pte_t *pte;
|
|
spinlock_t *ptl;
|
|
|
|
retval = -EINVAL;
|
|
if (PageAnon(page))
|
|
goto out;
|
|
retval = -ENOMEM;
|
|
flush_dcache_page(page);
|
|
pte = get_locked_pte(mm, addr, &ptl);
|
|
if (!pte)
|
|
goto out;
|
|
retval = -EBUSY;
|
|
if (!pte_none(*pte))
|
|
goto out_unlock;
|
|
|
|
/* Ok, finally just insert the thing.. */
|
|
get_page(page);
|
|
inc_mm_counter_fast(mm, mm_counter_file(page));
|
|
page_add_file_rmap(page, false);
|
|
set_pte_at(mm, addr, pte, mk_pte(page, prot));
|
|
|
|
retval = 0;
|
|
pte_unmap_unlock(pte, ptl);
|
|
return retval;
|
|
out_unlock:
|
|
pte_unmap_unlock(pte, ptl);
|
|
out:
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* vm_insert_page - insert single page into user vma
|
|
* @vma: user vma to map to
|
|
* @addr: target user address of this page
|
|
* @page: source kernel page
|
|
*
|
|
* This allows drivers to insert individual pages they've allocated
|
|
* into a user vma.
|
|
*
|
|
* The page has to be a nice clean _individual_ kernel allocation.
|
|
* If you allocate a compound page, you need to have marked it as
|
|
* such (__GFP_COMP), or manually just split the page up yourself
|
|
* (see split_page()).
|
|
*
|
|
* NOTE! Traditionally this was done with "remap_pfn_range()" which
|
|
* took an arbitrary page protection parameter. This doesn't allow
|
|
* that. Your vma protection will have to be set up correctly, which
|
|
* means that if you want a shared writable mapping, you'd better
|
|
* ask for a shared writable mapping!
|
|
*
|
|
* 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.
|
|
* Caller must set VM_MIXEDMAP on vma if it wants to call this
|
|
* function from other places, for example from page-fault handler.
|
|
*/
|
|
int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
|
|
struct page *page)
|
|
{
|
|
if (addr < vma->vm_start || addr >= vma->vm_end)
|
|
return -EFAULT;
|
|
if (!page_count(page))
|
|
return -EINVAL;
|
|
if (!(vma->vm_flags & VM_MIXEDMAP)) {
|
|
BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
|
|
BUG_ON(vma->vm_flags & VM_PFNMAP);
|
|
vma->vm_flags |= VM_MIXEDMAP;
|
|
}
|
|
return insert_page(vma, addr, page, vma->vm_page_prot);
|
|
}
|
|
EXPORT_SYMBOL(vm_insert_page);
|
|
|
|
static int insert_pfn(struct vm_area_struct *vma, unsigned long addr,
|
|
pfn_t pfn, pgprot_t prot, bool mkwrite)
|
|
{
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
int retval;
|
|
pte_t *pte, entry;
|
|
spinlock_t *ptl;
|
|
|
|
retval = -ENOMEM;
|
|
pte = get_locked_pte(mm, addr, &ptl);
|
|
if (!pte)
|
|
goto out;
|
|
retval = -EBUSY;
|
|
if (!pte_none(*pte)) {
|
|
if (mkwrite) {
|
|
/*
|
|
* For read faults on private mappings the PFN passed
|
|
* in may not match the PFN we have mapped if the
|
|
* mapped PFN is a writeable COW page. In the mkwrite
|
|
* case we are creating a writable PTE for a shared
|
|
* mapping and we expect the PFNs to match. If they
|
|
* don't match, we are likely racing with block
|
|
* allocation and mapping invalidation so just skip the
|
|
* update.
|
|
*/
|
|
if (pte_pfn(*pte) != pfn_t_to_pfn(pfn)) {
|
|
WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte)));
|
|
goto out_unlock;
|
|
}
|
|
entry = pte_mkyoung(*pte);
|
|
entry = maybe_mkwrite(pte_mkdirty(entry), vma->vm_flags);
|
|
if (ptep_set_access_flags(vma, addr, pte, entry, 1))
|
|
update_mmu_cache(vma, addr, pte);
|
|
}
|
|
goto out_unlock;
|
|
}
|
|
|
|
/* Ok, finally just insert the thing.. */
|
|
if (pfn_t_devmap(pfn))
|
|
entry = pte_mkdevmap(pfn_t_pte(pfn, prot));
|
|
else
|
|
entry = pte_mkspecial(pfn_t_pte(pfn, prot));
|
|
|
|
if (mkwrite) {
|
|
entry = pte_mkyoung(entry);
|
|
entry = maybe_mkwrite(pte_mkdirty(entry), vma->vm_flags);
|
|
}
|
|
|
|
set_pte_at(mm, addr, pte, entry);
|
|
update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
|
|
|
|
retval = 0;
|
|
out_unlock:
|
|
pte_unmap_unlock(pte, ptl);
|
|
out:
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* vm_insert_pfn - insert single pfn into user vma
|
|
* @vma: user vma to map to
|
|
* @addr: target user address of this page
|
|
* @pfn: source kernel pfn
|
|
*
|
|
* Similar to vm_insert_page, this allows drivers to insert individual pages
|
|
* they've allocated into a user vma. Same comments apply.
|
|
*
|
|
* This function should only be called from a vm_ops->fault handler, and
|
|
* in that case the handler should return NULL.
|
|
*
|
|
* vma cannot be a COW mapping.
|
|
*
|
|
* As this is called only for pages that do not currently exist, we
|
|
* do not need to flush old virtual caches or the TLB.
|
|
*/
|
|
int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
|
|
unsigned long pfn)
|
|
{
|
|
return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot);
|
|
}
|
|
EXPORT_SYMBOL(vm_insert_pfn);
|
|
|
|
/**
|
|
* vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot
|
|
* @vma: user vma to map to
|
|
* @addr: target user address of this page
|
|
* @pfn: source kernel pfn
|
|
* @pgprot: pgprot flags for the inserted page
|
|
*
|
|
* This is exactly like vm_insert_pfn, except that it allows drivers to
|
|
* to override pgprot on a per-page basis.
|
|
*
|
|
* This only makes sense for IO mappings, and it makes no sense for
|
|
* cow mappings. In general, using multiple vmas is preferable;
|
|
* vm_insert_pfn_prot should only be used if using multiple VMAs is
|
|
* impractical.
|
|
*/
|
|
int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
|
|
unsigned long pfn, pgprot_t pgprot)
|
|
{
|
|
int ret;
|
|
/*
|
|
* Technically, architectures with pte_special can avoid all these
|
|
* restrictions (same for remap_pfn_range). However we would like
|
|
* consistency in testing and feature parity among all, so we should
|
|
* try to keep these invariants in place for everybody.
|
|
*/
|
|
BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)));
|
|
BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) ==
|
|
(VM_PFNMAP|VM_MIXEDMAP));
|
|
BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags));
|
|
BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn));
|
|
|
|
if (addr < vma->vm_start || addr >= vma->vm_end)
|
|
return -EFAULT;
|
|
|
|
if (!pfn_modify_allowed(pfn, pgprot))
|
|
return -EACCES;
|
|
|
|
track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV));
|
|
|
|
ret = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot,
|
|
false);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(vm_insert_pfn_prot);
|
|
|
|
static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn)
|
|
{
|
|
/* these checks mirror the abort conditions in vm_normal_page */
|
|
if (vma->vm_flags & VM_MIXEDMAP)
|
|
return true;
|
|
if (pfn_t_devmap(pfn))
|
|
return true;
|
|
if (pfn_t_special(pfn))
|
|
return true;
|
|
if (is_zero_pfn(pfn_t_to_pfn(pfn)))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
static int __vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
|
|
pfn_t pfn, bool mkwrite)
|
|
{
|
|
pgprot_t pgprot = vma->vm_page_prot;
|
|
|
|
BUG_ON(!vm_mixed_ok(vma, pfn));
|
|
|
|
if (addr < vma->vm_start || addr >= vma->vm_end)
|
|
return -EFAULT;
|
|
|
|
track_pfn_insert(vma, &pgprot, pfn);
|
|
|
|
if (!pfn_modify_allowed(pfn_t_to_pfn(pfn), pgprot))
|
|
return -EACCES;
|
|
|
|
/*
|
|
* If we don't have pte special, then we have to use the pfn_valid()
|
|
* based VM_MIXEDMAP scheme (see vm_normal_page), and thus we *must*
|
|
* refcount the page if pfn_valid is true (hence insert_page rather
|
|
* than insert_pfn). If a zero_pfn were inserted into a VM_MIXEDMAP
|
|
* without pte special, it would there be refcounted as a normal page.
|
|
*/
|
|
if (!IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) &&
|
|
!pfn_t_devmap(pfn) && pfn_t_valid(pfn)) {
|
|
struct page *page;
|
|
|
|
/*
|
|
* At this point we are committed to insert_page()
|
|
* regardless of whether the caller specified flags that
|
|
* result in pfn_t_has_page() == false.
|
|
*/
|
|
page = pfn_to_page(pfn_t_to_pfn(pfn));
|
|
return insert_page(vma, addr, page, pgprot);
|
|
}
|
|
return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
|
|
}
|
|
|
|
int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
|
|
pfn_t pfn)
|
|
{
|
|
return __vm_insert_mixed(vma, addr, pfn, false);
|
|
|
|
}
|
|
EXPORT_SYMBOL(vm_insert_mixed);
|
|
|
|
/*
|
|
* If the insertion of PTE failed because someone else already added a
|
|
* different entry in the mean time, we treat that as success as we assume
|
|
* the same entry was actually inserted.
|
|
*/
|
|
|
|
vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
|
|
unsigned long addr, pfn_t pfn)
|
|
{
|
|
int err;
|
|
|
|
err = __vm_insert_mixed(vma, addr, pfn, true);
|
|
if (err == -ENOMEM)
|
|
return VM_FAULT_OOM;
|
|
if (err < 0 && err != -EBUSY)
|
|
return VM_FAULT_SIGBUS;
|
|
return VM_FAULT_NOPAGE;
|
|
}
|
|
EXPORT_SYMBOL(vmf_insert_mixed_mkwrite);
|
|
|
|
/*
|
|
* maps a range of physical memory into the requested pages. the old
|
|
* mappings are removed. any references to nonexistent pages results
|
|
* in null mappings (currently treated as "copy-on-access")
|
|
*/
|
|
static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long pfn, pgprot_t prot)
|
|
{
|
|
pte_t *pte;
|
|
spinlock_t *ptl;
|
|
int err = 0;
|
|
|
|
pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
|
|
if (!pte)
|
|
return -ENOMEM;
|
|
arch_enter_lazy_mmu_mode();
|
|
do {
|
|
BUG_ON(!pte_none(*pte));
|
|
if (!pfn_modify_allowed(pfn, prot)) {
|
|
err = -EACCES;
|
|
break;
|
|
}
|
|
set_pte_at(mm, addr, pte, pte_mkspecial(pfn_pte(pfn, prot)));
|
|
pfn++;
|
|
} while (pte++, addr += PAGE_SIZE, addr != end);
|
|
arch_leave_lazy_mmu_mode();
|
|
pte_unmap_unlock(pte - 1, ptl);
|
|
return err;
|
|
}
|
|
|
|
static inline int remap_pmd_range(struct mm_struct *mm, pud_t *pud,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long pfn, pgprot_t prot)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
pfn -= addr >> PAGE_SHIFT;
|
|
pmd = pmd_alloc(mm, pud, addr);
|
|
if (!pmd)
|
|
return -ENOMEM;
|
|
VM_BUG_ON(pmd_trans_huge(*pmd));
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
err = remap_pte_range(mm, pmd, addr, next,
|
|
pfn + (addr >> PAGE_SHIFT), prot);
|
|
if (err)
|
|
return err;
|
|
} while (pmd++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static inline int remap_pud_range(struct mm_struct *mm, p4d_t *p4d,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long pfn, pgprot_t prot)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
pfn -= addr >> PAGE_SHIFT;
|
|
pud = pud_alloc(mm, p4d, addr);
|
|
if (!pud)
|
|
return -ENOMEM;
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
err = remap_pmd_range(mm, pud, addr, next,
|
|
pfn + (addr >> PAGE_SHIFT), prot);
|
|
if (err)
|
|
return err;
|
|
} while (pud++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd,
|
|
unsigned long addr, unsigned long end,
|
|
unsigned long pfn, pgprot_t prot)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
pfn -= addr >> PAGE_SHIFT;
|
|
p4d = p4d_alloc(mm, pgd, addr);
|
|
if (!p4d)
|
|
return -ENOMEM;
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
err = remap_pud_range(mm, p4d, addr, next,
|
|
pfn + (addr >> PAGE_SHIFT), prot);
|
|
if (err)
|
|
return err;
|
|
} while (p4d++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* remap_pfn_range - remap kernel memory to userspace
|
|
* @vma: user vma to map to
|
|
* @addr: target user address to start at
|
|
* @pfn: physical address of kernel memory
|
|
* @size: size of map area
|
|
* @prot: page protection flags for this mapping
|
|
*
|
|
* Note: this is only safe if the mm semaphore is held when called.
|
|
*/
|
|
int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
|
|
unsigned long pfn, unsigned long size, pgprot_t prot)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
unsigned long end = addr + PAGE_ALIGN(size);
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
unsigned long remap_pfn = pfn;
|
|
int err;
|
|
|
|
/*
|
|
* Physically remapped pages are special. Tell the
|
|
* rest of the world about it:
|
|
* VM_IO tells people not to look at these pages
|
|
* (accesses can have side effects).
|
|
* VM_PFNMAP tells the core MM that the base pages are just
|
|
* raw PFN mappings, and do not have a "struct page" associated
|
|
* with them.
|
|
* VM_DONTEXPAND
|
|
* Disable vma merging and expanding with mremap().
|
|
* VM_DONTDUMP
|
|
* Omit vma from core dump, even when VM_IO turned off.
|
|
*
|
|
* There's a horrible special case to handle copy-on-write
|
|
* behaviour that some programs depend on. We mark the "original"
|
|
* un-COW'ed pages by matching them up with "vma->vm_pgoff".
|
|
* See vm_normal_page() for details.
|
|
*/
|
|
if (is_cow_mapping(vma->vm_flags)) {
|
|
if (addr != vma->vm_start || end != vma->vm_end)
|
|
return -EINVAL;
|
|
vma->vm_pgoff = pfn;
|
|
}
|
|
|
|
err = track_pfn_remap(vma, &prot, remap_pfn, addr, PAGE_ALIGN(size));
|
|
if (err)
|
|
return -EINVAL;
|
|
|
|
vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
|
|
|
|
BUG_ON(addr >= end);
|
|
pfn -= addr >> PAGE_SHIFT;
|
|
pgd = pgd_offset(mm, addr);
|
|
flush_cache_range(vma, addr, end);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
err = remap_p4d_range(mm, pgd, addr, next,
|
|
pfn + (addr >> PAGE_SHIFT), prot);
|
|
if (err)
|
|
break;
|
|
} while (pgd++, addr = next, addr != end);
|
|
|
|
if (err)
|
|
untrack_pfn(vma, remap_pfn, PAGE_ALIGN(size));
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL(remap_pfn_range);
|
|
|
|
/**
|
|
* vm_iomap_memory - remap memory to userspace
|
|
* @vma: user vma to map to
|
|
* @start: start of area
|
|
* @len: size of area
|
|
*
|
|
* This is a simplified io_remap_pfn_range() for common driver use. The
|
|
* driver just needs to give us the physical memory range to be mapped,
|
|
* we'll figure out the rest from the vma information.
|
|
*
|
|
* NOTE! Some drivers might want to tweak vma->vm_page_prot first to get
|
|
* whatever write-combining details or similar.
|
|
*/
|
|
int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len)
|
|
{
|
|
unsigned long vm_len, pfn, pages;
|
|
|
|
/* Check that the physical memory area passed in looks valid */
|
|
if (start + len < start)
|
|
return -EINVAL;
|
|
/*
|
|
* You *really* shouldn't map things that aren't page-aligned,
|
|
* but we've historically allowed it because IO memory might
|
|
* just have smaller alignment.
|
|
*/
|
|
len += start & ~PAGE_MASK;
|
|
pfn = start >> PAGE_SHIFT;
|
|
pages = (len + ~PAGE_MASK) >> PAGE_SHIFT;
|
|
if (pfn + pages < pfn)
|
|
return -EINVAL;
|
|
|
|
/* We start the mapping 'vm_pgoff' pages into the area */
|
|
if (vma->vm_pgoff > pages)
|
|
return -EINVAL;
|
|
pfn += vma->vm_pgoff;
|
|
pages -= vma->vm_pgoff;
|
|
|
|
/* Can we fit all of the mapping? */
|
|
vm_len = vma->vm_end - vma->vm_start;
|
|
if (vm_len >> PAGE_SHIFT > pages)
|
|
return -EINVAL;
|
|
|
|
/* Ok, let it rip */
|
|
return io_remap_pfn_range(vma, vma->vm_start, pfn, vm_len, vma->vm_page_prot);
|
|
}
|
|
EXPORT_SYMBOL(vm_iomap_memory);
|
|
|
|
static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
|
|
unsigned long addr, unsigned long end,
|
|
pte_fn_t fn, void *data)
|
|
{
|
|
pte_t *pte;
|
|
int err;
|
|
pgtable_t token;
|
|
spinlock_t *uninitialized_var(ptl);
|
|
|
|
pte = (mm == &init_mm) ?
|
|
pte_alloc_kernel(pmd, addr) :
|
|
pte_alloc_map_lock(mm, pmd, addr, &ptl);
|
|
if (!pte)
|
|
return -ENOMEM;
|
|
|
|
BUG_ON(pmd_huge(*pmd));
|
|
|
|
arch_enter_lazy_mmu_mode();
|
|
|
|
token = pmd_pgtable(*pmd);
|
|
|
|
do {
|
|
err = fn(pte++, token, addr, data);
|
|
if (err)
|
|
break;
|
|
} while (addr += PAGE_SIZE, addr != end);
|
|
|
|
arch_leave_lazy_mmu_mode();
|
|
|
|
if (mm != &init_mm)
|
|
pte_unmap_unlock(pte-1, ptl);
|
|
return err;
|
|
}
|
|
|
|
static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
|
|
unsigned long addr, unsigned long end,
|
|
pte_fn_t fn, void *data)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
BUG_ON(pud_huge(*pud));
|
|
|
|
pmd = pmd_alloc(mm, pud, addr);
|
|
if (!pmd)
|
|
return -ENOMEM;
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
err = apply_to_pte_range(mm, pmd, addr, next, fn, data);
|
|
if (err)
|
|
break;
|
|
} while (pmd++, addr = next, addr != end);
|
|
return err;
|
|
}
|
|
|
|
static int apply_to_pud_range(struct mm_struct *mm, p4d_t *p4d,
|
|
unsigned long addr, unsigned long end,
|
|
pte_fn_t fn, void *data)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
pud = pud_alloc(mm, p4d, addr);
|
|
if (!pud)
|
|
return -ENOMEM;
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
err = apply_to_pmd_range(mm, pud, addr, next, fn, data);
|
|
if (err)
|
|
break;
|
|
} while (pud++, addr = next, addr != end);
|
|
return err;
|
|
}
|
|
|
|
static int apply_to_p4d_range(struct mm_struct *mm, pgd_t *pgd,
|
|
unsigned long addr, unsigned long end,
|
|
pte_fn_t fn, void *data)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
int err;
|
|
|
|
p4d = p4d_alloc(mm, pgd, addr);
|
|
if (!p4d)
|
|
return -ENOMEM;
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
err = apply_to_pud_range(mm, p4d, addr, next, fn, data);
|
|
if (err)
|
|
break;
|
|
} while (p4d++, addr = next, addr != end);
|
|
return err;
|
|
}
|
|
|
|
/*
|
|
* Scan a region of virtual memory, filling in page tables as necessary
|
|
* and calling a provided function on each leaf page table.
|
|
*/
|
|
int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
|
|
unsigned long size, pte_fn_t fn, void *data)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
unsigned long end = addr + size;
|
|
int err;
|
|
|
|
if (WARN_ON(addr >= end))
|
|
return -EINVAL;
|
|
|
|
pgd = pgd_offset(mm, addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
err = apply_to_p4d_range(mm, pgd, addr, next, fn, data);
|
|
if (err)
|
|
break;
|
|
} while (pgd++, addr = next, addr != end);
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(apply_to_page_range);
|
|
|
|
#ifdef CONFIG_SPECULATIVE_PAGE_FAULT
|
|
static bool pte_spinlock(struct vm_fault *vmf)
|
|
{
|
|
bool ret = false;
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
pmd_t pmdval;
|
|
#endif
|
|
|
|
/* Check if vma is still valid */
|
|
if (!(vmf->flags & FAULT_FLAG_SPECULATIVE)) {
|
|
vmf->ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd);
|
|
spin_lock(vmf->ptl);
|
|
return true;
|
|
}
|
|
|
|
local_irq_disable();
|
|
if (vma_has_changed(vmf)) {
|
|
trace_spf_vma_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
/*
|
|
* We check if the pmd value is still the same to ensure that there
|
|
* is not a huge collapse operation in progress in our back.
|
|
*/
|
|
pmdval = READ_ONCE(*vmf->pmd);
|
|
if (!pmd_same(pmdval, vmf->orig_pmd)) {
|
|
trace_spf_pmd_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
#endif
|
|
|
|
vmf->ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd);
|
|
if (unlikely(!spin_trylock(vmf->ptl))) {
|
|
trace_spf_pte_lock(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
if (vma_has_changed(vmf)) {
|
|
spin_unlock(vmf->ptl);
|
|
trace_spf_vma_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
ret = true;
|
|
out:
|
|
local_irq_enable();
|
|
return ret;
|
|
}
|
|
|
|
static bool pte_map_lock(struct vm_fault *vmf)
|
|
{
|
|
bool ret = false;
|
|
pte_t *pte;
|
|
spinlock_t *ptl;
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
pmd_t pmdval;
|
|
#endif
|
|
|
|
if (!(vmf->flags & FAULT_FLAG_SPECULATIVE)) {
|
|
vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd,
|
|
vmf->address, &vmf->ptl);
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* The first vma_has_changed() guarantees the page-tables are still
|
|
* valid, having IRQs disabled ensures they stay around, hence the
|
|
* second vma_has_changed() to make sure they are still valid once
|
|
* we've got the lock. After that a concurrent zap_pte_range() will
|
|
* block on the PTL and thus we're safe.
|
|
*/
|
|
local_irq_disable();
|
|
if (vma_has_changed(vmf)) {
|
|
trace_spf_vma_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
/*
|
|
* We check if the pmd value is still the same to ensure that there
|
|
* is not a huge collapse operation in progress in our back.
|
|
*/
|
|
pmdval = READ_ONCE(*vmf->pmd);
|
|
if (!pmd_same(pmdval, vmf->orig_pmd)) {
|
|
trace_spf_pmd_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* Same as pte_offset_map_lock() except that we call
|
|
* spin_trylock() in place of spin_lock() to avoid race with
|
|
* unmap path which may have the lock and wait for this CPU
|
|
* to invalidate TLB but this CPU has irq disabled.
|
|
* Since we are in a speculative patch, accept it could fail
|
|
*/
|
|
ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd);
|
|
pte = pte_offset_map(vmf->pmd, vmf->address);
|
|
if (unlikely(!spin_trylock(ptl))) {
|
|
pte_unmap(pte);
|
|
trace_spf_pte_lock(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
if (vma_has_changed(vmf)) {
|
|
pte_unmap_unlock(pte, ptl);
|
|
trace_spf_vma_changed(_RET_IP_, vmf->vma, vmf->address);
|
|
goto out;
|
|
}
|
|
|
|
vmf->pte = pte;
|
|
vmf->ptl = ptl;
|
|
ret = true;
|
|
out:
|
|
local_irq_enable();
|
|
return ret;
|
|
}
|
|
#else
|
|
static inline bool pte_spinlock(struct vm_fault *vmf)
|
|
{
|
|
vmf->ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd);
|
|
spin_lock(vmf->ptl);
|
|
return true;
|
|
}
|
|
|
|
static inline bool pte_map_lock(struct vm_fault *vmf)
|
|
{
|
|
vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd,
|
|
vmf->address, &vmf->ptl);
|
|
return true;
|
|
}
|
|
#endif /* CONFIG_SPECULATIVE_PAGE_FAULT */
|
|
|
|
/*
|
|
* handle_pte_fault chooses page fault handler according to an entry which was
|
|
* read non-atomically. Before making any commitment, on those architectures
|
|
* or configurations (e.g. i386 with PAE) which might give a mix of unmatched
|
|
* parts, do_swap_page must check under lock before unmapping the pte and
|
|
* proceeding (but do_wp_page is only called after already making such a check;
|
|
* and do_anonymous_page can safely check later on).
|
|
*
|
|
* pte_unmap_same() returns:
|
|
* 0 if the PTE are the same
|
|
* VM_FAULT_PTNOTSAME if the PTE are different
|
|
* VM_FAULT_RETRY if the VMA has changed in our back during
|
|
* a speculative page fault handling.
|
|
*/
|
|
static inline int pte_unmap_same(struct vm_fault *vmf)
|
|
{
|
|
int ret = 0;
|
|
|
|
#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
|
|
if (sizeof(pte_t) > sizeof(unsigned long)) {
|
|
if (pte_spinlock(vmf)) {
|
|
if (!pte_same(*vmf->pte, vmf->orig_pte))
|
|
ret = VM_FAULT_PTNOTSAME;
|
|
spin_unlock(vmf->ptl);
|
|
} else
|
|
ret = VM_FAULT_RETRY;
|
|
}
|
|
#endif
|
|
pte_unmap(vmf->pte);
|
|
return ret;
|
|
}
|
|
|
|
static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)
|
|
{
|
|
debug_dma_assert_idle(src);
|
|
|
|
/*
|
|
* If the source page was a PFN mapping, we don't have
|
|
* a "struct page" for it. We do a best-effort copy by
|
|
* just copying from the original user address. If that
|
|
* fails, we just zero-fill it. Live with it.
|
|
*/
|
|
if (unlikely(!src)) {
|
|
void *kaddr = kmap_atomic(dst);
|
|
void __user *uaddr = (void __user *)(va & PAGE_MASK);
|
|
|
|
/*
|
|
* This really shouldn't fail, because the page is there
|
|
* in the page tables. But it might just be unreadable,
|
|
* in which case we just give up and fill the result with
|
|
* zeroes.
|
|
*/
|
|
if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
|
|
clear_page(kaddr);
|
|
kunmap_atomic(kaddr);
|
|
flush_dcache_page(dst);
|
|
} else
|
|
copy_user_highpage(dst, src, va, vma);
|
|
}
|
|
|
|
static gfp_t __get_fault_gfp_mask(struct vm_area_struct *vma)
|
|
{
|
|
struct file *vm_file = vma->vm_file;
|
|
|
|
if (vm_file)
|
|
return mapping_gfp_mask(vm_file->f_mapping) | __GFP_FS | __GFP_IO;
|
|
|
|
/*
|
|
* Special mappings (e.g. VDSO) do not have any file so fake
|
|
* a default GFP_KERNEL for them.
|
|
*/
|
|
return GFP_KERNEL;
|
|
}
|
|
|
|
/*
|
|
* Notify the address space that the page is about to become writable so that
|
|
* it can prohibit this or wait for the page to get into an appropriate state.
|
|
*
|
|
* We do this without the lock held, so that it can sleep if it needs to.
|
|
*/
|
|
static vm_fault_t do_page_mkwrite(struct vm_fault *vmf)
|
|
{
|
|
vm_fault_t ret;
|
|
struct page *page = vmf->page;
|
|
unsigned int old_flags = vmf->flags;
|
|
|
|
vmf->flags = FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE;
|
|
|
|
if (vmf->vma->vm_file &&
|
|
IS_SWAPFILE(vmf->vma->vm_file->f_mapping->host))
|
|
return VM_FAULT_SIGBUS;
|
|
|
|
ret = vmf->vma->vm_ops->page_mkwrite(vmf);
|
|
/* Restore original flags so that caller is not surprised */
|
|
vmf->flags = old_flags;
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))
|
|
return ret;
|
|
if (unlikely(!(ret & VM_FAULT_LOCKED))) {
|
|
lock_page(page);
|
|
if (!page->mapping) {
|
|
unlock_page(page);
|
|
return 0; /* retry */
|
|
}
|
|
ret |= VM_FAULT_LOCKED;
|
|
} else
|
|
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Handle dirtying of a page in shared file mapping on a write fault.
|
|
*
|
|
* The function expects the page to be locked and unlocks it.
|
|
*/
|
|
static void fault_dirty_shared_page(struct vm_area_struct *vma,
|
|
struct page *page)
|
|
{
|
|
struct address_space *mapping;
|
|
bool dirtied;
|
|
bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite;
|
|
|
|
dirtied = set_page_dirty(page);
|
|
VM_BUG_ON_PAGE(PageAnon(page), page);
|
|
/*
|
|
* Take a local copy of the address_space - page.mapping may be zeroed
|
|
* by truncate after unlock_page(). The address_space itself remains
|
|
* pinned by vma->vm_file's reference. We rely on unlock_page()'s
|
|
* release semantics to prevent the compiler from undoing this copying.
|
|
*/
|
|
mapping = page_rmapping(page);
|
|
unlock_page(page);
|
|
|
|
if ((dirtied || page_mkwrite) && mapping) {
|
|
/*
|
|
* Some device drivers do not set page.mapping
|
|
* but still dirty their pages
|
|
*/
|
|
balance_dirty_pages_ratelimited(mapping);
|
|
}
|
|
|
|
if (!page_mkwrite)
|
|
file_update_time(vma->vm_file);
|
|
}
|
|
|
|
/*
|
|
* Handle write page faults for pages that can be reused in the current vma
|
|
*
|
|
* This can happen either due to the mapping being with the VM_SHARED flag,
|
|
* or due to us being the last reference standing to the page. In either
|
|
* case, all we need to do here is to mark the page as writable and update
|
|
* any related book-keeping.
|
|
*/
|
|
static inline void wp_page_reuse(struct vm_fault *vmf)
|
|
__releases(vmf->ptl)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct page *page = vmf->page;
|
|
pte_t entry;
|
|
/*
|
|
* Clear the pages cpupid information as the existing
|
|
* information potentially belongs to a now completely
|
|
* unrelated process.
|
|
*/
|
|
if (page)
|
|
page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1);
|
|
|
|
flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte));
|
|
entry = pte_mkyoung(vmf->orig_pte);
|
|
entry = maybe_mkwrite(pte_mkdirty(entry), vmf->vma_flags);
|
|
if (ptep_set_access_flags(vma, vmf->address, vmf->pte, entry, 1))
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
}
|
|
|
|
/*
|
|
* 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
|
|
* without the ptl held.
|
|
*
|
|
* High level logic flow:
|
|
*
|
|
* - Allocate a page, copy the content of the old page to the new one.
|
|
* - Handle book keeping and accounting - cgroups, mmu-notifiers, etc.
|
|
* - Take the PTL. If the pte changed, bail out and release the allocated page
|
|
* - If the pte is still the way we remember it, update the page table and all
|
|
* relevant references. This includes dropping the reference the page-table
|
|
* held to the old page, as well as updating the rmap.
|
|
* - In any case, unlock the PTL and drop the reference we took to the old page.
|
|
*/
|
|
static vm_fault_t wp_page_copy(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
struct page *old_page = vmf->page;
|
|
struct page *new_page = NULL;
|
|
pte_t entry;
|
|
int page_copied = 0;
|
|
const unsigned long mmun_start = vmf->address & PAGE_MASK;
|
|
const unsigned long mmun_end = mmun_start + PAGE_SIZE;
|
|
struct mem_cgroup *memcg;
|
|
int ret = VM_FAULT_OOM;
|
|
|
|
if (unlikely(anon_vma_prepare(vma)))
|
|
goto out;
|
|
|
|
if (is_zero_pfn(pte_pfn(vmf->orig_pte))) {
|
|
new_page = alloc_zeroed_user_highpage_movable(vma,
|
|
vmf->address);
|
|
if (!new_page)
|
|
goto out;
|
|
} else {
|
|
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma,
|
|
vmf->address);
|
|
if (!new_page)
|
|
goto out;
|
|
cow_user_page(new_page, old_page, vmf->address, vma);
|
|
}
|
|
|
|
if (mem_cgroup_try_charge_delay(new_page, mm, GFP_KERNEL, &memcg, false))
|
|
goto out_free_new;
|
|
|
|
__SetPageUptodate(new_page);
|
|
|
|
mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
|
|
|
|
/*
|
|
* Re-check the pte - we dropped the lock
|
|
*/
|
|
if (!pte_map_lock(vmf)) {
|
|
ret = VM_FAULT_RETRY;
|
|
goto out_uncharge;
|
|
}
|
|
if (likely(pte_same(*vmf->pte, vmf->orig_pte))) {
|
|
if (old_page) {
|
|
if (!PageAnon(old_page)) {
|
|
dec_mm_counter_fast(mm,
|
|
mm_counter_file(old_page));
|
|
inc_mm_counter_fast(mm, MM_ANONPAGES);
|
|
}
|
|
} else {
|
|
inc_mm_counter_fast(mm, MM_ANONPAGES);
|
|
}
|
|
flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte));
|
|
entry = mk_pte(new_page, vmf->vma_page_prot);
|
|
entry = maybe_mkwrite(pte_mkdirty(entry), vmf->vma_flags);
|
|
/*
|
|
* Clear the pte entry and flush it first, before updating the
|
|
* pte with the new entry. This will avoid a race condition
|
|
* seen in the presence of one thread doing SMC and another
|
|
* thread doing COW.
|
|
*/
|
|
ptep_clear_flush_notify(vma, vmf->address, vmf->pte);
|
|
__page_add_new_anon_rmap(new_page, vma, vmf->address, false);
|
|
mem_cgroup_commit_charge(new_page, memcg, false, false);
|
|
__lru_cache_add_active_or_unevictable(new_page, vmf->vma_flags);
|
|
/*
|
|
* We call the notify macro here because, when using secondary
|
|
* mmu page tables (such as kvm shadow page tables), we want the
|
|
* new page to be mapped directly into the secondary page table.
|
|
*/
|
|
set_pte_at_notify(mm, vmf->address, vmf->pte, entry);
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
if (old_page) {
|
|
/*
|
|
* Only after switching the pte to the new page may
|
|
* we remove the mapcount here. Otherwise another
|
|
* process may come and find the rmap count decremented
|
|
* before the pte is switched to the new page, and
|
|
* "reuse" the old page writing into it while our pte
|
|
* here still points into it and can be read by other
|
|
* threads.
|
|
*
|
|
* The critical issue is to order this
|
|
* page_remove_rmap with the ptp_clear_flush above.
|
|
* Those stores are ordered by (if nothing else,)
|
|
* the barrier present in the atomic_add_negative
|
|
* in page_remove_rmap.
|
|
*
|
|
* Then the TLB flush in ptep_clear_flush ensures that
|
|
* no process can access the old page before the
|
|
* decremented mapcount is visible. And the old page
|
|
* cannot be reused until after the decremented
|
|
* mapcount is visible. So transitively, TLBs to
|
|
* old page will be flushed before it can be reused.
|
|
*/
|
|
page_remove_rmap(old_page, false);
|
|
}
|
|
|
|
/* Free the old page.. */
|
|
new_page = old_page;
|
|
page_copied = 1;
|
|
} else {
|
|
mem_cgroup_cancel_charge(new_page, memcg, false);
|
|
}
|
|
|
|
if (new_page)
|
|
put_page(new_page);
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
/*
|
|
* No need to double call mmu_notifier->invalidate_range() callback as
|
|
* the above ptep_clear_flush_notify() did already call it.
|
|
*/
|
|
mmu_notifier_invalidate_range_only_end(mm, mmun_start, mmun_end);
|
|
if (old_page) {
|
|
/*
|
|
* Don't let another task, with possibly unlocked vma,
|
|
* keep the mlocked page.
|
|
*/
|
|
if (page_copied && (vmf->vma_flags & VM_LOCKED)) {
|
|
lock_page(old_page); /* LRU manipulation */
|
|
if (PageMlocked(old_page))
|
|
munlock_vma_page(old_page);
|
|
unlock_page(old_page);
|
|
}
|
|
put_page(old_page);
|
|
}
|
|
return page_copied ? VM_FAULT_WRITE : 0;
|
|
out_uncharge:
|
|
mem_cgroup_cancel_charge(new_page, memcg, false);
|
|
out_free_new:
|
|
put_page(new_page);
|
|
out:
|
|
if (old_page)
|
|
put_page(old_page);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* finish_mkwrite_fault - finish page fault for a shared mapping, making PTE
|
|
* writeable once the page is prepared
|
|
*
|
|
* @vmf: structure describing the fault
|
|
*
|
|
* This function handles all that is needed to finish a write page fault in a
|
|
* shared mapping due to PTE being read-only once the mapped page is prepared.
|
|
* It handles locking of PTE and modifying it. The function returns
|
|
* VM_FAULT_WRITE on success, 0 when PTE got changed before we acquired PTE
|
|
* lock.
|
|
*
|
|
* The function expects the page to be locked or other protection against
|
|
* concurrent faults / writeback (such as DAX radix tree locks).
|
|
*/
|
|
vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf)
|
|
{
|
|
WARN_ON_ONCE(!(vmf->vma_flags & VM_SHARED));
|
|
if (!pte_map_lock(vmf))
|
|
return VM_FAULT_RETRY;
|
|
/*
|
|
* We might have raced with another page fault while we released the
|
|
* pte_offset_map_lock.
|
|
*/
|
|
if (!pte_same(*vmf->pte, vmf->orig_pte)) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return VM_FAULT_NOPAGE;
|
|
}
|
|
wp_page_reuse(vmf);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Handle write page faults for VM_MIXEDMAP or VM_PFNMAP for a VM_SHARED
|
|
* mapping
|
|
*/
|
|
static vm_fault_t wp_pfn_shared(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
|
|
if (vma->vm_ops && vma->vm_ops->pfn_mkwrite) {
|
|
vm_fault_t ret;
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
vmf->flags |= FAULT_FLAG_MKWRITE;
|
|
ret = vma->vm_ops->pfn_mkwrite(vmf);
|
|
if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))
|
|
return ret;
|
|
return finish_mkwrite_fault(vmf);
|
|
}
|
|
wp_page_reuse(vmf);
|
|
return VM_FAULT_WRITE;
|
|
}
|
|
|
|
static vm_fault_t wp_page_shared(struct vm_fault *vmf)
|
|
__releases(vmf->ptl)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
|
|
get_page(vmf->page);
|
|
|
|
if (vma->vm_ops && vma->vm_ops->page_mkwrite) {
|
|
vm_fault_t tmp;
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
tmp = do_page_mkwrite(vmf);
|
|
if (unlikely(!tmp || (tmp &
|
|
(VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
|
|
put_page(vmf->page);
|
|
return tmp;
|
|
}
|
|
tmp = finish_mkwrite_fault(vmf);
|
|
if (unlikely(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) {
|
|
unlock_page(vmf->page);
|
|
put_page(vmf->page);
|
|
return tmp;
|
|
}
|
|
} else {
|
|
wp_page_reuse(vmf);
|
|
lock_page(vmf->page);
|
|
}
|
|
fault_dirty_shared_page(vma, vmf->page);
|
|
put_page(vmf->page);
|
|
|
|
return VM_FAULT_WRITE;
|
|
}
|
|
|
|
/*
|
|
* This routine handles present pages, when users try to write
|
|
* to a shared page. It is done by copying the page to a new address
|
|
* and decrementing the shared-page counter for the old page.
|
|
*
|
|
* Note that this routine assumes that the protection checks have been
|
|
* done by the caller (the low-level page fault routine in most cases).
|
|
* Thus we can safely just mark it writable once we've done any necessary
|
|
* COW.
|
|
*
|
|
* We also mark the page dirty at this point even though the page will
|
|
* 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,
|
|
* but allow concurrent faults), with pte both mapped and locked.
|
|
* We return with mmap_sem still held, but pte unmapped and unlocked.
|
|
*/
|
|
static vm_fault_t do_wp_page(struct vm_fault *vmf)
|
|
__releases(vmf->ptl)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
|
|
vmf->page = __vm_normal_page(vma, vmf->address, vmf->orig_pte, false,
|
|
vmf->vma_flags);
|
|
if (!vmf->page) {
|
|
/*
|
|
* VM_MIXEDMAP !pfn_valid() case, or VM_SOFTDIRTY clear on a
|
|
* VM_PFNMAP VMA.
|
|
*
|
|
* We should not cow pages in a shared writeable mapping.
|
|
* Just mark the pages writable and/or call ops->pfn_mkwrite.
|
|
*/
|
|
if ((vmf->vma_flags & (VM_WRITE|VM_SHARED)) ==
|
|
(VM_WRITE|VM_SHARED))
|
|
return wp_pfn_shared(vmf);
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return wp_page_copy(vmf);
|
|
}
|
|
|
|
/*
|
|
* Take out anonymous pages first, anonymous shared vmas are
|
|
* not dirty accountable.
|
|
*/
|
|
if (PageAnon(vmf->page) && !PageKsm(vmf->page)) {
|
|
int total_map_swapcount;
|
|
if (!trylock_page(vmf->page)) {
|
|
get_page(vmf->page);
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
lock_page(vmf->page);
|
|
if (!pte_map_lock(vmf)) {
|
|
unlock_page(vmf->page);
|
|
put_page(vmf->page);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
if (!pte_same(*vmf->pte, vmf->orig_pte)) {
|
|
unlock_page(vmf->page);
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
put_page(vmf->page);
|
|
return 0;
|
|
}
|
|
put_page(vmf->page);
|
|
}
|
|
if (reuse_swap_page(vmf->page, &total_map_swapcount)) {
|
|
if (total_map_swapcount == 1) {
|
|
/*
|
|
* The page is all ours. Move it to
|
|
* our anon_vma so the rmap code will
|
|
* not search our parent or siblings.
|
|
* Protected against the rmap code by
|
|
* the page lock.
|
|
*/
|
|
page_move_anon_rmap(vmf->page, vma);
|
|
}
|
|
unlock_page(vmf->page);
|
|
wp_page_reuse(vmf);
|
|
return VM_FAULT_WRITE;
|
|
}
|
|
unlock_page(vmf->page);
|
|
} else if (unlikely((vmf->vma_flags & (VM_WRITE|VM_SHARED)) ==
|
|
(VM_WRITE|VM_SHARED))) {
|
|
return wp_page_shared(vmf);
|
|
}
|
|
|
|
/*
|
|
* Ok, we need to copy. Oh, well..
|
|
*/
|
|
get_page(vmf->page);
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return wp_page_copy(vmf);
|
|
}
|
|
|
|
static void unmap_mapping_range_vma(struct vm_area_struct *vma,
|
|
unsigned long start_addr, unsigned long end_addr,
|
|
struct zap_details *details)
|
|
{
|
|
zap_page_range_single(vma, start_addr, end_addr - start_addr, details);
|
|
}
|
|
|
|
static inline void unmap_mapping_range_tree(struct rb_root_cached *root,
|
|
struct zap_details *details)
|
|
{
|
|
struct vm_area_struct *vma;
|
|
pgoff_t vba, vea, zba, zea;
|
|
|
|
vma_interval_tree_foreach(vma, root,
|
|
details->first_index, details->last_index) {
|
|
|
|
vba = vma->vm_pgoff;
|
|
vea = vba + vma_pages(vma) - 1;
|
|
zba = details->first_index;
|
|
if (zba < vba)
|
|
zba = vba;
|
|
zea = details->last_index;
|
|
if (zea > vea)
|
|
zea = vea;
|
|
|
|
unmap_mapping_range_vma(vma,
|
|
((zba - vba) << PAGE_SHIFT) + vma->vm_start,
|
|
((zea - vba + 1) << PAGE_SHIFT) + vma->vm_start,
|
|
details);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* unmap_mapping_pages() - Unmap pages from processes.
|
|
* @mapping: The address space containing pages to be unmapped.
|
|
* @start: Index of first page to be unmapped.
|
|
* @nr: Number of pages to be unmapped. 0 to unmap to end of file.
|
|
* @even_cows: Whether to unmap even private COWed pages.
|
|
*
|
|
* Unmap the pages in this address space from any userspace process which
|
|
* has them mmaped. Generally, you want to remove COWed pages as well when
|
|
* a file is being truncated, but not when invalidating pages from the page
|
|
* cache.
|
|
*/
|
|
void unmap_mapping_pages(struct address_space *mapping, pgoff_t start,
|
|
pgoff_t nr, bool even_cows)
|
|
{
|
|
struct zap_details details = { };
|
|
|
|
details.check_mapping = even_cows ? NULL : mapping;
|
|
details.first_index = start;
|
|
details.last_index = start + nr - 1;
|
|
if (details.last_index < details.first_index)
|
|
details.last_index = ULONG_MAX;
|
|
|
|
i_mmap_lock_write(mapping);
|
|
if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
|
|
unmap_mapping_range_tree(&mapping->i_mmap, &details);
|
|
i_mmap_unlock_write(mapping);
|
|
}
|
|
|
|
/**
|
|
* unmap_mapping_range - unmap the portion of all mmaps in the specified
|
|
* address_space corresponding to the specified byte range in the underlying
|
|
* file.
|
|
*
|
|
* @mapping: the address space containing mmaps to be unmapped.
|
|
* @holebegin: byte in first page to unmap, relative to the start of
|
|
* the underlying file. This will be rounded down to a PAGE_SIZE
|
|
* boundary. Note that this is different from truncate_pagecache(), which
|
|
* must keep the partial page. In contrast, we must get rid of
|
|
* partial pages.
|
|
* @holelen: size of prospective hole in bytes. This will be rounded
|
|
* up to a PAGE_SIZE boundary. A holelen of zero truncates to the
|
|
* end of the file.
|
|
* @even_cows: 1 when truncating a file, unmap even private COWed pages;
|
|
* but 0 when invalidating pagecache, don't throw away private data.
|
|
*/
|
|
void unmap_mapping_range(struct address_space *mapping,
|
|
loff_t const holebegin, loff_t const holelen, int even_cows)
|
|
{
|
|
pgoff_t hba = holebegin >> PAGE_SHIFT;
|
|
pgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
|
|
|
/* Check for overflow. */
|
|
if (sizeof(holelen) > sizeof(hlen)) {
|
|
long long holeend =
|
|
(holebegin + holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
|
if (holeend & ~(long long)ULONG_MAX)
|
|
hlen = ULONG_MAX - hba + 1;
|
|
}
|
|
|
|
unmap_mapping_pages(mapping, hba, hlen, even_cows);
|
|
}
|
|
EXPORT_SYMBOL(unmap_mapping_range);
|
|
|
|
/*
|
|
* We enter with non-exclusive mmap_sem (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
|
|
* as does filemap_fault().
|
|
*/
|
|
vm_fault_t do_swap_page(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct page *page = NULL, *swapcache;
|
|
struct mem_cgroup *memcg;
|
|
swp_entry_t entry;
|
|
struct swap_info_struct *si;
|
|
bool skip_swapcache = false;
|
|
pte_t pte;
|
|
int locked;
|
|
int exclusive = 0;
|
|
vm_fault_t ret;
|
|
|
|
ret = pte_unmap_same(vmf);
|
|
if (ret) {
|
|
/*
|
|
* If pte != orig_pte, this means another thread did the
|
|
* swap operation in our back.
|
|
* So nothing else to do.
|
|
*/
|
|
if (ret == VM_FAULT_PTNOTSAME)
|
|
ret = 0;
|
|
goto out;
|
|
}
|
|
|
|
entry = pte_to_swp_entry(vmf->orig_pte);
|
|
if (unlikely(non_swap_entry(entry))) {
|
|
if (is_migration_entry(entry)) {
|
|
migration_entry_wait(vma->vm_mm, vmf->pmd,
|
|
vmf->address);
|
|
} else if (is_device_private_entry(entry)) {
|
|
/*
|
|
* For un-addressable device memory we call the pgmap
|
|
* fault handler callback. The callback must migrate
|
|
* the page back to some CPU accessible page.
|
|
*/
|
|
ret = device_private_entry_fault(vma, vmf->address, entry,
|
|
vmf->flags, vmf->pmd);
|
|
} else if (is_hwpoison_entry(entry)) {
|
|
ret = VM_FAULT_HWPOISON;
|
|
} else {
|
|
print_bad_pte(vma, vmf->address, vmf->orig_pte, NULL);
|
|
ret = VM_FAULT_SIGBUS;
|
|
}
|
|
goto out;
|
|
}
|
|
|
|
|
|
delayacct_set_flag(DELAYACCT_PF_SWAPIN);
|
|
|
|
/*
|
|
* lookup_swap_cache below can fail and before the SWP_SYNCHRONOUS_IO
|
|
* check is made, another process can populate the swapcache, delete
|
|
* the swap entry and decrement the swap count. So decide on taking
|
|
* the SWP_SYNCHRONOUS_IO path before the lookup. In the event of the
|
|
* race described, the victim process will find a swap_count > 1
|
|
* and can then take the readahead path instead of SWP_SYNCHRONOUS_IO.
|
|
*/
|
|
si = swp_swap_info(entry);
|
|
if (si->flags & SWP_SYNCHRONOUS_IO && __swap_count(si, entry) == 1)
|
|
skip_swapcache = true;
|
|
|
|
page = lookup_swap_cache(entry, vma, vmf->address);
|
|
swapcache = page;
|
|
|
|
if (!page) {
|
|
if (skip_swapcache) {
|
|
page = alloc_page_vma(GFP_HIGHUSER_MOVABLE | __GFP_CMA,
|
|
vma, vmf->address);
|
|
if (page) {
|
|
__SetPageLocked(page);
|
|
__SetPageSwapBacked(page);
|
|
set_page_private(page, entry.val);
|
|
lru_cache_add_anon(page);
|
|
swap_readpage(page, true);
|
|
}
|
|
} else if (vmf->flags & FAULT_FLAG_SPECULATIVE) {
|
|
/*
|
|
* Don't try readahead during a speculative page fault
|
|
* as the VMA's boundaries may change in our back.
|
|
* If the page is not in the swap cache and synchronous
|
|
* read is disabled, fall back to the regular page fault
|
|
* mechanism.
|
|
*/
|
|
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
|
|
ret = VM_FAULT_RETRY;
|
|
goto out;
|
|
} else {
|
|
page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
|
|
vmf);
|
|
swapcache = page;
|
|
}
|
|
|
|
if (!page) {
|
|
/*
|
|
* Back out if the VMA has changed in our back during
|
|
* a speculative page fault or if somebody else
|
|
* faulted in this pte while we released the pte lock.
|
|
*/
|
|
if (!pte_map_lock(vmf)) {
|
|
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
|
|
ret = VM_FAULT_RETRY;
|
|
goto out;
|
|
}
|
|
|
|
if (likely(pte_same(*vmf->pte, vmf->orig_pte)))
|
|
ret = VM_FAULT_OOM;
|
|
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
|
|
goto unlock;
|
|
}
|
|
|
|
/* Had to read the page from swap area: Major fault */
|
|
ret = VM_FAULT_MAJOR;
|
|
count_vm_event(PGMAJFAULT);
|
|
count_memcg_event_mm(vma->vm_mm, PGMAJFAULT);
|
|
} else if (PageHWPoison(page)) {
|
|
/*
|
|
* hwpoisoned dirty swapcache pages are kept for killing
|
|
* owner processes (which may be unknown at hwpoison time)
|
|
*/
|
|
ret = VM_FAULT_HWPOISON;
|
|
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
|
|
goto out_release;
|
|
}
|
|
|
|
locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags);
|
|
|
|
delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
|
|
if (!locked) {
|
|
ret |= VM_FAULT_RETRY;
|
|
goto out_release;
|
|
}
|
|
|
|
/*
|
|
* Make sure try_to_free_swap or reuse_swap_page or swapoff did not
|
|
* release the swapcache from under us. The page pin, and pte_same
|
|
* test below, are not enough to exclude that. Even if it is still
|
|
* swapcache, we need to check that the page's swap has not changed.
|
|
*/
|
|
if (unlikely((!PageSwapCache(page) ||
|
|
page_private(page) != entry.val)) && swapcache)
|
|
goto out_page;
|
|
|
|
page = ksm_might_need_to_copy(page, vma, vmf->address);
|
|
if (unlikely(!page)) {
|
|
ret = VM_FAULT_OOM;
|
|
page = swapcache;
|
|
goto out_page;
|
|
}
|
|
|
|
if (mem_cgroup_try_charge_delay(page, vma->vm_mm, GFP_KERNEL,
|
|
&memcg, false)) {
|
|
ret = VM_FAULT_OOM;
|
|
goto out_page;
|
|
}
|
|
|
|
/*
|
|
* Back out if the VMA has changed in our back during a speculative
|
|
* page fault or if somebody else already faulted in this pte.
|
|
*/
|
|
if (!pte_map_lock(vmf)) {
|
|
ret = VM_FAULT_RETRY;
|
|
goto out_cancel_cgroup;
|
|
}
|
|
if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte)))
|
|
goto out_nomap;
|
|
|
|
if (unlikely(!PageUptodate(page))) {
|
|
ret = VM_FAULT_SIGBUS;
|
|
goto out_nomap;
|
|
}
|
|
|
|
/*
|
|
* The page isn't present yet, go ahead with the fault.
|
|
*
|
|
* Be careful about the sequence of operations here.
|
|
* To get its accounting right, reuse_swap_page() must be called
|
|
* while the page is counted on swap but not yet in mapcount i.e.
|
|
* before page_add_anon_rmap() and swap_free(); try_to_free_swap()
|
|
* must be called after the swap_free(), or it will never succeed.
|
|
*/
|
|
|
|
inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
|
|
dec_mm_counter_fast(vma->vm_mm, MM_SWAPENTS);
|
|
pte = mk_pte(page, vmf->vma_page_prot);
|
|
if ((vmf->flags & FAULT_FLAG_WRITE) && reuse_swap_page(page, NULL)) {
|
|
pte = maybe_mkwrite(pte_mkdirty(pte), vmf->vma_flags);
|
|
vmf->flags &= ~FAULT_FLAG_WRITE;
|
|
ret |= VM_FAULT_WRITE;
|
|
exclusive = RMAP_EXCLUSIVE;
|
|
}
|
|
flush_icache_page(vma, page);
|
|
if (pte_swp_soft_dirty(vmf->orig_pte))
|
|
pte = pte_mksoft_dirty(pte);
|
|
set_pte_at(vma->vm_mm, vmf->address, vmf->pte, pte);
|
|
arch_do_swap_page(vma->vm_mm, vma, vmf->address, pte, vmf->orig_pte);
|
|
vmf->orig_pte = pte;
|
|
|
|
/* ksm created a completely new copy */
|
|
if (unlikely(page != swapcache && swapcache)) {
|
|
__page_add_new_anon_rmap(page, vma, vmf->address, false);
|
|
mem_cgroup_commit_charge(page, memcg, false, false);
|
|
__lru_cache_add_active_or_unevictable(page, vmf->vma_flags);
|
|
} else {
|
|
do_page_add_anon_rmap(page, vma, vmf->address, exclusive);
|
|
mem_cgroup_commit_charge(page, memcg, true, false);
|
|
activate_page(page);
|
|
}
|
|
|
|
swap_free(entry);
|
|
if (mem_cgroup_swap_full(page) ||
|
|
(vmf->vma_flags & VM_LOCKED) || PageMlocked(page))
|
|
try_to_free_swap(page);
|
|
unlock_page(page);
|
|
if (page != swapcache && swapcache) {
|
|
/*
|
|
* Hold the lock to avoid the swap entry to be reused
|
|
* until we take the PT lock for the pte_same() check
|
|
* (to avoid false positives from pte_same). For
|
|
* further safety release the lock after the swap_free
|
|
* so that the swap count won't change under a
|
|
* parallel locked swapcache.
|
|
*/
|
|
unlock_page(swapcache);
|
|
put_page(swapcache);
|
|
}
|
|
|
|
if (vmf->flags & FAULT_FLAG_WRITE) {
|
|
ret |= do_wp_page(vmf);
|
|
if (ret & VM_FAULT_ERROR)
|
|
ret &= VM_FAULT_ERROR;
|
|
goto out;
|
|
}
|
|
|
|
/* No need to invalidate - it was non-present before */
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
unlock:
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
out:
|
|
return ret;
|
|
out_nomap:
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
out_cancel_cgroup:
|
|
mem_cgroup_cancel_charge(page, memcg, false);
|
|
out_page:
|
|
unlock_page(page);
|
|
out_release:
|
|
put_page(page);
|
|
if (page != swapcache && swapcache) {
|
|
unlock_page(swapcache);
|
|
put_page(swapcache);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* We enter with non-exclusive mmap_sem (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.
|
|
*/
|
|
static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct mem_cgroup *memcg;
|
|
struct page *page;
|
|
vm_fault_t ret = 0;
|
|
pte_t entry;
|
|
|
|
/* File mapping without ->vm_ops ? */
|
|
if (vmf->vma_flags & VM_SHARED)
|
|
return VM_FAULT_SIGBUS;
|
|
|
|
/*
|
|
* Use pte_alloc() instead of pte_alloc_map(). We can't run
|
|
* 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
|
|
* parallel threads are excluded by other means.
|
|
*
|
|
* Here we only have down_read(mmap_sem).
|
|
*/
|
|
if (pte_alloc(vma->vm_mm, vmf->pmd, vmf->address))
|
|
return VM_FAULT_OOM;
|
|
|
|
/* See the comment in pte_alloc_one_map() */
|
|
if (unlikely(pmd_trans_unstable(vmf->pmd)))
|
|
return 0;
|
|
|
|
/* Use the zero-page for reads */
|
|
if (!(vmf->flags & FAULT_FLAG_WRITE) &&
|
|
!mm_forbids_zeropage(vma->vm_mm)) {
|
|
entry = pte_mkspecial(pfn_pte(my_zero_pfn(vmf->address),
|
|
vmf->vma_page_prot));
|
|
if (!pte_map_lock(vmf))
|
|
return VM_FAULT_RETRY;
|
|
if (!pte_none(*vmf->pte))
|
|
goto unlock;
|
|
ret = check_stable_address_space(vma->vm_mm);
|
|
if (ret)
|
|
goto unlock;
|
|
/*
|
|
* Don't call the userfaultfd during the speculative path.
|
|
* We already checked for the VMA to not be managed through
|
|
* userfaultfd, but it may be set in our back once we have lock
|
|
* the pte. In such a case we can ignore it this time.
|
|
*/
|
|
if (vmf->flags & FAULT_FLAG_SPECULATIVE)
|
|
goto setpte;
|
|
/* Deliver the page fault to userland, check inside PT lock */
|
|
if (userfaultfd_missing(vma)) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return handle_userfault(vmf, VM_UFFD_MISSING);
|
|
}
|
|
goto setpte;
|
|
}
|
|
|
|
/* Allocate our own private page. */
|
|
if (unlikely(anon_vma_prepare(vma)))
|
|
goto oom;
|
|
page = alloc_zeroed_user_highpage_movable(vma, vmf->address);
|
|
if (!page)
|
|
goto oom;
|
|
|
|
if (mem_cgroup_try_charge_delay(page, vma->vm_mm, GFP_KERNEL, &memcg,
|
|
false))
|
|
goto oom_free_page;
|
|
|
|
/*
|
|
* The memory barrier inside __SetPageUptodate makes sure that
|
|
* preceeding stores to the page contents become visible before
|
|
* the set_pte_at() write.
|
|
*/
|
|
__SetPageUptodate(page);
|
|
|
|
entry = mk_pte(page, vmf->vma_page_prot);
|
|
if (vmf->vma_flags & VM_WRITE)
|
|
entry = pte_mkwrite(pte_mkdirty(entry));
|
|
|
|
if (!pte_map_lock(vmf)) {
|
|
ret = VM_FAULT_RETRY;
|
|
goto release;
|
|
}
|
|
if (!pte_none(*vmf->pte))
|
|
goto unlock_and_release;
|
|
|
|
ret = check_stable_address_space(vma->vm_mm);
|
|
if (ret)
|
|
goto unlock_and_release;
|
|
|
|
/* Deliver the page fault to userland, check inside PT lock */
|
|
if (!(vmf->flags & FAULT_FLAG_SPECULATIVE) &&
|
|
userfaultfd_missing(vma)) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
mem_cgroup_cancel_charge(page, memcg, false);
|
|
put_page(page);
|
|
return handle_userfault(vmf, VM_UFFD_MISSING);
|
|
}
|
|
|
|
inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
|
|
__page_add_new_anon_rmap(page, vma, vmf->address, false);
|
|
mem_cgroup_commit_charge(page, memcg, false, false);
|
|
__lru_cache_add_active_or_unevictable(page, vmf->vma_flags);
|
|
setpte:
|
|
set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry);
|
|
|
|
/* No need to invalidate - it was non-present before */
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
unlock:
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return ret;
|
|
unlock_and_release:
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
release:
|
|
mem_cgroup_cancel_charge(page, memcg, false);
|
|
put_page(page);
|
|
return ret;
|
|
oom_free_page:
|
|
put_page(page);
|
|
oom:
|
|
return VM_FAULT_OOM;
|
|
}
|
|
|
|
/*
|
|
* The mmap_sem 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().
|
|
*/
|
|
static vm_fault_t __do_fault(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
vm_fault_t ret;
|
|
|
|
/*
|
|
* Preallocate pte before we take page_lock because this might lead to
|
|
* deadlocks for memcg reclaim which waits for pages under writeback:
|
|
* lock_page(A)
|
|
* SetPageWriteback(A)
|
|
* unlock_page(A)
|
|
* lock_page(B)
|
|
* lock_page(B)
|
|
* pte_alloc_pne
|
|
* shrink_page_list
|
|
* wait_on_page_writeback(A)
|
|
* SetPageWriteback(B)
|
|
* unlock_page(B)
|
|
* # flush A, B to clear the writeback
|
|
*/
|
|
if (pmd_none(*vmf->pmd) && !vmf->prealloc_pte) {
|
|
vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm,
|
|
vmf->address);
|
|
if (!vmf->prealloc_pte)
|
|
return VM_FAULT_OOM;
|
|
smp_wmb(); /* See comment in __pte_alloc() */
|
|
}
|
|
|
|
ret = vma->vm_ops->fault(vmf);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY |
|
|
VM_FAULT_DONE_COW)))
|
|
return ret;
|
|
|
|
if (unlikely(PageHWPoison(vmf->page))) {
|
|
if (ret & VM_FAULT_LOCKED)
|
|
unlock_page(vmf->page);
|
|
put_page(vmf->page);
|
|
vmf->page = NULL;
|
|
return VM_FAULT_HWPOISON;
|
|
}
|
|
|
|
if (unlikely(!(ret & VM_FAULT_LOCKED)))
|
|
lock_page(vmf->page);
|
|
else
|
|
VM_BUG_ON_PAGE(!PageLocked(vmf->page), vmf->page);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* The ordering of these checks is important for pmds with _PAGE_DEVMAP set.
|
|
* If we check pmd_trans_unstable() first we will trip the bad_pmd() check
|
|
* inside of pmd_none_or_trans_huge_or_clear_bad(). This will end up correctly
|
|
* returning 1 but not before it spams dmesg with the pmd_clear_bad() output.
|
|
*/
|
|
static int pmd_devmap_trans_unstable(pmd_t *pmd)
|
|
{
|
|
return pmd_devmap(*pmd) || pmd_trans_unstable(pmd);
|
|
}
|
|
|
|
static vm_fault_t pte_alloc_one_map(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
|
|
if (!pmd_none(*vmf->pmd) || (vmf->flags & FAULT_FLAG_SPECULATIVE))
|
|
goto map_pte;
|
|
if (vmf->prealloc_pte) {
|
|
vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
|
|
if (unlikely(!pmd_none(*vmf->pmd))) {
|
|
spin_unlock(vmf->ptl);
|
|
goto map_pte;
|
|
}
|
|
|
|
mm_inc_nr_ptes(vma->vm_mm);
|
|
pmd_populate(vma->vm_mm, vmf->pmd, vmf->prealloc_pte);
|
|
spin_unlock(vmf->ptl);
|
|
vmf->prealloc_pte = NULL;
|
|
} else if (unlikely(pte_alloc(vma->vm_mm, vmf->pmd, vmf->address))) {
|
|
return VM_FAULT_OOM;
|
|
}
|
|
map_pte:
|
|
/*
|
|
* If a huge pmd materialized under us just retry later. Use
|
|
* pmd_trans_unstable() via pmd_devmap_trans_unstable() instead of
|
|
* pmd_trans_huge() to ensure the pmd didn't become pmd_trans_huge
|
|
* under us and then back to pmd_none, as a result of MADV_DONTNEED
|
|
* running immediately after a huge pmd fault in a different thread of
|
|
* this mm, in turn leading to a misleading pmd_trans_huge() retval.
|
|
* All we have to ensure is that it is a regular pmd that we can walk
|
|
* with pte_offset_map() and we can do that through an atomic read in
|
|
* C, which is what pmd_trans_unstable() provides.
|
|
*/
|
|
if (pmd_devmap_trans_unstable(vmf->pmd))
|
|
return VM_FAULT_NOPAGE;
|
|
|
|
/*
|
|
* At this point we know that our vmf->pmd points to a page of ptes
|
|
* and it cannot become pmd_none(), pmd_devmap() or pmd_trans_huge()
|
|
* for the duration of the fault. If a racing MADV_DONTNEED runs and
|
|
* we zap the ptes pointed to by our vmf->pmd, the vmf->ptl will still
|
|
* be valid and we will re-check to make sure the vmf->pte isn't
|
|
* pte_none() under vmf->ptl protection when we return to
|
|
* alloc_set_pte().
|
|
*/
|
|
if (!pte_map_lock(vmf))
|
|
return VM_FAULT_RETRY;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
|
|
|
|
#define HPAGE_CACHE_INDEX_MASK (HPAGE_PMD_NR - 1)
|
|
static inline bool transhuge_vma_suitable(struct vm_area_struct *vma,
|
|
unsigned long haddr)
|
|
{
|
|
if (((vma->vm_start >> PAGE_SHIFT) & HPAGE_CACHE_INDEX_MASK) !=
|
|
(vma->vm_pgoff & HPAGE_CACHE_INDEX_MASK))
|
|
return false;
|
|
if (haddr < vma->vm_start || haddr + HPAGE_PMD_SIZE > vma->vm_end)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
static void deposit_prealloc_pte(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
|
|
pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, vmf->prealloc_pte);
|
|
/*
|
|
* We are going to consume the prealloc table,
|
|
* count that as nr_ptes.
|
|
*/
|
|
mm_inc_nr_ptes(vma->vm_mm);
|
|
vmf->prealloc_pte = NULL;
|
|
}
|
|
|
|
static vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
bool write = vmf->flags & FAULT_FLAG_WRITE;
|
|
unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
|
|
pmd_t entry;
|
|
int i;
|
|
vm_fault_t ret;
|
|
|
|
if (!transhuge_vma_suitable(vma, haddr))
|
|
return VM_FAULT_FALLBACK;
|
|
|
|
ret = VM_FAULT_FALLBACK;
|
|
page = compound_head(page);
|
|
|
|
/*
|
|
* Archs like ppc64 need additonal space to store information
|
|
* related to pte entry. Use the preallocated table for that.
|
|
*/
|
|
if (arch_needs_pgtable_deposit() && !vmf->prealloc_pte) {
|
|
vmf->prealloc_pte = pte_alloc_one(vma->vm_mm, vmf->address);
|
|
if (!vmf->prealloc_pte)
|
|
return VM_FAULT_OOM;
|
|
smp_wmb(); /* See comment in __pte_alloc() */
|
|
}
|
|
|
|
vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
|
|
if (unlikely(!pmd_none(*vmf->pmd)))
|
|
goto out;
|
|
|
|
for (i = 0; i < HPAGE_PMD_NR; i++)
|
|
flush_icache_page(vma, page + i);
|
|
|
|
entry = mk_huge_pmd(page, vmf->vma_page_prot);
|
|
if (write)
|
|
entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
|
|
|
|
add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR);
|
|
page_add_file_rmap(page, true);
|
|
/*
|
|
* deposit and withdraw with pmd lock held
|
|
*/
|
|
if (arch_needs_pgtable_deposit())
|
|
deposit_prealloc_pte(vmf);
|
|
|
|
set_pmd_at(vma->vm_mm, haddr, vmf->pmd, entry);
|
|
|
|
update_mmu_cache_pmd(vma, haddr, vmf->pmd);
|
|
|
|
/* fault is handled */
|
|
ret = 0;
|
|
count_vm_event(THP_FILE_MAPPED);
|
|
out:
|
|
spin_unlock(vmf->ptl);
|
|
return ret;
|
|
}
|
|
#else
|
|
static vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
|
|
{
|
|
BUILD_BUG();
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* alloc_set_pte - setup new PTE entry for given page and add reverse page
|
|
* mapping. If needed, the fucntion allocates page table or use pre-allocated.
|
|
*
|
|
* @vmf: fault environment
|
|
* @memcg: memcg to charge page (only for private mappings)
|
|
* @page: page to map
|
|
*
|
|
* Caller must take care of unlocking vmf->ptl, if vmf->pte is non-NULL on
|
|
* return.
|
|
*
|
|
* Target users are page handler itself and implementations of
|
|
* vm_ops->map_pages.
|
|
*/
|
|
vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
|
|
struct page *page)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
bool write = vmf->flags & FAULT_FLAG_WRITE;
|
|
pte_t entry;
|
|
vm_fault_t ret;
|
|
|
|
if (pmd_none(*vmf->pmd) && PageTransCompound(page) &&
|
|
IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
|
|
/* THP on COW? */
|
|
VM_BUG_ON_PAGE(memcg, page);
|
|
|
|
ret = do_set_pmd(vmf, page);
|
|
if (ret != VM_FAULT_FALLBACK)
|
|
return ret;
|
|
}
|
|
|
|
if (!vmf->pte) {
|
|
ret = pte_alloc_one_map(vmf);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
/* Re-check under ptl */
|
|
if (unlikely(!pte_none(*vmf->pte)))
|
|
return VM_FAULT_NOPAGE;
|
|
|
|
flush_icache_page(vma, page);
|
|
entry = mk_pte(page, vmf->vma_page_prot);
|
|
if (write)
|
|
entry = maybe_mkwrite(pte_mkdirty(entry), vmf->vma_flags);
|
|
|
|
if (vmf->flags & FAULT_FLAG_PREFAULT_OLD)
|
|
entry = pte_mkold(entry);
|
|
|
|
/* copy-on-write page */
|
|
if (write && !(vmf->vma_flags & VM_SHARED)) {
|
|
inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
|
|
__page_add_new_anon_rmap(page, vma, vmf->address, false);
|
|
mem_cgroup_commit_charge(page, memcg, false, false);
|
|
__lru_cache_add_active_or_unevictable(page, vmf->vma_flags);
|
|
} else {
|
|
inc_mm_counter_fast(vma->vm_mm, mm_counter_file(page));
|
|
page_add_file_rmap(page, false);
|
|
}
|
|
set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry);
|
|
|
|
/* no need to invalidate: a not-present page won't be cached */
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/**
|
|
* finish_fault - finish page fault once we have prepared the page to fault
|
|
*
|
|
* @vmf: structure describing the fault
|
|
*
|
|
* This function handles all that is needed to finish a page fault once the
|
|
* page to fault in is prepared. It handles locking of PTEs, inserts PTE for
|
|
* given page, adds reverse page mapping, handles memcg charges and LRU
|
|
* addition. The function returns 0 on success, VM_FAULT_ code in case of
|
|
* error.
|
|
*
|
|
* The function expects the page to be locked and on success it consumes a
|
|
* reference of a page being mapped (for the PTE which maps it).
|
|
*/
|
|
vm_fault_t finish_fault(struct vm_fault *vmf)
|
|
{
|
|
struct page *page;
|
|
vm_fault_t ret = 0;
|
|
|
|
/* Did we COW the page? */
|
|
if ((vmf->flags & FAULT_FLAG_WRITE) &&
|
|
!(vmf->vma_flags & VM_SHARED))
|
|
page = vmf->cow_page;
|
|
else
|
|
page = vmf->page;
|
|
|
|
/*
|
|
* check even for read faults because we might have lost our CoWed
|
|
* page
|
|
*/
|
|
if (!(vmf->vma->vm_flags & VM_SHARED))
|
|
ret = check_stable_address_space(vmf->vma->vm_mm);
|
|
if (!ret)
|
|
ret = alloc_set_pte(vmf, vmf->memcg, page);
|
|
if (vmf->pte)
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* If architecture emulates "accessed" or "young" bit without HW support,
|
|
* there is no much gain with fault_around.
|
|
*/
|
|
static unsigned long fault_around_bytes __read_mostly =
|
|
#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
|
|
PAGE_SIZE;
|
|
#else
|
|
rounddown_pow_of_two(65536);
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
static int fault_around_bytes_get(void *data, u64 *val)
|
|
{
|
|
*val = fault_around_bytes;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* fault_around_bytes must be rounded down to the nearest page order as it's
|
|
* what do_fault_around() expects to see.
|
|
*/
|
|
static int fault_around_bytes_set(void *data, u64 val)
|
|
{
|
|
if (val / PAGE_SIZE > PTRS_PER_PTE)
|
|
return -EINVAL;
|
|
if (val > PAGE_SIZE)
|
|
fault_around_bytes = rounddown_pow_of_two(val);
|
|
else
|
|
fault_around_bytes = PAGE_SIZE; /* rounddown_pow_of_two(0) is undefined */
|
|
return 0;
|
|
}
|
|
DEFINE_DEBUGFS_ATTRIBUTE(fault_around_bytes_fops,
|
|
fault_around_bytes_get, fault_around_bytes_set, "%llu\n");
|
|
|
|
static int __init fault_around_debugfs(void)
|
|
{
|
|
void *ret;
|
|
|
|
ret = debugfs_create_file_unsafe("fault_around_bytes", 0644, NULL, NULL,
|
|
&fault_around_bytes_fops);
|
|
if (!ret)
|
|
pr_warn("Failed to create fault_around_bytes in debugfs");
|
|
return 0;
|
|
}
|
|
late_initcall(fault_around_debugfs);
|
|
#endif
|
|
|
|
/*
|
|
* do_fault_around() tries to map few pages around the fault address. The hope
|
|
* is that the pages will be needed soon and this will lower the number of
|
|
* faults to handle.
|
|
*
|
|
* It uses vm_ops->map_pages() to map the pages, which skips the page if it's
|
|
* not ready to be mapped: not up-to-date, locked, etc.
|
|
*
|
|
* This function is called with the page table lock taken. In the split ptlock
|
|
* case the page table lock only protects only those entries which belong to
|
|
* the page table corresponding to the fault address.
|
|
*
|
|
* This function doesn't cross the VMA boundaries, in order to call map_pages()
|
|
* only once.
|
|
*
|
|
* fault_around_bytes defines how many bytes we'll try to map.
|
|
* do_fault_around() expects it to be set to a power of two less than or equal
|
|
* to PTRS_PER_PTE.
|
|
*
|
|
* The virtual address of the area that we map is naturally aligned to
|
|
* fault_around_bytes rounded down to the machine page size
|
|
* (and therefore to page order). This way it's easier to guarantee
|
|
* that we don't cross page table boundaries.
|
|
*/
|
|
static vm_fault_t do_fault_around(struct vm_fault *vmf)
|
|
{
|
|
unsigned long address = vmf->address, nr_pages, mask;
|
|
pgoff_t start_pgoff = vmf->pgoff;
|
|
pgoff_t end_pgoff;
|
|
int off;
|
|
vm_fault_t ret = 0;
|
|
|
|
nr_pages = READ_ONCE(fault_around_bytes) >> PAGE_SHIFT;
|
|
mask = ~(nr_pages * PAGE_SIZE - 1) & PAGE_MASK;
|
|
|
|
vmf->address = max(address & mask, vmf->vma->vm_start);
|
|
off = ((address - vmf->address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
|
|
start_pgoff -= off;
|
|
|
|
/*
|
|
* end_pgoff is either the end of the page table, the end of
|
|
* the vma or nr_pages from start_pgoff, depending what is nearest.
|
|
*/
|
|
end_pgoff = start_pgoff -
|
|
((vmf->address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) +
|
|
PTRS_PER_PTE - 1;
|
|
end_pgoff = min3(end_pgoff, vma_pages(vmf->vma) + vmf->vma->vm_pgoff - 1,
|
|
start_pgoff + nr_pages - 1);
|
|
|
|
if (pmd_none(*vmf->pmd)) {
|
|
vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm,
|
|
vmf->address);
|
|
if (!vmf->prealloc_pte)
|
|
goto out;
|
|
smp_wmb(); /* See comment in __pte_alloc() */
|
|
}
|
|
|
|
vmf->vma->vm_ops->map_pages(vmf, start_pgoff, end_pgoff);
|
|
|
|
/* Huge page is mapped? Page fault is solved */
|
|
if (pmd_trans_huge(*vmf->pmd)) {
|
|
ret = VM_FAULT_NOPAGE;
|
|
goto out;
|
|
}
|
|
|
|
/* ->map_pages() haven't done anything useful. Cold page cache? */
|
|
if (!vmf->pte)
|
|
goto out;
|
|
|
|
/* check if the page fault is solved */
|
|
vmf->pte -= (vmf->address >> PAGE_SHIFT) - (address >> PAGE_SHIFT);
|
|
if (!pte_none(*vmf->pte))
|
|
ret = VM_FAULT_NOPAGE;
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
out:
|
|
vmf->address = address;
|
|
vmf->pte = NULL;
|
|
return ret;
|
|
}
|
|
|
|
static vm_fault_t do_read_fault(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
vm_fault_t ret = 0;
|
|
|
|
/*
|
|
* Let's call ->map_pages() first and use ->fault() as fallback
|
|
* if page by the offset is not ready to be mapped (cold cache or
|
|
* something).
|
|
*/
|
|
if (vma->vm_ops->map_pages && fault_around_bytes >> PAGE_SHIFT > 1) {
|
|
ret = do_fault_around(vmf);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
ret = __do_fault(vmf);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
|
|
return ret;
|
|
|
|
ret |= finish_fault(vmf);
|
|
unlock_page(vmf->page);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
|
|
put_page(vmf->page);
|
|
return ret;
|
|
}
|
|
|
|
static vm_fault_t do_cow_fault(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
vm_fault_t ret;
|
|
|
|
if (unlikely(anon_vma_prepare(vma)))
|
|
return VM_FAULT_OOM;
|
|
|
|
vmf->cow_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vmf->address);
|
|
if (!vmf->cow_page)
|
|
return VM_FAULT_OOM;
|
|
|
|
if (mem_cgroup_try_charge_delay(vmf->cow_page, vma->vm_mm, GFP_KERNEL,
|
|
&vmf->memcg, false)) {
|
|
put_page(vmf->cow_page);
|
|
return VM_FAULT_OOM;
|
|
}
|
|
|
|
ret = __do_fault(vmf);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
|
|
goto uncharge_out;
|
|
if (ret & VM_FAULT_DONE_COW)
|
|
return ret;
|
|
|
|
copy_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma);
|
|
__SetPageUptodate(vmf->cow_page);
|
|
|
|
ret |= finish_fault(vmf);
|
|
unlock_page(vmf->page);
|
|
put_page(vmf->page);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
|
|
goto uncharge_out;
|
|
return ret;
|
|
uncharge_out:
|
|
mem_cgroup_cancel_charge(vmf->cow_page, vmf->memcg, false);
|
|
put_page(vmf->cow_page);
|
|
return ret;
|
|
}
|
|
|
|
static vm_fault_t do_shared_fault(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
vm_fault_t ret, tmp;
|
|
|
|
ret = __do_fault(vmf);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY)))
|
|
return ret;
|
|
|
|
/*
|
|
* Check if the backing address space wants to know that the page is
|
|
* about to become writable
|
|
*/
|
|
if (vma->vm_ops->page_mkwrite) {
|
|
unlock_page(vmf->page);
|
|
tmp = do_page_mkwrite(vmf);
|
|
if (unlikely(!tmp ||
|
|
(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
|
|
put_page(vmf->page);
|
|
return tmp;
|
|
}
|
|
}
|
|
|
|
ret |= finish_fault(vmf);
|
|
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE |
|
|
VM_FAULT_RETRY))) {
|
|
unlock_page(vmf->page);
|
|
put_page(vmf->page);
|
|
return ret;
|
|
}
|
|
|
|
fault_dirty_shared_page(vma, vmf->page);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* We enter with non-exclusive mmap_sem (to exclude vma changes,
|
|
* but allow concurrent faults).
|
|
* The mmap_sem 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
|
|
* by other thread calling munmap()).
|
|
*/
|
|
static vm_fault_t do_fault(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct mm_struct *vm_mm = vma->vm_mm;
|
|
vm_fault_t ret;
|
|
|
|
/*
|
|
* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND
|
|
*/
|
|
if (!vma->vm_ops->fault) {
|
|
/*
|
|
* If we find a migration pmd entry or a none pmd entry, which
|
|
* should never happen, return SIGBUS
|
|
*/
|
|
if (unlikely(!pmd_present(*vmf->pmd)))
|
|
ret = VM_FAULT_SIGBUS;
|
|
else {
|
|
vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm,
|
|
vmf->pmd,
|
|
vmf->address,
|
|
&vmf->ptl);
|
|
/*
|
|
* Make sure this is not a temporary clearing of pte
|
|
* by holding ptl and checking again. A R/M/W update
|
|
* of pte involves: take ptl, clearing the pte so that
|
|
* we don't have concurrent modification by hardware
|
|
* followed by an update.
|
|
*/
|
|
if (unlikely(pte_none(*vmf->pte)))
|
|
ret = VM_FAULT_SIGBUS;
|
|
else
|
|
ret = VM_FAULT_NOPAGE;
|
|
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
}
|
|
} else if (!(vmf->flags & FAULT_FLAG_WRITE))
|
|
ret = do_read_fault(vmf);
|
|
else if (!(vmf->vma_flags & VM_SHARED))
|
|
ret = do_cow_fault(vmf);
|
|
else
|
|
ret = do_shared_fault(vmf);
|
|
|
|
/* preallocated pagetable is unused: free it */
|
|
if (vmf->prealloc_pte) {
|
|
pte_free(vm_mm, vmf->prealloc_pte);
|
|
vmf->prealloc_pte = NULL;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
|
|
unsigned long addr, int page_nid,
|
|
int *flags)
|
|
{
|
|
get_page(page);
|
|
|
|
count_vm_numa_event(NUMA_HINT_FAULTS);
|
|
if (page_nid == numa_node_id()) {
|
|
count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);
|
|
*flags |= TNF_FAULT_LOCAL;
|
|
}
|
|
|
|
return mpol_misplaced(page, vma, addr);
|
|
}
|
|
|
|
static vm_fault_t do_numa_page(struct vm_fault *vmf)
|
|
{
|
|
struct vm_area_struct *vma = vmf->vma;
|
|
struct page *page = NULL;
|
|
int page_nid = -1;
|
|
int last_cpupid;
|
|
int target_nid;
|
|
bool migrated = false;
|
|
pte_t pte;
|
|
bool was_writable = pte_savedwrite(vmf->orig_pte);
|
|
int flags = 0;
|
|
|
|
/*
|
|
* The "pte" at this point cannot be used safely without
|
|
* validation through pte_unmap_same(). It's of NUMA type but
|
|
* the pfn may be screwed if the read is non atomic.
|
|
*/
|
|
if (!pte_spinlock(vmf))
|
|
return VM_FAULT_RETRY;
|
|
if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte))) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
goto out;
|
|
}
|
|
|
|
/*
|
|
* Make it present again, Depending on how arch implementes non
|
|
* accessible ptes, some can allow access by kernel mode.
|
|
*/
|
|
pte = ptep_modify_prot_start(vma->vm_mm, vmf->address, vmf->pte);
|
|
pte = pte_modify(pte, vmf->vma_page_prot);
|
|
pte = pte_mkyoung(pte);
|
|
if (was_writable)
|
|
pte = pte_mkwrite(pte);
|
|
ptep_modify_prot_commit(vma->vm_mm, vmf->address, vmf->pte, pte);
|
|
update_mmu_cache(vma, vmf->address, vmf->pte);
|
|
|
|
page = __vm_normal_page(vma, vmf->address, pte, false, vmf->vma_flags);
|
|
if (!page) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return 0;
|
|
}
|
|
|
|
/* TODO: handle PTE-mapped THP */
|
|
if (PageCompound(page)) {
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Avoid grouping on RO pages in general. RO pages shouldn't hurt as
|
|
* much anyway since they can be in shared cache state. This misses
|
|
* the case where a mapping is writable but the process never writes
|
|
* to it but pte_write gets cleared during protection updates and
|
|
* pte_dirty has unpredictable behaviour between PTE scan updates,
|
|
* background writeback, dirty balancing and application behaviour.
|
|
*/
|
|
if (!pte_write(pte))
|
|
flags |= TNF_NO_GROUP;
|
|
|
|
/*
|
|
* Flag if the page is shared between multiple address spaces. This
|
|
* is later used when determining whether to group tasks together
|
|
*/
|
|
if (page_mapcount(page) > 1 && (vmf->vma_flags & VM_SHARED))
|
|
flags |= TNF_SHARED;
|
|
|
|
last_cpupid = page_cpupid_last(page);
|
|
page_nid = page_to_nid(page);
|
|
target_nid = numa_migrate_prep(page, vma, vmf->address, page_nid,
|
|
&flags);
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
if (target_nid == -1) {
|
|
put_page(page);
|
|
goto out;
|
|
}
|
|
|
|
/* Migrate to the requested node */
|
|
migrated = migrate_misplaced_page(page, vmf, target_nid);
|
|
if (migrated) {
|
|
page_nid = target_nid;
|
|
flags |= TNF_MIGRATED;
|
|
} else
|
|
flags |= TNF_MIGRATE_FAIL;
|
|
|
|
out:
|
|
if (page_nid != -1)
|
|
task_numa_fault(last_cpupid, page_nid, 1, flags);
|
|
return 0;
|
|
}
|
|
|
|
static inline vm_fault_t create_huge_pmd(struct vm_fault *vmf)
|
|
{
|
|
if (vma_is_anonymous(vmf->vma))
|
|
return do_huge_pmd_anonymous_page(vmf);
|
|
if (vmf->vma->vm_ops->huge_fault)
|
|
return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PMD);
|
|
return VM_FAULT_FALLBACK;
|
|
}
|
|
|
|
/* `inline' is required to avoid gcc 4.1.2 build error */
|
|
static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)
|
|
{
|
|
if (vma_is_anonymous(vmf->vma))
|
|
return do_huge_pmd_wp_page(vmf, orig_pmd);
|
|
if (vmf->vma->vm_ops->huge_fault)
|
|
return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PMD);
|
|
|
|
/* COW handled on pte level: split pmd */
|
|
VM_BUG_ON_VMA(vmf->vma_flags & VM_SHARED, vmf->vma);
|
|
__split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL);
|
|
|
|
return VM_FAULT_FALLBACK;
|
|
}
|
|
|
|
static inline bool vma_is_accessible(struct vm_area_struct *vma)
|
|
{
|
|
return vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE);
|
|
}
|
|
|
|
static vm_fault_t create_huge_pud(struct vm_fault *vmf)
|
|
{
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
/* No support for anonymous transparent PUD pages yet */
|
|
if (vma_is_anonymous(vmf->vma))
|
|
return VM_FAULT_FALLBACK;
|
|
if (vmf->vma->vm_ops->huge_fault)
|
|
return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD);
|
|
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
|
|
return VM_FAULT_FALLBACK;
|
|
}
|
|
|
|
static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud)
|
|
{
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
/* No support for anonymous transparent PUD pages yet */
|
|
if (vma_is_anonymous(vmf->vma))
|
|
return VM_FAULT_FALLBACK;
|
|
if (vmf->vma->vm_ops->huge_fault)
|
|
return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD);
|
|
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
|
|
return VM_FAULT_FALLBACK;
|
|
}
|
|
|
|
/*
|
|
* These routines also need to handle stuff like marking pages dirty
|
|
* and/or accessed for architectures that don't do it in hardware (most
|
|
* RISC architectures). The early dirtying is also good on the i386.
|
|
*
|
|
* There is also a hook called "update_mmu_cache()" that architectures
|
|
* 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
|
|
* concurrent faults).
|
|
*
|
|
* The mmap_sem 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)
|
|
{
|
|
pte_t entry;
|
|
int ret = 0;
|
|
|
|
if (unlikely(pmd_none(*vmf->pmd))) {
|
|
/*
|
|
* In the case of the speculative page fault handler we abort
|
|
* the speculative path immediately as the pmd is probably
|
|
* in the way to be converted in a huge one. We will try
|
|
* again holding the mmap_sem (which implies that the collapse
|
|
* operation is done).
|
|
*/
|
|
if (vmf->flags & FAULT_FLAG_SPECULATIVE)
|
|
return VM_FAULT_RETRY;
|
|
/*
|
|
* Leave __pte_alloc() until later: because vm_ops->fault may
|
|
* want to allocate huge page, and if we expose page table
|
|
* for an instant, it will be difficult to retract from
|
|
* concurrent faults and from rmap lookups.
|
|
*/
|
|
vmf->pte = NULL;
|
|
} else if (!(vmf->flags & FAULT_FLAG_SPECULATIVE)) {
|
|
/* See comment in pte_alloc_one_map() */
|
|
if (pmd_devmap_trans_unstable(vmf->pmd))
|
|
return 0;
|
|
/*
|
|
* 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.
|
|
* So now it's safe to run pte_offset_map().
|
|
* This is not applicable to the speculative page fault handler
|
|
* but in that case, the pte is fetched earlier in
|
|
* handle_speculative_fault().
|
|
*/
|
|
vmf->pte = pte_offset_map(vmf->pmd, vmf->address);
|
|
vmf->orig_pte = *vmf->pte;
|
|
|
|
/*
|
|
* some architectures can have larger ptes than wordsize,
|
|
* e.g.ppc44x-defconfig has CONFIG_PTE_64BIT=y and
|
|
* CONFIG_32BIT=y, so READ_ONCE cannot guarantee atomic
|
|
* accesses. The code below just needs a consistent view
|
|
* for the ifs and we later double check anyway with the
|
|
* ptl lock held. So here a barrier will do.
|
|
*/
|
|
barrier();
|
|
if (pte_none(vmf->orig_pte)) {
|
|
pte_unmap(vmf->pte);
|
|
vmf->pte = NULL;
|
|
}
|
|
}
|
|
|
|
if (!vmf->pte) {
|
|
if (vma_is_anonymous(vmf->vma))
|
|
return do_anonymous_page(vmf);
|
|
else
|
|
return do_fault(vmf);
|
|
}
|
|
|
|
if (!pte_present(vmf->orig_pte))
|
|
return do_swap_page(vmf);
|
|
|
|
if (pte_protnone(vmf->orig_pte) && vma_is_accessible(vmf->vma))
|
|
return do_numa_page(vmf);
|
|
|
|
if (!pte_spinlock(vmf))
|
|
return VM_FAULT_RETRY;
|
|
entry = vmf->orig_pte;
|
|
if (unlikely(!pte_same(*vmf->pte, entry)))
|
|
goto unlock;
|
|
if (vmf->flags & FAULT_FLAG_WRITE) {
|
|
if (!pte_write(entry))
|
|
return do_wp_page(vmf);
|
|
entry = pte_mkdirty(entry);
|
|
}
|
|
entry = pte_mkyoung(entry);
|
|
if (ptep_set_access_flags(vmf->vma, vmf->address, vmf->pte, entry,
|
|
vmf->flags & FAULT_FLAG_WRITE)) {
|
|
update_mmu_cache(vmf->vma, vmf->address, vmf->pte);
|
|
} else {
|
|
/*
|
|
* This is needed only for protection faults but the arch code
|
|
* is not yet telling us if this is a protection fault or not.
|
|
* This still avoids useless tlb flushes for .text page faults
|
|
* with threads.
|
|
*/
|
|
if (vmf->flags & FAULT_FLAG_WRITE)
|
|
flush_tlb_fix_spurious_fault(vmf->vma, vmf->address);
|
|
if (vmf->flags & FAULT_FLAG_SPECULATIVE)
|
|
ret = VM_FAULT_RETRY;
|
|
}
|
|
unlock:
|
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* By the time we get here, we already hold the mm semaphore
|
|
*
|
|
* The mmap_sem 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,
|
|
unsigned long address, unsigned int flags)
|
|
{
|
|
struct vm_fault vmf = {
|
|
.vma = vma,
|
|
.address = address & PAGE_MASK,
|
|
.flags = flags,
|
|
.pgoff = linear_page_index(vma, address),
|
|
.gfp_mask = __get_fault_gfp_mask(vma),
|
|
.vma_flags = vma->vm_flags,
|
|
.vma_page_prot = vma->vm_page_prot,
|
|
};
|
|
unsigned int dirty = flags & FAULT_FLAG_WRITE;
|
|
struct mm_struct *mm = vma->vm_mm;
|
|
pgd_t *pgd;
|
|
p4d_t *p4d;
|
|
vm_fault_t ret;
|
|
|
|
pgd = pgd_offset(mm, address);
|
|
p4d = p4d_alloc(mm, pgd, address);
|
|
if (!p4d)
|
|
return VM_FAULT_OOM;
|
|
|
|
vmf.pud = pud_alloc(mm, p4d, address);
|
|
if (!vmf.pud)
|
|
return VM_FAULT_OOM;
|
|
if (pud_none(*vmf.pud) && __transparent_hugepage_enabled(vma)) {
|
|
ret = create_huge_pud(&vmf);
|
|
if (!(ret & VM_FAULT_FALLBACK))
|
|
return ret;
|
|
} else {
|
|
pud_t orig_pud = *vmf.pud;
|
|
|
|
barrier();
|
|
if (pud_trans_huge(orig_pud) || pud_devmap(orig_pud)) {
|
|
|
|
/* NUMA case for anonymous PUDs would go here */
|
|
|
|
if (dirty && !pud_write(orig_pud)) {
|
|
ret = wp_huge_pud(&vmf, orig_pud);
|
|
if (!(ret & VM_FAULT_FALLBACK))
|
|
return ret;
|
|
} else {
|
|
huge_pud_set_accessed(&vmf, orig_pud);
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
vmf.pmd = pmd_alloc(mm, vmf.pud, address);
|
|
if (!vmf.pmd)
|
|
return VM_FAULT_OOM;
|
|
#ifdef CONFIG_SPECULATIVE_PAGE_FAULT
|
|
vmf.sequence = raw_read_seqcount(&vma->vm_sequence);
|
|
#endif
|
|
if (pmd_none(*vmf.pmd) && __transparent_hugepage_enabled(vma)) {
|
|
ret = create_huge_pmd(&vmf);
|
|
if (!(ret & VM_FAULT_FALLBACK))
|
|
return ret;
|
|
} else {
|
|
pmd_t orig_pmd = *vmf.pmd;
|
|
|
|
barrier();
|
|
if (unlikely(is_swap_pmd(orig_pmd))) {
|
|
VM_BUG_ON(thp_migration_supported() &&
|
|
!is_pmd_migration_entry(orig_pmd));
|
|
if (is_pmd_migration_entry(orig_pmd))
|
|
pmd_migration_entry_wait(mm, vmf.pmd);
|
|
return 0;
|
|
}
|
|
if (pmd_trans_huge(orig_pmd) || pmd_devmap(orig_pmd)) {
|
|
if (pmd_protnone(orig_pmd) && vma_is_accessible(vma))
|
|
return do_huge_pmd_numa_page(&vmf, orig_pmd);
|
|
|
|
if (dirty && !pmd_write(orig_pmd)) {
|
|
ret = wp_huge_pmd(&vmf, orig_pmd);
|
|
if (!(ret & VM_FAULT_FALLBACK))
|
|
return ret;
|
|
} else {
|
|
huge_pmd_set_accessed(&vmf, orig_pmd);
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
return handle_pte_fault(&vmf);
|
|
}
|
|
|
|
#ifdef CONFIG_SPECULATIVE_PAGE_FAULT
|
|
|
|
#ifndef CONFIG_ARCH_HAS_PTE_SPECIAL
|
|
/* This is required by vm_normal_page() */
|
|
#error "Speculative page fault handler requires CONFIG_ARCH_HAS_PTE_SPECIAL"
|
|
#endif
|
|
/*
|
|
* vm_normal_page() adds some processing which should be done while
|
|
* hodling the mmap_sem.
|
|
*/
|
|
|
|
/*
|
|
* Tries to handle the page fault in a speculative way, without grabbing the
|
|
* mmap_sem.
|
|
* When VM_FAULT_RETRY is returned, the vma pointer is valid and this vma must
|
|
* be checked later when the mmap_sem has been grabbed by calling
|
|
* can_reuse_spf_vma().
|
|
* This is needed as the returned vma is kept in memory until the call to
|
|
* can_reuse_spf_vma() is made.
|
|
*/
|
|
int __handle_speculative_fault(struct mm_struct *mm, unsigned long address,
|
|
unsigned int flags, struct vm_area_struct **vma)
|
|
{
|
|
struct vm_fault vmf = {
|
|
.address = address,
|
|
};
|
|
pgd_t *pgd, pgdval;
|
|
p4d_t *p4d, p4dval;
|
|
pud_t pudval;
|
|
int seq, ret;
|
|
|
|
/* Clear flags that may lead to release the mmap_sem to retry */
|
|
flags &= ~(FAULT_FLAG_ALLOW_RETRY|FAULT_FLAG_KILLABLE);
|
|
flags |= FAULT_FLAG_SPECULATIVE;
|
|
|
|
*vma = get_vma(mm, address);
|
|
if (!*vma)
|
|
return VM_FAULT_RETRY;
|
|
vmf.vma = *vma;
|
|
|
|
/* rmb <-> seqlock,vma_rb_erase() */
|
|
seq = raw_read_seqcount(&vmf.vma->vm_sequence);
|
|
if (seq & 1) {
|
|
trace_spf_vma_changed(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
/*
|
|
* __anon_vma_prepare() requires the mmap_sem to be held
|
|
* because vm_next and vm_prev must be safe. This can't be guaranteed
|
|
* in the speculative path.
|
|
*/
|
|
if (unlikely(vma_is_anonymous(vmf.vma) && !vmf.vma->anon_vma)) {
|
|
trace_spf_vma_notsup(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
vmf.vma_flags = READ_ONCE(vmf.vma->vm_flags);
|
|
vmf.vma_page_prot = READ_ONCE(vmf.vma->vm_page_prot);
|
|
|
|
/* Can't call userland page fault handler in the speculative path */
|
|
if (unlikely(vmf.vma_flags & VM_UFFD_MISSING)) {
|
|
trace_spf_vma_notsup(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
if (vmf.vma_flags & VM_GROWSDOWN || vmf.vma_flags & VM_GROWSUP) {
|
|
/*
|
|
* This could be detected by the check address against VMA's
|
|
* boundaries but we want to trace it as not supported instead
|
|
* of changed.
|
|
*/
|
|
trace_spf_vma_notsup(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
if (address < READ_ONCE(vmf.vma->vm_start)
|
|
|| READ_ONCE(vmf.vma->vm_end) <= address) {
|
|
trace_spf_vma_changed(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
if (!arch_vma_access_permitted(vmf.vma, flags & FAULT_FLAG_WRITE,
|
|
flags & FAULT_FLAG_INSTRUCTION,
|
|
flags & FAULT_FLAG_REMOTE))
|
|
goto out_segv;
|
|
|
|
/* This is one is required to check that the VMA has write access set */
|
|
if (flags & FAULT_FLAG_WRITE) {
|
|
if (unlikely(!(vmf.vma_flags & VM_WRITE)))
|
|
goto out_segv;
|
|
} else if (unlikely(!(vmf.vma_flags & (VM_READ|VM_EXEC|VM_WRITE))))
|
|
goto out_segv;
|
|
|
|
#ifdef CONFIG_NUMA
|
|
struct mempolicy *pol;
|
|
|
|
/*
|
|
* MPOL_INTERLEAVE implies additional checks in
|
|
* mpol_misplaced() which are not compatible with the
|
|
*speculative page fault processing.
|
|
*/
|
|
pol = __get_vma_policy(vmf.vma, address);
|
|
if (!pol)
|
|
pol = get_task_policy(current);
|
|
if (!pol)
|
|
if (pol && pol->mode == MPOL_INTERLEAVE) {
|
|
trace_spf_vma_notsup(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* Do a speculative lookup of the PTE entry.
|
|
*/
|
|
local_irq_disable();
|
|
pgd = pgd_offset(mm, address);
|
|
pgdval = READ_ONCE(*pgd);
|
|
if (pgd_none(pgdval) || unlikely(pgd_bad(pgdval)))
|
|
goto out_walk;
|
|
|
|
p4d = p4d_offset(pgd, address);
|
|
p4dval = READ_ONCE(*p4d);
|
|
if (p4d_none(p4dval) || unlikely(p4d_bad(p4dval)))
|
|
goto out_walk;
|
|
|
|
vmf.pud = pud_offset(p4d, address);
|
|
pudval = READ_ONCE(*vmf.pud);
|
|
if (pud_none(pudval) || unlikely(pud_bad(pudval)))
|
|
goto out_walk;
|
|
|
|
/* Huge pages at PUD level are not supported. */
|
|
if (unlikely(pud_trans_huge(pudval)))
|
|
goto out_walk;
|
|
|
|
vmf.pmd = pmd_offset(vmf.pud, address);
|
|
vmf.orig_pmd = READ_ONCE(*vmf.pmd);
|
|
/*
|
|
* pmd_none could mean that a hugepage collapse is in progress
|
|
* in our back as collapse_huge_page() mark it before
|
|
* invalidating the pte (which is done once the IPI is catched
|
|
* by all CPU and we have interrupt disabled).
|
|
* For this reason we cannot handle THP in a speculative way since we
|
|
* can't safely indentify an in progress collapse operation done in our
|
|
* back on that PMD.
|
|
* Regarding the order of the following checks, see comment in
|
|
* pmd_devmap_trans_unstable()
|
|
*/
|
|
if (unlikely(pmd_devmap(vmf.orig_pmd) ||
|
|
pmd_none(vmf.orig_pmd) || pmd_trans_huge(vmf.orig_pmd) ||
|
|
is_swap_pmd(vmf.orig_pmd)))
|
|
goto out_walk;
|
|
|
|
/*
|
|
* The above does not allocate/instantiate page-tables because doing so
|
|
* would lead to the possibility of instantiating page-tables after
|
|
* free_pgtables() -- and consequently leaking them.
|
|
*
|
|
* The result is that we take at least one !speculative fault per PMD
|
|
* in order to instantiate it.
|
|
*/
|
|
|
|
vmf.pte = pte_offset_map(vmf.pmd, address);
|
|
vmf.orig_pte = READ_ONCE(*vmf.pte);
|
|
barrier(); /* See comment in handle_pte_fault() */
|
|
if (pte_none(vmf.orig_pte)) {
|
|
pte_unmap(vmf.pte);
|
|
vmf.pte = NULL;
|
|
}
|
|
|
|
vmf.pgoff = linear_page_index(vmf.vma, address);
|
|
vmf.gfp_mask = __get_fault_gfp_mask(vmf.vma);
|
|
vmf.sequence = seq;
|
|
vmf.flags = flags;
|
|
|
|
local_irq_enable();
|
|
|
|
/*
|
|
* We need to re-validate the VMA after checking the bounds, otherwise
|
|
* we might have a false positive on the bounds.
|
|
*/
|
|
if (read_seqcount_retry(&vmf.vma->vm_sequence, seq)) {
|
|
trace_spf_vma_changed(_RET_IP_, vmf.vma, address);
|
|
return VM_FAULT_RETRY;
|
|
}
|
|
|
|
mem_cgroup_enter_user_fault();
|
|
ret = handle_pte_fault(&vmf);
|
|
mem_cgroup_exit_user_fault();
|
|
|
|
/*
|
|
* If there is no need to retry, don't return the vma to the caller.
|
|
*/
|
|
if (ret != VM_FAULT_RETRY) {
|
|
if (vma_is_anonymous(vmf.vma))
|
|
count_vm_event(SPECULATIVE_PGFAULT_ANON);
|
|
else
|
|
count_vm_event(SPECULATIVE_PGFAULT_FILE);
|
|
put_vma(vmf.vma);
|
|
*vma = NULL;
|
|
}
|
|
|
|
/*
|
|
* The task may have entered a memcg OOM situation but
|
|
* if the allocation error was handled gracefully (no
|
|
* VM_FAULT_OOM), there is no need to kill anything.
|
|
* Just clean up the OOM state peacefully.
|
|
*/
|
|
if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))
|
|
mem_cgroup_oom_synchronize(false);
|
|
return ret;
|
|
|
|
out_walk:
|
|
trace_spf_vma_notsup(_RET_IP_, vmf.vma, address);
|
|
local_irq_enable();
|
|
return VM_FAULT_RETRY;
|
|
|
|
out_segv:
|
|
trace_spf_vma_access(_RET_IP_, vmf.vma, address);
|
|
/*
|
|
* We don't return VM_FAULT_RETRY so the caller is not expected to
|
|
* retrieve the fetched VMA.
|
|
*/
|
|
put_vma(vmf.vma);
|
|
*vma = NULL;
|
|
return VM_FAULT_SIGSEGV;
|
|
}
|
|
|
|
/*
|
|
* This is used to know if the vma fetch in the speculative page fault handler
|
|
* is still valid when trying the regular fault path while holding the
|
|
* mmap_sem.
|
|
* The call to put_vma(vma) must be made after checking the vma's fields, as
|
|
* the vma may be freed by put_vma(). In such a case it is expected that false
|
|
* is returned.
|
|
*/
|
|
bool can_reuse_spf_vma(struct vm_area_struct *vma, unsigned long address)
|
|
{
|
|
bool ret;
|
|
|
|
ret = !RB_EMPTY_NODE(&vma->vm_rb) &&
|
|
vma->vm_start <= address && address < vma->vm_end;
|
|
put_vma(vma);
|
|
return ret;
|
|
}
|
|
#endif /* CONFIG_SPECULATIVE_PAGE_FAULT */
|
|
|
|
/*
|
|
* By the time we get here, we already hold the mm semaphore
|
|
*
|
|
* The mmap_sem 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,
|
|
unsigned int flags)
|
|
{
|
|
vm_fault_t ret;
|
|
|
|
__set_current_state(TASK_RUNNING);
|
|
|
|
count_vm_event(PGFAULT);
|
|
count_memcg_event_mm(vma->vm_mm, PGFAULT);
|
|
|
|
/* do counter updates before entering really critical section. */
|
|
check_sync_rss_stat(current);
|
|
|
|
if (!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE,
|
|
flags & FAULT_FLAG_INSTRUCTION,
|
|
flags & FAULT_FLAG_REMOTE))
|
|
return VM_FAULT_SIGSEGV;
|
|
|
|
/*
|
|
* Enable the memcg OOM handling for faults triggered in user
|
|
* space. Kernel faults are handled more gracefully.
|
|
*/
|
|
if (flags & FAULT_FLAG_USER)
|
|
mem_cgroup_enter_user_fault();
|
|
|
|
if (unlikely(is_vm_hugetlb_page(vma)))
|
|
ret = hugetlb_fault(vma->vm_mm, vma, address, flags);
|
|
else
|
|
ret = __handle_mm_fault(vma, address, flags);
|
|
|
|
if (flags & FAULT_FLAG_USER) {
|
|
mem_cgroup_exit_user_fault();
|
|
/*
|
|
* The task may have entered a memcg OOM situation but
|
|
* if the allocation error was handled gracefully (no
|
|
* VM_FAULT_OOM), there is no need to kill anything.
|
|
* Just clean up the OOM state peacefully.
|
|
*/
|
|
if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))
|
|
mem_cgroup_oom_synchronize(false);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(handle_mm_fault);
|
|
|
|
#ifndef __PAGETABLE_P4D_FOLDED
|
|
/*
|
|
* Allocate p4d page table.
|
|
* We've already handled the fast-path in-line.
|
|
*/
|
|
int __p4d_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
|
|
{
|
|
p4d_t *new = p4d_alloc_one(mm, address);
|
|
if (!new)
|
|
return -ENOMEM;
|
|
|
|
smp_wmb(); /* See comment in __pte_alloc */
|
|
|
|
spin_lock(&mm->page_table_lock);
|
|
if (pgd_present(*pgd)) /* Another has populated it */
|
|
p4d_free(mm, new);
|
|
else
|
|
pgd_populate(mm, pgd, new);
|
|
spin_unlock(&mm->page_table_lock);
|
|
return 0;
|
|
}
|
|
#endif /* __PAGETABLE_P4D_FOLDED */
|
|
|
|
#ifndef __PAGETABLE_PUD_FOLDED
|
|
/*
|
|
* Allocate page upper directory.
|
|
* We've already handled the fast-path in-line.
|
|
*/
|
|
int __pud_alloc(struct mm_struct *mm, p4d_t *p4d, unsigned long address)
|
|
{
|
|
pud_t *new = pud_alloc_one(mm, address);
|
|
if (!new)
|
|
return -ENOMEM;
|
|
|
|
smp_wmb(); /* See comment in __pte_alloc */
|
|
|
|
spin_lock(&mm->page_table_lock);
|
|
#ifndef __ARCH_HAS_5LEVEL_HACK
|
|
if (!p4d_present(*p4d)) {
|
|
mm_inc_nr_puds(mm);
|
|
p4d_populate(mm, p4d, new);
|
|
} else /* Another has populated it */
|
|
pud_free(mm, new);
|
|
#else
|
|
if (!pgd_present(*p4d)) {
|
|
mm_inc_nr_puds(mm);
|
|
pgd_populate(mm, p4d, new);
|
|
} else /* Another has populated it */
|
|
pud_free(mm, new);
|
|
#endif /* __ARCH_HAS_5LEVEL_HACK */
|
|
spin_unlock(&mm->page_table_lock);
|
|
return 0;
|
|
}
|
|
#endif /* __PAGETABLE_PUD_FOLDED */
|
|
|
|
#ifndef __PAGETABLE_PMD_FOLDED
|
|
/*
|
|
* Allocate page middle directory.
|
|
* We've already handled the fast-path in-line.
|
|
*/
|
|
int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
|
|
{
|
|
spinlock_t *ptl;
|
|
pmd_t *new = pmd_alloc_one(mm, address);
|
|
if (!new)
|
|
return -ENOMEM;
|
|
|
|
smp_wmb(); /* See comment in __pte_alloc */
|
|
|
|
ptl = pud_lock(mm, pud);
|
|
#ifndef __ARCH_HAS_4LEVEL_HACK
|
|
if (!pud_present(*pud)) {
|
|
mm_inc_nr_pmds(mm);
|
|
pud_populate(mm, pud, new);
|
|
} else /* Another has populated it */
|
|
pmd_free(mm, new);
|
|
#else
|
|
if (!pgd_present(*pud)) {
|
|
mm_inc_nr_pmds(mm);
|
|
pgd_populate(mm, pud, new);
|
|
} else /* Another has populated it */
|
|
pmd_free(mm, new);
|
|
#endif /* __ARCH_HAS_4LEVEL_HACK */
|
|
spin_unlock(ptl);
|
|
return 0;
|
|
}
|
|
#endif /* __PAGETABLE_PMD_FOLDED */
|
|
|
|
static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
|
|
unsigned long *start, unsigned long *end,
|
|
pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
|
|
{
|
|
pgd_t *pgd;
|
|
p4d_t *p4d;
|
|
pud_t *pud;
|
|
pmd_t *pmd;
|
|
pte_t *ptep;
|
|
|
|
pgd = pgd_offset(mm, address);
|
|
if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
|
|
goto out;
|
|
|
|
p4d = p4d_offset(pgd, address);
|
|
if (p4d_none(*p4d) || unlikely(p4d_bad(*p4d)))
|
|
goto out;
|
|
|
|
pud = pud_offset(p4d, address);
|
|
if (pud_none(*pud) || unlikely(pud_bad(*pud)))
|
|
goto out;
|
|
|
|
pmd = pmd_offset(pud, address);
|
|
VM_BUG_ON(pmd_trans_huge(*pmd));
|
|
|
|
if (pmd_huge(*pmd)) {
|
|
if (!pmdpp)
|
|
goto out;
|
|
|
|
if (start && end) {
|
|
*start = address & PMD_MASK;
|
|
*end = *start + PMD_SIZE;
|
|
mmu_notifier_invalidate_range_start(mm, *start, *end);
|
|
}
|
|
*ptlp = pmd_lock(mm, pmd);
|
|
if (pmd_huge(*pmd)) {
|
|
*pmdpp = pmd;
|
|
return 0;
|
|
}
|
|
spin_unlock(*ptlp);
|
|
if (start && end)
|
|
mmu_notifier_invalidate_range_end(mm, *start, *end);
|
|
}
|
|
|
|
if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
|
|
goto out;
|
|
|
|
if (start && end) {
|
|
*start = address & PAGE_MASK;
|
|
*end = *start + PAGE_SIZE;
|
|
mmu_notifier_invalidate_range_start(mm, *start, *end);
|
|
}
|
|
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
|
|
if (!pte_present(*ptep))
|
|
goto unlock;
|
|
*ptepp = ptep;
|
|
return 0;
|
|
unlock:
|
|
pte_unmap_unlock(ptep, *ptlp);
|
|
if (start && end)
|
|
mmu_notifier_invalidate_range_end(mm, *start, *end);
|
|
out:
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline int follow_pte(struct mm_struct *mm, unsigned long address,
|
|
pte_t **ptepp, spinlock_t **ptlp)
|
|
{
|
|
int res;
|
|
|
|
/* (void) is needed to make gcc happy */
|
|
(void) __cond_lock(*ptlp,
|
|
!(res = __follow_pte_pmd(mm, address, NULL, NULL,
|
|
ptepp, NULL, ptlp)));
|
|
return res;
|
|
}
|
|
|
|
int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
|
|
unsigned long *start, unsigned long *end,
|
|
pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
|
|
{
|
|
int res;
|
|
|
|
/* (void) is needed to make gcc happy */
|
|
(void) __cond_lock(*ptlp,
|
|
!(res = __follow_pte_pmd(mm, address, start, end,
|
|
ptepp, pmdpp, ptlp)));
|
|
return res;
|
|
}
|
|
EXPORT_SYMBOL(follow_pte_pmd);
|
|
|
|
/**
|
|
* follow_pfn - look up PFN at a user virtual address
|
|
* @vma: memory mapping
|
|
* @address: user virtual address
|
|
* @pfn: location to store found PFN
|
|
*
|
|
* Only IO mappings and raw PFN mappings are allowed.
|
|
*
|
|
* Returns zero and the pfn at @pfn on success, -ve otherwise.
|
|
*/
|
|
int follow_pfn(struct vm_area_struct *vma, unsigned long address,
|
|
unsigned long *pfn)
|
|
{
|
|
int ret = -EINVAL;
|
|
spinlock_t *ptl;
|
|
pte_t *ptep;
|
|
|
|
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
|
|
return ret;
|
|
|
|
ret = follow_pte(vma->vm_mm, address, &ptep, &ptl);
|
|
if (ret)
|
|
return ret;
|
|
*pfn = pte_pfn(*ptep);
|
|
pte_unmap_unlock(ptep, ptl);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(follow_pfn);
|
|
|
|
#ifdef CONFIG_HAVE_IOREMAP_PROT
|
|
int follow_phys(struct vm_area_struct *vma,
|
|
unsigned long address, unsigned int flags,
|
|
unsigned long *prot, resource_size_t *phys)
|
|
{
|
|
int ret = -EINVAL;
|
|
pte_t *ptep, pte;
|
|
spinlock_t *ptl;
|
|
|
|
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
|
|
goto out;
|
|
|
|
if (follow_pte(vma->vm_mm, address, &ptep, &ptl))
|
|
goto out;
|
|
pte = *ptep;
|
|
|
|
if ((flags & FOLL_WRITE) && !pte_write(pte))
|
|
goto unlock;
|
|
|
|
*prot = pgprot_val(pte_pgprot(pte));
|
|
*phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT;
|
|
|
|
ret = 0;
|
|
unlock:
|
|
pte_unmap_unlock(ptep, ptl);
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
|
|
void *buf, int len, int write)
|
|
{
|
|
resource_size_t phys_addr;
|
|
unsigned long prot = 0;
|
|
void __iomem *maddr;
|
|
int offset = addr & (PAGE_SIZE-1);
|
|
|
|
if (follow_phys(vma, addr, write, &prot, &phys_addr))
|
|
return -EINVAL;
|
|
|
|
maddr = ioremap_prot(phys_addr, PAGE_ALIGN(len + offset), prot);
|
|
if (!maddr)
|
|
return -ENOMEM;
|
|
|
|
if (write)
|
|
memcpy_toio(maddr + offset, buf, len);
|
|
else
|
|
memcpy_fromio(buf, maddr + offset, len);
|
|
iounmap(maddr);
|
|
|
|
return len;
|
|
}
|
|
EXPORT_SYMBOL_GPL(generic_access_phys);
|
|
#endif
|
|
|
|
/*
|
|
* Access another process' address space as given in mm. If non-NULL, use the
|
|
* given task for page fault accounting.
|
|
*/
|
|
int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
|
|
unsigned long addr, void *buf, int len, unsigned int gup_flags)
|
|
{
|
|
struct vm_area_struct *vma;
|
|
void *old_buf = buf;
|
|
int write = gup_flags & FOLL_WRITE;
|
|
|
|
if (down_read_killable(&mm->mmap_sem))
|
|
return 0;
|
|
|
|
/* ignore errors, just check how much was successfully transferred */
|
|
while (len) {
|
|
int bytes, ret, offset;
|
|
void *maddr;
|
|
struct page *page = NULL;
|
|
|
|
ret = get_user_pages_remote(tsk, mm, addr, 1,
|
|
gup_flags, &page, &vma, NULL);
|
|
if (ret <= 0) {
|
|
#ifndef CONFIG_HAVE_IOREMAP_PROT
|
|
break;
|
|
#else
|
|
/*
|
|
* Check if this is a VM_IO | VM_PFNMAP VMA, which
|
|
* we can access using slightly different code.
|
|
*/
|
|
vma = find_vma(mm, addr);
|
|
if (!vma || vma->vm_start > addr)
|
|
break;
|
|
if (vma->vm_ops && vma->vm_ops->access)
|
|
ret = vma->vm_ops->access(vma, addr, buf,
|
|
len, write);
|
|
if (ret <= 0)
|
|
break;
|
|
bytes = ret;
|
|
#endif
|
|
} else {
|
|
bytes = len;
|
|
offset = addr & (PAGE_SIZE-1);
|
|
if (bytes > PAGE_SIZE-offset)
|
|
bytes = PAGE_SIZE-offset;
|
|
|
|
maddr = kmap(page);
|
|
if (write) {
|
|
copy_to_user_page(vma, page, addr,
|
|
maddr + offset, buf, bytes);
|
|
set_page_dirty_lock(page);
|
|
} else {
|
|
copy_from_user_page(vma, page, addr,
|
|
buf, maddr + offset, bytes);
|
|
}
|
|
kunmap(page);
|
|
put_page(page);
|
|
}
|
|
len -= bytes;
|
|
buf += bytes;
|
|
addr += bytes;
|
|
}
|
|
up_read(&mm->mmap_sem);
|
|
|
|
return buf - old_buf;
|
|
}
|
|
|
|
/**
|
|
* access_remote_vm - access another process' address space
|
|
* @mm: the mm_struct of the target address space
|
|
* @addr: start address to access
|
|
* @buf: source or destination buffer
|
|
* @len: number of bytes to transfer
|
|
* @gup_flags: flags modifying lookup behaviour
|
|
*
|
|
* The caller must hold a reference on @mm.
|
|
*/
|
|
int access_remote_vm(struct mm_struct *mm, unsigned long addr,
|
|
void *buf, int len, unsigned int gup_flags)
|
|
{
|
|
return __access_remote_vm(NULL, mm, addr, buf, len, gup_flags);
|
|
}
|
|
|
|
/*
|
|
* Access another process' address space.
|
|
* Source/target buffer must be kernel space,
|
|
* Do not walk the page table directly, use get_user_pages
|
|
*/
|
|
int access_process_vm(struct task_struct *tsk, unsigned long addr,
|
|
void *buf, int len, unsigned int gup_flags)
|
|
{
|
|
struct mm_struct *mm;
|
|
int ret;
|
|
|
|
mm = get_task_mm(tsk);
|
|
if (!mm)
|
|
return 0;
|
|
|
|
ret = __access_remote_vm(tsk, mm, addr, buf, len, gup_flags);
|
|
|
|
mmput(mm);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(access_process_vm);
|
|
|
|
/*
|
|
* Print the name of a VMA.
|
|
*/
|
|
void print_vma_addr(char *prefix, unsigned long ip)
|
|
{
|
|
struct mm_struct *mm = current->mm;
|
|
struct vm_area_struct *vma;
|
|
|
|
/*
|
|
* we might be running from an atomic context so we cannot sleep
|
|
*/
|
|
if (!down_read_trylock(&mm->mmap_sem))
|
|
return;
|
|
|
|
vma = find_vma(mm, ip);
|
|
if (vma && vma->vm_file) {
|
|
struct file *f = vma->vm_file;
|
|
char *buf = (char *)__get_free_page(GFP_NOWAIT);
|
|
if (buf) {
|
|
char *p;
|
|
|
|
p = file_path(f, buf, PAGE_SIZE);
|
|
if (IS_ERR(p))
|
|
p = "?";
|
|
printk("%s%s[%lx+%lx]", prefix, kbasename(p),
|
|
vma->vm_start,
|
|
vma->vm_end - vma->vm_start);
|
|
free_page((unsigned long)buf);
|
|
}
|
|
}
|
|
up_read(&mm->mmap_sem);
|
|
}
|
|
|
|
#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)
|
|
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
|
|
* get paged out, therefore we'll never actually fault, and the
|
|
* below annotations will generate false positives.
|
|
*/
|
|
if (uaccess_kernel())
|
|
return;
|
|
if (pagefault_disabled())
|
|
return;
|
|
__might_sleep(file, line, 0);
|
|
#if defined(CONFIG_DEBUG_ATOMIC_SLEEP)
|
|
if (current->mm)
|
|
might_lock_read(¤t->mm->mmap_sem);
|
|
#endif
|
|
}
|
|
EXPORT_SYMBOL(__might_fault);
|
|
#endif
|
|
|
|
#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
|
|
/*
|
|
* Process all subpages of the specified huge page with the specified
|
|
* operation. The target subpage will be processed last to keep its
|
|
* cache lines hot.
|
|
*/
|
|
static inline void process_huge_page(
|
|
unsigned long addr_hint, unsigned int pages_per_huge_page,
|
|
void (*process_subpage)(unsigned long addr, int idx, void *arg),
|
|
void *arg)
|
|
{
|
|
int i, n, base, l;
|
|
unsigned long addr = addr_hint &
|
|
~(((unsigned long)pages_per_huge_page << PAGE_SHIFT) - 1);
|
|
|
|
/* Process target subpage last to keep its cache lines hot */
|
|
might_sleep();
|
|
n = (addr_hint - addr) / PAGE_SIZE;
|
|
if (2 * n <= pages_per_huge_page) {
|
|
/* If target subpage in first half of huge page */
|
|
base = 0;
|
|
l = n;
|
|
/* Process subpages at the end of huge page */
|
|
for (i = pages_per_huge_page - 1; i >= 2 * n; i--) {
|
|
cond_resched();
|
|
process_subpage(addr + i * PAGE_SIZE, i, arg);
|
|
}
|
|
} else {
|
|
/* If target subpage in second half of huge page */
|
|
base = pages_per_huge_page - 2 * (pages_per_huge_page - n);
|
|
l = pages_per_huge_page - n;
|
|
/* Process subpages at the begin of huge page */
|
|
for (i = 0; i < base; i++) {
|
|
cond_resched();
|
|
process_subpage(addr + i * PAGE_SIZE, i, arg);
|
|
}
|
|
}
|
|
/*
|
|
* Process remaining subpages in left-right-left-right pattern
|
|
* towards the target subpage
|
|
*/
|
|
for (i = 0; i < l; i++) {
|
|
int left_idx = base + i;
|
|
int right_idx = base + 2 * l - 1 - i;
|
|
|
|
cond_resched();
|
|
process_subpage(addr + left_idx * PAGE_SIZE, left_idx, arg);
|
|
cond_resched();
|
|
process_subpage(addr + right_idx * PAGE_SIZE, right_idx, arg);
|
|
}
|
|
}
|
|
|
|
static void clear_gigantic_page(struct page *page,
|
|
unsigned long addr,
|
|
unsigned int pages_per_huge_page)
|
|
{
|
|
int i;
|
|
struct page *p = page;
|
|
|
|
might_sleep();
|
|
for (i = 0; i < pages_per_huge_page;
|
|
i++, p = mem_map_next(p, page, i)) {
|
|
cond_resched();
|
|
clear_user_highpage(p, addr + i * PAGE_SIZE);
|
|
}
|
|
}
|
|
|
|
static void clear_subpage(unsigned long addr, int idx, void *arg)
|
|
{
|
|
struct page *page = arg;
|
|
|
|
clear_user_highpage(page + idx, addr);
|
|
}
|
|
|
|
void clear_huge_page(struct page *page,
|
|
unsigned long addr_hint, unsigned int pages_per_huge_page)
|
|
{
|
|
unsigned long addr = addr_hint &
|
|
~(((unsigned long)pages_per_huge_page << PAGE_SHIFT) - 1);
|
|
|
|
if (unlikely(pages_per_huge_page > MAX_ORDER_NR_PAGES)) {
|
|
clear_gigantic_page(page, addr, pages_per_huge_page);
|
|
return;
|
|
}
|
|
|
|
process_huge_page(addr_hint, pages_per_huge_page, clear_subpage, page);
|
|
}
|
|
|
|
static void copy_user_gigantic_page(struct page *dst, struct page *src,
|
|
unsigned long addr,
|
|
struct vm_area_struct *vma,
|
|
unsigned int pages_per_huge_page)
|
|
{
|
|
int i;
|
|
struct page *dst_base = dst;
|
|
struct page *src_base = src;
|
|
|
|
for (i = 0; i < pages_per_huge_page; ) {
|
|
cond_resched();
|
|
copy_user_highpage(dst, src, addr + i*PAGE_SIZE, vma);
|
|
|
|
i++;
|
|
dst = mem_map_next(dst, dst_base, i);
|
|
src = mem_map_next(src, src_base, i);
|
|
}
|
|
}
|
|
|
|
struct copy_subpage_arg {
|
|
struct page *dst;
|
|
struct page *src;
|
|
struct vm_area_struct *vma;
|
|
};
|
|
|
|
static void copy_subpage(unsigned long addr, int idx, void *arg)
|
|
{
|
|
struct copy_subpage_arg *copy_arg = arg;
|
|
|
|
copy_user_highpage(copy_arg->dst + idx, copy_arg->src + idx,
|
|
addr, copy_arg->vma);
|
|
}
|
|
|
|
void copy_user_huge_page(struct page *dst, struct page *src,
|
|
unsigned long addr_hint, struct vm_area_struct *vma,
|
|
unsigned int pages_per_huge_page)
|
|
{
|
|
unsigned long addr = addr_hint &
|
|
~(((unsigned long)pages_per_huge_page << PAGE_SHIFT) - 1);
|
|
struct copy_subpage_arg arg = {
|
|
.dst = dst,
|
|
.src = src,
|
|
.vma = vma,
|
|
};
|
|
|
|
if (unlikely(pages_per_huge_page > MAX_ORDER_NR_PAGES)) {
|
|
copy_user_gigantic_page(dst, src, addr, vma,
|
|
pages_per_huge_page);
|
|
return;
|
|
}
|
|
|
|
process_huge_page(addr_hint, pages_per_huge_page, copy_subpage, &arg);
|
|
}
|
|
|
|
long copy_huge_page_from_user(struct page *dst_page,
|
|
const void __user *usr_src,
|
|
unsigned int pages_per_huge_page,
|
|
bool allow_pagefault)
|
|
{
|
|
void *src = (void *)usr_src;
|
|
void *page_kaddr;
|
|
unsigned long i, rc = 0;
|
|
unsigned long ret_val = pages_per_huge_page * PAGE_SIZE;
|
|
|
|
for (i = 0; i < pages_per_huge_page; i++) {
|
|
if (allow_pagefault)
|
|
page_kaddr = kmap(dst_page + i);
|
|
else
|
|
page_kaddr = kmap_atomic(dst_page + i);
|
|
rc = copy_from_user(page_kaddr,
|
|
(const void __user *)(src + i * PAGE_SIZE),
|
|
PAGE_SIZE);
|
|
if (allow_pagefault)
|
|
kunmap(dst_page + i);
|
|
else
|
|
kunmap_atomic(page_kaddr);
|
|
|
|
ret_val -= (PAGE_SIZE - rc);
|
|
if (rc)
|
|
break;
|
|
|
|
cond_resched();
|
|
}
|
|
return ret_val;
|
|
}
|
|
#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
|
|
|
|
#if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS
|
|
|
|
static struct kmem_cache *page_ptl_cachep;
|
|
|
|
void __init ptlock_cache_init(void)
|
|
{
|
|
page_ptl_cachep = kmem_cache_create("page->ptl", sizeof(spinlock_t), 0,
|
|
SLAB_PANIC, NULL);
|
|
}
|
|
|
|
bool ptlock_alloc(struct page *page)
|
|
{
|
|
spinlock_t *ptl;
|
|
|
|
ptl = kmem_cache_alloc(page_ptl_cachep, GFP_KERNEL);
|
|
if (!ptl)
|
|
return false;
|
|
page->ptl = ptl;
|
|
return true;
|
|
}
|
|
|
|
void ptlock_free(struct page *page)
|
|
{
|
|
kmem_cache_free(page_ptl_cachep, page->ptl);
|
|
}
|
|
#endif
|