xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Andres Lagar-Cavilla" <andres@lagarcavilla.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "olaf@aepfle.de" <olaf@aepfle.de>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	"andres@gridcentric.ca" <andres@gridcentric.ca>,
	"Tim (Xen.org)" <tim@xen.org>,
	"keir.xen@gmail.com" <keir.xen@gmail.com>,
	"adin@gridcentric.ca" <adin@gridcentric.ca>
Subject: Re: [PATCH 1 of 7] Tools: Sanitize mem_event/access/paging interfaces
Date: Tue, 28 Feb 2012 07:14:43 -0800	[thread overview]
Message-ID: <d584802ff8deff07b8de3483b75aada7.squirrel@webmail.lagarcavilla.org> (raw)
In-Reply-To: <1330433794.31269.146.camel@zakaz.uk.xensource.com>

> On Thu, 2012-02-23 at 06:05 +0000, Andres Lagar-Cavilla wrote:
>> tools/libxc/xc_mem_access.c         |  10 ++++++++--
>>  tools/libxc/xc_mem_event.c          |  13 ++++++++-----
>>  tools/libxc/xc_mem_paging.c         |  10 ++++++++--
>>  tools/libxc/xenctrl.h               |   6 +++---
>>  tools/tests/xen-access/xen-access.c |  22 ++++------------------
>>  tools/xenpaging/xenpaging.c         |  18 +++---------------
>>  tools/xenpaging/xenpaging.h         |   2 +-
>>  xen/arch/x86/mm/mem_event.c         |  33
>> +++------------------------------
>>  xen/include/public/domctl.h         |   4 ++--
>>  xen/include/public/mem_event.h      |   4 ----
>>  xen/include/xen/sched.h             |   2 --
>>  11 files changed, 40 insertions(+), 84 deletions(-)
>>
>>
>> Don't use the superfluous shared page, return the event channel directly
>> as
>> part of the domctl struct, instead.
>>
>> In-tree consumers (xenpaging, xen-access) updated. This is an ABI/API
>> change,
>> so please voice any concerns.
>>
>> Known pending issues:
>> - pager could die and its ring page could be used by some other process,
>> yet
>>   Xen retains the mapping to it.
>> - use a saner interface for the paging_load buffer.
>>
>> This change also affects the x86/mm bits in the hypervisor that process
>> the
>> mem_event setup domctl.
>>
>> Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
>>
>> diff -r 8ddd13cc783e -r 3b24188d8815 tools/libxc/xc_mem_access.c
>> --- a/tools/libxc/xc_mem_access.c
>> +++ b/tools/libxc/xc_mem_access.c
>> @@ -25,12 +25,18 @@
>>
>>
>>  int xc_mem_access_enable(xc_interface *xch, domid_t domain_id,
>> -                        void *shared_page, void *ring_page)
>> +                         uint32_t *port, void *ring_page)
>>  {
>> +    if ( !port )
>> +    {
>> +        errno = -EINVAL;
>
> Aren't errno vals normally +ve?
>
> Is there any situation where port==NULL would be valid, i.e. any chance
> that this might happen, or are such callers just buggy?

Definitely, it should be errno = EINVAL. I'll fix this in this patch and
the sharing ring one.
>
>> +        return -1;
>> +    }
>
>> +
>>      return xc_mem_event_control(xch, domain_id,
>>                                  XEN_DOMCTL_MEM_EVENT_OP_ACCESS_ENABLE,
>>                                  XEN_DOMCTL_MEM_EVENT_OP_ACCESS,
>> -                                shared_page, ring_page);
>> +                                port, ring_page);
>>  }
>>
>>  int xc_mem_access_disable(xc_interface *xch, domid_t domain_id)
>> diff -r 8ddd13cc783e -r 3b24188d8815 tools/libxc/xc_mem_event.c
>> --- a/tools/libxc/xc_mem_event.c
>> +++ b/tools/libxc/xc_mem_event.c
>> @@ -24,19 +24,22 @@
>>  #include "xc_private.h"
>>
>>  int xc_mem_event_control(xc_interface *xch, domid_t domain_id, unsigned
>> int op,
>> -                         unsigned int mode, void *page, void
>> *ring_page)
>> +                         unsigned int mode, uint32_t *port, void
>> *ring_page)
>>  {
>>      DECLARE_DOMCTL;
>> +    int rc;
>>
>>      domctl.cmd = XEN_DOMCTL_mem_event_op;
>>      domctl.domain = domain_id;
>>      domctl.u.mem_event_op.op = op;
>>      domctl.u.mem_event_op.mode = mode;
>> -
>> -    domctl.u.mem_event_op.shared_addr = (unsigned long)page;
>> -    domctl.u.mem_event_op.ring_addr = (unsigned long)ring_page;
>> +    domctl.u.mem_event_op.ring_addr = (unsigned long) ring_page;
>>
>> -    return do_domctl(xch, &domctl);
>> +    errno = 0;
>> +    rc = do_domctl(xch, &domctl);
>> +    if ( !rc && port )
>> +        *port = domctl.u.mem_event_op.port;
>> +    return rc;
>
> Clearing errno is an unusual pattern, normally callers only expect errno
> to contain a valid value on failure. Are you trying to provide some
> backwards compatibility with something or is there another reason for
> doing it this way?

I can remove that as well.
Thanks,
Andres
>
>>  }
>>
>>  int xc_mem_event_memop(xc_interface *xch, domid_t domain_id,
>> diff -r 8ddd13cc783e -r 3b24188d8815 tools/libxc/xc_mem_paging.c
>> --- a/tools/libxc/xc_mem_paging.c
>> +++ b/tools/libxc/xc_mem_paging.c
>> @@ -25,12 +25,18 @@
>>
>>
>>  int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id,
>> -                        void *shared_page, void *ring_page)
>> +                         uint32_t *port, void *ring_page)
>>  {
>> +    if ( !port )
>> +    {
>> +        errno = -EINVAL;
>
> Same comments as before.
>
>> +        return -1;
>> +    }
>> +
>>      return xc_mem_event_control(xch, domain_id,
>>                                  XEN_DOMCTL_MEM_EVENT_OP_PAGING_ENABLE,
>>                                  XEN_DOMCTL_MEM_EVENT_OP_PAGING,
>> -                                shared_page, ring_page);
>> +                                port, ring_page);
>>  }
>>
>
> Ian.
>
>
>

  reply	other threads:[~2012-02-28 15:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23  6:05 [PATCH 0 of 7] Mem event ring setup interface update Andres Lagar-Cavilla
2012-02-23  6:05 ` [PATCH 1 of 7] Tools: Sanitize mem_event/access/paging interfaces Andres Lagar-Cavilla
2012-02-23 14:29   ` Olaf Hering
2012-02-28 12:56   ` Ian Campbell
2012-02-28 15:14     ` Andres Lagar-Cavilla [this message]
2012-02-23  6:05 ` [PATCH 2 of 7] x86/hvm: refactor calls to prepare and tear down a helper ring Andres Lagar-Cavilla
2012-02-23  6:05 ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event rings Andres Lagar-Cavilla
2012-02-28 13:01   ` Ian Campbell
2012-02-28 15:19     ` Andres Lagar-Cavilla
2012-03-01  7:47       ` Ian Campbell
2012-03-01 15:17         ` Tim Deegan
2012-03-01 16:26           ` Andres Lagar-Cavilla
2012-03-01 16:30           ` Andres Lagar-Cavilla
2012-03-01 17:32             ` Tim Deegan
2012-03-01 17:44               ` Andres Lagar-Cavilla
2012-03-01 17:52                 ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event ringsg Tim Deegan
2012-03-06 19:27                   ` Andres Lagar-Cavilla
2012-03-01  2:29     ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event rings Andres Lagar-Cavilla
2012-02-23  6:05 ` [PATCH 4 of 7] x86/mm: wire up sharing ring Andres Lagar-Cavilla
2012-02-23  6:05 ` [PATCH 5 of 7] Tools: libxc side for setting up the mem " Andres Lagar-Cavilla
2012-02-28 13:02   ` Ian Campbell
2012-02-23  6:05 ` [PATCH 6 of 7] x86/mm: Clean up mem event structures on domain destruction Andres Lagar-Cavilla
2012-02-23 14:32   ` Olaf Hering
2012-02-23  6:05 ` [PATCH 7 of 7] x86/mm: Fix mem event error message typos Andres Lagar-Cavilla
2012-02-23 16:07 ` [PATCH 0 of 7] Mem event ring setup interface update Tim Deegan
2012-02-27 22:43   ` Andres Lagar-Cavilla
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01  2:43 [PATCH 0 of 7] Mem event ring interface setup update, V2 Andres Lagar-Cavilla
2012-03-01  2:43 ` [PATCH 1 of 7] Tools: Sanitize mem_event/access/paging interfaces Andres Lagar-Cavilla

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=d584802ff8deff07b8de3483b75aada7.squirrel@webmail.lagarcavilla.org \
    --to=andres@lagarcavilla.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=adin@gridcentric.ca \
    --cc=andres@gridcentric.ca \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir.xen@gmail.com \
    --cc=olaf@aepfle.de \
    --cc=tim@xen.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 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).