Skip to contentSkip to conversation

mtrr: fix PGE mask

PATCH New Brian Gerst 1 participant 1 message May 19, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtrr: fix PGE mask

cr4 is a 32-bit register, so casting the mask to an unsigned char is wrong, as it clears more than the PGE bit.

---
 arch/i386/kernel/cpu/mtrr/cyrix.c |    2 +-
 arch/i386/kernel/cpu/mtrr/state.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/i386/kernel/cpu/mtrr/cyrix.c +1 -1
index 0737a59..9edf562 100644
@@ -136,7 +136,7 @@ static void prepare_set(void)
 	/*  Save value of CR4 and clear Page Global Enable (bit 7)  */
 	if ( cpu_has_pge ) {
 		cr4 = read_cr4();
-		write_cr4(cr4 & (unsigned char) ~(1 << 7));
+		write_cr4(cr4 & ~X86_CR4_PGE);
 	}
 
 	/*  Disable and flush caches. Note that wbinvd flushes the TLBs as
arch/i386/kernel/cpu/mtrr/state.c +1 -1
index f62ecd1..7b39a2f 100644
@@ -19,7 +19,7 @@ void set_mtrr_prepare_save(struct set_mtrr_context *ctxt)
 		/*  Save value of CR4 and clear Page Global Enable (bit 7)  */
 		if ( cpu_has_pge ) {
 			ctxt->cr4val = read_cr4();
-			write_cr4(ctxt->cr4val & (unsigned char) ~(1 << 7));
+			write_cr4(ctxt->cr4val & ~X86_CR4_PGE);
 		}
 
 		/*  Disable and flush caches. Note that wbinvd flushes the TLBs as
Signature · 1 line
1.5.2.rc3.39.gaf9b