1. 20 4月, 2019 1 次提交
    • J
      iommu/dmar: Fix buffer overflow during PCI bus notification · 38855a84
      Julia Cartwright 提交于
      [ Upstream commit cffaaf0c816238c45cd2d06913476c83eb50f682 ]
      
      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>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      38855a84
  2. 06 7月, 2018 1 次提交
  3. 13 6月, 2018 1 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
  4. 03 5月, 2018 3 次提交
    • 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
    • D
      iommu/vt-d: Ratelimit each dmar fault printing · 6c50d79f
      Dmitry Safonov 提交于
      There is a ratelimit for printing, but it's incremented each time the
      cpu recives dmar fault interrupt. While one interrupt may signal about
      *many* faults.
      So, measuring the impact it turns out that reading/clearing one fault
      takes < 1 usec, and printing info about the fault takes ~170 msec.
      
      Having in mind that maximum number of fault recording registers per
      remapping hardware unit is 256.. IRQ handler may run for (170*256) msec.
      And as fault-serving loop runs without a time limit, during servicing
      new faults may occur..
      
      Ratelimit each fault printing rather than each irq printing.
      
      Fixes: commit c43fce4e ("iommu/vt-d: Ratelimit fault handler")
      
      BUG: spinlock lockup suspected on CPU#0, CliShell/9903
       lock: 0xffffffff81a47440, .magic: dead4ead, .owner: kworker/u16:2/8915, .owner_cpu: 6
      CPU: 0 PID: 9903 Comm: CliShell
      Call Trace:$\n'
      [..] dump_stack+0x65/0x83$\n'
      [..] spin_dump+0x8f/0x94$\n'
      [..] do_raw_spin_lock+0x123/0x170$\n'
      [..] _raw_spin_lock_irqsave+0x32/0x3a$\n'
      [..] uart_chars_in_buffer+0x20/0x4d$\n'
      [..] tty_chars_in_buffer+0x18/0x1d$\n'
      [..] n_tty_poll+0x1cb/0x1f2$\n'
      [..] tty_poll+0x5e/0x76$\n'
      [..] do_select+0x363/0x629$\n'
      [..] compat_core_sys_select+0x19e/0x239$\n'
      [..] compat_SyS_select+0x98/0xc0$\n'
      [..] sysenter_dispatch+0x7/0x25$\n'
      [..]
      NMI backtrace for cpu 6
      CPU: 6 PID: 8915 Comm: kworker/u16:2
      Workqueue: dmar_fault dmar_fault_work
      Call Trace:$\n'
      [..] wait_for_xmitr+0x26/0x8f$\n'
      [..] serial8250_console_putchar+0x1c/0x2c$\n'
      [..] uart_console_write+0x40/0x4b$\n'
      [..] serial8250_console_write+0xe6/0x13f$\n'
      [..] call_console_drivers.constprop.13+0xce/0x103$\n'
      [..] console_unlock+0x1f8/0x39b$\n'
      [..] vprintk_emit+0x39e/0x3e6$\n'
      [..] printk+0x4d/0x4f$\n'
      [..] dmar_fault+0x1a8/0x1fc$\n'
      [..] dmar_fault_work+0x15/0x17$\n'
      [..] process_one_work+0x1e8/0x3a9$\n'
      [..] worker_thread+0x25d/0x345$\n'
      [..] kthread+0xea/0xf2$\n'
      [..] ret_from_fork+0x58/0x90$\n'
      
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Signed-off-by: NDmitry Safonov <dima@arista.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      6c50d79f
  5. 14 2月, 2018 1 次提交
  6. 04 11月, 2017 1 次提交
  7. 06 10月, 2017 1 次提交
  8. 19 9月, 2017 1 次提交
    • A
      iommu/vt-d: Fix harmless section mismatch warning · 3bd71e18
      Arnd Bergmann 提交于
      Building with gcc-4.6 results in this warning due to
      dmar_table_print_dmar_entry being inlined as in newer compiler versions:
      
      WARNING: vmlinux.o(.text+0x5c8bee): Section mismatch in reference from the function dmar_walk_remapping_entries() to the function .init.text:dmar_table_print_dmar_entry()
      The function dmar_walk_remapping_entries() references
      the function __init dmar_table_print_dmar_entry().
      This is often because dmar_walk_remapping_entries lacks a __init
      annotation or the annotation of dmar_table_print_dmar_entry is wrong.
      
      This removes the __init annotation to avoid the warning. On compilers
      that don't show the warning today, this should have no impact since the
      function gets inlined anyway.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      3bd71e18
  9. 16 8月, 2017 1 次提交
  10. 07 6月, 2017 1 次提交
  11. 22 3月, 2017 4 次提交
  12. 22 2月, 2017 1 次提交
    • A
      iommu/vt-d: Fix crash on boot when DMAR is disabled · c37a0177
      Andy Shevchenko 提交于
      By default CONFIG_INTEL_IOMMU_DEFAULT_ON is not set and thus
      dmar_disabled variable is set.
      
      Intel IOMMU driver based on above doesn't set intel_iommu_enabled
      variable.
      
      The commit b0119e87 ("iommu: Introduce new 'struct iommu_device'")
      mistakenly assumes it never happens and tries to unregister not ever
      registered resources, which crashes the kernel at boot time:
      
      	BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      	IP: iommu_device_unregister+0x31/0x60
      
      Make unregister procedure conditional in free_iommu().
      
      Fixes: b0119e87 ("iommu: Introduce new 'struct iommu_device'")
      Cc: Joerg Roedel <jroedel@suse.de>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      c37a0177
  13. 10 2月, 2017 2 次提交
    • J
      iommu: Add sysfs bindings for struct iommu_device · 39ab9555
      Joerg Roedel 提交于
      There is currently support for iommu sysfs bindings, but
      those need to be implemented in the IOMMU drivers. Add a
      more generic version of this by adding a struct device to
      struct iommu_device and use that for the sysfs bindings.
      
      Also convert the AMD and Intel IOMMU driver to make use of
      it.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      39ab9555
    • J
      iommu: Introduce new 'struct iommu_device' · b0119e87
      Joerg Roedel 提交于
      This struct represents one hardware iommu in the iommu core
      code. For now it only has the iommu-ops associated with it,
      but that will be extended soon.
      
      The register/unregister interface is also added, as well as
      making use of it in the Intel and AMD IOMMU drivers.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      b0119e87
  14. 05 1月, 2017 1 次提交
  15. 21 12月, 2016 1 次提交
    • L
      ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users · 6b11d1d6
      Lv Zheng 提交于
      This patch removes the users of the deprectated APIs:
       acpi_get_table_with_size()
       early_acpi_os_unmap_memory()
      The following APIs should be used instead of:
       acpi_get_table()
       acpi_put_table()
      
      The deprecated APIs are invented to be a replacement of acpi_get_table()
      during the early stage so that the early mapped pointer will not be stored
      in ACPICA core and thus the late stage acpi_get_table() won't return a
      wrong pointer. The mapping size is returned just because it is required by
      early_acpi_os_unmap_memory() to unmap the pointer during early stage.
      
      But as the mapping size equals to the acpi_table_header.length
      (see acpi_tb_init_table_descriptor() and acpi_tb_validate_table()), when
      such a convenient result is returned, driver code will start to use it
      instead of accessing acpi_table_header to obtain the length.
      
      Thus this patch cleans up the drivers by replacing returned table size with
      acpi_table_header.length, and should be a no-op.
      Reported-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6b11d1d6
  16. 30 10月, 2016 1 次提交
    • A
      iommu/vt-d: Fix IOMMU lookup for SR-IOV Virtual Functions · 1c387188
      Ashok Raj 提交于
      The VT-d specification (§8.3.3) says:
          ‘Virtual Functions’ of a ‘Physical Function’ are under the scope
          of the same remapping unit as the ‘Physical Function’.
      
      The BIOS is not required to list all the possible VFs in the scope
      tables, and arguably *shouldn't* make any attempt to do so, since there
      could be a huge number of them.
      
      This has been broken basically for ever — the VF is never going to match
      against a specific unit's scope, so it ends up being assigned to the
      INCLUDE_ALL IOMMU. Which was always actually correct by coincidence, but
      now we're looking at Root-Complex integrated devices with SR-IOV support
      it's going to start being wrong.
      
      Fix it to simply use pci_physfn() before doing the lookup for PCI devices.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NSainath Grandhi <sainath.grandhi@intel.com>
      Signed-off-by: NAshok Raj <ashok.raj@intel.com>
      Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
      1c387188
  17. 28 7月, 2016 1 次提交
    • L
      Add braces to avoid "ambiguous ‘else’" compiler warnings · 194dc870
      Linus Torvalds 提交于
      Some of our "for_each_xyz()" macro constructs make gcc unhappy about
      lack of braces around if-statements inside or outside the loop, because
      the loop construct itself has a "if-then-else" statement inside of it.
      
      The resulting warnings look something like this:
      
        drivers/gpu/drm/i915/i915_debugfs.c: In function ‘i915_dump_lrc’:
        drivers/gpu/drm/i915/i915_debugfs.c:2103:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses]
           if (ctx != dev_priv->kernel_context)
              ^
      
      even if the code itself is fine.
      
      Since the warning is fairly easy to avoid by adding a braces around the
      if-statement near the for_each_xyz() construct, do so, rather than
      disabling the otherwise potentially useful warning.
      
      (The if-then-else statements used in the "for_each_xyz()" constructs are
      designed to be inherently safe even with no braces, but in this case
      it's quite understandable that gcc isn't really able to tell that).
      
      This finally leaves the standard "allmodconfig" build with just a
      handful of remaining warnings, so new and valid warnings hopefully will
      stand out.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      194dc870
  18. 13 7月, 2016 1 次提交
  19. 15 6月, 2016 1 次提交
    • R
      iommu/vt-d: Don't reject NTB devices due to scope mismatch · ffb2d1eb
      Roland Dreier 提交于
      On a system with an Intel PCIe port configured as an NTB device, iommu
      initialization fails with
      
          DMAR: Device scope type does not match for 0000:80:03.0
      
      This is because the DMAR table reports this device as having scope 2
      (ACPI_DMAR_SCOPE_TYPE_BRIDGE):
      
          [0A0h 0160   1]      Device Scope Entry Type : 02
          [0A1h 0161   1]                 Entry Length : 08
          [0A2h 0162   2]                     Reserved : 0000
          [0A4h 0164   1]               Enumeration ID : 00
          [0A5h 0165   1]               PCI Bus Number : 80
      
          [0A6h 0166   2]                     PCI Path : 03,00
      
      but the device has a type 0 PCI header:
      
          80:03.0 Bridge [0680]: Intel Corporation Device [8086:2f0d] (rev 02)
          00: 86 80 0d 2f 00 00 10 00 02 00 80 06 10 00 80 00
          10: 0c 00 c0 00 c0 38 00 00 0c 00 00 00 80 38 00 00
          20: 00 00 00 c8 00 00 10 c8 00 00 00 00 86 80 00 00
          30: 00 00 00 00 60 00 00 00 00 00 00 00 ff 01 00 00
      
      VT-d works perfectly on this system, so there's no reason to bail out
      on initialization due to this apparent scope mismatch.  Use the class
      0x0680 ("Other bridge device") as a heuristic for allowing DMAR
      initialization for non-bridge PCI devices listed with scope bridge.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      ffb2d1eb
  20. 05 4月, 2016 2 次提交
  21. 01 3月, 2016 1 次提交
  22. 14 1月, 2016 1 次提交
  23. 07 1月, 2016 2 次提交
  24. 15 10月, 2015 1 次提交
  25. 03 8月, 2015 1 次提交
  26. 16 6月, 2015 1 次提交
  27. 24 4月, 2015 1 次提交
    • J
      iommu/vt-d: Refine the interfaces to create IRQ for DMAR unit · 34742db8
      Jiang Liu 提交于
      Refine the interfaces to create IRQ for DMAR unit. It's a preparation
      for converting DMAR IRQ to hierarchical irqdomain on x86.
      
      It also moves dmar_alloc_hwirq()/dmar_free_hwirq() from irq_remapping.h
      to dmar.h. They are not irq_remapping specific.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: David Cohen <david.a.cohen@linux.intel.com>
      Cc: Sander Eikelenboom <linux@eikelenboom.it>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: iommu@lists.linux-foundation.org
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dimitri Sivanich <sivanich@sgi.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Link: http://lkml.kernel.org/r/1428905519-23704-20-git-send-email-jiang.liu@linux.intel.comSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      34742db8
  28. 18 11月, 2014 4 次提交
  29. 02 10月, 2014 1 次提交
    • J
      iommu/vt-d: Work around broken RMRR firmware entries · 80f7b3d1
      Joerg Roedel 提交于
      The VT-d specification states that an RMRR entry in the DMAR
      table needs to specify the full path to the device. This is
      also how newer Linux kernels implement it.
      
      Unfortunatly older drivers just match for the target device
      and not the full path to the device, so that BIOS vendors
      implement that behavior into their BIOSes to make them work
      with older Linux kernels. But those RMRR entries break on
      newer Linux kernels.
      
      Work around this issue by adding a fall-back into the RMRR
      matching code to match those old RMRR entries too.
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      80f7b3d1