summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2020-11-13 23:20:32 -0800
committerGravatar bunnei2020-11-29 01:31:52 -0800
commit63fd1bb50302867b233325f253b1e2abbc379875 (patch)
tree65204a55cc87b2b4ef7260744ff96fabc813c9f6 /src/core/hle/kernel
parenthle: kernel: time_manager: Avoid a crash on process exit. (diff)
downloadyuzu-63fd1bb50302867b233325f253b1e2abbc379875.tar.gz
yuzu-63fd1bb50302867b233325f253b1e2abbc379875.tar.xz
yuzu-63fd1bb50302867b233325f253b1e2abbc379875.zip
core: arm: Implement InvalidateCacheRange for CPU cache invalidation.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/kernel.cpp15
-rw-r--r--src/core/hle/kernel/kernel.h2
-rw-r--r--src/core/hle/kernel/memory/page_table.cpp5
-rw-r--r--src/core/hle/kernel/physical_core.h4
4 files changed, 21 insertions, 5 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index c426b6378..929db696d 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -497,12 +497,17 @@ const Core::ExclusiveMonitor& KernelCore::GetExclusiveMonitor() const {
497} 497}
498 498
499void KernelCore::InvalidateAllInstructionCaches() { 499void KernelCore::InvalidateAllInstructionCaches() {
500 if (!IsMulticore()) { 500 for (auto& physical_core : impl->cores) {
501 for (auto& physical_core : impl->cores) { 501 physical_core.ArmInterface().ClearInstructionCache();
502 physical_core.ArmInterface().ClearInstructionCache(); 502 }
503}
504
505void KernelCore::InvalidateCpuInstructionCacheRange(VAddr addr, std::size_t size) {
506 for (auto& physical_core : impl->cores) {
507 if (!physical_core.IsInitialized()) {
508 continue;
503 } 509 }
504 } else { 510 physical_core.ArmInterface().InvalidateCacheRange(addr, size);
505 UNIMPLEMENTED();
506 } 511 }
507} 512}
508 513
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index a9fdc5860..a73a93039 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -156,6 +156,8 @@ public:
156 156
157 void InvalidateAllInstructionCaches(); 157 void InvalidateAllInstructionCaches();
158 158
159 void InvalidateCpuInstructionCacheRange(VAddr addr, std::size_t size);
160
159 /// Adds a port to the named port table 161 /// Adds a port to the named port table
160 void AddNamedPort(std::string name, std::shared_ptr<ClientPort> port); 162 void AddNamedPort(std::string name, std::shared_ptr<ClientPort> port);
161 163
diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp
index a3fadb533..f53a7be82 100644
--- a/src/core/hle/kernel/memory/page_table.cpp
+++ b/src/core/hle/kernel/memory/page_table.cpp
@@ -670,6 +670,11 @@ ResultCode PageTable::SetCodeMemoryPermission(VAddr addr, std::size_t size, Memo
670 return RESULT_SUCCESS; 670 return RESULT_SUCCESS;
671 } 671 }
672 672
673 if ((prev_perm & MemoryPermission::Execute) != (perm & MemoryPermission::Execute)) {
674 // Memory execution state is changing, invalidate CPU cache range
675 system.InvalidateCpuInstructionCacheRange(addr, size);
676 }
677
673 const std::size_t num_pages{size / PageSize}; 678 const std::size_t num_pages{size / PageSize};
674 const OperationType operation{(perm & MemoryPermission::Execute) != MemoryPermission::None 679 const OperationType operation{(perm & MemoryPermission::Execute) != MemoryPermission::None
675 ? OperationType::ChangePermissionsAndRefresh 680 ? OperationType::ChangePermissionsAndRefresh
diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h
index ace058a5a..37513130a 100644
--- a/src/core/hle/kernel/physical_core.h
+++ b/src/core/hle/kernel/physical_core.h
@@ -58,6 +58,10 @@ public:
58 // Shutdown this physical core. 58 // Shutdown this physical core.
59 void Shutdown(); 59 void Shutdown();
60 60
61 bool IsInitialized() const {
62 return arm_interface != nullptr;
63 }
64
61 Core::ARM_Interface& ArmInterface() { 65 Core::ARM_Interface& ArmInterface() {
62 return *arm_interface; 66 return *arm_interface;
63 } 67 }