aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
AgeCommit message (Collapse)Author
2018-10-12Merge pull request #1481 from lioncash/typobunnei
svc: Fix typos in sanitizing checks for MapMemory/UnmapMemory
2018-10-12Merge pull request #1467 from ogniK5377/svcbreak-type-fixbunnei
Fixed incorrect types for svcBreak
2018-10-12svc: Fix typos in sanitizing checks for MapMemory/UnmapMemoryLioncash
2018-10-10svc: Add missing address range sanitizing checks to MapMemory/UnmapMemoryLioncash
This adds the missing address range checking that the service functions do before attempting to map or unmap memory. Given that both service functions perform the same set of checks in the same order, we can wrap these into a function and just call it from both functions, which deduplicates a little bit of code.
2018-10-10kernel/thread: Use a regular pointer for the owner/current processLioncash
There's no real need to use a shared pointer in these cases, and only makes object management more fragile in terms of how easy it would be to introduce cycles. Instead, just do the simple thing of using a regular pointer. Much of this is just a hold-over from citra anyways. It also doesn't make sense from a behavioral point of view for a process' thread to prolong the lifetime of the process itself (the process is supposed to own the thread, not the other way around).
2018-10-10Use a better name than "dont_kill_application"David Marcec
signal_debugger seems like a more fitting name
2018-10-10Fixed incorrect types for svcBreakDavid Marcec
svcBreak reason should be a u32, not a u64.
2018-10-09Added bitfield instead of manually checking if the bit is setDavid Marcec
2018-10-09Actual kill execution when the bit isn't set, not the other way aroundDavid Marcec
2018-10-09svcBreak, Signalling to the debugger should not kill executionDavid Marcec
When loading NROs, svcBreak is called to signal to the debugger that a new "module" is loaded. As no debugger is technically attached we shouldn't be killing the programs execution.
2018-10-04kernel/thread: Make all instance variables privateLioncash
Many of the member variables of the thread class aren't even used outside of the class itself, so there's no need to make those variables public. This change follows in the steps of the previous changes that made other kernel types' members private. The main motivation behind this is that the Thread class will likely change in the future as emulation becomes more accurate, and letting random bits of the emulator access data members of the Thread class directly makes it a pain to shuffle around and/or modify internals. Having all data members public like this also makes it difficult to reason about certain bits of behavior without first verifying what parts of the core actually use them. Everything being public also generally follows the tendency for changes to be introduced in completely different translation units that would otherwise be better introduced as an addition to the Thread class' public interface.
2018-09-30kernel/svc: Implement svcGetThreadContext()Lioncash
Now that we have all of the rearranging and proper structure sizes in place, it's fairly trivial to implement svcGetThreadContext(). In the 64-bit case we can more or less just write out the context as is, minus some minor value sanitizing. In the 32-bit case we'll need to clear out the registers that wouldn't normally be accessible from a 32-bit AArch32 exectuable (or process).
2018-09-30kernel/process: Make data member variables privateLioncash
Makes the public interface consistent in terms of how accesses are done on a process object. It also makes it slightly nicer to reason about the logic of the process class, as we don't want to expose everything to external code.
2018-09-29Merge pull request #1395 from lioncash/vmbunnei
process/vm_manager: Initial modifications to load NPDM metadata
2018-09-25Merge pull request #1393 from tech4me/svcbunnei
svc: Updated svc names
2018-09-24memory: Dehardcode the use of fixed memory range constantsLioncash
The locations of these can actually vary depending on the address space layout, so we shouldn't be using these when determining where to map memory or be using them as offsets for calculations. This keeps all the memory ranges flexible and malleable based off of the virtual memory manager instance state.
2018-09-24svc: Report correct memory-related values within some of the cases in ↵Lioncash
svcGetInfo() Previously, these were reporting hardcoded values, but given the regions can change depending on the requested address spaces, these need to report the values that the memory manager contains.
2018-09-23svc: Updated svc namestech4me
2018-09-21svc: Move most process termination code to its own function within ProcessLioncash
Reduces the use of Process class members externally and keeps most code related to tearing down a process with the rest of the process code.
2018-09-17kernel/svc: Handle error cases for svcArbitrateLock() and svcArbitrateUnlock()Lioncash
The kernel does the equivalent of the following check before proceeding: if (address + 0x8000000000 < 0x7FFFE00000) { return ERR_INVALID_MEMORY_STATE; } which is essentially what our IsKernelVirtualAddress() function does. So we should also be checking for this. The kernel also checks if the given input addresses are 4-byte aligned, however our Mutex::TryAcquire() and Mutex::Release() functions already handle this, so we don't need to add code for this case.
2018-09-17Merge pull request #1315 from lioncash/sizebunnei
kernel/svc: Handle a few error cases within memory-related functions
2018-09-17Merge pull request #1328 from FearlessTobi/port-4192bunnei
Port #4192 from Citra: "svc: change unknown to thread in CreateThread"
2018-09-15Port # #4192 from Citra: "svc: change unknown to thread in CreateThread"Valentin Vanelslande
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi
2018-09-13kernel/svc: Sanitize creation of shared memory via svcCreateSharedMemory()Lioncash
The kernel caps the size limit of shared memory to 8589930496 bytes (or (1GB - 512 bytes) * 8), so approximately 8GB, where every GB has a 512 byte sector taken off of it. It also ensures the shared memory is created with either read or read/write permissions for both permission types passed in, allowing the remote permissions to also be set as "don't care".
2018-09-13kernel/svc: Sanitize addresses, permissions, and sizes within ↵Lioncash
svcMapSharedMemory() and svcUnmapSharedMemory() Part of the checking done by the kernel is to check if the given address and size are 4KB aligned, as well as checking if the size isn't zero. It also only allows mapping shared memory as readable or read/write, but nothing else, and so we shouldn't allow mapping as anything else either.
2018-09-13kernel/svc: Sanitize addresses and sizes within svcMapMemory() and ↵Lioncash
svcUnmapMemory() The kernel checks if the addresses and given size is 4KB aligned before continuing onwards to map the memory.
2018-09-13kernel/svc: Sanitize heap sizes within svcSetHeapSize()Lioncash
The kernel checks if the given size is a multiple of 2MB and <= to 4GB before going ahead and attempting to allocate that much memory.
2018-09-12Merge pull request #1303 from lioncash/errorbunnei
kernel/errors: Amend invalid thread priority and invalid processor ID error codes
2018-09-12svc: Return ERR_INVALID_PROCESSOR_ID in CreateThread() if an invalid ↵Lioncash
processor ID is given This is what the kernel does for an out-of-range processor ID.
2018-09-12kernel/errors: Correct error codes for invalid thread priority and invalid ↵Lioncash
processor ID
2018-09-12svc: Do nothing if svcOutputDebugString() is given a length of zeroLioncash
While unlikely, it does avoid constructing a std::string and unnecessarily calling into the memory code if a game or executable decides to be really silly about their logging.
2018-09-12svc: Correct parameter type for OutputDebugString()Lioncash
This should be a u64 to represent size.
2018-09-02service: Migrate global named port map to the KernelCore classLioncash
Now that we have a class representing the kernel in some capacity, we now have a place to put the named port map, so we move it over and get rid of another piece of global state within the core.
2018-08-31core/core: Replace includes with forward declarations where applicableLioncash
The follow-up to e2457418dae19b889b2ad85255bb95d4cd0e4bff, which replaces most of the includes in the core header with forward declarations. This makes it so that if any of the headers the core header was previously including change, then no one will need to rebuild the bulk of the core, due to core.h being quite a prevalent inclusion. This should make turnaround for changes much faster for developers.
2018-08-28kernel: Eliminate kernel global stateLioncash
As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
2018-08-25svc: Return process title ID if queried in GetInfo()Lioncash
We already have the variable itself set up to perform this task, so we can just return its value from the currently executing process instead of always stubbing it to zero.
2018-08-14kernel/svc: Log svcBreak parametersLioncash
Given if we hit here all is lost, we should probably be logging the break reason code and associated information to distinguish between the causes.
2018-08-12Merge pull request #1043 from Subv/timingbunnei
Use an approximated amortized amount of ticks when advancing timing.
2018-08-12Kernel/SVC: Don't reschedule the current core when creating a new thread.Subv
The current core may have nothing to do with the core where the new thread was scheduled to run. In case it's the same core, then the following PrepareReshedule call will take care of that.
2018-08-12Kernel/Mutex: Don't duplicate threads in the mutex waiter list.Subv
Exit from AddMutexWaiter early if the thread is already waiting for a mutex owned by the owner thread. This accounts for the possibility of a thread that is waiting on a condition variable being awakened twice in a row. Also added more validation asserts. This should fix one of the random crashes in Breath Of The Wild.
2018-08-02kernel/vm_manager: Use const where applicableLioncash
Makes our immutable state explicit.
2018-07-31Merge pull request #877 from lioncash/removebunnei
kernel: Remove unused object_address_table.cpp/.h
2018-07-31kernel: Remove unused object_address_table.cpp/.hLioncash
These source files were entirely unused throughout the rest of the codebase. This also has the benefit of getting rid of a global variable as well.
2018-07-31kernel: Remove unnecessary includesLioncash
Removes unnecessary direct dependencies in some headers and also gets rid of indirect dependencies that were being relied on to be included.
2018-07-25Merge pull request #804 from lioncash/logMat M
svc: Log parameters in SetMemoryAttribute()
2018-07-24svc: Resolve sign comparison warnings in WaitSynchronization()Lioncash
The loop's induction variable was signed, but we were comparing against an unsigned variable.
2018-07-24svc: Log parameters in SetMemoryAttribute()Lioncash
Provides slightly more context than only logging out the address value.
2018-07-22Kernel/SVC: Perform atomic accesses in SignalProcessWideKey as per the real ↵Subv
kernel.
2018-07-19thread: Convert ThreadStatus into an enum classLioncash
Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.