This commit add the stubs for two exception handlers: arch_handle_trap and arch_handle_fault.
Rationale: On RISC-V, there's a scratch register (CSR), which is typically user by the supervisor to store its stack pointer. On traps, the guest/user's SP is atomically exchanged with the scratch register, to set up the supervisor's stack. Now, in case of faults when we're inside Jailhouse, we would have to do the same trick, but, in case of double faults we're doomed anyway. So instead of preparing a new scratch register when entering the Hypervisor, I chose to simply redirect the trap vector and reuse the stack, while the hypervisor is active. So if we're trapping the hypervisor, we will later end up in arch_handle_trap. If we get a fault while we're inside the hypervisor, we will end up in arch_handle_fault. These routines will be called from assembly. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/riscv/Kbuild | 2 +- hypervisor/arch/riscv/traps.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 hypervisor/arch/riscv/traps.c diff --git a/hypervisor/arch/riscv/Kbuild b/hypervisor/arch/riscv/Kbuild index dd114a6c..4213194f 100644 --- a/hypervisor/arch/riscv/Kbuild +++ b/hypervisor/arch/riscv/Kbuild @@ -14,4 +14,4 @@ always-y := lib.a -lib-y := entry.o setup.o dbg-write.o control.o ivshmem.o paging.o pci.o lib.o +lib-y := entry.o setup.o dbg-write.o control.o ivshmem.o paging.o pci.o traps.o lib.o diff --git a/hypervisor/arch/riscv/traps.c b/hypervisor/arch/riscv/traps.c new file mode 100644 index 00000000..f61dfc1a --- /dev/null +++ b/hypervisor/arch/riscv/traps.c @@ -0,0 +1,28 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2022 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include <asm/processor.h> + +void arch_handle_trap(union registers *regs); +void arch_handle_fault(union registers *regs); + +void arch_handle_trap(union registers *regs) +{ + for (;;) + cpu_relax(); +} + +void arch_handle_fault(union registers *regs) +{ + for (;;) + cpu_relax(); +} -- 2.36.1 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20220627132905.4338-19-ralf.ramsauer%40oth-regensburg.de.
