diff options
author | bunnei <bunneidev@gmail.com> | 2021-12-30 05:30:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-30 05:30:12 +0100 |
commit | 5e5827190374946cc906da3a5d2aa586a9721ba0 (patch) | |
tree | 201c75203b27a63f9706c1d3297c70f9d1b9ef2c /src/core/hle/kernel/svc.cpp | |
parent | Merge pull request #7618 from goldenx86/patch-4 (diff) | |
parent | core: hle: kernel: Updated implementation of svcSetHeapSize. (diff) | |
download | yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar.gz yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar.bz2 yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar.lz yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar.xz yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.tar.zst yuzu-5e5827190374946cc906da3a5d2aa586a9721ba0.zip |
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 23 |
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 { } // Anonymous namespace /// Set the process heap to a given Size. It can both extend and shrink the heap. -static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) { - LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); +static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { + LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size); - // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB. - if ((heap_size % 0x200000) != 0) { - LOG_ERROR(Kernel_SVC, "The heap size is not a multiple of 2MB, heap_size=0x{:016X}", - heap_size); - return ResultInvalidSize; - } - - if (heap_size >= 0x200000000) { - LOG_ERROR(Kernel_SVC, "The heap size is not less than 8GB, heap_size=0x{:016X}", heap_size); - return ResultInvalidSize; - } - - auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; + // Validate size. + R_UNLESS(Common::IsAligned(size, HeapSizeAlignment), ResultInvalidSize); + R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize); - CASCADE_RESULT(*heap_addr, page_table.SetHeapSize(heap_size)); + // Set the heap size. + R_TRY(system.Kernel().CurrentProcess()->PageTable().SetHeapSize(out_address, size)); return ResultSuccess; } |