From patchwork Fri Apr 25 00:36:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sumner, William" X-Patchwork-Id: 4056841 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AD9E89F1F4 for ; Fri, 25 Apr 2014 00:40:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F1F220380 for ; Fri, 25 Apr 2014 00:40:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C305220382 for ; Fri, 25 Apr 2014 00:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751732AbaDYAh6 (ORCPT ); Thu, 24 Apr 2014 20:37:58 -0400 Received: from g9t1613g.houston.hp.com ([15.240.0.71]:59654 "EHLO g9t1613g.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751497AbaDYAhY (ORCPT ); Thu, 24 Apr 2014 20:37:24 -0400 Received: from g5t1626.atlanta.hp.com (g5t1626.atlanta.hp.com [15.192.137.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by g9t1613g.houston.hp.com (Postfix) with ESMTPS id 6976361207; Fri, 25 Apr 2014 00:37:24 +0000 (UTC) Received: from g5t1633.atlanta.hp.com (g5t1633.atlanta.hp.com [16.201.144.132]) by g5t1626.atlanta.hp.com (Postfix) with ESMTP id 39EAC26A; Fri, 25 Apr 2014 00:36:51 +0000 (UTC) Received: from lxbuild.fcux.usa.hp.com (unknown [16.78.34.175]) by g5t1633.atlanta.hp.com (Postfix) with ESMTP id 58B3963; Fri, 25 Apr 2014 00:36:50 +0000 (UTC) From: Bill Sumner To: dwmw2@infradead.org, indou.takao@jp.fujitsu.com, bhe@redhat.com, joro@8bytes.org Cc: iommu@lists.linux-foundation.org, kexec@lists.infradead.org, alex.williamson@redhat.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ddutile@redhat.com, ishii.hironobu@jp.fujitsu.com, bhelgaas@google.com, bill.sumner@hp.com, doug.hatch@hp.com, zhenhua@hp.com, jerry.hoemann@hp.com Subject: [PATCH 5/8] iommu/vt-d: Items required for kdump Date: Thu, 24 Apr 2014 18:36:35 -0600 Message-Id: <1398386198-19304-6-git-send-email-bill.sumner@hp.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1398386198-19304-1-git-send-email-bill.sumner@hp.com> References: <1398386198-19304-1-git-send-email-bill.sumner@hp.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add data declarations and prototypes needed for kdump. Signed-off-by: Bill Sumner --- drivers/iommu/intel-iommu-private.h | 94 +++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/drivers/iommu/intel-iommu-private.h b/drivers/iommu/intel-iommu-private.h index 480399c..3f20234 100644 --- a/drivers/iommu/intel-iommu-private.h +++ b/drivers/iommu/intel-iommu-private.h @@ -361,3 +361,97 @@ static inline void free_pgtable_page(void *vaddr) { free_page((unsigned long)vaddr); } + +#ifdef CONFIG_CRASH_DUMP +/* + * Fix Crashdump failure caused by leftover DMA through a hardware IOMMU + * + * Fixes the crashdump kernel to deal with an active iommu and legacy + * DMA from the (old) panicked kernel in a manner similar to how legacy + * DMA is handled when no hardware iommu was in use by the old kernel -- + * allow the legacy DMA to continue into its current buffers. + * + * In the crashdump kernel, this code: + * 1. skips disabling the IOMMU's translating of IO Virtual Addresses (IOVA) + * 2. leaves the current translations in-place so that legacy DMA will + * continue to use its current buffers, + * 3. allocates to the device drivers in the crashdump kernel + * portions of the iova address ranges that are different + * from the iova address ranges that were being used by the old kernel + * at the time of the panic. + * + */ + +struct domain_values_entry { + struct list_head link; /* link entries into a list */ + struct iova_domain iovad; /* iova's that belong to this domain */ + struct dma_pte *pgd; /* virtual address */ + int did; /* domain id */ + int gaw; /* max guest address width */ + int iommu_superpage; /* Level of superpages supported: + 0 == 4KiB (no superpages), 1 == 2MiB, + 2 == 1GiB, 3 == 512GiB, 4 == 1TiB */ +}; + + + +/* ------------------------------------------------------------------------ + * Prototypes of interface functions + * ------------------------------------------------------------------------ + */ + +extern int +intel_iommu_copy_translation_tables(struct dmar_drhd_unit *drhd, + struct root_entry **root_old_p, struct root_entry **root_new_p, + int g_num_of_iommus); + +extern int +intel_iommu_get_dids_from_old_kernel(struct intel_iommu *iommu); + +extern struct domain_values_entry * +intel_iommu_did_to_domain_values_entry(int did, struct intel_iommu *iommu); + + +/* ------------------------------------------------------------------------ + * Utility functions for accessing the iommu Translation Tables + * ------------------------------------------------------------------------ + */ + +static inline struct context_entry * +get_context_phys_from_root(struct root_entry *root) +{ + return (struct context_entry *) + (root_present(root) ? (void *) (root->val & VTD_PAGE_MASK) + : NULL); +} + +static inline int +context_get_p(struct context_entry *c) {return((c->lo >> 0) & 0x1); } + +static inline int +context_get_fpdi(struct context_entry *c) {return((c->lo >> 1) & 0x1); } + +static inline int +context_get_t(struct context_entry *c) {return((c->lo >> 2) & 0x3); } + +static inline u64 +context_get_asr(struct context_entry *c) {return((c->lo >> 12)); } + +static inline int +context_get_aw(struct context_entry *c) {return((c->hi >> 0) & 0x7); } + +static inline int +context_get_aval(struct context_entry *c) {return((c->hi >> 3) & 0xf); } + +static inline int +context_get_did(struct context_entry *c) {return((c->hi >> 8) & 0xffff); } + +static inline void +context_put_asr(struct context_entry *c, unsigned long asr) +{ + c->lo &= (~VTD_PAGE_MASK); + c->lo |= (asr << VTD_PAGE_SHIFT); +} + +#endif /* CONFIG_CRASH_DUMP */ +