xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: "Slutz, Donald Christopher" <dslutz@verizon.com>
Cc: Tim Deegan <tim@xen.org>, Kevin Tian <kevin.tian@intel.com>,
	Keir Fraser <keir@xen.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Eddie Dong <eddie.dong@intel.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH v4 04/16] xen: Add is_vmware_port_enabled
Date: Wed, 17 Sep 2014 11:56:41 -0400	[thread overview]
Message-ID: <5419AF39.70403@oracle.com> (raw)
In-Reply-To: <A3CD31A5D207064088A18AC2AF7B5DC6B90012B3@MIA20725MBX891B.apps.tmrk.corp>


On 09/16/2014 08:08 AM, Slutz, Donald Christopher wrote:
> On 09/12/14 09:08, Boris Ostrovsky wrote:
>> On 09/11/2014 02:36 PM, Don Slutz wrote:
>>>    int __get_instruction_length_from_list(struct vcpu *v,
>>> -        const enum instruction_index *list, unsigned int list_count)
>>> +                                       const enum instruction_index
>>> *list,
>>> +                                       unsigned int list_count,
>>> +                                       bool_t err_rpt)
>>>    {
>>>        struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
>>>        unsigned int i, j, inst_len = 0;
>>> @@ -211,10 +222,13 @@ int __get_instruction_length_from_list(struct
>>> vcpu *v,
>>>        mismatch: ;
>>>        }
>>>    -    gdprintk(XENLOG_WARNING,
>>> -             "%s: Mismatch between expected and actual instruction
>>> bytes: "
>>> -             "eip = %lx\n",  __func__, (unsigned long)vmcb->rip);
>>> -    hvm_inject_hw_exception(TRAP_gp_fault, 0);
>>> +    if ( err_rpt )
>>> +    {
>>> +        gdprintk(XENLOG_WARNING,
>>> +                 "%s: Mismatch between expected and actual
>>> instruction bytes: "
>>> +                 "eip = %lx\n",  __func__, (unsigned long)vmcb->rip);
>>> +        hvm_inject_hw_exception(TRAP_gp_fault, 0);
>>> +    }
>>>        return 0;
>>>       done:
>>> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
>>> index b5188e6..9e14d2a 100644
>>> --- a/xen/arch/x86/hvm/svm/svm.c
>>> +++ b/xen/arch/x86/hvm/svm/svm.c
>>> @@ -59,6 +59,7 @@
>>>    #include <public/sched.h>
>>>    #include <asm/hvm/vpt.h>
>>>    #include <asm/hvm/trace.h>
>>> +#include <asm/hvm/vmport.h>
>>>    #include <asm/hap.h>
>>>    #include <asm/apic.h>
>>>    #include <asm/debugger.h>
>>> @@ -2065,6 +2066,38 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
>>>        return;
>>>    }
>>>    +static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs,
>>> +                                    struct vcpu *v)
>>> +{
>>> +    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
>>> +    unsigned long inst_len;
>>> +    unsigned long inst_addr = svm_rip2pointer(v);
>>> +    int rc;
>>> +    static const enum instruction_index list[] = {
>>> +        INSTR_INL_DX, INSTR_INB_DX, INSTR_OUTL_DX, INSTR_OUTB_DX
>>> +    };
>>> +
>>> +    inst_len = __get_instruction_length_from_list(
>>> +        v, list, ARRAY_SIZE(list), 0);
>> I should have asked earlier but I don't think I understand why the
>> last argument here is 0 (and therefore why you have this last argument
>> at all).
>>
>> Because whether or not you are warning in
>> __get_instruction_length_from_list() it will still return 0. And that,
>> in turn, will cause vmport_gp_check() to return an error. And then you
>> will print another warning in VMPORT_LOG. So there is a warning anyway.
>>
> A key part that you appear to have missed is that
> __get_instruction_length_from_list() uses gdprintk(XENLOG_WARNING,...
> but VMPORT_DBG_LOG is only available in debug=y builds.  So the new
> last argument is used to control this.  Since this change includes
> enabling #GP vmexits, it is now possible for ring 3 users to generate at
> large volume of these which with gdprintk() can flood the console.

Would it be possible to decide where and whether to print the warning 
inside __get_instruction_length_from_list() as opposed to passing a new 
parameter? E.g. if vmware_port_enabled is set and list includes IN/OUT 
and possibly something else?

-boris

>
>
>> Second, since this handler appears to be handling #GP only for VMware
>> guest we should make sure that it is not executed for any other guest.
>> You do now condition intercept got #GP for such guests only but I
>> still think having a check here is worth doing. Maybe a BUG() or
>> ASSERT()?
>>
>> The same comments are applicable to VMX code, I suspect.
>>
> I will change the check in vmport_gp_check on is_vmware_port_enabled
> into an ASSERT() so both SVM and VMX will be covered.
>
>>> +
>>> +    rc = vmport_gp_check(regs, v, inst_len, inst_addr,
>>> +                         vmcb->exitinfo1, vmcb->exitinfo2);
>>> +    if ( !rc )
>>> +        __update_guest_eip(regs, inst_len);
>>> +    else
>>> +    {
>>> +        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
>>> +                       "gp: rc=%d ei1=0x%lx ei2=0x%lx ip=%"PRIx64
>>> +                       " (0x%lx,%ld) ax=%"PRIx64" bx=%"PRIx64"
>>> cx=%"PRIx64
>>> +                       " dx=%"PRIx64" si=%"PRIx64" di=%"PRIx64, rc,
>>> +                       (unsigned long)vmcb->exitinfo1,
>>> +                       (unsigned long)vmcb->exitinfo2, regs->rip,
>>> inst_addr,
>>> +                       inst_len, regs->rax, regs->rbx, regs->rcx,
>>> regs->rdx,
>>> +                       regs->rsi, regs->rdi);
>>> +        hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
>>> +    }
>>> +}
>>> +
>> .

  reply	other threads:[~2014-09-17 15:56 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 18:36 [PATCH v4 00/16] Xen VMware tools support Don Slutz
2014-09-11 18:36 ` [PATCH v4 01/16] xen: Add support for VMware cpuid leaves Don Slutz
2014-09-11 19:49   ` Andrew Cooper
2014-09-12  9:49     ` Jan Beulich
2014-09-12 17:46       ` Don Slutz
2014-09-15  7:42         ` Jan Beulich
2014-09-17 15:41           ` Don Slutz
2014-09-12 21:26     ` Don Slutz
2014-09-12 12:37   ` Boris Ostrovsky
2014-09-12 17:50     ` Don Slutz
2014-09-11 18:36 ` [PATCH v4 02/16] tools: Add vmware_hw support Don Slutz
2014-09-11 21:09   ` Andrew Cooper
2014-09-16 16:20     ` Don Slutz
2014-09-11 18:36 ` [PATCH v4 03/16] vmware: Add VMware provided include files Don Slutz
2014-09-11 18:36 ` [PATCH v4 04/16] xen: Add is_vmware_port_enabled Don Slutz
2014-09-11 21:22   ` Andrew Cooper
2014-09-16 16:20     ` Don Slutz
2014-09-12 13:08   ` Boris Ostrovsky
2014-09-16 12:08     ` Slutz, Donald Christopher
2014-09-17 15:56       ` Boris Ostrovsky [this message]
2014-09-17 18:23         ` Slutz, Donald Christopher
2014-09-18  9:14           ` Jan Beulich
2014-09-19 12:48             ` Slutz, Donald Christopher
2014-09-18 22:53           ` Boris Ostrovsky
2014-09-19 13:24             ` Slutz, Donald Christopher
2014-09-19 15:50               ` Boris Ostrovsky
2014-09-19 17:00                 ` Slutz, Donald Christopher
2014-09-11 18:36 ` [PATCH v4 05/16] tools: Add vmware_port support Don Slutz
2014-09-11 18:36 ` [PATCH v4 06/16] xen: Convert vmware_port to xentrace usage Don Slutz
2014-09-12 13:10   ` Boris Ostrovsky
2014-09-12 23:57     ` Don Slutz
2014-09-11 18:36 ` [PATCH v4 07/16] tools: " Don Slutz
2014-09-12 13:15   ` Boris Ostrovsky
2014-09-13  0:01     ` Don Slutz
2014-09-11 18:36 ` [PATCH v4 08/16] xen: Add limited support of VMware's hyper-call rpc Don Slutz
2014-09-12 13:37   ` Boris Ostrovsky
2014-09-12 14:27     ` Jan Beulich
2014-09-16 12:38       ` Slutz, Donald Christopher
2014-09-16 12:46         ` Jan Beulich
2014-09-16 13:47           ` Slutz, Donald Christopher
2014-09-16 13:17     ` Slutz, Donald Christopher
2014-09-11 18:36 ` [PATCH v4 09/16] tools: " Don Slutz
2014-09-11 18:36 ` [PATCH v4 10/16] Add VMware tool's triggers Don Slutz
2014-09-11 18:36 ` [PATCH v4 11/16] Add live migration of VMware's hyper-call RPC Don Slutz
2014-09-12 13:54   ` Boris Ostrovsky
2014-09-16 15:48     ` Don Slutz
2014-09-11 18:36 ` [PATCH v4 12/16] Add dump of HVM_SAVE_CODE(VMPORT) to xen-hvmctx Don Slutz
2014-09-11 18:36 ` [PATCH v4 13/16] Add xen-hvm-param Don Slutz
2014-09-11 18:36 ` [PATCH v4 14/16] Add xen-vmware-guestinfo Don Slutz
2014-09-11 18:36 ` [PATCH v4 15/16] Add xen-list-vmware-guestinfo Don Slutz
2014-09-11 18:36 ` [PATCH v4 16/16] Add xen-hvm-send-trigger Don Slutz

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=5419AF39.70403@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=Aravind.Gopalakrishnan@amd.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dslutz@verizon.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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).