revert Fix: Core_Memory logging and ARM_NCE Mutex logging
This commit is contained in:
Zephyron 2025-03-06 06:42:48 +00:00
parent 0d0963d32f
commit af4f08be33
4 changed files with 13 additions and 23 deletions

View file

@ -36,7 +36,6 @@ enum class Class : u8 {
Core, ///< LLE emulation core Core, ///< LLE emulation core
Core_ARM, ///< ARM CPU core Core_ARM, ///< ARM CPU core
Core_Timing, ///< CoreTiming functions Core_Timing, ///< CoreTiming functions
Core_Memory, ///< Core memory functions
Config, ///< Emulator configuration (including commandline) Config, ///< Emulator configuration (including commandline)
Debug, ///< Debugging tools Debug, ///< Debugging tools
Debug_Emulated, ///< Debug messages from the emulated programs Debug_Emulated, ///< Debug messages from the emulated programs

View file

@ -199,7 +199,7 @@ bool ArmNce::HandleGuestAccessFault(GuestContext* guest_ctx, void* raw_info, voi
} }
// Trigger an immediate remap if lookup fails // 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); LOG_ERROR(Core_ARM, "Immediate remap failed for address {:X}", fault_addr);
return HandleFailedGuestFault(guest_ctx, raw_info, raw_context); 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) { 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 // Simple linear search - more reliable than complex indexing
for (size_t i = 0; i < TLB_SIZE; i++) { 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; 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; size_t replace_idx = TLB_SIZE;
auto now = std::chrono::steady_clock::now(); 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() { 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 now = std::chrono::steady_clock::now();
auto expiration_time = std::chrono::minutes(5); // Example: 5 minutes expiration auto expiration_time = std::chrono::minutes(5); // Example: 5 minutes expiration

View file

@ -62,11 +62,6 @@ public:
void LockThread(Kernel::KThread* thread) override; void LockThread(Kernel::KThread* thread) override;
void UnlockThread(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: protected:
const Kernel::DebugWatchpoint* HaltedWatchpoint() const override { const Kernel::DebugWatchpoint* HaltedWatchpoint() const override {
return nullptr; return nullptr;
@ -114,8 +109,8 @@ public:
std::unique_ptr<u8[]> m_stack{}; std::unique_ptr<u8[]> m_stack{};
// Enhanced TLB implementation // Enhanced TLB implementation
std::array<TlbEntry, TLB_SIZE> m_tlb{}; // Declare m_tlb std::array<TlbEntry, TLB_SIZE> m_tlb{};
std::mutex m_tlb_mutex; // Declare m_tlb_mutex std::mutex m_tlb_mutex;
u64 m_tlb_access_counter{0}; u64 m_tlb_access_counter{0};
// TLB helper functions // TLB helper functions
@ -125,7 +120,6 @@ public:
size_t GetTlbSetIndex(u64 guest_addr) const; size_t GetTlbSetIndex(u64 guest_addr) const;
size_t FindReplacementEntry(size_t set_start); size_t FindReplacementEntry(size_t set_start);
void UpdateTlbEntryStats(TlbEntry& entry); void UpdateTlbEntryStats(TlbEntry& entry);
void StartTlbInvalidationTimer();
// Thread context caching // Thread context caching
std::mutex m_context_mutex; std::mutex m_context_mutex;

View file

@ -27,7 +27,6 @@
#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/host1x/gpu_device_memory_manager.h"
#include "video_core/host1x/host1x.h" #include "video_core/host1x/host1x.h"
#include "video_core/rasterizer_download_area.h" #include "video_core/rasterizer_download_area.h"
#include "core/arm/nce/arm_nce.h"
namespace Core::Memory { namespace Core::Memory {
@ -1152,7 +1151,7 @@ bool Memory::InvalidateSeparateHeap(void* fault_address) {
#endif #endif
} }
bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) { bool Memory::Remap(u64 guest_addr, u32 size) {
// Unmap the old address // Unmap the old address
UnmapRegion(*impl->current_page_table, guest_addr, size, false); 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 // Allocate new memory
void* new_memory = std::malloc(size); void* new_memory = std::malloc(size);
if (!new_memory) { 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; return false;
} }
@ -1171,7 +1170,7 @@ bool Memory::Remap(u64 guest_addr, u32 size, ArmNce& arm_nce) {
// Verify the mapping // Verify the mapping
if (GetPointer(guest_addr) != nullptr) { 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; return true;
} else { } else {
LOG_ERROR(Core_Memory, "Failed to remap address {:X}", guest_addr); 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) { void Memory::ReclaimUnusedMemory() {
std::lock_guard<std::mutex> lock(arm_nce.m_tlb_mutex); // Correct usage of lock_guard std::lock_guard lock(m_tlb_mutex);
const auto& tlb_entries = arm_nce.GetTlbEntries(); for (auto& entry : m_tlb) {
for (const auto& entry : tlb_entries) {
if (entry.valid && entry.ref_count == 0) { if (entry.valid && entry.ref_count == 0) {
// Unmap the memory region // Unmap the memory region
UnmapRegion(*impl->current_page_table, entry.guest_addr, entry.size, false); 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)); std::free(reinterpret_cast<void*>(entry.host_addr));
// Invalidate the TLB entry // 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); LOG_INFO(Core_Memory, "Reclaimed memory for address {:X}", entry.guest_addr);
} }