summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar David Marcec2018-11-27 12:29:06 +1100
committerGravatar David Marcec2018-11-27 12:29:06 +1100
commitf271316822c8887b1b6dfeff0803077f5ec2c0a8 (patch)
treee8144d94031332ca7439edb80ee2823774bd8a99 /src/core/hle/kernel/svc.cpp
parentFixed hwopus compile error (diff)
downloadyuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.gz
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.xz
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.zip
Reworked svcs slightly, improved error messages in AM and fsp_srv
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 7f5640adb..16e9704ff 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -63,6 +63,8 @@ bool IsInsideNewMapRegion(const VMManager& vm, VAddr address, u64 size) {
63 vm.GetNewMapRegionEndAddress()); 63 vm.GetNewMapRegionEndAddress());
64} 64}
65 65
66const u64 SZ_8GB = 0x200000000;
67
66// Helper function that performs the common sanity checks for svcMapMemory 68// Helper function that performs the common sanity checks for svcMapMemory
67// and svcUnmapMemory. This is doable, as both functions perform their sanitizing 69// and svcUnmapMemory. This is doable, as both functions perform their sanitizing
68// in the same order. 70// in the same order.
@@ -75,6 +77,7 @@ ResultCode MapUnmapMemorySanityChecks(const VMManager& vm_manager, VAddr dst_add
75 77
76 if (!Common::Is4KBAligned(src_addr)) { 78 if (!Common::Is4KBAligned(src_addr)) {
77 LOG_ERROR(Kernel_SVC, "Source address is not aligned to 4KB, 0x{:016X}", src_addr); 79 LOG_ERROR(Kernel_SVC, "Source address is not aligned to 4KB, 0x{:016X}", src_addr);
80 return ERR_INVALID_SIZE;
78 } 81 }
79 82
80 if (size == 0) { 83 if (size == 0) {
@@ -141,12 +144,15 @@ ResultCode MapUnmapMemorySanityChecks(const VMManager& vm_manager, VAddr dst_add
141static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { 144static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
142 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); 145 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
143 146
144 // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 4GB. 147 // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB.
145 if ((heap_size & 0xFFFFFFFE001FFFFF) != 0) { 148 if ((heap_size & 0x1FFFFF) != 0) {
146 LOG_ERROR( 149 LOG_ERROR(Kernel_SVC, "The heap size is not a multiple of 2MB, heap_size=0x{:016X}",
147 Kernel_SVC, 150 heap_size);
148 "The heap size is not a multiple of 2mb or is greater than 4GB, heap_size=0x{:016X}", 151 return ERR_INVALID_SIZE;
149 heap_size); 152 }
153
154 if (heap_size >= SZ_8GB) {
155 LOG_ERROR(Kernel_SVC, "The heap size is not less than 8GB, heap_size=0x{:016X}", heap_size);
150 return ERR_INVALID_SIZE; 156 return ERR_INVALID_SIZE;
151 } 157 }
152 158
@@ -1438,15 +1444,17 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
1438 u32 remote_permissions) { 1444 u32 remote_permissions) {
1439 LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size, 1445 LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size,
1440 local_permissions, remote_permissions); 1446 local_permissions, remote_permissions);
1441
1442 // Size must be a multiple of 4KB and be less than or equal to
1443 // approx. 8 GB (actually (1GB - 512B) * 8)
1444 if (size == 0) { 1447 if (size == 0) {
1445 LOG_ERROR(Kernel_SVC, "Size is 0"); 1448 LOG_ERROR(Kernel_SVC, "Size is 0");
1449 return ERR_INVALID_SIZE;
1446 } 1450 }
1447 if ((size & 0xFFFFFFFE00000FFF) != 0) { 1451 if (!Common::Is4KBAligned(size)) {
1448 LOG_ERROR(Kernel_SVC, "Size is not a multiple of 4KB or is greater than 8GB, size={:016X}", 1452 LOG_ERROR(Kernel_SVC, "Size is not aligned to 4KB, 0x{:016X}", size);
1449 size); 1453 return ERR_INVALID_SIZE;
1454 }
1455
1456 if (size >= SZ_8GB) {
1457 LOG_ERROR(Kernel_SVC, "Size is not less than 8GB, 0x{:016X}", size);
1450 return ERR_INVALID_SIZE; 1458 return ERR_INVALID_SIZE;
1451 } 1459 }
1452 1460