forked from Mirrors/opensbi
lib: sbi: sse: Add support for SSTATUS.SPELP
As raised during the ARC review, SPELP was not handled during the event injection process. Save it as part of the interrupted flags, clear it before injecting the event and restore it after completion. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
This commit is contained in:

committed by
Anup Patel

parent
53d322f8ae
commit
b4464b22e4
@@ -384,6 +384,7 @@ enum sbi_sse_attr_id {
|
|||||||
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE BIT(1)
|
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE BIT(1)
|
||||||
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPV BIT(2)
|
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPV BIT(2)
|
||||||
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP BIT(3)
|
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP BIT(3)
|
||||||
|
#define SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPELP BIT(4)
|
||||||
|
|
||||||
enum sbi_sse_state {
|
enum sbi_sse_state {
|
||||||
SBI_SSE_STATE_UNUSED = 0,
|
SBI_SSE_STATE_UNUSED = 0,
|
||||||
|
@@ -430,7 +430,8 @@ static int sse_event_set_attr_check(struct sbi_sse_event *e, uint32_t attr_id,
|
|||||||
if (val & ~(SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP |
|
if (val & ~(SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP |
|
||||||
SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE |
|
SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE |
|
||||||
SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPV |
|
SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPV |
|
||||||
SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP))
|
SBI_SSE_ATTR_INTERRUPTED_FLAGS_HSTATUS_SPVP |
|
||||||
|
SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPELP))
|
||||||
return SBI_EINVAL;
|
return SBI_EINVAL;
|
||||||
__attribute__((__fallthrough__));
|
__attribute__((__fallthrough__));
|
||||||
case SBI_SSE_ATTR_INTERRUPTED_SEPC:
|
case SBI_SSE_ATTR_INTERRUPTED_SEPC:
|
||||||
@@ -522,6 +523,8 @@ static unsigned long sse_interrupted_flags(unsigned long mstatus)
|
|||||||
flags |= SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE;
|
flags |= SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPIE;
|
||||||
if (mstatus & MSTATUS_SPP)
|
if (mstatus & MSTATUS_SPP)
|
||||||
flags |= SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP;
|
flags |= SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP;
|
||||||
|
if (mstatus & MSTATUS_SPELP)
|
||||||
|
flags |= SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPELP;
|
||||||
|
|
||||||
if (misa_extension('H')) {
|
if (misa_extension('H')) {
|
||||||
hstatus = csr_read(CSR_HSTATUS);
|
hstatus = csr_read(CSR_HSTATUS);
|
||||||
@@ -579,8 +582,11 @@ static void sse_event_inject(struct sbi_sse_event *e,
|
|||||||
regs->a7 = e->attrs.entry.arg;
|
regs->a7 = e->attrs.entry.arg;
|
||||||
regs->mepc = e->attrs.entry.pc;
|
regs->mepc = e->attrs.entry.pc;
|
||||||
|
|
||||||
/* Return to S-mode with virtualization disabled */
|
/*
|
||||||
regs->mstatus &= ~(MSTATUS_MPP | MSTATUS_SIE);
|
* Return to S-mode with virtualization disabled, not expected landing
|
||||||
|
* pad.
|
||||||
|
*/
|
||||||
|
regs->mstatus &= ~(MSTATUS_MPP | MSTATUS_SIE | MSTATUS_SPELP);
|
||||||
regs->mstatus |= (PRV_S << MSTATUS_MPP_SHIFT);
|
regs->mstatus |= (PRV_S << MSTATUS_MPP_SHIFT);
|
||||||
|
|
||||||
#if __riscv_xlen == 64
|
#if __riscv_xlen == 64
|
||||||
@@ -639,6 +645,10 @@ static void sse_event_resume(struct sbi_sse_event *e,
|
|||||||
if (i_ctx->flags & SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP)
|
if (i_ctx->flags & SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPP)
|
||||||
regs->mstatus |= MSTATUS_SPP;
|
regs->mstatus |= MSTATUS_SPP;
|
||||||
|
|
||||||
|
regs->mstatus &= ~MSTATUS_SPELP;
|
||||||
|
if (i_ctx->flags & SBI_SSE_ATTR_INTERRUPTED_FLAGS_SSTATUS_SPELP)
|
||||||
|
regs->mstatus |= MSTATUS_SPELP;
|
||||||
|
|
||||||
regs->a7 = i_ctx->a7;
|
regs->a7 = i_ctx->a7;
|
||||||
regs->a6 = i_ctx->a6;
|
regs->a6 = i_ctx->a6;
|
||||||
csr_write(CSR_SEPC, i_ctx->sepc);
|
csr_write(CSR_SEPC, i_ctx->sepc);
|
||||||
|
Reference in New Issue
Block a user