mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 12:15:42 +01:00
hle: kernel: KSystemControl does not belong in Memory namespace.
This commit is contained in:
parent
6a19086001
commit
f7a008d77f
@ -182,6 +182,8 @@ add_library(core STATIC
|
|||||||
hle/kernel/k_spin_lock.h
|
hle/kernel/k_spin_lock.h
|
||||||
hle/kernel/k_synchronization_object.cpp
|
hle/kernel/k_synchronization_object.cpp
|
||||||
hle/kernel/k_synchronization_object.h
|
hle/kernel/k_synchronization_object.h
|
||||||
|
hle/kernel/k_system_control.cpp
|
||||||
|
hle/kernel/k_system_control.h
|
||||||
hle/kernel/k_thread.cpp
|
hle/kernel/k_thread.cpp
|
||||||
hle/kernel/k_thread.h
|
hle/kernel/k_thread.h
|
||||||
hle/kernel/k_thread_queue.h
|
hle/kernel/k_thread_queue.h
|
||||||
@ -204,8 +206,6 @@ add_library(core STATIC
|
|||||||
hle/kernel/memory/page_table.cpp
|
hle/kernel/memory/page_table.cpp
|
||||||
hle/kernel/memory/page_table.h
|
hle/kernel/memory/page_table.h
|
||||||
hle/kernel/memory/slab_heap.h
|
hle/kernel/memory/slab_heap.h
|
||||||
hle/kernel/memory/system_control.cpp
|
|
||||||
hle/kernel/memory/system_control.h
|
|
||||||
hle/kernel/object.cpp
|
hle/kernel/object.cpp
|
||||||
hle/kernel/object.h
|
hle/kernel/object.h
|
||||||
hle/kernel/physical_core.cpp
|
hle/kernel/physical_core.cpp
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "common/bit_util.h"
|
#include "common/bit_util.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/tiny_mt.h"
|
#include "common/tiny_mt.h"
|
||||||
#include "core/hle/kernel/memory/system_control.h"
|
#include "core/hle/kernel/k_system_control.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RandomBitGenerator() {
|
RandomBitGenerator() {
|
||||||
rng.Initialize(static_cast<u32>(Memory::SystemControl::GenerateRandomU64()));
|
rng.Initialize(static_cast<u32>(KSystemControl::GenerateRandomU64()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t SelectRandomBit(u64 bitmap) {
|
std::size_t SelectRandomBit(u64 bitmap) {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
// Copyright 2020 yuzu Emulator Project
|
// Copyright 2021 yuzu Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include "core/hle/kernel/memory/system_control.h"
|
#include "core/hle/kernel/k_system_control.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
namespace Kernel::Memory::SystemControl {
|
|
||||||
namespace {
|
namespace {
|
||||||
template <typename F>
|
template <typename F>
|
||||||
u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
||||||
@ -27,15 +28,15 @@ u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
|||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
u64 GenerateRandomU64() {
|
u64 KSystemControl::GenerateRandomU64() {
|
||||||
static std::random_device device;
|
static std::random_device device;
|
||||||
static std::mt19937 gen(device());
|
static std::mt19937 gen(device());
|
||||||
static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
static std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
||||||
return distribution(gen);
|
return distribution(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GenerateRandomRange(u64 min, u64 max) {
|
u64 KSystemControl::GenerateRandomRange(u64 min, u64 max) {
|
||||||
return GenerateUniformRange(min, max, GenerateRandomU64);
|
return GenerateUniformRange(min, max, GenerateRandomU64);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Kernel::Memory::SystemControl
|
} // namespace Kernel
|
19
src/core/hle/kernel/k_system_control.h
Normal file
19
src/core/hle/kernel/k_system_control.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2021 yuzu Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
class KSystemControl {
|
||||||
|
public:
|
||||||
|
KSystemControl() = default;
|
||||||
|
|
||||||
|
static u64 GenerateRandomRange(u64 min, u64 max);
|
||||||
|
static u64 GenerateRandomU64();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Kernel
|
@ -6,14 +6,15 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "core/hle/kernel/k_resource_limit.h"
|
||||||
#include "core/hle/kernel/k_scoped_resource_reservation.h"
|
#include "core/hle/kernel/k_scoped_resource_reservation.h"
|
||||||
|
#include "core/hle/kernel/k_system_control.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/memory/address_space_info.h"
|
#include "core/hle/kernel/memory/address_space_info.h"
|
||||||
#include "core/hle/kernel/memory/memory_block.h"
|
#include "core/hle/kernel/memory/memory_block.h"
|
||||||
#include "core/hle/kernel/memory/memory_block_manager.h"
|
#include "core/hle/kernel/memory/memory_block_manager.h"
|
||||||
#include "core/hle/kernel/memory/page_linked_list.h"
|
#include "core/hle/kernel/memory/page_linked_list.h"
|
||||||
#include "core/hle/kernel/memory/page_table.h"
|
#include "core/hle/kernel/memory/page_table.h"
|
||||||
#include "core/hle/kernel/memory/system_control.h"
|
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -149,13 +150,13 @@ ResultCode PageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_t
|
|||||||
// Determine random placements for each region
|
// Determine random placements for each region
|
||||||
std::size_t alias_rnd{}, heap_rnd{}, stack_rnd{}, kmap_rnd{};
|
std::size_t alias_rnd{}, heap_rnd{}, stack_rnd{}, kmap_rnd{};
|
||||||
if (enable_aslr) {
|
if (enable_aslr) {
|
||||||
alias_rnd = SystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
alias_rnd = KSystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
||||||
RegionAlignment;
|
RegionAlignment;
|
||||||
heap_rnd = SystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
heap_rnd = KSystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
||||||
RegionAlignment;
|
RegionAlignment;
|
||||||
stack_rnd = SystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
stack_rnd = KSystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
||||||
RegionAlignment;
|
RegionAlignment;
|
||||||
kmap_rnd = SystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
kmap_rnd = KSystemControl::GenerateRandomRange(0, remaining_size / RegionAlignment) *
|
||||||
RegionAlignment;
|
RegionAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
// Copyright 2020 yuzu Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/common_types.h"
|
|
||||||
|
|
||||||
namespace Kernel::Memory::SystemControl {
|
|
||||||
|
|
||||||
u64 GenerateRandomRange(u64 min, u64 max);
|
|
||||||
u64 GenerateRandomU64();
|
|
||||||
|
|
||||||
} // namespace Kernel::Memory::SystemControl
|
|
@ -11,8 +11,8 @@
|
|||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
|
#include "core/hle/kernel/k_system_control.h"
|
||||||
#include "core/hle/kernel/memory/page_table.h"
|
#include "core/hle/kernel/memory/page_table.h"
|
||||||
#include "core/hle/kernel/memory/system_control.h"
|
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
#include "core/hle/service/ldr/ldr.h"
|
#include "core/hle/service/ldr/ldr.h"
|
||||||
@ -315,7 +315,7 @@ public:
|
|||||||
Kernel::Memory::PageBits};
|
Kernel::Memory::PageBits};
|
||||||
do {
|
do {
|
||||||
addr = page_table.GetAliasCodeRegionStart() +
|
addr = page_table.GetAliasCodeRegionStart() +
|
||||||
(Kernel::Memory::SystemControl::GenerateRandomRange(0, end_pages)
|
(Kernel::KSystemControl::GenerateRandomRange(0, end_pages)
|
||||||
<< Kernel::Memory::PageBits);
|
<< Kernel::Memory::PageBits);
|
||||||
} while (!page_table.IsInsideAddressSpace(addr, size) ||
|
} while (!page_table.IsInsideAddressSpace(addr, size) ||
|
||||||
page_table.IsInsideHeapRegion(addr, size) ||
|
page_table.IsInsideHeapRegion(addr, size) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user