diff --git a/exosphere/src/smc_api.c b/exosphere/src/smc_api.c index 464a28c..66ec692 100644 --- a/exosphere/src/smc_api.c +++ b/exosphere/src/smc_api.c @@ -129,6 +129,13 @@ } } +void set_user_smc_in_progress(void) { + lock_acquire(&g_is_user_smc_in_progress); +} +void clear_user_smc_in_progress(void) { + lock_release(&g_is_user_smc_in_progress); +} + /* Privileged SMC lock must be available to exceptions.s. */ void set_priv_smc_in_progress(void) { lock_acquire(&g_is_priv_smc_in_progress); @@ -200,7 +207,7 @@ return 3; } result = handler(args); - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return result; } @@ -225,7 +232,7 @@ /* smcCheckStatus needs to be called. */ result = 3; } - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return result; } @@ -306,7 +313,7 @@ se_get_exp_mod_output(buf, 0x100); /* smc_exp_mod is done now. */ - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return 0; } @@ -332,7 +339,7 @@ return 3; } /* smc_crypt_aes is done now. */ - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return 0; } @@ -381,7 +388,7 @@ se_get_exp_mod_output(rsa_wrapped_titlekey, 0x100); if (tkey_rsa_oaep_unwrap(aes_wrapped_titlekey, 0x10, rsa_wrapped_titlekey, 0x100) != 0x10) { /* Failed to extract RSA OAEP wrapped key. */ - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return 2; } @@ -392,7 +399,7 @@ p_sealed_key[1] = sealed_titlekey[1]; /* smc_unwrap_rsa_oaep_wrapped_titlekey is done now. */ - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); return 0; } @@ -445,7 +452,7 @@ result = user_get_random_bytes(args); /* Also, refill our cache while we have the chance in case we get denied later. */ randomcache_refill(); - lock_release(&g_is_user_smc_in_progress); + clear_user_smc_in_progress(); } return result; } diff --git a/exosphere/src/smc_api.h b/exosphere/src/smc_api.h index affc683..6b19602 100644 --- a/exosphere/src/smc_api.h +++ b/exosphere/src/smc_api.h @@ -10,6 +10,9 @@ uint64_t X[8]; } smc_args_t; +void set_user_smc_in_progress(void); +void clear_user_smc_in_progress(void); + void set_priv_smc_in_progress(void); void clear_priv_smc_in_progress(void); diff --git a/exosphere/src/warmboot_main.c b/exosphere/src/warmboot_main.c index 1b3a3ea..60404f5 100644 --- a/exosphere/src/warmboot_main.c +++ b/exosphere/src/warmboot_main.c @@ -56,12 +56,13 @@ clkrst_disable(CARDEVICE_I2C1); } + clear_user_smc_in_progress(); + if (mkey_get_revision() >= MASTERKEY_REVISION_400_CURRENT) { setup_4x_mmio(); /* TODO */ } } - clear_priv_smc_in_progress(); setup_current_core_state(); /* Update SCR_EL3 depending on value in Bootconfig. */