diff options
author | Zephyron <zephyron@citron-emu.org> | 2025-02-01 19:48:11 +1000 |
---|---|---|
committer | Zephyron <zephyron@citron-emu.org> | 2025-02-01 19:48:11 +1000 |
commit | ecc32958ec1a14f48d51ac48001b3b7e101d994c (patch) | |
tree | ab2812fa953ce503b8df7aa7d4fdc37f2a77d9a3 /src/common | |
parent | e8bbdbce4250c5f6d7dc48d6895bd653969e5c4a (diff) |
nvdrv: Add GetTpcMasks2 support and improve memory mapping validation
This commit makes two main changes:
1. Adds support for GetTpcMasks2 (ioctl 0x13) in nvhost_ctrl_gpu:
- Implements new GetTpcMasks2 method to handle TPC mask queries
- Adds IoctlGetTpcMasks structure to store mask parameters
- Returns conservative single TPC configuration for compatibility
2. Enhances memory mapping validation in HostMemory:
- Adds verification check after memory mapping operations
- Improves error handling for direct mapped address enabling
- Adds logging for mapping and direct address failures
Additional changes:
- Updates copyright headers to include citron Emulator Project
- Improves error handling and validation in several paths
- Adds debug logging for TPC mask operations
This improves GPU virtualization support and memory mapping reliability.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/host_memory.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 14b4e4367..4f5a11f86 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #ifdef _WIN32 @@ -720,10 +721,18 @@ void HostMemory::Map(size_t virtual_offset, size_t host_offset, size_t length, ASSERT(length % PageAlignment == 0); ASSERT(virtual_offset + length <= virtual_size); ASSERT(host_offset + length <= backing_size); + if (length == 0 || !virtual_base || !impl) { return; } + impl->Map(virtual_offset + virtual_base_offset, host_offset, length, perms); + + // Verify mapping was successful + if (!impl->IsValidMapping(virtual_offset + virtual_base_offset, length)) { + LOG_CRITICAL(Common_Memory, "Failed to verify memory mapping: virtual_offset={:x}, host_offset={:x}, length={:x}", + virtual_offset, host_offset, length); + } } void HostMemory::Unmap(size_t virtual_offset, size_t length, bool separate_heap) { @@ -756,9 +765,18 @@ void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 f } void HostMemory::EnableDirectMappedAddress() { - if (impl) { - impl->EnableDirectMappedAddress(); + if (!impl) { + LOG_ERROR(Common_Memory, "Implementation not initialized"); + return; + } + + impl->EnableDirectMappedAddress(); + + // Only update virtual_size if the direct mapping was successful + if (impl->IsDirectMappingEnabled()) { virtual_size += reinterpret_cast<uintptr_t>(virtual_base); + } else { + LOG_ERROR(Common_Memory, "Failed to enable direct mapped address"); } } |