All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <daniel.kiper@oracle.com>
To: Juergen Gross <jgross@suse.com>
Cc: grub-devel@gnu.org, xen-devel@lists.xen.org, phcoder@gmail.com,
	roger.pau@citrix.com, hans@knorrie.org
Subject: Re: [PATCH v5 11/20] xen: setup hypercall page for PVH
Date: Wed, 28 Nov 2018 12:28:08 +0100	[thread overview]
Message-ID: <20181128112808.uikn75y2rmcoqma6@tomti.i.net-space.pl> (raw)
In-Reply-To: <20181127203110.bcti52xm2jnqux5k@tomti.i.net-space.pl>

On Tue, Nov 27, 2018 at 09:31:10PM +0100, Daniel Kiper wrote:
> On Wed, Nov 21, 2018 at 03:28:46PM +0100, Juergen Gross wrote:
> > Add the needed code to setup the hypercall page for calling into the
> > Xen hypervisor.
> >
> > Import the XEN_HVM_DEBUGCONS_IOPORT define from Xen unstable into
> > include/xen/arch-x86/xen.h
> >
> > Signed-off-by: Juergen Gross <jgross@suse.com>

[...]

> > +int
> > +grub_xen_hypercall (grub_uint32_t callno, grub_uint32_t a0,
> > +		    grub_uint32_t a1, grub_uint32_t a2,
> > +		    grub_uint32_t a3, grub_uint32_t a4,
> > +		    grub_uint32_t a5 __attribute__ ((unused)))
> > +{
> > +  grub_uint32_t __res, dummy;
> > +
> > +  asm volatile ("call *%[callno]"
> > +		: "=a" (__res), "=b" (dummy), "=c" (dummy), "=d" (dummy),
> > +		  "=S" (dummy), "=D" (dummy)
> > +		: "1" (a0), "2" (a1), "3" (a2), "4" (a3), "5" (a4),
> > +		  [callno] "a" (&hypercall_page[callno * 32])
> > +		: "memory");
>
> Have you tried "+b", "+c", ... instead of "=b", "=c", ...?

I have done some experiments. Your code:

  grub_uint32_t __res, dummy;

  asm volatile ("call *%[callno]"
                : "=a" (__res), "=b" (dummy), "=c" (dummy), "=d" (dummy),
                  "=S" (dummy), "=D" (dummy)
                : "1" (a0), "2" (a1), "3" (a2), "4" (a3), "5" (a4),
                  [callno] "a" (&hypercall_page[callno * 32])
                : "memory");

... generates this assembly:

0000048e <grub_xen_hypercall>:
 48e:   55                      push   %ebp
 48f:   89 e5                   mov    %esp,%ebp
 491:   57                      push   %edi
 492:   56                      push   %esi
 493:   53                      push   %ebx
 494:   c1 e0 05                shl    $0x5,%eax
 497:   05 00 10 00 00          add    $0x1000,%eax
 49c:   89 d3                   mov    %edx,%ebx
 49e:   8b 55 08                mov    0x8(%ebp),%edx
 4a1:   8b 75 0c                mov    0xc(%ebp),%esi
 4a4:   8b 7d 10                mov    0x10(%ebp),%edi
 4a7:   ff d0                   call   *%eax
 4a9:   5b                      pop    %ebx
 4aa:   5e                      pop    %esi
 4ab:   5f                      pop    %edi
 4ac:   5d                      pop    %ebp
 4ad:   c2 10 00                ret    $0x10

Mine code:

  grub_uint32_t __res;

  asm volatile ("call *%[callno]"
                : "=a" (__res), "+b" (a0), "+c" (a1), "+d" (a2), "+S" (a3), "+D" (a4)
                : [callno] "rm" (&hypercall_page[callno * 32])
                : "memory");

... generates this assembly:

0000048e <grub_xen_hypercall>:
 48e:   55                      push   %ebp
 48f:   89 e5                   mov    %esp,%ebp
 491:   57                      push   %edi
 492:   56                      push   %esi
 493:   53                      push   %ebx
 494:   c1 e0 05                shl    $0x5,%eax
 497:   05 00 10 00 00          add    $0x1000,%eax
 49c:   89 d3                   mov    %edx,%ebx
 49e:   8b 55 08                mov    0x8(%ebp),%edx
 4a1:   8b 75 0c                mov    0xc(%ebp),%esi
 4a4:   8b 7d 10                mov    0x10(%ebp),%edi
 4a7:   ff d0                   call   *%eax
 4a9:   5b                      pop    %ebx
 4aa:   5e                      pop    %esi
 4ab:   5f                      pop    %edi
 4ac:   5d                      pop    %ebp
 4ad:   c2 10 00                ret    $0x10

So, both are equal but mine seems a bit simpler.

And I think that you can drop "__" from __res variable.

Daniel


  parent reply	other threads:[~2018-11-28 11:28 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 14:28 [PATCH v5 00/20] xen: add pvh guest support Juergen Gross
2018-11-21 14:28 ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 01/20] xen: add some xen headers Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-28 11:31   ` Daniel Kiper
2018-11-28 11:31     ` Daniel Kiper
2018-11-28 11:46     ` Juergen Gross
2018-11-28 11:46     ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 02/20] loader/linux: support passing rsdp address via boot params Juergen Gross
2018-11-21 14:28 ` Juergen Gross
2018-11-27 19:52   ` Daniel Kiper
2018-11-27 19:52   ` Daniel Kiper
2018-11-21 14:28 ` [PATCH v5 03/20] xen: carve out grant tab initialization into dedicated function Juergen Gross
2018-11-21 14:28 ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 04/20] xen: prepare common code for Xen PVH support Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 05/20] xen: add some dummy headers for PVH mode Juergen Gross
2018-11-21 14:28 ` Juergen Gross
2018-11-27 19:59   ` Daniel Kiper
2018-11-27 19:59   ` Daniel Kiper
2018-11-21 14:28 ` [PATCH v5 06/20] xen: rearrange xen/init.c to prepare it for Xen " Juergen Gross
2018-11-21 14:28 ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 07/20] xen: modify grub_xen_ptr2mfn() for xen-pvh Juergen Gross
2018-11-27 20:02   ` Daniel Kiper
2018-11-27 20:02   ` Daniel Kiper
2018-11-21 14:28 ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 08/20] xen: add PVH specific defines to offset.h Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 09/20] xen: add basic hooks for PVH in current code Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-27 20:10   ` Daniel Kiper
2018-11-27 20:10   ` Daniel Kiper
2018-11-21 14:28 ` [PATCH v5 10/20] xen: add PVH boot entry code Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 11/20] xen: setup hypercall page for PVH Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-23 15:14   ` Roger Pau Monné
2018-11-23 15:14   ` Roger Pau Monné
2018-11-27 20:31   ` Daniel Kiper
2018-11-27 20:31     ` Daniel Kiper
2018-11-28 11:28     ` Daniel Kiper
2018-11-28 11:28     ` Daniel Kiper [this message]
2018-11-28 11:44       ` Juergen Gross
2018-11-28 11:44       ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 12/20] xen: get memory map from hypervisor " Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 13/20] xen: setup Xen specific data " Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-23 15:04   ` Roger Pau Monné
2018-11-23 15:04     ` Roger Pau Monné
2018-11-27 21:10   ` Daniel Kiper
2018-11-27 21:10     ` Daniel Kiper
2018-11-21 14:28 ` [PATCH v5 14/20] xen: init memory regions " Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 15/20] xen_pvh: add build runes for grub-core Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-27 21:17   ` Daniel Kiper
2018-11-27 21:17     ` Daniel Kiper
2018-11-28 11:52     ` Juergen Gross
2018-11-28 11:52     ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 16/20] grub-module-verifier: Ignore all_video for xenpvh Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 17/20] xen: use elfnote defines instead of plain numbers Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 18/20] xen_pvh: support building a standalone image Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 19/20] xen_pvh: support grub-install for xen_pvh Juergen Gross
2018-11-21 14:28   ` Juergen Gross
2018-11-21 14:28 ` [PATCH v5 20/20] xen_pvh: add support to configure Juergen Gross
2018-11-21 14:28   ` Juergen Gross

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=20181128112808.uikn75y2rmcoqma6@tomti.i.net-space.pl \
    --to=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=hans@knorrie.org \
    --cc=jgross@suse.com \
    --cc=phcoder@gmail.com \
    --cc=roger.pau@citrix.com \
    --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 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.