mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(security): add anti-FI checks while setting up PSRAM encryption
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "hal/assert.h"
|
||||
#include "hal/mmu_types.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
#include "esp_fault.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -289,6 +290,15 @@ __attribute__((always_inline)) static inline void mmu_ll_write_entry(uint32_t mm
|
||||
|
||||
REG_WRITE(index_reg, entry_id);
|
||||
REG_WRITE(content_reg, mmu_val);
|
||||
|
||||
// Anti-FI check to confirm the encryption status for PSRAM entry.
|
||||
// This avoids a potential FI attacks to keep PSRAM unencrypted and
|
||||
// hence read out plaintext in execute from PSRAM model.
|
||||
if (mmu_ll_cache_encryption_enabled() && mmu_id == MMU_LL_PSRAM_MMU_ID) {
|
||||
ESP_FAULT_ASSERT(REG_READ(content_reg) & SOC_MMU_PSRAM_SENSITIVE);
|
||||
} else {
|
||||
ESP_FAULT_ASSERT(!(mmu_ll_cache_encryption_enabled() && mmu_id == MMU_LL_PSRAM_MMU_ID));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user