summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-09-30 15:32:27 -0400
committerGravatar GitHub2018-09-30 15:32:27 -0400
commit5e2f23e2b185475c3ce7ae1750ec14daefcd3e08 (patch)
treeac2c341c94976552acd507359e8853105193d288
parentMerge pull request #1418 from FearlessTobi/port-4269 (diff)
parentkernel/svc: Implement svcGetThreadContext() (diff)
downloadyuzu-5e2f23e2b185475c3ce7ae1750ec14daefcd3e08.tar.gz
yuzu-5e2f23e2b185475c3ce7ae1750ec14daefcd3e08.tar.xz
yuzu-5e2f23e2b185475c3ce7ae1750ec14daefcd3e08.zip
Merge pull request #1417 from lioncash/context
svc: Implement svcGetThreadContext
-rw-r--r--src/core/arm/arm_interface.h10
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp12
-rw-r--r--src/core/file_sys/romfs_factory.cpp2
-rw-r--r--src/core/file_sys/savedata_factory.cpp2
-rw-r--r--src/core/gdbstub/gdbstub.cpp6
-rw-r--r--src/core/hle/kernel/errors.h2
-rw-r--r--src/core/hle/kernel/process.cpp1
-rw-r--r--src/core/hle/kernel/process.h107
-rw-r--r--src/core/hle/kernel/scheduler.cpp2
-rw-r--r--src/core/hle/kernel/shared_memory.cpp14
-rw-r--r--src/core/hle/kernel/svc.cpp62
-rw-r--r--src/core/hle/kernel/svc_wrap.h5
-rw-r--r--src/core/hle/kernel/thread.cpp4
-rw-r--r--src/core/hle/service/fatal/fatal.cpp2
-rw-r--r--src/core/hle/service/ns/pl_u.cpp6
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp2
-rw-r--r--src/core/loader/elf.cpp2
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nso.cpp2
-rw-r--r--src/core/memory.cpp14
-rw-r--r--src/tests/core/arm/arm_test_common.cpp2
-rw-r--r--src/yuzu/main.cpp4
22 files changed, 183 insertions, 82 deletions
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 16d528994..59da33f30 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -22,10 +22,16 @@ public:
22 std::array<u64, 31> cpu_registers; 22 std::array<u64, 31> cpu_registers;
23 u64 sp; 23 u64 sp;
24 u64 pc; 24 u64 pc;
25 u64 pstate; 25 u32 pstate;
26 std::array<u8, 4> padding;
26 std::array<u128, 32> vector_registers; 27 std::array<u128, 32> vector_registers;
27 u64 fpcr; 28 u32 fpcr;
29 u32 fpsr;
30 u64 tpidr;
28 }; 31 };
32 // Internally within the kernel, it expects the AArch64 version of the
33 // thread context to be 800 bytes in size.
34 static_assert(sizeof(ThreadContext) == 0x320);
29 35
30 /// Runs the CPU until an event happens 36 /// Runs the CPU until an event happens
31 virtual void Run() = 0; 37 virtual void Run() = 0;
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index 8cad070b4..05cc84458 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -130,7 +130,7 @@ public:
130 130
131std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { 131std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const {
132 auto& current_process = Core::CurrentProcess(); 132 auto& current_process = Core::CurrentProcess();
133 auto** const page_table = current_process->vm_manager.page_table.pointers.data(); 133 auto** const page_table = current_process->VMManager().page_table.pointers.data();
134 134
135 Dynarmic::A64::UserConfig config; 135 Dynarmic::A64::UserConfig config;
136 136
@@ -139,7 +139,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const {
139 139
140 // Memory 140 // Memory
141 config.page_table = reinterpret_cast<void**>(page_table); 141 config.page_table = reinterpret_cast<void**>(page_table);
142 config.page_table_address_space_bits = current_process->vm_manager.GetAddressSpaceWidth(); 142 config.page_table_address_space_bits = current_process->VMManager().GetAddressSpaceWidth();
143 config.silently_mirror_page_table = false; 143 config.silently_mirror_page_table = false;
144 144
145 // Multi-process state 145 // Multi-process state
@@ -247,15 +247,19 @@ void ARM_Dynarmic::SaveContext(ThreadContext& ctx) {
247 ctx.pstate = jit->GetPstate(); 247 ctx.pstate = jit->GetPstate();
248 ctx.vector_registers = jit->GetVectors(); 248 ctx.vector_registers = jit->GetVectors();
249 ctx.fpcr = jit->GetFpcr(); 249 ctx.fpcr = jit->GetFpcr();
250 ctx.fpsr = jit->GetFpsr();
251 ctx.tpidr = cb->tpidr_el0;
250} 252}
251 253
252void ARM_Dynarmic::LoadContext(const ThreadContext& ctx) { 254void ARM_Dynarmic::LoadContext(const ThreadContext& ctx) {
253 jit->SetRegisters(ctx.cpu_registers); 255 jit->SetRegisters(ctx.cpu_registers);
254 jit->SetSP(ctx.sp); 256 jit->SetSP(ctx.sp);
255 jit->SetPC(ctx.pc); 257 jit->SetPC(ctx.pc);
256 jit->SetPstate(static_cast<u32>(ctx.pstate)); 258 jit->SetPstate(ctx.pstate);
257 jit->SetVectors(ctx.vector_registers); 259 jit->SetVectors(ctx.vector_registers);
258 jit->SetFpcr(static_cast<u32>(ctx.fpcr)); 260 jit->SetFpcr(ctx.fpcr);
261 jit->SetFpsr(ctx.fpsr);
262 SetTPIDR_EL0(ctx.tpidr);
259} 263}
260 264
261void ARM_Dynarmic::PrepareReschedule() { 265void ARM_Dynarmic::PrepareReschedule() {
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 3d1a3685e..d027a8d59 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -34,7 +34,7 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
34 if (!updatable) 34 if (!updatable)
35 return MakeResult<VirtualFile>(file); 35 return MakeResult<VirtualFile>(file);
36 36
37 const PatchManager patch_manager(Core::CurrentProcess()->program_id); 37 const PatchManager patch_manager(Core::CurrentProcess()->GetTitleID());
38 return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file, ivfc_offset)); 38 return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file, ivfc_offset));
39} 39}
40 40
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index 9b2c51bbd..47f2ab9e0 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -81,7 +81,7 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ
81 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should 81 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
82 // be interpreted as the title id of the current process. 82 // be interpreted as the title id of the current process.
83 if (type == SaveDataType::SaveData && title_id == 0) 83 if (type == SaveDataType::SaveData && title_id == 0)
84 title_id = Core::CurrentProcess()->program_id; 84 title_id = Core::CurrentProcess()->GetTitleID();
85 85
86 std::string out; 86 std::string out;
87 87
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index d8c7b3492..5bc947010 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -250,7 +250,7 @@ static void RegWrite(std::size_t id, u64 val, Kernel::Thread* thread = nullptr)
250 } else if (id == PC_REGISTER) { 250 } else if (id == PC_REGISTER) {
251 thread->context.pc = val; 251 thread->context.pc = val;
252 } else if (id == PSTATE_REGISTER) { 252 } else if (id == PSTATE_REGISTER) {
253 thread->context.pstate = val; 253 thread->context.pstate = static_cast<u32>(val);
254 } else if (id > PSTATE_REGISTER && id < FPCR_REGISTER) { 254 } else if (id > PSTATE_REGISTER && id < FPCR_REGISTER) {
255 thread->context.vector_registers[id - (PSTATE_REGISTER + 1)][0] = val; 255 thread->context.vector_registers[id - (PSTATE_REGISTER + 1)][0] = val;
256 } 256 }
@@ -587,7 +587,7 @@ static void HandleQuery() {
587 strlen("Xfer:features:read:target.xml:")) == 0) { 587 strlen("Xfer:features:read:target.xml:")) == 0) {
588 SendReply(target_xml); 588 SendReply(target_xml);
589 } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) { 589 } else if (strncmp(query, "Offsets", strlen("Offsets")) == 0) {
590 const VAddr base_address = Core::CurrentProcess()->vm_manager.GetCodeRegionBaseAddress(); 590 const VAddr base_address = Core::CurrentProcess()->VMManager().GetCodeRegionBaseAddress();
591 std::string buffer = fmt::format("TextSeg={:0x}", base_address); 591 std::string buffer = fmt::format("TextSeg={:0x}", base_address);
592 SendReply(buffer.c_str()); 592 SendReply(buffer.c_str());
593 } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) { 593 } else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) {
@@ -909,7 +909,7 @@ static void ReadMemory() {
909 SendReply("E01"); 909 SendReply("E01");
910 } 910 }
911 911
912 const auto& vm_manager = Core::CurrentProcess()->vm_manager; 912 const auto& vm_manager = Core::CurrentProcess()->VMManager();
913 if (addr < vm_manager.GetCodeRegionBaseAddress() || 913 if (addr < vm_manager.GetCodeRegionBaseAddress() ||
914 addr >= vm_manager.GetMapRegionEndAddress()) { 914 addr >= vm_manager.GetMapRegionEndAddress()) {
915 return SendReply("E00"); 915 return SendReply("E00");
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h
index 8c2be2681..e5fa67ae8 100644
--- a/src/core/hle/kernel/errors.h
+++ b/src/core/hle/kernel/errors.h
@@ -31,6 +31,7 @@ enum {
31 TooLarge = 119, 31 TooLarge = 119,
32 InvalidEnumValue = 120, 32 InvalidEnumValue = 120,
33 NoSuchEntry = 121, 33 NoSuchEntry = 121,
34 AlreadyRegistered = 122,
34 InvalidState = 125, 35 InvalidState = 125,
35 ResourceLimitExceeded = 132, 36 ResourceLimitExceeded = 132,
36}; 37};
@@ -58,6 +59,7 @@ constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS(ErrorModule::Kernel,
58constexpr ResultCode ERR_INVALID_HANDLE(ErrorModule::Kernel, ErrCodes::InvalidHandle); 59constexpr ResultCode ERR_INVALID_HANDLE(ErrorModule::Kernel, ErrCodes::InvalidHandle);
59constexpr ResultCode ERR_INVALID_PROCESSOR_ID(ErrorModule::Kernel, ErrCodes::InvalidProcessorId); 60constexpr ResultCode ERR_INVALID_PROCESSOR_ID(ErrorModule::Kernel, ErrCodes::InvalidProcessorId);
60constexpr ResultCode ERR_INVALID_SIZE(ErrorModule::Kernel, ErrCodes::InvalidSize); 61constexpr ResultCode ERR_INVALID_SIZE(ErrorModule::Kernel, ErrCodes::InvalidSize);
62constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::Kernel, ErrCodes::AlreadyRegistered);
61constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState); 63constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState);
62constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel, 64constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel,
63 ErrCodes::InvalidThreadPriority); 65 ErrCodes::InvalidThreadPriority);
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index a8e3098ca..dc9fc8470 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -47,6 +47,7 @@ SharedPtr<Process> Process::Create(KernelCore& kernel, std::string&& name) {
47 47
48void Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) { 48void Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) {
49 program_id = metadata.GetTitleID(); 49 program_id = metadata.GetTitleID();
50 is_64bit_process = metadata.Is64BitProgram();
50 vm_manager.Reset(metadata.GetAddressSpaceType()); 51 vm_manager.Reset(metadata.GetAddressSpaceType());
51} 52}
52 53
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index adb03c228..590e0c73d 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -135,6 +135,16 @@ public:
135 return HANDLE_TYPE; 135 return HANDLE_TYPE;
136 } 136 }
137 137
138 /// Gets a reference to the process' memory manager.
139 Kernel::VMManager& VMManager() {
140 return vm_manager;
141 }
142
143 /// Gets a const reference to the process' memory manager.
144 const Kernel::VMManager& VMManager() const {
145 return vm_manager;
146 }
147
138 /// Gets the current status of the process 148 /// Gets the current status of the process
139 ProcessStatus GetStatus() const { 149 ProcessStatus GetStatus() const {
140 return status; 150 return status;
@@ -145,6 +155,45 @@ public:
145 return process_id; 155 return process_id;
146 } 156 }
147 157
158 /// Gets the title ID corresponding to this process.
159 u64 GetTitleID() const {
160 return program_id;
161 }
162
163 /// Gets the resource limit descriptor for this process
164 ResourceLimit& GetResourceLimit() {
165 return *resource_limit;
166 }
167
168 /// Gets the resource limit descriptor for this process
169 const ResourceLimit& GetResourceLimit() const {
170 return *resource_limit;
171 }
172
173 /// Gets the default CPU ID for this process
174 u8 GetDefaultProcessorID() const {
175 return ideal_processor;
176 }
177
178 /// Gets the bitmask of allowed CPUs that this process' threads can run on.
179 u32 GetAllowedProcessorMask() const {
180 return allowed_processor_mask;
181 }
182
183 /// Gets the bitmask of allowed thread priorities.
184 u32 GetAllowedThreadPriorityMask() const {
185 return allowed_thread_priority_mask;
186 }
187
188 u32 IsVirtualMemoryEnabled() const {
189 return is_virtual_address_memory_enabled;
190 }
191
192 /// Whether this process is an AArch64 or AArch32 process.
193 bool Is64BitProcess() const {
194 return is_64bit_process;
195 }
196
148 /** 197 /**
149 * Loads process-specifics configuration info with metadata provided 198 * Loads process-specifics configuration info with metadata provided
150 * by an executable. 199 * by an executable.
@@ -153,30 +202,6 @@ public:
153 */ 202 */
154 void LoadFromMetadata(const FileSys::ProgramMetadata& metadata); 203 void LoadFromMetadata(const FileSys::ProgramMetadata& metadata);
155 204
156 /// Title ID corresponding to the process
157 u64 program_id;
158
159 /// Resource limit descriptor for this process
160 SharedPtr<ResourceLimit> resource_limit;
161
162 /// The process may only call SVCs which have the corresponding bit set.
163 std::bitset<0x80> svc_access_mask;
164 /// Maximum size of the handle table for the process.
165 unsigned int handle_table_size = 0x200;
166 /// Special memory ranges mapped into this processes address space. This is used to give
167 /// processes access to specific I/O regions and device memory.
168 boost::container::static_vector<AddressMapping, 8> address_mappings;
169 ProcessFlags flags;
170 /// Kernel compatibility version for this process
171 u16 kernel_version = 0;
172 /// The default CPU for this process, threads are scheduled on this cpu by default.
173 u8 ideal_processor = 0;
174 /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse
175 /// this value from the process header.
176 u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK;
177 u32 allowed_thread_priority_mask = 0xFFFFFFFF;
178 u32 is_virtual_address_memory_enabled = 0;
179
180 /** 205 /**
181 * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them 206 * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them
182 * to this process. 207 * to this process.
@@ -212,18 +237,43 @@ public:
212 237
213 ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); 238 ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size);
214 239
215 VMManager vm_manager;
216
217private: 240private:
218 explicit Process(KernelCore& kernel); 241 explicit Process(KernelCore& kernel);
219 ~Process() override; 242 ~Process() override;
220 243
244 /// Memory manager for this process.
245 Kernel::VMManager vm_manager;
246
221 /// Current status of the process 247 /// Current status of the process
222 ProcessStatus status; 248 ProcessStatus status;
223 249
224 /// The ID of this process 250 /// The ID of this process
225 u32 process_id = 0; 251 u32 process_id = 0;
226 252
253 /// Title ID corresponding to the process
254 u64 program_id;
255
256 /// Resource limit descriptor for this process
257 SharedPtr<ResourceLimit> resource_limit;
258
259 /// The process may only call SVCs which have the corresponding bit set.
260 std::bitset<0x80> svc_access_mask;
261 /// Maximum size of the handle table for the process.
262 u32 handle_table_size = 0x200;
263 /// Special memory ranges mapped into this processes address space. This is used to give
264 /// processes access to specific I/O regions and device memory.
265 boost::container::static_vector<AddressMapping, 8> address_mappings;
266 ProcessFlags flags;
267 /// Kernel compatibility version for this process
268 u16 kernel_version = 0;
269 /// The default CPU for this process, threads are scheduled on this cpu by default.
270 u8 ideal_processor = 0;
271 /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse
272 /// this value from the process header.
273 u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK;
274 u32 allowed_thread_priority_mask = 0xFFFFFFFF;
275 u32 is_virtual_address_memory_enabled = 0;
276
227 // Memory used to back the allocations in the regular heap. A single vector is used to cover 277 // Memory used to back the allocations in the regular heap. A single vector is used to cover
228 // the entire virtual address space extents that bound the allocations, including any holes. 278 // the entire virtual address space extents that bound the allocations, including any holes.
229 // This makes deallocation and reallocation of holes fast and keeps process memory contiguous 279 // This makes deallocation and reallocation of holes fast and keeps process memory contiguous
@@ -242,6 +292,11 @@ private:
242 /// This vector will grow as more pages are allocated for new threads. 292 /// This vector will grow as more pages are allocated for new threads.
243 std::vector<std::bitset<8>> tls_slots; 293 std::vector<std::bitset<8>> tls_slots;
244 294
295 /// Whether or not this process is AArch64, or AArch32.
296 /// By default, we currently assume this is true, unless otherwise
297 /// specified by metadata provided to the process during loading.
298 bool is_64bit_process = true;
299
245 std::string name; 300 std::string name;
246}; 301};
247 302
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 9faf903cf..1e82cfffb 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -88,7 +88,7 @@ void Scheduler::SwitchContext(Thread* new_thread) {
88 88
89 if (previous_process != current_thread->owner_process) { 89 if (previous_process != current_thread->owner_process) {
90 Core::CurrentProcess() = current_thread->owner_process; 90 Core::CurrentProcess() = current_thread->owner_process;
91 SetCurrentPageTable(&Core::CurrentProcess()->vm_manager.page_table); 91 SetCurrentPageTable(&Core::CurrentProcess()->VMManager().page_table);
92 } 92 }
93 93
94 cpu_core.LoadContext(new_thread->context); 94 cpu_core.LoadContext(new_thread->context);
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 9b78c8cb5..d061e6155 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -35,11 +35,11 @@ SharedPtr<SharedMemory> SharedMemory::Create(KernelCore& kernel, SharedPtr<Proce
35 35
36 // Refresh the address mappings for the current process. 36 // Refresh the address mappings for the current process.
37 if (Core::CurrentProcess() != nullptr) { 37 if (Core::CurrentProcess() != nullptr) {
38 Core::CurrentProcess()->vm_manager.RefreshMemoryBlockMappings( 38 Core::CurrentProcess()->VMManager().RefreshMemoryBlockMappings(
39 shared_memory->backing_block.get()); 39 shared_memory->backing_block.get());
40 } 40 }
41 } else { 41 } else {
42 auto& vm_manager = shared_memory->owner_process->vm_manager; 42 auto& vm_manager = shared_memory->owner_process->VMManager();
43 43
44 // The memory is already available and mapped in the owner process. 44 // The memory is already available and mapped in the owner process.
45 auto vma = vm_manager.FindVMA(address); 45 auto vma = vm_manager.FindVMA(address);
@@ -73,7 +73,7 @@ SharedPtr<SharedMemory> SharedMemory::CreateForApplet(
73 shared_memory->backing_block = std::move(heap_block); 73 shared_memory->backing_block = std::move(heap_block);
74 shared_memory->backing_block_offset = offset; 74 shared_memory->backing_block_offset = offset;
75 shared_memory->base_address = 75 shared_memory->base_address =
76 kernel.CurrentProcess()->vm_manager.GetHeapRegionBaseAddress() + offset; 76 kernel.CurrentProcess()->VMManager().GetHeapRegionBaseAddress() + offset;
77 77
78 return shared_memory; 78 return shared_memory;
79} 79}
@@ -107,7 +107,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
107 VAddr target_address = address; 107 VAddr target_address = address;
108 108
109 // Map the memory block into the target process 109 // Map the memory block into the target process
110 auto result = target_process->vm_manager.MapMemoryBlock( 110 auto result = target_process->VMManager().MapMemoryBlock(
111 target_address, backing_block, backing_block_offset, size, MemoryState::Shared); 111 target_address, backing_block, backing_block_offset, size, MemoryState::Shared);
112 if (result.Failed()) { 112 if (result.Failed()) {
113 LOG_ERROR( 113 LOG_ERROR(
@@ -117,14 +117,14 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
117 return result.Code(); 117 return result.Code();
118 } 118 }
119 119
120 return target_process->vm_manager.ReprotectRange(target_address, size, 120 return target_process->VMManager().ReprotectRange(target_address, size,
121 ConvertPermissions(permissions)); 121 ConvertPermissions(permissions));
122} 122}
123 123
124ResultCode SharedMemory::Unmap(Process* target_process, VAddr address) { 124ResultCode SharedMemory::Unmap(Process* target_process, VAddr address) {
125 // TODO(Subv): Verify what happens if the application tries to unmap an address that is not 125 // TODO(Subv): Verify what happens if the application tries to unmap an address that is not
126 // mapped to a SharedMemory. 126 // mapped to a SharedMemory.
127 return target_process->vm_manager.UnmapRange(address, size); 127 return target_process->VMManager().UnmapRange(address, size);
128} 128}
129 129
130VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) { 130VMAPermission SharedMemory::ConvertPermissions(MemoryPermission permission) {
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 44bbaf0c8..1cdaa740a 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -51,7 +51,7 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
51 } 51 }
52 52
53 auto& process = *Core::CurrentProcess(); 53 auto& process = *Core::CurrentProcess();
54 const VAddr heap_base = process.vm_manager.GetHeapRegionBaseAddress(); 54 const VAddr heap_base = process.VMManager().GetHeapRegionBaseAddress();
55 CASCADE_RESULT(*heap_addr, 55 CASCADE_RESULT(*heap_addr,
56 process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite)); 56 process.HeapAllocate(heap_base, heap_size, VMAPermission::ReadWrite));
57 return RESULT_SUCCESS; 57 return RESULT_SUCCESS;
@@ -327,14 +327,14 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
327 info_sub_id, handle); 327 info_sub_id, handle);
328 328
329 const auto& current_process = Core::CurrentProcess(); 329 const auto& current_process = Core::CurrentProcess();
330 const auto& vm_manager = current_process->vm_manager; 330 const auto& vm_manager = current_process->VMManager();
331 331
332 switch (static_cast<GetInfoType>(info_id)) { 332 switch (static_cast<GetInfoType>(info_id)) {
333 case GetInfoType::AllowedCpuIdBitmask: 333 case GetInfoType::AllowedCpuIdBitmask:
334 *result = current_process->allowed_processor_mask; 334 *result = current_process->GetAllowedProcessorMask();
335 break; 335 break;
336 case GetInfoType::AllowedThreadPrioBitmask: 336 case GetInfoType::AllowedThreadPrioBitmask:
337 *result = current_process->allowed_thread_priority_mask; 337 *result = current_process->GetAllowedThreadPriorityMask();
338 break; 338 break;
339 case GetInfoType::MapRegionBaseAddr: 339 case GetInfoType::MapRegionBaseAddr:
340 *result = vm_manager.GetMapRegionBaseAddress(); 340 *result = vm_manager.GetMapRegionBaseAddress();
@@ -386,10 +386,10 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id)
386 *result = vm_manager.GetNewMapRegionSize(); 386 *result = vm_manager.GetNewMapRegionSize();
387 break; 387 break;
388 case GetInfoType::IsVirtualAddressMemoryEnabled: 388 case GetInfoType::IsVirtualAddressMemoryEnabled:
389 *result = current_process->is_virtual_address_memory_enabled; 389 *result = current_process->IsVirtualMemoryEnabled();
390 break; 390 break;
391 case GetInfoType::TitleId: 391 case GetInfoType::TitleId:
392 *result = current_process->program_id; 392 *result = current_process->GetTitleID();
393 break; 393 break;
394 case GetInfoType::PrivilegedProcessId: 394 case GetInfoType::PrivilegedProcessId:
395 LOG_WARNING(Kernel_SVC, 395 LOG_WARNING(Kernel_SVC,
@@ -415,8 +415,36 @@ static ResultCode SetThreadActivity(Handle handle, u32 unknown) {
415} 415}
416 416
417/// Gets the thread context 417/// Gets the thread context
418static ResultCode GetThreadContext(Handle handle, VAddr addr) { 418static ResultCode GetThreadContext(VAddr thread_context, Handle handle) {
419 LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, addr=0x{:X}", handle, addr); 419 LOG_DEBUG(Kernel_SVC, "called, context=0x{:08X}, thread=0x{:X}", thread_context, handle);
420
421 auto& kernel = Core::System::GetInstance().Kernel();
422 const SharedPtr<Thread> thread = kernel.HandleTable().Get<Thread>(handle);
423 if (!thread) {
424 return ERR_INVALID_HANDLE;
425 }
426
427 const auto current_process = Core::CurrentProcess();
428 if (thread->owner_process != current_process) {
429 return ERR_INVALID_HANDLE;
430 }
431
432 if (thread == GetCurrentThread()) {
433 return ERR_ALREADY_REGISTERED;
434 }
435
436 Core::ARM_Interface::ThreadContext ctx = thread->context;
437 // Mask away mode bits, interrupt bits, IL bit, and other reserved bits.
438 ctx.pstate &= 0xFF0FFE20;
439
440 // If 64-bit, we can just write the context registers directly and we're good.
441 // However, if 32-bit, we have to ensure some registers are zeroed out.
442 if (!current_process->Is64BitProcess()) {
443 std::fill(ctx.cpu_registers.begin() + 15, ctx.cpu_registers.end(), 0);
444 std::fill(ctx.vector_registers.begin() + 16, ctx.vector_registers.end(), u128{});
445 }
446
447 Memory::WriteBlock(thread_context, &ctx, sizeof(ctx));
420 return RESULT_SUCCESS; 448 return RESULT_SUCCESS;
421} 449}
422 450
@@ -444,8 +472,8 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {
444 472
445 // Note: The kernel uses the current process's resource limit instead of 473 // Note: The kernel uses the current process's resource limit instead of
446 // the one from the thread owner's resource limit. 474 // the one from the thread owner's resource limit.
447 SharedPtr<ResourceLimit>& resource_limit = Core::CurrentProcess()->resource_limit; 475 const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit();
448 if (resource_limit->GetMaxResourceValue(ResourceType::Priority) > priority) { 476 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) {
449 return ERR_NOT_AUTHORIZED; 477 return ERR_NOT_AUTHORIZED;
450 } 478 }
451 479
@@ -519,9 +547,9 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i
519 if (!process) { 547 if (!process) {
520 return ERR_INVALID_HANDLE; 548 return ERR_INVALID_HANDLE;
521 } 549 }
522 auto vma = process->vm_manager.FindVMA(addr); 550 auto vma = process->VMManager().FindVMA(addr);
523 memory_info->attributes = 0; 551 memory_info->attributes = 0;
524 if (vma == Core::CurrentProcess()->vm_manager.vma_map.end()) { 552 if (vma == Core::CurrentProcess()->VMManager().vma_map.end()) {
525 memory_info->base_address = 0; 553 memory_info->base_address = 0;
526 memory_info->permission = static_cast<u32>(VMAPermission::None); 554 memory_info->permission = static_cast<u32>(VMAPermission::None);
527 memory_info->size = 0; 555 memory_info->size = 0;
@@ -568,14 +596,14 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V
568 return ERR_INVALID_THREAD_PRIORITY; 596 return ERR_INVALID_THREAD_PRIORITY;
569 } 597 }
570 598
571 SharedPtr<ResourceLimit>& resource_limit = Core::CurrentProcess()->resource_limit; 599 const ResourceLimit& resource_limit = Core::CurrentProcess()->GetResourceLimit();
572 if (resource_limit->GetMaxResourceValue(ResourceType::Priority) > priority) { 600 if (resource_limit.GetMaxResourceValue(ResourceType::Priority) > priority) {
573 return ERR_NOT_AUTHORIZED; 601 return ERR_NOT_AUTHORIZED;
574 } 602 }
575 603
576 if (processor_id == THREADPROCESSORID_DEFAULT) { 604 if (processor_id == THREADPROCESSORID_DEFAULT) {
577 // Set the target CPU to the one specified in the process' exheader. 605 // Set the target CPU to the one specified in the process' exheader.
578 processor_id = Core::CurrentProcess()->ideal_processor; 606 processor_id = Core::CurrentProcess()->GetDefaultProcessorID();
579 ASSERT(processor_id != THREADPROCESSORID_DEFAULT); 607 ASSERT(processor_id != THREADPROCESSORID_DEFAULT);
580 } 608 }
581 609
@@ -902,10 +930,10 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) {
902 } 930 }
903 931
904 if (core == static_cast<u32>(THREADPROCESSORID_DEFAULT)) { 932 if (core == static_cast<u32>(THREADPROCESSORID_DEFAULT)) {
905 ASSERT(thread->owner_process->ideal_processor != 933 ASSERT(thread->owner_process->GetDefaultProcessorID() !=
906 static_cast<u8>(THREADPROCESSORID_DEFAULT)); 934 static_cast<u8>(THREADPROCESSORID_DEFAULT));
907 // Set the target CPU to the one specified in the process' exheader. 935 // Set the target CPU to the one specified in the process' exheader.
908 core = thread->owner_process->ideal_processor; 936 core = thread->owner_process->GetDefaultProcessorID();
909 mask = 1ull << core; 937 mask = 1ull << core;
910 } 938 }
911 939
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h
index fea9ba5ea..22712e64f 100644
--- a/src/core/hle/kernel/svc_wrap.h
+++ b/src/core/hle/kernel/svc_wrap.h
@@ -64,6 +64,11 @@ void SvcWrap() {
64 FuncReturn(func(Param(0), (s32)Param(1)).raw); 64 FuncReturn(func(Param(0), (s32)Param(1)).raw);
65} 65}
66 66
67template <ResultCode func(u64, u32)>
68void SvcWrap() {
69 FuncReturn(func(Param(0), static_cast<u32>(Param(1))).raw);
70}
71
67template <ResultCode func(u64*, u64)> 72template <ResultCode func(u64*, u64)>
68void SvcWrap() { 73void SvcWrap() {
69 u64 param_1 = 0; 74 u64 param_1 = 0;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 064ed908d..b5c16cfbb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -259,10 +259,10 @@ void Thread::BoostPriority(u32 priority) {
259SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 priority, 259SharedPtr<Thread> SetupMainThread(KernelCore& kernel, VAddr entry_point, u32 priority,
260 Process& owner_process) { 260 Process& owner_process) {
261 // Setup page table so we can write to memory 261 // Setup page table so we can write to memory
262 SetCurrentPageTable(&owner_process.vm_manager.page_table); 262 SetCurrentPageTable(&owner_process.VMManager().page_table);
263 263
264 // Initialize new "main" thread 264 // Initialize new "main" thread
265 const VAddr stack_top = owner_process.vm_manager.GetTLSIORegionEndAddress(); 265 const VAddr stack_top = owner_process.VMManager().GetTLSIORegionEndAddress();
266 auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, THREADPROCESSORID_0, 266 auto thread_res = Thread::Create(kernel, "main", entry_point, priority, 0, THREADPROCESSORID_0,
267 stack_top, &owner_process); 267 stack_top, &owner_process);
268 268
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 2212b2cdd..2f15ac2a6 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -51,7 +51,7 @@ enum class FatalType : u32 {
51}; 51};
52 52
53static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) { 53static void GenerateErrorReport(ResultCode error_code, const FatalInfo& info) {
54 const auto title_id = Core::CurrentProcess()->program_id; 54 const auto title_id = Core::CurrentProcess()->GetTitleID();
55 std::string crash_report = 55 std::string crash_report =
56 fmt::format("Yuzu {}-{} crash report\n" 56 fmt::format("Yuzu {}-{} crash report\n"
57 "Title ID: {:016x}\n" 57 "Title ID: {:016x}\n"
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
index 1069d103f..4b2f758a8 100644
--- a/src/core/hle/service/ns/pl_u.cpp
+++ b/src/core/hle/service/ns/pl_u.cpp
@@ -317,9 +317,9 @@ void PL_U::GetSharedMemoryAddressOffset(Kernel::HLERequestContext& ctx) {
317 317
318void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { 318void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
319 // Map backing memory for the font data 319 // Map backing memory for the font data
320 Core::CurrentProcess()->vm_manager.MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0, 320 Core::CurrentProcess()->VMManager().MapMemoryBlock(SHARED_FONT_MEM_VADDR, impl->shared_font, 0,
321 SHARED_FONT_MEM_SIZE, 321 SHARED_FONT_MEM_SIZE,
322 Kernel::MemoryState::Shared); 322 Kernel::MemoryState::Shared);
323 323
324 // Create shared font memory object 324 // Create shared font memory object
325 auto& kernel = Core::System::GetInstance().Kernel(); 325 auto& kernel = Core::System::GetInstance().Kernel();
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp
index 1b198cc5c..c1824b9c3 100644
--- a/src/core/loader/deconstructed_rom_directory.cpp
+++ b/src/core/loader/deconstructed_rom_directory.cpp
@@ -132,7 +132,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
132 process.LoadFromMetadata(metadata); 132 process.LoadFromMetadata(metadata);
133 133
134 // Load NSO modules 134 // Load NSO modules
135 const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); 135 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
136 VAddr next_load_addr = base_address; 136 VAddr next_load_addr = base_address;
137 for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", 137 for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3",
138 "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { 138 "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 5712a2a11..e67b49fc9 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -395,7 +395,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::Process& process) {
395 if (buffer.size() != file->GetSize()) 395 if (buffer.size() != file->GetSize())
396 return ResultStatus::ErrorIncorrectELFFileSize; 396 return ResultStatus::ErrorIncorrectELFFileSize;
397 397
398 const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); 398 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
399 ElfReader elf_reader(&buffer[0]); 399 ElfReader elf_reader(&buffer[0]);
400 SharedPtr<CodeSet> codeset = elf_reader.LoadInto(base_address); 400 SharedPtr<CodeSet> codeset = elf_reader.LoadInto(base_address);
401 codeset->name = file->GetName(); 401 codeset->name = file->GetName();
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 8ad973c3a..c10f826a4 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -181,7 +181,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) {
181 } 181 }
182 182
183 // Load NRO 183 // Load NRO
184 const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); 184 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
185 185
186 if (!LoadNro(file, base_address)) { 186 if (!LoadNro(file, base_address)) {
187 return ResultStatus::ErrorLoadingNRO; 187 return ResultStatus::ErrorLoadingNRO;
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 6fe3e17a7..cbe2a3e53 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -159,7 +159,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) {
159 } 159 }
160 160
161 // Load module 161 // Load module
162 const VAddr base_address = process.vm_manager.GetCodeRegionBaseAddress(); 162 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
163 LoadModule(file, base_address); 163 LoadModule(file, base_address);
164 LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); 164 LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address);
165 165
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 6430daad4..014298ed6 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -119,7 +119,7 @@ void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPoin
119static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) { 119static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) {
120 u8* direct_pointer = nullptr; 120 u8* direct_pointer = nullptr;
121 121
122 auto& vm_manager = process.vm_manager; 122 auto& vm_manager = process.VMManager();
123 123
124 auto it = vm_manager.FindVMA(vaddr); 124 auto it = vm_manager.FindVMA(vaddr);
125 ASSERT(it != vm_manager.vma_map.end()); 125 ASSERT(it != vm_manager.vma_map.end());
@@ -214,7 +214,7 @@ void Write(const VAddr vaddr, const T data) {
214} 214}
215 215
216bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) { 216bool IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
217 auto& page_table = process.vm_manager.page_table; 217 const auto& page_table = process.VMManager().page_table;
218 218
219 const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS]; 219 const u8* page_pointer = page_table.pointers[vaddr >> PAGE_BITS];
220 if (page_pointer) 220 if (page_pointer)
@@ -363,7 +363,7 @@ void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) {
363 } 363 }
364 }; 364 };
365 365
366 const auto& vm_manager = Core::CurrentProcess()->vm_manager; 366 const auto& vm_manager = Core::CurrentProcess()->VMManager();
367 367
368 CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress()); 368 CheckRegion(vm_manager.GetCodeRegionBaseAddress(), vm_manager.GetCodeRegionEndAddress());
369 CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress()); 369 CheckRegion(vm_manager.GetHeapRegionBaseAddress(), vm_manager.GetHeapRegionEndAddress());
@@ -387,7 +387,7 @@ u64 Read64(const VAddr addr) {
387 387
388void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer, 388void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer,
389 const std::size_t size) { 389 const std::size_t size) {
390 auto& page_table = process.vm_manager.page_table; 390 const auto& page_table = process.VMManager().page_table;
391 391
392 std::size_t remaining_size = size; 392 std::size_t remaining_size = size;
393 std::size_t page_index = src_addr >> PAGE_BITS; 393 std::size_t page_index = src_addr >> PAGE_BITS;
@@ -452,7 +452,7 @@ void Write64(const VAddr addr, const u64 data) {
452 452
453void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer, 453void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer,
454 const std::size_t size) { 454 const std::size_t size) {
455 auto& page_table = process.vm_manager.page_table; 455 const auto& page_table = process.VMManager().page_table;
456 std::size_t remaining_size = size; 456 std::size_t remaining_size = size;
457 std::size_t page_index = dest_addr >> PAGE_BITS; 457 std::size_t page_index = dest_addr >> PAGE_BITS;
458 std::size_t page_offset = dest_addr & PAGE_MASK; 458 std::size_t page_offset = dest_addr & PAGE_MASK;
@@ -498,7 +498,7 @@ void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t
498} 498}
499 499
500void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { 500void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) {
501 auto& page_table = process.vm_manager.page_table; 501 const auto& page_table = process.VMManager().page_table;
502 std::size_t remaining_size = size; 502 std::size_t remaining_size = size;
503 std::size_t page_index = dest_addr >> PAGE_BITS; 503 std::size_t page_index = dest_addr >> PAGE_BITS;
504 std::size_t page_offset = dest_addr & PAGE_MASK; 504 std::size_t page_offset = dest_addr & PAGE_MASK;
@@ -540,7 +540,7 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std:
540 540
541void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, 541void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr,
542 const std::size_t size) { 542 const std::size_t size) {
543 auto& page_table = process.vm_manager.page_table; 543 const auto& page_table = process.VMManager().page_table;
544 std::size_t remaining_size = size; 544 std::size_t remaining_size = size;
545 std::size_t page_index = src_addr >> PAGE_BITS; 545 std::size_t page_index = src_addr >> PAGE_BITS;
546 std::size_t page_offset = src_addr & PAGE_MASK; 546 std::size_t page_offset = src_addr & PAGE_MASK;
diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp
index c17a122cd..c0a57e71f 100644
--- a/src/tests/core/arm/arm_test_common.cpp
+++ b/src/tests/core/arm/arm_test_common.cpp
@@ -16,7 +16,7 @@ TestEnvironment::TestEnvironment(bool mutable_memory_)
16 : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { 16 : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) {
17 17
18 Core::CurrentProcess() = Kernel::Process::Create(kernel, ""); 18 Core::CurrentProcess() = Kernel::Process::Create(kernel, "");
19 page_table = &Core::CurrentProcess()->vm_manager.page_table; 19 page_table = &Core::CurrentProcess()->VMManager().page_table;
20 20
21 std::fill(page_table->pointers.begin(), page_table->pointers.end(), nullptr); 21 std::fill(page_table->pointers.begin(), page_table->pointers.end(), nullptr);
22 page_table->special_regions.clear(); 22 page_table->special_regions.clear();
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index d74489935..681758ad2 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -622,9 +622,9 @@ void GMainWindow::BootGame(const QString& filename) {
622 std::string title_name; 622 std::string title_name;
623 const auto res = Core::System::GetInstance().GetGameName(title_name); 623 const auto res = Core::System::GetInstance().GetGameName(title_name);
624 if (res != Loader::ResultStatus::Success) { 624 if (res != Loader::ResultStatus::Success) {
625 const u64 program_id = Core::System::GetInstance().CurrentProcess()->program_id; 625 const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
626 626
627 const auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata(); 627 const auto [nacp, icon_file] = FileSys::PatchManager(title_id).GetControlMetadata();
628 if (nacp != nullptr) 628 if (nacp != nullptr)
629 title_name = nacp->GetApplicationName(); 629 title_name = nacp->GetApplicationName();
630 630