mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-13 12:52:13 +02:00
Compare commits
3 Commits
db3dc4ebd2
...
e09ba765a1
Author | SHA1 | Date | |
---|---|---|---|
|
e09ba765a1 | ||
|
3217df147e | ||
|
1fa41c3e2a |
@ -96,7 +96,7 @@ namespace ams::nxboot::loader {
|
||||
}
|
||||
|
||||
void Uncompress(void *dst, size_t dst_size, const void *src, size_t src_size) {
|
||||
/* Create an execute a decompressor. */
|
||||
/* Create and execute a decompressor. */
|
||||
Lz4Uncompressor(dst, dst_size, src, src_size).Uncompress();
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,11 @@ namespace ams::kern {
|
||||
case RegionType::NoMapping:
|
||||
break;
|
||||
case RegionType::KernelTraceBuffer:
|
||||
/* NOTE: This does not match official, but is used to make pre-processing hbl capabilities in userland unnecessary. */
|
||||
/* If ktrace isn't enabled, allow ktrace to succeed without mapping anything. */
|
||||
if constexpr (!ams::kern::IsKTraceEnabled) {
|
||||
break;
|
||||
}
|
||||
case RegionType::OnMemoryBootImage:
|
||||
case RegionType::DTB:
|
||||
R_TRY(f(MemoryRegions[static_cast<u32>(type)], perm));
|
||||
|
@ -107,7 +107,6 @@ namespace ams::kern {
|
||||
R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions());
|
||||
new_sessions = cur_sessions + 1;
|
||||
} while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions));
|
||||
|
||||
}
|
||||
|
||||
/* Atomically update the peak session tracking. */
|
||||
@ -182,7 +181,6 @@ namespace ams::kern {
|
||||
R_UNLESS(cur_sessions < max, svc::ResultOutOfSessions());
|
||||
new_sessions = cur_sessions + 1;
|
||||
} while (!m_num_sessions.CompareExchangeWeak<std::memory_order_relaxed>(cur_sessions, new_sessions));
|
||||
|
||||
}
|
||||
|
||||
/* Atomically update the peak session tracking. */
|
||||
|
@ -3624,7 +3624,7 @@ namespace ams::kern {
|
||||
R_UNLESS(this->Contains(address, size), svc::ResultInvalidCurrentMemory());
|
||||
|
||||
/* Get the source permission. */
|
||||
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead);
|
||||
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead);
|
||||
|
||||
/* Get aligned extents. */
|
||||
const KProcessAddress aligned_src_start = util::AlignDown(GetInteger(address), PageSize);
|
||||
@ -3953,7 +3953,7 @@ namespace ams::kern {
|
||||
const size_t src_map_size = src_map_end - src_map_start;
|
||||
|
||||
/* Ensure that we clean up appropriately if we fail after this. */
|
||||
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped : KMemoryPermission_UserRead);
|
||||
const auto src_perm = static_cast<KMemoryPermission>((test_perm == KMemoryPermission_UserReadWrite) ? (KMemoryPermission_KernelReadWrite | KMemoryPermission_NotMapped) : KMemoryPermission_UserRead);
|
||||
ON_RESULT_FAILURE {
|
||||
if (src_map_end > src_map_start) {
|
||||
src_page_table.CleanupForIpcClientOnServerSetupFailure(updater.GetPageList(), src_map_start, src_map_size, src_perm);
|
||||
@ -4488,7 +4488,7 @@ namespace ams::kern {
|
||||
}
|
||||
}
|
||||
|
||||
/* Map the papges. */
|
||||
/* Map the pages. */
|
||||
R_TRY(this->Operate(updater.GetPageList(), cur_address, map_pages, cur_pg, map_properties, OperationType_MapFirstGroup, false));
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace ams::kern {
|
||||
|
||||
/* Cleanup the session list. */
|
||||
while (true) {
|
||||
/* Get the last session in the list */
|
||||
/* Get the last session in the list. */
|
||||
KServerSession *session = nullptr;
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
@ -56,7 +56,7 @@ namespace ams::kern {
|
||||
|
||||
/* Cleanup the light session list. */
|
||||
while (true) {
|
||||
/* Get the last session in the list */
|
||||
/* Get the last session in the list. */
|
||||
KLightServerSession *session = nullptr;
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
|
@ -650,7 +650,7 @@ namespace ams::kern {
|
||||
const auto src_state = src_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped;
|
||||
|
||||
/* Determine the source permission. User buffer should be unmapped + read, TLS should be user readable. */
|
||||
const KMemoryPermission src_perm = static_cast<KMemoryPermission>(src_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelRead : KMemoryPermission_UserRead);
|
||||
const KMemoryPermission src_perm = static_cast<KMemoryPermission>(src_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelRead) : KMemoryPermission_UserRead);
|
||||
|
||||
/* Perform the fast part of the copy. */
|
||||
R_TRY(src_page_table.CopyMemoryFromLinearToKernel(reinterpret_cast<uintptr_t>(dst_msg_ptr) + offset_words, fast_size, src_message_buffer + offset_words,
|
||||
@ -753,7 +753,7 @@ namespace ams::kern {
|
||||
/* Perform the pointer data copy. */
|
||||
const bool dst_heap = dst_user && dst_recv_list.IsToMessageBuffer();
|
||||
const auto dst_state = dst_heap ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped;
|
||||
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_heap ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite);
|
||||
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_heap ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite);
|
||||
R_TRY(dst_page_table.CopyMemoryFromUserToLinear(recv_pointer, recv_size,
|
||||
dst_state, dst_state,
|
||||
dst_perm,
|
||||
@ -911,7 +911,7 @@ namespace ams::kern {
|
||||
const auto dst_state = dst_user ? KMemoryState_FlagReferenceCounted : KMemoryState_FlagLinearMapped;
|
||||
|
||||
/* Determine the dst permission. User buffer should be unmapped + read, TLS should be user readable. */
|
||||
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_user ? KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite : KMemoryPermission_UserReadWrite);
|
||||
const KMemoryPermission dst_perm = static_cast<KMemoryPermission>(dst_user ? (KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite) : KMemoryPermission_UserReadWrite);
|
||||
|
||||
/* Perform the fast part of the copy. */
|
||||
R_TRY(dst_page_table.CopyMemoryFromKernelToLinear(dst_message_buffer + offset_words, fast_size,
|
||||
|
@ -143,7 +143,7 @@ namespace ams::kern::svc {
|
||||
/* Get the process page table. */
|
||||
auto &page_table = GetCurrentProcess().GetPageTable();
|
||||
|
||||
/* Lock the mesage buffer. */
|
||||
/* Lock the message buffer. */
|
||||
R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size));
|
||||
|
||||
{
|
||||
@ -186,7 +186,7 @@ namespace ams::kern::svc {
|
||||
/* Commit our reservation. */
|
||||
event_reservation.Commit();
|
||||
|
||||
/* At end of scope, kill the standing references to the sub events. */
|
||||
/* At end of scope, kill the standing event references. */
|
||||
ON_SCOPE_EXIT {
|
||||
event->GetReadableEvent().Close();
|
||||
event->Close();
|
||||
@ -215,7 +215,7 @@ namespace ams::kern::svc {
|
||||
/* Get the process page table. */
|
||||
auto &page_table = GetCurrentProcess().GetPageTable();
|
||||
|
||||
/* Lock the mesage buffer. */
|
||||
/* Lock the message buffer. */
|
||||
R_TRY(page_table.LockForIpcUserBuffer(nullptr, message, buffer_size));
|
||||
|
||||
/* Ensure that if we fail and aren't terminating that we unlock the user buffer. */
|
||||
@ -242,7 +242,7 @@ namespace ams::kern::svc {
|
||||
/* Get the process page table. */
|
||||
auto &page_table = GetCurrentProcess().GetPageTable();
|
||||
|
||||
/* Lock the mesage buffer, getting its physical address. */
|
||||
/* Lock the message buffer, getting its physical address. */
|
||||
KPhysicalAddress message_paddr;
|
||||
R_TRY(page_table.LockForIpcUserBuffer(std::addressof(message_paddr), message, buffer_size));
|
||||
|
||||
|
@ -96,7 +96,7 @@ namespace ams::kern::svc {
|
||||
/* Add the client to the handle table. */
|
||||
R_TRY(handle_table.Add(out_client, std::addressof(port->GetClientPort())));
|
||||
|
||||
/* Ensure that we maintaing a clean handle state on exit. */
|
||||
/* Ensure that we maintain a clean handle state on exit. */
|
||||
ON_RESULT_FAILURE { handle_table.Remove(*out_client); };
|
||||
|
||||
/* Add the server to the handle table. */
|
||||
|
@ -167,6 +167,7 @@ namespace ams::patcher {
|
||||
|
||||
/* Apply patch. */
|
||||
if (patch_offset + rle_size > mapped_size) {
|
||||
AMS_ABORT_UNLESS(patch_offset <= mapped_size);
|
||||
rle_size = mapped_size - patch_offset;
|
||||
}
|
||||
std::memset(mapped_module + patch_offset, buffer[0], rle_size);
|
||||
@ -190,6 +191,7 @@ namespace ams::patcher {
|
||||
/* Apply patch. */
|
||||
u32 read_size = patch_size;
|
||||
if (patch_offset + read_size > mapped_size) {
|
||||
AMS_ABORT_UNLESS(patch_offset <= mapped_size);
|
||||
read_size = mapped_size - patch_offset;
|
||||
}
|
||||
{
|
||||
|
@ -418,15 +418,7 @@ namespace ams::ldr {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const auto cap = kac[i];
|
||||
switch (GetCapabilityId(cap)) {
|
||||
case CapabilityId::MapRegion:
|
||||
{
|
||||
/* MapRegion was added in 8.0.0+, and is only allowed under kernels which have the relevant mappings. */
|
||||
/* However, we allow it under all firmwares on mesosphere, to facilitate KTrace usage by hbl. */
|
||||
if (!svc::IsKTraceEnabled()) {
|
||||
kac[i] = EmptyCapability;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* NOTE: Currently, there is no pre-processing necessary. */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user