1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-23 02:42:09 +00:00

exosphere: fix reentrancy of se interrupt handler

This commit is contained in:
Michael Scire 2020-04-14 12:23:08 -07:00
parent d7ba3291ed
commit 7d30460214
2 changed files with 11 additions and 16 deletions

View file

@ -52,19 +52,20 @@ void ll_init(volatile se_ll_t *ll, void *buffer, size_t size) {
} }
void set_security_engine_callback(unsigned int (*callback)(void)) { void set_security_engine_callback(unsigned int (*callback)(void)) {
if (callback == NULL || g_se_callback != NULL) { /* Set the callback. */
generic_panic();
}
g_se_callback = callback; g_se_callback = callback;
/* Enable SE Interrupt firing for async op. */
se_get_regs()->SE_INT_ENABLE = 0x10;
} }
/* Fires on Security Engine operation completion. */ /* Fires on Security Engine operation completion. */
void se_operation_completed(void) { void se_operation_completed(void) {
se_get_regs()->SE_INT_ENABLE = 0; se_get_regs()->SE_INT_ENABLE = 0;
if (g_se_callback != NULL) { unsigned int (*callback)(void) = g_se_callback;
g_se_callback(); if (callback != NULL) {
g_se_callback = NULL; g_se_callback = NULL;
callback();
} }
} }
@ -304,9 +305,6 @@ void se_aes_crypt_insecure_internal(unsigned int keyslot, uint32_t out_ll_paddr,
/* Set the callback, for after the async operation. */ /* Set the callback, for after the async operation. */
set_security_engine_callback(callback); set_security_engine_callback(callback);
/* Enable SE Interrupt firing for async op. */
se->SE_INT_ENABLE = 0x10;
/* Setup Input/Output lists */ /* Setup Input/Output lists */
se->SE_IN_LL_ADDR = in_ll_paddr; se->SE_IN_LL_ADDR = in_ll_paddr;
se->SE_OUT_LL_ADDR = out_ll_paddr; se->SE_OUT_LL_ADDR = out_ll_paddr;
@ -358,9 +356,6 @@ void se_exp_mod(unsigned int keyslot, const void *buf, size_t size, unsigned int
set_security_engine_callback(callback); set_security_engine_callback(callback);
/* Enable SE interrupt firing for async op. */
se->SE_INT_ENABLE = 0x10;
flush_dcache_range(stack_buf, stack_buf + KEYSIZE_RSA_MAX); flush_dcache_range(stack_buf, stack_buf + KEYSIZE_RSA_MAX);
trigger_se_rsa_op(stack_buf, size); trigger_se_rsa_op(stack_buf, size);

View file

@ -36,13 +36,13 @@
static bool g_crypt_aes_done = false; static bool g_crypt_aes_done = false;
static uint32_t g_exp_mod_result = 0; static uint32_t g_exp_mod_result = 0;
static uint8_t g_imported_exponents[4][0x100]; static __attribute__((aligned(4))) uint8_t g_imported_exponents[4][0x100];
static uint8_t g_imported_moduli[4][0x100]; static __attribute__((aligned(4))) uint8_t g_imported_moduli[4][0x100];
static bool g_is_modulus_verified[4]; static bool g_is_modulus_verified[4];
static const uint8_t g_rsa_public_key[4] = { 0x00, 0x01, 0x00, 0x01 }; static __attribute__((aligned(4))) const uint8_t g_rsa_public_key[4] = { 0x00, 0x01, 0x00, 0x01 };
static const uint8_t g_rsa_test_vector[0x100] = { static __attribute__((aligned(4))) const uint8_t g_rsa_test_vector[0x100] = {
'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',
'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',
'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',