14 Jan, 2021

10 commits

  • When a buffer is added to the LRU list, a reference is taken which is
    not dropped until the buffer is evicted from the LRU list. This is the
    correct behavior, however this LRU reference will prevent the buffer
    from being dropped. This means that the buffer can't actually be dropped
    until it is selected for eviction. There's no bound on the time spent
    on the LRU list, which means that the buffer may be undroppable for
    very long periods of time. Given that migration involves dropping
    buffers, the associated page is now unmigratible for long periods of
    time as well. CMA relies on being able to migrate a specific range
    of pages, so these types of failures make CMA significantly
    less reliable, especially under high filesystem usage.

    Rather than waiting for the LRU algorithm to eventually kick out
    the buffer, explicitly remove the buffer from the LRU list when trying
    to drop it. There is still the possibility that the buffer
    could be added back on the list, but that indicates the buffer is
    still in use and would probably have other 'in use' indicates to
    prevent dropping.

    Note: a bug reported by "kernel test robot" lead to a switch from
    using xas_for_each() to xa_for_each().

    Bug: 174118021
    Link: https://lore.kernel.org/linux-mm/cover.1610572007.git.cgoldswo@codeaurora.org/
    Signed-off-by: Laura Abbott
    Signed-off-by: Chris Goldsworthy
    Cc: Matthew Wilcox
    Reported-by: kernel test robot
    Change-Id: I4a93c4ed81c57874764d12f3beea1194a30c13b2

    Laura Abbott
     
  • We loop around from_user, but we dereference to_user. Whoops.

    Fixes this trace seen in some cleanup paths:

    [ 11.612684] BUG: unable to handle page fault for address: 0000000000113d62
    [ 11.612777] #PF: supervisor write access in kernel mode
    [ 11.612777] #PF: error_code(0x0002) - not-present page
    [ 11.612777] PGD 0 P4D 0
    [ 11.612777] Oops: 0002 [#1] PREEMPT SMP PTI
    [ 11.612777] CPU: 1 PID: 150 Comm: snapuserd Tainted: G O 5.10.4-android12-0-03442-gf2684370d34d-ab7068937 #1
    [ 11.612777] Hardware name: ChromiumOS crosvm, BIOS 0
    [ 11.612777] RIP: 0010:channel_free+0xb0/0x140
    [ 11.612777] Code: 48 49 8b 5c 24 48 4c 39 fb 74 48 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 4c 8d 73 a0 4d 8b 2c 24 49 83 c5 38 48 8b 43 c8 40 1a 0a 48 8b 7b c8 e8 e3 87 bd ff 48 8b 7b c8 e8 1a 71 bd ff
    [ 11.612777] RSP: 0018:ffff9728c029fc18 EFLAGS: 00010282
    [ 11.612777] RAX: 0000000000113d48 RBX: ffff8a3941e021d0 RCX: ffff8a3944221080
    [ 11.612777] RDX: ffff8a39452e5810 RSI: ffff8a39452e5800 RDI: ffff8a39486f9300
    [ 11.612777] RBP: ffff9728c029fc40 R08: ffff8a3940148500 R09: ffff8a394886a7c0
    [ 11.612777] R10: ffff8a3944200650 R11: ffffffff86623d30 R12: ffff8a39486f9300
    [ 11.612777] R13: ffff8a3941749638 R14: ffff8a3941e02170 R15: ffff8a39486f9348
    [ 11.612777] FS: 0000000000000000(0000) GS:ffff8a396bc80000(0000) knlGS:0000000000000000
    [ 11.612777] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
    [ 11.612777] CR2: 0000000000113d62 CR3: 000000001820c005 CR4: 0000000000170ee0
    [ 11.612777] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [ 11.612777] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [ 11.612777] Call Trace:
    [ 11.612777] dev_release+0x22/0x40
    [ 11.612777] __fput+0xe0/0x210
    [ 11.612777] ____fput+0x9/0x10
    [ 11.612777] task_work_run+0x6f/0xb0
    [ 11.612777] do_exit+0x332/0xa80
    [ 11.612777] do_group_exit+0x8c/0xb0
    [ 11.612777] get_signal+0x78d/0x9c0
    [ 11.612777] arch_do_signal+0x80/0x260
    [ 11.612777] exit_to_user_mode_prepare+0xaa/0xe0
    [ 11.612777] syscall_exit_to_user_mode+0x24/0x40
    [ 11.612777] __do_fast_syscall_32+0x7d/0x90
    [ 11.612777] do_fast_syscall_32+0x34/0x70
    [ 11.612777] do_SYSENTER_32+0x1b/0x20
    [ 11.612777] entry_SYSENTER_compat_after_hwframe+0x4d/0x5f

    Bug: 161496058
    Test: launch_cvd ..
    Change-Id: I26b244b66121324aef6956d01adcc3ad55c782a9
    Signed-off-by: Alistair Delva

    Alistair Delva
     
  • In order to debug critical domain and device power issues, it may be
    necessary to disallow certain idle states at runtime. Enable a vendor
    hook to check if a domain idle state is allowed for powering down the
    domain.

    Bug: 175718935
    Signed-off-by: Lina Iyer
    Change-Id: I403c0c7d272439fb338bbf54a346861559385047

    Lina Iyer
     
  • Previously idle_cpu is exported which is used by vendor module to check
    if a cpu is in idle state, but later we think available_idle_cpu is
    better than idle_cpu because it also checks vcpu_is_preempted.

    Bug: 171740453
    Change-Id: I17ccc4925650431f334a9eb2bbc94a138ab36ae0
    Signed-off-by: Rick Yiu
    Signed-off-by: Will McVicker

    Rick Yiu
     
  • If CONFIG_LOCKDEP is enabled, export sched_domains_mutex as it is
    indirectly accessed by the macro for_each_domain, and that macro might
    be used in module code.

    Bug: 176254015
    Signed-off-by: Daniel Mentz
    Change-Id: Ia9f2989de41b2224c63855f2fd129cbeeac4f195
    Signed-off-by: Will McVicker

    Daniel Mentz
     
  • IOMMU_SYS_CACHE_ONLY_NWA allows buffers for non-coherent devices
    to be mapped with the correct memory attributes so that the buffers
    can be cached in the system cache, with a no write allocate cache policy.
    However, this property is only usable by drivers that invoke the
    IOMMU API directly; it is not usable by drivers that use the DMA API.

    Thus, introduce DMA_ATTR_SYS_CACHE_ONLY_NWA, so that drivers for
    non-coherent devices that use the DMA API can use it to specify if
    they want a buffer to be cached in the system cache.

    Bug: 176778547
    Change-Id: Ic812a1fb144a58deb4279c2bf121fc6cc4c3b208
    Signed-off-by: Isaac J. Manjarres

    Isaac J. Manjarres
     
  • IOMMU_SYS_CACHE_ONLY allows buffers for non-coherent devices
    to be mapped with the correct memory attributes so that the buffers
    can be cached in the system cache. However, this property
    is only usable by drivers that invoke the IOMMU API directly;
    it is not usable by drivers that use the DMA API.

    Thus, introduce DMA_ATTR_SYS_CACHE_ONLY, so that drivers for
    non-coherent devices that use the DMA API can use it to specify if
    they want a buffer to be cached in the system cache.

    Bug: 176778547
    Change-Id: I849d7a3f36b689afd2f6ee400507223fd6395158
    Signed-off-by: Isaac J. Manjarres

    Isaac J. Manjarres
     
  • Non-coherent devices on systems that support a system or
    last level cache may want to request that allocations be
    cached in the system cache. For memory that is allocated
    by the kernel, and used for DMA with devices, the memory
    attributes used for CPU access should match the memory
    attributes that will be used for device access.

    The memory attributes that need to be programmed into
    the MAIR for system cache usage are:

    0xf4 - Normal memory, outer write back read/write allocate,
    inner non-cacheable.

    There is currently no support for this memory attribute for
    CPU mappings, so add it.

    Bug: 176778547
    Change-Id: I3abc7becd408f20ac5499cbbe3c6c6f53f784107
    Signed-off-by: Isaac J. Manjarres

    Isaac J. Manjarres
     
  • Add following vendor hooks in ftrace oops path to allow
    vendor modules to get ftrace buffer data.

    1) android_vh_ftrace_oops_enter
    2) android_vh_ftrace_size_check
    3) android_vh_ftrace_format_check
    4) android_vh_ftrace_dump_buffer
    5) android_vh_ftrace_oops_exit

    Ftrace dump on oops can be controlled with kernel command
    line parameter ftrace_dump_on_oops.

    Bug: 177387994
    Change-Id: I898026bfc3e5c5c5ab1eaa0e86a019a6a720408e
    Signed-off-by: Prateek Sood
    Signed-off-by: Mukesh Ojha

    Prateek Sood
     
  • Export kstat_irqs_usr and kstat_irqs_cpu symbols for vendor
    loadable modules. These symbols are useful for continuous
    monitoring of irq stats to detect problems like interrupt
    storms.

    1) kstat_irqs_usr: it helps in getting total interrupt count
    for an IRQ.

    2) kstat_irqs_cpu: it helps in getting per cpu interrupt count
    for an IRQ.

    Bug: 177393442
    Change-Id: I6f65c5759cd096db391e1c41e4260aa4ebc40fb4
    Signed-off-by: Prateek Sood
    Signed-off-by: Mukesh Ojha

    Prateek Sood
     

13 Jan, 2021

30 commits

  • Changes in 5.10.7
    i40e: Fix Error I40E_AQ_RC_EINVAL when removing VFs
    iavf: fix double-release of rtnl_lock
    net/sched: sch_taprio: ensure to reset/destroy all child qdiscs
    net: mvpp2: Add TCAM entry to drop flow control pause frames
    net: mvpp2: prs: fix PPPoE with ipv6 packet parse
    net: systemport: set dev->max_mtu to UMAC_MAX_MTU_SIZE
    ethernet: ucc_geth: fix use-after-free in ucc_geth_remove()
    ethernet: ucc_geth: set dev->max_mtu to 1518
    ionic: account for vlan tag len in rx buffer len
    atm: idt77252: call pci_disable_device() on error path
    net: mvpp2: Fix GoP port 3 Networking Complex Control configurations
    net: stmmac: dwmac-meson8b: ignore the second clock input
    ibmvnic: fix login buffer memory leak
    ibmvnic: continue fatal error reset after passive init
    net: ethernet: mvneta: Fix error handling in mvneta_probe
    qede: fix offload for IPIP tunnel packets
    virtio_net: Fix recursive call to cpus_read_lock()
    net/ncsi: Use real net-device for response handler
    net: ethernet: Fix memleak in ethoc_probe
    net-sysfs: take the rtnl lock when storing xps_cpus
    net-sysfs: take the rtnl lock when accessing xps_cpus_map and num_tc
    net-sysfs: take the rtnl lock when storing xps_rxqs
    net-sysfs: take the rtnl lock when accessing xps_rxqs_map and num_tc
    net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered
    tun: fix return value when the number of iovs exceeds MAX_SKB_FRAGS
    e1000e: Only run S0ix flows if shutdown succeeded
    e1000e: bump up timeout to wait when ME un-configures ULP mode
    Revert "e1000e: disable s0ix entry and exit flows for ME systems"
    e1000e: Export S0ix flags to ethtool
    bnxt_en: Check TQM rings for maximum supported value.
    net: mvpp2: fix pkt coalescing int-threshold configuration
    bnxt_en: Fix AER recovery.
    ipv4: Ignore ECN bits for fib lookups in fib_compute_spec_dst()
    net: sched: prevent invalid Scell_log shift count
    net: hns: fix return value check in __lb_other_process()
    erspan: fix version 1 check in gre_parse_header()
    net: hdlc_ppp: Fix issues when mod_timer is called while timer is running
    bareudp: set NETIF_F_LLTX flag
    bareudp: Fix use of incorrect min_headroom size
    vhost_net: fix ubuf refcount incorrectly when sendmsg fails
    r8169: work around power-saving bug on some chip versions
    net: dsa: lantiq_gswip: Enable GSWIP_MII_CFG_EN also for internal PHYs
    net: dsa: lantiq_gswip: Fix GSWIP_MII_CFG(p) register access
    CDC-NCM: remove "connected" log message
    ibmvnic: fix: NULL pointer dereference.
    net: usb: qmi_wwan: add Quectel EM160R-GL
    selftests: mlxsw: Set headroom size of correct port
    stmmac: intel: Add PCI IDs for TGL-H platform
    selftests/vm: fix building protection keys test
    block: add debugfs stanza for QUEUE_FLAG_NOWAIT
    workqueue: Kick a worker based on the actual activation of delayed works
    scsi: ufs: Fix wrong print message in dev_err()
    scsi: ufs-pci: Fix restore from S4 for Intel controllers
    scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff()
    scsi: ufs-pci: Fix recovery from hibernate exit errors for Intel controllers
    scsi: ufs-pci: Enable UFSHCD_CAP_RPM_AUTOSUSPEND for Intel controllers
    scsi: block: Introduce BLK_MQ_REQ_PM
    scsi: ide: Do not set the RQF_PREEMPT flag for sense requests
    scsi: ide: Mark power management requests with RQF_PM instead of RQF_PREEMPT
    scsi: scsi_transport_spi: Set RQF_PM for domain validation commands
    scsi: core: Only process PM requests if rpm_status != RPM_ACTIVE
    local64.h: make mandatory
    lib/genalloc: fix the overflow when size is too big
    depmod: handle the case of /sbin/depmod without /sbin in PATH
    scsi: ufs: Clear UAC for FFU and RPMB LUNs
    kbuild: don't hardcode depmod path
    Bluetooth: revert: hci_h5: close serdev device and free hu in h5_close
    scsi: block: Remove RQF_PREEMPT and BLK_MQ_REQ_PREEMPT
    scsi: block: Do not accept any requests while suspended
    crypto: ecdh - avoid buffer overflow in ecdh_set_secret()
    crypto: asym_tpm: correct zero out potential secrets
    powerpc: Handle .text.{hot,unlikely}.* in linker script
    Staging: comedi: Return -EFAULT if copy_to_user() fails
    staging: mt7621-dma: Fix a resource leak in an error handling path
    usb: gadget: enable super speed plus
    USB: cdc-acm: blacklist another IR Droid device
    USB: cdc-wdm: Fix use after free in service_outstanding_interrupt().
    usb: typec: intel_pmc_mux: Configure HPD first for HPD+IRQ request
    usb: dwc3: meson-g12a: disable clk on error handling path in probe
    usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
    usb: dwc3: gadget: Clear wait flag on dequeue
    usb: dwc3: ulpi: Use VStsDone to detect PHY regs access completion
    usb: dwc3: ulpi: Replace CPU-based busyloop with Protocol-based one
    usb: dwc3: ulpi: Fix USB2.0 HS/FS/LS PHY suspend regression
    usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data()
    USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set
    usb: usbip: vhci_hcd: protect shift size
    usb: uas: Add PNY USB Portable SSD to unusual_uas
    USB: serial: iuu_phoenix: fix DMA from stack
    USB: serial: option: add LongSung M5710 module support
    USB: serial: option: add Quectel EM160R-GL
    USB: yurex: fix control-URB timeout handling
    USB: usblp: fix DMA to stack
    ALSA: usb-audio: Fix UBSAN warnings for MIDI jacks
    usb: gadget: select CONFIG_CRC32
    USB: Gadget: dummy-hcd: Fix shift-out-of-bounds bug
    usb: gadget: f_uac2: reset wMaxPacketSize
    usb: gadget: function: printer: Fix a memory leak for interface descriptor
    usb: gadget: u_ether: Fix MTU size mismatch with RX packet size
    USB: gadget: legacy: fix return error code in acm_ms_bind()
    usb: gadget: Fix spinlock lockup on usb_function_deactivate
    usb: gadget: configfs: Preserve function ordering after bind failure
    usb: gadget: configfs: Fix use-after-free issue with udc_name
    USB: serial: keyspan_pda: remove unused variable
    hwmon: (amd_energy) fix allocation of hwmon_channel_info config
    mm: make wait_on_page_writeback() wait for multiple pending writebacks
    x86/mm: Fix leak of pmd ptlock
    KVM: x86/mmu: Use -1 to flag an undefined spte in get_mmio_spte()
    KVM: x86/mmu: Get root level from walkers when retrieving MMIO SPTE
    kvm: check tlbs_dirty directly
    KVM: x86/mmu: Ensure TDP MMU roots are freed after yield
    x86/resctrl: Use an IPI instead of task_work_add() to update PQR_ASSOC MSR
    x86/resctrl: Don't move a task to the same resource group
    blk-iocost: fix NULL iocg deref from racing against initialization
    ALSA: hda/via: Fix runtime PM for Clevo W35xSS
    ALSA: hda/conexant: add a new hda codec CX11970
    ALSA: hda/realtek - Fix speaker volume control on Lenovo C940
    ALSA: hda/realtek: Add mute LED quirk for more HP laptops
    ALSA: hda/realtek: Enable mute and micmute LED on HP EliteBook 850 G7
    ALSA: hda/realtek: Add two "Intel Reference board" SSID in the ALC256.
    iommu/vt-d: Move intel_iommu info from struct intel_svm to struct intel_svm_dev
    btrfs: qgroup: don't try to wait flushing if we're already holding a transaction
    btrfs: send: fix wrong file path when there is an inode with a pending rmdir
    Revert "device property: Keep secondary firmware node secondary by type"
    dmabuf: fix use-after-free of dmabuf's file->f_inode
    arm64: link with -z norelro for LLD or aarch64-elf
    drm/i915: clear the shadow batch
    drm/i915: clear the gpu reloc batch
    bcache: fix typo from SUUP to SUPP in features.h
    bcache: check unsupported feature sets for bcache register
    bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large bucket
    net/mlx5e: Fix SWP offsets when vlan inserted by driver
    ARM: dts: OMAP3: disable AES on N950/N9
    netfilter: x_tables: Update remaining dereference to RCU
    netfilter: ipset: fix shift-out-of-bounds in htable_bits()
    netfilter: xt_RATEEST: reject non-null terminated string from userspace
    netfilter: nft_dynset: report EOPNOTSUPP on missing set feature
    dmaengine: idxd: off by one in cleanup code
    x86/mtrr: Correct the range check before performing MTRR type lookups
    KVM: x86: fix shift out of bounds reported by UBSAN
    xsk: Fix memory leak for failed bind
    rtlwifi: rise completion at the last step of firmware callback
    scsi: target: Fix XCOPY NAA identifier lookup
    Linux 5.10.7

    Signed-off-by: Greg Kroah-Hartman
    Change-Id: I1a7c195af35831fe362b027fe013c0c7e4dc20ea

    Greg Kroah-Hartman
     
  • Changes in 5.10.6
    Revert "drm/amd/display: Fix memory leaks in S3 resume"
    Revert "mtd: spinand: Fix OOB read"
    rtc: pcf2127: move watchdog initialisation to a separate function
    rtc: pcf2127: only use watchdog when explicitly available
    dt-bindings: rtc: add reset-source property
    kdev_t: always inline major/minor helper functions
    Bluetooth: Fix attempting to set RPA timeout when unsupported
    ALSA: hda/realtek - Modify Dell platform name
    ALSA: hda/hdmi: Fix incorrect mutex unlock in silent_stream_disable()
    drm/i915/tgl: Fix Combo PHY DPLL fractional divider for 38.4MHz ref clock
    scsi: ufs: Allow an error return value from ->device_reset()
    scsi: ufs: Re-enable WriteBooster after device reset
    RDMA/core: remove use of dma_virt_ops
    RDMA/siw,rxe: Make emulated devices virtual in the device tree
    fuse: fix bad inode
    perf: Break deadlock involving exec_update_mutex
    rwsem: Implement down_read_killable_nested
    rwsem: Implement down_read_interruptible
    exec: Transform exec_update_mutex into a rw_semaphore
    mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start
    Linux 5.10.6

    Signed-off-by: Greg Kroah-Hartman
    Change-Id: Id4c57a151a1e8f2162163d2337b6055f04edbe9b

    Greg Kroah-Hartman
     
  • Fix an issue for non-GKI builds found by the 0-day test bot:

    kernel/sched/fair.c: In function 'select_task_rq_fair':
    >> kernel/sched/fair.c:6766:6: error: implicit declaration of function
    'trace_android_rvh_select_task_rq_fair_enabled';
    did you mean 'trace_android_rvh_select_task_rq_fair'?
    6766 | if (trace_android_rvh_select_task_rq_fair_enabled())
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | trace_android_rvh_select_task_rq_fair
    cc1: some warnings being treated as errors

    Reported-by: kernel test robot
    Fixes: c7ba09ce6aa5 ("ANDROID: sched/fair: Sync task util for strf hook")
    Signed-off-by: Todd Kjos
    Change-Id: I1b15b9ada83dc5b2678cef3910a7aedc0d19f174

    Todd Kjos
     
  • Export cpuidle_driver_state_disabled() so that CPU idle states may be
    disabled at runtime for debugging CPU and cluster idle states.

    Bug: 175718935
    Signed-off-by: Lina Iyer
    Change-Id: Id9038074d64fb6c0444d9aca68420414c3223e93

    Lina Iyer
     
  • Modules with a large number of compilation units may be
    exceeding AR and LD command argument list. Handle this gracefully by
    writing the long argument list in a file. The command line options
    read from file are inserted in place of the original @file option.

    The usage is well documented at
    https://www.gnu.org/software/make/manual/html_node/File-Function.html

    Bug: 175420573
    Change-Id: I3f9b8b9c59b9ba0c01ddd00d39fc3bbc62fda832
    Signed-off-by: Mahesh Kumar Kalikot Veetil
    Signed-off-by: Jeff Johnson

    Mahesh Kumar Kalikot Veetil
     
  • Modules with a large number of compilation units can exceed execv
    argument list resulting in E2BIG (Argument list too long) error.

    Fix this by replacing shell 'echo > file' into a more native
    $(file op filename[,text]) option.

    Bug: 175420575
    Change-Id: I9bc495482f16f2c9b4e05a4cb5b2283ff0c0439d
    Signed-off-by: Mahesh Kumar Kalikot Veetil
    Signed-off-by: Jeff Johnson

    Mahesh Kumar Kalikot Veetil
     
  • Kernel stack violation when getting unit_descriptor/wb_buf_alloc_units from
    rpmb lun. The reason is the unit descriptor length is different per LU.

    The lengh of Normal LU is 45, while the one of rpmb LU is 35.

    int ufshcd_read_desc_param(struct ufs_hba *hba, ...)
    {
    param_offset=41;
    param_size=4;
    buff_len=45;
    ...
    buff_len=35 by rpmb LU;

    if (is_kmalloc) {
    /* Make sure we don't copy more data than available */
    if (param_offset + param_size > buff_len)
    param_size = buff_len - param_offset;
    --> param_size = 250;
    memcpy(param_read_buf, &desc_buf[param_offset], param_size);
    --> memcpy(param_read_buf, desc_buf+41, 250);

    [ 141.868974][ T9174] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: wb_buf_alloc_units_show+0x11c/0x11c
    }
    }

    Bug: 174701661
    Link: https://lore.kernel.org/linux-scsi/20210111095927.1830311-1-jaegeuk@kernel.org/
    Reviewed-by: Avri Altman
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Jaegeuk Kim
    Change-Id: I25205d465daa25b4bd330876ad05fcfd01195a56

    Jaegeuk Kim
     
  • When non-fatal error like line-reset happens, ufshcd_err_handler() starts
    to abort tasks by ufshcd_try_to_abort_task(). When it tries to issue a task
    management request, we hit two warnings:

    WARNING: CPU: 7 PID: 7 at block/blk-core.c:630 blk_get_request+0x68/0x70
    WARNING: CPU: 4 PID: 157 at block/blk-mq-tag.c:82 blk_mq_get_tag+0x438/0x46c

    After fixing the above warnings we hit another tm_cmd timeout which may be
    caused by unstable controller state:

    __ufshcd_issue_tm_cmd: task management cmd 0x80 timed-out

    Then, ufshcd_err_handler() enters full reset, and kernel gets stuck. It
    turned out ufshcd_print_trs() printed too many messages on console which
    requires CPU locks. Likewise hba->silence_err_logs, we need to avoid too
    verbose messages. This is actually not an error case.

    Bug: 175693074
    Bug: 175170490
    (cherry picked from commit eeb1b55b6e25c5f7265ff45cd050f3bc2cc423a4 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git fixes)
    Link: https://lore.kernel.org/r/20210107185316.788815-3-jaegeuk@kernel.org
    Fixes: 69a6c269c097 ("scsi: ufs: Use blk_{get,put}_request() to allocate and free TMFs")
    Reviewed-by: Can Guo
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Martin K. Petersen
    Change-Id: Ie05496f7a5ef1192d19ee08f9f7f91ee8ebb31cd
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • When gate_work/ungate_work experience an error during hibern8_enter or exit
    we can livelock:

    ufshcd_err_handler()
    ufshcd_scsi_block_requests()
    ufshcd_reset_and_restore()
    ufshcd_clear_ua_wluns() -> stuck
    ufshcd_scsi_unblock_requests()

    In order to avoid this, ufshcd_clear_ua_wluns() can be called per recovery
    flows such as suspend/resume, link_recovery, and error_handler.

    Bug: 175391270
    (cherry picked from commit 4ee7ee530bc2bae6268247988d86722c65d02a37 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git fixes)
    Link: https://lore.kernel.org/r/20210107185316.788815-2-jaegeuk@kernel.org
    Fixes: b56c9e4cdf09 ("FROMLIST: scsi: ufs: fix livelock of ufshcd_clear_ua_wluns")
    Reviewed-by: Can Guo
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Martin K. Petersen
    Change-Id: I16f41f552a0e4d6c93592b73cf7489fa1197a987
    Signed-off-by: Jaegeuk Kim

    Jaegeuk Kim
     
  • Export show_regs for vendor module usage to print cpu back trace
    from trace_android_vh_ipi_stop vendor hook.

    Bug: 177348820
    Change-Id: Idcbe887dfc02626d4af1a4cb53dafe3d5a2ba1dd
    Signed-off-by: Prasad Sodagudi

    Prasad Sodagudi
     
  • UCSI already conveys the information about a port's connection
    status, whether it is operating in UFP or DFP mode, and whether the
    partner supports USB data or not. This information can be used to
    notify a dual-role controller to start up its host or peripheral
    mode accordingly. Add optional support for this by querying each
    port's fwnode to look for an associated USB role switch device.
    If present, call usb_role_switch_set() with the determined data
    role upon Connect Change or Connector Partner Change updates.

    Bug: 177215430
    (cherry picked from commit 89795852c9c46b9b0701f7376d30a1c5ab4d146c
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing)
    Change-Id: I83106abd1c5122d9ca89e5854e82aa988f5b528f
    Reviewed-by: Heikki Krogerus
    Signed-off-by: Mayank Rana
    Signed-off-by: Jack Pham
    Link: https://lore.kernel.org/r/20210111215520.18476-1-jackp@codeaurora.org
    Signed-off-by: Greg Kroah-Hartman

    Mayank Rana
     
  • Export vmalloc_nr_pages which is used as part
    of meminfo collection from minidump module.

    Bug: 177031593
    Change-Id: I4c80fe2a0712658ec46b49064fda670da84b3732
    Signed-off-by: Vijayanand Jitta

    Vijayanand Jitta
     
  • Export symbols needed to implement vendor scheduler value-adds to modify
    sched features.

    Bug: 177050087
    Change-Id: Ibe14d2019403be68b7ceeee47425b2473ccb51fe
    Signed-off-by: Shaleen Agrawal

    Shaleen Agrawal
     
  • When used for qos or other reasons, wake up idle
    cpus will wake cpus en-mass. Cpus that are paused
    should not be woken up like this.

    Update to use active_mask, so that paused cpus are
    ignored for general cpu wakeup operations.

    Bug: 161210528
    Change-Id: I10721e75497a8902f8ec998ded4e2eb094770f38
    Signed-off-by: Stephen Dickey

    Stephen Dickey
     
  • With the introduction of pause, irqs should avoid
    paused cpus. Previously, when userspace set the
    irq affinity, it was only filtered toward online cpus.
    A cpu can be paused but online, and irqs should avoid.

    Check the cpu_active_mask instead of the online mask
    when writing the irq affinity, such that the subset
    of cpus allowed doesn't include inactive cpus.

    Bug: 161210528
    Change-Id: I359a452cc97ad58ad85e9613a29d144ffcd51567
    Signed-off-by: Stephen Dickey

    Stephen Dickey
     
  • Users can initiate resets to specific SCSI device/target/host through
    IOCTL. When this happens, the SCSI cmd passed to eh_device/target/host
    _reset_handler() callbacks is initialized with a request whose tag is -1.
    In this case it is not right for eh_device_reset_handler() callback to
    count on the LUN get from hba->lrb[-1]. Fix it by getting LUN from the SCSI
    device associated with the SCSI cmd.

    Link: https://lore.kernel.org/r/1609157080-26283-1-git-send-email-cang@codeaurora.org
    Reviewed-by: Avri Altman
    Reviewed-by: Stanley Chu
    Signed-off-by: Can Guo
    Signed-off-by: Martin K. Petersen

    Bug: 177042238
    (cherry picked from commit 35fc4cd34426c242ab015ef280853b7bff101f48
    git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git 5.11/scsi-fixes)
    Change-Id: I7bd7602581b97f76442e179b5264ee2891d923a9
    Signed-off-by: Can Guo

    Can Guo
     
  • Reducing the section size helps reduce wastage of reserved memory
    for huge memory holes in sparsemem model. But having a much smaller
    section size bits could break PMD mappings for vmemmap and wouldn't
    accomodate the highest order page for certain page size granule configs.
    It is determined that SECTION_SIZE_BITS of 27 (128MB) could be ideal
    default value for 4K_PAGES that gives least section size without breaking
    PMD based vmemmap mappings. For simplicity, 16K_PAGES could follow the
    same as 4K_PAGES. And the least SECTION_SIZE_BITS for 64K_PAGES is 29
    that could accomodate MAX_ORDER.

    Signed-off-by: Sudarshan Rajagopalan
    Suggested-by: David Hildenbrand
    Cc: Will Deacon
    Cc: Anshuman Khandual
    Cc: Mike Rapoport
    Cc: Mark Rutland
    Cc: Suren Baghdasaryan

    Link: https://lore.kernel.org/lkml/15cf9a2359197fee0168f820c5c904650d07939e.1610146597.git.sudaraja@codeaurora.org/
    Bug: 175715646
    Signed-off-by: Suren Baghdasaryan
    Change-Id: Iecc0369c595bcabe01182a85a5464c87df36c217

    Sudarshan Rajagopalan
     
  • Bing Song noticed the CMA heap was leaking memory due to a flub
    I made in commit a5d2d29e24be ("dma-buf: heaps: Move heap-helper
    logic into the cma_heap implementation"), and provided this fix
    which ensures the pagelist is also freed on release.

    Cc: Bing Song
    Cc: Sumit Semwal
    Cc: Liam Mark
    Cc: Laura Abbott
    Cc: Brian Starkey
    Cc: Hridya Valsaraju
    Cc: Suren Baghdasaryan
    Cc: Sandeep Patil
    Cc: Daniel Mentz
    Cc: Chris Goldsworthy
    Cc: Ørjan Eide
    Cc: Robin Murphy
    Cc: Ezequiel Garcia
    Cc: Simon Ser
    Cc: James Jones
    Cc: linux-media@vger.kernel.org
    Cc: dri-devel@lists.freedesktop.org
    Reported-by: Bing Song
    Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
    Signed-off-by: John Stultz
    Signed-off-by: Sumit Semwal
    Link: https://patchwork.freedesktop.org/patch/msgid/20210107202616.75170-1-john.stultz@linaro.org
    (cherry picked from commit a0adc8eabb402cfb9f32d15edd9f65f65e35cdce
    git: //anongit.freedesktop.org/drm/drm-misc drm-misc-fixes)
    Signed-off-by: John Stultz
    Change-Id: Ic532b71ad58699db1b11870eb0027966d93acac1

    John Stultz
     
  • Export task_may_not_preempt.

    Bug: 174030348
    Signed-off-by: Rick Yiu
    Change-Id: I71b50f876306811f008414096043b883dc43b4d5
    Signed-off-by: Will McVicker

    Rick Yiu
     
  • Export cpupri_find_fitness.

    Bug: 174030348
    Signed-off-by: Rick Yiu
    Change-Id: I47b2af2395bc7a618eb4f4af4469cc2422e25446
    Signed-off-by: Will McVicker

    Rick Yiu
     
  • Since the sugov traces were added in kernel/sched/cpufreq_schedutil.c,
    move it from power.h to sched.h.
    And move the tracepoint to where the change happens.

    Bug: 174488007
    Test: build pass and boot to home
    Signed-off-by: Jimmy Shiu
    Change-Id: Ibe18f04773c28be84db3619b1a4253bf08f0e289
    Signed-off-by: Will McVicker

    Jimmy Shiu
     
  • ufshcd.c:8144:1: warning: unused label 'out' [-Wunused-label]

    Bug: 175212278
    Signed-off-by: Petri Gynther
    Change-Id: I185958877f94f7cc18ccd3da476f4659665a6cb0
    Signed-off-by: Will McVicker

    Petri Gynther
     
  • During init, vbus_vsafe0v does not get updated till the first
    connect as a sink. This causes TCPM to be stuck in SRC_ATTACH_WAIT
    state while booting with a sink (For instance: a headset) connected.

    [ 1.429168] Start toggling
    [ 1.439907] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
    [ 1.445242] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
    [ 53.358528] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected]
    [ 53.358564] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]

    Fix this by updating vbus_vsafe0v based on vbus_present status
    on boot.

    Reviewed-by: Heikki Krogerus
    Signed-off-by: Badhri Jagan Sridharan
    Link: https://lore.kernel.org/r/20201211071911.2205197-1-badhri@google.com
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 3db4c21c0f71f7a51ce5c50f0d4d3742c9ec4a65)
    Signed-off-by: Will McVicker
    Change-Id: I2760d68069088754546f462caa24d7c73f7a533f

    Badhri Jagan Sridharan
     
  • debugfs nodes were created in genpd_debug_init alled in late_initcall
    preventing power domains registered though loadable modules to have
    a debugfs entry.

    Create/remove debugfs nodes when the power domain is added/removed
    to/from the internal gpd_list.

    Signed-off-by: Thierry Strudel
    Reviewed-by: Greg Kroah-Hartman
    Reviewed-by: Ulf Hansson
    Signed-off-by: Rafael J. Wysocki
    (cherry picked from commit 718072ceb211833f3c71724f49d733d636067191)
    Signed-off-by: Will McVicker
    Change-Id: Ibde0adddc5fb50a8c8e1a16d66ee0f6b58330a96

    Thierry Strudel
     
  • There is currently support for non-coherent devices to use the system
    cache for their buffers by mapping the buffer with the IOMMU_SYS_CACHE_ONLY
    protection flag. The IOMMU_SYS_CACHE_ONLY_FLAG maps the buffers with
    a RW-allocate cache policy by default.

    There are usecases that do not benefit from having a RW allocate policy,
    but instead benefit from a no write allocate (NWA) policy, while using
    the system cache.

    Thus, add support for mapping memory with the attributes required
    for it to be cached in the system cached, with a NWA policy:

    MAIR: 0xe4: inner non-cacheable, outer write-back read allocate.

    Bug: 176778547
    Change-Id: I6d2700a19f0f2e61905b3d36b15f60db3ae59b73
    Signed-off-by: Isaac J. Manjarres

    Isaac J. Manjarres
     
  • Tested-by: Jon Hunter
    Tested-by: Guenter Roeck
    Tested-by: Shuah Khan
    Tested-by: Linux Kernel Functional Testing
    Link: https://lore.kernel.org/r/20210111161510.602817176@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • commit 2896c93811e39d63a4d9b63ccf12a8fbc226e5e4 upstream.

    When attempting to match EXTENDED COPY CSCD descriptors with corresponding
    se_devices, target_xcopy_locate_se_dev_e4() currently iterates over LIO's
    global devices list which includes all configured backstores.

    This change ensures that only initiator-accessible backstores are
    considered during CSCD descriptor lookup, according to the session's
    se_node_acl LUN list.

    To avoid LUN removal race conditions, device pinning is changed from being
    configfs based to instead using the se_node_acl lun_ref.

    Reference: CVE-2020-28374
    Fixes: cbf031f425fd ("target: Add support for EXTENDED_COPY copy offload emulation")
    Reviewed-by: Lee Duncan
    Signed-off-by: David Disseldorp
    Signed-off-by: Mike Christie
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Greg Kroah-Hartman

    David Disseldorp
     
  • commit 4dfde294b9792dcf8615b55c58f093d544f472f0 upstream.

    request_firmware_nowait() which schedules another work is used to load
    firmware when USB is probing. If USB is unplugged before running the
    firmware work, it goes disconnect ops, and then causes use-after-free.
    Though we wait for completion of firmware work before freeing the hw,
    firmware callback rises completion too early. So I move it to the
    last step.

    usb 5-1: Direct firmware load for rtlwifi/rtl8192cufw.bin failed with error -2
    rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
    rtlwifi: Selected firmware is not available
    ==================================================================
    BUG: KASAN: use-after-free in rtl_fw_do_work.cold+0x68/0x6a drivers/net/wireless/realtek/rtlwifi/core.c:93
    Write of size 4 at addr ffff8881454cff50 by task kworker/0:6/7379

    CPU: 0 PID: 7379 Comm: kworker/0:6 Not tainted 5.10.0-rc7-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Workqueue: events request_firmware_work_func
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x107/0x163 lib/dump_stack.c:118
    print_address_description.constprop.0.cold+0xae/0x4c8 mm/kasan/report.c:385
    __kasan_report mm/kasan/report.c:545 [inline]
    kasan_report.cold+0x1f/0x37 mm/kasan/report.c:562
    rtl_fw_do_work.cold+0x68/0x6a drivers/net/wireless/realtek/rtlwifi/core.c:93
    request_firmware_work_func+0x12c/0x230 drivers/base/firmware_loader/main.c:1079
    process_one_work+0x933/0x1520 kernel/workqueue.c:2272
    worker_thread+0x64c/0x1120 kernel/workqueue.c:2418
    kthread+0x38c/0x460 kernel/kthread.c:292
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

    The buggy address belongs to the page:
    page:00000000f54435b3 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1454cf
    flags: 0x200000000000000()
    raw: 0200000000000000 0000000000000000 ffffea00051533c8 0000000000000000
    raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
    ffff8881454cfe00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    ffff8881454cfe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    >ffff8881454cff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    ^
    ffff8881454cff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    ffff8881454d0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

    Reported-by: syzbot+65be4277f3c489293939@syzkaller.appspotmail.com
    Signed-off-by: Ping-Ke Shih
    Signed-off-by: Kalle Valo
    Link: https://lore.kernel.org/r/20201214053106.7748-1-pkshih@realtek.com
    Signed-off-by: Greg Kroah-Hartman

    Ping-Ke Shih
     
  • commit 8bee683384087a6275c9183a483435225f7bb209 upstream.

    Fix a possible memory leak when a bind of an AF_XDP socket fails. When
    the fill and completion rings are created, they are tied to the
    socket. But when the buffer pool is later created at bind time, the
    ownership of these two rings are transferred to the buffer pool as
    they might be shared between sockets (and the buffer pool cannot be
    created until we know what we are binding to). So, before the buffer
    pool is created, these two rings are cleaned up with the socket, and
    after they have been transferred they are cleaned up together with
    the buffer pool.

    The problem is that ownership was transferred before it was absolutely
    certain that the buffer pool could be created and initialized
    correctly and when one of these errors occurred, the fill and
    completion rings did neither belong to the socket nor the pool and
    where therefore leaked. Solve this by moving the ownership transfer
    to the point where the buffer pool has been completely set up and
    there is no way it can fail.

    Fixes: 7361f9c3d719 ("xsk: Move fill and completion rings to buffer pool")
    Reported-by: syzbot+cfa88ddd0655afa88763@syzkaller.appspotmail.com
    Signed-off-by: Magnus Karlsson
    Signed-off-by: Daniel Borkmann
    Acked-by: Björn Töpel
    Link: https://lore.kernel.org/bpf/20201214085127.3960-1-magnus.karlsson@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Magnus Karlsson
     
  • commit 2f80d502d627f30257ba7e3655e71c373b7d1a5a upstream.

    Since we know that e >= s, we can reassociate the left shift,
    changing the shifted number from 1 to 2 in exchange for
    decreasing the right hand side by 1.

    Reported-by: syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.com
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    Paolo Bonzini