Fixed MM_UnmapHWPages overwriting the wrong area
authorJohn Hodge <[email protected]>
Sat, 24 Apr 2010 02:20:35 +0000 (10:20 +0800)
committerJohn Hodge <[email protected]>
Sat, 24 Apr 2010 02:20:35 +0000 (10:20 +0800)
Kernel/arch/x86/mm_virt.c

index f3cd7bb..9c93334 100644 (file)
@@ -1024,17 +1024,21 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr)
 void MM_UnmapHWPages(tVAddr VAddr, Uint Number)
 {
         int    i, j;
+       
+       //Log_Debug("VirtMem", "MM_UnmapHWPages: (VAddr=0x%08x, Number=%i)", VAddr, Number);
+       
        // Sanity Check
-       if(VAddr < HW_MAP_ADDR || VAddr-Number*0x1000 > HW_MAP_MAX)     return;
+       if(VAddr < HW_MAP_ADDR || VAddr+Number*0x1000 > HW_MAP_MAX)     return;
        
        i = VAddr >> 12;
        
        LOCK( &gilTempMappings );       // Temp and HW share a directory, so they share a lock
        
+       
        for( j = 0; j < Number; j++ )
        {
-               MM_DerefPhys( gaPageTable[ (HW_MAP_ADDR >> 12) + i + j ] & ~0xFFF );
-               gaPageTable[ (HW_MAP_ADDR >> 12) + i + j ] = 0;
+               MM_DerefPhys( gaPageTable[ i + j ] & ~0xFFF );
+               gaPageTable[ i + j ] = 0;
        }
        
        RELEASE( &gilTempMappings );

UCC git Repository :: git.ucc.asn.au