Reworked svcs slightly, improved error messages in AM and fsp_srv

This commit is contained in:
David Marcec 2018-11-27 12:29:06 +11:00
parent dace6087d6
commit f271316822
3 changed files with 30 additions and 20 deletions

View File

@ -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,15 +144,18 @@ 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}",
// 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;
}
auto& process = *Core::CurrentProcess();
const VAddr heap_base = process.VMManager().GetHeapRegionBaseAddress();
CASCADE_RESULT(*heap_addr,
@ -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;
}

View File

@ -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;

View File

@ -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;