xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Tamas K Lengyel <tamas@tklengyel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Wei Liu <wei.liu2@citrix.com>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v4 8/8] x86/vm_event: Add HVM debug exception vm_events
Date: Mon, 30 May 2016 14:13:51 -0600	[thread overview]
Message-ID: <CABfawhmG7U6K8hg2r28DjQ+Z0AouPqA8rDY=OmrPGcHH2OPJYg@mail.gmail.com> (raw)
In-Reply-To: <574C675902000078000EFB1F@prv-mh.provo.novell.com>

On Mon, May 30, 2016 at 8:16 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 30.05.16 at 00:37, <tamas@tklengyel.com> wrote:
>> @@ -117,7 +133,11 @@ int hvm_monitor_breakpoint(unsigned long rip,
>>
>>      req.vcpu_id = curr->vcpu_id;
>>
>> -    return vm_event_monitor_traps(curr, 1, &req);
>> +    rc = vm_event_monitor_traps(curr, sync, &req);
>> +    if ( type == HVM_MONITOR_DEBUG_EXCEPTION && rc == 1 && !sync )
>> +        rc = 0;
>> +
>> +    return rc;
>>  }
>
> To someone like me, not intimately familiar with the code, this added
> logic looks pretty arbitrary. Please add a comment indicating why
> under these special circumstances rc needs to be altered here, which
> then will hopefully also clarify why that can't be done right in
> vm_event_monitor_traps().

Yea, vm_event_monitor_traps is not the most straight forward function
in regards of what the return value means. I'll see if I can clean it
up a bit in another patch.

>
>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> @@ -3377,9 +3377,25 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>>              HVMTRACE_1D(TRAP_DEBUG, exit_qualification);
>>              write_debugreg(6, exit_qualification | DR_STATUS_RESERVED_ONE);
>>              if ( !v->domain->debugger_attached )
>> -                vmx_propagate_intr(intr_info);
>> +            {
>> +                unsigned long insn_length = 0;
>> +                int handled;
>
> The variable name suggests it wants to be bool_t, but ...
>
>> +                unsigned long trap_type = MASK_EXTR(intr_info,
>> +                                                    INTR_INFO_INTR_TYPE_MASK);
>> +
>> +                if( trap_type >= X86_EVENTTYPE_SW_INTERRUPT )
>> +                    __vmread(VM_EXIT_INSTRUCTION_LEN, &insn_length);
>> +
>> +                handled = hvm_monitor_debug(regs->eip,
>> +                                            HVM_MONITOR_DEBUG_EXCEPTION,
>> +                                            trap_type, insn_length);
>> +                if ( handled <= 0 )
>
> ... it clearly can't. Please use a better name (could by just "rc" or
> "ret"). (Otoh I see that code you modify further down uses that
> same naming for a similar purpose variable. Let's see what the VMX
> maintainers say.)
>
>> +                    vmx_propagate_intr(intr_info);
>> +
>> +            }
>>              else
>>                  domain_pause_for_debugger();
>> +
>>              break;
>>          case TRAP_int3:
>
> If anywhere, this added blank line wants to go after the break.
>
>> @@ -3393,8 +3409,9 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>>              }
>>              else {
>>                  int handled =
>> -                    hvm_monitor_breakpoint(regs->eip,
>> -                                           HVM_MONITOR_SOFTWARE_BREAKPOINT);
>> +                        hvm_monitor_debug(regs->eip,
>> +                                          HVM_MONITOR_SOFTWARE_BREAKPOINT,
>> +                                          X86_EVENTTYPE_SW_EXCEPTION, 1);
>
> Please let's not add further mistakes like this, assuming INT3 can't
> have any prefixes. It can, even if they're useless.

You mean the instruction length is not necessarily 1? Ultimately it
doesn't seem to matter because reinjecting it with xc_hvm_inject_trap
ignores this field. Instruction length is only required to be properly
set AFAICT for a subset of debug exceptions during reinjection.

>
>> @@ -3721,8 +3738,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>>          vmx_update_cpu_exec_control(v);
>>          if ( v->arch.hvm_vcpu.single_step )
>>          {
>> -            hvm_monitor_breakpoint(regs->eip,
>> -                                   HVM_MONITOR_SINGLESTEP_BREAKPOINT);
>> +            hvm_monitor_debug(regs->eip, HVM_MONITOR_SINGLESTEP_BREAKPOINT, 0, 0);
>
> How come the 3rd argument is literal zero here?

Instruction length is only meaningful for a subset of debug exceptions
that could be reinjected to the guest using xc_hvm_inject_trap.
Monitor trap flag events are external to the guest so there is nothing
to inject. The instruction length field won't even exist for this type
of singlestep events (we distinguish vm_event_singlestep and
vm_event_debug structs for this reason), so 0 here is arbitrary. We
could set it to ~0 to make it more obvious that it's just a
placeholder in this context.

> Also you're creating a long line here.

Ack.

Thanks,
Tamas

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-05-30 20:13 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-29 22:37 [PATCH v4 1/8] monitor: Rename vm_event_monitor_get_capabilities Tamas K Lengyel
2016-05-29 22:37 ` [PATCH v4 2/8] monitor: Rename vm_event_monitor_guest_request Tamas K Lengyel
2016-05-30  7:05   ` Razvan Cojocaru
2016-05-30 13:51   ` Jan Beulich
2016-05-29 22:37 ` [PATCH v4 3/8] monitor: Rename hvm/event to hvm/monitor Tamas K Lengyel
2016-05-30  7:08   ` Razvan Cojocaru
2016-05-30 13:53   ` Jan Beulich
2016-05-29 22:37 ` [PATCH v4 4/8] monitor: ARM SMC events Tamas K Lengyel
2016-06-01 11:37   ` Julien Grall
     [not found]     ` <CABfawhmO9tUG3-OcorfwqdOgZTkjoUk+u=dHySGonBDvobqyKw@mail.gmail.com>
     [not found]       ` <CABfawhmK2GAmQqZMhrgjYzeUZ_XaoyRUPuJxyPK5LJEHwsp5SA@mail.gmail.com>
     [not found]         ` <CABfawh=J1fwinTYKGvJNrFPOsGLSXz6U3GE8fxPz3-KsXSWfbQ@mail.gmail.com>
     [not found]           ` <CABfawhn7zvE=hn0hq1ryH+sW-jdkAXgZM1C2KxwZVUE8pbp8cQ@mail.gmail.com>
2016-06-01 15:41             ` Tamas K Lengyel
2016-06-02 14:23               ` Julien Grall
2016-06-02 22:31                 ` Tamas K Lengyel
2016-07-04 19:13                 ` Tamas K Lengyel
2016-07-04 20:02                   ` Julien Grall
2016-07-04 21:05                     ` Tamas K Lengyel
2016-07-05  9:58                       ` Julien Grall
2016-05-29 22:37 ` [PATCH v4 5/8] arm/vm_event: get/set registers Tamas K Lengyel
2016-05-30  7:09   ` Razvan Cojocaru
2016-05-30 11:50   ` Jan Beulich
2016-05-30 19:47     ` Tamas K Lengyel
2016-05-30 20:20       ` Julien Grall
2016-05-30 20:37         ` Tamas K Lengyel
2016-05-30 20:46           ` Razvan Cojocaru
2016-05-30 20:53             ` Tamas K Lengyel
2016-05-30 21:35           ` Julien Grall
2016-05-30 21:41             ` Tamas K Lengyel
2016-05-31  7:54           ` Jan Beulich
2016-05-31  8:06             ` Razvan Cojocaru
2016-05-31  8:30               ` Jan Beulich
2016-05-31 16:20             ` Tamas K Lengyel
2016-05-31  7:48       ` Jan Beulich
2016-05-31 16:28         ` Tamas K Lengyel
2016-06-01  8:41           ` Jan Beulich
2016-06-01 11:24             ` Julien Grall
2016-06-01 18:21               ` Tamas K Lengyel
2016-06-01 19:34                 ` Razvan Cojocaru
2016-06-01 19:43                   ` Julien Grall
2016-06-02  7:35                   ` Jan Beulich
2016-06-02  8:26                     ` Razvan Cojocaru
2016-06-02  9:38                       ` Jan Beulich
2016-06-02  9:42                         ` Razvan Cojocaru
2016-06-01 19:38                 ` Julien Grall
2016-06-01 19:49                   ` Julien Grall
2016-06-01 19:50                   ` Tamas K Lengyel
2016-05-29 22:37 ` [PATCH v4 6/8] tools/libxc: add xc_monitor_privileged_call Tamas K Lengyel
2016-05-29 22:37 ` [PATCH v4 7/8] tools/xen-access: add test-case for ARM SMC Tamas K Lengyel
2016-05-30  9:56   ` Wei Liu
2016-05-29 22:37 ` [PATCH v4 8/8] x86/vm_event: Add HVM debug exception vm_events Tamas K Lengyel
2016-05-30  7:29   ` Razvan Cojocaru
2016-05-30 14:16   ` Jan Beulich
2016-05-30 20:13     ` Tamas K Lengyel [this message]
2016-05-30 20:58       ` Andrew Cooper
2016-05-31  7:59       ` Jan Beulich
2016-06-01 21:46         ` Tamas K Lengyel
2016-06-01 22:17           ` Andrew Cooper
2016-06-02  0:01             ` Tamas K Lengyel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABfawhmG7U6K8hg2r28DjQ+Z0AouPqA8rDY=OmrPGcHH2OPJYg@mail.gmail.com' \
    --to=tamas@tklengyel.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).