diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp index 297d30b52..7209dbfa1 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp @@ -110,12 +110,12 @@ namespace ams::kern::arch::arm64 { R_RETURN(m_page_table.MapRegion(region_type, perm)); } - Result MapInsecureMemory(KProcessAddress address, size_t size) { - R_RETURN(m_page_table.MapInsecureMemory(address, size)); + Result MapInsecurePhysicalMemory(KProcessAddress address, size_t size) { + R_RETURN(m_page_table.MapInsecurePhysicalMemory(address, size)); } - Result UnmapInsecureMemory(KProcessAddress address, size_t size) { - R_RETURN(m_page_table.UnmapInsecureMemory(address, size)); + Result UnmapInsecurePhysicalMemory(KProcessAddress address, size_t size) { + R_RETURN(m_page_table.UnmapInsecurePhysicalMemory(address, size)); } Result MapPageGroup(KProcessAddress addr, const KPageGroup &pg, KMemoryState state, KMemoryPermission perm) { diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp index 530b68dea..51e4c4075 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp @@ -387,8 +387,8 @@ namespace ams::kern { Result UnmapIoRegion(KProcessAddress dst_address, KPhysicalAddress phys_addr, size_t size, ams::svc::MemoryMapping mapping); Result MapStatic(KPhysicalAddress phys_addr, size_t size, KMemoryPermission perm); Result MapRegion(KMemoryRegionType region_type, KMemoryPermission perm); - Result MapInsecureMemory(KProcessAddress address, size_t size); - Result UnmapInsecureMemory(KProcessAddress address, size_t size); + Result MapInsecurePhysicalMemory(KProcessAddress address, size_t size); + Result UnmapInsecurePhysicalMemory(KProcessAddress address, size_t size); Result MapPages(KProcessAddress *out_addr, size_t num_pages, size_t alignment, KPhysicalAddress phys_addr, KProcessAddress region_start, size_t region_num_pages, KMemoryState state, KMemoryPermission perm) { R_RETURN(this->MapPages(out_addr, num_pages, alignment, phys_addr, true, region_start, region_num_pages, state, perm)); diff --git a/libraries/libmesosphere/source/arch/arm64/svc/kern_svc_tables.cpp b/libraries/libmesosphere/source/arch/arm64/svc/kern_svc_tables.cpp index aec27c4ba..cb9151823 100644 --- a/libraries/libmesosphere/source/arch/arm64/svc/kern_svc_tables.cpp +++ b/libraries/libmesosphere/source/arch/arm64/svc/kern_svc_tables.cpp @@ -142,10 +142,10 @@ namespace ams::kern::svc { /* Get the target firmware. */ const auto target_fw = kern::GetTargetFirmware(); - /* 10.0.0 broke the ABI for QueryIoMapping. */ + /* 10.0.0 broke the ABI for QueryIoMapping, and renamed it to QueryMemoryMapping. */ if (target_fw < TargetFirmware_10_0_0) { - if (table_64) { ::ams::kern::svc::PatchSvcTableEntry(table_64, svc::SvcId_QueryIoMapping, LegacyQueryIoMapping::Call64); } - if (table_64_from_32) { ::ams::kern::svc::PatchSvcTableEntry(table_64_from_32, svc::SvcId_QueryIoMapping, LegacyQueryIoMapping::Call64From32); } + if (table_64) { ::ams::kern::svc::PatchSvcTableEntry(table_64, svc::SvcId_QueryMemoryMapping, LegacyQueryIoMapping::Call64); } + if (table_64_from_32) { ::ams::kern::svc::PatchSvcTableEntry(table_64_from_32, svc::SvcId_QueryMemoryMapping, LegacyQueryIoMapping::Call64From32); } } /* 6.0.0 broke the ABI for GetFutureThreadInfo, and renamed it to GetDebugFutureThreadInfo. */ diff --git a/libraries/libmesosphere/source/kern_k_page_table_base.cpp b/libraries/libmesosphere/source/kern_k_page_table_base.cpp index bfa687aed..d1ee43054 100644 --- a/libraries/libmesosphere/source/kern_k_page_table_base.cpp +++ b/libraries/libmesosphere/source/kern_k_page_table_base.cpp @@ -1072,7 +1072,7 @@ namespace ams::kern { R_SUCCEED(); } - Result KPageTableBase::MapInsecureMemory(KProcessAddress address, size_t size) { + Result KPageTableBase::MapInsecurePhysicalMemory(KProcessAddress address, size_t size) { /* Get the insecure memory resource limit and pool. */ auto * const insecure_resource_limit = KSystemControl::GetInsecureMemoryResourceLimit(); const auto insecure_pool = static_cast(KSystemControl::GetInsecureMemoryPool()); @@ -1128,7 +1128,7 @@ namespace ams::kern { R_SUCCEED(); } - Result KPageTableBase::UnmapInsecureMemory(KProcessAddress address, size_t size) { + Result KPageTableBase::UnmapInsecurePhysicalMemory(KProcessAddress address, size_t size) { /* Lock the table. */ KScopedLightLock lk(m_general_lock); diff --git a/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp b/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp index 746eed6bb..e93fbfd55 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp @@ -37,7 +37,7 @@ namespace ams::kern::svc { R_SUCCEED(); } - Result QueryIoMapping(uintptr_t *out_address, size_t *out_size, uint64_t phys_addr, size_t size) { + Result QueryMemoryMapping(uintptr_t *out_address, size_t *out_size, uint64_t phys_addr, size_t size) { /* Declare variables we'll populate. */ KProcessAddress found_address = Null; size_t found_size = 0; @@ -125,15 +125,15 @@ namespace ams::kern::svc { R_RETURN(QueryPhysicalAddress(out_info, address)); } - Result QueryIoMapping64(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { + Result QueryMemoryMapping64(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); static_assert(sizeof(*out_size) == sizeof(size_t)); - R_RETURN(QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); + R_RETURN(QueryMemoryMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } Result LegacyQueryIoMapping64(ams::svc::Address *out_address, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - R_RETURN(QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); + R_RETURN(QueryMemoryMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); } /* ============================= 64From32 ABI ============================= */ @@ -150,15 +150,15 @@ namespace ams::kern::svc { R_SUCCEED(); } - Result QueryIoMapping64From32(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { + Result QueryMemoryMapping64From32(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); static_assert(sizeof(*out_size) == sizeof(size_t)); - R_RETURN(QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); + R_RETURN(QueryMemoryMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } Result LegacyQueryIoMapping64From32(ams::svc::Address *out_address, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - R_RETURN(QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); + R_RETURN(QueryMemoryMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_insecure_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_insecure_memory.cpp index c358bff2d..c0262b5c1 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_insecure_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_insecure_memory.cpp @@ -21,7 +21,7 @@ namespace ams::kern::svc { namespace { - Result MapInsecureMemory(uintptr_t address, size_t size) { + Result MapInsecurePhysicalMemory(uintptr_t address, size_t size) { /* Validate the address/size. */ R_UNLESS(util::IsAligned(size, PageSize), svc::ResultInvalidSize()); R_UNLESS(size > 0, svc::ResultInvalidSize()); @@ -33,10 +33,10 @@ namespace ams::kern::svc { R_UNLESS(GetCurrentProcess().GetPageTable().CanContain(address, size, KMemoryState_Insecure), svc::ResultInvalidMemoryRegion()); /* Map the insecure memory. */ - R_RETURN(pt.MapInsecureMemory(address, size)); + R_RETURN(pt.MapInsecurePhysicalMemory(address, size)); } - Result UnmapInsecureMemory(uintptr_t address, size_t size) { + Result UnmapInsecurePhysicalMemory(uintptr_t address, size_t size) { /* Validate the address/size. */ R_UNLESS(util::IsAligned(size, PageSize), svc::ResultInvalidSize()); R_UNLESS(size > 0, svc::ResultInvalidSize()); @@ -48,29 +48,29 @@ namespace ams::kern::svc { R_UNLESS(GetCurrentProcess().GetPageTable().CanContain(address, size, KMemoryState_Insecure), svc::ResultInvalidMemoryRegion()); /* Map the insecure memory. */ - R_RETURN(pt.UnmapInsecureMemory(address, size)); + R_RETURN(pt.UnmapInsecurePhysicalMemory(address, size)); } } /* ============================= 64 ABI ============================= */ - Result MapInsecureMemory64(ams::svc::Address address, ams::svc::Size size) { - R_RETURN(MapInsecureMemory(address, size)); + Result MapInsecurePhysicalMemory64(ams::svc::Address address, ams::svc::Size size) { + R_RETURN(MapInsecurePhysicalMemory(address, size)); } - Result UnmapInsecureMemory64(ams::svc::Address address, ams::svc::Size size) { - R_RETURN(UnmapInsecureMemory(address, size)); + Result UnmapInsecurePhysicalMemory64(ams::svc::Address address, ams::svc::Size size) { + R_RETURN(UnmapInsecurePhysicalMemory(address, size)); } /* ============================= 64From32 ABI ============================= */ - Result MapInsecureMemory64From32(ams::svc::Address address, ams::svc::Size size) { - R_RETURN(MapInsecureMemory(address, size)); + Result MapInsecurePhysicalMemory64From32(ams::svc::Address address, ams::svc::Size size) { + R_RETURN(MapInsecurePhysicalMemory(address, size)); } - Result UnmapInsecureMemory64From32(ams::svc::Address address, ams::svc::Size size) { - R_RETURN(UnmapInsecureMemory(address, size)); + Result UnmapInsecurePhysicalMemory64From32(ams::svc::Address address, ams::svc::Size size) { + R_RETURN(UnmapInsecurePhysicalMemory(address, size)); } } diff --git a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp index 8e34756de..b724ce5f1 100644 --- a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp +++ b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp @@ -331,8 +331,8 @@ R_RETURN(::svcQueryPhysicalAddress(reinterpret_cast<::PhysicalMemoryInfo *>(out_info), address)); } - ALWAYS_INLINE Result QueryIoMapping(::ams::svc::Address *out_address, ::ams::svc::Size *out_size, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { - R_RETURN(::svcQueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); + ALWAYS_INLINE Result QueryMemoryMapping(::ams::svc::Address *out_address, ::ams::svc::Size *out_size, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { + R_RETURN(::svcQueryMemoryMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } ALWAYS_INLINE Result LegacyQueryIoMapping(::ams::svc::Address *out_address, ::ams::svc::PhysicalAddress physical_address, ::ams::svc::Size size) { @@ -503,12 +503,12 @@ ::svcCallSecureMonitor(reinterpret_cast<::SecmonArgs *>(args)); } - ALWAYS_INLINE Result MapInsecureMemory(::ams::svc::Address address, ::ams::svc::Size size) { - R_RETURN(::svcMapInsecureMemory(reinterpret_cast(static_cast(address)), size)); + ALWAYS_INLINE Result MapInsecurePhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { + R_RETURN(::svcMapInsecurePhysicalMemory(reinterpret_cast(static_cast(address)), size)); } - ALWAYS_INLINE Result UnmapInsecureMemory(::ams::svc::Address address, ::ams::svc::Size size) { - R_RETURN(::svcUnmapInsecureMemory(reinterpret_cast(static_cast(address)), size)); + ALWAYS_INLINE Result UnmapInsecurePhysicalMemory(::ams::svc::Address address, ::ams::svc::Size size) { + R_RETURN(::svcUnmapInsecurePhysicalMemory(reinterpret_cast(static_cast(address)), size)); } } diff --git a/libraries/libstratosphere/source/os/impl/os_insecure_memory_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_insecure_memory_impl.os.horizon.cpp index fd8e78f9f..27ffab700 100644 --- a/libraries/libstratosphere/source/os/impl/os_insecure_memory_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_insecure_memory_impl.os.horizon.cpp @@ -23,7 +23,7 @@ namespace ams::os::impl { /* Map at a random address. */ R_RETURN(impl::GetAslrSpaceManager().MapAtRandomAddress(out_address, [](uintptr_t map_address, size_t map_size) -> Result { - R_TRY_CATCH(svc::MapInsecureMemory(map_address, map_size)) { + R_TRY_CATCH(svc::MapInsecurePhysicalMemory(map_address, map_size)) { R_CONVERT(svc::ResultOutOfMemory, os::ResultOutOfMemory()) R_CONVERT(svc::ResultInvalidCurrentMemory, os::ResultInvalidCurrentMemoryState()) } R_END_TRY_CATCH_WITH_ABORT_UNLESS; @@ -39,7 +39,7 @@ namespace ams::os::impl { } void InsecureMemoryImpl::FreeInsecureMemoryImpl(uintptr_t address, size_t size) { - R_ABORT_UNLESS(svc::UnmapInsecureMemory(address, size)); + R_ABORT_UNLESS(svc::UnmapInsecurePhysicalMemory(address, size)); } } diff --git a/libraries/libvapours/include/vapours/svc/svc_definition_macro.hpp b/libraries/libvapours/include/vapours/svc/svc_definition_macro.hpp index d4668e445..0f1c57783 100644 --- a/libraries/libvapours/include/vapours/svc/svc_definition_macro.hpp +++ b/libraries/libvapours/include/vapours/svc/svc_definition_macro.hpp @@ -99,7 +99,7 @@ HANDLER(0x52, Result, UnmapTransferMemory, INPUT(::ams::svc::Handle, trmem_handle), INPUT(::ams::svc::Address, address), INPUT(::ams::svc::Size, size)) \ HANDLER(0x53, Result, CreateInterruptEvent, OUTPUT(::ams::svc::Handle, out_read_handle), INPUT(int32_t, interrupt_id), INPUT(::ams::svc::InterruptType, interrupt_type)) \ HANDLER(0x54, Result, QueryPhysicalAddress, OUTPUT(::ams::svc::NAMESPACE::PhysicalMemoryInfo, out_info), INPUT(::ams::svc::Address, address)) \ - HANDLER(0x55, Result, QueryIoMapping, OUTPUT(::ams::svc::Address, out_address), OUTPUT(::ams::svc::Size, out_size), INPUT(::ams::svc::PhysicalAddress, physical_address), INPUT(::ams::svc::Size, size)) \ + HANDLER(0x55, Result, QueryMemoryMapping, OUTPUT(::ams::svc::Address, out_address), OUTPUT(::ams::svc::Size, out_size), INPUT(::ams::svc::PhysicalAddress, physical_address), INPUT(::ams::svc::Size, size)) \ HANDLER(0x56, Result, CreateDeviceAddressSpace, OUTPUT(::ams::svc::Handle, out_handle), INPUT(uint64_t, das_address), INPUT(uint64_t, das_size)) \ HANDLER(0x57, Result, AttachDeviceAddressSpace, INPUT(::ams::svc::DeviceName, device_name), INPUT(::ams::svc::Handle, das_handle)) \ HANDLER(0x58, Result, DetachDeviceAddressSpace, INPUT(::ams::svc::DeviceName, device_name), INPUT(::ams::svc::Handle, das_handle)) \ @@ -142,8 +142,8 @@ HANDLER(0x7E, Result, SetResourceLimitLimitValue, INPUT(::ams::svc::Handle, resource_limit_handle), INPUT(::ams::svc::LimitableResource, which), INPUT(int64_t, limit_value)) \ HANDLER(0x7F, void, CallSecureMonitor, OUTPUT(::ams::svc::NAMESPACE::SecureMonitorArguments, args)) \ \ - HANDLER(0x90, Result, MapInsecureMemory, INPUT(::ams::svc::Address, address), INPUT(::ams::svc::Size, size)) \ - HANDLER(0x91, Result, UnmapInsecureMemory, INPUT(::ams::svc::Address, address), INPUT(::ams::svc::Size, size)) \ + HANDLER(0x90, Result, MapInsecurePhysicalMemory, INPUT(::ams::svc::Address, address), INPUT(::ams::svc::Size, size)) \ + HANDLER(0x91, Result, UnmapInsecurePhysicalMemory, INPUT(::ams::svc::Address, address), INPUT(::ams::svc::Size, size)) \ \ HANDLER(0x2E, Result, LegacyGetFutureThreadInfo, OUTPUT(::ams::svc::NAMESPACE::LastThreadContext, out_context), OUTPUT(::ams::svc::Address, out_tls_address), OUTPUT(uint32_t, out_flags), INPUT(int64_t, ns)) \ HANDLER(0x55, Result, LegacyQueryIoMapping, OUTPUT(::ams::svc::Address, out_address), INPUT(::ams::svc::PhysicalAddress, physical_address), INPUT(::ams::svc::Size, size)) \ diff --git a/libraries/libvapours/source/dd/dd_io_mapping.os.horizon.cpp b/libraries/libvapours/source/dd/dd_io_mapping.os.horizon.cpp index b549b99a4..11d7c4971 100644 --- a/libraries/libvapours/source/dd/dd_io_mapping.os.horizon.cpp +++ b/libraries/libvapours/source/dd/dd_io_mapping.os.horizon.cpp @@ -68,7 +68,7 @@ namespace ams::dd { if (hos::GetVersion() >= hos::Version_10_0_0) { svc::Size region_size = 0; - R_TRY_CATCH(svc::QueryIoMapping(std::addressof(virt_addr), std::addressof(region_size), aligned_addr, aligned_size)) { + R_TRY_CATCH(svc::QueryMemoryMapping(std::addressof(virt_addr), std::addressof(region_size), aligned_addr, aligned_size)) { /* Official software handles this by returning 0. */ R_CATCH(svc::ResultNotFound) { return 0; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS;