[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v5] hvm/svm: Implement Debug events



>>> On 23.03.18 at 09:31, <aisaila@xxxxxxxxxxxxxxx> wrote:
> @@ -2656,9 +2663,28 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
>          HVMTRACE_0D(SMI);
>          break;
>  
> +    case VMEXIT_ICEBP:
>      case VMEXIT_EXCEPTION_DB:
>          if ( !v->domain->debugger_attached )
> -            hvm_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
> +        {
> +            int rc;
> +            unsigned int trap_type = exit_reason == VMEXIT_ICEBP ?
> +                X86_EVENTTYPE_PRI_SW_EXCEPTION : X86_EVENTTYPE_HW_EXCEPTION;
> +
> +            inst_len = 0;
> +
> +            if ( trap_type == X86_EVENTTYPE_PRI_SW_EXCEPTION )
> +                inst_len = __get_instruction_length(v, INSTR_ICEBP);

It'll be the SVM maintainers to judge, but I think the code structure
I've previously suggested would make things more clear:

            if ( exit_reason != VMEXIT_ICEBP )
            {
                trap_type == X86_EVENTTYPE_HW_EXCEPTION;
                inst_len = 0;
            }
            else
            {
                trap_type == X86_EVENTTYPE_PRI_SW_EXCEPTION;
                inst_len = __get_instruction_length(v, INSTR_ICEBP);
            }

Perhaps even with likely() added.

> @@ -407,6 +408,20 @@ void hvm_migrate_pirqs(struct vcpu *v);
>  
>  void hvm_inject_event(const struct x86_event *event);
>  
> +static inline void hvm_inject_exception(
> +    unsigned int vector, unsigned int type,
> +    unsigned int insn_len, int error_code)
> +{
> +    struct x86_event event = {
> +        .vector = vector,
> +        .type = type,
> +        .insn_len = insn_len,
> +        .error_code = error_code,
> +    };
> +
> +    hvm_inject_event(&event);
> +}
> +
>  static inline void hvm_inject_hw_exception(unsigned int vector, int errcode)

One more note here: I wonder whether hvm_inject_hw_exception()
shouldn't become a wrapper now around the new function you
introduce. But of course this could also be done as cleanup later.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.