lib: sbi: sse: fixes after review
cover lib: sbi: sse: fixes after review
This small series addresses a few comments from Samuel that were made after the series was merged.
Cl?ment L?ger (7):
lib: sbi: sse: fix typos, comments and spacing errors
lib: sbi: sse: rename sse_hart_unlock() to sse_enabled_event_unlock()
lib: sbi: sse: simplify 32bits overflow check
lib: sbi: sse: remove superfluous sbi_list_empty() check
lib: sbi: sse: call enable callback before sending IPI
lib: sbi: sse: use PRV_S instead of hardcoded value for mode
lib: sbi: sse: check handler entry to belong to supervisor mode
include/sbi/sbi_ecall_interface.h | 24 +++++++------- lib/sbi/sbi_sse.c | 53 ++++++++++++++++--------------- 2 files changed, 40 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/7 lib: sbi: sse: fix typos, comments and spacing errors
Fix some errors spotted by Samuel while reviewing the SSE implementation.
--- include/sbi/sbi_ecall_interface.h | 24 ++++++++++++------------ lib/sbi/sbi_sse.c | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-)
include/sbi/sbi_ecall_interface.h +12 -12
@@ -344,36 +344,36 @@ enum sbi_sse_attr_id {#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP BIT(3)enum sbi_sse_state { -SBI_SSE_STATE_UNUSED =0 , -SBI_SSE_STATE_REGISTERED =1 , -SBI_SSE_STATE_ENABLED =2 , -SBI_SSE_STATE_RUNNING =3 , +SBI_SSE_STATE_UNUSED =0 , +SBI_SSE_STATE_REGISTERED =1 , +SBI_SSE_STATE_ENABLED =2 , +SBI_SSE_STATE_RUNNING =3 , };/* SBI SSE Event IDs. */ #define SBI_SSE_EVENT_LOCAL_RAS 0x00000000 -#define SBI_SSE_EVENT_LOCAL_PLAT_0_START 0x00004000 +#define SBI_SSE_EVENT_LOCAL_PLAT_0_START 0x00004000#define SBI_SSE_EVENT_LOCAL_PLAT_0_END 0x00007fff#define SBI_SSE_EVENT_GLOBAL_RAS 0x00008000 -#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START 0x00004000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START 0x00004000#define SBI_SSE_EVENT_GLOBAL_PLAT_0_END 0x00007fff#define SBI_SSE_EVENT_LOCAL_PMU 0x00010000 -#define SBI_SSE_EVENT_LOCAL_PLAT_1_START 0x00014000 +#define SBI_SSE_EVENT_LOCAL_PLAT_1_START 0x00014000#define SBI_SSE_EVENT_LOCAL_PLAT_1_END 0x00017fff -#define SBI_SSE_EVENT_GLOBAL_PLAT_1_START 0x0001c000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_1_START 0x0001c000#define SBI_SSE_EVENT_GLOBAL_PLAT_1_END 0x0001ffff -#define SBI_SSE_EVENT_LOCAL_PLAT_2_START 0x00024000 +#define SBI_SSE_EVENT_LOCAL_PLAT_2_START 0x00024000#define SBI_SSE_EVENT_LOCAL_PLAT_2_END 0x00027fff -#define SBI_SSE_EVENT_GLOBAL_PLAT_2_START 0x0002c000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_2_START 0x0002c000#define SBI_SSE_EVENT_GLOBAL_PLAT_2_END 0x0002ffff#define SBI_SSE_EVENT_LOCAL_SOFTWARE 0xffff0000 -#define SBI_SSE_EVENT_LOCAL_PLAT_3_START 0xffff4000 +#define SBI_SSE_EVENT_LOCAL_PLAT_3_START 0xffff4000#define SBI_SSE_EVENT_LOCAL_PLAT_3_END 0xffff7fff#define SBI_SSE_EVENT_GLOBAL_SOFTWARE 0xffff8000 -#define SBI_SSE_EVENT_GLOBAL_PLAT_3_START 0xffffc000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_3_START 0xffffc000#define SBI_SSE_EVENT_GLOBAL_PLAT_3_END 0xffffffff#define SBI_SSE_EVENT_GLOBAL_BIT (1 << 15)
lib/sbi/sbi_sse.c +11 -11
@@ -128,7 +128,7 @@ struct sse_hart_state {* * When an event is in a state >= ENABLED, then it is inserted in the * this enabled_event_list and thus can only be removed from this -* list upon disable ecall or on complete with ONE_SHOT flag. +* list upon disable ecall or on complete with ONESHOT flag. */ struct sbi_dlist enabled_event_list;
@@ -202,7 +202,7 @@ static struct sse_hart_state *sse_get_hart_state(struct sbi_sse_event *e)return sse_get_hart_state_ptr (s); } -static struct sse_global_event *sse_get_global_event (struct sbi_sse_event * e) +static struct sse_global_event *sse_get_global_event (struct sbi_sse_event *e) { return container_of(e, struct sse_global_event, event); }
@@ -552,11 +552,11 @@ static bool sse_event_check_inject(struct sbi_sse_event *e, struct sbi_trap_regs *regs) {/* -* List of event is ordered by priority, stop at first running -* event since all other events after this one are of lower -* priority. This means an event of higher priority is already -* running. -*/ +* List of event is ordered by priority, stop at first running +* event since all other events after this one are of lower +* priority. This means an event of higher priority is already +* running. +*/ if (sse_event_state (e) ==SBI_SSE_STATE_RUNNING ) {return true; }
@@ -882,10 +882,10 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,/* * Copy all attributes at once since struct sse_event_attrs is matching -* the SBI_SSE_ATTR_* attributes. While WRITE_ATTR attribute is not used -* in s-mode sse handling path, READ_ATTR is used to retrieve the value -* of registers when interrupted. Rather than doing multiple SBI calls, -* a single one is done allowing to retrieve them all at once. +* the SBI_SSE_ATTR_* attributes. READ_ATTR is used in SSE handling path +* to retrieve the value of registers when interrupted. Rather than +* doing multiple SBI calls a single one is done allowing to retrieve +* them all at once. */ e_attrs = (unsigned long *)&e->attrs; attrs = (unsigned long *)output_phys_lo;
Signature · 1 line
2.43.0
PATCH 1/7 lib: sbi: sse: fix typos, comments and spacing errors
Quoted 5 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
Fix some errors spotted by Samuel while reviewing the SSE implementation.
Signed-off-by Cl?ment L?ger <[email protected]>Reported-by Samuel Holland <[email protected]>
LGTM.
Regards,
Anup
Quoted 120 lines
--- include/sbi/sbi_ecall_interface.h | 24 ++++++++++++------------ lib/sbi/sbi_sse.c | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-)include/sbi/sbi_ecall_interface.h +12
-12@@ -344,36 +344,36 @@ enum sbi_sse_attr_id {#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP BIT(3)enum sbi_sse_state { -SBI_SSE_STATE_UNUSED =0 , -SBI_SSE_STATE_REGISTERED =1 , -SBI_SSE_STATE_ENABLED =2 , -SBI_SSE_STATE_RUNNING =3 , +SBI_SSE_STATE_UNUSED =0 , +SBI_SSE_STATE_REGISTERED =1 , +SBI_SSE_STATE_ENABLED =2 , +SBI_SSE_STATE_RUNNING =3 , };/* SBI SSE Event IDs. */ #define SBI_SSE_EVENT_LOCAL_RAS 0x00000000 -#define SBI_SSE_EVENT_LOCAL_PLAT_0_START 0x00004000 +#define SBI_SSE_EVENT_LOCAL_PLAT_0_START 0x00004000#define SBI_SSE_EVENT_LOCAL_PLAT_0_END 0x00007fff#define SBI_SSE_EVENT_GLOBAL_RAS 0x00008000 -#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START 0x00004000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START 0x00004000#define SBI_SSE_EVENT_GLOBAL_PLAT_0_END 0x00007fff#define SBI_SSE_EVENT_LOCAL_PMU 0x00010000 -#define SBI_SSE_EVENT_LOCAL_PLAT_1_START 0x00014000 +#define SBI_SSE_EVENT_LOCAL_PLAT_1_START 0x00014000#define SBI_SSE_EVENT_LOCAL_PLAT_1_END 0x00017fff -#define SBI_SSE_EVENT_GLOBAL_PLAT_1_START 0x0001c000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_1_START 0x0001c000#define SBI_SSE_EVENT_GLOBAL_PLAT_1_END 0x0001ffff -#define SBI_SSE_EVENT_LOCAL_PLAT_2_START 0x00024000 +#define SBI_SSE_EVENT_LOCAL_PLAT_2_START 0x00024000#define SBI_SSE_EVENT_LOCAL_PLAT_2_END 0x00027fff -#define SBI_SSE_EVENT_GLOBAL_PLAT_2_START 0x0002c000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_2_START 0x0002c000#define SBI_SSE_EVENT_GLOBAL_PLAT_2_END 0x0002ffff#define SBI_SSE_EVENT_LOCAL_SOFTWARE 0xffff0000 -#define SBI_SSE_EVENT_LOCAL_PLAT_3_START 0xffff4000 +#define SBI_SSE_EVENT_LOCAL_PLAT_3_START 0xffff4000#define SBI_SSE_EVENT_LOCAL_PLAT_3_END 0xffff7fff#define SBI_SSE_EVENT_GLOBAL_SOFTWARE 0xffff8000 -#define SBI_SSE_EVENT_GLOBAL_PLAT_3_START 0xffffc000 +#define SBI_SSE_EVENT_GLOBAL_PLAT_3_START 0xffffc000#define SBI_SSE_EVENT_GLOBAL_PLAT_3_END 0xffffffff#define SBI_SSE_EVENT_GLOBAL_BIT (1 << 15)lib/sbi/sbi_sse.c +11
-12@@ -128,7 +128,7 @@ struct sse_hart_state {* * When an event is in a state >= ENABLED, then it is inserted in the * this enabled_event_list and thus can only be removed from this -* list upon disable ecall or on complete with ONE_SHOT flag. +* list upon disable ecall or on complete with ONESHOT flag. */ struct sbi_dlist enabled_event_list;@@ -202,7 +202,7 @@ static struct sse_hart_state *sse_get_hart_state(struct sbi_sse_event *e)return sse_get_hart_state_ptr (s); } -static struct sse_global_event *sse_get_global_event (struct sbi_sse_event * e) +static struct sse_global_event *sse_get_global_event (struct sbi_sse_event *e) { return container_of(e, struct sse_global_event, event); }@@ -552,11 +552,11 @@ static bool sse_event_check_inject(struct sbi_sse_event *e, struct sbi_trap_regs *regs) {/* -* List of event is ordered by priority, stop at first running -* event since all other events after this one are of lower -* priority. This means an event of higher priority is already -* running. -*/ +* List of event is ordered by priority, stop at first running +* event since all other events after this one are of lower +* priority. This means an event of higher priority is already +* running. +*/ if (sse_event_state (e) ==SBI_SSE_STATE_RUNNING ) {return true; }@@ -882,10 +882,10 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,/* * Copy all attributes at once since struct sse_event_attrs is matching -* the SBI_SSE_ATTR_* attributes. While WRITE_ATTR attribute is not used -* in s-mode sse handling path, READ_ATTR is used to retrieve the value -* of registers when interrupted. Rather than doing multiple SBI calls, -* a single one is done allowing to retrieve them all at once. +* the SBI_SSE_ATTR_* attributes. READ_ATTR is used in SSE handling path +* to retrieve the value of registers when interrupted. Rather than +* doing multiple SBI calls a single one is done allowing to retrieve +* them all at once. */ e_attrs = (unsigned long *)&e->attrs; attrs = (unsigned long *)output_phys_lo; --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 2/7 lib: sbi: sse: rename sse_hart_unlock() to sse_enabled_event_unlock()
In reply to Clément LégerThere was a naming incoherency between enabled events list lock/unlock. Rename sse_hart_unlock() to sse_enabled_event_unlock() to be coherent and reword comments above lock()/unlock() functions.
--- lib/sbi/sbi_sse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
lib/sbi/sbi_sse.c +5 -5
@@ -208,7 +208,7 @@ static struct sse_global_event *sse_get_global_event(struct sbi_sse_event *e) }/** -* If event is global, must be called under global event lock +* If event is global, must be called under enabled event lock */ static void sse_enabled_event_lock (struct sbi_sse_event *e) {
@@ -219,9 +219,9 @@ static void sse_enabled_event_lock(struct sbi_sse_event *e) }/** -* If event is global, must be called under global event lock +* If event is global, must be called under enabled event lock */ -static void sse_hart_unlock (struct sbi_sse_event *e) +static void sse_enabled_event_unlock (struct sbi_sse_event *e) {struct sse_hart_state *shs;
@@ -753,7 +753,7 @@ int sbi_sse_enable(uint32_t event_id)sse_enabled_event_lock (e); ret =sse_event_enable (e); -sse_hart_unlock (e); +sse_enabled_event_unlock (e);sse_event_put (e);return ret;
@@ -770,7 +770,7 @@ int sbi_sse_disable(uint32_t event_id)sse_enabled_event_lock (e); ret =sse_event_disable (e); -sse_hart_unlock (e); +sse_enabled_event_unlock (e);sse_event_put (e);
Signature · 1 line
2.43.0
PATCH 2/7 lib: sbi: sse: rename sse_hart_unlock() to sse_enabled_event_unlock()
Quoted 6 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
There was a naming incoherency between enabled events list lock/unlock. Rename
sse_hart_unlock()tosse_enabled_event_unlock()to be coherent and reword comments above lock()/unlock() functions.Signed-off-by Cl?ment L?ger <[email protected]>
LGTM.
Regards,
Anup
Quoted 50 lines
--- lib/sbi/sbi_sse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)lib/sbi/sbi_sse.c +5
-6@@ -208,7 +208,7 @@ static struct sse_global_event *sse_get_global_event(struct sbi_sse_event *e) }/** -* If event is global, must be called under global event lock +* If event is global, must be called under enabled event lock */ static void sse_enabled_event_lock (struct sbi_sse_event *e) {@@ -219,9 +219,9 @@ static void sse_enabled_event_lock(struct sbi_sse_event *e) }/** -* If event is global, must be called under global event lock +* If event is global, must be called under enabled event lock */ -static void sse_hart_unlock (struct sbi_sse_event *e) +static void sse_enabled_event_unlock (struct sbi_sse_event *e) {struct sse_hart_state *shs;@@ -753,7 +753,7 @@ int sbi_sse_enable(uint32_t event_id)sse_enabled_event_lock (e); ret =sse_event_enable (e); -sse_hart_unlock (e); +sse_enabled_event_unlock (e);sse_event_put (e);return ret;@@ -770,7 +770,7 @@ int sbi_sse_disable(uint32_t event_id)sse_enabled_event_lock (e); ret =sse_event_disable (e); -sse_hart_unlock (e); +sse_enabled_event_unlock (e);sse_event_put (e); --2.43.0
PATCH 3/7 lib: sbi: sse: simplify 32bits overflow check
In reply to Clément LégerRather than checking 32bits overflow with some absolute value, check the value to be different from the cast itself.
--- lib/sbi/sbi_sse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbi/sbi_sse.c +1 -1
@@ -344,7 +344,7 @@ static int sse_event_set_attr_check(struct sbi_sse_event *e, uint32_t attr_id,break ;case SBI_SSE_ATTR_PRIO :#if __riscv_xlen >32 -if (val >0xFFFFFFFFUL ) { +if (val != (uint32_t )val) { ret =SBI_EINVAL ;break ; }
Signature · 1 line
2.43.0
PATCH 3/7 lib: sbi: sse: simplify 32bits overflow check
Quoted 6 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
Rather than checking 32bits overflow with some absolute value, check the value to be different from the cast itself.
Signed-off-by Cl?ment L?ger <[email protected]>Reported-by Samuel Holland <[email protected]>
LGTM.
Regards,
Anup
Quoted 25 lines
--- lib/sbi/sbi_sse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/sbi/sbi_sse.c +1
-2@@ -344,7 +344,7 @@ static int sse_event_set_attr_check(struct sbi_sse_event *e, uint32_t attr_id,break ;case SBI_SSE_ATTR_PRIO :#if __riscv_xlen >32 -if (val >0xFFFFFFFFUL ) { +if (val != (uint32_t )val) { ret =SBI_EINVAL ;break ; } --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 4/7 lib: sbi: sse: remove superfluous sbi_list_empty() check
In reply to Clément LégerThe list loop below that check is actually not looping if the list is empty so there was no need for this check.
--- lib/sbi/sbi_sse.c | 3 --- 1 file changed, 3 deletions(-)
lib/sbi/sbi_sse.c +0 -3
@@ -578,9 +578,6 @@ void sbi_sse_process_pending_events(struct sbi_trap_regs *regs)spin_lock (&state->enabled_event_lock); -if (sbi_list_empty (&state->enabled_event_list)) - goto out; -sbi_list_for_each_entry (e, &state->enabled_event_list, node) { ret =sse_event_check_inject (e, regs);if (ret)
Signature · 1 line
2.43.0
PATCH 4/7 lib: sbi: sse: remove superfluous sbi_list_empty() check
Quoted 6 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
The list loop below that check is actually not looping if the list is empty so there was no need for this check.
Signed-off-by Cl?ment L?ger <[email protected]>Reported-by Samuel Holland <[email protected]>
LGTM.
Regards,
Anup
Quoted 26 lines
--- lib/sbi/sbi_sse.c | 3 --- 1 file changed, 3 deletions(-)lib/sbi/sbi_sse.c +0
-4@@ -578,9 +578,6 @@ void sbi_sse_process_pending_events(struct sbi_trap_regs *regs)spin_lock (&state->enabled_event_lock); -if (sbi_list_empty (&state->enabled_event_list)) - goto out; -sbi_list_for_each_entry (e, &state->enabled_event_list, node) { ret =sse_event_check_inject (e, regs);if (ret) --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 5/7 lib: sbi: sse: call enable callback before sending IPI
In reply to Clément LégerMove the enable callback call before sending the IPI. Even though the event is locked and no race condition can happen, this is more logical.
--- lib/sbi/sbi_sse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/sbi/sbi_sse.c +3 -3
@@ -686,12 +686,12 @@ static int sse_event_enable(struct sbi_sse_event *e)sse_event_set_state (e,SBI_SSE_STATE_ENABLED );sse_event_add_to_list (e); -if (sse_event_pending (e)) +sse_event_invoke_cb (e, enable_cb); + +if (sse_event_is_global (e) &&sse_event_pending (e))sbi_ipi_send_many (1 , e->attrs.hartid, sse_ipi_inject_event,NULL ); -sse_event_invoke_cb (e, enable_cb); -return SBI_OK ; }
Signature · 1 line
2.43.0
PATCH 5/7 lib: sbi: sse: call enable callback before sending IPI
Quoted 6 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
Move the enable callback call before sending the IPI. Even though the event is locked and no race condition can happen, this is more logical.
Signed-off-by Cl?ment L?ger <[email protected]>Reported-by Samuel Holland <[email protected]>
LGTM.
Regards,
Anup
Quoted 32 lines
--- lib/sbi/sbi_sse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/sbi/sbi_sse.c +3
-4@@ -686,12 +686,12 @@ static int sse_event_enable(struct sbi_sse_event *e)sse_event_set_state (e,SBI_SSE_STATE_ENABLED );sse_event_add_to_list (e); -if (sse_event_pending (e)) +sse_event_invoke_cb (e, enable_cb); + +if (sse_event_is_global (e) &&sse_event_pending (e))sbi_ipi_send_many (1 , e->attrs.hartid, sse_ipi_inject_event,NULL ); -sse_event_invoke_cb (e, enable_cb); -return SBI_OK ; } --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 6/7 lib: sbi: sse: use PRV_S instead of hardcoded value for mode
In reply to Clément LégerRather then passing 1 to sbi_domain_check_addr_range() for supervisor mode, use PRV_S.
--- lib/sbi/sbi_sse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +2 -2
@@ -837,8 +837,8 @@ int sbi_sse_attr_check(uint32_t base_attr_id, uint32_t attr_count,return SBI_EINVALID_ADDR ;if (!sbi_domain_check_addr_range (sbi_domain_thishart_ptr (), phys_lo, -sizeof (unsigned long ) * attr_count,1 , - access)) +sizeof (unsigned long ) * attr_count, +PRV_S , access))return SBI_EINVALID_ADDR ;return SBI_OK ;
Signature · 1 line
2.43.0
PATCH 6/7 lib: sbi: sse: use PRV_S instead of hardcoded value for mode
Quoted 5 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
Rather then passing 1 to
sbi_domain_check_addr_range()for supervisor mode, usePRV_S.Signed-off-by Cl?ment L?ger <[email protected]>
LGTM.
Regards,
Anup
Quoted 27 lines
--- lib/sbi/sbi_sse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/sbi/sbi_sse.c +2
-3@@ -837,8 +837,8 @@ int sbi_sse_attr_check(uint32_t base_attr_id, uint32_t attr_count,return SBI_EINVALID_ADDR ;if (!sbi_domain_check_addr_range (sbi_domain_thishart_ptr (), phys_lo, -sizeof (unsigned long ) * attr_count,1 , - access)) +sizeof (unsigned long ) * attr_count, +PRV_S , access))return SBI_EINVALID_ADDR ;return SBI_OK ; --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 7/7 lib: sbi: sse: check handler entry to belong to supervisor mode
In reply to Clément LégerWhen registering an SSE event, check for the handler_entry_pc to belong to supervisor mode domain using sbi_domain_check_addr_range().
--- lib/sbi/sbi_sse.c | 6 ++++++ 1 file changed, 6 insertions(+)
lib/sbi/sbi_sse.c +6 -0
@@ -959,6 +959,12 @@ int sbi_sse_register(uint32_t event_id, unsigned long handler_entry_pc,if (handler_entry_pc &0x1 )return SBI_EINVAL ; +if (!sbi_domain_check_addr_range (sbi_domain_thishart_ptr (), + handler_entry_pc, +sizeof (unsigned long ),PRV_S , +SBI_DOMAIN_EXECUTE )) +return SBI_EINVALID_ADDR ; + e =sse_event_get (event_id);if (!e)return SBI_EINVAL ;
Signature · 1 line
2.43.0
PATCH 7/7 lib: sbi: sse: check handler entry to belong to supervisor mode
Quoted 6 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
When registering an SSE event, check for the
handler_entry_pcto belong to supervisor mode domain usingsbi_domain_check_addr_range().Signed-off-by Cl?ment L?ger <[email protected]>Reported-by Samuel Holland <[email protected]>
LGTM.
Regards,
Anup
Quoted 29 lines
--- lib/sbi/sbi_sse.c | 6 ++++++ 1 file changed, 6 insertions(+)lib/sbi/sbi_sse.c +6
-1@@ -959,6 +959,12 @@ int sbi_sse_register(uint32_t event_id, unsigned long handler_entry_pc,if (handler_entry_pc &0x1 )return SBI_EINVAL ; +if (!sbi_domain_check_addr_range (sbi_domain_thishart_ptr (), + handler_entry_pc, +sizeof (unsigned long ),PRV_S , +SBI_DOMAIN_EXECUTE )) +return SBI_EINVALID_ADDR ; + e =sse_event_get (event_id);if (!e)return SBI_EINVAL ; --2.43.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
Appliedcover lib: sbi: sse: fixes after review
In reply to Clément LégerQuoted 4 lines · On Tue, Apr 9, 2024 at 3:32?PM Cl?ment L?ger <[email protected]> wrote:
This small series addresses a few comments from Samuel that were made after the series was merged.
Quoted 8 lines
Cl?ment L?ger (7):
lib: sbi: sse: fix typos, comments and spacing errors
lib: sbi: sse: renamesse_hart_unlock()tosse_enabled_event_unlock()
lib: sbi: sse: simplify 32bits overflow check
lib: sbi: sse: remove superfluoussbi_list_empty()check
lib: sbi: sse: call enable callback before sending IPI
lib: sbi: sse: usePRV_Sinstead of hardcoded value for mode
lib: sbi: sse: check handler entry to belong to supervisor mode
Applied this series to the riscv/opensbi repo.
Thanks,
Anup
Quoted 13 lines
include/sbi/sbi_ecall_interface.h | 24 +++++++------- lib/sbi/sbi_sse.c | 53 ++++++++++++++++--------------- 2 files changed, 40 insertions(+), 37 deletions(-)--
2.43.0--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi