Re: [PATCH 2/4] KVM: riscv: selftests: Add exception handling support
From: Haibo Xu
Date: Tue Aug 01 2023 - 21:50:00 EST
On Fri, Jul 28, 2023 at 11:53 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Fri, Jul 28, 2023, Andrew Jones wrote:
> > On Thu, Jul 27, 2023 at 03:20:06PM +0800, Haibo Xu wrote:
> > > +void vm_init_trap_vector_tables(struct kvm_vm *vm);
> > > +void vcpu_init_trap_vector_tables(struct kvm_vcpu *vcpu);
> >
> > I think we should use a common name for these prototypes that the other
> > architectures agree to and then put them in a common header. My vote for
> > the naming is,
>
> Just allocate the tables in kvm_arch_vm_post_create(). I've been meaning to
> convert x86 and ARM, but keep getting distracted/waylaid by other things.
>
> https://lore.kernel.org/all/Y8hCBOndYMD9zsDL@xxxxxxxxxx
>
> > void vm_init_vector_tables(struct kvm_vm *vm);
> > void vcpu_init_vector_tables(struct kvm_vcpu *vcpu);
> >
> > > +
> > > +typedef void(*handler_fn)(struct ex_regs *);
> > > +void vm_install_exception_handler(struct kvm_vm *vm, int ec, handler_fn handler);
> >
> > I'd also put this typedef
>
> And rename it to (*exception_handler_fn).
>
> > and prototype in a common header (with s/ec/vector/ to what you have here)
>
> Hmm, yeah, I think it makes sense to let vm_install_exception_handler() be used
> from common code. the vector to be installed is inherently arch specific, but
> it would be easy enough for a test to use #ifdeffery to define the correct vector.
Thanks for the suggestion. I'll have a try to consolidate these codes in v2.