All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org,
	Ross Lagerwall <ross.lagerwall@citrix.com>,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v1 02/11] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op
Date: Fri, 13 Nov 2015 09:13:59 -0500	[thread overview]
Message-ID: <20151113141359.GA32204@char.us.oracle.com> (raw)
In-Reply-To: <5644CC4402000078000B4603@prv-mh.provo.novell.com>

On Thu, Nov 12, 2015 at 09:28:36AM -0700, Jan Beulich wrote:
> >>> On 03.11.15 at 19:15, <ross.lagerwall@citrix.com> wrote:
> > Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> > ---
> > v2: Rebased on keyhandler: rework keyhandler infrastructure
> > v3: Fixed XSM.
> > v4: Removed REVERTED state.
> >     Split status and error code.
> >     Add REPLACE action.
> >     Separate payload data from the payload structure.
> >     s/XSPLICE_ID_../XSPLICE_NAME_../
> 
> Odd - the subject says v1.
> 
> > --- /dev/null
> > +++ b/xen/common/xsplice.c
> > @@ -0,0 +1,398 @@
> > +/*
> > + * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
> > + *
> > + */
> > +
> > +#include <xen/smp.h>
> > +#include <xen/keyhandler.h>
> > +#include <xen/spinlock.h>
> > +#include <xen/mm.h>
> > +#include <xen/list.h>
> > +#include <xen/guest_access.h>
> > +#include <xen/stdbool.h>
> 
> No use of this header except in code shared with the tools.
> 
> Also I'd like to encourage you to sort all xen/ headers in a file
> (and all public/ and asm/ ones, just that this doesn't apply here)
> alphabetically in new code.

I tried sorting it. I couldn't build the file. And then I put
it on the 'TODO yak-shaving pile' and hadn't yet touched it.

There has to be some automatic tool to help with figuring the
header dependencies for all the headers, not just the ones
I am uisng.
Not exactly sure how to make all of the head
> 
> > +}
> > +
> > +
> > +static int verify_payload(xen_sysctl_xsplice_upload_t *upload)
> 
> Double blank line above.
> 
> > +/*
> > + * We MUST be holding the spinlock.
> > + */
> 
> Which spinlock? Also this is a single line comment.
> 
> > +static void __free_payload(struct payload *data)
> 
> I see no reason for this function to have two underscores at the
> beginning of its name.
> 
> 
> > +err_raw:
> > +    free_xenheap_pages(raw_data, get_order_from_bytes(upload->size));
> > +err_data:
> 
> Labels indented by at least one blank please.
> 
> > +static int xsplice_list(xen_sysctl_xsplice_list_t *list)
> > +{
> > +    xen_xsplice_status_t status;
> > +    struct payload *data;
> > +    unsigned int idx = 0, i = 0;
> > +    int rc = 0;
> > +    unsigned int ver = payload_version;
> > +
> > +    if ( list->nr > 1024 )
> > +        return -E2BIG;
> > +
> > +    if ( list->pad != 0 )
> > +        return -EINVAL;
> > +
> > +    if ( guest_handle_is_null(list->status) ||
> > +         guest_handle_is_null(list->id) ||
> > +         guest_handle_is_null(list->len) )
> > +        return -EINVAL;
> 
> ???
> 
> > +    if ( !guest_handle_okay(list->status, sizeof(status) * list->nr) ||
> > +         !guest_handle_okay(list->id, XEN_XSPLICE_NAME_SIZE * list->nr) ||
> > +         !guest_handle_okay(list->len, sizeof(uint32_t) * list->nr) )
> > +        return -EINVAL;
> > +
> > +    spin_lock(&payload_list_lock);
> > +    if ( list->idx > payload_cnt )
> > +    {
> > +        spin_unlock(&payload_list_lock);
> > +        return -EINVAL;
> > +    }
> > +
> > +    list_for_each_entry( data, &payload_list, list )
> > +    {
> > +        uint32_t len;
> > +
> > +        if ( list->idx > i++ )
> > +            continue;
> > +
> > +        status.state = data->state;
> > +        status.rc = data->rc;
> > +        len = strlen(data->id);
> > +
> > +        /* N.B. 'idx' != 'i'. */
> > +        if ( copy_to_guest_offset(list->id, idx * XEN_XSPLICE_NAME_SIZE,
> > +                                  data->id, len) ||
> > +             copy_to_guest_offset(list->len, idx, &len, 1) ||
> > +             copy_to_guest_offset(list->status, idx, &status, 1) )
> 
> You having used guest_handle_okay() above, all of these can be
> __copy_to_guest_offset)() afaict.
> 
> > +        {
> > +            rc = -EFAULT;
> > +            break;
> > +        }
> > +        idx ++;
> 
> Spurious blank.
> 
> > +        if ( hypercall_preempt_check() || (idx + 1 > list->nr) )
> > +        {
> > +            break;
> > +        }
> 
> Pointless braces.
> 
> Also - what about an input list->nr of zero?

Duh! Right.
> 
> > +    }
> > +    list->nr = payload_cnt - i; /* Remaining amount. */
> > +    spin_unlock(&payload_list_lock);
> > +    list->version = ver;
> > +
> > +    /* And how many we have processed. */
> > +    return rc ? rc : idx;
> 
> Please omit the middle expression in cases like this. To be honest I
> can't help myself thinking that I'v already made at least some of
> these comments.

You did. I hadn't had a chance to address them. Sorry about you
wasting your time and not addressing them in the code yet.

> 
> > --- a/xen/include/public/sysctl.h
> > +++ b/xen/include/public/sysctl.h
> > @@ -766,6 +766,161 @@ struct xen_sysctl_tmem_op {
> >  typedef struct xen_sysctl_tmem_op xen_sysctl_tmem_op_t;
> >  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_tmem_op_t);
> >  
> > +/*
> > + * XEN_SYSCTL_XSPLICE_op
> > + *
> > + * Refer to the docs/misc/xsplice.markdown for the design details
> > + * of this hypercall.
> 
> To someone importing this header into another project, this
> reference may be quite odd. Don't these get translated to
> some html with a canonical place on the web?
> 
> > +struct xen_sysctl_xsplice_action {
> > +    xen_xsplice_id_t id;                    /* IN, name of the patch. */
> > +#define XSPLICE_ACTION_CHECK        1
> > +#define XSPLICE_ACTION_UNLOAD       2
> > +#define XSPLICE_ACTION_REVERT       3
> > +#define XSPLICE_ACTION_APPLY        4
> > +#define XSPLICE_ACTION_REPLACE      5
> > +    uint32_t    cmd;                        /* IN: XSPLICE_ACTION_*. */
> > +    uint32_t    pad;                        /* IN: MUST be zero. */
> > +    uint64_aligned_t time;                  /* IN: Zero if no timeout. */
> > +                                            /* Or upper bound of time (ms) */
> > +                                            /* for operation to take. */
> 
> So if the field represent a timeout, why not call it such?

<brainfart>
> 
> > +struct xen_sysctl_xsplice_op {
> > +    uint32_t cmd;                           /* IN: XEN_SYSCTL_XSPLICE_* */
> > +    uint32_t pad;                           /* IN: Always zero. */
> 
> Other "pad" fields get checked to be zero, but I wasn't able to
> spot a check for this one.

<nods> Thanks for spotting that!
> 
> > --- /dev/null
> > +++ b/xen/include/xen/xsplice.h
> > @@ -0,0 +1,9 @@
> > +#ifndef __XEN_XSPLICE_H__
> > +#define __XEN_XSPLICE_H__
> > +
> > +struct xen_sysctl_xsplice_op;
> > +int xsplice_control(struct xen_sysctl_xsplice_op *);
> > +
> > +extern void xsplice_printall(unsigned char key);
> 
> What is this declaration good for? The function ought to be static
> afaics.

Yes, good spoting. The code was written before Andrew's big
keyhandler rewrite and after the rebase I forgot about this.

> 
> Jan
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  reply	other threads:[~2015-11-13 14:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 18:15 [PATCH v1 01/11] xsplice: Design document (v2) Ross Lagerwall
2015-11-03 18:15 ` [PATCH v1 02/11] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op Ross Lagerwall
2015-11-04 21:17   ` Konrad Rzeszutek Wilk
2015-11-12 16:28   ` Jan Beulich
2015-11-13 14:13     ` Konrad Rzeszutek Wilk [this message]
2015-11-13 23:50   ` Daniel De Graaf
2015-11-03 18:16 ` [PATCH v1 03/11] libxc: Implementation of XEN_XSPLICE_op in libxc Ross Lagerwall
2015-11-03 18:16 ` [PATCH v1 04/11] xen-xsplice: Tool to manipulate xsplice payloads Ross Lagerwall
2015-11-04 21:27   ` Konrad Rzeszutek Wilk
2015-11-03 18:16 ` [PATCH v1 05/11] elf: Add relocation types to elfstructs.h Ross Lagerwall
2015-11-05 10:38   ` Jan Beulich
2015-11-05 11:52     ` Ross Lagerwall
2015-11-03 18:16 ` [PATCH v1 06/11] xsplice: Add helper elf routines Ross Lagerwall
2015-11-04 21:49   ` Konrad Rzeszutek Wilk
2015-11-03 18:16 ` [PATCH v1 07/11] xsplice: Implement payload loading Ross Lagerwall
2015-11-04 22:21   ` Konrad Rzeszutek Wilk
2015-11-05 10:35     ` Jan Beulich
2015-11-05 11:51       ` Ross Lagerwall
2015-11-05 12:13         ` Jan Beulich
2015-11-05 11:15     ` Ross Lagerwall
2015-11-05 20:12       ` Konrad Rzeszutek Wilk
2015-11-03 18:16 ` [PATCH v1 08/11] xsplice: Implement support for applying patches Ross Lagerwall
2015-11-05  3:17   ` Konrad Rzeszutek Wilk
2015-11-05 11:45     ` Ross Lagerwall
2015-11-05 20:08       ` Konrad Rzeszutek Wilk
2015-11-05  3:19   ` Konrad Rzeszutek Wilk
2015-11-27 13:51   ` Martin Pohlack
2015-11-03 18:16 ` [PATCH v1 09/11] xsplice: Add support for bug frames Ross Lagerwall
2015-11-05 19:43   ` Konrad Rzeszutek Wilk
2015-11-03 18:16 ` [PATCH v1 10/11] xsplice: Add support for exception tables Ross Lagerwall
2015-11-05 19:47   ` Konrad Rzeszutek Wilk
2015-11-27 16:28   ` Martin Pohlack
2015-11-27 17:05     ` Ross Lagerwall
2015-11-03 18:16 ` [PATCH v1 11/11] xsplice: Add support for alternatives Ross Lagerwall
2015-11-05 19:48   ` Konrad Rzeszutek Wilk
2015-11-04 21:10 ` [PATCH v1 01/11] xsplice: Design document (v2) Konrad Rzeszutek Wilk
2015-11-05 10:49   ` Ross Lagerwall
2015-11-05 19:56     ` Konrad Rzeszutek Wilk
2015-11-10  9:55 ` Ross Lagerwall
2015-11-27 12:48 ` Martin Pohlack

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=20151113141359.GA32204@char.us.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@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.