1. 10 May, 2020 22 commits
  2. 06 May, 2020 18 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.19.121 · 84920cc7
      Greg Kroah-Hartman authored
      84920cc7
    • Martin Blumenstingl's avatar
      mmc: meson-mx-sdio: remove the broken ->card_busy() op · 144857ac
      Martin Blumenstingl authored
      commit ddca1092 upstream.
      
      The recent commit 0d84c3e6 ("mmc: core: Convert to
      mmc_poll_for_busy() for erase/trim/discard") makes use of the
      ->card_busy() op for SD cards. This uncovered that the ->card_busy() op
      in the Meson SDIO driver was never working right:
      while polling the busy status with ->card_busy()
      meson_mx_mmc_card_busy() reads only one of the two MESON_MX_SDIO_IRQC
      register values 0x1f001f10 or 0x1f003f10. This translates to "three out
      of four DAT lines are HIGH" and "all four DAT lines are HIGH", which
      is interpreted as "the card is busy".
      
      It turns out that no situation can be observed where all four DAT lines
      are LOW, meaning the card is not busy anymore. Upon further research the
      3.10 vendor driver for this controller does not implement the
      ->card_busy() op.
      
      Remove the ->card_busy() op from the meson-mx-sdio driver since it is
      not working. At the time of writing this patch it is not clear what's
      needed to make the ->card_busy() implementation work with this specific
      controller hardware. For all use-cases which have previously worked the
      MMC_CAP_WAIT_WHILE_BUSY flag is now taking over, even if we don't have
      a ->card_busy() op anymore.
      
      Fixes: ed80a13b ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200416183513.993763-3-martin.blumenstingl@googlemail.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      144857ac
    • Martin Blumenstingl's avatar
      mmc: meson-mx-sdio: Set MMC_CAP_WAIT_WHILE_BUSY · 920d9c11
      Martin Blumenstingl authored
      commit e53b868b upstream.
      
      The Meson SDIO controller uses the DAT0 lane for hardware busy
      detection. Set MMC_CAP_WAIT_WHILE_BUSY accordingly. This fixes
      the following error observed with Linux 5.7 (pre-rc-1):
        mmc1: Card stuck being busy! __mmc_poll_for_busy
        blk_update_request: I/O error, dev mmcblk1, sector 17111080 op
         0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0
      
      Fixes: ed80a13b ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200416183513.993763-2-martin.blumenstingl@googlemail.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      920d9c11
    • Veerabhadrarao Badiganti's avatar
      mmc: sdhci-msm: Enable host capabilities pertains to R1b response · 2c1b0513
      Veerabhadrarao Badiganti authored
      commit 9d8cb586 upstream.
      
      MSM sd host controller is capable of HW busy detection of device busy
      signaling over DAT0 line. And it requires the R1B response for commands
      that have this response associated with them.
      
      So set the below two host capabilities for qcom SDHC.
       - MMC_CAP_WAIT_WHILE_BUSY
       - MMC_CAP_NEED_RSP_BUSY
      
      Recent development of the mmc core in regards to this, revealed this as
      being a potential bug, hence the stable tag.
      
      Cc: <stable@vger.kernel.org> # v4.19+
      Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/1587363626-20413-2-git-send-email-vbadigan@codeaurora.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c1b0513
    • Adrian Hunter's avatar
      mmc: sdhci-pci: Fix eMMC driver strength for BYT-based controllers · a1acd57f
      Adrian Hunter authored
      commit 1a8eb6b3 upstream.
      
      BIOS writers have begun the practice of setting 40 ohm eMMC driver strength
      even though the eMMC may not support it, on the assumption that the kernel
      will validate the value against the eMMC (Extended CSD DRIVER_STRENGTH
      [offset 197]) and revert to the default 50 ohm value if 40 ohm is invalid.
      
      This is done to avoid changing the value for different boards.
      
      Putting aside the merits of this approach, it is clear the eMMC's mask
      of supported driver strengths is more reliable than the value provided
      by BIOS. Add validation accordingly.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Fixes: 51ced59c ("mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200422111629.4899-1-adrian.hunter@intel.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a1acd57f
    • Marek Behún's avatar
      mmc: sdhci-xenon: fix annoying 1.8V regulator warning · 82e242c1
      Marek Behún authored
      commit bb32e198 upstream.
      
      For some reason the Host Control2 register of the Xenon SDHCI controller
      sometimes reports the bit representing 1.8V signaling as 0 when read
      after it was written as 1. Subsequent read reports 1.
      
      This causes the sdhci_start_signal_voltage_switch function to report
        1.8V regulator output did not become stable
      
      When CONFIG_PM is enabled, the host is suspended and resumend many
      times, and in each resume the switch to 1.8V is called, and so the
      kernel log reports this message annoyingly often.
      
      Do an empty read of the Host Control2 register in Xenon's
      .voltage_switch method to circumvent this.
      
      This patch fixes this particular problem on Turris MOX.
      Signed-off-by: default avatarMarek Behún <marek.behun@nic.cz>
      Fixes: 8d876bf4 ("mmc: sdhci-xenon: wait 5ms after set 1.8V...")
      Cc: stable@vger.kernel.org # v4.16+
      Link: https://lore.kernel.org/r/20200420080444.25242-1-marek.behun@nic.czSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82e242c1
    • Douglas Anderson's avatar
      mmc: cqhci: Avoid false "cqhci: CQE stuck on" by not open-coding timeout loop · dbbee5a1
      Douglas Anderson authored
      commit b1ac62a7 upstream.
      
      Open-coding a timeout loop invariably leads to errors with handling
      the timeout properly in one corner case or another.  In the case of
      cqhci we might report "CQE stuck on" even if it wasn't stuck on.
      You'd just need this sequence of events to happen in cqhci_off():
      
      1. Call ktime_get().
      2. Something happens to interrupt the CPU for > 100 us (context switch
         or interrupt).
      3. Check time and; set "timed_out" to true since > 100 us.
      4. Read CQHCI_CTL.
      5. Both "reg & CQHCI_HALT" and "timed_out" are true, so break.
      6. Since "timed_out" is true, falsely print the error message.
      
      Rather than fixing the polling loop, use readx_poll_timeout() like
      many people do.  This has been time tested to handle the corner cases.
      
      Fixes: a4080225 ("mmc: cqhci: support for command queue enabled host")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200413162717.1.Idece266f5c8793193b57a1ddb1066d030c6af8e0@changeidSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dbbee5a1
    • Qu Wenruo's avatar
      btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info · 57be052c
      Qu Wenruo authored
      commit fcc99734 upstream.
      
      [BUG]
      One run of btrfs/063 triggered the following lockdep warning:
        ============================================
        WARNING: possible recursive locking detected
        5.6.0-rc7-custom+ #48 Not tainted
        --------------------------------------------
        kworker/u24:0/7 is trying to acquire lock:
        ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
      
        but task is already holding lock:
        ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
      
        other info that might help us debug this:
         Possible unsafe locking scenario:
      
               CPU0
               ----
          lock(sb_internal#2);
          lock(sb_internal#2);
      
         *** DEADLOCK ***
      
         May be due to missing lock nesting notation
      
        4 locks held by kworker/u24:0/7:
         #0: ffff88817b495948 ((wq_completion)btrfs-endio-write){+.+.}, at: process_one_work+0x557/0xb80
         #1: ffff888189ea7db8 ((work_completion)(&work->normal_work)){+.+.}, at: process_one_work+0x557/0xb80
         #2: ffff88817d3a46e0 (sb_internal#2){.+.+}, at: start_transaction+0x66c/0x890 [btrfs]
         #3: ffff888174ca4da8 (&fs_info->reloc_mutex){+.+.}, at: btrfs_record_root_in_trans+0x83/0xd0 [btrfs]
      
        stack backtrace:
        CPU: 0 PID: 7 Comm: kworker/u24:0 Not tainted 5.6.0-rc7-custom+ #48
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
        Workqueue: btrfs-endio-write btrfs_work_helper [btrfs]
        Call Trace:
         dump_stack+0xc2/0x11a
         __lock_acquire.cold+0xce/0x214
         lock_acquire+0xe6/0x210
         __sb_start_write+0x14e/0x290
         start_transaction+0x66c/0x890 [btrfs]
         btrfs_join_transaction+0x1d/0x20 [btrfs]
         find_free_extent+0x1504/0x1a50 [btrfs]
         btrfs_reserve_extent+0xd5/0x1f0 [btrfs]
         btrfs_alloc_tree_block+0x1ac/0x570 [btrfs]
         btrfs_copy_root+0x213/0x580 [btrfs]
         create_reloc_root+0x3bd/0x470 [btrfs]
         btrfs_init_reloc_root+0x2d2/0x310 [btrfs]
         record_root_in_trans+0x191/0x1d0 [btrfs]
         btrfs_record_root_in_trans+0x90/0xd0 [btrfs]
         start_transaction+0x16e/0x890 [btrfs]
         btrfs_join_transaction+0x1d/0x20 [btrfs]
         btrfs_finish_ordered_io+0x55d/0xcd0 [btrfs]
         finish_ordered_fn+0x15/0x20 [btrfs]
         btrfs_work_helper+0x116/0x9a0 [btrfs]
         process_one_work+0x632/0xb80
         worker_thread+0x80/0x690
         kthread+0x1a3/0x1f0
         ret_from_fork+0x27/0x50
      
      It's pretty hard to reproduce, only one hit so far.
      
      [CAUSE]
      This is because we're calling btrfs_join_transaction() without re-using
      the current running one:
      
      btrfs_finish_ordered_io()
      |- btrfs_join_transaction()		<<< Call #1
         |- btrfs_record_root_in_trans()
            |- btrfs_reserve_extent()
      	 |- btrfs_join_transaction()	<<< Call #2
      
      Normally such btrfs_join_transaction() call should re-use the existing
      one, without trying to re-start a transaction.
      
      But the problem is, in btrfs_join_transaction() call #1, we call
      btrfs_record_root_in_trans() before initializing current::journal_info.
      
      And in btrfs_join_transaction() call #2, we're relying on
      current::journal_info to avoid such deadlock.
      
      [FIX]
      Call btrfs_record_root_in_trans() after we have initialized
      current::journal_info.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57be052c
    • Filipe Manana's avatar
      btrfs: fix partial loss of prealloc extent past i_size after fsync · 00043456
      Filipe Manana authored
      commit f135cea3 upstream.
      
      When we have an inode with a prealloc extent that starts at an offset
      lower than the i_size and there is another prealloc extent that starts at
      an offset beyond i_size, we can end up losing part of the first prealloc
      extent (the part that starts at i_size) and have an implicit hole if we
      fsync the file and then have a power failure.
      
      Consider the following example with comments explaining how and why it
      happens.
      
        $ mkfs.btrfs -f /dev/sdb
        $ mount /dev/sdb /mnt
      
        # Create our test file with 2 consecutive prealloc extents, each with a
        # size of 128Kb, and covering the range from 0 to 256Kb, with a file
        # size of 0.
        $ xfs_io -f -c "falloc -k 0 128K" /mnt/foo
        $ xfs_io -c "falloc -k 128K 128K" /mnt/foo
      
        # Fsync the file to record both extents in the log tree.
        $ xfs_io -c "fsync" /mnt/foo
      
        # Now do a redudant extent allocation for the range from 0 to 64Kb.
        # This will merely increase the file size from 0 to 64Kb. Instead we
        # could also do a truncate to set the file size to 64Kb.
        $ xfs_io -c "falloc 0 64K" /mnt/foo
      
        # Fsync the file, so we update the inode item in the log tree with the
        # new file size (64Kb). This also ends up setting the number of bytes
        # for the first prealloc extent to 64Kb. This is done by the truncation
        # at btrfs_log_prealloc_extents().
        # This means that if a power failure happens after this, a write into
        # the file range 64Kb to 128Kb will not use the prealloc extent and
        # will result in allocation of a new extent.
        $ xfs_io -c "fsync" /mnt/foo
      
        # Now set the file size to 256K with a truncate and then fsync the file.
        # Since no changes happened to the extents, the fsync only updates the
        # i_size in the inode item at the log tree. This results in an implicit
        # hole for the file range from 64Kb to 128Kb, something which fsck will
        # complain when not using the NO_HOLES feature if we replay the log
        # after a power failure.
        $ xfs_io -c "truncate 256K" -c "fsync" /mnt/foo
      
      So instead of always truncating the log to the inode's current i_size at
      btrfs_log_prealloc_extents(), check first if there's a prealloc extent
      that starts at an offset lower than the i_size and with a length that
      crosses the i_size - if there is one, just make sure we truncate to a
      size that corresponds to the end offset of that prealloc extent, so
      that we don't lose the part of that extent that starts at i_size if a
      power failure happens.
      
      A test case for fstests follows soon.
      
      Fixes: 31d11b83 ("Btrfs: fix duplicate extents after fsync of file with prealloc extents")
      CC: stable@vger.kernel.org # 4.14+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00043456
    • Paul Moore's avatar
      selinux: properly handle multiple messages in selinux_netlink_send() · 23075857
      Paul Moore authored
      commit fb739741 upstream.
      
      Fix the SELinux netlink_send hook to properly handle multiple netlink
      messages in a single sk_buff; each message is parsed and subject to
      SELinux access control.  Prior to this patch, SELinux only inspected
      the first message in the sk_buff.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: default avatarStephen Smalley <stephen.smalley.work@gmail.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23075857
    • Andy Shevchenko's avatar
      dmaengine: dmatest: Fix iteration non-stop logic · 87cb81e6
      Andy Shevchenko authored
      commit b9f96020 upstream.
      
      Under some circumstances, i.e. when test is still running and about to
      time out and user runs, for example,
      
      	grep -H . /sys/module/dmatest/parameters/*
      
      the iterations parameter is not respected and test is going on and on until
      user gives
      
      	echo 0 > /sys/module/dmatest/parameters/run
      
      This is not what expected.
      
      The history of this bug is interesting. I though that the commit
        2d88ce76 ("dmatest: add a 'wait' parameter")
      is a culprit, but looking closer to the code I think it simple revealed the
      broken logic from the day one, i.e. in the commit
        0a2ff57d ("dmaengine: dmatest: add a maximum number of test iterations")
      which adds iterations parameter.
      
      So, to the point, the conditional of checking the thread to be stopped being
      first part of conjunction logic prevents to check iterations. Thus, we have to
      always check both conditions to be able to stop after given iterations.
      
      Since it wasn't visible before second commit appeared, I add a respective
      Fixes tag.
      
      Fixes: 2d88ce76 ("dmatest: add a 'wait' parameter")
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Link: https://lore.kernel.org/r/20200424161147.16895-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87cb81e6
    • Andreas Gruenbacher's avatar
      nfs: Fix potential posix_acl refcnt leak in nfs3_set_acl · 7b4e9bfa
      Andreas Gruenbacher authored
      commit 7648f939 upstream.
      
      nfs3_set_acl keeps track of the acl it allocated locally to determine if an acl
      needs to be released at the end.  This results in a memory leak when the
      function allocates an acl as well as a default acl.  Fix by releasing acls
      that differ from the acl originally passed into nfs3_set_acl.
      
      Fixes: b7fa0554 ("[PATCH] NFS: Add support for NFSv3 ACLs")
      Reported-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b4e9bfa
    • Arnd Bergmann's avatar
      ALSA: opti9xx: shut up gcc-10 range warning · eadf95a6
      Arnd Bergmann authored
      commit 5ce00760 upstream.
      
      gcc-10 points out a few instances of suspicious integer arithmetic
      leading to value truncation:
      
      sound/isa/opti9xx/opti92x-ad1848.c: In function 'snd_opti9xx_configure':
      sound/isa/opti9xx/opti92x-ad1848.c:322:43: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_opti9xx_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow]
        322 |   (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
            |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      sound/isa/opti9xx/opti92x-ad1848.c:351:3: note: in expansion of macro 'snd_opti9xx_write_mask'
        351 |   snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
            |   ^~~~~~~~~~~~~~~~~~~~~~
      sound/isa/opti9xx/miro.c: In function 'snd_miro_configure':
      sound/isa/opti9xx/miro.c:873:40: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_miro_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow]
        873 |   (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask)))
            |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
      sound/isa/opti9xx/miro.c:1010:3: note: in expansion of macro 'snd_miro_write_mask'
       1010 |   snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
            |   ^~~~~~~~~~~~~~~~~~~
      
      These are all harmless here as only the low 8 bit are passed down
      anyway. Change the macros to inline functions to make the code
      more readable and also avoid the warning.
      
      Strictly speaking those functions also need locking to make the
      read/write pair atomic, but it seems unlikely that anyone would
      still run into that issue.
      
      Fixes: 1841f613 ("[ALSA] Add snd-miro driver")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20200429190216.85919-1-arnd@arndb.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eadf95a6
    • Suravee Suthikulpanit's avatar
      iommu/amd: Fix legacy interrupt remapping for x2APIC-enabled system · 4fc9c61f
      Suravee Suthikulpanit authored
      commit b74aa02d upstream.
      
      Currently, system fails to boot because the legacy interrupt remapping
      mode does not enable 128-bit IRTE (GA), which is required for x2APIC
      support.
      
      Fix by using AMD_IOMMU_GUEST_IR_LEGACY_GA mode when booting with
      kernel option amd_iommu_intr=legacy instead. The initialization
      logic will check GASup and automatically fallback to using
      AMD_IOMMU_GUEST_IR_LEGACY if GA mode is not supported.
      
      Fixes: 3928aa3f ("iommu/amd: Detect and enable guest vAPIC support")
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Link: https://lore.kernel.org/r/1587562202-14183-1-git-send-email-suravee.suthikulpanit@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fc9c61f
    • David Disseldorp's avatar
      scsi: target/iblock: fix WRITE SAME zeroing · b454d754
      David Disseldorp authored
      commit 1d2ff149 upstream.
      
      SBC4 specifies that WRITE SAME requests with the UNMAP bit set to zero
      "shall perform the specified write operation to each LBA specified by the
      command".  Commit 2237498f ("target/iblock: Convert WRITE_SAME to
      blkdev_issue_zeroout") modified the iblock backend to call
      blkdev_issue_zeroout() when handling WRITE SAME requests with UNMAP=0 and a
      zero data segment.
      
      The iblock blkdev_issue_zeroout() call incorrectly provides a flags
      parameter of 0 (bool false), instead of BLKDEV_ZERO_NOUNMAP.  The bool
      false parameter reflects the blkdev_issue_zeroout() API prior to commit
      ee472d83 ("block: add a flags argument to (__)blkdev_issue_zeroout")
      which was merged shortly before 2237498f.
      
      Link: https://lore.kernel.org/r/20200419163109.11689-1-ddiss@suse.de
      Fixes: 2237498f ("target/iblock: Convert WRITE_SAME to blkdev_issue_zeroout")
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b454d754
    • Tang Bin's avatar
      iommu/qcom: Fix local_base status check · d40ceed1
      Tang Bin authored
      commit b52649ae upstream.
      
      The function qcom_iommu_device_probe() does not perform sufficient
      error checking after executing devm_ioremap_resource(), which can
      result in crashes if a critical error path is encountered.
      
      Fixes: 0ae349a0 ("iommu/qcom: Add qcom_iommu")
      Signed-off-by: default avatarTang Bin <tangbin@cmss.chinamobile.com>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Link: https://lore.kernel.org/r/20200418134703.1760-1-tangbin@cmss.chinamobile.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d40ceed1
    • Sean Christopherson's avatar
      vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn() · cf25855e
      Sean Christopherson authored
      commit 5cbf3264 upstream.
      
      Use follow_pfn() to get the PFN of a PFNMAP VMA instead of assuming that
      vma->vm_pgoff holds the base PFN of the VMA.  This fixes a bug where
      attempting to do VFIO_IOMMU_MAP_DMA on an arbitrary PFNMAP'd region of
      memory calculates garbage for the PFN.
      
      Hilariously, this only got detected because the first "PFN" calculated
      by vaddr_get_pfn() is PFN 0 (vma->vm_pgoff==0), and iommu_iova_to_phys()
      uses PA==0 as an error, which triggers a WARN in vfio_unmap_unpin()
      because the translation "failed".  PFN 0 is now unconditionally reserved
      on x86 in order to mitigate L1TF, which causes is_invalid_reserved_pfn()
      to return true and in turns results in vaddr_get_pfn() returning success
      for PFN 0.  Eventually the bogus calculation runs into PFNs that aren't
      reserved and leads to failure in vfio_pin_map_dma().  The subsequent
      call to vfio_remove_dma() attempts to unmap PFN 0 and WARNs.
      
        WARNING: CPU: 8 PID: 5130 at drivers/vfio/vfio_iommu_type1.c:750 vfio_unmap_unpin+0x2e1/0x310 [vfio_iommu_type1]
        Modules linked in: vfio_pci vfio_virqfd vfio_iommu_type1 vfio ...
        CPU: 8 PID: 5130 Comm: sgx Tainted: G        W         5.6.0-rc5-705d787c7fee-vfio+ #3
        Hardware name: Intel Corporation Mehlow UP Server Platform/Moss Beach Server, BIOS CNLSE2R1.D00.X119.B49.1803010910 03/01/2018
        RIP: 0010:vfio_unmap_unpin+0x2e1/0x310 [vfio_iommu_type1]
        Code: <0f> 0b 49 81 c5 00 10 00 00 e9 c5 fe ff ff bb 00 10 00 00 e9 3d fe
        RSP: 0018:ffffbeb5039ebda8 EFLAGS: 00010246
        RAX: 0000000000000000 RBX: ffff9a55cbf8d480 RCX: 0000000000000000
        RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff9a52b771c200
        RBP: 0000000000000000 R08: 0000000000000040 R09: 00000000fffffff2
        R10: 0000000000000001 R11: ffff9a51fa896000 R12: 0000000184010000
        R13: 0000000184000000 R14: 0000000000010000 R15: ffff9a55cb66ea08
        FS:  00007f15d3830b40(0000) GS:ffff9a55d5600000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000561cf39429e0 CR3: 000000084f75f005 CR4: 00000000003626e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         vfio_remove_dma+0x17/0x70 [vfio_iommu_type1]
         vfio_iommu_type1_ioctl+0x9e3/0xa7b [vfio_iommu_type1]
         ksys_ioctl+0x92/0xb0
         __x64_sys_ioctl+0x16/0x20
         do_syscall_64+0x4c/0x180
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7f15d04c75d7
        Code: <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 48 2d 00 f7 d8 64 89 01 48
      
      Fixes: 73fa0d10 ("vfio: Type1 IOMMU implementation")
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf25855e
    • Yan Zhao's avatar
      vfio: avoid possible overflow in vfio_iommu_type1_pin_pages · f034b331
      Yan Zhao authored
      commit 0ea971f8 upstream.
      
      add parentheses to avoid possible vaddr overflow.
      
      Fixes: a54eb550 ("vfio iommu type1: Add support for mediated devices")
      Signed-off-by: default avatarYan Zhao <yan.y.zhao@intel.com>
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f034b331