summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Marcec <dmarcecguzman@gmail.com>2018-11-27 02:29:06 +0100
committerDavid Marcec <dmarcecguzman@gmail.com>2018-11-27 02:29:06 +0100
commitf271316822c8887b1b6dfeff0803077f5ec2c0a8 (patch)
treee8144d94031332ca7439edb80ee2823774bd8a99
parentFixed hwopus compile error (diff)
downloadyuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.gz
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.bz2
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.lz
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.xz
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.tar.zst
yuzu-f271316822c8887b1b6dfeff0803077f5ec2c0a8.zip
-rw-r--r--src/core/hle/kernel/svc.cpp32
-rw-r--r--src/core/hle/service/am/am.cpp6
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp12
3 files changed, 30 insertions, 20 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) {
vm.GetNewMapRegionEndAddress());
}
+const u64 SZ_8GB = 0x200000000;
+
// Helper function that performs the common sanity checks for svcMapMemory
// and svcUnmapMemory. This is doable, as both functions perform their sanitizing
// in the same order.
@@ -75,6 +77,7 @@ ResultCode MapUnmapMemorySanityChecks(const VMManager& vm_manager, VAddr dst_add
if (!Common::Is4KBAligned(src_addr)) {
LOG_ERROR(Kernel_SVC, "Source address is not aligned to 4KB, 0x{:016X}", src_addr);
+ return ERR_INVALID_SIZE;
}
if (size == 0) {
@@ -141,12 +144,15 @@ ResultCode MapUnmapMemorySanityChecks(const VMManager& vm_manager, VAddr dst_add
static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
- // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 4GB.
- if ((heap_size & 0xFFFFFFFE001FFFFF) != 0) {
- LOG_ERROR(
- Kernel_SVC,
- "The heap size is not a multiple of 2mb or is greater than 4GB, heap_size=0x{:016X}",
- heap_size);
+ // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB.
+ if ((heap_size & 0x1FFFFF) != 0) {
+ LOG_ERROR(Kernel_SVC, "The heap size is not a multiple of 2MB, heap_size=0x{:016X}",
+ heap_size);
+ return ERR_INVALID_SIZE;
+ }
+
+ if (heap_size >= SZ_8GB) {
+ LOG_ERROR(Kernel_SVC, "The heap size is not less than 8GB, heap_size=0x{:016X}", heap_size);
return ERR_INVALID_SIZE;
}
@@ -1438,15 +1444,17 @@ static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permiss
u32 remote_permissions) {
LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size,
local_permissions, remote_permissions);
-
- // Size must be a multiple of 4KB and be less than or equal to
- // approx. 8 GB (actually (1GB - 512B) * 8)
if (size == 0) {
LOG_ERROR(Kernel_SVC, "Size is 0");
+ return ERR_INVALID_SIZE;
}
- if ((size & 0xFFFFFFFE00000FFF) != 0) {
- LOG_ERROR(Kernel_SVC, "Size is not a multiple of 4KB or is greater than 8GB, size={:016X}",
- size);
+ if (!Common::Is4KBAligned(size)) {
+ LOG_ERROR(Kernel_SVC, "Size is not aligned to 4KB, 0x{:016X}", size);
+ return ERR_INVALID_SIZE;
+ }
+
+ if (size >= SZ_8GB) {
+ LOG_ERROR(Kernel_SVC, "Size is not less than 8GB, 0x{:016X}", size);
return ERR_INVALID_SIZE;
}
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index f6757adab..d595c37b0 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -616,7 +616,8 @@ private:
const auto storage = applet->GetBroker().PopNormalDataToGame();
if (storage == nullptr) {
- LOG_ERROR(Service_AM, "storage is a nullptr. There is no data in the current channel");
+ LOG_ERROR(Service_AM,
+ "storage is a nullptr. There is no data in the current normal channel");
rb.Push(ERR_NO_DATA_IN_CHANNEL);
return;
@@ -647,7 +648,8 @@ private:
const auto storage = applet->GetBroker().PopInteractiveDataToGame();
if (storage == nullptr) {
- LOG_ERROR(Service_AM, "storage is a nullptr. There is no data in the current channel");
+ LOG_ERROR(Service_AM,
+ "storage is a nullptr. There is no data in the current interactive channel");
rb.Push(ERR_NO_DATA_IN_CHANNEL);
return;
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 233cb302f..99d9ebc39 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -62,13 +62,13 @@ private:
// Error checking
if (length < 0) {
- LOG_ERROR(Service_FS, "Invalid length provided");
+ LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_SIZE);
return;
}
if (offset < 0) {
- LOG_ERROR(Service_FS, "Invalid offset provided");
+ LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_OFFSET);
return;
@@ -109,13 +109,13 @@ private:
// Error checking
if (length < 0) {
- LOG_ERROR(Service_FS, "Invalid length provided");
+ LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_SIZE);
return;
}
if (offset < 0) {
- LOG_ERROR(Service_FS, "Invalid offset provided");
+ LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_OFFSET);
return;
@@ -142,13 +142,13 @@ private:
// Error checking
if (length < 0) {
- LOG_ERROR(Service_FS, "Invalid length provided");
+ LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_SIZE);
return;
}
if (offset < 0) {
- LOG_ERROR(Service_FS, "Invalid offset provided");
+ LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(FileSys::ERROR_INVALID_OFFSET);
return;