summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------externals/dynarmic0
-rw-r--r--src/common/page_table.h2
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.cpp1
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.cpp4
-rw-r--r--src/core/device_memory.cpp2
-rw-r--r--src/core/device_memory.h17
-rw-r--r--src/core/memory.cpp12
7 files changed, 30 insertions, 8 deletions
diff --git a/externals/dynarmic b/externals/dynarmic
Subproject 828959caedfac2d456a0c877fda4612e35fffc0 Subproject 0c12614d1a7a72d778609920dde96a4c63074ec
diff --git a/src/common/page_table.h b/src/common/page_table.h
index e92b66b2b..8267e8b4d 100644
--- a/src/common/page_table.h
+++ b/src/common/page_table.h
@@ -111,6 +111,8 @@ struct PageTable {
111 VirtualBuffer<u64> backing_addr; 111 VirtualBuffer<u64> backing_addr;
112 112
113 size_t current_address_space_width_in_bits; 113 size_t current_address_space_width_in_bits;
114
115 u8* fastmem_arena;
114}; 116};
115 117
116} // namespace Common 118} // namespace Common
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
index cea7f0fb1..fb128f735 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
@@ -128,6 +128,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable*
128 if (page_table) { 128 if (page_table) {
129 config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>( 129 config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>(
130 page_table->pointers.data()); 130 page_table->pointers.data());
131 config.fastmem_pointer = page_table->fastmem_arena;
131 } 132 }
132 config.absolute_offset_page_table = true; 133 config.absolute_offset_page_table = true;
133 config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS; 134 config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS;
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
index 63193dcb1..b0ac8cf8a 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
@@ -160,6 +160,10 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
160 config.absolute_offset_page_table = true; 160 config.absolute_offset_page_table = true;
161 config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128; 161 config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128;
162 config.only_detect_misalignment_via_page_table_on_page_boundary = true; 162 config.only_detect_misalignment_via_page_table_on_page_boundary = true;
163
164 config.fastmem_pointer = page_table->fastmem_arena;
165 config.fastmem_address_space_bits = address_space_bits;
166 config.silently_mirror_fastmem = false;
163 } 167 }
164 168
165 // Multi-process state 169 // Multi-process state
diff --git a/src/core/device_memory.cpp b/src/core/device_memory.cpp
index 0c4b440ed..f19c0515f 100644
--- a/src/core/device_memory.cpp
+++ b/src/core/device_memory.cpp
@@ -6,7 +6,7 @@
6 6
7namespace Core { 7namespace Core {
8 8
9DeviceMemory::DeviceMemory() : buffer{DramMemoryMap::Size} {} 9DeviceMemory::DeviceMemory() : buffer{DramMemoryMap::Size, 1ULL << 39} {}
10DeviceMemory::~DeviceMemory() = default; 10DeviceMemory::~DeviceMemory() = default;
11 11
12} // namespace Core 12} // namespace Core
diff --git a/src/core/device_memory.h b/src/core/device_memory.h
index 5b1ae28f3..c4d17705f 100644
--- a/src/core/device_memory.h
+++ b/src/core/device_memory.h
@@ -5,7 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/virtual_buffer.h" 8#include "common/host_memory.h"
9 9
10namespace Core { 10namespace Core {
11 11
@@ -21,27 +21,30 @@ enum : u64 {
21}; 21};
22}; // namespace DramMemoryMap 22}; // namespace DramMemoryMap
23 23
24class DeviceMemory : NonCopyable { 24class DeviceMemory {
25public: 25public:
26 explicit DeviceMemory(); 26 explicit DeviceMemory();
27 ~DeviceMemory(); 27 ~DeviceMemory();
28 28
29 DeviceMemory& operator=(const DeviceMemory&) = delete;
30 DeviceMemory(const DeviceMemory&) = delete;
31
29 template <typename T> 32 template <typename T>
30 PAddr GetPhysicalAddr(const T* ptr) const { 33 PAddr GetPhysicalAddr(const T* ptr) const {
31 return (reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(buffer.data())) + 34 return (reinterpret_cast<uintptr_t>(ptr) -
35 reinterpret_cast<uintptr_t>(buffer.BackingBasePointer())) +
32 DramMemoryMap::Base; 36 DramMemoryMap::Base;
33 } 37 }
34 38
35 u8* GetPointer(PAddr addr) { 39 u8* GetPointer(PAddr addr) {
36 return buffer.data() + (addr - DramMemoryMap::Base); 40 return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
37 } 41 }
38 42
39 const u8* GetPointer(PAddr addr) const { 43 const u8* GetPointer(PAddr addr) const {
40 return buffer.data() + (addr - DramMemoryMap::Base); 44 return buffer.BackingBasePointer() + (addr - DramMemoryMap::Base);
41 } 45 }
42 46
43private: 47 Common::HostMemory buffer;
44 Common::VirtualBuffer<u8> buffer;
45}; 48};
46 49
47} // namespace Core 50} // namespace Core
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 9857278f6..79468e4dc 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -12,6 +12,7 @@
12#include "common/common_types.h" 12#include "common/common_types.h"
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/page_table.h" 14#include "common/page_table.h"
15#include "common/settings.h"
15#include "common/swap.h" 16#include "common/swap.h"
16#include "core/arm/arm_interface.h" 17#include "core/arm/arm_interface.h"
17#include "core/core.h" 18#include "core/core.h"
@@ -32,6 +33,7 @@ struct Memory::Impl {
32 33
33 void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id) { 34 void SetCurrentPageTable(Kernel::KProcess& process, u32 core_id) {
34 current_page_table = &process.PageTable().PageTableImpl(); 35 current_page_table = &process.PageTable().PageTableImpl();
36 current_page_table->fastmem_arena = system.DeviceMemory().buffer.VirtualBasePointer();
35 37
36 const std::size_t address_space_width = process.PageTable().GetAddressSpaceWidth(); 38 const std::size_t address_space_width = process.PageTable().GetAddressSpaceWidth();
37 39
@@ -41,13 +43,19 @@ struct Memory::Impl {
41 void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, PAddr target) { 43 void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, PAddr target) {
42 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 44 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
43 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 45 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
46 ASSERT_MSG(target >= DramMemoryMap::Base && target < DramMemoryMap::End,
47 "Out of bounds target: {:016X}", target);
44 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, Common::PageType::Memory); 48 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, Common::PageType::Memory);
49
50 system.DeviceMemory().buffer.Map(base, target - DramMemoryMap::Base, size);
45 } 51 }
46 52
47 void UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) { 53 void UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) {
48 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size); 54 ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: {:016X}", size);
49 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base); 55 ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: {:016X}", base);
50 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, 0, Common::PageType::Unmapped); 56 MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, 0, Common::PageType::Unmapped);
57
58 system.DeviceMemory().buffer.Unmap(base, size);
51 } 59 }
52 60
53 bool IsValidVirtualAddress(const Kernel::KProcess& process, const VAddr vaddr) const { 61 bool IsValidVirtualAddress(const Kernel::KProcess& process, const VAddr vaddr) const {
@@ -466,6 +474,10 @@ struct Memory::Impl {
466 if (vaddr == 0) { 474 if (vaddr == 0) {
467 return; 475 return;
468 } 476 }
477
478 const bool is_read_enable = Settings::IsGPULevelHigh() || !cached;
479 system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached);
480
469 // Iterate over a contiguous CPU address space, which corresponds to the specified GPU 481 // Iterate over a contiguous CPU address space, which corresponds to the specified GPU
470 // address space, marking the region as un/cached. The region is marked un/cached at a 482 // address space, marking the region as un/cached. The region is marked un/cached at a
471 // granularity of CPU pages, hence why we iterate on a CPU page basis (note: GPU page size 483 // granularity of CPU pages, hence why we iterate on a CPU page basis (note: GPU page size