mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
kern: fix/update thread permissions on pin
This commit is contained in:
parent
99c74469e6
commit
98f438e742
1 changed files with 22 additions and 8 deletions
|
@ -221,7 +221,7 @@ namespace ams::kern {
|
||||||
data[id / BitsPerWord] &= ~(1ul << (id % BitsPerWord));
|
data[id / BitsPerWord] &= ~(1ul << (id % BitsPerWord));
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr ALWAYS_INLINE bool GetSvcAllowedImpl(u8 *data, u32 id) {
|
static constexpr ALWAYS_INLINE bool GetSvcAllowedImpl(const u8 *data, u32 id) {
|
||||||
constexpr size_t BitsPerWord = BITSIZEOF(*data);
|
constexpr size_t BitsPerWord = BITSIZEOF(*data);
|
||||||
MESOSPHERE_ASSERT(id < svc::SvcId_Count);
|
MESOSPHERE_ASSERT(id < svc::SvcId_Count);
|
||||||
return (data[id / BitsPerWord] & (1ul << (id % BitsPerWord))) != 0;
|
return (data[id / BitsPerWord] & (1ul << (id % BitsPerWord))) != 0;
|
||||||
|
@ -285,14 +285,28 @@ namespace ams::kern {
|
||||||
|
|
||||||
ALWAYS_INLINE void CopyPinnedSvcPermissionsTo(KThread::StackParameters &sp) const {
|
ALWAYS_INLINE void CopyPinnedSvcPermissionsTo(KThread::StackParameters &sp) const {
|
||||||
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
||||||
|
/* Get whether we have access to return from exception. */
|
||||||
|
const bool return_from_exception = GetSvcAllowedImpl(sp.svc_permission, svc::SvcId_ReturnFromException);
|
||||||
|
|
||||||
/* Clear all permissions. */
|
/* Clear all permissions. */
|
||||||
std::memset(sp.svc_permission, 0, sizeof(m_svc_access_flags));
|
std::memset(sp.svc_permission, 0, sizeof(m_svc_access_flags));
|
||||||
|
|
||||||
/* Set specific SVCs based on our state. */
|
/* Set SynchronizePreemptionState if allowed. */
|
||||||
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_SynchronizePreemptionState);
|
if (GetSvcAllowedImpl(m_svc_access_flags, svc::SvcId_SynchronizePreemptionState)) {
|
||||||
if (GetSvcAllowedImpl(sp.svc_permission, svc::SvcId_ReturnFromException)) {
|
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_SynchronizePreemptionState);
|
||||||
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_ReturnFromException);
|
}
|
||||||
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_GetInfo);
|
|
||||||
|
/* If we previously had ReturnFromException, potentially grant it and GetInfo. */
|
||||||
|
if (return_from_exception) {
|
||||||
|
/* Set ReturnFromException if allowed. */
|
||||||
|
if (GetSvcAllowedImpl(m_svc_access_flags, svc::SvcId_ReturnFromException)) {
|
||||||
|
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_ReturnFromException);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set GetInfo if allowed. */
|
||||||
|
if (GetSvcAllowedImpl(m_svc_access_flags, svc::SvcId_GetInfo)) {
|
||||||
|
SetSvcAllowedImpl(sp.svc_permission, svc::SvcId_GetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +326,7 @@ namespace ams::kern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE void CopyEnterExceptionSvcPermissionsTo(KThread::StackParameters &sp) {
|
ALWAYS_INLINE void CopyEnterExceptionSvcPermissionsTo(KThread::StackParameters &sp) const {
|
||||||
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
||||||
|
|
||||||
/* Set ReturnFromException if allowed. */
|
/* Set ReturnFromException if allowed. */
|
||||||
|
@ -326,7 +340,7 @@ namespace ams::kern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE void CopyLeaveExceptionSvcPermissionsTo(KThread::StackParameters &sp) {
|
ALWAYS_INLINE void CopyLeaveExceptionSvcPermissionsTo(KThread::StackParameters &sp) const {
|
||||||
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
static_assert(sizeof(m_svc_access_flags) == sizeof(sp.svc_permission));
|
||||||
|
|
||||||
/* Clear ReturnFromException. */
|
/* Clear ReturnFromException. */
|
||||||
|
|
Loading…
Reference in a new issue