mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
Fix lock_try_acquire(&g_is_user_smc_in_progress) calls
This commit is contained in:
parent
6b10c21a10
commit
827280ca12
3 changed files with 8 additions and 4 deletions
|
@ -129,6 +129,9 @@ uintptr_t get_exception_entry_stack_address(unsigned int core_id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool try_set_user_smc_in_progress(void) {
|
||||||
|
return lock_try_acquire(&g_is_user_smc_in_progress);
|
||||||
|
}
|
||||||
void set_user_smc_in_progress(void) {
|
void set_user_smc_in_progress(void) {
|
||||||
lock_acquire(&g_is_user_smc_in_progress);
|
lock_acquire(&g_is_user_smc_in_progress);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +206,7 @@ void call_smc_handler(uint32_t handler_id, smc_args_t *args) {
|
||||||
|
|
||||||
uint32_t smc_wrapper_sync(smc_args_t *args, uint32_t (*handler)(smc_args_t *)) {
|
uint32_t smc_wrapper_sync(smc_args_t *args, uint32_t (*handler)(smc_args_t *)) {
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
if (!lock_try_acquire(&g_is_user_smc_in_progress)) {
|
if (!try_set_user_smc_in_progress()) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
result = handler(args);
|
result = handler(args);
|
||||||
|
@ -214,7 +217,7 @@ uint32_t smc_wrapper_sync(smc_args_t *args, uint32_t (*handler)(smc_args_t *)) {
|
||||||
uint32_t smc_wrapper_async(smc_args_t *args, uint32_t (*handler)(smc_args_t *), uint32_t (*callback)(void *, uint64_t)) {
|
uint32_t smc_wrapper_async(smc_args_t *args, uint32_t (*handler)(smc_args_t *), uint32_t (*callback)(void *, uint64_t)) {
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
uint64_t key;
|
uint64_t key;
|
||||||
if (!lock_try_acquire(&g_is_user_smc_in_progress)) {
|
if (!try_set_user_smc_in_progress()) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if ((key = try_set_smc_callback(callback)) != 0) {
|
if ((key = try_set_smc_callback(callback)) != 0) {
|
||||||
|
@ -439,7 +442,7 @@ uint32_t smc_get_random_bytes_for_priv(smc_args_t *args) {
|
||||||
|
|
||||||
uint32_t result;
|
uint32_t result;
|
||||||
|
|
||||||
if (!lock_try_acquire(&g_is_user_smc_in_progress)) {
|
if (!try_set_user_smc_in_progress()) {
|
||||||
if (args->X[1] > 0x38) {
|
if (args->X[1] > 0x38) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ typedef struct {
|
||||||
uint64_t X[8];
|
uint64_t X[8];
|
||||||
} smc_args_t;
|
} smc_args_t;
|
||||||
|
|
||||||
|
bool try_set_user_smc_in_progress(void);
|
||||||
void set_user_smc_in_progress(void);
|
void set_user_smc_in_progress(void);
|
||||||
void clear_user_smc_in_progress(void);
|
void clear_user_smc_in_progress(void);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ static inline void lock_release(atomic_flag *flag) {
|
||||||
|
|
||||||
/* Try to acquire a lock. */
|
/* Try to acquire a lock. */
|
||||||
static inline bool lock_try_acquire(atomic_flag *flag) {
|
static inline bool lock_try_acquire(atomic_flag *flag) {
|
||||||
return atomic_flag_test_and_set_explicit(flag, memory_order_acquire);
|
return !atomic_flag_test_and_set_explicit(flag, memory_order_acquire);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue