Message ID | 83b9053330e4dae38e926c99f47d0ef11d9dd31d.1719918148.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RISCV basic exception handling implementation | expand |
On 02.07.2024 13:23, Oleksii Kurochko wrote: > --- a/xen/arch/riscv/traps.c > +++ b/xen/arch/riscv/traps.c > @@ -12,6 +12,18 @@ > #include <asm/riscv_encoding.h> > #include <asm/traps.h> > > +/* > + * Initialize the trap handling. > + * > + * The function is called after MMU is enabled. > + */ > +void trap_init(void) It may be deliberate that this isn't __init, but for the present needs it certainly could be. This is the kind of thing that imo want saying in the description (which sadly once again is entirely empty). Jan
On Wed, 2024-07-10 at 11:50 +0200, Jan Beulich wrote: > On 02.07.2024 13:23, Oleksii Kurochko wrote: > > --- a/xen/arch/riscv/traps.c > > +++ b/xen/arch/riscv/traps.c > > @@ -12,6 +12,18 @@ > > #include <asm/riscv_encoding.h> > > #include <asm/traps.h> > > > > +/* > > + * Initialize the trap handling. > > + * > > + * The function is called after MMU is enabled. > > + */ > > +void trap_init(void) > > It may be deliberate that this isn't __init, but for the present > needs it > certainly could be. This is the kind of thing that imo want saying in > the > description (which sadly once again is entirely empty). I just missed to add __init so I have to added it in the next patch version. Thanks for finding that. ~ Oleksii
On 11/07/2024 9:19 am, Oleksii wrote: > On Wed, 2024-07-10 at 11:50 +0200, Jan Beulich wrote: >> On 02.07.2024 13:23, Oleksii Kurochko wrote: >>> --- a/xen/arch/riscv/traps.c >>> +++ b/xen/arch/riscv/traps.c >>> @@ -12,6 +12,18 @@ >>> #include <asm/riscv_encoding.h> >>> #include <asm/traps.h> >>> >>> +/* >>> + * Initialize the trap handling. >>> + * >>> + * The function is called after MMU is enabled. >>> + */ >>> +void trap_init(void) >> It may be deliberate that this isn't __init, but for the present >> needs it >> certainly could be. This is the kind of thing that imo want saying in >> the >> description (which sadly once again is entirely empty). > I just missed to add __init so I have to added it in the next patch > version. > > Thanks for finding that. Don't be so hasty. It will definitely need to not be __init as soon as you add multi-CPU support to Xen. Just say so in the commit message, and save yourself needing to undo the __init in a later patch. ~Andrew
diff --git a/xen/arch/riscv/include/asm/traps.h b/xen/arch/riscv/include/asm/traps.h index 3fef318478..c30118e095 100644 --- a/xen/arch/riscv/include/asm/traps.h +++ b/xen/arch/riscv/include/asm/traps.h @@ -9,6 +9,7 @@ void do_trap(struct cpu_user_regs *cpu_regs); void handle_trap(void); +void trap_init(void); #endif /* __ASSEMBLY__ */ diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index e3cb0866d5..a6a29a1508 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -8,6 +8,7 @@ #include <public/version.h> #include <asm/early_printk.h> +#include <asm/traps.h> void arch_get_xen_caps(xen_capabilities_info_t *info) { @@ -23,6 +24,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id, { remove_identity_mapping(); + trap_init(); + printk("All set up\n"); for ( ;; ) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 37cec40dfa..cb18b30ff2 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -12,6 +12,18 @@ #include <asm/riscv_encoding.h> #include <asm/traps.h> +/* + * Initialize the trap handling. + * + * The function is called after MMU is enabled. + */ +void trap_init(void) +{ + unsigned long addr = (unsigned long)&handle_trap; + + csr_write(CSR_STVEC, addr); +} + static const char *decode_trap_cause(unsigned long cause) { static const char *const trap_causes[] = {