1. 09 1月, 2014 11 次提交
    • J
      iommu/vt-d: fix invalid memory access when freeing DMAR irq · b5f36d9e
      Jiang Liu 提交于
      In function free_dmar_iommu(), it sets IRQ handler data to NULL
      before calling free_irq(), which will cause invalid memory access
      because free_irq() will access IRQ handler data when calling
      function dmar_msi_mask(). So only set IRQ handler data to NULL
      after calling free_irq().
      
      Sample stack dump:
      [   13.094010] BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
      [   13.103215] IP: [<ffffffff810a97cd>] __lock_acquire+0x4d/0x12a0
      [   13.110104] PGD 0
      [   13.112614] Oops: 0000 [#1] SMP
      [   13.116585] Modules linked in:
      [   13.120260] CPU: 60 PID: 1 Comm: swapper/0 Tainted: G        W    3.13.0-rc1-gerry+ #9
      [   13.129367] Hardware name: Intel Corporation LH Pass ........../SVRBD-ROW_T, BIOS SE5C600.86B.99.99.x059.091020121352 09/10/2012
      [   13.142555] task: ffff88042dd38010 ti: ffff88042dd32000 task.ti: ffff88042dd32000
      [   13.151179] RIP: 0010:[<ffffffff810a97cd>]  [<ffffffff810a97cd>] __lock_acquire+0x4d/0x12a0
      [   13.160867] RSP: 0000:ffff88042dd33b78  EFLAGS: 00010046
      [   13.166969] RAX: 0000000000000046 RBX: 0000000000000002 RCX: 0000000000000000
      [   13.175122] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000048
      [   13.183274] RBP: ffff88042dd33bd8 R08: 0000000000000002 R09: 0000000000000001
      [   13.191417] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88042dd38010
      [   13.199571] R13: 0000000000000000 R14: 0000000000000048 R15: 0000000000000000
      [   13.207725] FS:  0000000000000000(0000) GS:ffff88103f200000(0000) knlGS:0000000000000000
      [   13.217014] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   13.223596] CR2: 0000000000000048 CR3: 0000000001a0b000 CR4: 00000000000407e0
      [   13.231747] Stack:
      [   13.234160]  0000000000000004 0000000000000046 ffff88042dd33b98 ffffffff810a567d
      [   13.243059]  ffff88042dd33c08 ffffffff810bb14c ffffffff828995a0 0000000000000046
      [   13.251969]  0000000000000000 0000000000000000 0000000000000002 0000000000000000
      [   13.260862] Call Trace:
      [   13.263775]  [<ffffffff810a567d>] ? trace_hardirqs_off+0xd/0x10
      [   13.270571]  [<ffffffff810bb14c>] ? vprintk_emit+0x23c/0x570
      [   13.277058]  [<ffffffff810ab1e3>] lock_acquire+0x93/0x120
      [   13.283269]  [<ffffffff814623f7>] ? dmar_msi_mask+0x47/0x70
      [   13.289677]  [<ffffffff8156b449>] _raw_spin_lock_irqsave+0x49/0x90
      [   13.296748]  [<ffffffff814623f7>] ? dmar_msi_mask+0x47/0x70
      [   13.303153]  [<ffffffff814623f7>] dmar_msi_mask+0x47/0x70
      [   13.309354]  [<ffffffff810c0d93>] irq_shutdown+0x53/0x60
      [   13.315467]  [<ffffffff810bdd9d>] __free_irq+0x26d/0x280
      [   13.321580]  [<ffffffff810be920>] free_irq+0xf0/0x180
      [   13.327395]  [<ffffffff81466591>] free_dmar_iommu+0x271/0x2b0
      [   13.333996]  [<ffffffff810a947d>] ? trace_hardirqs_on+0xd/0x10
      [   13.340696]  [<ffffffff81461a17>] free_iommu+0x17/0x50
      [   13.346597]  [<ffffffff81dc75a5>] init_dmars+0x691/0x77a
      [   13.352711]  [<ffffffff81dc7afd>] intel_iommu_init+0x351/0x438
      [   13.359400]  [<ffffffff81d8a711>] ? iommu_setup+0x27d/0x27d
      [   13.365806]  [<ffffffff81d8a739>] pci_iommu_init+0x28/0x52
      [   13.372114]  [<ffffffff81000342>] do_one_initcall+0x122/0x180
      [   13.378707]  [<ffffffff81077738>] ? parse_args+0x1e8/0x320
      [   13.385016]  [<ffffffff81d850e8>] kernel_init_freeable+0x1e1/0x26c
      [   13.392100]  [<ffffffff81d84833>] ? do_early_param+0x88/0x88
      [   13.398596]  [<ffffffff8154f8b0>] ? rest_init+0xd0/0xd0
      [   13.404614]  [<ffffffff8154f8be>] kernel_init+0xe/0x130
      [   13.410626]  [<ffffffff81574d6c>] ret_from_fork+0x7c/0xb0
      [   13.416829]  [<ffffffff8154f8b0>] ? rest_init+0xd0/0xd0
      [   13.422842] Code: ec 99 00 85 c0 8b 05 53 05 a5 00 41 0f 45 d8 85 c0 0f 84 ff 00 00 00 8b 05 99 f9 7e 01 49 89 fe 41 89 f7 85 c0 0f 84 03 01 00 00 <49> 8b 06 be 01 00 00 00 48 3d c0 0e 01 82 0f 44 de 41 83 ff 01
      [   13.450191] RIP  [<ffffffff810a97cd>] __lock_acquire+0x4d/0x12a0
      [   13.458598]  RSP <ffff88042dd33b78>
      [   13.462671] CR2: 0000000000000048
      [   13.466551] ---[ end trace c5bd26a37c81d760 ]---
      Reviewed-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      b5f36d9e
    • J
      iommu/vt-d, trivial: simplify code with existing macros · 7c919779
      Jiang Liu 提交于
      Simplify vt-d related code with existing macros and introduce a new
      macro for_each_active_drhd_unit() to enumerate all active DRHD unit.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      7c919779
    • J
      iommu/vt-d, trivial: use defined macro instead of hardcoding · 2fe2c602
      Jiang Liu 提交于
      Use defined macro instead of hardcoding in function set_ioapic_sid()
      for readability.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      2fe2c602
    • J
      iommu/vt-d: mark internal functions as static · 694835dc
      Jiang Liu 提交于
      Functions alloc_iommu() and parse_ioapics_under_ir()
      are only used internally, so mark them as static.
      
      [Joerg: Made detect_intel_iommu() non-static again for IA64]
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      694835dc
    • J
      iommu/vt-d, trivial: clean up unused code · b8a2d288
      Jiang Liu 提交于
      Remove dead code from VT-d related files.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      
      Conflicts:
      
      	drivers/iommu/dmar.c
      b8a2d288
    • J
      iommu/vt-d, trivial: check suitable flag in function detect_intel_iommu() · b977e73a
      Jiang Liu 提交于
      Flag irq_remapping_enabled is only set by intel_enable_irq_remapping(),
      which is called after detect_intel_iommu(). So moving pr_info() from
      detect_intel_iommu() to intel_enable_irq_remapping(), which also
      slightly simplifies implementation.
      Reviewed-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      b977e73a
    • J
      iommu/vt-d, trivial: print correct domain id of static identity domain · 9544c003
      Jiang Liu 提交于
      Field si_domain->id is set by iommu_attach_domain(), so we should only
      print domain id for static identity domain after calling
      iommu_attach_domain(si_domain, iommu), otherwise it's always zero.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      9544c003
    • J
      iommu/vt-d, trivial: refine support of 64bit guest address · 5c645b35
      Jiang Liu 提交于
      In Intel IOMMU driver, it calculate page table level from adjusted guest
      address width as 'level = (agaw - 30) / 9', which assumes (agaw -30)
      could be divided by 9. On the other hand, 64bit is a valid agaw and
      (64 - 30) can't be divided by 9, so it needs special handling.
      
      This patch enhances Intel IOMMU driver to correctly handle 64bit agaw.
      It's mainly for code readability because there's no hardware supporting
      64bit agaw yet.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      5c645b35
    • J
      iommu/vt-d: fix resource leakage on error recovery path in iommu_init_domains() · 852bdb04
      Jiang Liu 提交于
      Release allocated resources on error recovery path in function
      iommu_init_domains().
      
      Also improve printk messages in iommu_init_domains().
      Acked-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      852bdb04
    • J
      iommu/vt-d: fix a race window in allocating domain ID for virtual machines · 18d99165
      Jiang Liu 提交于
      Function intel_iommu_domain_init() may be concurrently called by upper
      layer without serialization, so use atomic_t to protect domain id
      allocation.
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      18d99165
    • J
      iommu/vt-d: fix PCI device reference leakage on error recovery path · ada4d4b2
      Jiang Liu 提交于
      Function dmar_parse_dev_scope() should release the PCI device reference
      count gained in function dmar_parse_one_dev_scope() on error recovery,
      otherwise it will cause PCI device object leakage.
      
      This patch also introduces dmar_free_dev_scope(), which will be used
      to support DMAR device hotplug.
      Reviewed-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      ada4d4b2
  2. 08 1月, 2014 1 次提交
    • J
      iommu/vt-d: use dedicated bitmap to track remapping entry allocation status · 360eb3c5
      Jiang Liu 提交于
      Currently Intel interrupt remapping drivers uses the "present" flag bit
      in remapping entry to track whether an entry is allocated or not.
      It works as follow:
      1) allocate a remapping entry and set its "present" flag bit to 1
      2) compose other fields for the entry
      3) update the remapping entry with the composed value
      
      The remapping hardware may access the entry between step 1 and step 3,
      which then observers an entry with the "present" flag set but random
      values in all other fields.
      
      This patch introduces a dedicated bitmap to track remapping entry
      allocation status instead of sharing the "present" flag with hardware,
      thus eliminate the race window. It also simplifies the implementation.
      Tested-and-reviewed-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      360eb3c5
  3. 07 1月, 2014 1 次提交
  4. 30 12月, 2013 3 次提交
  5. 07 12月, 2013 3 次提交
  6. 16 11月, 2013 1 次提交
    • L
      Don't try to compile shmobile-iommu outside of ARM · f63c4824
      Linus Torvalds 提交于
      Commit 7d02c4d6 ("iommu/shmobile: Enable the driver on all ARM
      platforms") completely brokenly enabled the shmobile-iommu driver under
      COMPILE_TEST.
      
      It's bogus, because it won't compile anywhere else than ARM, since it
      tries to include <asm/dma-iommu.h>, which is very much ARM-only.
      
      So remove the bogus COMPILE_TEST dependency, which just causes
      allmodconfig to fail on non-ARM platforms.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: iommu@lists.linux-foundation.org
      Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
      Cc: Simon Horman <horms@verge.net.au>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f63c4824
  7. 15 11月, 2013 1 次提交
  8. 13 11月, 2013 1 次提交
  9. 01 11月, 2013 6 次提交
  10. 31 10月, 2013 1 次提交
    • L
      ACPICA: Update DMAR table definitions. · fa5f508f
      Lv Zheng 提交于
      This patch updates DMAR table header definitions as such enhancement
      has been made in ACPICA upstream already.  It ports that change to
      the Linux source to reduce source code differences between Linux and
      ACPICA upstream.
      
      Build test done on x86-64 machine with the following configs enabled:
        CONFIG_DMAR_TABLE
        CONFIG_IRQ_REMAP
        CONFIG_INTEL_IOMMU
      
      This patch does not affect the generation of the Linux kernel binary.
      
      [rjw: Changelog]
      Signed-off-by: NLv Zheng <lv.zheng@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      fa5f508f
  11. 09 10月, 2013 7 次提交
  12. 05 10月, 2013 1 次提交
    • T
      x86, build, pci: Fix PCI_MSI build on !SMP · 0dbc6078
      Thomas Petazzoni 提交于
      Commit ebd97be6 ('PCI: remove ARCH_SUPPORTS_MSI kconfig option')
      removed the ARCH_SUPPORTS_MSI option which architectures could select
      to indicate that they support MSI. Now, all architectures are supposed
      to build fine when MSI support is enabled: instead of having the
      architecture tell *when* MSI support can be used, it's up to the
      architecture code to ensure that MSI support can be enabled.
      
      On x86, commit ebd97be6 removed the following line:
      
        select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
      
      Which meant that MSI support was only available when the local APIC
      and I/O APIC were enabled. While this is always true on SMP or x86-64,
      it is not necessarily the case on i386 !SMP.
      
      The below patch makes sure that the local APIC and I/O APIC support is
      always enabled when MSI support is enabled. To do so, it:
      
       * Ensures the X86_UP_APIC option is not visible when PCI_MSI is
         enabled. This is the option that allows, on UP machines, to enable
         or not the APIC support. It is already not visible on SMP systems,
         or x86-64 systems, for example. We're simply also making it
         invisible on i386 MSI systems.
      
       * Ensures that the X86_LOCAL_APIC and X86_IO_APIC options are 'y'
         when PCI_MSI is enabled.
      
      Notice that this change requires a change in drivers/iommu/Kconfig to
      avoid a recursive Kconfig dependencey. The AMD_IOMMU option selects
      PCI_MSI, but was depending on X86_IO_APIC. This dependency is no
      longer needed: as soon as PCI_MSI is selected, the presence of
      X86_IO_APIC is guaranteed. Moreover, the AMD_IOMMU already depended on
      X86_64, which already guaranteed that X86_IO_APIC was enabled, so this
      dependency was anyway redundant.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Link: http://lkml.kernel.org/r/1380794354-9079-1-git-send-email-thomas.petazzoni@free-electrons.comReported-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      0dbc6078
  13. 04 10月, 2013 1 次提交
    • N
      iommu: Remove stack trace from broken irq remapping warning · 05104a4e
      Neil Horman 提交于
      The warning for the irq remapping broken check in intel_irq_remapping.c is
      pretty pointless.  We need the warning, but we know where its comming from, the
      stack trace will always be the same, and it needlessly triggers things like
      Abrt.  This changes the warning to just print a text warning about BIOS being
      broken, without the stack trace, then sets the appropriate taint bit.  Since we
      automatically disable irq remapping, theres no need to contiue making Abrt jump
      at this problem
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      CC: Joerg Roedel <joro@8bytes.org>
      CC: Bjorn Helgaas <bhelgaas@google.com>
      CC: Andy Lutomirski <luto@amacapital.net>
      CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      CC: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
      Signed-off-by: NJoerg Roedel <joro@8bytes.org>
      05104a4e
  14. 25 9月, 2013 1 次提交
  15. 24 9月, 2013 1 次提交