From: Adrian Pop <apop@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>, xen-devel@lists.xenproject.org
Cc: Kevin Tian <kevin.tian@intel.com>,
Tamas K Lengyel <tamas@tklengyel.com>,
Wei Liu <wei.liu2@citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Razvan Cojocaru <rcojocaru@bitdefender.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH v3] x86/monitor: add support for descriptor access events
Date: Fri, 7 Apr 2017 16:38:03 +0300 [thread overview]
Message-ID: <20170407133803.GA26163@hel> (raw)
In-Reply-To: <58E7ADC2020000780014E941@prv-mh.provo.novell.com>
On Fri, Apr 07, 2017 at 07:18:26AM -0600, Jan Beulich wrote:
> >>> On 07.04.17 at 12:17, <apop@bitdefender.com> wrote:
> > --- a/xen/arch/x86/hvm/hvm.c
> > +++ b/xen/arch/x86/hvm/hvm.c
> > @@ -3589,6 +3589,41 @@ gp_fault:
> > return X86EMUL_EXCEPTION;
> > }
> >
> > +int hvm_descriptor_access_intercept(uint64_t exit_info,
> > + uint64_t vmx_exit_qualification,
> > + unsigned int descriptor, bool is_write)
> > +{
> > + struct vcpu *curr = current;
> > + struct domain *currd = curr->domain;
> > +
> > + if ( currd->arch.monitor.descriptor_access_enabled )
> > + {
> > + ASSERT(curr->arch.vm_event);
> > + hvm_monitor_descriptor_access(exit_info, vmx_exit_qualification,
> > + descriptor, is_write);
> > + }
> > + else
> > + {
> > + struct hvm_emulate_ctxt ctxt = {};
>
> Pointless initializer - this function ...
>
> > + hvm_emulate_init_once(&ctxt, NULL, guest_cpu_user_regs());
>
> ... memset()s the whole structure.
Indeed.
> > --- a/xen/arch/x86/hvm/monitor.c
> > +++ b/xen/arch/x86/hvm/monitor.c
> > @@ -72,6 +72,30 @@ void hvm_monitor_msr(unsigned int msr, uint64_t value)
> > }
> > }
> >
> > +void hvm_monitor_descriptor_access(uint64_t exit_info,
> > + uint64_t vmx_exit_qualification,
> > + uint8_t descriptor, bool is_write)
> > +{
> > + struct vcpu *curr = current;
>
> Pointless local variable, it is being use just once ...
>
> > + vm_event_request_t req = {
> > + .reason = VM_EVENT_REASON_DESCRIPTOR_ACCESS,
> > + .u.desc_access.descriptor = descriptor,
> > + .u.desc_access.is_write = is_write,
> > + };
> > +
> > + if ( cpu_has_vmx )
> > + {
> > + req.u.desc_access.arch.vmx.instr_info = exit_info;
> > + req.u.desc_access.arch.vmx.exit_qualification = vmx_exit_qualification;
> > + }
> > + else
> > + {
> > + req.u.desc_access.arch.svm.exitinfo = exit_info;
> > + }
> > +
> > + monitor_traps(curr, true, &req);
>
> ... here afaics.
That's right. Using current directly would be fine.
> > --- a/xen/include/asm-x86/hvm/vmx/vmx.h
> > +++ b/xen/include/asm-x86/hvm/vmx/vmx.h
> > @@ -628,4 +628,48 @@ typedef struct {
> > u16 eptp_index;
> > } ve_info_t;
> >
> > +/* VM-Exit instruction info for LIDT, LGDT, SIDT, SGDT */
> > +typedef union idt_or_gdt_instr_info {
> > + unsigned long raw;
> > + struct {
> > + unsigned long scaling :2, /* bits 0:1 - Scaling */
> > + :5, /* bits 6:2 - Undefined */
> > + addr_size :3, /* bits 9:7 - Address size */
> > + :1, /* bit 10 - Cleared to 0 */
> > + operand_size :1, /* bit 11 - Operand size */
> > + :3, /* bits 14:12 - Undefined */
> > + segment_reg :3, /* bits 17:15 - Segment register */
> > + index_reg :4, /* bits 21:18 - Index register */
> > + index_reg_invalid :1, /* bit 22 - Index register invalid */
> > + base_reg :4, /* bits 26:23 - Base register */
> > + base_reg_invalid :1, /* bit 27 - Base register invalid */
> > + instr_identity :1, /* bit 28 - 0:GDT, 1:IDT */
> > + instr_write :1, /* bit 29 - 0:store, 1:load */
> > + :2, /* bits 30:31 - Undefined */
> > + :32; /* bits 32:63 - Undefined */
>
> Is there anything wrong with :34?
Nothing wrong with :34.
> With these cosmetic issues addressed (which I guess I'll take the
> liberty of doing while committing)
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
Thanks!
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2017-04-07 14:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-07 10:17 [PATCH v3] x86/monitor: add support for descriptor access events Adrian Pop
2017-04-07 13:18 ` Jan Beulich
2017-04-07 13:38 ` Adrian Pop [this message]
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=20170407133803.GA26163@hel \
--to=apop@bitdefender.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=ian.jackson@eu.citrix.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 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.