mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: utils/irqchip: plic: Ensure no out-of-bound access in priority save/restore helpers
Currently the priority save/restore helpers writes/reads the provided array using an index whose maximum value is determined by PLIC, which potentially may disagree with the caller to these helpers. Add a parameter to ask the caller to provide the size limit of the array to ensure no out-of-bound access happens. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -24,18 +24,18 @@ static struct plic_data plic[PLIC_MAX_NR];
|
||||
static struct plic_data *plic_hartid2data[SBI_HARTMASK_MAX_BITS];
|
||||
static int plic_hartid2context[SBI_HARTMASK_MAX_BITS][2];
|
||||
|
||||
void fdt_plic_priority_save(u8 *priority)
|
||||
void fdt_plic_priority_save(u8 *priority, u32 num)
|
||||
{
|
||||
struct plic_data *plic = plic_hartid2data[current_hartid()];
|
||||
|
||||
plic_priority_save(plic, priority);
|
||||
plic_priority_save(plic, priority, num);
|
||||
}
|
||||
|
||||
void fdt_plic_priority_restore(const u8 *priority)
|
||||
void fdt_plic_priority_restore(const u8 *priority, u32 num)
|
||||
{
|
||||
struct plic_data *plic = plic_hartid2data[current_hartid()];
|
||||
|
||||
plic_priority_restore(plic, priority);
|
||||
plic_priority_restore(plic, priority, num);
|
||||
}
|
||||
|
||||
void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold)
|
||||
|
Reference in New Issue
Block a user