diff options
| author | Zephyron <zephyron@citron-emu.org> | 2025-03-06 06:42:48 +0000 | 
|---|---|---|
| committer | Zephyron <zephyron@citron-emu.org> | 2025-03-06 06:42:48 +0000 | 
| commit | af4f08be339a2ba093578e7083638a95d847fb9d (patch) | |
| tree | bbc13a49f4f8a73c925024e220e454942a59d1d9 | |
| parent | 0d0963d32ff11a487a4402dfd395c6d08afac6d6 (diff) | |
revert 6565055865688ba316801d99a3c3a5a0300cad5d
revert Fix: Core_Memory logging and ARM_NCE Mutex logging
| -rw-r--r-- | src/common/logging/types.h | 1 | ||||
| -rw-r--r-- | src/core/arm/nce/arm_nce.cpp | 8 | ||||
| -rw-r--r-- | src/core/arm/nce/arm_nce.h | 10 | ||||
| -rw-r--r-- | src/core/memory.cpp | 17 | 
4 files changed, 13 insertions, 23 deletions
diff --git a/src/common/logging/types.h b/src/common/logging/types.h index b6960afa3..9e2f42c5d 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -36,7 +36,6 @@ enum class Class : u8 {      Core,               ///< LLE emulation core      Core_ARM,           ///< ARM CPU core      Core_Timing,        ///< CoreTiming functions -    Core_Memory,        ///< Core memory functions      Config,             ///< Emulator configuration (including commandline)      Debug,              ///< Debugging tools      Debug_Emulated,     ///< Debug messages from the emulated programs diff --git a/src/core/arm/nce/arm_nce.cpp b/src/core/arm/nce/arm_nce.cpp index 6220e3031..f08c5c352 100644 --- a/src/core/arm/nce/arm_nce.cpp +++ b/src/core/arm/nce/arm_nce.cpp @@ -199,7 +199,7 @@ bool ArmNce::HandleGuestAccessFault(GuestContext* guest_ctx, void* raw_info, voi          }          // Trigger an immediate remap if lookup fails -        if (!memory.Remap(fault_addr, Memory::CITRON_PAGESIZE, *nce)) { +        if (!memory.Remap(fault_addr, Memory::CITRON_PAGESIZE)) {              LOG_ERROR(Core_ARM, "Immediate remap failed for address {:X}", fault_addr);              return HandleFailedGuestFault(guest_ctx, raw_info, raw_context);          } @@ -430,7 +430,7 @@ void ArmNce::InvalidateCacheRange(u64 addr, std::size_t size) {  }  TlbEntry* ArmNce::FindTlbEntry(u64 guest_addr) { -    std::lock_guard<std::mutex> lock(m_tlb_mutex); // Correct usage of lock_guard +    std::lock_guard lock(m_tlb_mutex);      // Simple linear search - more reliable than complex indexing      for (size_t i = 0; i < TLB_SIZE; i++) { @@ -456,7 +456,7 @@ void ArmNce::AddTlbEntry(u64 guest_addr, u64 host_addr, u32 size, bool writable)          return;      } -    std::lock_guard<std::mutex> lock(m_tlb_mutex); // Correct usage of lock_guard +    std::lock_guard lock(m_tlb_mutex);      size_t replace_idx = TLB_SIZE;      auto now = std::chrono::steady_clock::now(); @@ -506,7 +506,7 @@ void ArmNce::AddTlbEntry(u64 guest_addr, u64 host_addr, u32 size, bool writable)  }  void ArmNce::InvalidateTlb() { -    std::lock_guard<std::mutex> lock(m_tlb_mutex); // Correct usage of lock_guard +    std::lock_guard lock(m_tlb_mutex);      auto now = std::chrono::steady_clock::now();      auto expiration_time = std::chrono::minutes(5); // Example: 5 minutes expiration diff --git a/src/core/arm/nce/arm_nce.h b/src/core/arm/nce/arm_nce.h index 416703557..13da2c8b4 100644 --- a/src/core/arm/nce/arm_nce.h +++ b/src/core/arm/nce/arm_nce.h @@ -62,11 +62,6 @@ public:      void LockThread(Kernel::KThread* thread) override;      void UnlockThread(Kernel::KThread* thread) override; -    // Method to provide access to TLB entries -    const std::array<TlbEntry, TLB_SIZE>& GetTlbEntries() const { -        return m_tlb; -    } -  protected:      const Kernel::DebugWatchpoint* HaltedWatchpoint() const override {          return nullptr; @@ -114,8 +109,8 @@ public:      std::unique_ptr<u8[]> m_stack{};      // Enhanced TLB implementation -    std::array<TlbEntry, TLB_SIZE> m_tlb{}; // Declare m_tlb -    std::mutex m_tlb_mutex; // Declare m_tlb_mutex +    std::array<TlbEntry, TLB_SIZE> m_tlb{}; +    std::mutex m_tlb_mutex;      u64 m_tlb_access_counter{0};      // TLB helper functions @@ -125,7 +120,6 @@ public:      size_t GetTlbSetIndex(u64 guest_addr) const;      size_t FindReplacementEntry(size_t set_start);      void UpdateTlbEntryStats(TlbEntry& entry); -    void StartTlbInvalidationTimer();      // Thread context caching      std::mutex m_context_mutex; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index b32071899..dd6ffaf6c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -27,7 +27,6 @@  #include "video_core/host1x/gpu_device_memory_manager.h"  #include "video_core/host1x/host1x.h"  #include "video_core/rasterizer_download_area.h" -#include "core/arm/nce/arm_nce.h"  namespace Core::Memory { @@ -1152,7 +1151,7 @@ bool Memory::InvalidateSeparateHeap(void* fault_address) {  #endif  } -bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) { +bool Memory::Remap(u64 guest_addr, u32 size) {      // Unmap the old address      UnmapRegion(*impl->current_page_table, guest_addr, size, false); @@ -1162,7 +1161,7 @@ bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {      // Allocate new memory      void* new_memory = std::malloc(size);      if (!new_memory) { -        LOG_ERROR(Core_ARM, "Failed to allocate new memory for remapping address {:X}", guest_addr); +        LOG_ERROR(Core_Memory, "Failed to allocate new memory for remapping address {:X}", guest_addr);          return false;      } @@ -1171,7 +1170,7 @@ bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {      // Verify the mapping      if (GetPointer(guest_addr) != nullptr) { -        LOG_INFO(Core_ARM, "Successfully remapped address {:X}", guest_addr); +        LOG_INFO(Core_Memory, "Successfully remapped address {:X}", guest_addr);          return true;      } else {          LOG_ERROR(Core_Memory, "Failed to remap address {:X}", guest_addr); @@ -1180,12 +1179,10 @@ bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {      }  } -void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) { -    std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard +void Memory::ReclaimUnusedMemory() { +    std::lock_guard lock(m_tlb_mutex); -    const auto& tlb_entries = arm_nce.GetTlbEntries(); - -    for (const auto& entry : tlb_entries) { +    for (auto& entry : m_tlb) {          if (entry.valid && entry.ref_count == 0) {              // Unmap the memory region              UnmapRegion(*impl->current_page_table, entry.guest_addr, entry.size, false); @@ -1194,7 +1191,7 @@ void Memory::ReclaimUnusedMemory(ArmNce& arm_nce) {              std::free(reinterpret_cast<void*>(entry.host_addr));              // Invalidate the TLB entry -            const_cast<TlbEntry&>(entry).valid = false; +            entry.valid = false;              LOG_INFO(Core_Memory, "Reclaimed memory for address {:X}", entry.guest_addr);          }  | 
