xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jan Beulich <JBeulich@suse.com>
To: Alexandru Stefan ISAILA <aisaila@bitdefender.com>
Cc: Petre Ovidiu PIRCALABU <ppircalabu@bitdefender.com>,
	"tamas@tklengyel.com" <tamas@tklengyel.com>,
	"wl@xen.org" <wl@xen.org>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	"george.dunlap@eu.citrix.com" <george.dunlap@eu.citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"paul.durrant@citrix.com" <paul.durrant@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v7] x86/emulate: Send vm_event from emulate
Date: Mon, 29 Jul 2019 11:30:54 +0000	[thread overview]
Message-ID: <b56852e8-e7db-5185-552a-cd91f8821778@suse.com> (raw)
In-Reply-To: <9a509cd8-d91a-036d-f949-f1c5d54059d6@bitdefender.com>

On 29.07.2019 10:12, Alexandru Stefan ISAILA wrote:
> 
> 
> On 19.07.2019 17:23, Razvan Cojocaru wrote:
>> On 7/19/19 4:38 PM, Jan Beulich wrote:
>>> On 19.07.2019 15:30, Razvan Cojocaru wrote:
>>>> On 7/19/19 4:18 PM, Jan Beulich wrote:
>>>>> On 19.07.2019 14:34, Alexandru Stefan ISAILA wrote:
>>>>>> On 18.07.2019 15:58, Jan Beulich wrote:
>>>>>>> On 03.07.2019 12:56, Alexandru Stefan ISAILA wrote:
>>>>>>>> A/D bit writes (on page walks) can be considered benign by an
>>>>>>>> introspection
>>>>>>>> agent, so receiving vm_events for them is a pessimization. We try
>>>>>>>> here to
>>>>>>>> optimize by fitering these events out.
>>>>>>>
>>>>>>> But you add the sending of more events - how does "filter out" match
>>>>>>> the actual implementation?
>>>>>>
>>>>>> The events are send only if there is a mem access violation
>>>>>> therefore we
>>>>>> are filtering and only sending the events that are interesting to
>>>>>> introspection.
>>>>>
>>>>> Where is it that you prevent any event from being sent? As said,
>>>>> reading the patch I only see new sending sites to get added.
>>>>
>>>> If we don't emulate, we would receive the page-walk-generated events
>>>> _and_ the touching-the-page-the-instruction-is-touching events.
>>>
>>> Since the patch here alters emulation paths only, how do you know
>>> whether to emulate? In order to not receive undue events it would
>>> seem to me that you'd first have to intercept the guest on insns
>>> of interest ... Overall I think that the patch description, while
>>> it has improved, is still lacking sufficient information for a
>>> person like me (not knowing much about your monitor tools) to be
>>> able to sensibly review this (which includes understanding the
>>> precise scenario you want to improve).
>>
>> If the hardware exits because of an EPT fault caused by a page walk, we
>> end up in p2m_mem_access_check(), at which point we need to decide if we
>> want to send out a vm_event or not.
>>
>> If we were to send out this vm_event, and it would then be magically
>> treated so that we get to actually run the instruction at RIP, said
>> instruction might also hit a protected page and provoke a vm_event.
>>
>> Now, if npfec.kind != npfec_kind_with_gla, then we're in the page walk
>> case, and so in this case only, and only if
>> d->arch.monitor.inguest_pagefault_disabled is true, we would choose to
>> do this emulation trick: emulate _the_page_walk_ while ignoring the EPT,
>> but don't ignore the EPT for the emulation of the actual instruction.
>>
>> So where in the first case we would have 2 EPT events, in the second we
>> only have one (or if the instruction at RIP does not trigger an EPT
>> event, we would have 1 event in the first case, and none in the second).
>> Hence the filtering mentioned.
>>
>> So to answer your question: "how do you know whether to emulate", we do
>> so only if npfec.kind != npfec_kind_with_gla &&
>> d->arch.monitor.inguest_pagefault_disabled.
>>
>> I hope this clears it up somewhat.
>>
> 
> To summarize the changes needed for the next version, apart from the
> code changes, is the description good or do I have to add something else?

As said in a prior reply, Razvan's explanation has helped. I don't think
though that it's suitable as a patch description without some adjustments.
I further seem to recall that I had asked for a concrete example to be
laid out in the description, highlighting what exactly in the overall flow
your patch means to change.

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

  reply	other threads:[~2019-07-29 11:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 10:56 [Xen-devel] [PATCH v7] x86/emulate: Send vm_event from emulate Alexandru Stefan ISAILA
2019-07-11 17:13 ` Tamas K Lengyel
2019-07-12  1:28   ` Jan Beulich
2019-07-15  8:52     ` Alexandru Stefan ISAILA
2019-07-18 12:58 ` Jan Beulich
2019-07-19 12:34   ` Alexandru Stefan ISAILA
2019-07-19 13:18     ` Jan Beulich
2019-07-19 13:30       ` Razvan Cojocaru
2019-07-19 13:38         ` Jan Beulich
2019-07-19 14:23           ` Razvan Cojocaru
2019-07-29  8:12             ` Alexandru Stefan ISAILA
2019-07-29 11:30               ` Jan Beulich [this message]
2019-07-22  7:51       ` Alexandru Stefan ISAILA
2019-07-30 12:21         ` Alexandru Stefan ISAILA
2019-07-30 13:27           ` Jan Beulich
2019-07-30 14:12             ` Alexandru Stefan ISAILA
2019-07-30 14:54               ` Jan Beulich
2019-07-30 15:28                 ` Alexandru Stefan ISAILA
2019-08-20 20:11                 ` Andrew Cooper
2019-08-27  8:26                   ` Jan Beulich
2019-09-02 14:36                     ` Alexandru Stefan ISAILA
2019-09-02 14:59                       ` Jan Beulich
2019-07-23  8:17       ` Alexandru Stefan ISAILA

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=b56852e8-e7db-5185-552a-cd91f8821778@suse.com \
    --to=jbeulich@suse.com \
    --cc=aisaila@bitdefender.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=paul.durrant@citrix.com \
    --cc=ppircalabu@bitdefender.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=roger.pau@citrix.com \
    --cc=tamas@tklengyel.com \
    --cc=wl@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 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).