x86 fixes for 2.6.34
Subsystems (3)
Linus,
Please pull the latest x86-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-fixes-for-linus
out-of-topic modifications in x86-fixes-for-linus:
--------------------------------------------------lib/dma-debug.c # 39a37ce: dma-debug: Cleanup for copy-loop
Thanks,
tglx
------------------>
Chris Wright (5):
x86/amd-iommu: Pt mode fix for domain_destroy x86/amd-iommu: enable iommu before attaching devices x86/amd-iommu: warn when issuing command to uninitialized cmd buffer Revert "x86: disable IOMMUs on kernel crash" x86/amd-iommu: use for_each_pci_dev
Dan Carpenter (1):
dma-debug: Cleanup for copy-loop in filter_write()
Joerg Roedel (5):
x86/amd-iommu: Protect IOMMU-API map/unmap path x86/amd-iommu: Report errors in acpi parsing functions upstream x86/amd-iommu: Use helper function to destroy domain x86/amd-iommu: Remove obsolete parameter documentation x86/gart: Disable GART explicitly before initialization
Julia Lawall (1):
x86/amd-iommu: Remove double NULL check in check_device
Documentation/kernel-parameters.txt | 5 --- arch/x86/include/asm/amd_iommu_types.h | 3 ++ arch/x86/kernel/amd_iommu.c | 20 +++++++++---- arch/x86/kernel/amd_iommu_init.c | 48 ++++++++++++++++++++++---------- arch/x86/kernel/aperture_64.c | 15 +++++++++- arch/x86/kernel/crash.c | 6 ---- arch/x86/kernel/pci-gart_64.c | 3 ++ lib/dma-debug.c | 2 +- 8 files changed, 68 insertions(+), 34 deletions(-)
Documentation/kernel-parameters.txt +0 -5
@@ -320,11 +320,6 @@ and is between 256 and 4096 characters. It is defined in the file amd_iommu= [HW,X86-84] Pass parameters to the AMD IOMMU driver in the system. Possible values are: - isolate - enable device isolation (each device, as far - as possible, will get its own protection - domain) [default] - share - put every device behind one IOMMU into the - same protection domain fullflush - enable flushing of IO/TLB entries when they are unmapped. Otherwise they are flushed before they will be reused, which
arch/x86/include/asm/amd_iommu_types.h +3 -0
@@ -21,6 +21,7 @@#define _ASM_X86_AMD_IOMMU_TYPES_H#include <linux/types.h> +#include <linux/mutex.h> #include <linux/list.h> #include <linux/spinlock.h>
@@ -140,6 +141,7 @@/* constants to configure the command buffer */ #define CMD_BUFFER_SIZE 8192 +#define CMD_BUFFER_UNINITIALIZED 1#define CMD_BUFFER_ENTRIES 512#define MMIO_CMD_SIZE_SHIFT 56#define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
@@ -237,6 +239,7 @@ struct protection_domain {struct list_head list;/* for list of all protection domains */ struct list_head dev_list;/* List of all devices in this domain */ spinlock_t lock;/* mostly used to lock the page table*/ +struct mutex api_lock;/* protect page tables in the iommu-api path */ u16 id;/* the domain id written to the device table */ int mode;/* paging mode (0-6 levels) */ u64 *pt_root;/* page table root pointer */
arch/x86/kernel/amd_iommu.c +14 -6
@@ -118,7 +118,7 @@ static bool check_device(struct device *dev)return false;/* No device or no PCI device */ -if (!dev || dev->bus != &pci_bus_type) +if (dev->bus != &pci_bus_type)return false; devid =get_device_id (dev);
@@ -392,6 +392,7 @@ static int __iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)u32 tail, head;u8 *target; +WARN_ON (iommu->cmd_buf_size &CMD_BUFFER_UNINITIALIZED ); tail =readl (iommu->mmio_base +MMIO_CMD_TAIL_OFFSET ); target = iommu->cmd_buf + tail;memcpy_toio (target, cmd,sizeof (*cmd));
@@ -2186,7 +2187,7 @@ static void prealloc_protection_domains(void)struct dma_ops_domain *dma_dom;u16 devid; -while ((dev =pci_get_device (PCI_ANY_ID ,PCI_ANY_ID , dev)) !=NULL ) { +for_each_pci_dev (dev) {/* Do we handle this device? */ if (!check_device (&dev->dev))
@@ -2298,7 +2299,7 @@ static void cleanup_domain(struct protection_domain *domain)list_for_each_entry_safe (dev_data, next, &domain->dev_list, list) {struct device *dev = dev_data->dev; -do_detach (dev); +__detach_device (dev);atomic_set (&dev_data->bind,0 ); }
@@ -2327,6 +2328,7 @@ static struct protection_domain *protection_domain_alloc(void)return NULL ;spin_lock_init (&domain->lock); +mutex_init (&domain->api_lock); domain->id =domain_id_alloc ();if (!domain->id) goto out_err;
@@ -2379,9 +2381,7 @@ static void amd_iommu_domain_destroy(struct iommu_domain *dom)free_pagetable (domain); -domain_id_free (domain->id); - -kfree (domain); +protection_domain_free (domain); dom->priv =NULL ; }
@@ -2456,6 +2456,8 @@ static int amd_iommu_map_range(struct iommu_domain *dom, iova &=PAGE_MASK ; paddr &=PAGE_MASK ; +mutex_lock (&domain->api_lock); +for (i =0 ; i < npages; ++i) { ret =iommu_map_page (domain, iova, paddr, prot, PM_MAP_4k);if (ret)
@@ -2465,6 +2467,8 @@ static int amd_iommu_map_range(struct iommu_domain *dom, paddr +=PAGE_SIZE ; } +mutex_unlock (&domain->api_lock); +return 0 ; }
@@ -2477,12 +2481,16 @@ static void amd_iommu_unmap_range(struct iommu_domain *dom, iova &=PAGE_MASK ; +mutex_lock (&domain->api_lock); +for (i =0 ; i < npages; ++i) {iommu_unmap_page (domain, iova, PM_MAP_4k); iova +=PAGE_SIZE ; }iommu_flush_tlb_pde (domain); + +mutex_unlock (&domain->api_lock); } static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
arch/x86/kernel/amd_iommu_init.c +33 -15
127 lines not on this page · raw message
arch/x86/kernel/aperture_64.c +14 -1
@@ -393,6 +393,7 @@ void __init gart_iommu_hole_init(void)for (i =0 ; i <ARRAY_SIZE (bus_dev_ranges); i++) {int bus;int dev_base, dev_limit; +u32 ctl; bus = bus_dev_ranges[i].bus; dev_base = bus_dev_ranges[i].dev_base;
@@ -406,7 +407,19 @@ void __init gart_iommu_hole_init(void) gart_iommu_aperture =1 ; x86_init.iommu.iommu_init = gart_iommu_init; - aper_order = (read_pci_config (bus, slot,3 ,AMD64_GARTAPERTURECTL ) >>1 ) &7 ; + ctl =read_pci_config (bus, slot,3 , +AMD64_GARTAPERTURECTL ); + +/* +* Before we do anything else disable the GART. It may +* still be enabled if we boot into a crash-kernel here. +* Reconfiguring the GART while it is enabled could have +* unknown side-effects. +*/ + ctl &= ~GARTEN ; +write_pci_config (bus, slot,3 ,AMD64_GARTAPERTURECTL , ctl); + + aper_order = (ctl >>1 ) &7 ; aper_size = (32 *1024 *1024 ) << aper_order; aper_base =read_pci_config (bus, slot,3 ,AMD64_GARTAPERTUREBASE ) &0x7fff ; aper_base <<=25 ;
arch/x86/kernel/crash.c +0 -6
@@ -27,7 +27,6 @@#include <asm/cpu.h> #include <asm/reboot.h> #include <asm/virtext.h> -#include <asm/x86_init.h> #if defined(CONFIG_SMP ) && defined(CONFIG_X86_LOCAL_APIC )
@@ -103,10 +102,5 @@ void native_machine_crash_shutdown(struct pt_regs *regs)#ifdef CONFIG_HPET_TIMER hpet_disable ();#endif - -#ifdef CONFIG_X86_64 - x86_platform.iommu_shutdown (); -#endif -crash_save_cpu (regs,safe_smp_processor_id ()); }
arch/x86/kernel/pci-gart_64.c +3 -0
@@ -565,6 +565,9 @@ static void enable_gart_translations(void)enable_gart_translation (dev,__pa (agp_gatt_table)); } + +/* Flush the GART-TLB to remove stale entries */ +k8_flush_garts (); }/*
lib/dma-debug.c +1 -1
@@ -570,7 +570,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,* Now parse out the first token and use it as the name for the * driver to filter for. */ -for (i =0 ; i <NAME_MAX_LEN ; ++i) { +for (i =0 ; i <NAME_MAX_LEN -1 ; ++i) { current_driver_name[i] = buf[i];if (isspace (buf[i]) || buf[i] ==' ' || buf[i] ==0 )break ;