Linux IOMMU Development
 help / color / mirror / Atom feed
From: "Li, Zhen-Hua" <zhen-hual-VXdhtT5mjnY@public.gmane.org>
To: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	indou.takao-+CUm20s59erQFUHtdCDX3A@public.gmane.org,
	bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: tom.vaden-VXdhtT5mjnY@public.gmane.org,
	linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	lisa.mitchell-VXdhtT5mjnY@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	zhen-hual-VXdhtT5mjnY@public.gmane.org,
	doug.hatch-VXdhtT5mjnY@public.gmane.org,
	ishii.hironobu-+CUm20s59erQFUHtdCDX3A@public.gmane.org,
	bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	billsumnerlinux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	li.zhang6-VXdhtT5mjnY@public.gmane.org
Subject: [PATCH 0/10] iommu/vt-d: Fix intel vt-d faults in kdump kernel
Date: Mon, 22 Dec 2014 17:15:19 +0800	[thread overview]
Message-ID: <1419239729-26529-1-git-send-email-zhen-hual@hp.com> (raw)

This patchset is an update of Bill Sumner's patchset, implements a fix for:
If a kernel boots with intel_iommu=on on a system that supports intel vt-d, 
when a panic happens, the kdump kernel will boot with these faults:

    dmar: DRHD: handling fault status reg 102
    dmar: DMAR:[DMA Read] Request device [01:00.0] fault addr fff80000
    DMAR:[fault reason 01] Present bit in root entry is clear

    dmar: DRHD: handling fault status reg 2
    dmar: INTR-REMAP: Request device [[61:00.0] fault index 42
    INTR-REMAP:[fault reason 34] Present field in the IRTE entry is clear

On some system, the interrupt remapping fault will also happen even if the 
intel_iommu is not set to on, because the interrupt remapping will be enabled 
when x2apic is needed by the system.

The cause of the DMA fault is described in Bill's original version, and the 
INTR-Remap fault is caused by a similar reason. In short, the initialization 
of vt-d drivers causes the in-flight DMA and interrupt requests get wrong 
response.

To fix this problem, we modifies the behaviors of the intel vt-d in the 
crashdump kernel:

For DMA Remapping:
1. To accept the vt-d hardware in an active state,
2. Do not disable and re-enable the translation, keep it enabled.
3. Use the old root entry table, do not rewrite the RTA register.
4. Malloc and use new context entry table and page table, copy data from the 
   old ones that used by the old kernel.
5. to use different portions of the iova address ranges for the device drivers
   in the crashdump kernel than the iova ranges that were in-use at the time
   of the panic.  
6. After device driver is loaded, when it issues the first dma_map command, 
   free the dmar_domain structure for this device, and generate a new one, so 
   that the device can be assigned a new and empty page table. 
7. When a new context entry table is generated, we also save its address to 
   the old root entry table.

For Interrupt Remapping:
1. To accept the vt-d hardware in an active state,
2. Do not disable and re-enable the interrupt remapping, keep it enabled.
3. Use the old interrupt remapping table, do not rewrite the IRTA register.
4. When ioapic entry is setup, the interrupt remapping table is changed, and 
   the updated data will be stored to the old interrupt remapping table.

Advantages of this approach:
1. All manipulation of the IO-device is done by the Linux device-driver
   for that device.
2. This approach behaves in a manner very similar to operation without an
   active iommu.
3. Any activity between the IO-device and its RMRR areas is handled by the
   device-driver in the same manner as during a non-kdump boot.
4. If an IO-device has no driver in the kdump kernel, it is simply left alone.
   This supports the practice of creating a special kdump kernel without
   drivers for any devices that are not required for taking a crashdump. 
5. Minimal code-changes among the existing mainline intel vt-d code.

Summary of changes in this patch set:
1. Added some useful function for root entry table in code intel-iommu.c
2. Added new members to struct root_entry and struct irte;
3. Functions to load old root entry table to iommu->root_entry from the memory 
   of old kernel.
4. Functions to malloc new context entry table and page table and copy the data
   from the old ones to the malloced new ones.
5. Functions to enable support for DMA remapping in kdump kernel.
6. Functions to load old irte data from the old kernel to the kdump kernel.
7. Some code changes that support other behaviours that have been listed.
8. In the new functions, use physical address as "unsigned long" type, not 
   pointers.

Original version by Bill Sumner:
    https://lkml.org/lkml/2014/1/10/518
    https://lkml.org/lkml/2014/4/15/716
    https://lkml.org/lkml/2014/4/24/836

Zhenhua's last of Bill's patchset:
    https://lkml.org/lkml/2014/10/21/134
    https://lkml.org/lkml/2014/12/15/121

Changed in this version:
1. Do not disable and re-enable traslation and interrupt remapping. 
2. Use old root entry table.
3. Use old interrupt remapping table.
4. Use "unsigned long" as physical address.
5. Use intel_unmap to unmap the old dma;

This patchset should be applied with this one together:
    https://lkml.org/lkml/2014/11/5/43
    x86/iommu: fix incorrect bit operations in setting values

Bill Sumner (5):
  iommu/vt-d: Update iommu_attach_domain() and its callers
  iommu/vt-d: Items required for kdump
  iommu/vt-d: data types and functions used for kdump
  iommu/vt-d: Add domain-id functions
  iommu/vt-d: enable kdump support in iommu module

Li, Zhen-Hua (10):
  iommu/vt-d: Update iommu_attach_domain() and its callers
  iommu/vt-d: Items required for kdump
  iommu/vt-d: Add domain-id functions
  iommu/vt-d: functions to copy data from old mem
  iommu/vt-d: Add functions to load and save old re
  iommu/vt-d: datatypes and functions used for kdump
  iommu/vt-d: enable kdump support in iommu module
  iommu/vtd: assign new page table for dma_map
  iommu/vt-d: Copy functions for irte
  iommu/vt-d: Use old irte in kdump kernel

 drivers/iommu/intel-iommu.c         | 1050 +++++++++++++++++++++++++++++++++--
 drivers/iommu/intel_irq_remapping.c |   99 +++-
 include/linux/intel-iommu.h         |   18 +
 3 files changed, 1123 insertions(+), 44 deletions(-)

-- 
2.0.0-rc0

             reply	other threads:[~2014-12-22  9:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22  9:15 Li, Zhen-Hua [this message]
     [not found] ` <1419239729-26529-1-git-send-email-zhen-hual-VXdhtT5mjnY@public.gmane.org>
2014-12-22  9:15   ` [PATCH 01/10] iommu/vt-d: Update iommu_attach_domain() and its callers Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 02/10] iommu/vt-d: Items required for kdump Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 03/10] iommu/vt-d: Add domain-id functions Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 04/10] iommu/vt-d: functions to copy data from old mem Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 05/10] iommu/vt-d: Add functions to load and save old re Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 06/10] iommu/vt-d: datatypes and functions used for kdump Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 07/10] iommu/vt-d: enable kdump support in iommu module Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 08/10] iommu/vtd: assign new page table for dma_map Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 09/10] iommu/vt-d: Copy functions for irte Li, Zhen-Hua
2014-12-22  9:15   ` [PATCH 10/10] iommu/vt-d: Use old irte in kdump kernel Li, Zhen-Hua
2014-12-26  5:13   ` [PATCH 0/10] iommu/vt-d: Fix intel vt-d faults " Takao Indoh
2014-12-26  6:46     ` Li, ZhenHua
2014-12-26  7:27       ` Takao Indoh
     [not found]         ` <549D0DEE.8000301-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2014-12-29  3:15           ` Li, ZhenHua
2015-01-06  0:18             ` Takao Indoh
     [not found]               ` <54AB29E6.6070403-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2015-01-06  2:04                 ` Li, ZhenHua
2015-01-06  6:37   ` Baoquan He
2015-01-06  7:05     ` Li, ZhenHua
2014-12-22  9:43 ` Li, ZhenHua
  -- strict thread matches above, loose matches on Subject: below --
2014-12-15  9:52 Li, Zhen-Hua

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419239729-26529-1-git-send-email-zhen-hual@hp.com \
    --to=zhen-hual-vxdhtt5mjny@public.gmane.org \
    --cc=bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=billsumnerlinux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=doug.hatch-VXdhtT5mjnY@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=indou.takao-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=ishii.hironobu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
    --cc=kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=li.zhang6-VXdhtT5mjnY@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lisa.mitchell-VXdhtT5mjnY@public.gmane.org \
    --cc=tom.vaden-VXdhtT5mjnY@public.gmane.org \
    --cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox