All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Stefano Stabellini <Stefano.Stabellini@citrix.com>,
	"Slutz, Donald Christopher" <dslutz@verizon.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"Marcel Apfelbaum" <marcel.a@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Michael S.\	Tsirkin" <mst@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access	to vmport
Date: Wed, 1 Oct 2014 15:08:03 +0000	[thread overview]
Message-ID: <9AAE0902D5BC7E449B7C8E4E778ABCD0110EF6B2@AMSPEX01CL01.citrite.net> (raw)
In-Reply-To: <alpine.DEB.2.02.1410011011030.17038@kaball.uk.xensource.com>

> -----Original Message-----
> From: qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org
> [mailto:qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org] On
> Behalf Of Stefano Stabellini
> Sent: 01 October 2014 10:20
> To: Slutz, Donald Christopher
> Cc: xen-devel@lists.xensource.com; Stefano Stabellini; Markus Armbruster;
> Marcel Apfelbaum; Alexander Graf; qemu-devel@nongnu.org; Michael S.
> Tsirkin; Anthony Liguori; Andreas Färber
> Subject: Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen
> access to vmport
> 
> On Wed, 1 Oct 2014, Slutz, Donald Christopher wrote:
> > On 09/30/14 06:35, Stefano Stabellini wrote:
> > > On Mon, 29 Sep 2014, Don Slutz wrote:
> > >> On 09/29/14 06:25, Stefano Stabellini wrote:
> > >>> On Mon, 29 Sep 2014, Stefano Stabellini wrote:
> > >>>> On Fri, 26 Sep 2014, Don Slutz wrote:
> > >>>>> This adds synchronisation of the vcpu registers
> > >>>>> between Xen and QEMU.
> > >>>>>
> > >>>>> Signed-off-by: Don Slutz <dslutz@verizon.com>
> > >>>> [...]
> > >>>>
> > >>>>> diff --git a/xen-hvm.c b/xen-hvm.c
> > >>>>> index 05e522c..e1274bb 100644
> > >>>>> --- a/xen-hvm.c
> > >>>>> +++ b/xen-hvm.c
> > >>>>> @@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void
> *opaque)
> > >>>>>          handle_buffered_iopage(state);
> > >>>>>        if (req) {
> > >>>>> +#ifdef IOREQ_TYPE_VMWARE_PORT
> > >>>> Is there any reason to #ifdef this code?
> > >>>> Couldn't we just always build it in QEMU?
> > >> This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5
> > >> or earlier installed; and work.
> > > I would rather remove the #ifdef from here and add any necessary
> > > compatibility stuff to include/hw/xen/xen_common.h.
> > >
> >
> > Ok, will do.
> >
> > >>>>> +        if (req->type == IOREQ_TYPE_VMWARE_PORT) {
> > >>>> I think it would make more sense to check for
> IOREQ_TYPE_VMWARE_PORT
> > >>>> from within handle_ioreq.
> > >>>>
> > >> Ok, I can move it.
> > >>
> > >>
> > >>>>> +            CPUX86State *env;
> > >>>>> +            ioreq_t fake_req = {
> > >>>>> +                .type = IOREQ_TYPE_PIO,
> > >>>>> +                .addr = (uint16_t)req->size,
> > >>>>> +                .size = 4,
> > >>>>> +                .dir = IOREQ_READ,
> > >>>>> +                .df = 0,
> > >>>>> +                .data_is_ptr = 0,
> > >>>>> +            };
> > >>> Why do you need a fake req?
> > >> To transport the 6 VCPU registers (only 32bits of them) that vmport.c
> > >> needs to do it's work.
> > >>
> > >>> Couldn't Xen send the real req instead?
> > >> Yes, but then a 2nd exchange between QEMU and Xen would be
> needed
> > >> to fetch the 6 VCPU registers.  The ways I know of to fetch the VCPU
> registers
> > >> from Xen, all need many cycles to do their work and return
> > >> a lot of data that is not needed.
> > >>
> > >> The other option that I have considered was to extend the ioreq_t type
> > >> to have room for these registers, but that reduces by almost half the
> > >> maximum number of VCPUs that are supported (They all live on 1 page).
> > > Urgh. Now that I understand the patch better is think it's horrible, no
> > > offense :-)
> >
> > None taken.
> >
> > > Why don't you add another new ioreq type to send out the vcpu state?
> > > Something like IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to
> QEMU
> > > before IOREQ_TYPE_VMWARE_PORT. Actually this solution looks very
> imilar
> > > to Alex's suggestion.
> > >
> >
> > I can, it is just slower.  This would require 2 new types.  1 for regs to
> > QEMU, 1 for regs from QEMU.  So instead of 1 round trip (Xen to QEMU
> > to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to
> > QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
> 
> This is not an high performance device, is it?
> 
> In any case I agree it would be better to avoid it.
> I wonder if we could send both ioreqs at once from Xen and back from
> QEMU. Or maybe append the registers to IOREQ_TYPE_VMWARE_PORT,
> changing
> the size of ioreq_t only for this ioreq type.
> Another maybe simpler possibility would be introducing a union in
> ioreq_t with the registers.
> Anything would be OK for me but I would like to see the registers being
> passes explicitely by Xen rather than "hiding" them into other ioreq
> fields.
> 

Changing the size of ioreq_t would be a bit of a nightmare: The structs are laid out in an array indexed by vcpu and shared by QEMU and Xen.

  Paul

> 
> > >>>    If any case you should spend a
> > >>> few more words on why you are doing this.
> > >>>
> > >> Sure.  Will add some form of the above as part of the commit message.
> > >>
> > >>>>> +            if (!xen_opaque_env) {
> > >>>>> +                xen_opaque_env = g_malloc(sizeof(CPUX86State));
> > >>>>> +            }
> > >>>>> +            env = xen_opaque_env;
> > >>>>> +            env->regs[R_EAX] = (uint32_t)(req->addr >> 32);
> > >>>>> +            env->regs[R_EBX] = (uint32_t)(req->addr);
> > >>>>> +            env->regs[R_ECX] = req->count;
> > >>>>> +            env->regs[R_EDX] = req->size;
> > >>>>> +            env->regs[R_ESI] = (uint32_t)(req->data >> 32);
> > >>>>> +            env->regs[R_EDI] = (uint32_t)(req->data);
> > >>>>> +            handle_ioreq(&fake_req);
> > >>>>> +            req->addr = ((uint64_t)fake_req.data << 32) |
> > >>>>> +                (uint32_t)env->regs[R_EBX];
> > >>>>> +            req->count = env->regs[R_ECX];
> > >>>>> +            req->size = env->regs[R_EDX];
> > >>>>> +            req->data = ((uint64_t)env->regs[R_ESI] << 32) |
> > >>>>> +                (uint32_t)env->regs[R_EDI];
> > >>>> This code could be moved to a separate helper function called by
> > >>>> handle_ioreq.
> > >>>>
> > >> Ok.
> > >>
> > >>     -Don Slutz
> > >>
> > >>>>> +        } else {
> > >>>>> +            handle_ioreq(req);
> > >>>>> +        }
> > >>>>> +#else
> > >>>>>            handle_ioreq(req);
> > >>>>> +#endif
> >

WARNING: multiple messages have this Message-ID (diff)
From: Paul Durrant <Paul.Durrant@citrix.com>
To: "Slutz, Donald Christopher" <dslutz@verizon.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"Marcel Apfelbaum" <marcel.a@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Michael S.\	Tsirkin" <mst@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Stefano Stabellini" <Stefano.Stabellini@citrix.com>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [PATCH 1/1] xen-hvm.c: Add support for Xen access	to vmport
Date: Wed, 1 Oct 2014 15:08:03 +0000	[thread overview]
Message-ID: <9AAE0902D5BC7E449B7C8E4E778ABCD0110EF6B2@AMSPEX01CL01.citrite.net> (raw)
In-Reply-To: <alpine.DEB.2.02.1410011011030.17038@kaball.uk.xensource.com>

> -----Original Message-----
> From: qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org
> [mailto:qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org] On
> Behalf Of Stefano Stabellini
> Sent: 01 October 2014 10:20
> To: Slutz, Donald Christopher
> Cc: xen-devel@lists.xensource.com; Stefano Stabellini; Markus Armbruster;
> Marcel Apfelbaum; Alexander Graf; qemu-devel@nongnu.org; Michael S.
> Tsirkin; Anthony Liguori; Andreas Färber
> Subject: Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen
> access to vmport
> 
> On Wed, 1 Oct 2014, Slutz, Donald Christopher wrote:
> > On 09/30/14 06:35, Stefano Stabellini wrote:
> > > On Mon, 29 Sep 2014, Don Slutz wrote:
> > >> On 09/29/14 06:25, Stefano Stabellini wrote:
> > >>> On Mon, 29 Sep 2014, Stefano Stabellini wrote:
> > >>>> On Fri, 26 Sep 2014, Don Slutz wrote:
> > >>>>> This adds synchronisation of the vcpu registers
> > >>>>> between Xen and QEMU.
> > >>>>>
> > >>>>> Signed-off-by: Don Slutz <dslutz@verizon.com>
> > >>>> [...]
> > >>>>
> > >>>>> diff --git a/xen-hvm.c b/xen-hvm.c
> > >>>>> index 05e522c..e1274bb 100644
> > >>>>> --- a/xen-hvm.c
> > >>>>> +++ b/xen-hvm.c
> > >>>>> @@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void
> *opaque)
> > >>>>>          handle_buffered_iopage(state);
> > >>>>>        if (req) {
> > >>>>> +#ifdef IOREQ_TYPE_VMWARE_PORT
> > >>>> Is there any reason to #ifdef this code?
> > >>>> Couldn't we just always build it in QEMU?
> > >> This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5
> > >> or earlier installed; and work.
> > > I would rather remove the #ifdef from here and add any necessary
> > > compatibility stuff to include/hw/xen/xen_common.h.
> > >
> >
> > Ok, will do.
> >
> > >>>>> +        if (req->type == IOREQ_TYPE_VMWARE_PORT) {
> > >>>> I think it would make more sense to check for
> IOREQ_TYPE_VMWARE_PORT
> > >>>> from within handle_ioreq.
> > >>>>
> > >> Ok, I can move it.
> > >>
> > >>
> > >>>>> +            CPUX86State *env;
> > >>>>> +            ioreq_t fake_req = {
> > >>>>> +                .type = IOREQ_TYPE_PIO,
> > >>>>> +                .addr = (uint16_t)req->size,
> > >>>>> +                .size = 4,
> > >>>>> +                .dir = IOREQ_READ,
> > >>>>> +                .df = 0,
> > >>>>> +                .data_is_ptr = 0,
> > >>>>> +            };
> > >>> Why do you need a fake req?
> > >> To transport the 6 VCPU registers (only 32bits of them) that vmport.c
> > >> needs to do it's work.
> > >>
> > >>> Couldn't Xen send the real req instead?
> > >> Yes, but then a 2nd exchange between QEMU and Xen would be
> needed
> > >> to fetch the 6 VCPU registers.  The ways I know of to fetch the VCPU
> registers
> > >> from Xen, all need many cycles to do their work and return
> > >> a lot of data that is not needed.
> > >>
> > >> The other option that I have considered was to extend the ioreq_t type
> > >> to have room for these registers, but that reduces by almost half the
> > >> maximum number of VCPUs that are supported (They all live on 1 page).
> > > Urgh. Now that I understand the patch better is think it's horrible, no
> > > offense :-)
> >
> > None taken.
> >
> > > Why don't you add another new ioreq type to send out the vcpu state?
> > > Something like IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to
> QEMU
> > > before IOREQ_TYPE_VMWARE_PORT. Actually this solution looks very
> imilar
> > > to Alex's suggestion.
> > >
> >
> > I can, it is just slower.  This would require 2 new types.  1 for regs to
> > QEMU, 1 for regs from QEMU.  So instead of 1 round trip (Xen to QEMU
> > to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to
> > QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
> 
> This is not an high performance device, is it?
> 
> In any case I agree it would be better to avoid it.
> I wonder if we could send both ioreqs at once from Xen and back from
> QEMU. Or maybe append the registers to IOREQ_TYPE_VMWARE_PORT,
> changing
> the size of ioreq_t only for this ioreq type.
> Another maybe simpler possibility would be introducing a union in
> ioreq_t with the registers.
> Anything would be OK for me but I would like to see the registers being
> passes explicitely by Xen rather than "hiding" them into other ioreq
> fields.
> 

Changing the size of ioreq_t would be a bit of a nightmare: The structs are laid out in an array indexed by vcpu and shared by QEMU and Xen.

  Paul

> 
> > >>>    If any case you should spend a
> > >>> few more words on why you are doing this.
> > >>>
> > >> Sure.  Will add some form of the above as part of the commit message.
> > >>
> > >>>>> +            if (!xen_opaque_env) {
> > >>>>> +                xen_opaque_env = g_malloc(sizeof(CPUX86State));
> > >>>>> +            }
> > >>>>> +            env = xen_opaque_env;
> > >>>>> +            env->regs[R_EAX] = (uint32_t)(req->addr >> 32);
> > >>>>> +            env->regs[R_EBX] = (uint32_t)(req->addr);
> > >>>>> +            env->regs[R_ECX] = req->count;
> > >>>>> +            env->regs[R_EDX] = req->size;
> > >>>>> +            env->regs[R_ESI] = (uint32_t)(req->data >> 32);
> > >>>>> +            env->regs[R_EDI] = (uint32_t)(req->data);
> > >>>>> +            handle_ioreq(&fake_req);
> > >>>>> +            req->addr = ((uint64_t)fake_req.data << 32) |
> > >>>>> +                (uint32_t)env->regs[R_EBX];
> > >>>>> +            req->count = env->regs[R_ECX];
> > >>>>> +            req->size = env->regs[R_EDX];
> > >>>>> +            req->data = ((uint64_t)env->regs[R_ESI] << 32) |
> > >>>>> +                (uint32_t)env->regs[R_EDI];
> > >>>> This code could be moved to a separate helper function called by
> > >>>> handle_ioreq.
> > >>>>
> > >> Ok.
> > >>
> > >>     -Don Slutz
> > >>
> > >>>>> +        } else {
> > >>>>> +            handle_ioreq(req);
> > >>>>> +        }
> > >>>>> +#else
> > >>>>>            handle_ioreq(req);
> > >>>>> +#endif
> >

  parent reply	other threads:[~2014-10-01 15:08 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 18:47 [Qemu-devel] [PATCH 0/1] Add support for Xen access to vmport Don Slutz
2014-09-26 18:47 ` Don Slutz
2014-09-26 18:47 ` [Qemu-devel] [PATCH 1/1] xen-hvm.c: " Don Slutz
2014-09-26 18:47   ` Don Slutz
2014-09-29  8:12   ` [Qemu-devel] " Alexander Graf
2014-09-29  8:12     ` Alexander Graf
2014-09-29 11:10     ` [Qemu-devel] " Paolo Bonzini
2014-09-29 11:10       ` Paolo Bonzini
2014-09-29 11:53       ` [Qemu-devel] " Alexander Graf
2014-09-29 11:53         ` Alexander Graf
2014-09-29 12:21         ` [Qemu-devel] " Paolo Bonzini
2014-09-29 12:21           ` Paolo Bonzini
2014-09-29 12:57           ` [Qemu-devel] " Alexander Graf
2014-09-29 12:57             ` Alexander Graf
2014-09-29 13:14             ` [Qemu-devel] " Paolo Bonzini
2014-09-29 13:14               ` Paolo Bonzini
2014-09-30  1:05               ` [Qemu-devel] " Don Slutz
2014-09-30  1:05                 ` Don Slutz
2014-09-30  8:14                 ` [Qemu-devel] " Paolo Bonzini
2014-09-30  8:14                   ` Paolo Bonzini
2014-09-30  1:00         ` [Qemu-devel] " Don Slutz
2014-09-30  1:00           ` Don Slutz
2014-09-29 10:15   ` [Qemu-devel] " Stefano Stabellini
2014-09-29 10:15     ` Stefano Stabellini
2014-09-29 10:25     ` [Qemu-devel] " Stefano Stabellini
2014-09-29 10:25       ` Stefano Stabellini
2014-09-30  0:32       ` [Qemu-devel] " Don Slutz
2014-09-30  0:32         ` Don Slutz
2014-09-30 10:35         ` [Qemu-devel] " Stefano Stabellini
2014-09-30 10:35           ` Stefano Stabellini
2014-10-01  5:21           ` [Qemu-devel] " Slutz, Donald Christopher
2014-10-01  5:21             ` Slutz, Donald Christopher
2014-10-01  9:20             ` [Qemu-devel] " Stefano Stabellini
2014-10-01  9:20               ` Stefano Stabellini
2014-10-01 12:33               ` [Qemu-devel] " Don Slutz
2014-10-01 12:33                 ` Don Slutz
2014-10-01 14:44               ` [Qemu-devel] [Xen-devel] " Ian Campbell
2014-10-01 14:44                 ` Ian Campbell
2014-10-01 16:01                 ` [Qemu-devel] " Anthony Liguori
2014-10-01 16:01                   ` Anthony Liguori
2014-10-01 15:08               ` Paul Durrant [this message]
2014-10-01 15:08                 ` Paul Durrant

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=9AAE0902D5BC7E449B7C8E4E778ABCD0110EF6B2@AMSPEX01CL01.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Stefano.Stabellini@citrix.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=dslutz@verizon.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xen-devel@lists.xensource.com \
    /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.