1. 06 6月, 2018 2 次提交
  2. 05 5月, 2018 3 次提交
    • G
      Revert "usb: host: ehci: Use dma_pool_zalloc()" · 43b78f11
      Greg Kroah-Hartman 提交于
      This reverts commit 22072e83 as it is
      broken.
      
      Alan writes:
      	What you can't see just from reading the patch is that in both
      	cases (ehci->itd_pool and ehci->sitd_pool) there are two
      	allocation paths -- the two branches of an "if" statement -- and
      	only one of the paths calls dma_pool_[z]alloc.  However, the
      	memset is needed for both paths, and so it can't be eliminated.
      	Given that it must be present, there's no advantage to calling
      	dma_pool_zalloc rather than dma_pool_alloc.
      Reported-by: NErick Cafferata <erick@cafferata.me>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43b78f11
    • M
      platform/x86: Kconfig: Fix dell-laptop dependency chain. · 7fe3fa3b
      Mario Limonciello 提交于
      As reported by Randy Dunlap:
      >> WARNING: unmet direct dependencies detected for DELL_SMBIOS
      >>   Depends on [m]: X86 [=y] && X86_PLATFORM_DEVICES [=y]
      >>	&& (DCDBAS [=m] ||
      >> DCDBAS [=m]=n) && (ACPI_WMI [=n] || ACPI_WMI [=n]=n)
      >>   Selected by [y]:
      >>   - DELL_LAPTOP [=y] && X86 [=y] && X86_PLATFORM_DEVICES [=y]
      >> && DMI [=y]
      >> && BACKLIGHT_CLASS_DEVICE [=y] && (ACPI_VIDEO [=n] ||
      >>	ACPI_VIDEO [=n]=n)
      >> && (RFKILL [=n] || RFKILL [=n]=n) && SERIO_I8042 [=y]
      >>
      
      Right now it's possible to set dell laptop to compile in but this
      causes dell-smbios to compile in which breaks if dcdbas is a module.
      
      Dell laptop shouldn't select dell-smbios anymore, but depend on it.
      
      Fixes: 32d7b19b (platform/x86: dell-smbios: Resolve dependency error on DCDBAS)
      Reported-by: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NMario Limonciello <mario.limonciello@dell.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDarren Hart (VMware) <dvhart@infradead.org>
      7fe3fa3b
    • J
      platform/x86: asus-wireless: Fix NULL pointer dereference · 9f0a93de
      João Paulo Rechi Vita 提交于
      When the module is removed the led workqueue is destroyed in the remove
      callback, before the led device is unregistered from the led subsystem.
      
      This leads to a NULL pointer derefence when the led device is
      unregistered automatically later as part of the module removal cleanup.
      Bellow is the backtrace showing the problem.
      
        BUG: unable to handle kernel NULL pointer dereference at           (null)
        IP: __queue_work+0x8c/0x410
        PGD 0 P4D 0
        Oops: 0000 [#1] SMP NOPTI
        Modules linked in: ccm edac_mce_amd kvm_amd kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 joydev crypto_simd asus_nb_wmi glue_helper uvcvideo snd_hda_codec_conexant snd_hda_codec_generic snd_hda_codec_hdmi snd_hda_intel asus_wmi snd_hda_codec cryptd snd_hda_core sparse_keymap videobuf2_vmalloc arc4 videobuf2_memops snd_hwdep input_leds videobuf2_v4l2 ath9k psmouse videobuf2_core videodev ath9k_common snd_pcm ath9k_hw media fam15h_power ath k10temp snd_timer mac80211 i2c_piix4 r8169 mii mac_hid cfg80211 asus_wireless(-) snd soundcore wmi shpchp 8250_dw ip_tables x_tables amdkfd amd_iommu_v2 amdgpu radeon chash i2c_algo_bit drm_kms_helper syscopyarea serio_raw sysfillrect sysimgblt fb_sys_fops ahci ttm libahci drm video
        CPU: 3 PID: 2177 Comm: rmmod Not tainted 4.15.0-5-generic #6+dev94.b4287e5bem1-Endless
        Hardware name: ASUSTeK COMPUTER INC. X555DG/X555DG, BIOS 5.011 05/05/2015
        RIP: 0010:__queue_work+0x8c/0x410
        RSP: 0018:ffffbe8cc249fcd8 EFLAGS: 00010086
        RAX: ffff992ac6810800 RBX: 0000000000000000 RCX: 0000000000000008
        RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff992ac6400e18
        RBP: ffffbe8cc249fd18 R08: ffff992ac6400db0 R09: 0000000000000000
        R10: 0000000000000040 R11: ffff992ac6400dd8 R12: 0000000000002000
        R13: ffff992abd762e00 R14: ffff992abd763e38 R15: 000000000001ebe0
        FS:  00007f318203e700(0000) GS:ffff992aced80000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000000 CR3: 00000001c720e000 CR4: 00000000001406e0
        Call Trace:
         queue_work_on+0x38/0x40
         led_state_set+0x2c/0x40 [asus_wireless]
         led_set_brightness_nopm+0x14/0x40
         led_set_brightness+0x37/0x60
         led_trigger_set+0xfc/0x1d0
         led_classdev_unregister+0x32/0xd0
         devm_led_classdev_release+0x11/0x20
         release_nodes+0x109/0x1f0
         devres_release_all+0x3c/0x50
         device_release_driver_internal+0x16d/0x220
         driver_detach+0x3f/0x80
         bus_remove_driver+0x55/0xd0
         driver_unregister+0x2c/0x40
         acpi_bus_unregister_driver+0x15/0x20
         asus_wireless_driver_exit+0x10/0xb7c [asus_wireless]
         SyS_delete_module+0x1da/0x2b0
         entry_SYSCALL_64_fastpath+0x24/0x87
        RIP: 0033:0x7f3181b65fd7
        RSP: 002b:00007ffe74bcbe18 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3181b65fd7
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000555ea2559258
        RBP: 0000555ea25591f0 R08: 00007ffe74bcad91 R09: 000000000000000a
        R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000003
        R13: 00007ffe74bcae00 R14: 0000000000000000 R15: 0000555ea25591f0
        Code: 01 00 00 02 0f 85 7d 01 00 00 48 63 45 d4 48 c7 c6 00 f4 fa 87 49 8b 9d 08 01 00 00 48 03 1c c6 4c 89 f7 e8 87 fb ff ff 48 85 c0 <48> 8b 3b 0f 84 c5 01 00 00 48 39 f8 0f 84 bc 01 00 00 48 89 c7
        RIP: __queue_work+0x8c/0x410 RSP: ffffbe8cc249fcd8
        CR2: 0000000000000000
        ---[ end trace 7aa4f4a232e9c39c ]---
      
      Unregistering the led device on the remove callback before destroying the
      workqueue avoids this problem.
      
      https://bugzilla.kernel.org/show_bug.cgi?id=196097Reported-by: NDun Hum <bitter.taste@gmx.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NJoão Paulo Rechi Vita <jprvita@endlessm.com>
      Signed-off-by: NDarren Hart (VMware) <dvhart@infradead.org>
      9f0a93de
  3. 04 5月, 2018 15 次提交
  4. 03 5月, 2018 20 次提交
    • M
      xhci: Fix use-after-free in xhci_free_virt_device · 44a182b9
      Mathias Nyman 提交于
      KASAN found a use-after-free in xhci_free_virt_device+0x33b/0x38e
      where xhci_free_virt_device() sets slot id to 0 if udev exists:
      if (dev->udev && dev->udev->slot_id)
      	dev->udev->slot_id = 0;
      
      dev->udev will be true even if udev is freed because dev->udev is
      not set to NULL.
      
      set dev->udev pointer to NULL in xhci_free_dev()
      
      The original patch went to stable so this fix needs to be applied
      there as well.
      
      Fixes: a400efe4 ("xhci: zero usb device slot_id member when disabling and freeing a xhci slot")
      Cc: <stable@vger.kernel.org>
      Reported-by: NGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Tested-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44a182b9
    • J
      nvmet: switch loopback target state to connecting when resetting · 8bfc3b4c
      Johannes Thumshirn 提交于
      After commit bb06ec31 ("nvme: expand nvmf_check_if_ready checks")
      resetting of the loopback nvme target failed as we forgot to switch
      it's state to NVME_CTRL_CONNECTING before we reconnect the admin
      queues. Therefore the checks in nvmf_check_if_ready() choose to go to
      the reject_io case and thus we couldn't sent out an identify
      controller command to reconnect.
      
      Change the controller state to NVME_CTRL_CONNECTING after tearing down
      the old connection and before re-establishing the connection.
      
      Fixes: bb06ec31 ("nvme: expand nvmf_check_if_ready checks")
      Signed-off-by: NJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      8bfc3b4c
    • K
      nvme/multipath: Fix multipath disabled naming collisions · a785dbcc
      Keith Busch 提交于
      When CONFIG_NVME_MULTIPATH is set, but we're not using nvme to multipath,
      namespaces with multiple paths were not creating unique names due to
      reusing the same instance number from the namespace's head.
      
      This patch fixes this by falling back to the non-multipath naming method
      when the parameter disabled using multipath.
      Reported-by: NMike Snitzer <snitzer@redhat.com>
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      a785dbcc
    • K
      nvme/multipath: Disable runtime writable enabling parameter · 5cadde80
      Keith Busch 提交于
      We can't allow the user to change multipath settings at runtime, as this
      will create naming conflicts due to the different naming schemes used
      for each mode.
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      5cadde80
    • K
      nvme: Set integrity flag for user passthrough commands · f31a2110
      Keith Busch 提交于
      If the command a separate metadata buffer attached, the request needs
      to have the integrity flag set so the driver knows to map it.
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      f31a2110
    • C
      nvme: fix potential memory leak in option parsing · 59a2f3f0
      Chengguang Xu 提交于
      When specifying same string type option several times,
      current option parsing may cause memory leak. Hence,
      call kfree for previous one in this case.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NSagi Grimberg <sagi@grimberg.me>
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      59a2f3f0
    • B
      qmi_wwan: do not steal interfaces from class drivers · 5697db4a
      Bjørn Mork 提交于
      The USB_DEVICE_INTERFACE_NUMBER matching macro assumes that
      the { vendorid, productid, interfacenumber } set uniquely
      identifies one specific function.  This has proven to fail
      for some configurable devices. One example is the Quectel
      EM06/EP06 where the same interface number can be either
      QMI or MBIM, without the device ID changing either.
      
      Fix by requiring the vendor-specific class for interface number
      based matching.  Functions of other classes can and should use
      class based matching instead.
      
      Fixes: 03304bcb ("net: qmi_wwan: use fixed interface number matching")
      Signed-off-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5697db4a
    • A
      iommu: rockchip: fix building without CONFIG_OF · 40fa84e1
      Arnd Bergmann 提交于
      We get a build error when compiling the iommu driver without CONFIG_OF:
      
      drivers/iommu/rockchip-iommu.c: In function 'rk_iommu_of_xlate':
      drivers/iommu/rockchip-iommu.c:1101:2: error: implicit declaration of function 'of_dev_put'; did you mean 'of_node_put'? [-Werror=implicit-function-declaration]
      
      This replaces the of_dev_put() with the equivalent
      platform_device_put().
      
      Fixes: 5fd577c3 ("iommu/rockchip: Use OF_IOMMU to attach devices automatically")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      40fa84e1
    • C
      bcache: use pr_info() to inform duplicated CACHE_SET_IO_DISABLE set · 09a44ca2
      Coly Li 提交于
      It is possible that multiple I/O requests hits on failed cache device or
      backing device, therefore it is quite common that CACHE_SET_IO_DISABLE is
      set already when a task tries to set the bit from bch_cache_set_error().
      Currently the message "CACHE_SET_IO_DISABLE already set" is printed by
      pr_warn(), which might mislead users to think a serious fault happens in
      source code.
      
      This patch uses pr_info() to print the information in such situation,
      avoid extra worries. This information is helpful to understand bcache
      behavior in cache device failures, so I still keep them in source code.
      
      Fixes: 771f393e ("bcache: add CACHE_SET_IO_DISABLE to struct cache_set flags")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      09a44ca2
    • C
      bcache: set dc->io_disable to true in conditional_stop_bcache_device() · 4fd8e138
      Coly Li 提交于
      Commit 7e027ca4 ("bcache: add stop_when_cache_set_failed option to
      backing device") adds stop_when_cache_set_failed option and stops bcache
      device if stop_when_cache_set_failed is auto and there is dirty data on
      broken cache device. There might exists a small time gap that the cache
      set is released and set to NULL but bcache device is not released yet
      (because they are released in parallel). During this time gap, dc->c is
      NULL so CACHE_SET_IO_DISABLE won't be checked, and dc->io_disable is still
      false, so new coming I/O requests will be accepted and directly go into
      backing device as no cache set attached to. If there is dirty data on
      cache device, this behavior may introduce potential inconsistent data.
      
      This patch sets dc->io_disable to true before calling bcache_device_stop()
      to make sure the backing device will reject new coming I/O request as
      well, so even in the small time gap no I/O will directly go into backing
      device to corrupt data consistency.
      
      Fixes: 7e027ca4 ("bcache: add stop_when_cache_set_failed option to backing device")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      4fd8e138
    • C
      bcache: add wait_for_kthread_stop() in bch_allocator_thread() · ecb2ba8c
      Coly Li 提交于
      When CACHE_SET_IO_DISABLE is set on cache set flags, bcache allocator
      thread routine bch_allocator_thread() may stop the while-loops and
      exit. Then it is possible to observe the following kernel oops message,
      
      [  631.068366] bcache: bch_btree_insert() error -5
      [  631.069115] bcache: cached_dev_detach_finish() Caching disabled for sdf
      [  631.070220] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
      [  631.070250] PGD 0 P4D 0
      [  631.070261] Oops: 0002 [#1] SMP PTI
      [snipped]
      [  631.070578] Workqueue: events cache_set_flush [bcache]
      [  631.070597] RIP: 0010:exit_creds+0x1b/0x50
      [  631.070610] RSP: 0018:ffffc9000705fe08 EFLAGS: 00010246
      [  631.070626] RAX: 0000000000000001 RBX: ffff880a622ad300 RCX: 000000000000000b
      [  631.070645] RDX: 0000000000000601 RSI: 000000000000000c RDI: 0000000000000000
      [  631.070663] RBP: ffff880a622ad300 R08: ffffea00190c66e0 R09: 0000000000000200
      [  631.070682] R10: ffff880a48123000 R11: ffff880000000000 R12: 0000000000000000
      [  631.070700] R13: ffff880a4b160e40 R14: ffff880a4b160000 R15: 0ffff880667e2530
      [  631.070719] FS:  0000000000000000(0000) GS:ffff880667e00000(0000) knlGS:0000000000000000
      [  631.070740] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  631.070755] CR2: 0000000000000000 CR3: 000000000200a001 CR4: 00000000003606e0
      [  631.070774] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  631.070793] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  631.070811] Call Trace:
      [  631.070828]  __put_task_struct+0x55/0x160
      [  631.070845]  kthread_stop+0xee/0x100
      [  631.070863]  cache_set_flush+0x11d/0x1a0 [bcache]
      [  631.070879]  process_one_work+0x146/0x340
      [  631.070892]  worker_thread+0x47/0x3e0
      [  631.070906]  kthread+0xf5/0x130
      [  631.070917]  ? max_active_store+0x60/0x60
      [  631.070930]  ? kthread_bind+0x10/0x10
      [  631.070945]  ret_from_fork+0x35/0x40
      [snipped]
      [  631.071017] RIP: exit_creds+0x1b/0x50 RSP: ffffc9000705fe08
      [  631.071033] CR2: 0000000000000000
      [  631.071045] ---[ end trace 011c63a24b22c927 ]---
      [  631.071085] bcache: bcache_device_free() bcache0 stopped
      
      The reason is when cache_set_flush() tries to call kthread_stop() to stop
      allocator thread, but it exits already due to cache device I/O errors.
      
      This patch adds wait_for_kthread_stop() at tail of bch_allocator_thread(),
      to prevent the thread routine exiting directly. Then the allocator thread
      can be blocked at wait_for_kthread_stop() and wait for cache_set_flush()
      to stop it by calling kthread_stop().
      
      changelog:
      v3: add Reviewed-by from Hannnes.
      v2: not directly return from allocator_wait(), move 'return 0' to tail of
          bch_allocator_thread().
      v1: initial version.
      
      Fixes: 771f393e ("bcache: add CACHE_SET_IO_DISABLE to struct cache_set flags")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      ecb2ba8c
    • C
      bcache: count backing device I/O error for writeback I/O · bf78980f
      Coly Li 提交于
      Commit c7b7bd07 ("bcache: add io_disable to struct cached_dev")
      counts backing device I/O requets and set dc->io_disable to true if error
      counters exceeds dc->io_error_limit. But it only counts I/O errors for
      regular I/O request, neglects errors of write back I/Os when backing device
      is offline.
      
      This patch counts the errors of writeback I/Os, in dirty_endio() if
      bio->bi_status is  not 0, it means error happens when writing dirty keys
      to backing device, then bch_count_backing_io_errors() is called.
      
      By this fix, even there is no reqular I/O request coming, if writeback I/O
      errors exceed dc->io_error_limit, the bcache device may still be stopped
      for the broken backing device.
      
      Fixes: c7b7bd07 ("bcache: add io_disable to struct cached_dev")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      bf78980f
    • C
      bcache: set CACHE_SET_IO_DISABLE in bch_cached_dev_error() · 6147305c
      Coly Li 提交于
      Commit c7b7bd07 ("bcache: add io_disable to struct cached_dev") tries
      to stop bcache device by calling bcache_device_stop() when too many I/O
      errors happened on backing device. But if there is internal I/O happening
      on cache device (writeback scan, garbage collection, etc), a regular I/O
      request triggers the internal I/Os may still holds a refcount of dc->count,
      and the refcount may only be dropped after the internal I/O stopped.
      
      By this patch, bch_cached_dev_error() will check if the backing device is
      attached to a cache set, if yes that CACHE_SET_IO_DISABLE will be set to
      flags of this cache set. Then internal I/Os on cache device will be
      rejected and stopped immediately, and the bcache device can be stopped.
      
      For people who are not familiar with the interesting refcount dependance,
      let me explain a bit more how the fix works. Example the writeback thread
      will scan cache device for dirty data writeback purpose. Before it stopps,
      it holds a refcount of dc->count. When CACHE_SET_IO_DISABLE bit is set,
      the internal I/O will stopped and the while-loop in bch_writeback_thread()
      quits and calls cached_dev_put() to drop dc->count. If this is the last
      refcount to drop, then cached_dev_detach_finish() will be called. In this
      call back function, in turn closure_put(dc->disk.cl) is called to drop a
      refcount of closure dc->disk.cl. If this is the last refcount of this
      closure to drop, then cached_dev_flush() will be called. Then the cached
      device is freed. So if CACHE_SET_IO_DISABLE is not set, the bache device
      can not be stopped until all inernal cache device I/O stopped. For large
      size cache device, and writeback thread competes locks with gc thread,
      there might be a quite long time to wait.
      
      Fixes: c7b7bd07 ("bcache: add io_disable to struct cached_dev")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      6147305c
    • C
      bcache: store disk name in struct cache and struct cached_dev · 6e916a7e
      Coly Li 提交于
      Current code uses bdevname() or bio_devname() to reference gendisk
      disk name when bcache needs to display the disk names in kernel message.
      It was safe before bcache device failure handling patch set merged in,
      because when devices are failed, there was deadlock to prevent bcache
      printing error messages with gendisk disk name. But after the failure
      handling patch set merged, the deadlock is fixed, so it is possible
      that the gendisk structure bdev->hd_disk is released when bdevname() is
      called to reference bdev->bd_disk->disk_name[]. This is why I receive
      bug report of NULL pointers deference panic.
      
      This patch stores gendisk disk name in a buffer inside struct cache and
      struct cached_dev, then print out the offline device name won't reference
      bdev->hd_disk anymore. And this patch also avoids extra function calls
      of bdevname() and bio_devnmae().
      
      Changelog:
      v3, add Reviewed-by from Hannes.
      v2, call bdevname() earlier in register_bdev()
      v1, first version with segguestion from Junhui Tang.
      
      Fixes: c7b7bd07 ("bcache: add io_disable to struct cached_dev")
      Fixes: 5138ac67 ("bcache: fix misleading error message in bch_count_io_errors()")
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      6e916a7e
    • J
      iommu/vt-d: Use WARN_ON_ONCE instead of BUG_ON in qi_flush_dev_iotlb() · a85894cd
      Joerg Roedel 提交于
      A misaligned address is only worth a warning, and not
      stopping the while execution path with a BUG_ON().
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      a85894cd
    • C
      iommu/vt-d: fix shift-out-of-bounds in bug checking · 0dfc0c79
      Changbin Du 提交于
      It allows to flush more than 4GB of device TLBs. So the mask should be
      64bit wide. UBSAN captured this fault as below.
      
      [    3.760024] ================================================================================
      [    3.768440] UBSAN: Undefined behaviour in drivers/iommu/dmar.c:1348:3
      [    3.774864] shift exponent 64 is too large for 32-bit type 'int'
      [    3.780853] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G     U            4.17.0-rc1+ #89
      [    3.788661] Hardware name: Dell Inc. OptiPlex 7040/0Y7WYT, BIOS 1.2.8 01/26/2016
      [    3.796034] Call Trace:
      [    3.798472]  <IRQ>
      [    3.800479]  dump_stack+0x90/0xfb
      [    3.803787]  ubsan_epilogue+0x9/0x40
      [    3.807353]  __ubsan_handle_shift_out_of_bounds+0x10e/0x170
      [    3.812916]  ? qi_flush_dev_iotlb+0x124/0x180
      [    3.817261]  qi_flush_dev_iotlb+0x124/0x180
      [    3.821437]  iommu_flush_dev_iotlb+0x94/0xf0
      [    3.825698]  iommu_flush_iova+0x10b/0x1c0
      [    3.829699]  ? fq_ring_free+0x1d0/0x1d0
      [    3.833527]  iova_domain_flush+0x25/0x40
      [    3.837448]  fq_flush_timeout+0x55/0x160
      [    3.841368]  ? fq_ring_free+0x1d0/0x1d0
      [    3.845200]  ? fq_ring_free+0x1d0/0x1d0
      [    3.849034]  call_timer_fn+0xbe/0x310
      [    3.852696]  ? fq_ring_free+0x1d0/0x1d0
      [    3.856530]  run_timer_softirq+0x223/0x6e0
      [    3.860625]  ? sched_clock+0x5/0x10
      [    3.864108]  ? sched_clock+0x5/0x10
      [    3.867594]  __do_softirq+0x1b5/0x6f5
      [    3.871250]  irq_exit+0xd4/0x130
      [    3.874470]  smp_apic_timer_interrupt+0xb8/0x2f0
      [    3.879075]  apic_timer_interrupt+0xf/0x20
      [    3.883159]  </IRQ>
      [    3.885255] RIP: 0010:poll_idle+0x60/0xe7
      [    3.889252] RSP: 0018:ffffb1b201943e30 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
      [    3.896802] RAX: 0000000080200000 RBX: 000000000000008e RCX: 000000000000001f
      [    3.903918] RDX: 0000000000000000 RSI: 000000002819aa06 RDI: 0000000000000000
      [    3.911031] RBP: ffff9e93c6b33280 R08: 00000010f717d567 R09: 000000000010d205
      [    3.918146] R10: ffffb1b201943df8 R11: 0000000000000001 R12: 00000000e01b169d
      [    3.925260] R13: 0000000000000000 R14: ffffffffb12aa400 R15: 0000000000000000
      [    3.932382]  cpuidle_enter_state+0xb4/0x470
      [    3.936558]  do_idle+0x222/0x310
      [    3.939779]  cpu_startup_entry+0x78/0x90
      [    3.943693]  start_secondary+0x205/0x2e0
      [    3.947607]  secondary_startup_64+0xa5/0xb0
      [    3.951783] ================================================================================
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      0dfc0c79
    • S
      iommu/dma: Move PCI window region reservation back into dma specific path. · cd2c9fcf
      Shameer Kolothum 提交于
      This pretty much reverts commit 273df963 ("iommu/dma: Make PCI
      window reservation generic")  by moving the PCI window region
      reservation back into the dma specific path so that these regions
      doesn't get exposed via the IOMMU API interface. With this change,
      the vfio interface will report only iommu specific reserved regions
      to the user space.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: NShameer Kolothum <shameerali.kolothum.thodi@huawei.com>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Fixes: 273df963 ('iommu/dma: Make PCI window reservation generic')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      cd2c9fcf
    • H
      iommu/rockchip: Make clock handling optional · 2f8c7f2e
      Heiko Stuebner 提交于
      iommu clocks are optional, so the driver should not fail if they are not
      present. Instead just set the number of clocks to 0, which the clk-blk APIs
      can handle just fine.
      
      Fixes: f2e3a5f5 ("iommu/rockchip: Control clocks needed to access the IOMMU")
      Signed-off-by: NHeiko Stuebner <heiko@sntech.de>
      Reviewed-by: NRobin Murphy <robin.murphy@arm.com>
      Tested-by: NEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      2f8c7f2e
    • A
      iommu/amd: Hide unused iommu_table_lock · 94c793ac
      Arnd Bergmann 提交于
      The newly introduced lock is only used when CONFIG_IRQ_REMAP is enabled:
      
      drivers/iommu/amd_iommu.c:86:24: error: 'iommu_table_lock' defined but not used [-Werror=unused-variable]
       static DEFINE_SPINLOCK(iommu_table_lock);
      
      This moves the definition next to the user, within the #ifdef protected
      section of the file.
      
      Fixes: ea6166f4 ("iommu/amd: Split irq_lookup_table out of the amd_iommu_devtable_lock")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      94c793ac
    • J
      iommu/vt-d: Fix usage of force parameter in intel_ir_reconfigure_irte() · aa7528fe
      Jagannathan Raman 提交于
      It was noticed that the IRTE configured for guest OS kernel
      was over-written while the guest was running. As a result,
      vt-d Posted Interrupts configured for the guest are not being
      delivered directly, and instead bounces off the host. Every
      interrupt delivery takes a VM Exit.
      
      It was noticed that the following stack is doing the over-write:
      [  147.463177]  modify_irte+0x171/0x1f0
      [  147.463405]  intel_ir_set_affinity+0x5c/0x80
      [  147.463641]  msi_domain_set_affinity+0x32/0x90
      [  147.463881]  irq_do_set_affinity+0x37/0xd0
      [  147.464125]  irq_set_affinity_locked+0x9d/0xb0
      [  147.464374]  __irq_set_affinity+0x42/0x70
      [  147.464627]  write_irq_affinity.isra.5+0xe1/0x110
      [  147.464895]  proc_reg_write+0x38/0x70
      [  147.465150]  __vfs_write+0x36/0x180
      [  147.465408]  ? handle_mm_fault+0xdf/0x200
      [  147.465671]  ? _cond_resched+0x15/0x30
      [  147.465936]  vfs_write+0xad/0x1a0
      [  147.466204]  SyS_write+0x52/0xc0
      [  147.466472]  do_syscall_64+0x74/0x1a0
      [  147.466744]  entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
      reversing the sense of force check in intel_ir_reconfigure_irte()
      restores proper posted interrupt functionality
      Signed-off-by: NJagannathan Raman <jag.raman@oracle.com>
      Fixes: d491bdff ('iommu/vt-d: Reevaluate vector configuration on activate()')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      aa7528fe