From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, julien.grall@linaro.org,
tim@xen.org, xen-devel@lists.xen.org,
David Vrabel <david.vrabel@citrix.com>,
xen-devel@lists.xenproject.org,
Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH LINUX RFC] xen: privcmd: implement IOCTL_PRIVCMD_MMAPBATCH_V2_UNCACHED
Date: Wed, 18 Dec 2013 16:16:30 -0500 [thread overview]
Message-ID: <20131218211630.GB11717@phenom.dumpdata.com> (raw)
In-Reply-To: <1387387837-9922-1-git-send-email-ian.campbell@citrix.com>
On Wed, Dec 18, 2013 at 05:30:37PM +0000, Ian Campbell wrote:
> On ARM we want to use uncached foreign mappings while building the domain
> because the guests start with MMU and caches disabled.
>
Why introduce a new ioctl? Could we piggyback on the old one and on ARM
do the uncached.
> Flushing the caches before launching the guest is problematic because there is
> a window between flush and unmap where the processor might speculatively fill
> a cache line. Using a non-cacheable mapping completely avoids this.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> Cc: Stefano.Stabellini@citrix.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: xen-devel@lists.xenproject.org
> ---
> drivers/xen/privcmd.c | 15 ++++++++++-----
> include/uapi/xen/privcmd.h | 2 ++
> 2 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
> index 569a13b..b5561d1 100644
> --- a/drivers/xen/privcmd.c
> +++ b/drivers/xen/privcmd.c
> @@ -253,6 +253,7 @@ struct mmap_batch_state {
> domid_t domain;
> unsigned long va;
> struct vm_area_struct *vma;
> + pgprot_t prot;
> int index;
> /* A tristate:
> * 0 for no errors
> @@ -285,8 +286,7 @@ static int mmap_batch_fn(void *data, void *state)
> cur_page = pages[st->index++];
>
> ret = xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1,
> - st->vma->vm_page_prot, st->domain,
> - &cur_page);
> + st->prot, st->domain, &cur_page);
>
> /* Store error code for second pass. */
> if (st->version == 1) {
> @@ -367,7 +367,7 @@ static int alloc_empty_pages(struct vm_area_struct *vma, int numpgs)
>
> static struct vm_operations_struct privcmd_vm_ops;
>
> -static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
> +static long privcmd_ioctl_mmap_batch(void __user *udata, int version, int cached)
> {
> int ret;
> struct privcmd_mmapbatch_v2 m;
> @@ -464,6 +464,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
>
> state.domain = m.dom;
> state.vma = vma;
> + state.prot = cached ? vma->vm_page_prot
> + : pgprot_noncached(vma->vm_page_prot);
> state.va = m.addr;
> state.index = 0;
> state.global_error = 0;
> @@ -514,13 +516,16 @@ static long privcmd_ioctl(struct file *file,
> break;
>
> case IOCTL_PRIVCMD_MMAPBATCH:
> - ret = privcmd_ioctl_mmap_batch(udata, 1);
> + ret = privcmd_ioctl_mmap_batch(udata, 1, 1);
> break;
>
> case IOCTL_PRIVCMD_MMAPBATCH_V2:
> - ret = privcmd_ioctl_mmap_batch(udata, 2);
> + ret = privcmd_ioctl_mmap_batch(udata, 2, 1);
> break;
>
> + case IOCTL_PRIVCMD_MMAPBATCH_V2_UNCACHED:
> + ret = privcmd_ioctl_mmap_batch(udata, 2, 0);
> + break;
> default:
> ret = -EINVAL;
> break;
> diff --git a/include/uapi/xen/privcmd.h b/include/uapi/xen/privcmd.h
> index a853168..be7e72b 100644
> --- a/include/uapi/xen/privcmd.h
> +++ b/include/uapi/xen/privcmd.h
> @@ -94,5 +94,7 @@ struct privcmd_mmapbatch_v2 {
> _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))
> #define IOCTL_PRIVCMD_MMAPBATCH_V2 \
> _IOC(_IOC_NONE, 'P', 4, sizeof(struct privcmd_mmapbatch_v2))
> +#define IOCTL_PRIVCMD_MMAPBATCH_V2_UNCACHED \
> + _IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_mmapbatch_v2))
>
> #endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
> --
> 1.7.10.4
>
next prev parent reply other threads:[~2013-12-18 21:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 17:28 [PATCH RFC] xen: arm: use uncached foreign mappings when building guests Ian Campbell
2013-12-18 17:30 ` [PATCH LINUX RFC] xen: privcmd: implement IOCTL_PRIVCMD_MMAPBATCH_V2_UNCACHED Ian Campbell
2013-12-18 19:24 ` Stefano Stabellini
2013-12-18 21:16 ` Konrad Rzeszutek Wilk [this message]
2013-12-20 9:19 ` Ian Campbell
2013-12-20 14:13 ` Konrad Rzeszutek Wilk
2013-12-20 14:18 ` Ian Campbell
2013-12-20 14:38 ` Konrad Rzeszutek Wilk
2013-12-20 14:44 ` Ian Campbell
2013-12-18 17:30 ` [PATCH XEN RFC] libxc: use an uncached mapping of guest ram in domain builder Ian Campbell
2013-12-18 21:14 ` Konrad Rzeszutek Wilk
2013-12-20 9:19 ` Ian Campbell
2013-12-18 18:41 ` [PATCH RFC] xen: arm: use uncached foreign mappings when building guests David Vrabel
2013-12-19 10:10 ` Ian Campbell
2013-12-19 11:23 ` Stefano Stabellini
2013-12-19 11:29 ` Ian Campbell
2014-01-02 15:10 ` David Vrabel
2014-01-06 10:05 ` Ian Campbell
2013-12-19 4:16 ` Julien Grall
2013-12-19 4:26 ` Julien Grall
2013-12-19 14:30 ` Ian Campbell
2014-01-06 12:10 ` Ian Campbell
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=20131218211630.GB11717@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=julien.grall@linaro.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--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 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.