Skip to contentSkip to conversation

x86/mtrr: Drop workaround for old 32bit CPUs

PATCH In review Andrew Cooper 3 participants 5 messages Jul 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mtrr: Drop workaround for old 32bit CPUs

This logic is dead as Xen is 64bit-only these days.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/mtrr/generic.c | 17 -----------------
 1 file changed, 17 deletions(-)
xen/arch/x86/cpu/mtrr/generic.c +0 -17
index 89634f918f..06fa0c0420 100644
@@ -570,23 +570,6 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i
 {
 	unsigned long lbase, last;
 
-	/*  For Intel PPro stepping <= 7, must be 4 MiB aligned 
-	    and not touch 0x70000000->0x7003FFFF */
-	if (is_cpu(INTEL) && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
-	    boot_cpu_data.x86_mask <= 7) {
-		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
-			printk(KERN_WARNING "mtrr: base(%#lx000) is not 4 MiB aligned\n", base);
-			return -EINVAL;
-		}
-		if (!(base + size < 0x70000 || base > 0x7003F) &&
-		    (type == MTRR_TYPE_WRCOMB
-		     || type == MTRR_TYPE_WRBACK)) {
-			printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n");
-			return -EINVAL;
-		}
-	}
-
 	/*  Check upper bits of base and last are equal and lower bits are 0
 	    for base and 1 for last  */
 	last = base + size - 1;
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Andrew Cooper

This logic is dead as Xen is 64bit-only these days.

Quoted 26 lines

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/mtrr/generic.c | 17 -----------------
 1 file changed, 17 deletions(-)
xen/arch/x86/cpu/mtrr/generic.c +0 -10
index 89634f918f..06fa0c0420 100644
@@ -570,23 +570,6 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i
 {
 	unsigned long lbase, last;
 
-	/*  For Intel PPro stepping <= 7, must be 4 MiB aligned 
-	    and not touch 0x70000000->0x7003FFFF */
-	if (is_cpu(INTEL) && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
-	    boot_cpu_data.x86_mask <= 7) {
-		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
-			printk(KERN_WARNING "mtrr: base(%#lx000) is not 4 MiB aligned\n", base);
-			return -EINVAL;
-		}
-		if (!(base + size < 0x70000 || base > 0x7003F) &&

xen/arch/x86/cpu/mtrr/generic.c int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i · line 575

Quoted 10 lines
xen/arch/x86/cpu/mtrr/generic.c +0 -7
-		    (type == MTRR_TYPE_WRCOMB
-		     || type == MTRR_TYPE_WRBACK)) {
-			printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n");
-			return -EINVAL;
-		}
-	}
-
 	/*  Check upper bits of base and last are equal and lower bits are 0
 	    for base and 1 for last  */
 	last = base + size - 1;

FWIW, you could also initialize last at definition time.

Roger.

#2 lore raw
Quoted 5 lines · Roger Pau Monné
Quoted 3 lines · Andrew Cooper

This logic is dead as Xen is 64bit-only these days.

Thanks,

Quoted 29 lines
Quoted 29 lines

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/mtrr/generic.c | 17 -----------------
 1 file changed, 17 deletions(-)
xen/arch/x86/cpu/mtrr/generic.c +0 -13
index 89634f918f..06fa0c0420 100644
@@ -570,23 +570,6 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i
 {
 	unsigned long lbase, last;
 
-	/*  For Intel PPro stepping <= 7, must be 4 MiB aligned 
-	    and not touch 0x70000000->0x7003FFFF */
-	if (is_cpu(INTEL) && boot_cpu_data.x86 == 6 &&
-	    boot_cpu_data.x86_model == 1 &&
-	    boot_cpu_data.x86_mask <= 7) {
-		if (base & ((1 << (22 - PAGE_SHIFT)) - 1)) {
-			printk(KERN_WARNING "mtrr: base(%#lx000) is not 4 MiB aligned\n", base);
-			return -EINVAL;
-		}
-		if (!(base + size < 0x70000 || base > 0x7003F) &&
-		    (type == MTRR_TYPE_WRCOMB
-		     || type == MTRR_TYPE_WRBACK)) {
-			printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n");
Quoted 8 lines

xen/arch/x86/cpu/mtrr/generic.c int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i · line 575

Quoted 7 lines
xen/arch/x86/cpu/mtrr/generic.c +0 -4
-			return -EINVAL;
-		}
-	}
-
 	/*  Check upper bits of base and last are equal and lower bits are 0
 	    for base and 1 for last  */
 	last = base + size - 1;

FWIW, you could also initialize last at definition time.

I've got some very different cleanup in mind for that code, seeing as it can be simplified to a single test expression.

~Andrew

#3 lore raw
Quoted 9 lines · Andrew Cooper
Quoted 5 lines · Roger Pau Monné

xen/arch/x86/cpu/mtrr/generic.c int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i · line 575

Quoted 3 lines · Andrew Cooper
xen/arch/x86/cpu/mtrr/generic.c +0 -0
 	/*  Check upper bits of base and last are equal and lower bits are 0
 	    for base and 1 for last  */
 	last = base + size - 1;

FWIW, you could also initialize last at definition time.

I've got some very different cleanup in mind for that code, seeing as it can be simplified to a single test expression.

Oh, I certainly didn't look at it that much :).

Thanks, Roger.