diff options
| author | 2017-07-21 21:17:57 -0500 | |
|---|---|---|
| committer | 2017-09-10 15:13:41 -0500 | |
| commit | 6d2734a074f44a24129db850339677d8d7b436aa (patch) | |
| tree | 418be08a059813466e7ed4495fd6198b16aa4ddc /src/core/hle/kernel | |
| parent | Added missing parts in libnetwork (#2838) (diff) | |
| download | yuzu-6d2734a074f44a24129db850339677d8d7b436aa.tar.gz yuzu-6d2734a074f44a24129db850339677d8d7b436aa.tar.xz yuzu-6d2734a074f44a24129db850339677d8d7b436aa.zip | |
Kernel/Memory: Give each Process its own page table.
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 13 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 6 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index cef1f7fa8..7a007c065 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -56,6 +56,10 @@ void VMManager::Reset() { | |||
| 56 | initial_vma.size = MAX_ADDRESS; | 56 | initial_vma.size = MAX_ADDRESS; |
| 57 | vma_map.emplace(initial_vma.base, initial_vma); | 57 | vma_map.emplace(initial_vma.base, initial_vma); |
| 58 | 58 | ||
| 59 | page_table.pointers.fill(nullptr); | ||
| 60 | page_table.attributes.fill(Memory::PageType::Unmapped); | ||
| 61 | page_table.cached_res_count.fill(0); | ||
| 62 | |||
| 59 | UpdatePageTableForVMA(initial_vma); | 63 | UpdatePageTableForVMA(initial_vma); |
| 60 | } | 64 | } |
| 61 | 65 | ||
| @@ -328,16 +332,17 @@ VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { | |||
| 328 | void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { | 332 | void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { |
| 329 | switch (vma.type) { | 333 | switch (vma.type) { |
| 330 | case VMAType::Free: | 334 | case VMAType::Free: |
| 331 | Memory::UnmapRegion(vma.base, vma.size); | 335 | Memory::UnmapRegion(page_table, vma.base, vma.size); |
| 332 | break; | 336 | break; |
| 333 | case VMAType::AllocatedMemoryBlock: | 337 | case VMAType::AllocatedMemoryBlock: |
| 334 | Memory::MapMemoryRegion(vma.base, vma.size, vma.backing_block->data() + vma.offset); | 338 | Memory::MapMemoryRegion(page_table, vma.base, vma.size, |
| 339 | vma.backing_block->data() + vma.offset); | ||
| 335 | break; | 340 | break; |
| 336 | case VMAType::BackingMemory: | 341 | case VMAType::BackingMemory: |
| 337 | Memory::MapMemoryRegion(vma.base, vma.size, vma.backing_memory); | 342 | Memory::MapMemoryRegion(page_table, vma.base, vma.size, vma.backing_memory); |
| 338 | break; | 343 | break; |
| 339 | case VMAType::MMIO: | 344 | case VMAType::MMIO: |
| 340 | Memory::MapIoRegion(vma.base, vma.size, vma.mmio_handler); | 345 | Memory::MapIoRegion(page_table, vma.base, vma.size, vma.mmio_handler); |
| 341 | break; | 346 | break; |
| 342 | } | 347 | } |
| 343 | } | 348 | } |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 38e0d74d0..1302527bb 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | #include "core/memory.h" | ||
| 12 | #include "core/mmio.h" | 13 | #include "core/mmio.h" |
| 13 | 14 | ||
| 14 | namespace Kernel { | 15 | namespace Kernel { |
| @@ -102,7 +103,6 @@ struct VirtualMemoryArea { | |||
| 102 | * - http://duartes.org/gustavo/blog/post/page-cache-the-affair-between-memory-and-files/ | 103 | * - http://duartes.org/gustavo/blog/post/page-cache-the-affair-between-memory-and-files/ |
| 103 | */ | 104 | */ |
| 104 | class VMManager final { | 105 | class VMManager final { |
| 105 | // TODO(yuriks): Make page tables switchable to support multiple VMManagers | ||
| 106 | public: | 106 | public: |
| 107 | /** | 107 | /** |
| 108 | * The maximum amount of address space managed by the kernel. Addresses above this are never | 108 | * The maximum amount of address space managed by the kernel. Addresses above this are never |
| @@ -184,6 +184,10 @@ public: | |||
| 184 | /// Dumps the address space layout to the log, for debugging | 184 | /// Dumps the address space layout to the log, for debugging |
| 185 | void LogLayout(Log::Level log_level) const; | 185 | void LogLayout(Log::Level log_level) const; |
| 186 | 186 | ||
| 187 | /// Each VMManager has its own page table, which is set as the main one when the owning process | ||
| 188 | /// is scheduled. | ||
| 189 | Memory::PageTable page_table; | ||
| 190 | |||
| 187 | private: | 191 | private: |
| 188 | using VMAIter = decltype(vma_map)::iterator; | 192 | using VMAIter = decltype(vma_map)::iterator; |
| 189 | 193 | ||