static void iommu_set_irq_remapping(struct intel_iommu *iommu, int mode) { unsigned long flags; u64 addr; u32 sts; addr = virt_to_phys((void *)iommu->ir_table->base); raw_spin_lock_irqsave(&iommu->register_lock, flags); dmar_writeq(iommu->reg + DMAR_IRTA_REG, (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE); /* Set interrupt-remapping table pointer */ writel(iommu->gcmd | DMA_GCMD_SIRTP, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRTPS), sts); raw_spin_unlock_irqrestore(&iommu->register_lock, flags); /* * Global invalidation of interrupt entry cache to make sure the * hardware uses the new irq remapping table. */ qi_global_iec(iommu); }
static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode) { u64 addr; u32 sts; unsigned long flags; addr = virt_to_phys((void *)iommu->ir_table->base); raw_spin_lock_irqsave(&iommu->register_lock, flags); dmar_writeq(iommu->reg + DMAR_IRTA_REG, (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE); iommu->gcmd |= DMA_GCMD_SIRTP; writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRTPS), sts); raw_spin_unlock_irqrestore(&iommu->register_lock, flags); qi_global_iec(iommu); raw_spin_lock_irqsave(&iommu->register_lock, flags); iommu->gcmd |= DMA_GCMD_IRE; writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRES), sts); raw_spin_unlock_irqrestore(&iommu->register_lock, flags); }
static void iommu_set_irq_remapping(struct intel_iommu *iommu, int mode) { u64 addr; u32 sts; unsigned long flags; addr = virt_to_phys((void *)iommu->ir_table->base); raw_spin_lock_irqsave(&iommu->register_lock, flags); dmar_writeq(iommu->reg + DMAR_IRTA_REG, (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE); /* Set interrupt-remapping table pointer */ iommu->gcmd |= DMA_GCMD_SIRTP; writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRTPS), sts); raw_spin_unlock_irqrestore(&iommu->register_lock, flags); /* * global invalidation of interrupt entry cache before enabling * interrupt-remapping. */ qi_global_iec(iommu); raw_spin_lock_irqsave(&iommu->register_lock, flags); /* Enable interrupt-remapping */ iommu->gcmd |= DMA_GCMD_IRE; iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format MSIs */ writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRES), sts); /* * With CFI clear in the Global Command register, we should be * protected from dangerous (i.e. compatibility) interrupts * regardless of x2apic status. Check just to be sure. */ if (sts & DMA_GSTS_CFIS) WARN(1, KERN_WARNING "Compatibility-format IRQs enabled despite intr remapping;\n" "you are vulnerable to IRQ injection.\n"); raw_spin_unlock_irqrestore(&iommu->register_lock, flags); }
static void iommu_set_intr_remapping(struct intel_iommu *iommu, int mode) { u64 addr; u32 cmd, sts; unsigned long flags; addr = virt_to_phys((void *)iommu->ir_table->base); spin_lock_irqsave(&iommu->register_lock, flags); dmar_writeq(iommu->reg + DMAR_IRTA_REG, (addr) | IR_X2APIC_MODE(mode) | INTR_REMAP_TABLE_REG_SIZE); /* Set interrupt-remapping table pointer */ cmd = iommu->gcmd | DMA_GCMD_SIRTP; writel(cmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRTPS), sts); spin_unlock_irqrestore(&iommu->register_lock, flags); /* * global invalidation of interrupt entry cache before enabling * interrupt-remapping. */ qi_global_iec(iommu); spin_lock_irqsave(&iommu->register_lock, flags); /* Enable interrupt-remapping */ cmd = iommu->gcmd | DMA_GCMD_IRE; iommu->gcmd |= DMA_GCMD_IRE; writel(cmd, iommu->reg + DMAR_GCMD_REG); IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, readl, (sts & DMA_GSTS_IRES), sts); spin_unlock_irqrestore(&iommu->register_lock, flags); }