]> Pileus Git - ~andy/linux/blobdiff - arch/x86/kernel/cpu/mtrr/generic.c
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / arch / x86 / kernel / cpu / mtrr / generic.c
index 00f557b95b165587e70f48df9d9603835297eafa..d4cdfa67509ec266b787ec7a284e04065bb01c60 100644 (file)
@@ -510,8 +510,9 @@ generic_get_free_region(unsigned long base, unsigned long size, int replace_reg)
 static void generic_get_mtrr(unsigned int reg, unsigned long *base,
                             unsigned long *size, mtrr_type *type)
 {
-       unsigned int mask_lo, mask_hi, base_lo, base_hi;
-       unsigned int tmp, hi;
+       u32 mask_lo, mask_hi, base_lo, base_hi;
+       unsigned int hi;
+       u64 tmp, mask;
 
        /*
         * get_mtrr doesn't need to update mtrr_state, also it could be called
@@ -532,18 +533,18 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base,
        rdmsr(MTRRphysBase_MSR(reg), base_lo, base_hi);
 
        /* Work out the shifted address mask: */
-       tmp = mask_hi << (32 - PAGE_SHIFT) | mask_lo >> PAGE_SHIFT;
-       mask_lo = size_or_mask | tmp;
+       tmp = (u64)mask_hi << (32 - PAGE_SHIFT) | mask_lo >> PAGE_SHIFT;
+       mask = size_or_mask | tmp;
 
        /* Expand tmp with high bits to all 1s: */
-       hi = fls(tmp);
+       hi = fls64(tmp);
        if (hi > 0) {
-               tmp |= ~((1<<(hi - 1)) - 1);
+               tmp |= ~((1ULL<<(hi - 1)) - 1);
 
-               if (tmp != mask_lo) {
+               if (tmp != mask) {
                        printk(KERN_WARNING "mtrr: your BIOS has configured an incorrect mask, fixing it.\n");
                        add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
-                       mask_lo = tmp;
+                       mask = tmp;
                }
        }
 
@@ -551,8 +552,8 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base,
         * This works correctly if size is a power of two, i.e. a
         * contiguous range:
         */
-       *size = -mask_lo;
-       *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT;
+       *size = -mask;
+       *base = (u64)base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT;
        *type = base_lo & 0xff;
 
 out_put_cpu: