diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index bb444fe9..1f773e41 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -193,10 +193,10 @@ struct sbi_domain { struct sbi_domain_state_priv state_priv; /** Logical index of this domain */ u32 index; - /** HARTs assigned to this domain */ - struct sbi_hartmask assigned_harts; /** Spinlock for accessing assigned_harts */ spinlock_t assigned_harts_lock; + /** HARTs assigned to this domain */ + struct sbi_hartmask assigned_harts GUARDED_BY(&assigned_harts_lock); /** Name of this domain */ char name[64]; /** Initialization order of this domain */ @@ -254,7 +254,8 @@ extern struct sbi_dlist domain_list; * @param hartindex the HART index * @return true if HART is assigned to domain otherwise false */ -bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex); +bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex) + MUST_NOT_HOLD(&dom->assigned_harts_lock); /** * Get the assigned HART mask for given domain @@ -263,7 +264,8 @@ bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex); * @return 0 on success and SBI_Exxx (< 0) on failure */ int sbi_domain_get_assigned_hartmask(const struct sbi_domain *dom, - struct sbi_hartmask *mask); + struct sbi_hartmask *mask) + MUST_NOT_HOLD(&dom->assigned_harts_lock); /** * Initialize a domain memory region based on it's physical diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 87e5faa8..b3f5892d 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -61,6 +61,7 @@ void sbi_update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom) } bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex) + MUST_NOT_HOLD(&dom->assigned_harts_lock) { bool ret; struct sbi_domain *tdom = (struct sbi_domain *)dom; @@ -77,6 +78,7 @@ bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartindex) int sbi_domain_get_assigned_hartmask(const struct sbi_domain *dom, struct sbi_hartmask *mask) + MUST_NOT_HOLD(&dom->assigned_harts_lock) { ulong ret = 0; struct sbi_domain *tdom = (struct sbi_domain *)dom; @@ -630,6 +632,7 @@ void sbi_domain_dump_all(const char *suffix) } int sbi_domain_register(struct sbi_domain *dom) + NO_THREAD_SAFETY_ANALYSIS { u32 i, cold_hartid = current_hartid(); struct sbi_domain *tdom; diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c index 6eb8199b..987ac7fa 100644 --- a/lib/sbi/sbi_domain_context.c +++ b/lib/sbi/sbi_domain_context.c @@ -107,6 +107,8 @@ static void hart_context_set(struct sbi_domain *dom, u32 hartindex, */ static int switch_to_next_domain_context(struct hart_context *ctx, struct hart_context *dom_ctx) + MUST_NOT_HOLD(&ctx->dom->assigned_harts_lock) + MUST_NOT_HOLD(&dom_ctx->dom->assigned_harts_lock) { u32 hartindex = current_hartindex(); struct sbi_trap_context *trap_ctx;