1. 22 3月, 2019 1 次提交
  2. 18 3月, 2019 1 次提交
    • S
      iommu/amd: fix sg->dma_address for sg->offset bigger than PAGE_SIZE · 4e50ce03
      Stanislaw Gruszka 提交于
      Take into account that sg->offset can be bigger than PAGE_SIZE when
      setting segment sg->dma_address. Otherwise sg->dma_address will point
      at diffrent page, what makes DMA not possible with erros like this:
      
      xhci_hcd 0000:38:00.3: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0x00000000fdaa70c0 flags=0x0020]
      xhci_hcd 0000:38:00.3: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0x00000000fdaa7040 flags=0x0020]
      xhci_hcd 0000:38:00.3: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0x00000000fdaa7080 flags=0x0020]
      xhci_hcd 0000:38:00.3: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0x00000000fdaa7100 flags=0x0020]
      xhci_hcd 0000:38:00.3: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0x00000000fdaa7000 flags=0x0020]
      
      Additinally with wrong sg->dma_address unmap_sg will free wrong pages,
      what what can cause crashes like this:
      
      Feb 28 19:27:45 kernel: BUG: Bad page state in process cinnamon  pfn:39e8b1
      Feb 28 19:27:45 kernel: Disabling lock debugging due to kernel taint
      Feb 28 19:27:45 kernel: flags: 0x2ffff0000000000()
      Feb 28 19:27:45 kernel: raw: 02ffff0000000000 0000000000000000 ffffffff00000301 0000000000000000
      Feb 28 19:27:45 kernel: raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      Feb 28 19:27:45 kernel: page dumped because: nonzero _refcount
      Feb 28 19:27:45 kernel: Modules linked in: ccm fuse arc4 nct6775 hwmon_vid amdgpu nls_iso8859_1 nls_cp437 edac_mce_amd vfat fat kvm_amd ccp rng_core kvm mt76x0u mt76x0_common mt76x02_usb irqbypass mt76_usb mt76x02_lib mt76 crct10dif_pclmul crc32_pclmul chash mac80211 amd_iommu_v2 ghash_clmulni_intel gpu_sched i2c_algo_bit ttm wmi_bmof snd_hda_codec_realtek snd_hda_codec_generic drm_kms_helper snd_hda_codec_hdmi snd_hda_intel drm snd_hda_codec aesni_intel snd_hda_core snd_hwdep aes_x86_64 crypto_simd snd_pcm cfg80211 cryptd mousedev snd_timer glue_helper pcspkr r8169 input_leds realtek agpgart libphy rfkill snd syscopyarea sysfillrect sysimgblt fb_sys_fops soundcore sp5100_tco k10temp i2c_piix4 wmi evdev gpio_amdpt pinctrl_amd mac_hid pcc_cpufreq acpi_cpufreq sg ip_tables x_tables ext4(E) crc32c_generic(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) sd_mod(E) hid_generic(E) usbhid(E) hid(E) dm_mod(E) serio_raw(E) atkbd(E) libps2(E) crc32c_intel(E) ahci(E) libahci(E) libata(E) xhci_pci(E) xhci_hcd(E)
      Feb 28 19:27:45 kernel:  scsi_mod(E) i8042(E) serio(E) bcache(E) crc64(E)
      Feb 28 19:27:45 kernel: CPU: 2 PID: 896 Comm: cinnamon Tainted: G    B   W   E     4.20.12-arch1-1-custom #1
      Feb 28 19:27:45 kernel: Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B450M Pro4, BIOS P1.20 06/26/2018
      Feb 28 19:27:45 kernel: Call Trace:
      Feb 28 19:27:45 kernel:  dump_stack+0x5c/0x80
      Feb 28 19:27:45 kernel:  bad_page.cold.29+0x7f/0xb2
      Feb 28 19:27:45 kernel:  __free_pages_ok+0x2c0/0x2d0
      Feb 28 19:27:45 kernel:  skb_release_data+0x96/0x180
      Feb 28 19:27:45 kernel:  __kfree_skb+0xe/0x20
      Feb 28 19:27:45 kernel:  tcp_recvmsg+0x894/0xc60
      Feb 28 19:27:45 kernel:  ? reuse_swap_page+0x120/0x340
      Feb 28 19:27:45 kernel:  ? ptep_set_access_flags+0x23/0x30
      Feb 28 19:27:45 kernel:  inet_recvmsg+0x5b/0x100
      Feb 28 19:27:45 kernel:  __sys_recvfrom+0xc3/0x180
      Feb 28 19:27:45 kernel:  ? handle_mm_fault+0x10a/0x250
      Feb 28 19:27:45 kernel:  ? syscall_trace_enter+0x1d3/0x2d0
      Feb 28 19:27:45 kernel:  ? __audit_syscall_exit+0x22a/0x290
      Feb 28 19:27:45 kernel:  __x64_sys_recvfrom+0x24/0x30
      Feb 28 19:27:45 kernel:  do_syscall_64+0x5b/0x170
      Feb 28 19:27:45 kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Cc: stable@vger.kernel.org
      Reported-and-tested-by: NJan Viktorin <jan.viktorin@gmail.com>
      Reviewed-by: NAlexander Duyck <alexander.h.duyck@linux.intel.com>
      Signed-off-by: NStanislaw Gruszka <sgruszka@redhat.com>
      Fixes: 80187fd3 ('iommu/amd: Optimize map_sg and unmap_sg')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      4e50ce03
  3. 15 3月, 2019 1 次提交
  4. 06 3月, 2019 1 次提交
    • A
      mm: replace all open encodings for NUMA_NO_NODE · 98fa15f3
      Anshuman Khandual 提交于
      Patch series "Replace all open encodings for NUMA_NO_NODE", v3.
      
      All these places for replacement were found by running the following
      grep patterns on the entire kernel code.  Please let me know if this
      might have missed some instances.  This might also have replaced some
      false positives.  I will appreciate suggestions, inputs and review.
      
      1. git grep "nid == -1"
      2. git grep "node == -1"
      3. git grep "nid = -1"
      4. git grep "node = -1"
      
      This patch (of 2):
      
      At present there are multiple places where invalid node number is
      encoded as -1.  Even though implicitly understood it is always better to
      have macros in there.  Replace these open encodings for an invalid node
      number with the global macro NUMA_NO_NODE.  This helps remove NUMA
      related assumptions like 'invalid node' from various places redirecting
      them to a common definition.
      
      Link: http://lkml.kernel.org/r/1545127933-10711-2-git-send-email-anshuman.khandual@arm.comSigned-off-by: NAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: NDavid Hildenbrand <david@redhat.com>
      Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>	[ixgbe]
      Acked-by: Jens Axboe <axboe@kernel.dk>			[mtip32xx]
      Acked-by: Vinod Koul <vkoul@kernel.org>			[dmaengine.c]
      Acked-by: Michael Ellerman <mpe@ellerman.id.au>		[powerpc]
      Acked-by: Doug Ledford <dledford@redhat.com>		[drivers/infiniband]
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Hans Verkuil <hverkuil@xs4all.nl>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      98fa15f3
  5. 01 3月, 2019 5 次提交
  6. 28 2月, 2019 1 次提交
    • L
      iommu/hyper-v: Add Hyper-V stub IOMMU driver · 29217a47
      Lan Tianyu 提交于
      On the bare metal, enabling X2APIC mode requires interrupt remapping
      function which helps to deliver irq to cpu with 32-bit APIC ID.
      Hyper-V doesn't provide interrupt remapping function so far and Hyper-V
      MSI protocol already supports to deliver interrupt to the CPU whose
      virtual processor index is more than 255. IO-APIC interrupt still has
      8-bit APIC ID limitation.
      
      This patch is to add Hyper-V stub IOMMU driver in order to enable
      X2APIC mode successfully in Hyper-V Linux guest. The driver returns X2APIC
      interrupt remapping capability when X2APIC mode is available. Otherwise,
      it creates a Hyper-V irq domain to limit IO-APIC interrupts' affinity
      and make sure cpus assigned with IO-APIC interrupt have 8-bit APIC ID.
      
      Define 24 IO-APIC remapping entries because Hyper-V only expose one
      single IO-APIC and one IO-APIC has 24 pins according IO-APIC spec(
      https://pdos.csail.mit.edu/6.828/2016/readings/ia32/ioapic.pdf).
      Reviewed-by: NMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: NLan Tianyu <Tianyu.Lan@microsoft.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      29217a47
  7. 26 2月, 2019 8 次提交
    • L
      iommu/vt-d: Check identity map for hot-added devices · 117266fd
      Lu Baolu 提交于
      The Intel IOMMU driver will put devices into a static identity
      mapped domain during boot if the kernel parameter "iommu=pt" is
      used. That means the IOMMU hardware will translate a DMA address
      into the same memory address.
      
      Unfortunately, hot-added devices are not subject to this. That
      results in some devices not working properly after hot added. A
      quick way to reproduce this issue is to boot a system with
      
          iommu=pt
      
      and, remove then readd the pci device with
      
          echo 1 > /sys/bus/pci/devices/[pci_source_id]/remove
          echo 1 > /sys/bus/pci/rescan
      
      You will find the identity mapped domain was replaced with a
      normal domain.
      
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: stable@vger.kernel.org
      Reported-by: NJis Ben <jisben@google.com>
      Signed-off-by: NLu Baolu <baolu.lu@linux.intel.com>
      Tested-by: NJames Dong <xmdong@google.com>
      Fixes: 99dcaded ('intel-iommu: Support PCIe hot-plug')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      117266fd
    • J
      iommu/dmar: Fix buffer overflow during PCI bus notification · cffaaf0c
      Julia Cartwright 提交于
      Commit 57384592 ("iommu/vt-d: Store bus information in RMRR PCI
      device path") changed the type of the path data, however, the change in
      path type was not reflected in size calculations.  Update to use the
      correct type and prevent a buffer overflow.
      
      This bug manifests in systems with deep PCI hierarchies, and can lead to
      an overflow of the static allocated buffer (dmar_pci_notify_info_buf),
      or can lead to overflow of slab-allocated data.
      
         BUG: KASAN: global-out-of-bounds in dmar_alloc_pci_notify_info+0x1d5/0x2e0
         Write of size 1 at addr ffffffff90445d80 by task swapper/0/1
         CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.87-rt49-02406-gd0a0e96 #1
         Call Trace:
          ? dump_stack+0x46/0x59
          ? print_address_description+0x1df/0x290
          ? dmar_alloc_pci_notify_info+0x1d5/0x2e0
          ? kasan_report+0x256/0x340
          ? dmar_alloc_pci_notify_info+0x1d5/0x2e0
          ? e820__memblock_setup+0xb0/0xb0
          ? dmar_dev_scope_init+0x424/0x48f
          ? __down_write_common+0x1ec/0x230
          ? dmar_dev_scope_init+0x48f/0x48f
          ? dmar_free_unused_resources+0x109/0x109
          ? cpumask_next+0x16/0x20
          ? __kmem_cache_create+0x392/0x430
          ? kmem_cache_create+0x135/0x2f0
          ? e820__memblock_setup+0xb0/0xb0
          ? intel_iommu_init+0x170/0x1848
          ? _raw_spin_unlock_irqrestore+0x32/0x60
          ? migrate_enable+0x27a/0x5b0
          ? sched_setattr+0x20/0x20
          ? migrate_disable+0x1fc/0x380
          ? task_rq_lock+0x170/0x170
          ? try_to_run_init_process+0x40/0x40
          ? locks_remove_file+0x85/0x2f0
          ? dev_prepare_static_identity_mapping+0x78/0x78
          ? rt_spin_unlock+0x39/0x50
          ? lockref_put_or_lock+0x2a/0x40
          ? dput+0x128/0x2f0
          ? __rcu_read_unlock+0x66/0x80
          ? __fput+0x250/0x300
          ? __rcu_read_lock+0x1b/0x30
          ? mntput_no_expire+0x38/0x290
          ? e820__memblock_setup+0xb0/0xb0
          ? pci_iommu_init+0x25/0x63
          ? pci_iommu_init+0x25/0x63
          ? do_one_initcall+0x7e/0x1c0
          ? initcall_blacklisted+0x120/0x120
          ? kernel_init_freeable+0x27b/0x307
          ? rest_init+0xd0/0xd0
          ? kernel_init+0xf/0x120
          ? rest_init+0xd0/0xd0
          ? ret_from_fork+0x1f/0x40
         The buggy address belongs to the variable:
          dmar_pci_notify_info_buf+0x40/0x60
      
      Fixes: 57384592 ("iommu/vt-d: Store bus information in RMRR PCI device path")
      Signed-off-by: NJulia Cartwright <julia@ni.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      cffaaf0c
    • G
      iommu: Fix IOMMU debugfs fallout · 18b3af44
      Geert Uytterhoeven 提交于
      A change made in the final version of IOMMU debugfs support replaced the
      public function iommu_debugfs_new_driver_dir() by the public dentry
      iommu_debugfs_dir in <linux/iommu.h>, but forgot to update both the
      implementation in iommu-debugfs.c, and the patch description.
      
      Fix this by exporting iommu_debugfs_dir, and removing the reference to
      and implementation of iommu_debugfs_new_driver_dir().
      
      Fixes: bad614b2 ("iommu: Enable debugfs exposure of IOMMU driver internals")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: NGary R Hook <gary.hook@amd.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      18b3af44
    • K
      iommu/vt-d: Enable ATS only if the device uses page aligned address. · 61363c14
      Kuppuswamy Sathyanarayanan 提交于
      As per Intel vt-d specification, Rev 3.0 (section 7.5.1.1, title "Page
      Request Descriptor"), Intel IOMMU page request descriptor only uses
      bits[63:12] of the page address. Hence Intel IOMMU driver would only
      permit devices that advertise they would only send Page Aligned Requests
      to participate in ATS service.
      
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Keith Busch <keith.busch@intel.com>
      Suggested-by: NAshok Raj <ashok.raj@intel.com>
      Signed-off-by: NKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      61363c14
    • K
      iommu/vt-d: Fix PRI/PASID dependency issue. · 1b84778a
      Kuppuswamy Sathyanarayanan 提交于
      In Intel IOMMU, if the Page Request Queue (PRQ) is full, it will
      automatically respond to the device with a success message as a keep
      alive. And when sending the success message, IOMMU will include PASID in
      the Response Message when the Page Request has a PASID in Request
      Message and it does not check against the PRG Response PASID requirement
      of the device before sending the response. Also, if the device receives
      the PRG response with PASID when its not expecting it the device behavior
      is undefined. So if PASID is enabled in the device, enable PRI only if
      device expects PASID in PRG Response Message.
      
      Cc: Ashok Raj <ashok.raj@intel.com>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Cc: Keith Busch <keith.busch@intel.com>
      Suggested-by: NAshok Raj <ashok.raj@intel.com>
      Signed-off-by: NKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      1b84778a
    • L
      iommu/vt-d: Allow interrupts from the entire bus for aliased devices · 3f0c625c
      Logan Gunthorpe 提交于
      When a device has multiple aliases that all are from the same bus,
      we program the IRTE to accept requests from any matching device on the
      bus.
      
      This is so NTB devices which can have requests from multiple bus-devfns
      can pass MSI interrupts through across the bridge.
      Signed-off-by: NLogan Gunthorpe <logang@deltatee.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      3f0c625c
    • L
      iommu/vt-d: Add helper to set an IRTE to verify only the bus number · 9ca82611
      Logan Gunthorpe 提交于
      The current code uses set_irte_sid() with SVT_VERIFY_BUS and PCI_DEVID
      to set the SID value. However, this is very confusing because, with
      SVT_VERIFY_BUS, the SID value is not a PCI devfn address, but the start
      and end bus numbers to match against.
      
      According to the Intel Virtualization Technology for Directed I/O
      Architecture Specification, Rev. 3.0, page 9-36:
      
        The most significant 8-bits of the SID field contains the Startbus#,
        and the least significant 8-bits of the SID field contains the Endbus#.
        Interrupt requests that reference this IRTE must have a requester-id
        whose bus# (most significant 8-bits of requester-id) has a value equal
        to or within the Startbus# to Endbus# range.
      
      So to make this more clear, introduce a new set_irte_verify_bus() that
      explicitly takes a start bus and end bus so that we can stop abusing
      the PCI_DEVID macro.
      
      This helper function will be called a second time in an subsequent patch.
      Signed-off-by: NLogan Gunthorpe <logang@deltatee.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      9ca82611
    • N
      iommu/io-pgtable-arm-v7s: Only kmemleak_ignore L2 tables · 032ebd85
      Nicolas Boichat 提交于
      L1 tables are allocated with __get_dma_pages, and therefore already
      ignored by kmemleak.
      
      Without this, the kernel would print this error message on boot,
      when the first L1 table is allocated:
      
      [    2.810533] kmemleak: Trying to color unknown object at 0xffffffd652388000 as Black
      [    2.818190] CPU: 5 PID: 39 Comm: kworker/5:0 Tainted: G S                4.19.16 #8
      [    2.831227] Workqueue: events deferred_probe_work_func
      [    2.836353] Call trace:
      ...
      [    2.852532]  paint_ptr+0xa0/0xa8
      [    2.855750]  kmemleak_ignore+0x38/0x6c
      [    2.859490]  __arm_v7s_alloc_table+0x168/0x1f4
      [    2.863922]  arm_v7s_alloc_pgtable+0x114/0x17c
      [    2.868354]  alloc_io_pgtable_ops+0x3c/0x78
      ...
      
      Fixes: e5fc9753 ("iommu/io-pgtable: Add ARMv7 short descriptor support")
      Signed-off-by: NNicolas Boichat <drinkcat@chromium.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      032ebd85
  8. 11 2月, 2019 7 次提交
  9. 01 2月, 2019 1 次提交
  10. 31 1月, 2019 5 次提交
  11. 24 1月, 2019 2 次提交
  12. 23 1月, 2019 1 次提交
  13. 22 1月, 2019 3 次提交
  14. 16 1月, 2019 3 次提交