summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-28 00:18:41 -0800
committerGravatar bunnei2021-12-28 01:25:20 -0800
commit091463a429c39969750e03a1b9cba04d7bd5a732 (patch)
tree496f636795bebc33a3fef016604f6c78c317915e /src/core/hle/kernel/svc.cpp
parentMerge pull request #7621 from bunnei/set-mem-perm (diff)
downloadyuzu-091463a429c39969750e03a1b9cba04d7bd5a732.tar.gz
yuzu-091463a429c39969750e03a1b9cba04d7bd5a732.tar.xz
yuzu-091463a429c39969750e03a1b9cba04d7bd5a732.zip
core: hle: kernel: Updated implementation of svcSetHeapSize.
- Updates our svcSetHeapSize with latest HOS, furthermore allowing heap size to properly be extended/shrunk. - Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_set_heap_size.cpp.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 68cb47211..63e2dff19 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -135,24 +135,15 @@ enum class ResourceLimitValueType {
135} // Anonymous namespace 135} // Anonymous namespace
136 136
137/// Set the process heap to a given Size. It can both extend and shrink the heap. 137/// Set the process heap to a given Size. It can both extend and shrink the heap.
138static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) { 138static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
139 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); 139 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size);
140 140
141 // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB. 141 // Validate size.
142 if ((heap_size % 0x200000) != 0) { 142 R_UNLESS(Common::IsAligned(size, HeapSizeAlignment), ResultInvalidSize);
143 LOG_ERROR(Kernel_SVC, "The heap size is not a multiple of 2MB, heap_size=0x{:016X}", 143 R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize);
144 heap_size);
145 return ResultInvalidSize;
146 }
147
148 if (heap_size >= 0x200000000) {
149 LOG_ERROR(Kernel_SVC, "The heap size is not less than 8GB, heap_size=0x{:016X}", heap_size);
150 return ResultInvalidSize;
151 }
152
153 auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
154 144
155 CASCADE_RESULT(*heap_addr, page_table.SetHeapSize(heap_size)); 145 // Set the heap size.
146 R_TRY(system.Kernel().CurrentProcess()->PageTable().SetHeapSize(out_address, size));
156 147
157 return ResultSuccess; 148 return ResultSuccess;
158} 149}