mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Juergen Gross <jgross@suse.com>,
	linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org
Cc: julien.grall@arm.com, tycho@docker.com
Subject: Re: [PATCH] xen: don't compile pv-specific parts if XEN_PV isn't configured
Date: Thu, 14 Sep 2017 10:00:51 -0400	[thread overview]
Message-ID: <fa4b3a38-7447-0168-0afd-4a9aa1c98050@oracle.com> (raw)
In-Reply-To: <20170914123858.1167-1-jgross@suse.com>

On 09/14/2017 08:38 AM, Juergen Gross wrote:
> xenbus_client.c contains some functions specific for pv guests.
> Enclose them with #ifdef CONFIG_XEN_PV to avoid compiling them when
> they are not needed (e.g. on ARM).
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  drivers/xen/xenbus/xenbus_client.c | 130 +++++++++++++++++++------------------
>  1 file changed, 67 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
> index 82a8866758ee..a1c17000129b 100644
> --- a/drivers/xen/xenbus/xenbus_client.c
> +++ b/drivers/xen/xenbus/xenbus_client.c
> @@ -519,64 +519,6 @@ static int __xenbus_map_ring(struct xenbus_device *dev,
>  	return err;
>  }
>  
> -static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev,
> -				     grant_ref_t *gnt_refs,
> -				     unsigned int nr_grefs,
> -				     void **vaddr)
> -{
> -	struct xenbus_map_node *node;
> -	struct vm_struct *area;
> -	pte_t *ptes[XENBUS_MAX_RING_GRANTS];
> -	phys_addr_t phys_addrs[XENBUS_MAX_RING_GRANTS];
> -	int err = GNTST_okay;
> -	int i;
> -	bool leaked;
> -
> -	*vaddr = NULL;
> -
> -	if (nr_grefs > XENBUS_MAX_RING_GRANTS)
> -		return -EINVAL;
> -
> -	node = kzalloc(sizeof(*node), GFP_KERNEL);
> -	if (!node)
> -		return -ENOMEM;
> -
> -	area = alloc_vm_area(XEN_PAGE_SIZE * nr_grefs, ptes);
> -	if (!area) {
> -		kfree(node);
> -		return -ENOMEM;
> -	}
> -
> -	for (i = 0; i < nr_grefs; i++)
> -		phys_addrs[i] = arbitrary_virt_to_machine(ptes[i]).maddr;
> -
> -	err = __xenbus_map_ring(dev, gnt_refs, nr_grefs, node->handles,
> -				phys_addrs,
> -				GNTMAP_host_map | GNTMAP_contains_pte,
> -				&leaked);
> -	if (err)
> -		goto failed;
> -
> -	node->nr_handles = nr_grefs;
> -	node->pv.area = area;
> -
> -	spin_lock(&xenbus_valloc_lock);
> -	list_add(&node->next, &xenbus_valloc_pages);
> -	spin_unlock(&xenbus_valloc_lock);
> -
> -	*vaddr = area->addr;
> -	return 0;
> -
> -failed:
> -	if (!leaked)
> -		free_vm_area(area);
> -	else
> -		pr_alert("leaking VM area %p size %u page(s)", area, nr_grefs);
> -
> -	kfree(node);
> -	return err;
> -}
> -
>  struct map_ring_valloc_hvm
>  {
>  	unsigned int idx;
> @@ -725,6 +667,65 @@ int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
>  }
>  EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
>  
> +#ifdef CONFIG_XEN_PV
> +static int xenbus_map_ring_valloc_pv(struct xenbus_device *dev,
> +				     grant_ref_t *gnt_refs,
> +				     unsigned int nr_grefs,
> +				     void **vaddr)
> +{
> +	struct xenbus_map_node *node;
> +	struct vm_struct *area;
> +	pte_t *ptes[XENBUS_MAX_RING_GRANTS];
> +	phys_addr_t phys_addrs[XENBUS_MAX_RING_GRANTS];
> +	int err = GNTST_okay;
> +	int i;
> +	bool leaked;
> +
> +	*vaddr = NULL;
> +
> +	if (nr_grefs > XENBUS_MAX_RING_GRANTS)
> +		return -EINVAL;
> +
> +	node = kzalloc(sizeof(*node), GFP_KERNEL);
> +	if (!node)
> +		return -ENOMEM;
> +
> +	area = alloc_vm_area(XEN_PAGE_SIZE * nr_grefs, ptes);
> +	if (!area) {
> +		kfree(node);
> +		return -ENOMEM;
> +	}
> +
> +	for (i = 0; i < nr_grefs; i++)
> +		phys_addrs[i] = arbitrary_virt_to_machine(ptes[i]).maddr;
> +
> +	err = __xenbus_map_ring(dev, gnt_refs, nr_grefs, node->handles,
> +				phys_addrs,
> +				GNTMAP_host_map | GNTMAP_contains_pte,
> +				&leaked);
> +	if (err)
> +		goto failed;
> +
> +	node->nr_handles = nr_grefs;
> +	node->pv.area = area;
> +
> +	spin_lock(&xenbus_valloc_lock);
> +	list_add(&node->next, &xenbus_valloc_pages);
> +	spin_unlock(&xenbus_valloc_lock);
> +
> +	*vaddr = area->addr;
> +	return 0;
> +
> +failed:
> +	if (!leaked)
> +		free_vm_area(area);
> +	else
> +		pr_alert("leaking VM area %p size %u page(s)", area, nr_grefs);
> +
> +	kfree(node);
> +	return err;
> +}
> +

Did you make any changes in xenbus_map_ring_valloc_pv()? I don't see any
but the diff looks pretty big --- I'd expect only the preprocessor
directives to show up.

-boris

  reply	other threads:[~2017-09-14 14:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 12:38 Juergen Gross
2017-09-14 14:00 ` Boris Ostrovsky [this message]
2017-09-14 14:03   ` Juergen Gross
2017-09-14 14:07     ` Boris Ostrovsky
2017-09-14 16:31 ` Tycho Andersen
2017-09-15  5:54   ` Juergen Gross
2017-09-18 20:00 ` Boris Ostrovsky

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=fa4b3a38-7447-0168-0afd-4a9aa1c98050@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=julien.grall@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tycho@docker.com \
    --cc=xen-devel@lists.xenproject.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

all inboxes | Powered by JetHome®