mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-10-09 18:12:18 +01:00
lib: sbi: Prevent target domain same as the current
Add error handling code to sbi_domain_context_enter to prevent the target domain from being the same as the current domain. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250903044619.394019-4-wxjstz@126.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -193,6 +193,10 @@ int sbi_domain_context_enter(struct sbi_domain *dom)
|
|||||||
struct hart_context *dom_ctx;
|
struct hart_context *dom_ctx;
|
||||||
struct hart_context *ctx = hart_context_thishart_get();
|
struct hart_context *ctx = hart_context_thishart_get();
|
||||||
|
|
||||||
|
/* Target domain must not be same as the current domain */
|
||||||
|
if (!dom || dom == sbi_domain_thishart_ptr())
|
||||||
|
return SBI_EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If it's first time to call `enter` on the current hart, no
|
* If it's first time to call `enter` on the current hart, no
|
||||||
* context allocated before. Allocate context for each valid
|
* context allocated before. Allocate context for each valid
|
||||||
|
Reference in New Issue
Block a user