All of lore.kernel.org
 help / color / mirror / Atom feed
From: Razvan Cojocaru <rcojocaru@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, keir@xen.org, ian.campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
	eddie.dong@intel.com, tim@xen.org, jun.nakajima@intel.com,
	xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com
Subject: Re: [PATCH V7 for-4.5 4/4] xen: Handle resumed instruction based on previous mem_event reply
Date: Thu, 11 Sep 2014 17:02:39 +0300	[thread overview]
Message-ID: <5411AB7F.8070004@bitdefender.com> (raw)
In-Reply-To: <5411C15C0200007800033EDB@mail.emea.novell.com>

On 09/11/2014 04:35 PM, Jan Beulich wrote:
>>>> On 11.09.14 at 15:15, <rcojocaru@bitdefender.com> wrote:
>> @@ -1448,6 +1449,28 @@ bool_t p2m_mem_access_check(paddr_t gpa, unsigned long gla,
>>          }
>>      }
>>  
>> +    /* The previous mem_event reply does not match the current state. */
>> +    if ( v->arch.mem_event.gpa != gpa || v->arch.mem_event.eip != eip )
>> +    {
>> +        /* Don't emulate the current instruction, send a new mem_event. */
>> +        v->arch.mem_event.emulate_flags = 0;
>> +
>> +        /* Make sure to mark the current state to match it again against
>> +         * the new mem_event about to be sent. */
> 
> Coding style.

Thank you for the review. The proper way to write multiline comments in
Xen is to always begin with '/*', then each line after preceded by an
'*', ended by a single '*/' below the next line, is that correct?

/*
 * Multiline comment
 * example.
 */

>> +        if ( rsp.flags & MEM_EVENT_FLAG_EMULATE )
>> +        {
>> +            xenmem_access_t access;
>> +            bool_t violation = 1;
>> +
>> +            v->arch.mem_event.emulate_flags = 0;
> 
> Do you really need to write this once here and ...
> 
>> +
>> +            if ( p2m_get_mem_access(d, rsp.gfn, &access) == 0 )
>> +            {
>> +                switch ( access )
>> +                {
>> +                case XENMEM_access_n:
>> +                case XENMEM_access_n2rwx:
>> +                default:
>> +                    violation = rsp.access_r || rsp.access_w || rsp.access_x;
>> +                    break;
>> +
>> +                case XENMEM_access_r:
>> +                    violation = rsp.access_w || rsp.access_x;
>> +                    break;
>> +
>> +                case XENMEM_access_w:
>> +                    violation = rsp.access_r || rsp.access_x;
>> +                    break;
>> +
>> +                case XENMEM_access_x:
>> +                    violation = rsp.access_r || rsp.access_w;
>> +                    break;
>> +
>> +                case XENMEM_access_rx:
>> +                case XENMEM_access_rx2rw:
>> +                    violation = rsp.access_w;
>> +                    break;
>> +
>> +                case XENMEM_access_wx:
>> +                    violation = rsp.access_r;
>> +                    break;
>> +
>> +                case XENMEM_access_rw:
>> +                    violation = rsp.access_x;
>> +                    break;
>> +
>> +                case XENMEM_access_rwx:
>> +                    violation = 0;
>> +                    break;
>> +                }
>> +            }
>> +
>> +            if ( violation )
>> +                v->arch.mem_event.emulate_flags = rsp.flags;
> 
> ... a second time here (rather making this one simply a conditional
> expression)?

I'll assign to v->arch.mem_event.emulate_flags directly in the switch.

> And I further wonder whether all the MEM_EVENT_FLAG_* values are
> really potentially useful in v->arch.mem_event.emulate_flags - right
> now it rather looks like this field could be a simple bool_t (likely with
> a different name), which would at once make the
> hvm_mem_event_emulate_one() a little better readable.

The value is checked here:

+        hvm_mem_event_emulate_one((v->arch.mem_event.emulate_flags &
+                                   MEM_EVENT_FLAG_EMULATE_NOWRITE) != 0,
+                                  TRAP_invalid_op,
HVM_DELIVER_NO_ERROR_CODE);

where it matters if MEM_EVENT_FLAG_EMULATE_NOWRITE is set. Also, please
bear in mind that in the original series we also had a
MEM_EVENT_FLAG_SKIP flag, so this allows for even more ways to respond
to a mem_event in the future.


Thanks,
Razvan Cojocaru

  reply	other threads:[~2014-09-11 14:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 13:15 [PATCH V7 for-4.5 0/4] Basic guest memory introspection support Razvan Cojocaru
2014-09-11 13:15 ` [PATCH V7 for-4.5 1/4] xen: Emulate with no writes Razvan Cojocaru
2014-09-11 13:15 ` [PATCH V7 for-4.5 2/4] xen: Optimize introspection access to guest state Razvan Cojocaru
2014-09-11 13:15 ` [PATCH V7 for-4.5 3/4] xen, libxc: Force-enable relevant MSR events Razvan Cojocaru
2014-09-11 13:15 ` [PATCH V7 for-4.5 4/4] xen: Handle resumed instruction based on previous mem_event reply Razvan Cojocaru
2014-09-11 13:25   ` Jan Beulich
2014-09-11 13:29     ` Razvan Cojocaru
2014-09-11 13:35   ` Jan Beulich
2014-09-11 14:02     ` Razvan Cojocaru [this message]
2014-09-11 15:02       ` Jan Beulich
2014-09-11 15:21         ` Razvan Cojocaru
2014-09-11 16:04           ` Jan Beulich

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=5411AB7F.8070004@bitdefender.com \
    --to=rcojocaru@bitdefender.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.