summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/vm_manager.h (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-09-05kernel/vm_manager: Correct doxygen comment parameter tags for MapPhysicalMemory/UnmapPhysicalMemoryLioncash1-4/+4
Corrects the parameter names within the doxygen comments so that they resolve properly.
2019-07-19VM_Manager: Align allocated memory to 256bytesFernando Sahmkow1-4/+5
This commit ensures that all backing memory allocated for the Guest CPU is aligned to 256 bytes. This due to how gpu memory works and the heavy constraints it has in the alignment of physical memory.
2019-07-07Remove unused member function declarationMichael Scire1-9/+0
2019-07-07physmem: add helpers, cleanup logic.Michael Scire1-0/+16
2019-07-07address review commentaryMichael Scire1-2/+2
2019-07-07Implement MapPhysicalMemory/UnmapPhysicalMemoryMichael Scire1-1/+40
This implements svcMapPhysicalMemory/svcUnmapPhysicalMemory for Yuzu, which can be used to map memory at a desired address by games since 3.0.0. It also properly parses SystemResourceSize from NPDM, and makes information available via svcGetInfo. This is needed for games like Super Smash Bros. and Diablo 3 -- this PR's implementation does not run into the "ASCII reads" issue mentioned in the comments of #2626, which was caused by the following bugs in Yuzu's memory management that this PR also addresses: * Yuzu's memory coalescing does not properly merge blocks. This results in a polluted address space/svcQueryMemory results that would be impossible to replicate on hardware, which can lead to game code making the wrong assumptions about memory layout. * This implements better merging for AllocatedMemoryBlocks. * Yuzu's implementation of svcMirrorMemory unprotected the entire virtual memory range containing the range being mirrored. This could lead to games attempting to map data at that unprotected range/attempting to access that range after yuzu improperly unmapped it. * This PR fixes it by simply calling ReprotectRange instead of Reprotect.
2019-07-06kernel/vm_manager: Rename 'new map' to 'stack'Lioncash1-10/+10
Provides a more accurate name for the memory region and also disambiguates between the map and new map regions of memory, making it easier to understand.
2019-07-04kernel/vm_manager: Add overload of FindFreeRegion() that operates on a boundaryLioncash1-3/+28
This will be necessary for making our TLS slot management slightly more straightforward. This can also be utilized for other purposes in the future. We can implement the existing simpler overload in terms of this one anyways, we just pass the beginning and end of the ASLR region as the boundaries.
2019-06-10kernel/svc: Amend naming for TotalMemoryUsage in svcGetInfo()Lioncash1-1/+1
Disambiguates and makes the name a little more consistent with TotalPhysicalMemoryUsed.
2019-04-17kernel/vm_manager: Remove usages of global system accessorsLioncash1-1/+7
Makes the dependency on the system instance explicit within VMManager's interface.
2019-04-13kernel/svc: Implement svcUnmapProcessCodeMemoryLioncash1-0/+23
Essentially performs the inverse of svcMapProcessCodeMemory. This unmaps the aliasing region first, then restores the general traits of the aliased memory. What this entails, is: - Restoring Read/Write permissions to the VMA. - Restoring its memory state to reflect it as a general heap memory region. - Clearing the memory attributes on the region.
2019-04-13kernel/svc: Implement svcMapProcessCodeMemoryLioncash1-0/+26
This is utilized for mapping code modules into memory. Notably, the ldr service would call this in order to map objects into memory.
2019-03-24kernel/vm_manager: Handle shrinking of the heap size within SetHeapSize()Lioncash1-3/+33
One behavior that we weren't handling properly in our heap allocation process was the ability for the heap to be shrunk down in size if a larger size was previously requested. This adds the basic behavior to do so and also gets rid of HeapFree, as it's no longer necessary now that we have allocations and deallocations going through the same API function. While we're at it, fully document the behavior that this function performs.
2019-03-24kernel/vm_manager: Rename HeapAllocate to SetHeapSizeLioncash1-1/+1
Makes it more obvious that this function is intending to stand in for the actual supervisor call itself, and not acting as a general heap allocation function. Also the following change will merge the freeing behavior of HeapFree into this function, so leaving it as HeapAllocate would be misleading.
2019-03-24kernel/vm_manager: Remove unused class variablesLioncash1-3/+0
Over time these have fallen out of use due to refactoring, so these can be removed.
2019-03-24kernel/vm_manager: Remove unnecessary heap_used data memberLioncash1-6/+0
This isn't required anymore, as all the kernel ever queries is the size of the current heap, not the total usage of it.
2019-03-24kernel/vm_manager: Tidy up heap allocation codeLioncash1-3/+13
Another holdover from citra that can be tossed out is the notion of the heap needing to be allocated in different addresses. On the switch, the base address of the heap will always be managed by the memory allocator in the kernel, so this doesn't need to be specified in the function's interface itself. The heap on the switch is always allocated with read/write permissions, so we don't need to add specifying the memory permissions as part of the heap allocation itself either. This also corrects the error code returned from within the function. If the size of the heap is larger than the entire heap region, then the kernel will report an out of memory condition.
2019-03-21kernel/vm_manager: Rename CodeStatic/CodeMutable to Code and CodeData respectivelyLioncash1-4/+4
Makes it more evident that one is for actual code and one is for actual data. Mutable and static are less than ideal terms here, because read-only data is technically not mutable, but we were mapping it with that label.
2019-03-21kernel/vm_manager: Amend flag values for CodeMutableLioncash1-1/+1
This should actually be using the data flags, rather than the code flags.
2019-03-17core: Move PageTable struct into Common.bunnei1-4/+5
2019-03-05vm_manager: Remove cheat-specific ranges from VMManagerZach Hilman1-8/+0
2019-03-05vm_manager: Add support for storing and getting main code regionZach Hilman1-0/+11
Used as root for one region of cheats, set by loader
2019-03-04vm_manager: Provide address range checking functions for other memory regionsLioncash1-4/+16
Makes the interface uniform when it comes to checking various memory regions.
2019-03-04svc: Migrate address range checking functions to VMManagerLioncash1-0/+6
Provides a bit of a more proper interface for these functions.
2018-12-19vm_manager: Add member function for setting memory attributes across an address rangeLioncash1-0/+13
This puts the backing functionality for svcSetMemoryAttribute in place, which will be utilized in a following change.
2018-12-19vm_manager: Add member function for checking a memory range adheres to certain attributes, permissions and statesLioncash1-0/+40
2018-12-16vm_manager: Rename meminfo_state to stateLioncash1-2/+1
This is shorter and more concise. This also removes the now-innaccurate comment, as it's not returned wholesale to svcQueryMemory anymore.
2018-12-16vm_manager: Add backing functionality for memory attributesLioncash1-0/+83
Adds the barebones enumeration constants and functions in place to handle memory attributes, while also essentially leaving the attribute itself non-functional.
2018-12-12vm_manager: Correct ordering of last two struct members of MemoryInfoLioncash1-2/+2
These should be swapped.
2018-12-12vm_manager: Amend the returned values for invalid memory queries in QueryMemory()Lioncash1-0/+3
The kernel returns a memory info instance with the base address set to the end of the address space, and the size of said block as 0 - address_space_end, it doesn't set both of said members to zero.
2018-12-12vm_manager: Migrate memory querying to the VMManager interfaceLioncash1-1/+9
Gets rid of the need to directly access the managed VMAs outside of the memory manager itself just for querying memory.
2018-12-12vm_manager: Migrate MemoryInfo and PageInfo to vm_manager.hLioncash1-0/+15
Gets the two structures out of an unrelated header and places them with the rest of the memory management code. This also corrects the structures. PageInfo appears to only contain a 32-bit flags member, and the extra padding word in MemoryInfo isn't necessary.
2018-12-12vm_manager: Amend MemoryState enum membersLioncash1-21/+105
Amends the MemoryState enum to use the same values like the actual kernel does. Also provides the necessary operators to operate on them. This will be necessary in the future for implementing svcSetMemoryAttribute, as memory block state is checked before applying the attribute.
2018-12-06vm_manager: Make vma_map privateLioncash1-10/+16
This was only ever public so that code could check whether or not a handle was valid or not. Instead of exposing the object directly and allowing external code to potentially mess with the map contents, we just provide a member function that allows checking whether or not a handle is valid. This makes all member variables of the VMManager class private except for the page table.
2018-11-18ldr_ro: Add error check for memory allocation failureZach Hilman1-1/+2
2018-11-13kernel/process: Migrate heap-related memory management out of the process class and into the vm managerLioncash1-0/+15
Avoids a breach of responsibilities in the interface and keeps the direct code for memory management within the VMManager class.
2018-10-26Kernel/Memory: Added a function to first a suitable guest address at which to allocate a region of a given size.bunnei1-0/+8
2018-10-18svc: Add missing sanitizing checks for MapSharedMemory/UnmapSharedMemoryLioncash1-0/+3
Now that the changes clarifying the address spaces has been merged, we can wrap the checks that the kernel performs when mapping shared memory (and other forms of memory) into its own helper function and then use those within MapSharedMemory and UnmapSharedMemory to complete the sanitizing checks that are supposed to be done.
2018-10-15svc: Clarify enum values for AddressSpaceBaseAddr and AddressSpaceSize in svcGetInfo()Lioncash1-0/+12
So, one thing that's puzzled me is why the kernel seemed to *not* use the direct code address ranges in some cases for some service functions. For example, in svcMapMemory, the full address space width is compared against for validity, but for svcMapSharedMemory, it compares against 0xFFE00000, 0xFF8000000, and 0x7FF8000000 as upper bounds, and uses either 0x200000 or 0x8000000 as the lower-bounds as the beginning of the compared range. Coincidentally, these exact same values are also used in svcGetInfo, and also when initializing the user address space, so this is actually retrieving the ASLR extents, not the extents of the address space in general.
2018-09-25svc: Report correct memory-related values within some of the cases in svcGetInfo()Lioncash1-9/+6
Previously, these were reporting hardcoded values, but given the regions can change depending on the requested address spaces, these need to report the values that the memory manager contains.
2018-09-25memory: Dehardcode the use of a 36-bit address spaceLioncash1-0/+3
Given games can also request a 32-bit or 39-bit address space, we shouldn't be hardcoding the address space range as 36-bit.
2018-09-24process/vm_manager: Amend API to allow reading parameters from NPDM metadataLioncash1-2/+82
Rather than hard-code the address range to be 36-bit, we can derive the parameters from supplied NPDM metadata if the supplied exectuable supports it. This is the bare minimum necessary for this to be possible. The following commits will rework the memory code further to adjust to this.
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi1-2/+2
2018-08-02kernel/vm_manager: Use const where applicableLioncash1-4/+4
Makes our immutable state explicit.
2018-04-27core: Replace usages of LOG_GENERIC with new fmt-capable equivalentsLioncash1-1/+1
2018-03-16svc: Use more correct values for GetInfo MapRegion and NewMapRegion.bunnei1-9/+0
2018-03-16MemoryState: Add additional memory states and improve naming.bunnei1-10/+19
2018-01-27memory: Replace all memory hooking with Special regionsMerryMage1-3/+3
2018-01-19svc: Fix svcGetInfo MapRegionBaseAddr.bunnei1-0/+3
2018-01-03vm_manager: Use a more reasonable MAX_ADDRESS size.bunnei1-5/+4
2018-01-01vm_manager: Stub out a bunch of interfaces used by svcGetInfo.bunnei1-0/+18
2017-10-20hle: Fix QueryMemory response for MemoryInfo.bunnei1-11/+8
2017-09-30core: Various changes to support 64-bit addressing.bunnei1-10/+10
2017-09-10Kernel/Memory: Give each Process its own page table.Subv1-1/+5
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
2017-05-25Kernel: Centralize error definitions in errors.hYuri Kunde Schlesner1-8/+0
2016-09-21Remove empty newlines in #include blocks.Emmanuel Gil Peyrot1-2/+0
This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
2016-09-18Sources: Run clang-format on everything.Emmanuel Gil Peyrot1-10/+11
2016-01-30Memory: Implement MMIOMerryMage1-1/+4
2015-08-16Kernel: Properly implement ControlMemory FREE and COMMITYuri Kunde Schlesner1-3/+21
2015-08-16VMManager: Introduce names for used ResultCodesYuri Kunde Schlesner1-0/+8
2015-08-16VMManager: Make LogLayout log level configurable as a parameterYuri Kunde Schlesner1-1/+1
2015-08-16VMManager: Change block offsets to size_tYuri Kunde Schlesner1-2/+2
2015-07-12Core: Properly configure address space when loading a binaryYuri Kunde Schlesner1-1/+5
The code now properly configures the process image to match the loaded binary segments (code, rodata, data) instead of just blindly allocating a large chunk of dummy memory.
2015-06-28Core: Cleanup core includes.Emmanuel Gil Peyrot1-1/+0
2015-05-27Kernel: Add VMManager to manage process address spacesYuri Kunde Schlesner1-0/+200
This enables more dynamic management of the process address space, compared to just directly configuring the page table for major areas. This will serve as the foundation upon which the rest of the Kernel memory management functions will be built.