diff --git a/exosphere/program/source/smc/secmon_smc_info.cpp b/exosphere/program/source/smc/secmon_smc_info.cpp index 334072f73..af030aeda 100644 --- a/exosphere/program/source/smc/secmon_smc_info.cpp +++ b/exosphere/program/source/smc/secmon_smc_info.cpp @@ -440,7 +440,6 @@ namespace ams::secmon::smc { const uintptr_t user_offset = user_address % 4_KB; /* Validate arguments. */ - /* NOTE: Only eMMC and SD redirection supported. GC redirection may be supported in the future */ SMC_R_UNLESS(mmc == EmummcMmc_Nand || mmc == EmummcMmc_Sd, NotSupported); SMC_R_UNLESS(mmc != EmummcMmc_Nand || user_offset + 2 * sizeof(EmummcFilePath) <= 4_KB, InvalidArgument); @@ -489,14 +488,24 @@ namespace ams::secmon::smc { static_assert(sizeof(cfg.base_cfg) <= InlineOutputSize); std::memcpy(inline_output, std::addressof(cfg.base_cfg), sizeof(cfg.base_cfg)); + AtmosphereUserPageMapper mapper(user_address); + SMC_R_UNLESS(mapper.Map(), InvalidArgument); + switch(cfg.base_cfg.type) { case EmummcSdType_None: + /* Nothing to be copied if disabled */ break; case EmummcSdType_Partition_Emmc: + case EmummcSdType_Partition_Sd: + /* Copy partition config */ static_assert(sizeof(cfg.base_cfg) + sizeof(cfg.partition_cfg) <= InlineOutputSize); std::memcpy(inline_output + sizeof(cfg.base_cfg), std::addressof(cfg.partition_cfg), sizeof(cfg.partition_cfg)); break; - /* File based and SD partition based (currently) not supported for SD redirection */ + case EmummcSdType_File_Emmc: + case EmummcSdType_File_Sd: + /* Copy file config */ + SMC_R_UNLESS(mapper.CopyToUser(user_address, std::addressof(cfg.file_cfg), sizeof(cfg.file_cfg)), InvalidArgument); + break; AMS_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp index 9c9ae2618..212c8cd38 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_configuration_context.arch.arm64.hpp @@ -20,7 +20,6 @@ #include namespace ams::secmon { - struct ConfigurationContext { union { SecureMonitorConfiguration secmon_cfg; @@ -28,7 +27,7 @@ namespace ams::secmon { }; union { EmummcConfiguration emummc_cfg; - u8 _raw_emummc_config[0x128]; + u8 _raw_emummc_config[0x1A0]; }; u8 sealed_device_keys[pkg1::KeyGeneration_Max][se::AesBlockSize]; u8 sealed_master_keys[pkg1::KeyGeneration_Max][se::AesBlockSize]; diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_emummc_context.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_emummc_context.hpp index 784a0c007..f864cde56 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_emummc_context.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_emummc_context.hpp @@ -29,10 +29,9 @@ namespace ams::secmon { enum EmummcSdType : u32 { EmummcSdType_None = 0, EmummcSdType_Partition_Emmc = 3, - // Not (currently) supported - // EmummcSdType_Partition_Sd = 1, - // EmummcSdType_File_Sd = 2, - // EmummcSdType_File_Emmc = 4, + EmummcSdType_Partition_Sd = 1, + EmummcSdType_File_Sd = 2, + EmummcSdType_File_Emmc = 4, }; enum EmummcMmc { @@ -121,8 +120,7 @@ namespace ams::secmon { EmummcSdBaseConfiguration base_cfg; union { EmummcPartitionConfiguration partition_cfg; - /* File based currently not supported */ - /* EmummcFileConfiguration file_cfg */ + EmummcFileConfiguration file_cfg; }; constexpr bool IsValid() const { @@ -134,7 +132,7 @@ namespace ams::secmon { } }; static_assert(util::is_pod::value); - static_assert(sizeof(EmummcSdConfiguration) == 0x18); + static_assert(sizeof(EmummcSdConfiguration) == 0x90); struct EmummcConfiguration { EmummcEmmcConfiguration emmc_cfg; diff --git a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp index d12c1d88f..dd1286f33 100644 --- a/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp +++ b/libraries/libexosphere/include/exosphere/secmon/secmon_monitor_context.hpp @@ -50,7 +50,7 @@ namespace ams::secmon { constexpr bool IsValid() const { return this->magic == Magic; } }; static_assert(util::is_pod::value); - static_assert(sizeof(SecureMonitorStorageConfiguration) == 0x148); + static_assert(sizeof(SecureMonitorStorageConfiguration) == 0x1C0); struct SecureMonitorConfiguration { ams::TargetFirmware target_firmware; diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp index 62cce555b..506c5432d 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp @@ -501,6 +501,7 @@ namespace ams::sdmmc::impl { if (!is_read) { #ifdef ATMOSPHERE_IS_EXOSPHERE /* Allow unaligned writes */ + /* TODO: bad */ constexpr u32 MmcWriteSectorAlignment = 0; #else constexpr u32 MmcWriteSectorAlignment = 16_KB / SectorSize;