yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #1498 from lioncash/aslr

svc: Clarify enum values for AddressSpaceBaseAddr and AddressSpaceSize in svcGetInfo()
This commit is contained in:
bunnei 2018-10-17 18:31:51 -04:00 committed by GitHub
commit 6e8752881c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 28 deletions

View File

@ -448,25 +448,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
case GetInfoType::RandomEntropy: case GetInfoType::RandomEntropy:
*result = 0; *result = 0;
break; break;
case GetInfoType::AddressSpaceBaseAddr: case GetInfoType::ASLRRegionBaseAddr:
*result = vm_manager.GetCodeRegionBaseAddress(); *result = vm_manager.GetASLRRegionBaseAddress();
break; break;
case GetInfoType::AddressSpaceSize: { case GetInfoType::ASLRRegionSize:
const u64 width = vm_manager.GetAddressSpaceWidth(); *result = vm_manager.GetASLRRegionSize();
switch (width) {
case 32:
*result = 0xFFE00000;
break; break;
case 36:
*result = 0xFF8000000;
break;
case 39:
*result = 0x7FF8000000;
break;
}
break;
}
case GetInfoType::NewMapRegionBaseAddr: case GetInfoType::NewMapRegionBaseAddr:
*result = vm_manager.GetNewMapRegionBaseAddress(); *result = vm_manager.GetNewMapRegionBaseAddress();
break; break;

View File

@ -41,8 +41,8 @@ enum class GetInfoType : u64 {
RandomEntropy = 11, RandomEntropy = 11,
PerformanceCounter = 0xF0000002, PerformanceCounter = 0xF0000002,
// 2.0.0+ // 2.0.0+
AddressSpaceBaseAddr = 12, ASLRRegionBaseAddr = 12,
AddressSpaceSize = 13, ASLRRegionSize = 13,
NewMapRegionBaseAddr = 14, NewMapRegionBaseAddr = 14,
NewMapRegionSize = 15, NewMapRegionSize = 15,
// 3.0.0+ // 3.0.0+

View File

@ -393,30 +393,35 @@ void VMManager::InitializeMemoryRegionRanges(FileSys::ProgramAddressSpaceType ty
switch (type) { switch (type) {
case FileSys::ProgramAddressSpaceType::Is32Bit: case FileSys::ProgramAddressSpaceType::Is32Bit:
case FileSys::ProgramAddressSpaceType::Is32BitNoMap:
address_space_width = 32; address_space_width = 32;
code_region_base = 0x200000; code_region_base = 0x200000;
code_region_end = code_region_base + 0x3FE00000; code_region_end = code_region_base + 0x3FE00000;
aslr_region_base = 0x200000;
aslr_region_end = aslr_region_base + 0xFFE00000;
if (type == FileSys::ProgramAddressSpaceType::Is32Bit) {
map_region_size = 0x40000000; map_region_size = 0x40000000;
heap_region_size = 0x40000000; heap_region_size = 0x40000000;
} else {
map_region_size = 0;
heap_region_size = 0x80000000;
}
break; break;
case FileSys::ProgramAddressSpaceType::Is36Bit: case FileSys::ProgramAddressSpaceType::Is36Bit:
address_space_width = 36; address_space_width = 36;
code_region_base = 0x8000000; code_region_base = 0x8000000;
code_region_end = code_region_base + 0x78000000; code_region_end = code_region_base + 0x78000000;
aslr_region_base = 0x8000000;
aslr_region_end = aslr_region_base + 0xFF8000000;
map_region_size = 0x180000000; map_region_size = 0x180000000;
heap_region_size = 0x180000000; heap_region_size = 0x180000000;
break; break;
case FileSys::ProgramAddressSpaceType::Is32BitNoMap:
address_space_width = 32;
code_region_base = 0x200000;
code_region_end = code_region_base + 0x3FE00000;
map_region_size = 0;
heap_region_size = 0x80000000;
break;
case FileSys::ProgramAddressSpaceType::Is39Bit: case FileSys::ProgramAddressSpaceType::Is39Bit:
address_space_width = 39; address_space_width = 39;
code_region_base = 0x8000000; code_region_base = 0x8000000;
code_region_end = code_region_base + 0x80000000; code_region_end = code_region_base + 0x80000000;
aslr_region_base = 0x8000000;
aslr_region_end = aslr_region_base + 0x7FF8000000;
map_region_size = 0x1000000000; map_region_size = 0x1000000000;
heap_region_size = 0x180000000; heap_region_size = 0x180000000;
new_map_region_size = 0x80000000; new_map_region_size = 0x80000000;
@ -490,6 +495,18 @@ u64 VMManager::GetAddressSpaceWidth() const {
return address_space_width; return address_space_width;
} }
VAddr VMManager::GetASLRRegionBaseAddress() const {
return aslr_region_base;
}
VAddr VMManager::GetASLRRegionEndAddress() const {
return aslr_region_end;
}
u64 VMManager::GetASLRRegionSize() const {
return aslr_region_end - aslr_region_base;
}
VAddr VMManager::GetCodeRegionBaseAddress() const { VAddr VMManager::GetCodeRegionBaseAddress() const {
return code_region_base; return code_region_base;
} }

View File

@ -205,6 +205,15 @@ public:
/// Gets the address space width in bits. /// Gets the address space width in bits.
u64 GetAddressSpaceWidth() const; u64 GetAddressSpaceWidth() const;
/// Gets the base address of the ASLR region.
VAddr GetASLRRegionBaseAddress() const;
/// Gets the end address of the ASLR region.
VAddr GetASLRRegionEndAddress() const;
/// Gets the size of the ASLR region
u64 GetASLRRegionSize() const;
/// Gets the base address of the code region. /// Gets the base address of the code region.
VAddr GetCodeRegionBaseAddress() const; VAddr GetCodeRegionBaseAddress() const;
@ -306,6 +315,9 @@ private:
VAddr address_space_base = 0; VAddr address_space_base = 0;
VAddr address_space_end = 0; VAddr address_space_end = 0;
VAddr aslr_region_base = 0;
VAddr aslr_region_end = 0;
VAddr code_region_base = 0; VAddr code_region_base = 0;
VAddr code_region_end = 0; VAddr code_region_end = 0;