On Mon, 2023-01-23 at 11:50 +0000, Andrew Cooper wrote: > > > > + /* Save context to stack */ > > + REG_S sp, (RISCV_CPU_USER_REGS_OFFSET(sp) - > > RISCV_CPU_USER_REGS_SIZE) (sp) > > + addi sp, sp, -RISCV_CPU_USER_REGS_SIZE > > + REG_S t0, RISCV_CPU_USER_REGS_OFFSET(t0)(sp) > > Exceptions on RISC-V don't adjust the stack pointer. This logic > depends > on interrupting Xen code, and Xen not having suffered a stack > overflow > (and actually, that the space on the stack for all registers also > doesn't overflow). > Probably I missed something but an idea of the code above was to reserve memory on a stack to save the registers which can be changed in __handler_expception() as the line of code where exception occurs will expect that registers value weren't changed. Otherwise if we won't reserve memory on stack it will be corrupted by REG_S which basically is SD instruction.
- Re: [PATCH v1 06/14] xen/riscv: introduce ex... Andrew Cooper
- Re: [PATCH v1 06/14] xen/riscv: introduce exception ... Jan Beulich
- [PATCH v1 07/14] xen/riscv: introduce exception handlers ... Oleksii Kurochko
- Re: [PATCH v1 07/14] xen/riscv: introduce exception ... Alistair Francis
- Re: [PATCH v1 07/14] xen/riscv: introduce exception ... Jan Beulich
- Re: [PATCH v1 07/14] xen/riscv: introduce exception ... Andrew Cooper
- Re: [PATCH v1 07/14] xen/riscv: introduce except... Jan Beulich
- Re: [PATCH v1 07/14] xen/riscv: introduce except... Oleksii
- Re: [PATCH v1 07/14] xen/riscv: introduce ex... Andrew Cooper
- Re: [PATCH v1 07/14] xen/riscv: introduce except... Oleksii
- [PATCH v1 04/14] xen/riscv: add <asm/csr.h> header Oleksii Kurochko
- Re: [PATCH v1 04/14] xen/riscv: add <asm/csr.h>... Alistair Francis
- Re: [PATCH v1 04/14] xen/riscv: add <asm/csr.h>... Jan Beulich
- [PATCH v1 12/14] xen/riscv: introduce an implementation o... Oleksii Kurochko
- [PATCH v1 10/14] xen/riscv: mask all interrupts Oleksii Kurochko
- Re: [PATCH v1 10/14] xen/riscv: mask all interrupts Alistair Francis
- [PATCH v1 11/14] xen/riscv: introduce setup_trap_handler(... Oleksii Kurochko