[haiku-commits] r36590 - haiku/trunk/src/system/kernel/vm

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 3 May 2010 00:52:25 +0200 (CEST)

Author: bonefish
Date: 2010-05-03 00:52:25 +0200 (Mon, 03 May 2010)
New Revision: 36590
Changeset: http://dev.haiku-os.org/changeset/36590/haiku

Modified:
   haiku/trunk/src/system/kernel/vm/vm.cpp
Log:
vm_map_physical_memory(): When alreadyWired we have to explicitly set the
memory type for the mapped pages.


Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/vm.cpp     2010-05-02 22:50:30 UTC (rev 
36589)
+++ haiku/trunk/src/system/kernel/vm/vm.cpp     2010-05-02 22:52:25 UTC (rev 
36590)
@@ -1451,17 +1451,28 @@
                        delete_area(locker.AddressSpace(), area, false);
        }
 
-       if (status >= B_OK && !alreadyWired) {
-               // make sure our area is mapped in completely
+       if (status != B_OK)
+               return status;
 
-               VMTranslationMap* map = locker.AddressSpace()->TranslationMap();
+       VMTranslationMap* map = locker.AddressSpace()->TranslationMap();
+
+       if (alreadyWired) {
+               // The area is already mapped, but possibly not with the right
+               // memory type.
+               map->Lock();
+               map->ProtectArea(area, area->protection);
+               map->Unlock();
+       } else {
+               // Map the area completely.
+
+               // reserve pages needed for the mapping
                size_t reservePages = map->MaxPagesNeededToMap(area->Base(),
                        area->Base() + (size - 1));
-
                vm_page_reservation reservation;
                vm_page_reserve_pages(&reservation, reservePages,
                        team == VMAddressSpace::KernelID()
                                ? VM_PRIORITY_SYSTEM : VM_PRIORITY_USER);
+
                map->Lock();
 
                for (addr_t offset = 0; offset < size; offset += B_PAGE_SIZE) {
@@ -1470,12 +1481,10 @@
                }
 
                map->Unlock();
+
                vm_page_unreserve_pages(&reservation);
        }
 
-       if (status < B_OK)
-               return status;
-
        // modify the pointer returned to be offset back into the new area
        // the same way the physical address in was offset
        *_address = (void*)((addr_t)*_address + mapOffset);


Other related posts:

  • » [haiku-commits] r36590 - haiku/trunk/src/system/kernel/vm - ingo_weinhold