mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
* refs/heads/tmp-816f245: Revert "clk: qcom: rcg2: Don't crash if our parent can't be found; return an error" Reverting crypto patches Reverting incremental fs changes Linux 4.14.180 cgroup, netclassid: remove double cond_resched mac80211: add ieee80211_is_any_nullfunc() ALSA: hda: Match both PCI ID and SSID for driver blacklist tracing: Reverse the order of trace_types_lock and event_mutex 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 net: dsa: b53: Rework ARL bin logic 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 net: stmmac: Fix sub-second increment net: stmmac: fix enabling socfpga's ptp_ref_clock wimax/i2400m: Fix potential urb refcnt leak ASoC: codecs: hdac_hdmi: Fix incorrect use of list_for_each_entry ASoC: rsnd: Fix HDMI channel mapping for multi-SSI mode 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: arm64: fix a mismerge in proc.S Linux 4.14.179 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/mlx4: Initialize ib_spec on the stack RDMA/mlx5: Set GRH fields in query QP on RoCE 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: hda/realtek - Two front mics on a Lenovo ThinkCenter mmc: sdhci-pci: Fix eMMC driver strength for BYT-based controllers mmc: sdhci-xenon: fix annoying 1.8V regulator warning btrfs: fix partial loss of prealloc extent past i_size after fsync 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 ext4: fix special inode number checks in __ext4_iget() ANDROID: Incremental fs: Fix issues with very large files Linux 4.14.178 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 ext4: unsigned int compared against zero ext4: fix block validity checks for journal inodes using indirect blocks ext4: don't perform block validity checks on the journal inode ext4: protect journal inode's blocks using block_validity ext4: avoid declaring fs inconsistent due to invalid file handles 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 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: fix PR IN / READ FULL STATUS for FC xfs: fix partially uninitialized structure in xfs_reflink_remap_extent x86: hyperv: report value of misc_features bpf, x86: Fix encoding for lower 8-bit registers in BPF_STX BPF_B mm: shmem: disable interrupt when acquiring info->lock in userfaultfd_copy path perf/core: fix parent pid/tid in task exit events ARM: dts: bcm283x: Disable dsi0 node net/cxgb4: Check the return from t4_query_params properly i2c: altera: use proper variable to hold errno nfsd: memory corruption in nfsd4_lock() 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 xfs: Fix deadlock between AGI and AGF with RENAME_WHITEOUT xfs: validate sb_logsunit is a multiple of the fs blocksize serial: sh-sci: Make sure status register SCxSR is read in correct sequence usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() 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 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: 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 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: 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 overflow.h: Add arithmetic shift helper 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: 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 ALSA: hda: Remove ASUS ROG Zenith from the blacklist KEYS: Avoid false positive ENOMEM error on key read vrf: Check skb for XFRM_TRANSFORMED flag xfrm: Always set XFRM_TRANSFORMED in xfrm{4,6}_output_finish net: dsa: b53: Fix ARL register definitions team: fix hang in team_mode_get() tcp: cache line align MAX_TCP_HEADER net/x25: Fix x25_neigh refcnt leak when receiving frame 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 mm, slub: restore the original intention of prefetch_freepointer() PCI/ASPM: Allow re-enabling Clock PM perf/core: Disable page faults when getting phys address pwm: bcm2835: Dynamically allocate base pwm: renesas-tpu: Fix late Runtime PM enablement s390/cio: avoid duplicated 'ADD' uevents 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 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 kasan slab-out-of-bounds error in lpfc_unreg_login watchdog: reset last_hw_keepalive time at start vti4: removed duplicate log message. crypto: mxs-dcp - make symbols 'sha1_null_hash' and 'sha256_null_hash' static drm/msm: Use the correct dma_sync calls harder keys: Fix the use of the C++ keyword "private" in uapi/linux/keyctl.h net: ipv4: avoid unused variable warning for sysctl net: ipv4: emulate READ_ONCE() on ->hdrincl bit-field in raw_sendmsg() ext4: fix extent_status fragmentation for plain files FROMGIT: f2fs: fix missing check for f2fs_unlock_op ANDROID: Fix kernel build regressions from virtio-gpu-next patches ANDROID: Incremental fs: Add setattr call ANDROID: cuttlefish_defconfig: enable LTO and CFI ANDROID: x86: map CFI jump tables in pti_clone_entry_text ANDROID: crypto: aesni: fix function types for aesni_(enc|dec) ANDROID: x86: disable CFI for do_syscall_* ANDROID: BACKPORT: x86, module: Ignore __typeid__ relocations ANDROID: BACKPORT: x86, relocs: Ignore __typeid__ relocations ANDROID: BACKPORT: x86/extable: Do not mark exception callback as CFI FROMLIST: crypto, x86/sha: Eliminate casts on asm implementations UPSTREAM: crypto: x86 - Rename functions to avoid conflict with crypto/sha256.h BACKPORT: x86/vmlinux: Actually use _etext for the end of the text segment ANDROID: x86: disable STACK_VALIDATION with LTO_CLANG ANDROID: x86: add support for CONFIG_LTO_CLANG ANDROID: x86/vdso: disable LTO only for VDSO ANDROID: x86/cpu/vmware: use the full form of inl in VMWARE_PORT UPSTREAM: x86/build/lto: Fix truncated .bss with -fdata-sections ANDROID: kbuild: don't select LD_DEAD_CODE_DATA_ELIMINATION with LTO ANDROID: kbuild: export LTO and CFI flags ANDROID: cfi: remove unnecessary <asm/memory.h> include ANDROID: drm/virtio: rebase to latest virgl/drm-misc-next (take 2) UPSTREAM: sysrq: Use panic() to force a crash ANDROID: Incremental fs: Use simple compression in log buffer ANDROID: dm-bow: Fix not to skip trim at framented range ANDROID: Remove VLA from uid_sys_stats.c ANDROID: cuttlefish_defconfig: enable CONFIG_DEBUG_LIST Linux 4.14.177 KEYS: Don't write out to userspace while holding key semaphore KEYS: Use individual pages in big_key for crypto buffers mtd: phram: fix a double free issue in error path mtd: lpddr: Fix a double free in probe() locktorture: Print ratio of acquisitions, not failures tty: evh_bytechan: Fix out of bounds accesses fbdev: potential information leak in do_fb_ioctl() net: dsa: bcm_sf2: Fix overflow checks iommu/amd: Fix the configuration of GCR3 table root pointer libnvdimm: Out of bounds read in __nd_ioctl() ext2: fix debug reference to ext2_xattr_cache ext2: fix empty body warnings when -Wextra is used iommu/vt-d: Fix mm reference leak 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() ext4: do not commit super on read-only bdev 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 of: unittest: kmemleak in of_unittest_platform_populate() rbd: call rbd_dev_unprobe() after unwatching and flushing notifies rbd: avoid a deadlock on header_rwsem when flushing notifies of: fix missing kobject init for !SYSFS && OF_DYNAMIC config soc: qcom: smem: Use le32_to_cpu for comparison wil6210: abort properly in cfg suspend wil6210: fix length check in __wmi_send wil6210: add block size checks during FW load wil6210: fix PCIe bus mastering in case of interface down rpmsg: glink: smem: Ensure ordering during tx rpmsg: glink: Fix missing mutex_init() in qcom_glink_alloc_channel() rtc: pm8xxx: Fix issue in RTC write path rpmsg: glink: use put_device() if device_register fail wil6210: rate limit wil_rx_refill error scsi: ufs: ufs-qcom: remove broken hci version quirk scsi: ufs: make sure all interrupts are processed wil6210: fix temperature debugfs wil6210: increase firmware ready timeout arch_topology: Fix section miss match warning due to free_raw_capacity() arm64: traps: Don't print stack or raw PC/LR values in backtraces arm64: perf: remove unsupported events for Cortex-A73 Revert "gpio: set up initial state from .get_direction()" clk: Fix debugfs_create_*() usage drm: NULL pointer dereference [null-pointer-deref] (CWE 476) problem video: fbdev: sis: Remove unnecessary parentheses and commented code lib/raid6: use vdupq_n_u8 to avoid endianness warnings 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, bpf: Fix bugs with ALU64 {RSH, ARSH} BPF_K shift by 0 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 mm/vmalloc.c: move 'area->pages' after if statement x86/resctrl: Fix invalid attempt at removing the default resource group x86/resctrl: Preserve CDP enable over CPU hotplug x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG x86/intel_rdt: Add two new resources for L2 Code and Data Prioritization (CDP) x86/intel_rdt: Enumerate L2 Code and Data Prioritization (CDP) feature 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 dm flakey: check for null arg_name in parse_features() ext4: do not zeroout extents beyond i_disksize 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 ALSA: usb-audio: Don't override ignore_ctl_error value from the map 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 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 mfd: dln2: Fix sanity checking for endpoints misc: echo: Remove unnecessary parentheses and simplify check for zero powerpc/fsl_booke: Avoid creating duplicate tlb1 entry ipmi: fix hung processes in __get_guid() 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 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 Btrfs: fix crash during unmount due to race with delayed inode workers 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 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 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() rtc: omap: Use define directive for PIN_CONFIG_ACTIVE_HIGH 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 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() net: rtnl_configure_link: fix dev flags changes arg to __dev_notify_flags ALSA: hda: Initialize power_state field properly crypto: mxs-dcp - fix scatterlist linearization for hash btrfs: drop block from cache on error in relocation CIFS: Fix bug which the return value by asynchronous read is error KVM: VMX: fix crash cleanup when KVM wasn't used 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 irqchip/versatile-fpga: Apply clear-mask earlier KEYS: reaching the keys quotas correctly PCI: endpoint: Fix for concurrent memory allocation in OB address region PCI/ASPM: Clear the correct bits when enabling L1 substates 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 - 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 misc: rtsx: set correct pcr_ops for rts522A uapi: rename ext2_swab() to swab() and share globally in swab.h btrfs: track reloc roots based on their commit root bytenr btrfs: remove a BUG_ON() from merge_reloc_roots() block, bfq: fix use-after-free in bfq_idle_slice_timer_body locking/lockdep: Avoid recursion in lockdep_count_{for,back}ward_deps() irqchip/gic-v4: Provide irq_retrigger to avoid circular locking dependency usb: dwc3: core: add support for disabling SS instances in park mode 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 libata: Remove extra scsi_host_put() in ata_scsi_add_hosts() 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 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 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 ANDROID: fix wakeup reason findings UPSTREAM: gpu/trace: add a gpu total memory usage tracepoint CHROMIUM: drm/virtio: rebase zero-copy patches to virgl/drm-misc-next CHROMIUM: virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature CHROMIUM: drm/virtgpu: add legacy VIRTIO_GPU_* values for non-upstream variants CHROMIUM: drm/virtgpu: fix various warnings CHROMIUM: drm/virtgpu: implement metadata allocation ioctl CHROMIUM: drm/virtgpu: introduce request IDRs CHROMIUM: drm/virtgpu: implement DRM_VIRTGPU_RESOURCE_CREATE_V2 CHROMIUM: drm/virtgpu: add stub ioctl implementation CHROMIUM: drm/virtgpu: check for revelant capabilites CHROMIUM: drm/virtgpu: add memory type to virtio_gpu_object_params CHROMIUM: drm/virtgpu: make memory and resource creation opaque CHROMIUM: virtio-gpu api: VIRTIO_GPU_F_MEMORY CHROMIUM: virtwl: store plane info per virtio_gpu_object CHROMIUM: drm/virtgpu: expose new ioctls to userspace BACKPORT: drm/virtio: move virtio_gpu_object_{attach, detach} calls. ANDROID: drm: ttm: Add ttm_tt_create2 driver hook UPSTREAM: virtio-gpu api: comment feature flags UPSTREAM: drm/virtio: module_param_named() requires linux/moduleparam.h BACKPORT: drm/virtio: fix resource id creation race BACKPORT: drm/virtio: make resource id workaround runtime switchable. BACKPORT: drm/virtio: do NOT reuse resource ids BACKPORT: drm/virtio: Drop deprecated load/unload initialization 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 UPSTREAM: kheaders: include only headers into kheaders_data.tar.xz UPSTREAM: kheaders: remove meaningless -R option of 'ls' ANDROID: Incremental fs: Fix create_file performance 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 Revert "ANDROID: Incremental fs: Fix initialization, use of bitfields" Linux 4.14.176 drm/msm: Use the correct dma_sync calls in msm_gem rpmsg: glink: smem: Support rx peak for size less than 4 bytes 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 acpi/nfit: Fix bus command validation 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 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 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 ipv6: don't auto-add link-local address to lag ports mm: mempolicy: require at least one nodeid for MPOL_PREFERRED padata: always acquire cpu_hotplug_lock before pinst->lock coresight: do not use the BIT() macro in the UAPI header misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices blk-mq: Allow blocking queue tag iter callbacks blk-mq: sync the update nr_hw_queues with blk_mq_queue_tag_busy_iter drm/etnaviv: replace MMU flush marker with flush sequence tools/power turbostat: Fix gcc build warnings initramfs: restore default compression behavior drm/bochs: downgrade pci_request_region failure from error to warning 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: power: wakeup_reason: wake reason enhancements 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 FROMLIST: power_supply: Add additional health properties to the header UPSTREAM: power: supply: core: Update sysfs-class-power ABI document BACKPORT: FROMGIT: kbuild: mkcompile_h: Include $LD version in /proc/version 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 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 UPSTREAM: loop: Only freeze block queue when needed. UPSTREAM: loop: Only change blocksize when needed. 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: Fix wq fp check for CFI builds ANDROID: Incremental fs: Fix four resource bugs ANDROID: kbuild: ensure __cfi_check is correctly aligned ANDROID: kbuild: fix module linker script flags for LTO Linux 4.14.175 arm64: dts: ls1046ardb: set RGMII interfaces to RGMII_ID mode arm64: dts: ls1043a-rdb: correct RGMII delay mode to rgmii-id 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() 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 afs: Fix some tracing details Input: raydium_i2c_ts - fix error codes in raydium_i2c_boot_trigger() Input: raydium_i2c_ts - use true and false for boolean values vti6: Fix memory leak of skb if input policy check fails netfilter: nft_fwd_netdev: validate family and chain type 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 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 Input: avoid BIT() macro usage in the serio.h UAPI header Input: synaptics - enable RMI on HP Envy 13-ad105ng 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() arm64: compat: map SPSR_ELx<->PSR for signals arm64: ptrace: map SPSR_ELx<->PSR for compat tasks 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 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 cgroup-v1: cgroup_pidlist_next should update position index net: ipv4: don't let PMTU updates increase route MTU 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() net: dsa: mt7530: Change the LINK bit to reflect the link status 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 macsec: restrict to ethernet devices hsr: fix general protection fault in hsr_addr_is_self() Revert "drm/dp_mst: Skip validating ports during destruction, just ref" staging: greybus: loopback_test: fix potential path truncations staging: greybus: loopback_test: fix potential path truncation drm/bridge: dw-hdmi: fix AVI frame colorimetry arm64: smp: fix crash_smp_send_stop() behaviour arm64: smp: fix smp_send_stop() behaviour ALSA: hda/realtek: Fix pop noise on ALC225 Revert "ipv6: Fix handling of LLA with VRF and sockets bound to VRF" Revert "vrf: mark skb for multicast or link-local as enslaved to VRF" futex: Unbreak futex hashing futex: Fix inode life-time issue kbuild: Disable -Wpointer-to-enum-cast iio: adc: at91-sama5d2_adc: fix differential channels in triggered mode iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels USB: cdc-acm: fix rounding error in TIOCSSERIAL USB: cdc-acm: fix close_delay and closing_wait units in TIOCSSERIAL x86/mm: split vmalloc_sync_all() page-flags: fix a crash at SetPageError(THP_SWAP) mm, slub: prevent kmalloc_node crashes and memory leaks mm: slub: be more careful about the double cmpxchg of freelist memcg: fix NULL pointer dereference in __mem_cgroup_usage_unregister_event xhci: Do not open code __print_symbolic() in xhci trace events rtc: max8907: add missing select REGMAP_IRQ intel_th: pci: Add Elkhart Lake CPU support intel_th: Fix user-visible error codes staging/speakup: fix get_word non-space look-ahead staging: rtl8188eu: Add device id for MERCUSYS MW150US v2 mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 iio: magnetometer: ak8974: Fix negative raw values in sysfs iio: trigger: stm32-timer: disable master mode when stopping ALSA: pcm: oss: Remove WARNING from snd_pcm_plug_alloc() checks ALSA: pcm: oss: Avoid plugin buffer overflow ALSA: seq: oss: Fix running status after receiving sysex ALSA: seq: virmidi: Fix running status after receiving sysex ALSA: line6: Fix endless MIDI read loop usb: xhci: apply XHCI_SUSPEND_DELAY to AMD XHCI controller 1022:145c USB: serial: pl2303: add device-id for HP LD381 usb: host: xhci-plat: add a shutdown USB: serial: option: add ME910G1 ECM composition 0x110b usb: quirks: add NO_LPM quirk for RTL8153 based ethernet adapters USB: Disable LPM on WD19's Realtek Hub parse-maintainers: Mark as executable block, bfq: fix overwrite of bfq_group pointer in bfq_find_set_group() xenbus: req->err should be updated before req->state xenbus: req->body should be updated before req->state dm bio record: save/restore bi_end_io and bi_integrity altera-stapl: altera_get_note: prevent write beyond end of 'key' drivers/perf: arm_pmu_acpi: Fix incorrect checking of gicc pointer drm/exynos: dsi: fix workaround for the legacy clock name drm/exynos: dsi: propagate error value and silence meaningless warning spi/zynqmp: remove entry that causes a cs glitch spi: pxa2xx: Add CS control clock quirk ARM: dts: dra7: Add "dma-ranges" property to PCIe RC DT nodes powerpc: Include .BTF section spi: qup: call spi_qup_pm_resume_runtime before suspending UPSTREAM: ubifs: wire up FS_IOC_GET_ENCRYPTION_NONCE UPSTREAM: f2fs: wire up FS_IOC_GET_ENCRYPTION_NONCE UPSTREAM: ext4: wire up FS_IOC_GET_ENCRYPTION_NONCE UPSTREAM: fscrypt: add FS_IOC_GET_ENCRYPTION_NONCE ioctl UPSTREAM: usb: raw_gadget: fix compilation warnings in uapi headers BACKPORT: usb: gadget: add raw-gadget interface UPSTREAM: usb: gadget: move choice ... endchoice to legacy/Kconfig ANDROID: clang: update to 10.0.5 FROMLIST: arm64: define __alloc_zeroed_user_highpage ANDROID: Incremental fs: Add INCFS_IOC_GET_FILLED_BLOCKS ANDROID: Incremental fs: Fix two typos 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 UPSTREAM: ipv6: ndisc: add support for 'PREF64' dns64 prefix identifier UPSTREAM: ipv6: ndisc: add support for 'PREF64' dns64 prefix identifier ANDROID: dm-bow: Fix free_show value is incorrect UPSTREAM: coresight: Potential uninitialized variable in probe() ANDROID: kbuild: do not merge .section..* into .section in modules ANDROID: scsi: ufs: add ->map_sg_crypto() variant op UPSTREAM: bpf: Explicitly memset some bpf info structures declared on the stack UPSTREAM: bpf: Explicitly memset the bpf_attr structure Linux 4.14.174 ipv4: ensure rcu_read_lock() in cipso_v4_error() mm: slub: add missing TID bump in kmem_cache_alloc_bulk() ARM: 8958/1: rename missed uaccess .fixup section ARM: 8957/1: VDSO: Match ARMv8 timer in cntvct_functional() jbd2: fix data races at struct journal_head net: rmnet: fix NULL pointer dereference in rmnet_newlink() hinic: fix a bug of setting hw_ioctxt slip: not call free_netdev before rtnl_unlock in slip_open signal: avoid double atomic counter increments for user accounting mac80211: rx: avoid RCU list traversal under mutex net: ks8851-ml: Fix IRQ handling and locking net: usb: qmi_wwan: restore mtu min/max values after raw_ip switch scsi: libfc: free response frame from GPN_ID cfg80211: check reg_rule for NULL in handle_channel_custom() HID: i2c-hid: add Trekstor Surfbook E11B to descriptor override HID: apple: Add support for recent firmware on Magic Keyboards ACPI: watchdog: Allow disabling WDAT at boot perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT flag batman-adv: Don't schedule OGM for disabled interface batman-adv: Avoid free/alloc race when handling OGM buffer batman-adv: Avoid free/alloc race when handling OGM2 buffer batman-adv: Fix duplicated OGMs on NETDEV_UP batman-adv: Fix debugfs path for renamed softif batman-adv: Fix debugfs path for renamed hardif batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs batman-adv: Fix TT sync flags for intermediate TT responses batman-adv: Avoid race in TT TVLV allocator helper batman-adv: update data pointers after skb_cow() batman-adv: Fix internal interface indices types batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible batman-adv: Always initialize fragment header priority batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation efi: Add a sanity check to efivar_store_raw() net/smc: check for valid ib_client_data ipv6: restrict IPV6_ADDRFORM operation i2c: acpi: put device when verifying client fails iommu/vt-d: Ignore devices with out-of-spec domain number iommu/vt-d: Fix the wrong printing in RHSA parsing netfilter: nft_payload: add missing attribute validation for payload csum flags netfilter: cthelper: add missing attribute validation for cthelper nl80211: add missing attribute validation for channel switch nl80211: add missing attribute validation for beacon report scanning nl80211: add missing attribute validation for critical protocol indication pinctrl: core: Remove extra kref_get which blocks hogs being freed pinctrl: meson-gxl: fix GPIOX sdio pins iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page iommu/vt-d: dmar: replace WARN_TAINT with pr_warn + add_taint iommu/dma: Fix MSI reservation allocation x86/mce: Fix logic and comments around MSR_PPIN_CTL efi: Fix a race and a buffer overflow while reading efivars via sysfs ARC: define __ALIGN_STR and __ALIGN symbols for ARC KVM: x86: clear stale x86_emulate_ctxt->intercept value gfs2_atomic_open(): fix O_EXCL|O_CREAT handling on cold dcache cifs_atomic_open(): fix double-put on late allocation failure ktest: Add timeout for ssh sync testing drm/amd/display: remove duplicated assignment to grph_obj_type workqueue: don't use wq_select_unbound_cpu() for bound works iommu/vt-d: quirk_ioat_snb_local_iommu: replace WARN_TAINT with pr_warn + add_taint virtio-blk: fix hw_queue stopped on arbitrary error iwlwifi: mvm: Do not require PHY_SKU NVM section for 3168 devices cgroup: Iterate tasks that did not finish do_exit() cgroup: cgroup_procs_next should increase position index ipvlan: don't deref eth hdr before checking it's set ipvlan: egress mcast packets are not exceptional ipvlan: do not add hardware address of master to its unicast filter list inet_diag: return classid for all socket types macvlan: add cond_resched() during multicast processing net: fec: validate the new settings in fec_enet_set_coalesce() slip: make slhc_compress() more robust against malicious packets bonding/alb: make sure arp header is pulled before accessing it net: phy: fix MDIO bus PM PHY resuming nfc: add missing attribute validation for vendor subcommand nfc: add missing attribute validation for SE API team: add missing attribute validation for array index team: add missing attribute validation for port ifindex net: fq: add missing attribute validation for orphan mask macsec: add missing attribute validation for port can: add missing attribute validation for termination nl802154: add missing attribute validation for dev_type nl802154: add missing attribute validation fib: add missing attribute validation for tun_id net: memcg: fix lockdep splat in inet_csk_accept() net: memcg: late association of sock to memcg cgroup: memcg: net: do not associate sock with unrelated cgroup bnxt_en: reinitialize IRQs when MTU is modified sfc: detach from cb_page in efx_copy_channel() r8152: check disconnect status after long sleep net/packet: tpacket_rcv: do not increment ring index on drop net: nfc: fix bounds checking bugs on "pipe" net: macsec: update SCI upon MAC address change. netlink: Use netlink header as base to calculate bad attribute offset ipvlan: do not use cond_resched_rcu() in ipvlan_process_multicast() ipvlan: add cond_resched_rcu() while processing muticast backlog ipv6/addrconf: call ipv6_mc_up() for non-Ethernet interface gre: fix uninit-value in __iptunnel_pull_header cgroup, netclassid: periodically release file_lock on classid updating net: phy: Avoid multiple suspends phy: Revert toggling reset changes. ANDROID: Incremental fs: Add INCFS_IOC_PERMIT_FILL ANDROID: Incremental fs: Remove signature checks from kernel ANDROID: Incremental fs: Pad hash blocks ANDROID: Incremental fs: Make fill block an ioctl ANDROID: Incremental fs: Remove all access_ok checks UPSTREAM: cgroup: Iterate tasks that did not finish do_exit() UPSTREAM: arm64: memory: Add missing brackets to untagged_addr() macro UPSTREAM: mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() ANDROID: Add TPM support and the vTPM proxy to Cuttlefish. ANDROID: serdev: restrict claim of platform devices UPSTREAM: fscrypt: don't evict dirty inodes after removing key fscrypt: don't evict dirty inodes after removing key Linux 4.14.173 ASoC: topology: Fix memleak in soc_tplg_manifest_load() xhci: handle port status events for removed USB3 hcd dm integrity: fix a deadlock due to offloading to an incorrect workqueue powerpc: fix hardware PMU exception bug on PowerVM compatibility mode systems dmaengine: coh901318: Fix a double lock bug in dma_tc_handle() hwmon: (adt7462) Fix an error return in ADT7462_REG_VOLT() ARM: imx: build v7_cpu_resume() unconditionally IB/hfi1, qib: Ensure RCU is locked when accessing list RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() RDMA/iwcm: Fix iwcm work deallocation ASoC: dapm: Correct DAPM handling of active widgets during shutdown ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output ASoC: intel: skl: Fix possible buffer overflow in debug outputs ASoC: intel: skl: Fix pin debug prints ASoC: topology: Fix memleak in soc_tplg_link_elems_load() ARM: dts: ls1021a: Restore MDIO compatible to gianfar dm cache: fix a crash due to incorrect work item cancelling dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list dmaengine: tegra-apb: Fix use-after-free x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes vt: selection, push sel_lock up vt: selection, push console lock down vt: selection, close sel_buffer race serial: 8250_exar: add support for ACCES cards tty:serial:mvebu-uart:fix a wrong return arm: dts: dra76x: Fix mmc3 max-frequency fat: fix uninit-memory access for partial initialized inode mm, numa: fix bad pmd by atomically check for pmd_trans_huge when marking page tables prot_numa vgacon: Fix a UAF in vgacon_invert_region usb: core: port: do error out if usb_autopm_get_interface() fails usb: core: hub: do error out if usb_autopm_get_interface() fails usb: core: hub: fix unhandled return by employing a void function usb: quirks: add NO_LPM quirk for Logitech Screen Share usb: storage: Add quirk for Samsung Fit flash cifs: don't leak -EAGAIN for stat() during reconnect net: thunderx: workaround BGX TX Underflow issue x86/xen: Distribute switch variables for initialization nvme: Fix uninitialized-variable warning x86/boot/compressed: Don't declare __force_order in kaslr_64.c s390/cio: cio_ignore_proc_seq_next should increase position index watchdog: da9062: do not ping the hw during stop() net: ks8851-ml: Fix 16-bit IO operation net: ks8851-ml: Fix 16-bit data access net: ks8851-ml: Remove 8-bit bus accessors drm/msm/dsi: save pll state before dsi host is powered off drm: msm: Fix return type of dsi_mgr_connector_mode_valid for kCFI drm/msm/mdp5: rate limit pp done timeout warnings usb: gadget: serial: fix Tx stall after buffer overflow usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags usb: gadget: composite: Support more than 500mA MaxPower selftests: fix too long argument serial: ar933x_uart: set UART_CS_{RX,TX}_READY_ORIDE kprobes: Fix optimize_kprobe()/unoptimize_kprobe() cancellation logic RDMA/core: Fix use of logical OR in get_new_pps RDMA/core: Fix pkey and port assignment in get_new_pps net: dsa: bcm_sf2: Forcibly configure IMP port for 1Gb/sec EDAC/amd64: Set grain per DIMM x86/mce: Handle varying MCA bank counts vhost: Check docket sk_family instead of call getname audit: always check the netlink payload length in audit_receive_msg() Revert "char/random: silence a lockdep splat with printk()" mm, thp: fix defrag setting if newline is not used mm/huge_memory.c: use head to check huge zero page perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc kprobes: Set unoptimized flag after unoptimizing code drivers: net: xgene: Fix the order of the arguments of 'alloc_etherdev_mqs()' tuntap: correctly set SOCKWQ_ASYNC_NOSPACE KVM: Check for a bad hva before dropping into the ghc slow path KVM: SVM: Override default MMIO mask if memory encryption is enabled mwifiex: drop most magic numbers from mwifiex_process_tdls_action_frame() namei: only return -ECHILD from follow_dotdot_rcu() net: ena: make ena rxfh support ETH_RSS_HASH_NO_CHANGE net: atlantic: fix potential error handling net: netlink: cap max groups which will be considered in netlink_bind() include/linux/bitops.h: introduce BITS_PER_TYPE ecryptfs: Fix up bad backport of fe2e082f5da5b4a0a92ae32978f81507ef37ec66 usb: charger: assign specific number for enum value drm/i915/gvt: Separate display reset from ALL_ENGINES reset i2c: jz4780: silence log flood on txabrt i2c: altera: Fix potential integer overflow MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()' HID: hiddev: Fix race in in hiddev_disconnect() Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs" tracing: Disable trace_printk() on post poned tests HID: core: increase HID report buffer size to 8KiB HID: core: fix off-by-one memset in hid_report_raw_event() HID: ite: Only bind to keyboard USB interface on Acer SW5-012 keyboard dock KVM: VMX: check descriptor table exits on instruction emulation ACPI: watchdog: Fix gas->access_width usage ACPICA: Introduce ACPI_ACCESS_BYTE_WIDTH() macro audit: fix error handling in audit_data_to_entry() ext4: potential crash on allocation error in ext4_alloc_flex_bg_array() net: sched: correct flower port blocking qede: Fix race between rdma destroy workqueue and link change event ipv6: Fix route replacement with dev-only route ipv6: Fix nlmsg_flags when splitting a multipath route sctp: move the format error check out of __sctp_sf_do_9_1_abort nfc: pn544: Fix occasional HW initialization failure net: phy: restore mdio regs in the iproc mdio driver net: fib_rules: Correctly set table field when table number exceeds 8 bits sysrq: Remove duplicated sysrq message sysrq: Restore original console_loglevel when sysrq disabled cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE cifs: Fix mode output in debugging statements net: ena: ena-com.c: prevent NULL pointer dereference net: ena: ethtool: use correct value for crc32 hash net: ena: fix incorrectly saving queue numbers when setting RSS indirection table net: ena: rss: store hash function as values and not bits net: ena: rss: fix failure to get indirection table net: ena: fix incorrect default RSS key net: ena: add missing ethtool TX timestamping indication net: ena: fix uses of round_jiffies() net: ena: fix potential crash when rxfh key is NULL qmi_wwan: unconditionally reject 2 ep interfaces qmi_wwan: re-add DW5821e pre-production variant cfg80211: check wiphy driver existence for drvinfo report mac80211: consider more elements in parsing CRC dax: pass NOWAIT flag to iomap_apply drm/msm: Set dma maximum segment size for mdss ipmi:ssif: Handle a possible NULL pointer reference ext4: fix potential race between s_group_info online resizing and access ext4: fix potential race between s_flex_groups online resizing and access ext4: fix potential race between online resizing and write operations netfilter: nf_conntrack: resolve clash for matching conntracks iwlwifi: pcie: fix rb_allocator workqueue allocation FROMLIST: f2fs: fix wrong check on F2FS_IOC_FSSETXATTR UPSTREAM: binder: prevent UAF for binderfs devices II UPSTREAM: binder: prevent UAF for binderfs devices FROMLIST: lib: test_stackinit.c: XFAIL switch variable init tests ANDROID: cuttlefish: disable KPROBES ANDROID: scsi: ufs: allow ufs variants to override sg entry size FROMLIST: ufs: fix a bug on printing PRDT BACKPORT: loop: Add LOOP_SET_BLOCK_SIZE in compat ioctl ANDROID: fix build issue in security/selinux/avc.c ANDROID: cuttlefish_defconfig: Disable CONFIG_RT_GROUP_SCHED ANDROID: Enable HID_NINTENDO as y FROMLIST: HID: nintendo: add nintendo switch controller driver Linux 4.14.172 s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range xen: Enable interrupts when calling _cond_resched() ata: ahci: Add shutdown to freeze hardware resources of ahci netfilter: xt_hashlimit: limit the max size of hashtable ALSA: seq: Fix concurrent access to queue current tick/time ALSA: seq: Avoid concurrent access to queue flags ALSA: rawmidi: Avoid bit fields for state flags genirq/proc: Reject invalid affinity masks (again) iommu/vt-d: Fix compile warning from intel-svm.h ecryptfs: replace BUG_ON with error handling code staging: greybus: use after free in gb_audio_manager_remove_all() staging: rtl8723bs: fix copy of overlapping memory usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session" scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout" Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents btrfs: do not check delayed items are empty for single transaction cleanup btrfs: fix bytes_may_use underflow in prealloc error condtition KVM: apic: avoid calculating pending eoi from an uninitialized val KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1 KVM: nVMX: Check IO instruction VM-exit conditions KVM: nVMX: Refactor IO bitmap checks into helper function ext4: fix race between writepages and enabling EXT4_EXTENTS_FL ext4: rename s_journal_flag_rwsem to s_writepages_rwsem ext4: fix mount failure with quota configured as module ext4: add cond_resched() to __ext4_find_entry() ext4: fix a data race in EXT4_I(inode)->i_disksize KVM: nVMX: Don't emulate instructions in guest mode lib/stackdepot.c: fix global out-of-bounds in stack_slabs serial: 8250: Check UPF_IRQ_SHARED in advance vt: vt_ioctl: fix race in VT_RESIZEX VT_RESIZEX: get rid of field-by-field copyin xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI drm/amdgpu/soc15: fix xclk for raven mm/vmscan.c: don't round up scan size for online memory cgroup Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" MAINTAINERS: Update drm/i915 bug filing URL serdev: ttyport: restore client ops on deregistration tty: serial: imx: setup the correct sg entry for tx dma tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode x86/mce/amd: Fix kobject lifetime x86/mce/amd: Publish the bank pointer only after setup has succeeded staging: rtl8723bs: Fix potential overuse of kernel memory staging: rtl8723bs: Fix potential security hole staging: rtl8188eu: Fix potential overuse of kernel memory staging: rtl8188eu: Fix potential security hole USB: hub: Fix the broken detection of USB3 device in SMSC hub USB: hub: Don't record a connect-change event during reset-resume USB: Fix novation SourceControl XL after suspend usb: uas: fix a plug & unplug racing usb: host: xhci: update event ring dequeue pointer on purpose xhci: fix runtime pm enabling for quirky Intel hosts xhci: Force Maximum Packet size for Full-speed bulk devices to valid range. staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi. staging: android: ashmem: Disallow ashmem memory from being remapped vt: selection, handle pending signals in paste_selection floppy: check FDC index for errors before assigning it USB: misc: iowarrior: add support for the 100 device USB: misc: iowarrior: add support for the 28 and 28L devices USB: misc: iowarrior: add support for 2 OEMed devices thunderbolt: Prevent crash if non-active NVMem file is read net/smc: fix leak of kernel memory to user space net/sched: flower: add missing validation of TCA_FLOWER_FLAGS net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS net: dsa: tag_qca: Make sure there is headroom for tag enic: prevent waking up stopped tx queues over watchdog reset selinux: ensure we cleanup the internal AVC counters on error in avc_update() mlxsw: spectrum_dpipe: Add missing error path virtio_balloon: prevent pfn array overflow help_next should increase position index brd: check and limit max_part par microblaze: Prevent the overflow of the start iwlwifi: mvm: Fix thermal zone registration irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL bcache: explicity type cast in bset_bkey_last() reiserfs: prevent NULL pointer dereference in reiserfs_insert_item() lib/scatterlist.c: adjust indentation in __sg_alloc_table ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() radeon: insert 10ms sleep in dce5_crtc_load_lut trigger_next should increase position index ftrace: fpid_next() should increase position index drm/nouveau/disp/nv50-: prevent oops when no channel method map provided irqchip/gic-v3: Only provision redistributors that are enabled in ACPI ceph: check availability of mds cluster on mount after wait timeout cifs: fix NULL dereference in match_prepath iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop hostap: Adjust indentation in prism2_hostapd_add_sta ARM: 8951/1: Fix Kexec compilation issue. jbd2: make sure ESHUTDOWN to be recorded in the journal superblock jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV ALSA: hda - Add docking station support for Lenovo Thinkpad T420s driver core: platform: fix u32 greater or equal to zero comparison s390/ftrace: generate traced function stack frame x86/decoder: Add TEST opcode to Group3-2 ALSA: hda/hdmi - add retry logic to parse_intel_hdmi() irqchip/mbigen: Set driver .suppress_bind_attrs to avoid remove problems remoteproc: Initialize rproc_class before use btrfs: device stats, log when stats are zeroed btrfs: safely advance counter when looking up bio csums btrfs: fix possible NULL-pointer dereference in integrity checks pwm: Remove set but not set variable 'pwm' ide: serverworks: potential overflow in svwks_set_pio_mode() cmd64x: potential buffer overflow in cmd64x_program_timings() pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional x86/mm: Fix NX bit clearing issue in kernel_map_pages_in_pgd f2fs: fix memleak of kobject watchdog/softlockup: Enforce that timestamp is valid on boot arm64: fix alternatives with LLVM's integrated assembler scsi: iscsi: Don't destroy session if there are outstanding connections f2fs: free sysfs kobject iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw drm/nouveau/secboot/gm20b: initialize pointer in gm20b_secboot_new() vme: bridges: reduce stack usage driver core: Print device when resources present in really_probe() driver core: platform: Prevent resouce overflow from causing infinite loops tty: synclink_gt: Adjust indentation in several functions tty: synclinkmp: Adjust indentation in several functions ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m wan: ixp4xx_hss: fix compile-testing on 64-bit Input: edt-ft5x06 - work around first register access error rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls efi/x86: Don't panic or BUG() on non-critical error conditions soc/tegra: fuse: Correct straps' address for older Tegra124 device trees IB/hfi1: Add software counter for ctxt0 seq drop udf: Fix free space reporting for metadata and virtual partitions usbip: Fix unsafe unaligned pointer usage drm: remove the newline for CRC source name. tools lib api fs: Fix gcc9 stringop-truncation compilation error ALSA: sh: Fix compile warning wrt const ALSA: sh: Fix unused variable warnings clk: sunxi-ng: add mux and pll notifiers for A64 CPU clock RDMA/rxe: Fix error type of mmap_offset pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency x86/vdso: Provide missing include file dmaengine: Store module owner in dma_device struct ARM: dts: r8a7779: Add device node for ARM global timer drm/mediatek: handle events when enabling/disabling crtc scsi: aic7xxx: Adjust indentation in ahc_find_syncrate scsi: ufs: Complete pending requests in host reset and restore path ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1 orinoco: avoid assertion in case of NULL pointer rtlwifi: rtl_pci: Fix -Wcast-function-type iwlegacy: Fix -Wcast-function-type ipw2x00: Fix -Wcast-function-type b43legacy: Fix -Wcast-function-type ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status fore200e: Fix incorrect checks of NULL pointer dereference reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros ARM: dts: imx6: rdu2: Disable WP for USDHC2 and USDHC3 arm64: dts: qcom: msm8996: Disable USB2 PHY suspend by core NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu(). PCI/IOV: Fix memory leak in pci_iov_add_virtfn() net/wan/fsl_ucc_hdlc: reject muram offsets above 64K regulator: rk808: Lower log level on optional GPIOs being not available drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table clk: qcom: rcg2: Don't crash if our parent can't be found; return an error kconfig: fix broken dependency in randconfig-generated .config KVM: s390: ENOTSUPP -> EOPNOTSUPP fixups nbd: add a flush_workqueue in nbd_start_device ext4, jbd2: ensure panic when aborting with zero errno tracing: Fix very unlikely race of registering two stat tracers tracing: Fix tracing_stat return values in error handling paths x86/sysfb: Fix check for bad VRAM size jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal kselftest: Minimise dependency of get_size on C library interfaces clocksource/drivers/bcm2835_timer: Fix memory leak of timer usb: dwc2: Fix IN FIFO allocation usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe() uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol() sparc: Add .exit.data section. MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() efi/x86: Map the entire EFI vendor string before copying it pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run() char/random: silence a lockdep splat with printk() gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap() powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number media: i2c: mt9v032: fix enum mbus codes and frame sizes pxa168fb: Fix the function used to release some memory in an error handling path pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs gianfar: Fix TX timestamping with a stacked DSA driver ALSA: ctl: allow TLV read operation for callback type of element in locked case ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT leds: pca963x: Fix open-drain initialization brcmfmac: Fix use after free in brcmf_sdio_readframes() cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order drm/gma500: Fixup fbdev stolen size usage evaluation KVM: nVMX: Use correct root level for nested EPT shadow page tables Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs" Revert "KVM: nVMX: Use correct root level for nested EPT shadow page tables" scsi: qla2xxx: fix a potential NULL pointer dereference jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer jbd2: move the clearing of b_modified flag to the journal_unmap_buffer() hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions. perf/x86/intel: Fix inaccurate period in context switch for auto-reload s390/time: Fix clk type in get_tod_clock RDMA/core: Fix protection fault in get_pkey_idx_qp_list IB/hfi1: Close window for pq and request coliding serial: imx: Only handle irqs that are actually enabled serial: imx: ensure that RX irqs are off if RX is off padata: Remove broken queue flushing perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map KVM: nVMX: Use correct root level for nested EPT shadow page tables arm64: ssbs: Fix context-switch when SSBS is present on all CPUs btrfs: log message when rw remount is attempted with unclean tree-log btrfs: print message when tree-log replay starts Btrfs: fix race between using extent maps and merging them ext4: improve explanation of a mount failure caused by a misconfigured kernel ext4: fix checksum errors with indexed dirs ext4: fix support for inode sizes > 1024 bytes ext4: don't assume that mmp_nodename/bdevname have NUL ARM: 8723/2: always assume the "unified" syntax for assembly code arm64: nofpsimd: Handle TIF_FOREIGN_FPSTATE flag cleanly arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly ALSA: usb-audio: Apply sample rate quirk for Audioengine D1 Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list Input: synaptics - enable SMBus on ThinkPad L470 Input: synaptics - switch T470s to RMI4 by default ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() ecryptfs: fix a memory leak bug in parse_tag_1_packet() ASoC: sun8i-codec: Fix setting DAI data format ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs iommu/qcom: Fix bogus detach logic KVM: x86: emulate RDPID UPSTREAM: sched/psi: Fix OOB write when writing 0 bytes to PSI files UPSTREAM: psi: Fix a division error in psi poll() UPSTREAM: sched/psi: Fix sampling error and rare div0 crashes with cgroups and high uptime UPSTREAM: sched/psi: Correct overly pessimistic size calculation FROMLIST: f2fs: Handle casefolding with Encryption FROMLIST: fscrypt: Have filesystems handle their d_ops FROMLIST: ext4: Use generic casefolding support FROMLIST: f2fs: Use generic casefolding support FROMLIST: Add standard casefolding support FROMLIST: unicode: Add utf8_casefold_hash ANDROID: cuttlefish_defconfig: Add CONFIG_UNICODE ANDROID: sdcardfs: fix -ENOENT lookup race issue ANDROID: gki_defconfig: Enable CONFIG_RD_LZ4 ANDROID: dm: Add wrapped key support in dm-default-key ANDROID: dm: add support for passing through derive_raw_secret ANDROID: block: Prevent crypto fallback for wrapped keys ANDROID: Disable wq fp check in CFI builds ANDROID: increase limit on sched-tune boost groups ANDROID: ufs, block: fix crypto power management and move into block layer ANDROID: Incremental fs: Support xattrs ANDROID: test_stackinit: work around LLVM PR44916 ANDROID: clang: update to 10.0.4 fs-verity: use u64_to_user_ptr() fs-verity: use mempool for hash requests fs-verity: implement readahead of Merkle tree pages ext4: readpages() should submit IO as read-ahead fs-verity: implement readahead for FS_IOC_ENABLE_VERITY fscrypt: improve format of no-key names ubifs: allow both hash and disk name to be provided in no-key names ubifs: don't trigger assertion on invalid no-key filename fscrypt: clarify what is meant by a per-file key fscrypt: derive dirhash key for casefolded directories fscrypt: don't allow v1 policies with casefolding fscrypt: add "fscrypt_" prefix to fname_encrypt() fscrypt: don't print name of busy file when removing key fscrypt: document gfp_flags for bounce page allocation fscrypt: optimize fscrypt_zeroout_range() fscrypt: remove redundant bi_status check fscrypt: Allow modular crypto algorithms fscrypt: include <linux/ioctl.h> in UAPI header fscrypt: don't check for ENOKEY from fscrypt_get_encryption_info() fscrypt: remove fscrypt_is_direct_key_policy() fscrypt: move fscrypt_valid_enc_modes() to policy.c fscrypt: check for appropriate use of DIRECT_KEY flag earlier fscrypt: split up fscrypt_supported_policy() by policy version fscrypt: introduce fscrypt_needs_contents_encryption() fscrypt: move fscrypt_d_revalidate() to fname.c fscrypt: constify inode parameter to filename encryption functions fscrypt: constify struct fscrypt_hkdf parameter to fscrypt_hkdf_expand() fscrypt: verify that the crypto_skcipher has the correct ivsize fscrypt: use crypto_skcipher_driver_name() fscrypt: support passing a keyring key to FS_IOC_ADD_ENCRYPTION_KEY keys: Export lookup_user_key to external users f2fs: fix build error on PAGE_KERNEL_RO Conflicts: arch/arm64/kernel/smp.c arch/arm64/kernel/traps.c block/blk-crypto-fallback.c block/keyslot-manager.c drivers/base/power/wakeup.c drivers/clk/clk.c drivers/clk/qcom/clk-rcg2.c drivers/gpu/Makefile drivers/gpu/drm/msm/msm_drv.c drivers/gpu/drm/msm/msm_gem.c drivers/hwtracing/coresight/coresight-funnel.c drivers/irqchip/irq-gic-v3.c drivers/md/dm.c drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c drivers/net/macsec.c drivers/net/phy/micrel.c drivers/net/wireless/ath/wil6210/cfg80211.c drivers/net/wireless/ath/wil6210/fw_inc.c drivers/net/wireless/ath/wil6210/pcie_bus.c drivers/net/wireless/ath/wil6210/pm.c drivers/net/wireless/ath/wil6210/wil6210.h drivers/of/base.c drivers/power/supply/power_supply_sysfs.c drivers/rpmsg/qcom_glink_smem.c drivers/scsi/sd.c drivers/scsi/ufs/ufshcd-crypto.c drivers/scsi/ufs/ufshcd.c drivers/scsi/ufs/ufshcd.h drivers/scsi/ufs/ufshci.h drivers/usb/dwc3/core.c drivers/usb/dwc3/gadget.c drivers/usb/gadget/Kconfig drivers/usb/gadget/composite.c drivers/usb/gadget/function/f_fs.c drivers/usb/gadget/legacy/Makefile drivers/usb/host/xhci-mem.c fs/ext4/readpage.c fs/sdcardfs/lookup.c include/linux/key.h include/linux/keyslot-manager.h include/linux/power_supply.h include/uapi/linux/coresight-stm.h net/qrtr/qrtr.c Change-Id: Iaa9fcbe987e721f02596e167249a519781ed3888 Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2910 lines
74 KiB
C
2910 lines
74 KiB
C
/*
|
|
* linux/mm/vmalloc.c
|
|
*
|
|
* Copyright (C) 1993 Linus Torvalds
|
|
* Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
|
|
* SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
|
|
* Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
|
|
* Numa awareness, Christoph Lameter, SGI, June 2005
|
|
*/
|
|
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/module.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/sched/signal.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/debugobjects.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/list.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/rbtree.h>
|
|
#include <linux/radix-tree.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/pfn.h>
|
|
#include <linux/kmemleak.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/llist.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/overflow.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <asm/tlbflush.h>
|
|
#include <asm/shmparam.h>
|
|
|
|
#include "internal.h"
|
|
|
|
struct vfree_deferred {
|
|
struct llist_head list;
|
|
struct work_struct wq;
|
|
};
|
|
static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred);
|
|
|
|
static void __vunmap(const void *, int);
|
|
|
|
static void free_work(struct work_struct *w)
|
|
{
|
|
struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq);
|
|
struct llist_node *t, *llnode;
|
|
|
|
llist_for_each_safe(llnode, t, llist_del_all(&p->list))
|
|
__vunmap((void *)llnode, 1);
|
|
}
|
|
|
|
/*** Page table manipulation functions ***/
|
|
|
|
static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
|
|
{
|
|
pte_t *pte;
|
|
|
|
pte = pte_offset_kernel(pmd, addr);
|
|
do {
|
|
pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
|
|
WARN_ON(!pte_none(ptent) && !pte_present(ptent));
|
|
} while (pte++, addr += PAGE_SIZE, addr != end);
|
|
}
|
|
|
|
static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
|
|
pmd = pmd_offset(pud, addr);
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
if (pmd_clear_huge(pmd))
|
|
continue;
|
|
if (pmd_none_or_clear_bad(pmd))
|
|
continue;
|
|
vunmap_pte_range(pmd, addr, next);
|
|
} while (pmd++, addr = next, addr != end);
|
|
}
|
|
|
|
static void vunmap_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
|
|
pud = pud_offset(p4d, addr);
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
if (pud_clear_huge(pud))
|
|
continue;
|
|
if (pud_none_or_clear_bad(pud))
|
|
continue;
|
|
vunmap_pmd_range(pud, addr, next);
|
|
} while (pud++, addr = next, addr != end);
|
|
}
|
|
|
|
static void vunmap_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
|
|
p4d = p4d_offset(pgd, addr);
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
if (p4d_clear_huge(p4d))
|
|
continue;
|
|
if (p4d_none_or_clear_bad(p4d))
|
|
continue;
|
|
vunmap_pud_range(p4d, addr, next);
|
|
} while (p4d++, addr = next, addr != end);
|
|
}
|
|
|
|
static void vunmap_page_range(unsigned long addr, unsigned long end)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
|
|
BUG_ON(addr >= end);
|
|
pgd = pgd_offset_k(addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
if (pgd_none_or_clear_bad(pgd))
|
|
continue;
|
|
vunmap_p4d_range(pgd, addr, next);
|
|
} while (pgd++, addr = next, addr != end);
|
|
}
|
|
|
|
static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
|
|
unsigned long end, pgprot_t prot, struct page **pages, int *nr)
|
|
{
|
|
pte_t *pte;
|
|
|
|
/*
|
|
* nr is a running index into the array which helps higher level
|
|
* callers keep track of where we're up to.
|
|
*/
|
|
|
|
pte = pte_alloc_kernel(pmd, addr);
|
|
if (!pte)
|
|
return -ENOMEM;
|
|
do {
|
|
struct page *page = pages[*nr];
|
|
|
|
if (WARN_ON(!pte_none(*pte)))
|
|
return -EBUSY;
|
|
if (WARN_ON(!page))
|
|
return -ENOMEM;
|
|
set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
|
|
(*nr)++;
|
|
} while (pte++, addr += PAGE_SIZE, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static int vmap_pmd_range(pud_t *pud, unsigned long addr,
|
|
unsigned long end, pgprot_t prot, struct page **pages, int *nr)
|
|
{
|
|
pmd_t *pmd;
|
|
unsigned long next;
|
|
|
|
pmd = pmd_alloc(&init_mm, pud, addr);
|
|
if (!pmd)
|
|
return -ENOMEM;
|
|
do {
|
|
next = pmd_addr_end(addr, end);
|
|
if (vmap_pte_range(pmd, addr, next, prot, pages, nr))
|
|
return -ENOMEM;
|
|
} while (pmd++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static int vmap_pud_range(p4d_t *p4d, unsigned long addr,
|
|
unsigned long end, pgprot_t prot, struct page **pages, int *nr)
|
|
{
|
|
pud_t *pud;
|
|
unsigned long next;
|
|
|
|
pud = pud_alloc(&init_mm, p4d, addr);
|
|
if (!pud)
|
|
return -ENOMEM;
|
|
do {
|
|
next = pud_addr_end(addr, end);
|
|
if (vmap_pmd_range(pud, addr, next, prot, pages, nr))
|
|
return -ENOMEM;
|
|
} while (pud++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
static int vmap_p4d_range(pgd_t *pgd, unsigned long addr,
|
|
unsigned long end, pgprot_t prot, struct page **pages, int *nr)
|
|
{
|
|
p4d_t *p4d;
|
|
unsigned long next;
|
|
|
|
p4d = p4d_alloc(&init_mm, pgd, addr);
|
|
if (!p4d)
|
|
return -ENOMEM;
|
|
do {
|
|
next = p4d_addr_end(addr, end);
|
|
if (vmap_pud_range(p4d, addr, next, prot, pages, nr))
|
|
return -ENOMEM;
|
|
} while (p4d++, addr = next, addr != end);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Set up page tables in kva (addr, end). The ptes shall have prot "prot", and
|
|
* will have pfns corresponding to the "pages" array.
|
|
*
|
|
* Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N]
|
|
*/
|
|
static int vmap_page_range_noflush(unsigned long start, unsigned long end,
|
|
pgprot_t prot, struct page **pages)
|
|
{
|
|
pgd_t *pgd;
|
|
unsigned long next;
|
|
unsigned long addr = start;
|
|
int err = 0;
|
|
int nr = 0;
|
|
|
|
BUG_ON(addr >= end);
|
|
pgd = pgd_offset_k(addr);
|
|
do {
|
|
next = pgd_addr_end(addr, end);
|
|
err = vmap_p4d_range(pgd, addr, next, prot, pages, &nr);
|
|
if (err)
|
|
return err;
|
|
} while (pgd++, addr = next, addr != end);
|
|
|
|
return nr;
|
|
}
|
|
|
|
static int vmap_page_range(unsigned long start, unsigned long end,
|
|
pgprot_t prot, struct page **pages)
|
|
{
|
|
int ret;
|
|
|
|
ret = vmap_page_range_noflush(start, end, prot, pages);
|
|
flush_cache_vmap(start, end);
|
|
return ret;
|
|
}
|
|
|
|
int is_vmalloc_or_module_addr(const void *x)
|
|
{
|
|
/*
|
|
* ARM, x86-64 and sparc64 put modules in a special place,
|
|
* and fall back on vmalloc() if that fails. Others
|
|
* just put it in the vmalloc space.
|
|
*/
|
|
#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
|
|
unsigned long addr = (unsigned long)x;
|
|
if (addr >= MODULES_VADDR && addr < MODULES_END)
|
|
return 1;
|
|
#endif
|
|
return is_vmalloc_addr(x);
|
|
}
|
|
|
|
/*
|
|
* Walk a vmap address to the struct page it maps.
|
|
*/
|
|
struct page *vmalloc_to_page(const void *vmalloc_addr)
|
|
{
|
|
unsigned long addr = (unsigned long) vmalloc_addr;
|
|
struct page *page = NULL;
|
|
pgd_t *pgd = pgd_offset_k(addr);
|
|
p4d_t *p4d;
|
|
pud_t *pud;
|
|
pmd_t *pmd;
|
|
pte_t *ptep, pte;
|
|
|
|
/*
|
|
* XXX we might need to change this if we add VIRTUAL_BUG_ON for
|
|
* architectures that do not vmalloc module space
|
|
*/
|
|
VIRTUAL_BUG_ON(!is_vmalloc_or_module_addr(vmalloc_addr));
|
|
|
|
if (pgd_none(*pgd))
|
|
return NULL;
|
|
p4d = p4d_offset(pgd, addr);
|
|
if (p4d_none(*p4d))
|
|
return NULL;
|
|
pud = pud_offset(p4d, addr);
|
|
|
|
/*
|
|
* Don't dereference bad PUD or PMD (below) entries. This will also
|
|
* identify huge mappings, which we may encounter on architectures
|
|
* that define CONFIG_HAVE_ARCH_HUGE_VMAP=y. Such regions will be
|
|
* identified as vmalloc addresses by is_vmalloc_addr(), but are
|
|
* not [unambiguously] associated with a struct page, so there is
|
|
* no correct value to return for them.
|
|
*/
|
|
WARN_ON_ONCE(pud_bad(*pud));
|
|
if (pud_none(*pud) || pud_bad(*pud))
|
|
return NULL;
|
|
pmd = pmd_offset(pud, addr);
|
|
WARN_ON_ONCE(pmd_bad(*pmd));
|
|
if (pmd_none(*pmd) || pmd_bad(*pmd))
|
|
return NULL;
|
|
|
|
ptep = pte_offset_map(pmd, addr);
|
|
pte = *ptep;
|
|
if (pte_present(pte))
|
|
page = pte_page(pte);
|
|
pte_unmap(ptep);
|
|
return page;
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_to_page);
|
|
|
|
/*
|
|
* Map a vmalloc()-space virtual address to the physical page frame number.
|
|
*/
|
|
unsigned long vmalloc_to_pfn(const void *vmalloc_addr)
|
|
{
|
|
return page_to_pfn(vmalloc_to_page(vmalloc_addr));
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_to_pfn);
|
|
|
|
|
|
/*** Global kva allocator ***/
|
|
|
|
#define VM_LAZY_FREE 0x02
|
|
#define VM_VM_AREA 0x04
|
|
|
|
static DEFINE_SPINLOCK(vmap_area_lock);
|
|
/* Export for kexec only */
|
|
LIST_HEAD(vmap_area_list);
|
|
static LLIST_HEAD(vmap_purge_list);
|
|
static struct rb_root vmap_area_root = RB_ROOT;
|
|
|
|
/* The vmap cache globals are protected by vmap_area_lock */
|
|
static struct rb_node *free_vmap_cache;
|
|
static unsigned long cached_hole_size;
|
|
static unsigned long cached_vstart;
|
|
static unsigned long cached_align;
|
|
|
|
static unsigned long vmap_area_pcpu_hole;
|
|
|
|
static atomic_long_t nr_vmalloc_pages;
|
|
|
|
unsigned long vmalloc_nr_pages(void)
|
|
{
|
|
return atomic_long_read(&nr_vmalloc_pages);
|
|
}
|
|
|
|
#ifdef CONFIG_ENABLE_VMALLOC_SAVING
|
|
#define POSSIBLE_VMALLOC_START PAGE_OFFSET
|
|
|
|
#define VMALLOC_BITMAP_SIZE ((VMALLOC_END - PAGE_OFFSET) >> \
|
|
PAGE_SHIFT)
|
|
#define VMALLOC_TO_BIT(addr) ((addr - PAGE_OFFSET) >> PAGE_SHIFT)
|
|
#define BIT_TO_VMALLOC(i) (PAGE_OFFSET + i * PAGE_SIZE)
|
|
|
|
unsigned long total_vmalloc_size;
|
|
static unsigned long vmalloc_reserved;
|
|
|
|
static DECLARE_BITMAP(possible_areas, VMALLOC_BITMAP_SIZE);
|
|
|
|
void mark_vmalloc_reserved_area(void *x, unsigned long size)
|
|
{
|
|
unsigned long addr = (unsigned long)x;
|
|
|
|
bitmap_set(possible_areas, VMALLOC_TO_BIT(addr), size >> PAGE_SHIFT);
|
|
vmalloc_reserved += size;
|
|
}
|
|
|
|
int is_vmalloc_addr(const void *x)
|
|
{
|
|
unsigned long addr = (unsigned long)x;
|
|
|
|
if (addr < POSSIBLE_VMALLOC_START || addr >= VMALLOC_END)
|
|
return 0;
|
|
|
|
if (test_bit(VMALLOC_TO_BIT(addr), possible_areas))
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static void calc_total_vmalloc_size(void)
|
|
{
|
|
total_vmalloc_size = VMALLOC_END - POSSIBLE_VMALLOC_START -
|
|
vmalloc_reserved;
|
|
}
|
|
#else
|
|
int is_vmalloc_addr(const void *x)
|
|
{
|
|
unsigned long addr = (unsigned long)x;
|
|
|
|
return addr >= VMALLOC_START && addr < VMALLOC_END;
|
|
}
|
|
|
|
static void calc_total_vmalloc_size(void) { }
|
|
#endif
|
|
EXPORT_SYMBOL(is_vmalloc_addr);
|
|
|
|
static struct vmap_area *__find_vmap_area(unsigned long addr)
|
|
{
|
|
struct rb_node *n = vmap_area_root.rb_node;
|
|
|
|
while (n) {
|
|
struct vmap_area *va;
|
|
|
|
va = rb_entry(n, struct vmap_area, rb_node);
|
|
if (addr < va->va_start)
|
|
n = n->rb_left;
|
|
else if (addr >= va->va_end)
|
|
n = n->rb_right;
|
|
else
|
|
return va;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static void __insert_vmap_area(struct vmap_area *va)
|
|
{
|
|
struct rb_node **p = &vmap_area_root.rb_node;
|
|
struct rb_node *parent = NULL;
|
|
struct rb_node *tmp;
|
|
|
|
while (*p) {
|
|
struct vmap_area *tmp_va;
|
|
|
|
parent = *p;
|
|
tmp_va = rb_entry(parent, struct vmap_area, rb_node);
|
|
if (va->va_start < tmp_va->va_end)
|
|
p = &(*p)->rb_left;
|
|
else if (va->va_end > tmp_va->va_start)
|
|
p = &(*p)->rb_right;
|
|
else
|
|
BUG();
|
|
}
|
|
|
|
rb_link_node(&va->rb_node, parent, p);
|
|
rb_insert_color(&va->rb_node, &vmap_area_root);
|
|
|
|
/* address-sort this list */
|
|
tmp = rb_prev(&va->rb_node);
|
|
if (tmp) {
|
|
struct vmap_area *prev;
|
|
prev = rb_entry(tmp, struct vmap_area, rb_node);
|
|
list_add_rcu(&va->list, &prev->list);
|
|
} else
|
|
list_add_rcu(&va->list, &vmap_area_list);
|
|
}
|
|
|
|
static void purge_vmap_area_lazy(void);
|
|
|
|
static BLOCKING_NOTIFIER_HEAD(vmap_notify_list);
|
|
|
|
/*
|
|
* Allocate a region of KVA of the specified size and alignment, within the
|
|
* vstart and vend.
|
|
*/
|
|
static struct vmap_area *alloc_vmap_area(unsigned long size,
|
|
unsigned long align,
|
|
unsigned long vstart, unsigned long vend,
|
|
int node, gfp_t gfp_mask)
|
|
{
|
|
struct vmap_area *va;
|
|
struct rb_node *n;
|
|
unsigned long addr;
|
|
int purged = 0;
|
|
struct vmap_area *first;
|
|
|
|
BUG_ON(!size);
|
|
BUG_ON(offset_in_page(size));
|
|
BUG_ON(!is_power_of_2(align));
|
|
|
|
might_sleep();
|
|
|
|
va = kmalloc_node(sizeof(struct vmap_area),
|
|
gfp_mask & GFP_RECLAIM_MASK, node);
|
|
if (unlikely(!va))
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
/*
|
|
* Only scan the relevant parts containing pointers to other objects
|
|
* to avoid false negatives.
|
|
*/
|
|
kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask & GFP_RECLAIM_MASK);
|
|
|
|
retry:
|
|
spin_lock(&vmap_area_lock);
|
|
/*
|
|
* Invalidate cache if we have more permissive parameters.
|
|
* cached_hole_size notes the largest hole noticed _below_
|
|
* the vmap_area cached in free_vmap_cache: if size fits
|
|
* into that hole, we want to scan from vstart to reuse
|
|
* the hole instead of allocating above free_vmap_cache.
|
|
* Note that __free_vmap_area may update free_vmap_cache
|
|
* without updating cached_hole_size or cached_align.
|
|
*/
|
|
if (!free_vmap_cache ||
|
|
size < cached_hole_size ||
|
|
vstart < cached_vstart ||
|
|
align < cached_align) {
|
|
nocache:
|
|
cached_hole_size = 0;
|
|
free_vmap_cache = NULL;
|
|
}
|
|
/* record if we encounter less permissive parameters */
|
|
cached_vstart = vstart;
|
|
cached_align = align;
|
|
|
|
/* find starting point for our search */
|
|
if (free_vmap_cache) {
|
|
first = rb_entry(free_vmap_cache, struct vmap_area, rb_node);
|
|
addr = ALIGN(first->va_end, align);
|
|
if (addr < vstart)
|
|
goto nocache;
|
|
if (addr + size < addr)
|
|
goto overflow;
|
|
|
|
} else {
|
|
addr = ALIGN(vstart, align);
|
|
if (addr + size < addr)
|
|
goto overflow;
|
|
|
|
n = vmap_area_root.rb_node;
|
|
first = NULL;
|
|
|
|
while (n) {
|
|
struct vmap_area *tmp;
|
|
tmp = rb_entry(n, struct vmap_area, rb_node);
|
|
if (tmp->va_end >= addr) {
|
|
first = tmp;
|
|
if (tmp->va_start <= addr)
|
|
break;
|
|
n = n->rb_left;
|
|
} else
|
|
n = n->rb_right;
|
|
}
|
|
|
|
if (!first)
|
|
goto found;
|
|
}
|
|
|
|
/* from the starting point, walk areas until a suitable hole is found */
|
|
while (addr + size > first->va_start && addr + size <= vend) {
|
|
if (addr + cached_hole_size < first->va_start)
|
|
cached_hole_size = first->va_start - addr;
|
|
addr = ALIGN(first->va_end, align);
|
|
if (addr + size < addr)
|
|
goto overflow;
|
|
|
|
if (list_is_last(&first->list, &vmap_area_list))
|
|
goto found;
|
|
|
|
first = list_next_entry(first, list);
|
|
}
|
|
|
|
found:
|
|
/*
|
|
* Check also calculated address against the vstart,
|
|
* because it can be 0 because of big align request.
|
|
*/
|
|
if (addr + size > vend || addr < vstart)
|
|
goto overflow;
|
|
|
|
va->va_start = addr;
|
|
va->va_end = addr + size;
|
|
va->flags = 0;
|
|
__insert_vmap_area(va);
|
|
free_vmap_cache = &va->rb_node;
|
|
spin_unlock(&vmap_area_lock);
|
|
|
|
BUG_ON(!IS_ALIGNED(va->va_start, align));
|
|
BUG_ON(va->va_start < vstart);
|
|
BUG_ON(va->va_end > vend);
|
|
|
|
return va;
|
|
|
|
overflow:
|
|
spin_unlock(&vmap_area_lock);
|
|
if (!purged) {
|
|
purge_vmap_area_lazy();
|
|
purged = 1;
|
|
goto retry;
|
|
}
|
|
|
|
if (gfpflags_allow_blocking(gfp_mask)) {
|
|
unsigned long freed = 0;
|
|
blocking_notifier_call_chain(&vmap_notify_list, 0, &freed);
|
|
if (freed > 0) {
|
|
purged = 0;
|
|
goto retry;
|
|
}
|
|
}
|
|
|
|
if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit())
|
|
pr_warn("vmap allocation for size %lu failed: use vmalloc=<size> to increase size\n",
|
|
size);
|
|
kfree(va);
|
|
return ERR_PTR(-EBUSY);
|
|
}
|
|
|
|
int register_vmap_purge_notifier(struct notifier_block *nb)
|
|
{
|
|
return blocking_notifier_chain_register(&vmap_notify_list, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(register_vmap_purge_notifier);
|
|
|
|
int unregister_vmap_purge_notifier(struct notifier_block *nb)
|
|
{
|
|
return blocking_notifier_chain_unregister(&vmap_notify_list, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier);
|
|
|
|
static void __free_vmap_area(struct vmap_area *va)
|
|
{
|
|
BUG_ON(RB_EMPTY_NODE(&va->rb_node));
|
|
|
|
if (free_vmap_cache) {
|
|
if (va->va_end < cached_vstart) {
|
|
free_vmap_cache = NULL;
|
|
} else {
|
|
struct vmap_area *cache;
|
|
cache = rb_entry(free_vmap_cache, struct vmap_area, rb_node);
|
|
if (va->va_start <= cache->va_start) {
|
|
free_vmap_cache = rb_prev(&va->rb_node);
|
|
/*
|
|
* We don't try to update cached_hole_size or
|
|
* cached_align, but it won't go very wrong.
|
|
*/
|
|
}
|
|
}
|
|
}
|
|
rb_erase(&va->rb_node, &vmap_area_root);
|
|
RB_CLEAR_NODE(&va->rb_node);
|
|
list_del_rcu(&va->list);
|
|
|
|
/*
|
|
* Track the highest possible candidate for pcpu area
|
|
* allocation. Areas outside of vmalloc area can be returned
|
|
* here too, consider only end addresses which fall inside
|
|
* vmalloc area proper.
|
|
*/
|
|
if (va->va_end > VMALLOC_START && va->va_end <= VMALLOC_END)
|
|
vmap_area_pcpu_hole = max(vmap_area_pcpu_hole, va->va_end);
|
|
|
|
kfree_rcu(va, rcu_head);
|
|
}
|
|
|
|
/*
|
|
* Free a region of KVA allocated by alloc_vmap_area
|
|
*/
|
|
static void free_vmap_area(struct vmap_area *va)
|
|
{
|
|
spin_lock(&vmap_area_lock);
|
|
__free_vmap_area(va);
|
|
spin_unlock(&vmap_area_lock);
|
|
}
|
|
|
|
/*
|
|
* Clear the pagetable entries of a given vmap_area
|
|
*/
|
|
static void unmap_vmap_area(struct vmap_area *va)
|
|
{
|
|
vunmap_page_range(va->va_start, va->va_end);
|
|
}
|
|
|
|
static void vmap_debug_free_range(unsigned long start, unsigned long end)
|
|
{
|
|
/*
|
|
* Unmap page tables and force a TLB flush immediately if pagealloc
|
|
* debugging is enabled. This catches use after free bugs similarly to
|
|
* those in linear kernel virtual address space after a page has been
|
|
* freed.
|
|
*
|
|
* All the lazy freeing logic is still retained, in order to minimise
|
|
* intrusiveness of this debugging feature.
|
|
*
|
|
* This is going to be *slow* (linear kernel virtual address debugging
|
|
* doesn't do a broadcast TLB flush so it is a lot faster).
|
|
*/
|
|
if (debug_pagealloc_enabled()) {
|
|
vunmap_page_range(start, end);
|
|
flush_tlb_kernel_range(start, end);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* lazy_max_pages is the maximum amount of virtual address space we gather up
|
|
* before attempting to purge with a TLB flush.
|
|
*
|
|
* There is a tradeoff here: a larger number will cover more kernel page tables
|
|
* and take slightly longer to purge, but it will linearly reduce the number of
|
|
* global TLB flushes that must be performed. It would seem natural to scale
|
|
* this number up linearly with the number of CPUs (because vmapping activity
|
|
* could also scale linearly with the number of CPUs), however it is likely
|
|
* that in practice, workloads might be constrained in other ways that mean
|
|
* vmap activity will not scale linearly with CPUs. Also, I want to be
|
|
* conservative and not introduce a big latency on huge systems, so go with
|
|
* a less aggressive log scale. It will still be an improvement over the old
|
|
* code, and it will be simple to change the scale factor if we find that it
|
|
* becomes a problem on bigger systems.
|
|
*/
|
|
static unsigned long lazy_max_pages(void)
|
|
{
|
|
unsigned int log;
|
|
|
|
log = fls(num_online_cpus());
|
|
|
|
return log * (32UL * 1024 * 1024 / PAGE_SIZE);
|
|
}
|
|
|
|
static atomic_t vmap_lazy_nr = ATOMIC_INIT(0);
|
|
|
|
/*
|
|
* Serialize vmap purging. There is no actual criticial section protected
|
|
* by this look, but we want to avoid concurrent calls for performance
|
|
* reasons and to make the pcpu_get_vm_areas more deterministic.
|
|
*/
|
|
static DEFINE_MUTEX(vmap_purge_lock);
|
|
|
|
/* for per-CPU blocks */
|
|
static void purge_fragmented_blocks_allcpus(void);
|
|
|
|
/*
|
|
* called before a call to iounmap() if the caller wants vm_area_struct's
|
|
* immediately freed.
|
|
*/
|
|
void set_iounmap_nonlazy(void)
|
|
{
|
|
atomic_set(&vmap_lazy_nr, lazy_max_pages()+1);
|
|
}
|
|
|
|
/*
|
|
* Purges all lazily-freed vmap areas.
|
|
*/
|
|
static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end)
|
|
{
|
|
struct llist_node *valist;
|
|
struct vmap_area *va;
|
|
struct vmap_area *n_va;
|
|
bool do_free = false;
|
|
|
|
lockdep_assert_held(&vmap_purge_lock);
|
|
|
|
valist = llist_del_all(&vmap_purge_list);
|
|
llist_for_each_entry(va, valist, purge_list) {
|
|
if (va->va_start < start)
|
|
start = va->va_start;
|
|
if (va->va_end > end)
|
|
end = va->va_end;
|
|
do_free = true;
|
|
}
|
|
|
|
if (!do_free)
|
|
return false;
|
|
|
|
flush_tlb_kernel_range(start, end);
|
|
|
|
spin_lock(&vmap_area_lock);
|
|
llist_for_each_entry_safe(va, n_va, valist, purge_list) {
|
|
int nr = (va->va_end - va->va_start) >> PAGE_SHIFT;
|
|
|
|
__free_vmap_area(va);
|
|
atomic_sub(nr, &vmap_lazy_nr);
|
|
cond_resched_lock(&vmap_area_lock);
|
|
}
|
|
spin_unlock(&vmap_area_lock);
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Kick off a purge of the outstanding lazy areas. Don't bother if somebody
|
|
* is already purging.
|
|
*/
|
|
static void try_purge_vmap_area_lazy(void)
|
|
{
|
|
if (mutex_trylock(&vmap_purge_lock)) {
|
|
__purge_vmap_area_lazy(ULONG_MAX, 0);
|
|
mutex_unlock(&vmap_purge_lock);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Kick off a purge of the outstanding lazy areas.
|
|
*/
|
|
static void purge_vmap_area_lazy(void)
|
|
{
|
|
mutex_lock(&vmap_purge_lock);
|
|
purge_fragmented_blocks_allcpus();
|
|
__purge_vmap_area_lazy(ULONG_MAX, 0);
|
|
mutex_unlock(&vmap_purge_lock);
|
|
}
|
|
|
|
/*
|
|
* Free a vmap area, caller ensuring that the area has been unmapped
|
|
* and flush_cache_vunmap had been called for the correct range
|
|
* previously.
|
|
*/
|
|
static void free_vmap_area_noflush(struct vmap_area *va)
|
|
{
|
|
int nr_lazy;
|
|
|
|
nr_lazy = atomic_add_return((va->va_end - va->va_start) >> PAGE_SHIFT,
|
|
&vmap_lazy_nr);
|
|
|
|
/* After this point, we may free va at any time */
|
|
llist_add(&va->purge_list, &vmap_purge_list);
|
|
|
|
if (unlikely(nr_lazy > lazy_max_pages()))
|
|
try_purge_vmap_area_lazy();
|
|
}
|
|
|
|
/*
|
|
* Free and unmap a vmap area
|
|
*/
|
|
static void free_unmap_vmap_area(struct vmap_area *va)
|
|
{
|
|
flush_cache_vunmap(va->va_start, va->va_end);
|
|
unmap_vmap_area(va);
|
|
free_vmap_area_noflush(va);
|
|
}
|
|
|
|
static struct vmap_area *find_vmap_area(unsigned long addr)
|
|
{
|
|
struct vmap_area *va;
|
|
|
|
spin_lock(&vmap_area_lock);
|
|
va = __find_vmap_area(addr);
|
|
spin_unlock(&vmap_area_lock);
|
|
|
|
return va;
|
|
}
|
|
|
|
/*** Per cpu kva allocator ***/
|
|
|
|
/*
|
|
* vmap space is limited especially on 32 bit architectures. Ensure there is
|
|
* room for at least 16 percpu vmap blocks per CPU.
|
|
*/
|
|
/*
|
|
* If we had a constant VMALLOC_START and VMALLOC_END, we'd like to be able
|
|
* to #define VMALLOC_SPACE (VMALLOC_END-VMALLOC_START). Guess
|
|
* instead (we just need a rough idea)
|
|
*/
|
|
#if BITS_PER_LONG == 32
|
|
#define VMALLOC_SPACE (128UL*1024*1024)
|
|
#else
|
|
#define VMALLOC_SPACE (128UL*1024*1024*1024)
|
|
#endif
|
|
|
|
#define VMALLOC_PAGES (VMALLOC_SPACE / PAGE_SIZE)
|
|
#define VMAP_MAX_ALLOC BITS_PER_LONG /* 256K with 4K pages */
|
|
#define VMAP_BBMAP_BITS_MAX 1024 /* 4MB with 4K pages */
|
|
#define VMAP_BBMAP_BITS_MIN (VMAP_MAX_ALLOC*2)
|
|
#define VMAP_MIN(x, y) ((x) < (y) ? (x) : (y)) /* can't use min() */
|
|
#define VMAP_MAX(x, y) ((x) > (y) ? (x) : (y)) /* can't use max() */
|
|
#define VMAP_BBMAP_BITS \
|
|
VMAP_MIN(VMAP_BBMAP_BITS_MAX, \
|
|
VMAP_MAX(VMAP_BBMAP_BITS_MIN, \
|
|
VMALLOC_PAGES / roundup_pow_of_two(NR_CPUS) / 16))
|
|
|
|
#define VMAP_BLOCK_SIZE (VMAP_BBMAP_BITS * PAGE_SIZE)
|
|
|
|
static bool vmap_initialized __read_mostly = false;
|
|
|
|
struct vmap_block_queue {
|
|
spinlock_t lock;
|
|
struct list_head free;
|
|
};
|
|
|
|
struct vmap_block {
|
|
spinlock_t lock;
|
|
struct vmap_area *va;
|
|
unsigned long free, dirty;
|
|
unsigned long dirty_min, dirty_max; /*< dirty range */
|
|
struct list_head free_list;
|
|
struct rcu_head rcu_head;
|
|
struct list_head purge;
|
|
};
|
|
|
|
/* Queue of free and dirty vmap blocks, for allocation and flushing purposes */
|
|
static DEFINE_PER_CPU(struct vmap_block_queue, vmap_block_queue);
|
|
|
|
/*
|
|
* Radix tree of vmap blocks, indexed by address, to quickly find a vmap block
|
|
* in the free path. Could get rid of this if we change the API to return a
|
|
* "cookie" from alloc, to be passed to free. But no big deal yet.
|
|
*/
|
|
static DEFINE_SPINLOCK(vmap_block_tree_lock);
|
|
static RADIX_TREE(vmap_block_tree, GFP_ATOMIC);
|
|
|
|
/*
|
|
* We should probably have a fallback mechanism to allocate virtual memory
|
|
* out of partially filled vmap blocks. However vmap block sizing should be
|
|
* fairly reasonable according to the vmalloc size, so it shouldn't be a
|
|
* big problem.
|
|
*/
|
|
|
|
static unsigned long addr_to_vb_idx(unsigned long addr)
|
|
{
|
|
addr -= VMALLOC_START & ~(VMAP_BLOCK_SIZE-1);
|
|
addr /= VMAP_BLOCK_SIZE;
|
|
return addr;
|
|
}
|
|
|
|
static void *vmap_block_vaddr(unsigned long va_start, unsigned long pages_off)
|
|
{
|
|
unsigned long addr;
|
|
|
|
addr = va_start + (pages_off << PAGE_SHIFT);
|
|
BUG_ON(addr_to_vb_idx(addr) != addr_to_vb_idx(va_start));
|
|
return (void *)addr;
|
|
}
|
|
|
|
/**
|
|
* new_vmap_block - allocates new vmap_block and occupies 2^order pages in this
|
|
* block. Of course pages number can't exceed VMAP_BBMAP_BITS
|
|
* @order: how many 2^order pages should be occupied in newly allocated block
|
|
* @gfp_mask: flags for the page level allocator
|
|
*
|
|
* Returns: virtual address in a newly allocated block or ERR_PTR(-errno)
|
|
*/
|
|
static void *new_vmap_block(unsigned int order, gfp_t gfp_mask)
|
|
{
|
|
struct vmap_block_queue *vbq;
|
|
struct vmap_block *vb;
|
|
struct vmap_area *va;
|
|
unsigned long vb_idx;
|
|
int node, err;
|
|
void *vaddr;
|
|
|
|
node = numa_node_id();
|
|
|
|
vb = kmalloc_node(sizeof(struct vmap_block),
|
|
gfp_mask & GFP_RECLAIM_MASK, node);
|
|
if (unlikely(!vb))
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
va = alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE,
|
|
VMALLOC_START, VMALLOC_END,
|
|
node, gfp_mask);
|
|
if (IS_ERR(va)) {
|
|
kfree(vb);
|
|
return ERR_CAST(va);
|
|
}
|
|
|
|
err = radix_tree_preload(gfp_mask);
|
|
if (unlikely(err)) {
|
|
kfree(vb);
|
|
free_vmap_area(va);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
vaddr = vmap_block_vaddr(va->va_start, 0);
|
|
spin_lock_init(&vb->lock);
|
|
vb->va = va;
|
|
/* At least something should be left free */
|
|
BUG_ON(VMAP_BBMAP_BITS <= (1UL << order));
|
|
vb->free = VMAP_BBMAP_BITS - (1UL << order);
|
|
vb->dirty = 0;
|
|
vb->dirty_min = VMAP_BBMAP_BITS;
|
|
vb->dirty_max = 0;
|
|
INIT_LIST_HEAD(&vb->free_list);
|
|
|
|
vb_idx = addr_to_vb_idx(va->va_start);
|
|
spin_lock(&vmap_block_tree_lock);
|
|
err = radix_tree_insert(&vmap_block_tree, vb_idx, vb);
|
|
spin_unlock(&vmap_block_tree_lock);
|
|
BUG_ON(err);
|
|
radix_tree_preload_end();
|
|
|
|
vbq = &get_cpu_var(vmap_block_queue);
|
|
spin_lock(&vbq->lock);
|
|
list_add_tail_rcu(&vb->free_list, &vbq->free);
|
|
spin_unlock(&vbq->lock);
|
|
put_cpu_var(vmap_block_queue);
|
|
|
|
return vaddr;
|
|
}
|
|
|
|
static void free_vmap_block(struct vmap_block *vb)
|
|
{
|
|
struct vmap_block *tmp;
|
|
unsigned long vb_idx;
|
|
|
|
vb_idx = addr_to_vb_idx(vb->va->va_start);
|
|
spin_lock(&vmap_block_tree_lock);
|
|
tmp = radix_tree_delete(&vmap_block_tree, vb_idx);
|
|
spin_unlock(&vmap_block_tree_lock);
|
|
BUG_ON(tmp != vb);
|
|
|
|
free_vmap_area_noflush(vb->va);
|
|
kfree_rcu(vb, rcu_head);
|
|
}
|
|
|
|
static void purge_fragmented_blocks(int cpu)
|
|
{
|
|
LIST_HEAD(purge);
|
|
struct vmap_block *vb;
|
|
struct vmap_block *n_vb;
|
|
struct vmap_block_queue *vbq = &per_cpu(vmap_block_queue, cpu);
|
|
|
|
rcu_read_lock();
|
|
list_for_each_entry_rcu(vb, &vbq->free, free_list) {
|
|
|
|
if (!(vb->free + vb->dirty == VMAP_BBMAP_BITS && vb->dirty != VMAP_BBMAP_BITS))
|
|
continue;
|
|
|
|
spin_lock(&vb->lock);
|
|
if (vb->free + vb->dirty == VMAP_BBMAP_BITS && vb->dirty != VMAP_BBMAP_BITS) {
|
|
vb->free = 0; /* prevent further allocs after releasing lock */
|
|
vb->dirty = VMAP_BBMAP_BITS; /* prevent purging it again */
|
|
vb->dirty_min = 0;
|
|
vb->dirty_max = VMAP_BBMAP_BITS;
|
|
spin_lock(&vbq->lock);
|
|
list_del_rcu(&vb->free_list);
|
|
spin_unlock(&vbq->lock);
|
|
spin_unlock(&vb->lock);
|
|
list_add_tail(&vb->purge, &purge);
|
|
} else
|
|
spin_unlock(&vb->lock);
|
|
}
|
|
rcu_read_unlock();
|
|
|
|
list_for_each_entry_safe(vb, n_vb, &purge, purge) {
|
|
list_del(&vb->purge);
|
|
free_vmap_block(vb);
|
|
}
|
|
}
|
|
|
|
static void purge_fragmented_blocks_allcpus(void)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_possible_cpu(cpu)
|
|
purge_fragmented_blocks(cpu);
|
|
}
|
|
|
|
static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
|
|
{
|
|
struct vmap_block_queue *vbq;
|
|
struct vmap_block *vb;
|
|
void *vaddr = NULL;
|
|
unsigned int order;
|
|
|
|
BUG_ON(offset_in_page(size));
|
|
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
|
|
if (WARN_ON(size == 0)) {
|
|
/*
|
|
* Allocating 0 bytes isn't what caller wants since
|
|
* get_order(0) returns funny result. Just warn and terminate
|
|
* early.
|
|
*/
|
|
return NULL;
|
|
}
|
|
order = get_order(size);
|
|
|
|
rcu_read_lock();
|
|
vbq = &get_cpu_var(vmap_block_queue);
|
|
list_for_each_entry_rcu(vb, &vbq->free, free_list) {
|
|
unsigned long pages_off;
|
|
|
|
spin_lock(&vb->lock);
|
|
if (vb->free < (1UL << order)) {
|
|
spin_unlock(&vb->lock);
|
|
continue;
|
|
}
|
|
|
|
pages_off = VMAP_BBMAP_BITS - vb->free;
|
|
vaddr = vmap_block_vaddr(vb->va->va_start, pages_off);
|
|
vb->free -= 1UL << order;
|
|
if (vb->free == 0) {
|
|
spin_lock(&vbq->lock);
|
|
list_del_rcu(&vb->free_list);
|
|
spin_unlock(&vbq->lock);
|
|
}
|
|
|
|
spin_unlock(&vb->lock);
|
|
break;
|
|
}
|
|
|
|
put_cpu_var(vmap_block_queue);
|
|
rcu_read_unlock();
|
|
|
|
/* Allocate new block if nothing was found */
|
|
if (!vaddr)
|
|
vaddr = new_vmap_block(order, gfp_mask);
|
|
|
|
return vaddr;
|
|
}
|
|
|
|
static void vb_free(const void *addr, unsigned long size)
|
|
{
|
|
unsigned long offset;
|
|
unsigned long vb_idx;
|
|
unsigned int order;
|
|
struct vmap_block *vb;
|
|
|
|
BUG_ON(offset_in_page(size));
|
|
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
|
|
|
|
flush_cache_vunmap((unsigned long)addr, (unsigned long)addr + size);
|
|
|
|
order = get_order(size);
|
|
|
|
offset = (unsigned long)addr & (VMAP_BLOCK_SIZE - 1);
|
|
offset >>= PAGE_SHIFT;
|
|
|
|
vb_idx = addr_to_vb_idx((unsigned long)addr);
|
|
rcu_read_lock();
|
|
vb = radix_tree_lookup(&vmap_block_tree, vb_idx);
|
|
rcu_read_unlock();
|
|
BUG_ON(!vb);
|
|
|
|
vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
|
|
|
|
spin_lock(&vb->lock);
|
|
|
|
/* Expand dirty range */
|
|
vb->dirty_min = min(vb->dirty_min, offset);
|
|
vb->dirty_max = max(vb->dirty_max, offset + (1UL << order));
|
|
|
|
vb->dirty += 1UL << order;
|
|
if (vb->dirty == VMAP_BBMAP_BITS) {
|
|
BUG_ON(vb->free);
|
|
spin_unlock(&vb->lock);
|
|
free_vmap_block(vb);
|
|
} else
|
|
spin_unlock(&vb->lock);
|
|
}
|
|
|
|
/**
|
|
* vm_unmap_aliases - unmap outstanding lazy aliases in the vmap layer
|
|
*
|
|
* The vmap/vmalloc layer lazily flushes kernel virtual mappings primarily
|
|
* to amortize TLB flushing overheads. What this means is that any page you
|
|
* have now, may, in a former life, have been mapped into kernel virtual
|
|
* address by the vmap layer and so there might be some CPUs with TLB entries
|
|
* still referencing that page (additional to the regular 1:1 kernel mapping).
|
|
*
|
|
* vm_unmap_aliases flushes all such lazy mappings. After it returns, we can
|
|
* be sure that none of the pages we have control over will have any aliases
|
|
* from the vmap layer.
|
|
*/
|
|
void vm_unmap_aliases(void)
|
|
{
|
|
unsigned long start = ULONG_MAX, end = 0;
|
|
int cpu;
|
|
int flush = 0;
|
|
|
|
if (unlikely(!vmap_initialized))
|
|
return;
|
|
|
|
might_sleep();
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
struct vmap_block_queue *vbq = &per_cpu(vmap_block_queue, cpu);
|
|
struct vmap_block *vb;
|
|
|
|
rcu_read_lock();
|
|
list_for_each_entry_rcu(vb, &vbq->free, free_list) {
|
|
spin_lock(&vb->lock);
|
|
if (vb->dirty) {
|
|
unsigned long va_start = vb->va->va_start;
|
|
unsigned long s, e;
|
|
|
|
s = va_start + (vb->dirty_min << PAGE_SHIFT);
|
|
e = va_start + (vb->dirty_max << PAGE_SHIFT);
|
|
|
|
start = min(s, start);
|
|
end = max(e, end);
|
|
|
|
flush = 1;
|
|
}
|
|
spin_unlock(&vb->lock);
|
|
}
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
mutex_lock(&vmap_purge_lock);
|
|
purge_fragmented_blocks_allcpus();
|
|
if (!__purge_vmap_area_lazy(start, end) && flush)
|
|
flush_tlb_kernel_range(start, end);
|
|
mutex_unlock(&vmap_purge_lock);
|
|
}
|
|
EXPORT_SYMBOL_GPL(vm_unmap_aliases);
|
|
|
|
/**
|
|
* vm_unmap_ram - unmap linear kernel address space set up by vm_map_ram
|
|
* @mem: the pointer returned by vm_map_ram
|
|
* @count: the count passed to that vm_map_ram call (cannot unmap partial)
|
|
*/
|
|
void vm_unmap_ram(const void *mem, unsigned int count)
|
|
{
|
|
unsigned long size = (unsigned long)count << PAGE_SHIFT;
|
|
unsigned long addr = (unsigned long)mem;
|
|
struct vmap_area *va;
|
|
|
|
might_sleep();
|
|
BUG_ON(!addr);
|
|
BUG_ON(addr < VMALLOC_START);
|
|
BUG_ON(addr > VMALLOC_END);
|
|
BUG_ON(!PAGE_ALIGNED(addr));
|
|
|
|
debug_check_no_locks_freed(mem, size);
|
|
vmap_debug_free_range(addr, addr+size);
|
|
|
|
if (likely(count <= VMAP_MAX_ALLOC)) {
|
|
vb_free(mem, size);
|
|
return;
|
|
}
|
|
|
|
va = find_vmap_area(addr);
|
|
BUG_ON(!va);
|
|
free_unmap_vmap_area(va);
|
|
}
|
|
EXPORT_SYMBOL(vm_unmap_ram);
|
|
|
|
/**
|
|
* vm_map_ram - map pages linearly into kernel virtual address (vmalloc space)
|
|
* @pages: an array of pointers to the pages to be mapped
|
|
* @count: number of pages
|
|
* @node: prefer to allocate data structures on this node
|
|
* @prot: memory protection to use. PAGE_KERNEL for regular RAM
|
|
*
|
|
* If you use this function for less than VMAP_MAX_ALLOC pages, it could be
|
|
* faster than vmap so it's good. But if you mix long-life and short-life
|
|
* objects with vm_map_ram(), it could consume lots of address space through
|
|
* fragmentation (especially on a 32bit machine). You could see failures in
|
|
* the end. Please use this function for short-lived objects.
|
|
*
|
|
* Returns: a pointer to the address that has been mapped, or %NULL on failure
|
|
*/
|
|
void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t prot)
|
|
{
|
|
unsigned long size = (unsigned long)count << PAGE_SHIFT;
|
|
unsigned long addr;
|
|
void *mem;
|
|
|
|
if (likely(count <= VMAP_MAX_ALLOC)) {
|
|
mem = vb_alloc(size, GFP_KERNEL);
|
|
if (IS_ERR(mem))
|
|
return NULL;
|
|
addr = (unsigned long)mem;
|
|
} else {
|
|
struct vmap_area *va;
|
|
va = alloc_vmap_area(size, PAGE_SIZE,
|
|
VMALLOC_START, VMALLOC_END, node, GFP_KERNEL);
|
|
if (IS_ERR(va))
|
|
return NULL;
|
|
|
|
addr = va->va_start;
|
|
mem = (void *)addr;
|
|
}
|
|
if (vmap_page_range(addr, addr + size, prot, pages) < 0) {
|
|
vm_unmap_ram(mem, count);
|
|
return NULL;
|
|
}
|
|
return mem;
|
|
}
|
|
EXPORT_SYMBOL(vm_map_ram);
|
|
|
|
static struct vm_struct *vmlist __initdata;
|
|
|
|
/**
|
|
* vm_area_check_early - check if vmap area is already mapped
|
|
* @vm: vm_struct to be checked
|
|
*
|
|
* This function is used to check if the vmap area has been
|
|
* mapped already. @vm->addr, @vm->size and @vm->flags should
|
|
* contain proper values.
|
|
*
|
|
*/
|
|
int __init vm_area_check_early(struct vm_struct *vm)
|
|
{
|
|
struct vm_struct *tmp, **p;
|
|
|
|
BUG_ON(vmap_initialized);
|
|
for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
|
|
if (tmp->addr >= vm->addr) {
|
|
if (tmp->addr < vm->addr + vm->size)
|
|
return 1;
|
|
} else {
|
|
if (tmp->addr + tmp->size > vm->addr)
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* vm_area_add_early - add vmap area early during boot
|
|
* @vm: vm_struct to add
|
|
*
|
|
* This function is used to add fixed kernel vm area to vmlist before
|
|
* vmalloc_init() is called. @vm->addr, @vm->size, and @vm->flags
|
|
* should contain proper values and the other fields should be zero.
|
|
*
|
|
* DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
|
|
*/
|
|
void __init vm_area_add_early(struct vm_struct *vm)
|
|
{
|
|
struct vm_struct *tmp, **p;
|
|
|
|
BUG_ON(vmap_initialized);
|
|
for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
|
|
if (tmp->addr >= vm->addr) {
|
|
BUG_ON(tmp->addr < vm->addr + vm->size);
|
|
break;
|
|
} else
|
|
BUG_ON(tmp->addr + tmp->size > vm->addr);
|
|
}
|
|
vm->next = *p;
|
|
*p = vm;
|
|
}
|
|
|
|
/**
|
|
* vm_area_register_early - register vmap area early during boot
|
|
* @vm: vm_struct to register
|
|
* @align: requested alignment
|
|
*
|
|
* This function is used to register kernel vm area before
|
|
* vmalloc_init() is called. @vm->size and @vm->flags should contain
|
|
* proper values on entry and other fields should be zero. On return,
|
|
* vm->addr contains the allocated address.
|
|
*
|
|
* DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING.
|
|
*/
|
|
void __init vm_area_register_early(struct vm_struct *vm, size_t align)
|
|
{
|
|
static size_t vm_init_off __initdata;
|
|
unsigned long addr;
|
|
|
|
addr = ALIGN(VMALLOC_START + vm_init_off, align);
|
|
vm_init_off = PFN_ALIGN(addr + vm->size) - VMALLOC_START;
|
|
|
|
vm->addr = (void *)addr;
|
|
|
|
vm_area_add_early(vm);
|
|
}
|
|
|
|
void __init vmalloc_init(void)
|
|
{
|
|
struct vmap_area *va;
|
|
struct vm_struct *tmp;
|
|
int i;
|
|
|
|
for_each_possible_cpu(i) {
|
|
struct vmap_block_queue *vbq;
|
|
struct vfree_deferred *p;
|
|
|
|
vbq = &per_cpu(vmap_block_queue, i);
|
|
spin_lock_init(&vbq->lock);
|
|
INIT_LIST_HEAD(&vbq->free);
|
|
p = &per_cpu(vfree_deferred, i);
|
|
init_llist_head(&p->list);
|
|
INIT_WORK(&p->wq, free_work);
|
|
}
|
|
|
|
/* Import existing vmlist entries. */
|
|
for (tmp = vmlist; tmp; tmp = tmp->next) {
|
|
va = kzalloc(sizeof(struct vmap_area), GFP_NOWAIT);
|
|
va->flags = VM_VM_AREA;
|
|
va->va_start = (unsigned long)tmp->addr;
|
|
va->va_end = va->va_start + tmp->size;
|
|
va->vm = tmp;
|
|
__insert_vmap_area(va);
|
|
}
|
|
|
|
vmap_area_pcpu_hole = VMALLOC_END;
|
|
calc_total_vmalloc_size();
|
|
vmap_initialized = true;
|
|
}
|
|
|
|
/**
|
|
* map_kernel_range_noflush - map kernel VM area with the specified pages
|
|
* @addr: start of the VM area to map
|
|
* @size: size of the VM area to map
|
|
* @prot: page protection flags to use
|
|
* @pages: pages to map
|
|
*
|
|
* Map PFN_UP(@size) pages at @addr. The VM area @addr and @size
|
|
* specify should have been allocated using get_vm_area() and its
|
|
* friends.
|
|
*
|
|
* NOTE:
|
|
* This function does NOT do any cache flushing. The caller is
|
|
* responsible for calling flush_cache_vmap() on to-be-mapped areas
|
|
* before calling this function.
|
|
*
|
|
* RETURNS:
|
|
* The number of pages mapped on success, -errno on failure.
|
|
*/
|
|
int map_kernel_range_noflush(unsigned long addr, unsigned long size,
|
|
pgprot_t prot, struct page **pages)
|
|
{
|
|
return vmap_page_range_noflush(addr, addr + size, prot, pages);
|
|
}
|
|
|
|
/**
|
|
* unmap_kernel_range_noflush - unmap kernel VM area
|
|
* @addr: start of the VM area to unmap
|
|
* @size: size of the VM area to unmap
|
|
*
|
|
* Unmap PFN_UP(@size) pages at @addr. The VM area @addr and @size
|
|
* specify should have been allocated using get_vm_area() and its
|
|
* friends.
|
|
*
|
|
* NOTE:
|
|
* This function does NOT do any cache flushing. The caller is
|
|
* responsible for calling flush_cache_vunmap() on to-be-mapped areas
|
|
* before calling this function and flush_tlb_kernel_range() after.
|
|
*/
|
|
void unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
|
|
{
|
|
vunmap_page_range(addr, addr + size);
|
|
}
|
|
EXPORT_SYMBOL_GPL(unmap_kernel_range_noflush);
|
|
|
|
/**
|
|
* unmap_kernel_range - unmap kernel VM area and flush cache and TLB
|
|
* @addr: start of the VM area to unmap
|
|
* @size: size of the VM area to unmap
|
|
*
|
|
* Similar to unmap_kernel_range_noflush() but flushes vcache before
|
|
* the unmapping and tlb after.
|
|
*/
|
|
void unmap_kernel_range(unsigned long addr, unsigned long size)
|
|
{
|
|
unsigned long end = addr + size;
|
|
|
|
flush_cache_vunmap(addr, end);
|
|
vunmap_page_range(addr, end);
|
|
flush_tlb_kernel_range(addr, end);
|
|
}
|
|
EXPORT_SYMBOL_GPL(unmap_kernel_range);
|
|
|
|
int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page **pages)
|
|
{
|
|
unsigned long addr = (unsigned long)area->addr;
|
|
unsigned long end = addr + get_vm_area_size(area);
|
|
int err;
|
|
|
|
err = vmap_page_range(addr, end, prot, pages);
|
|
|
|
return err > 0 ? 0 : err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(map_vm_area);
|
|
|
|
static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
|
|
unsigned long flags, const void *caller)
|
|
{
|
|
spin_lock(&vmap_area_lock);
|
|
vm->flags = flags;
|
|
vm->addr = (void *)va->va_start;
|
|
vm->size = va->va_end - va->va_start;
|
|
vm->caller = caller;
|
|
va->vm = vm;
|
|
va->flags |= VM_VM_AREA;
|
|
spin_unlock(&vmap_area_lock);
|
|
}
|
|
|
|
static void clear_vm_uninitialized_flag(struct vm_struct *vm)
|
|
{
|
|
/*
|
|
* Before removing VM_UNINITIALIZED,
|
|
* we should make sure that vm has proper values.
|
|
* Pair with smp_rmb() in show_numa_info().
|
|
*/
|
|
smp_wmb();
|
|
vm->flags &= ~VM_UNINITIALIZED;
|
|
}
|
|
|
|
static struct vm_struct *__get_vm_area_node(unsigned long size,
|
|
unsigned long align, unsigned long flags, unsigned long start,
|
|
unsigned long end, int node, gfp_t gfp_mask, const void *caller)
|
|
{
|
|
struct vmap_area *va;
|
|
struct vm_struct *area;
|
|
|
|
BUG_ON(in_interrupt());
|
|
size = PAGE_ALIGN(size);
|
|
if (unlikely(!size))
|
|
return NULL;
|
|
|
|
if (flags & VM_IOREMAP)
|
|
align = 1ul << clamp_t(int, get_count_order_long(size),
|
|
PAGE_SHIFT, IOREMAP_MAX_ORDER);
|
|
|
|
area = kzalloc_node(sizeof(*area), gfp_mask & GFP_RECLAIM_MASK, node);
|
|
if (unlikely(!area))
|
|
return NULL;
|
|
|
|
if (!(flags & VM_NO_GUARD))
|
|
size += PAGE_SIZE;
|
|
|
|
va = alloc_vmap_area(size, align, start, end, node, gfp_mask);
|
|
if (IS_ERR(va)) {
|
|
kfree(area);
|
|
return NULL;
|
|
}
|
|
|
|
setup_vmalloc_vm(area, va, flags, caller);
|
|
|
|
return area;
|
|
}
|
|
|
|
struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
|
|
unsigned long start, unsigned long end)
|
|
{
|
|
return __get_vm_area_node(size, 1, flags, start, end, NUMA_NO_NODE,
|
|
GFP_KERNEL, __builtin_return_address(0));
|
|
}
|
|
EXPORT_SYMBOL_GPL(__get_vm_area);
|
|
|
|
struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags,
|
|
unsigned long start, unsigned long end,
|
|
const void *caller)
|
|
{
|
|
return __get_vm_area_node(size, 1, flags, start, end, NUMA_NO_NODE,
|
|
GFP_KERNEL, caller);
|
|
}
|
|
|
|
/**
|
|
* get_vm_area - reserve a contiguous kernel virtual area
|
|
* @size: size of the area
|
|
* @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
|
|
*
|
|
* Search an area of @size in the kernel virtual mapping area,
|
|
* and reserved it for out purposes. Returns the area descriptor
|
|
* on success or %NULL on failure.
|
|
*/
|
|
struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
|
|
{
|
|
#ifdef CONFIG_ENABLE_VMALLOC_SAVING
|
|
return __get_vm_area_node(size, 1, flags, PAGE_OFFSET, VMALLOC_END,
|
|
NUMA_NO_NODE, GFP_KERNEL,
|
|
__builtin_return_address(0));
|
|
#else
|
|
return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END,
|
|
NUMA_NO_NODE, GFP_KERNEL,
|
|
__builtin_return_address(0));
|
|
#endif
|
|
}
|
|
|
|
struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags,
|
|
const void *caller)
|
|
{
|
|
#ifdef CONFIG_ENABLE_VMALLOC_SAVING
|
|
return __get_vm_area_node(size, 1, flags, PAGE_OFFSET, VMALLOC_END,
|
|
NUMA_NO_NODE, GFP_KERNEL, caller);
|
|
#else
|
|
return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END,
|
|
NUMA_NO_NODE, GFP_KERNEL, caller);
|
|
#endif
|
|
}
|
|
|
|
/**
|
|
* find_vm_area - find a continuous kernel virtual area
|
|
* @addr: base address
|
|
*
|
|
* Search for the kernel VM area starting at @addr, and return it.
|
|
* It is up to the caller to do all required locking to keep the returned
|
|
* pointer valid.
|
|
*/
|
|
struct vm_struct *find_vm_area(const void *addr)
|
|
{
|
|
struct vmap_area *va;
|
|
|
|
va = find_vmap_area((unsigned long)addr);
|
|
if (va && va->flags & VM_VM_AREA)
|
|
return va->vm;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* remove_vm_area - find and remove a continuous kernel virtual area
|
|
* @addr: base address
|
|
*
|
|
* Search for the kernel VM area starting at @addr, and remove it.
|
|
* This function returns the found VM area, but using it is NOT safe
|
|
* on SMP machines, except for its size or flags.
|
|
*/
|
|
struct vm_struct *remove_vm_area(const void *addr)
|
|
{
|
|
struct vmap_area *va;
|
|
|
|
might_sleep();
|
|
|
|
va = find_vmap_area((unsigned long)addr);
|
|
if (va && va->flags & VM_VM_AREA) {
|
|
struct vm_struct *vm = va->vm;
|
|
|
|
spin_lock(&vmap_area_lock);
|
|
va->vm = NULL;
|
|
va->flags &= ~VM_VM_AREA;
|
|
va->flags |= VM_LAZY_FREE;
|
|
spin_unlock(&vmap_area_lock);
|
|
|
|
vmap_debug_free_range(va->va_start, va->va_end);
|
|
kasan_free_shadow(vm);
|
|
free_unmap_vmap_area(va);
|
|
|
|
return vm;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static void __vunmap(const void *addr, int deallocate_pages)
|
|
{
|
|
struct vm_struct *area;
|
|
|
|
if (!addr)
|
|
return;
|
|
|
|
if (WARN(!PAGE_ALIGNED(addr), "Trying to vfree() bad address (%p)\n",
|
|
addr))
|
|
return;
|
|
|
|
area = find_vm_area(addr);
|
|
if (unlikely(!area)) {
|
|
WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
|
|
addr);
|
|
return;
|
|
}
|
|
|
|
debug_check_no_locks_freed(addr, get_vm_area_size(area));
|
|
debug_check_no_obj_freed(addr, get_vm_area_size(area));
|
|
|
|
remove_vm_area(addr);
|
|
if (deallocate_pages) {
|
|
int i;
|
|
|
|
for (i = 0; i < area->nr_pages; i++) {
|
|
struct page *page = area->pages[i];
|
|
|
|
BUG_ON(!page);
|
|
__free_pages(page, 0);
|
|
}
|
|
atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
|
|
|
|
kvfree(area->pages);
|
|
}
|
|
|
|
kfree(area);
|
|
return;
|
|
}
|
|
|
|
static inline void __vfree_deferred(const void *addr)
|
|
{
|
|
/*
|
|
* Use raw_cpu_ptr() because this can be called from preemptible
|
|
* context. Preemption is absolutely fine here, because the llist_add()
|
|
* implementation is lockless, so it works even if we are adding to
|
|
* nother cpu's list. schedule_work() should be fine with this too.
|
|
*/
|
|
struct vfree_deferred *p = raw_cpu_ptr(&vfree_deferred);
|
|
|
|
if (llist_add((struct llist_node *)addr, &p->list))
|
|
schedule_work(&p->wq);
|
|
}
|
|
|
|
/**
|
|
* vfree_atomic - release memory allocated by vmalloc()
|
|
* @addr: memory base address
|
|
*
|
|
* This one is just like vfree() but can be called in any atomic context
|
|
* except NMIs.
|
|
*/
|
|
void vfree_atomic(const void *addr)
|
|
{
|
|
BUG_ON(in_nmi());
|
|
|
|
kmemleak_free(addr);
|
|
|
|
if (!addr)
|
|
return;
|
|
__vfree_deferred(addr);
|
|
}
|
|
|
|
/**
|
|
* vfree - release memory allocated by vmalloc()
|
|
* @addr: memory base address
|
|
*
|
|
* Free the virtually continuous memory area starting at @addr, as
|
|
* obtained from vmalloc(), vmalloc_32() or __vmalloc(). If @addr is
|
|
* NULL, no operation is performed.
|
|
*
|
|
* Must not be called in NMI context (strictly speaking, only if we don't
|
|
* have CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG, but making the calling
|
|
* conventions for vfree() arch-depenedent would be a really bad idea)
|
|
*
|
|
* NOTE: assumes that the object at @addr has a size >= sizeof(llist_node)
|
|
*/
|
|
void vfree(const void *addr)
|
|
{
|
|
BUG_ON(in_nmi());
|
|
|
|
kmemleak_free(addr);
|
|
|
|
if (!addr)
|
|
return;
|
|
if (unlikely(in_interrupt()))
|
|
__vfree_deferred(addr);
|
|
else
|
|
__vunmap(addr, 1);
|
|
}
|
|
EXPORT_SYMBOL(vfree);
|
|
|
|
/**
|
|
* vunmap - release virtual mapping obtained by vmap()
|
|
* @addr: memory base address
|
|
*
|
|
* Free the virtually contiguous memory area starting at @addr,
|
|
* which was created from the page array passed to vmap().
|
|
*
|
|
* Must not be called in interrupt context.
|
|
*/
|
|
void vunmap(const void *addr)
|
|
{
|
|
BUG_ON(in_interrupt());
|
|
might_sleep();
|
|
if (addr)
|
|
__vunmap(addr, 0);
|
|
}
|
|
EXPORT_SYMBOL(vunmap);
|
|
|
|
/**
|
|
* vmap - map an array of pages into virtually contiguous space
|
|
* @pages: array of page pointers
|
|
* @count: number of pages to map
|
|
* @flags: vm_area->flags
|
|
* @prot: page protection for the mapping
|
|
*
|
|
* Maps @count pages from @pages into contiguous kernel virtual
|
|
* space.
|
|
*/
|
|
void *vmap(struct page **pages, unsigned int count,
|
|
unsigned long flags, pgprot_t prot)
|
|
{
|
|
struct vm_struct *area;
|
|
unsigned long size; /* In bytes */
|
|
|
|
might_sleep();
|
|
|
|
if (count > totalram_pages)
|
|
return NULL;
|
|
|
|
size = (unsigned long)count << PAGE_SHIFT;
|
|
area = get_vm_area_caller(size, flags, __builtin_return_address(0));
|
|
if (!area)
|
|
return NULL;
|
|
|
|
if (map_vm_area(area, prot, pages)) {
|
|
vunmap(area->addr);
|
|
return NULL;
|
|
}
|
|
|
|
return area->addr;
|
|
}
|
|
EXPORT_SYMBOL(vmap);
|
|
|
|
static void *__vmalloc_node(unsigned long size, unsigned long align,
|
|
gfp_t gfp_mask, pgprot_t prot,
|
|
int node, const void *caller);
|
|
static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
|
|
pgprot_t prot, int node)
|
|
{
|
|
struct page **pages;
|
|
unsigned int nr_pages, array_size, i;
|
|
const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
|
|
const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
|
|
const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
|
|
0 :
|
|
__GFP_HIGHMEM;
|
|
|
|
nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
|
|
array_size = (nr_pages * sizeof(struct page *));
|
|
|
|
/* Please note that the recursion is strictly bounded. */
|
|
if (array_size > PAGE_SIZE) {
|
|
pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
|
|
PAGE_KERNEL, node, area->caller);
|
|
} else {
|
|
pages = kmalloc_node(array_size, nested_gfp, node);
|
|
}
|
|
|
|
if (!pages) {
|
|
remove_vm_area(area->addr);
|
|
kfree(area);
|
|
return NULL;
|
|
}
|
|
|
|
area->pages = pages;
|
|
area->nr_pages = nr_pages;
|
|
|
|
for (i = 0; i < area->nr_pages; i++) {
|
|
struct page *page;
|
|
|
|
if (node == NUMA_NO_NODE)
|
|
page = alloc_page(alloc_mask|highmem_mask);
|
|
else
|
|
page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
|
|
|
|
if (unlikely(!page)) {
|
|
/* Successfully allocated i pages, free them in __vunmap() */
|
|
area->nr_pages = i;
|
|
atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
|
|
goto fail;
|
|
}
|
|
area->pages[i] = page;
|
|
if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
|
|
cond_resched();
|
|
}
|
|
atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
|
|
|
|
if (map_vm_area(area, prot, pages))
|
|
goto fail;
|
|
return area->addr;
|
|
|
|
fail:
|
|
warn_alloc(gfp_mask, NULL,
|
|
"vmalloc: allocation failure, allocated %ld of %ld bytes",
|
|
(area->nr_pages*PAGE_SIZE), area->size);
|
|
vfree(area->addr);
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* __vmalloc_node_range - allocate virtually contiguous memory
|
|
* @size: allocation size
|
|
* @align: desired alignment
|
|
* @start: vm area range start
|
|
* @end: vm area range end
|
|
* @gfp_mask: flags for the page level allocator
|
|
* @prot: protection mask for the allocated pages
|
|
* @vm_flags: additional vm area flags (e.g. %VM_NO_GUARD)
|
|
* @node: node to use for allocation or NUMA_NO_NODE
|
|
* @caller: caller's return address
|
|
*
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator with @gfp_mask flags. Map them into contiguous
|
|
* kernel virtual space, using a pagetable protection of @prot.
|
|
*/
|
|
void *__vmalloc_node_range(unsigned long size, unsigned long align,
|
|
unsigned long start, unsigned long end, gfp_t gfp_mask,
|
|
pgprot_t prot, unsigned long vm_flags, int node,
|
|
const void *caller)
|
|
{
|
|
struct vm_struct *area;
|
|
void *addr;
|
|
unsigned long real_size = size;
|
|
|
|
size = PAGE_ALIGN(size);
|
|
if (!size || (size >> PAGE_SHIFT) > totalram_pages)
|
|
goto fail;
|
|
|
|
area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED |
|
|
vm_flags, start, end, node, gfp_mask, caller);
|
|
if (!area)
|
|
goto fail;
|
|
|
|
addr = __vmalloc_area_node(area, gfp_mask, prot, node);
|
|
if (!addr)
|
|
return NULL;
|
|
|
|
/*
|
|
* First make sure the mappings are removed from all page-tables
|
|
* before they are freed.
|
|
*/
|
|
vmalloc_sync_unmappings();
|
|
|
|
/*
|
|
* In this function, newly allocated vm_struct has VM_UNINITIALIZED
|
|
* flag. It means that vm_struct is not fully initialized.
|
|
* Now, it is fully initialized, so remove this flag here.
|
|
*/
|
|
clear_vm_uninitialized_flag(area);
|
|
|
|
kmemleak_vmalloc(area, size, gfp_mask);
|
|
|
|
return addr;
|
|
|
|
fail:
|
|
warn_alloc(gfp_mask, NULL,
|
|
"vmalloc: allocation failure: %lu bytes", real_size);
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* __vmalloc_node - allocate virtually contiguous memory
|
|
* @size: allocation size
|
|
* @align: desired alignment
|
|
* @gfp_mask: flags for the page level allocator
|
|
* @prot: protection mask for the allocated pages
|
|
* @node: node to use for allocation or NUMA_NO_NODE
|
|
* @caller: caller's return address
|
|
*
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator with @gfp_mask flags. Map them into contiguous
|
|
* kernel virtual space, using a pagetable protection of @prot.
|
|
*
|
|
* Reclaim modifiers in @gfp_mask - __GFP_NORETRY, __GFP_RETRY_MAYFAIL
|
|
* and __GFP_NOFAIL are not supported
|
|
*
|
|
* Any use of gfp flags outside of GFP_KERNEL should be consulted
|
|
* with mm people.
|
|
*
|
|
*/
|
|
static void *__vmalloc_node(unsigned long size, unsigned long align,
|
|
gfp_t gfp_mask, pgprot_t prot,
|
|
int node, const void *caller)
|
|
{
|
|
return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
|
|
gfp_mask, prot, 0, node, caller);
|
|
}
|
|
|
|
void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
|
|
{
|
|
return __vmalloc_node(size, 1, gfp_mask, prot, NUMA_NO_NODE,
|
|
__builtin_return_address(0));
|
|
}
|
|
EXPORT_SYMBOL(__vmalloc);
|
|
|
|
static inline void *__vmalloc_node_flags(unsigned long size,
|
|
int node, gfp_t flags)
|
|
{
|
|
return __vmalloc_node(size, 1, flags, PAGE_KERNEL,
|
|
node, __builtin_return_address(0));
|
|
}
|
|
|
|
|
|
void *__vmalloc_node_flags_caller(unsigned long size, int node, gfp_t flags,
|
|
void *caller)
|
|
{
|
|
return __vmalloc_node(size, 1, flags, PAGE_KERNEL, node, caller);
|
|
}
|
|
|
|
/**
|
|
* vmalloc - allocate virtually contiguous memory
|
|
* @size: allocation size
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator and map them into contiguous kernel virtual space.
|
|
*
|
|
* For tight control over page level allocator and protection flags
|
|
* use __vmalloc() instead.
|
|
*/
|
|
void *vmalloc(unsigned long size)
|
|
{
|
|
return __vmalloc_node_flags(size, NUMA_NO_NODE,
|
|
GFP_KERNEL);
|
|
}
|
|
EXPORT_SYMBOL(vmalloc);
|
|
|
|
/**
|
|
* vzalloc - allocate virtually contiguous memory with zero fill
|
|
* @size: allocation size
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator and map them into contiguous kernel virtual space.
|
|
* The memory allocated is set to zero.
|
|
*
|
|
* For tight control over page level allocator and protection flags
|
|
* use __vmalloc() instead.
|
|
*/
|
|
void *vzalloc(unsigned long size)
|
|
{
|
|
return __vmalloc_node_flags(size, NUMA_NO_NODE,
|
|
GFP_KERNEL | __GFP_ZERO);
|
|
}
|
|
EXPORT_SYMBOL(vzalloc);
|
|
|
|
/**
|
|
* vmalloc_user - allocate zeroed virtually contiguous memory for userspace
|
|
* @size: allocation size
|
|
*
|
|
* The resulting memory area is zeroed so it can be mapped to userspace
|
|
* without leaking data.
|
|
*/
|
|
void *vmalloc_user(unsigned long size)
|
|
{
|
|
struct vm_struct *area;
|
|
void *ret;
|
|
|
|
ret = __vmalloc_node(size, SHMLBA,
|
|
GFP_KERNEL | __GFP_ZERO,
|
|
PAGE_KERNEL, NUMA_NO_NODE,
|
|
__builtin_return_address(0));
|
|
if (ret) {
|
|
area = find_vm_area(ret);
|
|
area->flags |= VM_USERMAP;
|
|
}
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_user);
|
|
|
|
/**
|
|
* vmalloc_node - allocate memory on a specific node
|
|
* @size: allocation size
|
|
* @node: numa node
|
|
*
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator and map them into contiguous kernel virtual space.
|
|
*
|
|
* For tight control over page level allocator and protection flags
|
|
* use __vmalloc() instead.
|
|
*/
|
|
void *vmalloc_node(unsigned long size, int node)
|
|
{
|
|
return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL,
|
|
node, __builtin_return_address(0));
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_node);
|
|
|
|
/**
|
|
* vzalloc_node - allocate memory on a specific node with zero fill
|
|
* @size: allocation size
|
|
* @node: numa node
|
|
*
|
|
* Allocate enough pages to cover @size from the page level
|
|
* allocator and map them into contiguous kernel virtual space.
|
|
* The memory allocated is set to zero.
|
|
*
|
|
* For tight control over page level allocator and protection flags
|
|
* use __vmalloc_node() instead.
|
|
*/
|
|
void *vzalloc_node(unsigned long size, int node)
|
|
{
|
|
return __vmalloc_node_flags(size, node,
|
|
GFP_KERNEL | __GFP_ZERO);
|
|
}
|
|
EXPORT_SYMBOL(vzalloc_node);
|
|
|
|
#ifndef PAGE_KERNEL_EXEC
|
|
# define PAGE_KERNEL_EXEC PAGE_KERNEL
|
|
#endif
|
|
|
|
/**
|
|
* vmalloc_exec - allocate virtually contiguous, executable memory
|
|
* @size: allocation size
|
|
*
|
|
* Kernel-internal function to allocate enough pages to cover @size
|
|
* the page level allocator and map them into contiguous and
|
|
* executable kernel virtual space.
|
|
*
|
|
* For tight control over page level allocator and protection flags
|
|
* use __vmalloc() instead.
|
|
*/
|
|
|
|
void *vmalloc_exec(unsigned long size)
|
|
{
|
|
return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC,
|
|
NUMA_NO_NODE, __builtin_return_address(0));
|
|
}
|
|
|
|
#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)
|
|
#define GFP_VMALLOC32 (GFP_DMA32 | GFP_KERNEL)
|
|
#elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA)
|
|
#define GFP_VMALLOC32 (GFP_DMA | GFP_KERNEL)
|
|
#else
|
|
/*
|
|
* 64b systems should always have either DMA or DMA32 zones. For others
|
|
* GFP_DMA32 should do the right thing and use the normal zone.
|
|
*/
|
|
#define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL
|
|
#endif
|
|
|
|
/**
|
|
* vmalloc_32 - allocate virtually contiguous memory (32bit addressable)
|
|
* @size: allocation size
|
|
*
|
|
* Allocate enough 32bit PA addressable pages to cover @size from the
|
|
* page level allocator and map them into contiguous kernel virtual space.
|
|
*/
|
|
void *vmalloc_32(unsigned long size)
|
|
{
|
|
return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL,
|
|
NUMA_NO_NODE, __builtin_return_address(0));
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_32);
|
|
|
|
/**
|
|
* vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory
|
|
* @size: allocation size
|
|
*
|
|
* The resulting memory area is 32bit addressable and zeroed so it can be
|
|
* mapped to userspace without leaking data.
|
|
*/
|
|
void *vmalloc_32_user(unsigned long size)
|
|
{
|
|
struct vm_struct *area;
|
|
void *ret;
|
|
|
|
ret = __vmalloc_node(size, 1, GFP_VMALLOC32 | __GFP_ZERO, PAGE_KERNEL,
|
|
NUMA_NO_NODE, __builtin_return_address(0));
|
|
if (ret) {
|
|
area = find_vm_area(ret);
|
|
area->flags |= VM_USERMAP;
|
|
}
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(vmalloc_32_user);
|
|
|
|
/*
|
|
* small helper routine , copy contents to buf from addr.
|
|
* If the page is not present, fill zero.
|
|
*/
|
|
|
|
static int aligned_vread(char *buf, char *addr, unsigned long count)
|
|
{
|
|
struct page *p;
|
|
int copied = 0;
|
|
|
|
while (count) {
|
|
unsigned long offset, length;
|
|
|
|
offset = offset_in_page(addr);
|
|
length = PAGE_SIZE - offset;
|
|
if (length > count)
|
|
length = count;
|
|
p = vmalloc_to_page(addr);
|
|
/*
|
|
* To do safe access to this _mapped_ area, we need
|
|
* lock. But adding lock here means that we need to add
|
|
* overhead of vmalloc()/vfree() calles for this _debug_
|
|
* interface, rarely used. Instead of that, we'll use
|
|
* kmap() and get small overhead in this access function.
|
|
*/
|
|
if (p) {
|
|
/*
|
|
* we can expect USER0 is not used (see vread/vwrite's
|
|
* function description)
|
|
*/
|
|
void *map = kmap_atomic(p);
|
|
memcpy(buf, map + offset, length);
|
|
kunmap_atomic(map);
|
|
} else
|
|
memset(buf, 0, length);
|
|
|
|
addr += length;
|
|
buf += length;
|
|
copied += length;
|
|
count -= length;
|
|
}
|
|
return copied;
|
|
}
|
|
|
|
static int aligned_vwrite(char *buf, char *addr, unsigned long count)
|
|
{
|
|
struct page *p;
|
|
int copied = 0;
|
|
|
|
while (count) {
|
|
unsigned long offset, length;
|
|
|
|
offset = offset_in_page(addr);
|
|
length = PAGE_SIZE - offset;
|
|
if (length > count)
|
|
length = count;
|
|
p = vmalloc_to_page(addr);
|
|
/*
|
|
* To do safe access to this _mapped_ area, we need
|
|
* lock. But adding lock here means that we need to add
|
|
* overhead of vmalloc()/vfree() calles for this _debug_
|
|
* interface, rarely used. Instead of that, we'll use
|
|
* kmap() and get small overhead in this access function.
|
|
*/
|
|
if (p) {
|
|
/*
|
|
* we can expect USER0 is not used (see vread/vwrite's
|
|
* function description)
|
|
*/
|
|
void *map = kmap_atomic(p);
|
|
memcpy(map + offset, buf, length);
|
|
kunmap_atomic(map);
|
|
}
|
|
addr += length;
|
|
buf += length;
|
|
copied += length;
|
|
count -= length;
|
|
}
|
|
return copied;
|
|
}
|
|
|
|
/**
|
|
* vread() - read vmalloc area in a safe way.
|
|
* @buf: buffer for reading data
|
|
* @addr: vm address.
|
|
* @count: number of bytes to be read.
|
|
*
|
|
* Returns # of bytes which addr and buf should be increased.
|
|
* (same number to @count). Returns 0 if [addr...addr+count) doesn't
|
|
* includes any intersect with alive vmalloc area.
|
|
*
|
|
* This function checks that addr is a valid vmalloc'ed area, and
|
|
* copy data from that area to a given buffer. If the given memory range
|
|
* of [addr...addr+count) includes some valid address, data is copied to
|
|
* proper area of @buf. If there are memory holes, they'll be zero-filled.
|
|
* IOREMAP area is treated as memory hole and no copy is done.
|
|
*
|
|
* If [addr...addr+count) doesn't includes any intersects with alive
|
|
* vm_struct area, returns 0. @buf should be kernel's buffer.
|
|
*
|
|
* Note: In usual ops, vread() is never necessary because the caller
|
|
* should know vmalloc() area is valid and can use memcpy().
|
|
* This is for routines which have to access vmalloc area without
|
|
* any informaion, as /dev/kmem.
|
|
*
|
|
*/
|
|
|
|
long vread(char *buf, char *addr, unsigned long count)
|
|
{
|
|
struct vmap_area *va;
|
|
struct vm_struct *vm;
|
|
char *vaddr, *buf_start = buf;
|
|
unsigned long buflen = count;
|
|
unsigned long n;
|
|
|
|
/* Don't allow overflow */
|
|
if ((unsigned long) addr + count < count)
|
|
count = -(unsigned long) addr;
|
|
|
|
spin_lock(&vmap_area_lock);
|
|
list_for_each_entry(va, &vmap_area_list, list) {
|
|
if (!count)
|
|
break;
|
|
|
|
if (!(va->flags & VM_VM_AREA))
|
|
continue;
|
|
|
|
vm = va->vm;
|
|
vaddr = (char *) vm->addr;
|
|
if (addr >= vaddr + get_vm_area_size(vm))
|
|
continue;
|
|
while (addr < vaddr) {
|
|
if (count == 0)
|
|
goto finished;
|
|
*buf = '\0';
|
|
buf++;
|
|
addr++;
|
|
count--;
|
|
}
|
|
n = vaddr + get_vm_area_size(vm) - addr;
|
|
if (n > count)
|
|
n = count;
|
|
if (!(vm->flags & VM_IOREMAP))
|
|
aligned_vread(buf, addr, n);
|
|
else /* IOREMAP area is treated as memory hole */
|
|
memset(buf, 0, n);
|
|
buf += n;
|
|
addr += n;
|
|
count -= n;
|
|
}
|
|
finished:
|
|
spin_unlock(&vmap_area_lock);
|
|
|
|
if (buf == buf_start)
|
|
return 0;
|
|
/* zero-fill memory holes */
|
|
if (buf != buf_start + buflen)
|
|
memset(buf, 0, buflen - (buf - buf_start));
|
|
|
|
return buflen;
|
|
}
|
|
|
|
/**
|
|
* vwrite() - write vmalloc area in a safe way.
|
|
* @buf: buffer for source data
|
|
* @addr: vm address.
|
|
* @count: number of bytes to be read.
|
|
*
|
|
* Returns # of bytes which addr and buf should be incresed.
|
|
* (same number to @count).
|
|
* If [addr...addr+count) doesn't includes any intersect with valid
|
|
* vmalloc area, returns 0.
|
|
*
|
|
* This function checks that addr is a valid vmalloc'ed area, and
|
|
* copy data from a buffer to the given addr. If specified range of
|
|
* [addr...addr+count) includes some valid address, data is copied from
|
|
* proper area of @buf. If there are memory holes, no copy to hole.
|
|
* IOREMAP area is treated as memory hole and no copy is done.
|
|
*
|
|
* If [addr...addr+count) doesn't includes any intersects with alive
|
|
* vm_struct area, returns 0. @buf should be kernel's buffer.
|
|
*
|
|
* Note: In usual ops, vwrite() is never necessary because the caller
|
|
* should know vmalloc() area is valid and can use memcpy().
|
|
* This is for routines which have to access vmalloc area without
|
|
* any informaion, as /dev/kmem.
|
|
*/
|
|
|
|
long vwrite(char *buf, char *addr, unsigned long count)
|
|
{
|
|
struct vmap_area *va;
|
|
struct vm_struct *vm;
|
|
char *vaddr;
|
|
unsigned long n, buflen;
|
|
int copied = 0;
|
|
|
|
/* Don't allow overflow */
|
|
if ((unsigned long) addr + count < count)
|
|
count = -(unsigned long) addr;
|
|
buflen = count;
|
|
|
|
spin_lock(&vmap_area_lock);
|
|
list_for_each_entry(va, &vmap_area_list, list) {
|
|
if (!count)
|
|
break;
|
|
|
|
if (!(va->flags & VM_VM_AREA))
|
|
continue;
|
|
|
|
vm = va->vm;
|
|
vaddr = (char *) vm->addr;
|
|
if (addr >= vaddr + get_vm_area_size(vm))
|
|
continue;
|
|
while (addr < vaddr) {
|
|
if (count == 0)
|
|
goto finished;
|
|
buf++;
|
|
addr++;
|
|
count--;
|
|
}
|
|
n = vaddr + get_vm_area_size(vm) - addr;
|
|
if (n > count)
|
|
n = count;
|
|
if (!(vm->flags & VM_IOREMAP)) {
|
|
aligned_vwrite(buf, addr, n);
|
|
copied++;
|
|
}
|
|
buf += n;
|
|
addr += n;
|
|
count -= n;
|
|
}
|
|
finished:
|
|
spin_unlock(&vmap_area_lock);
|
|
if (!copied)
|
|
return 0;
|
|
return buflen;
|
|
}
|
|
|
|
/**
|
|
* remap_vmalloc_range_partial - map vmalloc pages to userspace
|
|
* @vma: vma to cover
|
|
* @uaddr: target user address to start at
|
|
* @kaddr: virtual address of vmalloc kernel memory
|
|
* @pgoff: offset from @kaddr to start at
|
|
* @size: size of map area
|
|
*
|
|
* Returns: 0 for success, -Exxx on failure
|
|
*
|
|
* This function checks that @kaddr is a valid vmalloc'ed area,
|
|
* and that it is big enough to cover the range starting at
|
|
* @uaddr in @vma. Will return failure if that criteria isn't
|
|
* met.
|
|
*
|
|
* Similar to remap_pfn_range() (see mm/memory.c)
|
|
*/
|
|
int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
|
|
void *kaddr, unsigned long pgoff,
|
|
unsigned long size)
|
|
{
|
|
struct vm_struct *area;
|
|
unsigned long off;
|
|
unsigned long end_index;
|
|
|
|
if (check_shl_overflow(pgoff, PAGE_SHIFT, &off))
|
|
return -EINVAL;
|
|
|
|
size = PAGE_ALIGN(size);
|
|
|
|
if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
|
|
return -EINVAL;
|
|
|
|
area = find_vm_area(kaddr);
|
|
if (!area)
|
|
return -EINVAL;
|
|
|
|
if (!(area->flags & VM_USERMAP))
|
|
return -EINVAL;
|
|
|
|
if (check_add_overflow(size, off, &end_index) ||
|
|
end_index > get_vm_area_size(area))
|
|
return -EINVAL;
|
|
kaddr += off;
|
|
|
|
do {
|
|
struct page *page = vmalloc_to_page(kaddr);
|
|
int ret;
|
|
|
|
ret = vm_insert_page(vma, uaddr, page);
|
|
if (ret)
|
|
return ret;
|
|
|
|
uaddr += PAGE_SIZE;
|
|
kaddr += PAGE_SIZE;
|
|
size -= PAGE_SIZE;
|
|
} while (size > 0);
|
|
|
|
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(remap_vmalloc_range_partial);
|
|
|
|
/**
|
|
* remap_vmalloc_range - map vmalloc pages to userspace
|
|
* @vma: vma to cover (map full range of vma)
|
|
* @addr: vmalloc memory
|
|
* @pgoff: number of pages into addr before first page to map
|
|
*
|
|
* Returns: 0 for success, -Exxx on failure
|
|
*
|
|
* This function checks that addr is a valid vmalloc'ed area, and
|
|
* that it is big enough to cover the vma. Will return failure if
|
|
* that criteria isn't met.
|
|
*
|
|
* Similar to remap_pfn_range() (see mm/memory.c)
|
|
*/
|
|
int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
|
|
unsigned long pgoff)
|
|
{
|
|
return remap_vmalloc_range_partial(vma, vma->vm_start,
|
|
addr, pgoff,
|
|
vma->vm_end - vma->vm_start);
|
|
}
|
|
EXPORT_SYMBOL(remap_vmalloc_range);
|
|
|
|
/*
|
|
* Implement stubs for vmalloc_sync_[un]mappings () if the architecture chose
|
|
* not to have one.
|
|
*
|
|
* The purpose of this function is to make sure the vmalloc area
|
|
* mappings are identical in all page-tables in the system.
|
|
*/
|
|
void __weak vmalloc_sync_mappings(void)
|
|
{
|
|
}
|
|
|
|
void __weak vmalloc_sync_unmappings(void)
|
|
{
|
|
}
|
|
|
|
static int f(pte_t *pte, pgtable_t table, unsigned long addr, void *data)
|
|
{
|
|
pte_t ***p = data;
|
|
|
|
if (p) {
|
|
*(*p) = pte;
|
|
(*p)++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* alloc_vm_area - allocate a range of kernel address space
|
|
* @size: size of the area
|
|
* @ptes: returns the PTEs for the address space
|
|
*
|
|
* Returns: NULL on failure, vm_struct on success
|
|
*
|
|
* This function reserves a range of kernel address space, and
|
|
* allocates pagetables to map that range. No actual mappings
|
|
* are created.
|
|
*
|
|
* If @ptes is non-NULL, pointers to the PTEs (in init_mm)
|
|
* allocated for the VM area are returned.
|
|
*/
|
|
struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes)
|
|
{
|
|
struct vm_struct *area;
|
|
|
|
area = get_vm_area_caller(size, VM_IOREMAP,
|
|
__builtin_return_address(0));
|
|
if (area == NULL)
|
|
return NULL;
|
|
|
|
/*
|
|
* This ensures that page tables are constructed for this region
|
|
* of kernel virtual address space and mapped into init_mm.
|
|
*/
|
|
if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
|
|
size, f, ptes ? &ptes : NULL)) {
|
|
free_vm_area(area);
|
|
return NULL;
|
|
}
|
|
|
|
return area;
|
|
}
|
|
EXPORT_SYMBOL_GPL(alloc_vm_area);
|
|
|
|
void free_vm_area(struct vm_struct *area)
|
|
{
|
|
struct vm_struct *ret;
|
|
ret = remove_vm_area(area->addr);
|
|
BUG_ON(ret != area);
|
|
kfree(area);
|
|
}
|
|
EXPORT_SYMBOL_GPL(free_vm_area);
|
|
|
|
#ifdef CONFIG_SMP
|
|
static struct vmap_area *node_to_va(struct rb_node *n)
|
|
{
|
|
return rb_entry_safe(n, struct vmap_area, rb_node);
|
|
}
|
|
|
|
/**
|
|
* pvm_find_next_prev - find the next and prev vmap_area surrounding @end
|
|
* @end: target address
|
|
* @pnext: out arg for the next vmap_area
|
|
* @pprev: out arg for the previous vmap_area
|
|
*
|
|
* Returns: %true if either or both of next and prev are found,
|
|
* %false if no vmap_area exists
|
|
*
|
|
* Find vmap_areas end addresses of which enclose @end. ie. if not
|
|
* NULL, *pnext->va_end > @end and *pprev->va_end <= @end.
|
|
*/
|
|
static bool pvm_find_next_prev(unsigned long end,
|
|
struct vmap_area **pnext,
|
|
struct vmap_area **pprev)
|
|
{
|
|
struct rb_node *n = vmap_area_root.rb_node;
|
|
struct vmap_area *va = NULL;
|
|
|
|
while (n) {
|
|
va = rb_entry(n, struct vmap_area, rb_node);
|
|
if (end < va->va_end)
|
|
n = n->rb_left;
|
|
else if (end > va->va_end)
|
|
n = n->rb_right;
|
|
else
|
|
break;
|
|
}
|
|
|
|
if (!va)
|
|
return false;
|
|
|
|
if (va->va_end > end) {
|
|
*pnext = va;
|
|
*pprev = node_to_va(rb_prev(&(*pnext)->rb_node));
|
|
} else {
|
|
*pprev = va;
|
|
*pnext = node_to_va(rb_next(&(*pprev)->rb_node));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* pvm_determine_end - find the highest aligned address between two vmap_areas
|
|
* @pnext: in/out arg for the next vmap_area
|
|
* @pprev: in/out arg for the previous vmap_area
|
|
* @align: alignment
|
|
*
|
|
* Returns: determined end address
|
|
*
|
|
* Find the highest aligned address between *@pnext and *@pprev below
|
|
* VMALLOC_END. *@pnext and *@pprev are adjusted so that the aligned
|
|
* down address is between the end addresses of the two vmap_areas.
|
|
*
|
|
* Please note that the address returned by this function may fall
|
|
* inside *@pnext vmap_area. The caller is responsible for checking
|
|
* that.
|
|
*/
|
|
static unsigned long pvm_determine_end(struct vmap_area **pnext,
|
|
struct vmap_area **pprev,
|
|
unsigned long align)
|
|
{
|
|
const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
|
|
unsigned long addr;
|
|
|
|
if (*pnext)
|
|
addr = min((*pnext)->va_start & ~(align - 1), vmalloc_end);
|
|
else
|
|
addr = vmalloc_end;
|
|
|
|
while (*pprev && (*pprev)->va_end > addr) {
|
|
*pnext = *pprev;
|
|
*pprev = node_to_va(rb_prev(&(*pnext)->rb_node));
|
|
}
|
|
|
|
return addr;
|
|
}
|
|
|
|
/**
|
|
* pcpu_get_vm_areas - allocate vmalloc areas for percpu allocator
|
|
* @offsets: array containing offset of each area
|
|
* @sizes: array containing size of each area
|
|
* @nr_vms: the number of areas to allocate
|
|
* @align: alignment, all entries in @offsets and @sizes must be aligned to this
|
|
*
|
|
* Returns: kmalloc'd vm_struct pointer array pointing to allocated
|
|
* vm_structs on success, %NULL on failure
|
|
*
|
|
* Percpu allocator wants to use congruent vm areas so that it can
|
|
* maintain the offsets among percpu areas. This function allocates
|
|
* congruent vmalloc areas for it with GFP_KERNEL. These areas tend to
|
|
* be scattered pretty far, distance between two areas easily going up
|
|
* to gigabytes. To avoid interacting with regular vmallocs, these
|
|
* areas are allocated from top.
|
|
*
|
|
* Despite its complicated look, this allocator is rather simple. It
|
|
* does everything top-down and scans areas from the end looking for
|
|
* matching slot. While scanning, if any of the areas overlaps with
|
|
* existing vmap_area, the base address is pulled down to fit the
|
|
* area. Scanning is repeated till all the areas fit and then all
|
|
* necessary data structures are inserted and the result is returned.
|
|
*/
|
|
struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
|
|
const size_t *sizes, int nr_vms,
|
|
size_t align)
|
|
{
|
|
const unsigned long vmalloc_start = ALIGN(VMALLOC_START, align);
|
|
const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
|
|
struct vmap_area **vas, *prev, *next;
|
|
struct vm_struct **vms;
|
|
int area, area2, last_area, term_area;
|
|
unsigned long base, start, end, last_end;
|
|
bool purged = false;
|
|
|
|
/* verify parameters and allocate data structures */
|
|
BUG_ON(offset_in_page(align) || !is_power_of_2(align));
|
|
for (last_area = 0, area = 0; area < nr_vms; area++) {
|
|
start = offsets[area];
|
|
end = start + sizes[area];
|
|
|
|
/* is everything aligned properly? */
|
|
BUG_ON(!IS_ALIGNED(offsets[area], align));
|
|
BUG_ON(!IS_ALIGNED(sizes[area], align));
|
|
|
|
/* detect the area with the highest address */
|
|
if (start > offsets[last_area])
|
|
last_area = area;
|
|
|
|
for (area2 = area + 1; area2 < nr_vms; area2++) {
|
|
unsigned long start2 = offsets[area2];
|
|
unsigned long end2 = start2 + sizes[area2];
|
|
|
|
BUG_ON(start2 < end && start < end2);
|
|
}
|
|
}
|
|
last_end = offsets[last_area] + sizes[last_area];
|
|
|
|
if (vmalloc_end - vmalloc_start < last_end) {
|
|
WARN_ON(true);
|
|
return NULL;
|
|
}
|
|
|
|
vms = kcalloc(nr_vms, sizeof(vms[0]), GFP_KERNEL);
|
|
vas = kcalloc(nr_vms, sizeof(vas[0]), GFP_KERNEL);
|
|
if (!vas || !vms)
|
|
goto err_free2;
|
|
|
|
for (area = 0; area < nr_vms; area++) {
|
|
vas[area] = kzalloc(sizeof(struct vmap_area), GFP_KERNEL);
|
|
vms[area] = kzalloc(sizeof(struct vm_struct), GFP_KERNEL);
|
|
if (!vas[area] || !vms[area])
|
|
goto err_free;
|
|
}
|
|
retry:
|
|
spin_lock(&vmap_area_lock);
|
|
|
|
/* start scanning - we scan from the top, begin with the last area */
|
|
area = term_area = last_area;
|
|
start = offsets[area];
|
|
end = start + sizes[area];
|
|
|
|
if (!pvm_find_next_prev(vmap_area_pcpu_hole, &next, &prev)) {
|
|
base = vmalloc_end - last_end;
|
|
goto found;
|
|
}
|
|
base = pvm_determine_end(&next, &prev, align) - end;
|
|
|
|
while (true) {
|
|
BUG_ON(next && next->va_end <= base + end);
|
|
BUG_ON(prev && prev->va_end > base + end);
|
|
|
|
/*
|
|
* base might have underflowed, add last_end before
|
|
* comparing.
|
|
*/
|
|
if (base + last_end < vmalloc_start + last_end) {
|
|
spin_unlock(&vmap_area_lock);
|
|
if (!purged) {
|
|
purge_vmap_area_lazy();
|
|
purged = true;
|
|
goto retry;
|
|
}
|
|
goto err_free;
|
|
}
|
|
|
|
/*
|
|
* If next overlaps, move base downwards so that it's
|
|
* right below next and then recheck.
|
|
*/
|
|
if (next && next->va_start < base + end) {
|
|
base = pvm_determine_end(&next, &prev, align) - end;
|
|
term_area = area;
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* If prev overlaps, shift down next and prev and move
|
|
* base so that it's right below new next and then
|
|
* recheck.
|
|
*/
|
|
if (prev && prev->va_end > base + start) {
|
|
next = prev;
|
|
prev = node_to_va(rb_prev(&next->rb_node));
|
|
base = pvm_determine_end(&next, &prev, align) - end;
|
|
term_area = area;
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* This area fits, move on to the previous one. If
|
|
* the previous one is the terminal one, we're done.
|
|
*/
|
|
area = (area + nr_vms - 1) % nr_vms;
|
|
if (area == term_area)
|
|
break;
|
|
start = offsets[area];
|
|
end = start + sizes[area];
|
|
pvm_find_next_prev(base + end, &next, &prev);
|
|
}
|
|
found:
|
|
/* we've found a fitting base, insert all va's */
|
|
for (area = 0; area < nr_vms; area++) {
|
|
struct vmap_area *va = vas[area];
|
|
|
|
va->va_start = base + offsets[area];
|
|
va->va_end = va->va_start + sizes[area];
|
|
__insert_vmap_area(va);
|
|
}
|
|
|
|
vmap_area_pcpu_hole = base + offsets[last_area];
|
|
|
|
spin_unlock(&vmap_area_lock);
|
|
|
|
/* insert all vm's */
|
|
for (area = 0; area < nr_vms; area++)
|
|
setup_vmalloc_vm(vms[area], vas[area], VM_ALLOC,
|
|
pcpu_get_vm_areas);
|
|
|
|
kfree(vas);
|
|
return vms;
|
|
|
|
err_free:
|
|
for (area = 0; area < nr_vms; area++) {
|
|
kfree(vas[area]);
|
|
kfree(vms[area]);
|
|
}
|
|
err_free2:
|
|
kfree(vas);
|
|
kfree(vms);
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* pcpu_free_vm_areas - free vmalloc areas for percpu allocator
|
|
* @vms: vm_struct pointer array returned by pcpu_get_vm_areas()
|
|
* @nr_vms: the number of allocated areas
|
|
*
|
|
* Free vm_structs and the array allocated by pcpu_get_vm_areas().
|
|
*/
|
|
void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < nr_vms; i++)
|
|
free_vm_area(vms[i]);
|
|
kfree(vms);
|
|
}
|
|
#endif /* CONFIG_SMP */
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
static void *s_start(struct seq_file *m, loff_t *pos)
|
|
__acquires(&vmap_area_lock)
|
|
{
|
|
spin_lock(&vmap_area_lock);
|
|
return seq_list_start(&vmap_area_list, *pos);
|
|
}
|
|
|
|
static void *s_next(struct seq_file *m, void *p, loff_t *pos)
|
|
{
|
|
return seq_list_next(p, &vmap_area_list, pos);
|
|
}
|
|
|
|
static void s_stop(struct seq_file *m, void *p)
|
|
__releases(&vmap_area_lock)
|
|
{
|
|
spin_unlock(&vmap_area_lock);
|
|
}
|
|
|
|
static void show_numa_info(struct seq_file *m, struct vm_struct *v)
|
|
{
|
|
if (IS_ENABLED(CONFIG_NUMA)) {
|
|
unsigned int nr, *counters = m->private;
|
|
|
|
if (!counters)
|
|
return;
|
|
|
|
if (v->flags & VM_UNINITIALIZED)
|
|
return;
|
|
/* Pair with smp_wmb() in clear_vm_uninitialized_flag() */
|
|
smp_rmb();
|
|
|
|
memset(counters, 0, nr_node_ids * sizeof(unsigned int));
|
|
|
|
for (nr = 0; nr < v->nr_pages; nr++)
|
|
counters[page_to_nid(v->pages[nr])]++;
|
|
|
|
for_each_node_state(nr, N_HIGH_MEMORY)
|
|
if (counters[nr])
|
|
seq_printf(m, " N%u=%u", nr, counters[nr]);
|
|
}
|
|
}
|
|
|
|
static int s_show(struct seq_file *m, void *p)
|
|
{
|
|
struct vmap_area *va;
|
|
struct vm_struct *v;
|
|
|
|
va = list_entry(p, struct vmap_area, list);
|
|
|
|
/*
|
|
* s_show can encounter race with remove_vm_area, !VM_VM_AREA on
|
|
* behalf of vmap area is being tear down or vm_map_ram allocation.
|
|
*/
|
|
if (!(va->flags & VM_VM_AREA)) {
|
|
seq_printf(m, "0x%pK-0x%pK %7ld %s\n",
|
|
(void *)va->va_start, (void *)va->va_end,
|
|
va->va_end - va->va_start,
|
|
va->flags & VM_LAZY_FREE ? "unpurged vm_area" : "vm_map_ram");
|
|
|
|
return 0;
|
|
}
|
|
|
|
v = va->vm;
|
|
|
|
seq_printf(m, "0x%pK-0x%pK %7ld",
|
|
v->addr, v->addr + v->size, v->size);
|
|
|
|
if (v->caller)
|
|
seq_printf(m, " %pS", v->caller);
|
|
|
|
if (v->nr_pages)
|
|
seq_printf(m, " pages=%d", v->nr_pages);
|
|
|
|
if (v->phys_addr)
|
|
seq_printf(m, " phys=%pa", &v->phys_addr);
|
|
|
|
if (v->flags & VM_IOREMAP)
|
|
seq_puts(m, " ioremap");
|
|
|
|
if (v->flags & VM_ALLOC)
|
|
seq_puts(m, " vmalloc");
|
|
|
|
if (v->flags & VM_MAP)
|
|
seq_puts(m, " vmap");
|
|
|
|
if (v->flags & VM_USERMAP)
|
|
seq_puts(m, " user");
|
|
|
|
if (is_vmalloc_addr(v->pages))
|
|
seq_puts(m, " vpages");
|
|
|
|
if (v->flags & VM_LOWMEM)
|
|
seq_puts(m, " lowmem");
|
|
|
|
show_numa_info(m, v);
|
|
seq_putc(m, '\n');
|
|
return 0;
|
|
}
|
|
|
|
static const struct seq_operations vmalloc_op = {
|
|
.start = s_start,
|
|
.next = s_next,
|
|
.stop = s_stop,
|
|
.show = s_show,
|
|
};
|
|
|
|
static int vmalloc_open(struct inode *inode, struct file *file)
|
|
{
|
|
if (IS_ENABLED(CONFIG_NUMA))
|
|
return seq_open_private(file, &vmalloc_op,
|
|
nr_node_ids * sizeof(unsigned int));
|
|
else
|
|
return seq_open(file, &vmalloc_op);
|
|
}
|
|
|
|
static const struct file_operations proc_vmalloc_operations = {
|
|
.open = vmalloc_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release_private,
|
|
};
|
|
|
|
static int __init proc_vmalloc_init(void)
|
|
{
|
|
proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
|
|
return 0;
|
|
}
|
|
module_init(proc_vmalloc_init);
|
|
|
|
#endif
|
|
|