cpu/intel/p4-netburst: skip caching rom on model_fxx

An unidentified combination of speculative reads and branch
predictions inside WRPROT-cacheable memory can cause invalidation of
cachelines and loss of stack on models based on NetBurst
microarchitecture.

Therefore disable WRPROT region entirely for all family F models.

As an extreme example, just changing the location of a constant string
passed to printk() has been witnessed to make a the boot fail early on
in romstage.

Change-Id: I1df84ad55e2d8d6d4e8dca10125131b5f525f0d7
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/27133
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
diff --git a/src/cpu/intel/car/p4-netburst/cache_as_ram.S b/src/cpu/intel/car/p4-netburst/cache_as_ram.S
index 63ee723..95ecba9 100644
--- a/src/cpu/intel/car/p4-netburst/cache_as_ram.S
+++ b/src/cpu/intel/car/p4-netburst/cache_as_ram.S
@@ -315,6 +315,18 @@
 	orl	$CR0_CacheDisable, %eax
 	movl	%eax, %cr0
 
+	/*
+	 * An unidentified combination of speculative reads and branch
+	 * predictions inside WRPROT-cacheable memory can cause invalidation
+	 * of cachelines and loss of stack on models based on NetBurst
+	 * microarchitecture. Therefore disable WRPROT region entirely for
+	 * all family F models.
+	 */
+	movl	$1, %eax
+	cpuid
+	cmp	$0xf, %ah
+	je	skip_cache_rom
+
 	/* Enable cache for our code in Flash because we do XIP here */
 	movl	$MTRR_PHYS_BASE(1), %ecx
 	xorl	%edx, %edx
@@ -332,6 +344,8 @@
 	movl	$(~(CONFIG_XIP_ROM_SIZE - 1) | MTRR_PHYS_MASK_VALID), %eax
 	wrmsr
 
+skip_cache_rom:
+
 	post_code(0x2e)
 	/* Enable cache. */
 	movl	%cr0, %eax