summaryrefslogtreecommitdiff
path: root/src/common/host_memory.cpp
AgeCommit message (Collapse)Author
2025-02-09common: Enhance memory mapping safety and debuggingZephyron
- Reduce max_memory_size from 512GB to 1GB for safer allocation limits - Add memory operation logging for debugging purposes - Implement MapMemory() with additional safety checks and large allocation handling - Add validation checks for memory mappings - Introduce chunked allocation strategy for large memory requests - Add detailed error logging for memory operations
2025-02-08common: improve host memory mapping validationZephyron
- Add maximum memory size limit of 512GB (Overkill) - Implement additional safety checks for memory mapping: * Validate non-zero addresses * Verify address alignment * Add length validation against maximum size - Remove redundant assertion for host_offset alignment - Remove potentially problematic mapping verification - Improve error logging for invalid mapping attempts These changes enhance memory safety by adding proper bounds checking and validation before performing memory mappings, while removing a potentially problematic post-mapping verification step.
2025-02-02vulkan: Fix parameter naming consistency for Android compilationZephyron
Renames 'size' parameter to 'length' in IsValidMapping() methods to avoid conflicts with Android NDK macros that define 'size'. This fixes compilation issues on Android platforms where the 'size' macro is defined.
2025-02-01common/nvdrv: improve memory validation and error handlingZephyron
Implements several improvements to memory handling and validation: - host_memory: Add IsValidMapping() and IsDirectMappingEnabled() methods to validate memory access - host_memory: Fix virtual base offset calculation to use proper pointer arithmetic - host_memory: Add size field to track allocation size - nvhost_ctrl_gpu: Return InvalidState instead of InvalidValue for TPC mask buffer size validation - Update copyright year for citron The changes improve memory safety by adding explicit validation checks and fixing pointer arithmetic in the virtual memory implementation.
2025-02-01nvdrv: Add GetTpcMasks2 support and improve memory mapping validationZephyron
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.
2025-02-01common: Improve error handling in host memory managementZephyron
Add proper error handling and recovery mechanisms for memory mapping operations instead of using assertions.
2025-01-14Revert incorrect copyright attribution for non-contributed filesZephyron
- In commit b3facaa6bb30cdc39f2b7d632fef1e3bfeee7785, the copyright header was updated to include "Citron Homebrew Project" across multiple files, regardless of whether any contributions were made. - This commit removes the incorrect attribution and reverts the copyright header to its previous state. - Copyright attribution should only be added when meaningful contributions have been made to the file. - This commit ensures proper compliance with copyright standards and maintains correct attribution to the respective contributors. - Special thanks to Tachi for pointing out the need for these corrections and ensuring that proper attribution practices are followed.
2024-12-31chore: update project references and add Citron copyrightZephyron
- Replaced all references to the old project name with Citron. - Added Citron copyright information alongside existing notices in all files.
2024-02-19scope_exit: Make constexprFearlessTobi
Allows the use of the macro in constexpr-contexts. Also avoids some potential problems when nesting braces inside it.
2023-12-25core: track separate heap allocation for linuxLiam
2023-12-14common: use memory holepunching when clearing memoryLiam
2023-12-02host_memory: move MAP_ALIGNED_SUPER attempt after 448d4815deceJan Beich
src/common/host_memory.cpp:410:14: error: unused function 'ChooseVirtualBase' [-Werror,-Wunused-function] 410 | static void* ChooseVirtualBase(size_t virtual_size) { | ^~~~~~~~~~~~~~~~~
2023-12-02host_memory: allow missing MAP_NORESERVE on FreeBSD after 448d4815deceJan Beich
src/common/host_memory.cpp:408:47: error: use of undeclared identifier 'MAP_NORESERVE' MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); ^
2023-11-29cmake: Move HAS_NCE to root cmakeGPUCode
* So we can use it in common
2023-11-26general: fix mac compileLiam
2023-11-25host_memory: Simplify randomness generationGPUCode
2023-11-25Address some review commentsGPUCode
2023-11-25android: Add cpu bakend gui toggleGPUCode
2023-11-25arm: Implement native code execution backendLiam
2023-11-25core: Respect memory permissions in MapGPUCode
2023-11-25host_memory: Switch to FreeRegionManagerLiam
2023-11-25host_memory: ensure map base is between 36 and 39 bitsLiam
2023-06-05Merge pull request #10508 from yuzu-emu/limebunnei
Project Lime - yuzu Android Port
2023-06-03common: host_memory: Implement for Android.bunnei
2023-06-01host_memory: merge adjacent placeholder mappings on Linuxkkoniuszy
Track the private anonymous placeholder mappings created by Unmap() and wherever possible, replace existing placeholders with larger ones instead of creating many small ones. This helps with the buildup of mappings in /proc/YUZU_PID/maps after a longer gaming session, improving stability without having to increase vm.max_map_count to a ridiculous value. The amount of placeholder mappings will no longer outgrow the amount of actual memfd mappings in cases of high memory fragmentation.
2023-03-12general: fix spelling mistakesLiam
2023-01-01host_memory: Use transparent huge pages where availableMerry
2023-01-01host_memory: Allocate virtual_base with MAP_NORESERVEMerry
Specify that we do not require swap to be reserved for this address range; allow overcommitting.
2022-11-09Initial ARM64 supportLiam
2022-04-23general: Convert source file copyright comments over to SPDXMorph
This formats all copyright comments according to SPDX formatting guidelines. Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
2022-04-07common: Replace lock_guard with scoped_lockMerry
2022-03-20general: Fix clang/gcc build errorsameerj
2022-03-19common: Reduce unused includesameerj
2022-03-02host_memory: Fix fastmem crashes in debug buildsMorph
It is possible for virtual_offset to not be 0 when the iterator is at the beginning, and thus, std::prev(it) may be evaluated, leading to a crash in debug mode. Co-Authored-By: Fernando S. <1731197+FernandoS27@users.noreply.github.com>
2021-12-05general: Add missing copyright noticesameerj
2021-09-29Fixed invalid iterator usageAndrew Strelsky
2021-07-27host_memory: Add workaround for FreeBSD 12Jan Beich
src/common/host_memory.cpp:360:14: error: use of undeclared identifier 'memfd_create' fd = memfd_create("HostMemory", 0); ^
2021-07-27host_memory: Enable Linux implementation on FreeBSDJan Beich
HW.Memory <Critical> common/host_memory.cpp:HostMemory:492: Fastmem unavailable, falling back to VirtualBuffer for memory allocation
2021-06-19host_memory: Correct MEM_RESERVE_PLACEHOLDERlat9nq
Microsoft defines `MEM_RESERVE_PLACEHOLDER` as `0x00040000`, but our manually imported version of it drops the last zero.
2021-06-11common/host_memory: Implement a fallback if fastmem fails.Markus Wick
This falls back to the old approach of using a virtual buffer. Windows is untested, but this build should fix support for Windows < 10 v1803. However without fastmem support at all.
2021-06-11common/host_shader: Load Windows 10 functions dynamicallyReinUsesLisp
Workaround old headers and libraries shipped on MinGW.
2021-06-11host_memory: Support staged VirtualProtect callsReinUsesLisp
2021-06-11common/host_memory: Optimize for huge tables.Markus Wick
In theory, if we have 2 MB continously mapped, this should save one layer of TLB. Let's make it at least more likely by aligning the memory.
2021-06-11common/host_memory: Add Linux implementationMarkus Wick
2021-06-11common/host_memory: Add interface and Windows implementationReinUsesLisp