Skip to contentSkip to conversation

x86 fixes

GIT PULL Ingo Molnar 3 participants 5 messages Dec 20, 2008 x86

lore
Share & tools
lore
#0 lore raw

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

Thanks,

Ingo

------------------>
Andi Kleen (1):
x86: re-enable MCE on secondary CPUS after suspend/resume

Bjorn Helgaas (1):
x86 gart: don't complain if no AMD GART found

Dmitry Adamushko (1):
x86: fix resume (S2R) broken by Intel microcode module, on A110L

Joerg Roedel (3):
AMD IOMMU: allocate rlookup_table with __GFP_ZERO AMD IOMMU: set cmd buffer pointers to zero manually AMD IOMMU: panic if completion wait loop fails

 arch/x86/kernel/amd_iommu.c         |    5 +++--
 arch/x86/kernel/amd_iommu_init.c    |    7 ++++++-
 arch/x86/kernel/cpu/mcheck/mce_64.c |    3 ---
 arch/x86/kernel/microcode_core.c    |   19 ++++++++++++++-----
 arch/x86/kernel/microcode_intel.c   |    6 ++++++
 arch/x86/kernel/pci-gart_64.c       |    4 +---
 6 files changed, 30 insertions(+), 14 deletions(-)
arch/x86/kernel/amd_iommu.c +3 -2
index a7b6dec..0a60d60 100644
@@ -235,8 +235,9 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
 	status &= ~MMIO_STATUS_COM_WAIT_INT_MASK;
 	writel(status, iommu->mmio_base + MMIO_STATUS_OFFSET);
 
-	if (unlikely((i == EXIT_LOOP_COUNT) && printk_ratelimit()))
-		printk(KERN_WARNING "AMD IOMMU: Completion wait loop failed\n");
+	if (unlikely(i == EXIT_LOOP_COUNT))
+		panic("AMD IOMMU: Completion wait loop failed\n");
+
 out:
 	spin_unlock_irqrestore(&iommu->lock, flags);
 
arch/x86/kernel/amd_iommu_init.c +6 -1
index 30ae270..c6cc228 100644
@@ -427,6 +427,10 @@ static u8 * __init alloc_command_buffer(struct amd_iommu *iommu)
 	memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET,
 			&entry, sizeof(entry));
 
+	/* set head and tail to zero manually */
+	writel(0x00, iommu->mmio_base + MMIO_CMD_HEAD_OFFSET);
+	writel(0x00, iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
+
 	iommu_feature_enable(iommu, CONTROL_CMDBUF_EN);
 
 	return cmd_buf;
@@ -1074,7 +1078,8 @@ int __init amd_iommu_init(void)
 		goto free;
 
 	/* IOMMU rlookup table - find the IOMMU for a specific device */
-	amd_iommu_rlookup_table = (void *)__get_free_pages(GFP_KERNEL,
+	amd_iommu_rlookup_table = (void *)__get_free_pages(
+			GFP_KERNEL | __GFP_ZERO,
 			get_order(rlookup_table_size));
 	if (amd_iommu_rlookup_table == NULL)
 		goto free;
arch/x86/kernel/cpu/mcheck/mce_64.c +0 -3
index 4b031a4..1c83803 100644
@@ -510,12 +510,9 @@ static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c)
  */
 void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
 {
-	static cpumask_t mce_cpus = CPU_MASK_NONE;
-
 	mce_cpu_quirks(c);
 
 	if (mce_dont_init ||
-	    cpu_test_and_set(smp_processor_id(), mce_cpus) ||
 	    !mce_available(c))
 		return;
 
arch/x86/kernel/microcode_core.c +14 -5
index 82fb280..c4b5b24 100644
@@ -272,13 +272,18 @@ static struct attribute_group mc_attr_group = {
 	.name = "microcode",
 };
 
-static void microcode_fini_cpu(int cpu)
+static void __microcode_fini_cpu(int cpu)
 {
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 
-	mutex_lock(&microcode_mutex);
 	microcode_ops->microcode_fini_cpu(cpu);
 	uci->valid = 0;
+}
+
+static void microcode_fini_cpu(int cpu)
+{
+	mutex_lock(&microcode_mutex);
+	__microcode_fini_cpu(cpu);
 	mutex_unlock(&microcode_mutex);
 }
 
@@ -306,12 +311,16 @@ static int microcode_resume_cpu(int cpu)
 	 * to this cpu (a bit of paranoia):
 	 */
 	if (microcode_ops->collect_cpu_info(cpu, &nsig)) {
-		microcode_fini_cpu(cpu);
+		__microcode_fini_cpu(cpu);
+		printk(KERN_ERR "failed to collect_cpu_info for resuming cpu #%d\n",
+				cpu);
 		return -1;
 	}
 
-	if (memcmp(&nsig, &uci->cpu_sig, sizeof(nsig))) {
-		microcode_fini_cpu(cpu);
+	if ((nsig.sig != uci->cpu_sig.sig) || (nsig.pf != uci->cpu_sig.pf)) {
+		__microcode_fini_cpu(cpu);
+		printk(KERN_ERR "cached ucode doesn't match the resuming cpu #%d\n",
+				cpu);
 		/* Should we look for a new ucode here? */
 		return 1;
 	}
arch/x86/kernel/microcode_intel.c +6 -0
index 622dc4a..a8e6279 100644
@@ -155,6 +155,7 @@ static DEFINE_SPINLOCK(microcode_update_lock);
 static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)
 {
 	struct cpuinfo_x86 *c = &cpu_data(cpu_num);
+	unsigned long flags;
 	unsigned int val[2];
 
 	memset(csig, 0, sizeof(*csig));
@@ -174,11 +175,16 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)
 		csig->pf = 1 << ((val[1] >> 18) & 7);
 	}
 
+	/* serialize access to the physical write to MSR 0x79 */
+	spin_lock_irqsave(&microcode_update_lock, flags);
+
 	wrmsr(MSR_IA32_UCODE_REV, 0, 0);
 	/* see notes above for revision 1.07.  Apparent chip bug */
 	sync_core();
 	/* get the current revision from MSR 0x8B */
 	rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev);
+	spin_unlock_irqrestore(&microcode_update_lock, flags);
+
 	pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
 			csig->sig, csig->pf, csig->rev);
 
arch/x86/kernel/pci-gart_64.c +1 -3
index ba7ad83..a35eaa3 100644
@@ -745,10 +745,8 @@ void __init gart_iommu_init(void)
 	unsigned long scratch;
 	long i;
 
-	if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) {
-		printk(KERN_INFO "PCI-GART: No AMD GART found.\n");
+	if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0)
 		return;
-	}
 
 #ifndef CONFIG_AGP_AMD64
 	no_agp = 1;
#1 lore raw
Quoted 3 lines · Ingo Molnar

Joerg Roedel (3):
AMD IOMMU: panic if completion wait loop fails

What's the advantage to this, especially this late in the game?

Now, I tried to google for the message (while ignoring the patches), and as far as I can tell, it has never happened that google has noticed. But still, why was this pushed as a "fix"?

Linus

#2 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 3 lines · Ingo Molnar

Joerg Roedel (3):
AMD IOMMU: panic if completion wait loop fails

What's the advantage to this, especially this late in the game?

Now, I tried to google for the message (while ignoring the patches), and as far as I can tell, it has never happened that google has noticed. But still, why was this pushed as a "fix"?

You are right, this patch should have been delayed to .29. Should i rebase the branch?

Joerg has been doing stress-tests of the iommu driver and these fixes are the result of that. I pulled three patches from Joerg in one group, and the other two were real fixes - and this one looked indeed unnecessary but harmless, so i didnt ask him to rebase. CONFIG_AMD_IOMMU is default-off and a relatively new driver, and the patch came from the hw vendor affected by it so i let it through. When i pulled i assumed i could get it in before -rc9 but once you released -rc9 the pull was done already. I wouldnt have pulled such a patch so close before final .28. The timing was a bit unfortunate - can rebase and re-test. Same deal for:

55aab5f: x86 gart: don't complain if no AMD GART found

i wouldnt have put it in after the final -rc.

Ingo

#4 lore raw
In reply to Linus Torvalds
Quoted 4 lines · Linus Torvalds
Quoted 1 line · Ingo Molnar
Quoted 8 lines
Quoted 2 lines

Joerg Roedel (3):
AMD IOMMU: panic if completion wait loop fails

What's the advantage to this, especially this late in the game?

Now, I tried to google for the message (while ignoring the patches), and as far as I can tell, it has never happened that google has noticed. But still, why was this pushed as a "fix"?

Google won't tell because the hardware is not yet for sale. The story behind this patch is, it happened that the completion wait loop failed in my tests.

And when it fails then for sure because some error occured and the AMD IOMMU stopped fetching commands from the command buffer (the reason why it stopped fetching commands for me is also fixed with another patch in this pull request, but there may be other reasons like internal errors). But it is important that the IOMMU fetches commands because they are needed to flush the IOTLB. If we can't flush the IOTLB we get data corruption sooner or later. So I decided its better to panic in this situation.

There is another way to handle this by resetting the command buffer. But that is more code (basically code to flush the IOMMU cache for everything we have under control with the IOMMU). Too much for inclusion that late in the release cycle. I will prepare that for one of the future merge windows.

For now, the best 'fix' in this situation is to panic before data corruption can happen.

Joerg

#3 lore raw
In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

You are right, this patch should have been delayed to .29. Should i rebase the branch?

I pulled it. I don't think it is a huge deal - as mentioned, google didn't seem to find any mention of the message ever triggering, so I doubt it really matters.

It just wasn't the right time for that kind of patch. But it's almost certainly harmless.

Linus