Skip to contentSkip to conversation

lib: sbi: fixes a few SSE errors

PATCH New Clément Léger 3 participants 9 messages Nov 25, 2024 – Dec 15, 2024

lore
Share & tools
lore
#0 lore raw

cover lib: sbi: fixes a few SSE errors

While reviewing kvm-unit-tests, Andrew Jones found a few implementation errors. This small series fixes them.

Cl?ment L?ger (2):
lib: sbi: fix GLOBAL_PLAT_DEFINE
lib: sbi: sse: Fix a6 and a7 register content upon injection

 include/sbi/sbi_ecall_interface.h | 4 ++--
 lib/sbi/sbi_sse.c                 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 lib: sbi: fix GLOBAL_PLAT_DEFINE

Fix GLOBAL_PLAT_0_START/END definitions. The specification states that the beginning of the range is 0xc000 and the end is 0xffff.

---
 include/sbi/sbi_ecall_interface.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/sbi/sbi_ecall_interface.h +2 -2
index 3aa5746..7e14d6c 100644
@@ -386,8 +386,8 @@ enum sbi_sse_state {
 #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_END		0x00007fff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START	0x0000c000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_END		0x0000ffff
 
 #define SBI_SSE_EVENT_LOCAL_PMU			0x00010000
 #define SBI_SSE_EVENT_LOCAL_PLAT_1_START	0x00014000
Signature · 1 line
2.45.2
Applied
#2 lore raw

PATCH 1/2 lib: sbi: fix GLOBAL_PLAT_DEFINE

Quoted 6 lines · On Mon, Nov 25, 2024 at 4:24?PM Cl?ment L?ger <[email protected]> wrote:

Fix GLOBAL_PLAT_0_START/END definitions. The specification states that the beginning of the range is 0xc000 and the end is 0xffff.

LGTM.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 27 lines
---
 include/sbi/sbi_ecall_interface.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/sbi/sbi_ecall_interface.h +2 -3
index 3aa5746..7e14d6c 100644
@@ -386,8 +386,8 @@ enum sbi_sse_state {
 #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_END                0x00007fff
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_START      0x0000c000
+#define SBI_SSE_EVENT_GLOBAL_PLAT_0_END                0x0000ffff
 
 #define SBI_SSE_EVENT_LOCAL_PMU                        0x00010000
 #define SBI_SSE_EVENT_LOCAL_PLAT_1_START       0x00014000
--

2.45.2

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#3 lore raw

PATCH 2/2 lib: sbi: sse: Fix a6 and a7 register content upon injection

In reply to Clément Léger

The specification states that a6 contains the current hart id and a7 contains the entry argument. This was inverted in the current implementation.

---
 lib/sbi/sbi_sse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +2 -2
index bf5620e..c9f9a9d 100644
@@ -509,8 +509,8 @@ static void sse_event_inject(struct sbi_sse_event *e,
 	csr_write(CSR_SEPC, regs->mepc);
 
 	/* Setup entry context */
-	regs->a6 = e->attrs.entry.arg;
-	regs->a7 = current_hartid();
+	regs->a6 = current_hartid();
+	regs->a7 = e->attrs.entry.arg;
 	regs->mepc = e->attrs.entry.pc;
 
 	/* Return to S-mode with virtualization disabled */
Signature · 1 line
2.45.2
Applied
#4 lore raw

PATCH 2/2 lib: sbi: sse: Fix a6 and a7 register content upon injection

Quoted 7 lines · On Mon, Nov 25, 2024 at 4:24?PM Cl?ment L?ger <[email protected]> wrote:

The specification states that a6 contains the current hart id and a7 contains the entry argument. This was inverted in the current implementation.

LGTM.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 27 lines
---
 lib/sbi/sbi_sse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/sbi/sbi_sse.c +2 -3
index bf5620e..c9f9a9d 100644
@@ -509,8 +509,8 @@ static void sse_event_inject(struct sbi_sse_event *e,
        csr_write(CSR_SEPC, regs->mepc);
 
        /* Setup entry context */
-       regs->a6 = e->attrs.entry.arg;
-       regs->a7 = current_hartid();
+       regs->a6 = current_hartid();
+       regs->a7 = e->attrs.entry.arg;
        regs->mepc = e->attrs.entry.pc;
 
        /* Return to S-mode with virtualization disabled */
--

2.45.2

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#5 lore raw

cover lib: sbi: fixes a few SSE errors

In reply to Clément Léger
Quoted 14 lines · Cl?ment L?ger

While reviewing kvm-unit-tests, Andrew Jones found a few implementation errors. This small series fixes them.

Cl?ment L?ger (2):
lib: sbi: fix GLOBAL_PLAT_DEFINE
lib: sbi: sse: Fix a6 and a7 register content upon injection

 include/sbi/sbi_ecall_interface.h | 4 ++--
 lib/sbi/sbi_sse.c                 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.2

For the series,

#6 lore raw

cover lib: sbi: fixes a few SSE errors

In reply to Clément Léger
Quoted 7 lines · On Mon, Nov 25, 2024 at 4:24?PM Cl?ment L?ger <[email protected]> wrote:

While reviewing kvm-unit-tests, Andrew Jones found a few implementation errors. This small series fixes them.

Cl?ment L?ger (2):
lib: sbi: fix GLOBAL_PLAT_DEFINE
lib: sbi: sse: Fix a6 and a7 register content upon injection

Do you have corresponding changes in Linux SSE implementation ?

Recently, we had found few more issues and fixed the Linux SSE implementation which is available in dev-upstream branch at:
https://github.com/ventanamicro/linux.git

Particularly, the Linux SSE entry/exit was not saving and restoring sscratch CSR in all paths which caused the kernel to crash in certain cases. The above mentioned branch already has the fix for it.

Regards,
Anup

#7 lore raw

cover lib: sbi: fixes a few SSE errors

Quoted 10 lines · Anup Patel
Quoted 7 lines · On Mon, Nov 25, 2024 at 4:24?PM Cl?ment L?ger <[email protected]> wrote:

While reviewing kvm-unit-tests, Andrew Jones found a few implementation errors. This small series fixes them.

Cl?ment L?ger (2):
lib: sbi: fix GLOBAL_PLAT_DEFINE
lib: sbi: sse: Fix a6 and a7 register content upon injection

Do you have corresponding changes in Linux SSE implementation ?

Yes, see my branch on github, I just rebased it on master this week:

https://github.com/rivosinc/linux/tree/dev/cleger/sse

Quoted 8 lines

Recently, we had found few more issues and fixed the Linux SSE implementation which is available in dev-upstream branch at:
https://github.com/ventanamicro/linux.git

Particularly, the Linux SSE entry/exit was not saving and restoring sscratch CSR in all paths which caused the kernel to crash in certain cases. The above mentioned branch already has the fix for it.

Yeah, I already fixed that in june and it was pushed on my branch dev/cleger/sse on github at that time. I also have a KVM SSE implementation on another branch.

I'll submit Linux SSE for review next week and I'have backported the PM notifier/ mask/unmask stuff from your branch. Whom did that work so I can credit him with a Co-Developed-by tag ?

I did not saw any other modifications though. For GHES, this seems to be a separate commit so I'll let that to Himanchu of course.

Thanks,

Cl?ment

Quoted 3 lines

Regards,
Anup

#8 lore raw

cover lib: sbi: fixes a few SSE errors

Quoted 13 lines · On Fri, Nov 29, 2024 at 8:11?PM Cl?ment L?ger <[email protected]> wrote:
Quoted 9 lines · Anup Patel
Quoted 7 lines · On Mon, Nov 25, 2024 at 4:24?PM Cl?ment L?ger <[email protected]> wrote:

While reviewing kvm-unit-tests, Andrew Jones found a few implementation errors. This small series fixes them.

Cl?ment L?ger (2):
lib: sbi: fix GLOBAL_PLAT_DEFINE
lib: sbi: sse: Fix a6 and a7 register content upon injection

Quoted 5 lines
Quoted 1 line

Do you have corresponding changes in Linux SSE implementation ?

Yes, see my branch on github, I just rebased it on master this week:

https://github.com/rivosinc/linux/tree/dev/cleger/sse

Thanks, I will cherry pick from your branch.

Quoted 11 lines
Quoted 10 lines

Recently, we had found few more issues and fixed the Linux SSE implementation which is available in dev-upstream branch at:
https://github.com/ventanamicro/linux.git

Particularly, the Linux SSE entry/exit was not saving and restoring sscratch CSR in all paths which caused the kernel to crash in certain cases. The above mentioned branch already has the fix for it.

Quoted 7 lines

Yeah, I already fixed that in june and it was pushed on my branch dev/cleger/sse on github at that time. I also have a KVM SSE implementation on another branch.

I'll submit Linux SSE for review next week and I'have backported the PM notifier/ mask/unmask stuff from your branch. Whom did that work so I can credit him with a Co-Developed-by tag ?

It was Himanshu (CC'ed).

Quoted 3 lines

I did not saw any other modifications though. For GHES, this seems to be a separate commit so I'll let that to Himanchu of course.

There was not much change in GHES related code.

Once you post an RFC for Linux SSE, Himanshu can post another RFC for GHES based on your RFC.

Regards,
Anup

Quoted 9 lines

Thanks,

Cl?ment

Quoted 3 lines

Regards,
Anup