xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Vlad-Ioan TOPAN <itopan@bitdefender.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Tamas K Lengyel <tamas@tklengyel.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] x86/monitor: add support for descriptor access events
Date: Tue, 14 Mar 2017 09:15:04 -0400	[thread overview]
Message-ID: <a8cdb344-796f-8474-17db-8fd6ed56eade@oracle.com> (raw)
In-Reply-To: <f53569fa-bea8-f95c-415e-d99215e32b90@bitdefender.com>



On 03/14/2017 08:50 AM, Razvan Cojocaru wrote:
> On 03/14/2017 02:15 PM, Vlad-Ioan TOPAN wrote:
>>>> @@ -2642,6 +2660,38 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
>>>>      case VMEXIT_PAUSE:
>>>>          svm_vmexit_do_pause(regs);
>>>>          break;
>>>> +
>>>> +    case VMEXIT_IDTR_READ:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_IDTR, 0);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_GDTR_READ:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_GDTR, 0);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_LDTR_READ:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_LDTR, 0);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_TR_READ:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_TR, 0);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_IDTR_WRITE:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_IDTR, 1);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_GDTR_WRITE:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_GDTR, 1);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_LDTR_WRITE:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_LDTR, 1);
>>>> +        break;
>>>> +
>>>> +    case VMEXIT_TR_WRITE:
>>>> +        hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0, VM_EVENT_DESC_TR, 1);
>>>> +        break;
>>>
>>> I think this can be halved in size by having
>>> 'hvm_descriptor_access_intercept(..., exit_reason_write?1:0)'
>>>
>>> And maybe even collapse completely by having a lookup table mapping exit
>>> reason to event.
>>
>> The problem with both ideas is that they depend on assumptions about the
>> values of the VMEXIT_* constants to make the code shorter and still
>> keep it readable, which in my opinion would be bad. Although they will
>> most likely stay sequential and keep their current numeric values, it's
>> not something I'd hardcode. Without those assumptions, it's either
>> another switch or a very long if, which would mean roughly the same
>> amount of code, but less readable (it's the way I've written it
>> initally before coming to this version).
>
> I'm reading Boris' suggestion to mean:
>
> case VMEXIT_IDTR_READ:
> case VMEXIT_IDTR_WRITE:
>     hvm_descriptor_access_intercept(vmcb->exitintinfo.bytes, 0,
>         VM_EVENT_DESC_IDTR, exit_reason == VMEXIT_IDTR_WRITE);
>     break;
>
> I could be wrong.


Right, that's exactly what I meant, thanks.

As for getting rid of all but one cases --- yes, it may be a a bit 
tricky to do it in a reasonably compact manner.

-boris

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

  reply	other threads:[~2017-03-14 13:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 15:50 [PATCH] x86/monitor: add support for descriptor access events Vlad Ioan Topan
2017-03-10 19:41 ` Tamas K Lengyel
2017-03-14 12:07   ` Vlad-Ioan TOPAN
2017-03-13 21:24 ` Boris Ostrovsky
2017-03-14 12:15   ` Vlad-Ioan TOPAN
2017-03-14 12:50     ` Razvan Cojocaru
2017-03-14 13:15       ` Boris Ostrovsky [this message]
2017-03-16  9:25         ` Vlad-Ioan TOPAN
2017-03-14 13:18     ` Jan Beulich
2017-03-14 12:39 ` Wei Liu
2017-03-17 11:03 ` Jan Beulich
2017-03-20 19:21   ` Vlad-Ioan TOPAN
2017-03-21  8:04     ` Jan Beulich
2017-03-21 12:04 ` Andrew Cooper
2017-03-28 12:32   ` Vlad-Ioan TOPAN

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=a8cdb344-796f-8474-17db-8fd6ed56eade@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=itopan@bitdefender.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tamas@tklengyel.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).