From: Anthony PERARD <anthony.perard@citrix.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [Qemu-devel] [PATCH v2 3/3] xen-hvm: try to use xenforeignmemory_map_resource() to map ioreq pages
Date: Tue, 15 May 2018 16:38:21 +0100 [thread overview]
Message-ID: <20180515153821.GD2057@perard.uk.xensource.com> (raw)
In-Reply-To: <20180510091518.28199-4-paul.durrant@citrix.com>
On Thu, May 10, 2018 at 10:15:18AM +0100, Paul Durrant wrote:
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -1239,13 +1239,41 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
>
> static int xen_map_ioreq_server(XenIOState *state)
> {
> + void *addr = NULL;
> + xenforeignmemory_resource_handle *fres;
> xen_pfn_t ioreq_pfn;
> xen_pfn_t bufioreq_pfn;
> evtchn_port_t bufioreq_evtchn;
> int rc;
>
> + /*
> + * Attempt to map using the resource API and fall back to normal
> + * foreign mapping if this is not supported.
> + */
> + QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq != 0);
> + QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) != 1);
> + fres = xenforeignmemory_map_resource(xen_fmem, xen_domid,
> + XENMEM_resource_ioreq_server,
XENMEM_resource_ioreq_server undeclared with Xen 4.10
> + state->ioservid, 0, 2,
> + &addr,
> + PROT_READ | PROT_WRITE, 0);
> + if (fres != NULL) {
> + trace_xen_map_resource_ioreq(state->ioservid, addr);
> + state->buffered_io_page = addr;
> + state->shared_page = addr + TARGET_PAGE_SIZE;
> + } else {
> + error_report("failed to map ioreq server resources: error %d handle=%p",
> + errno, xen_xc);
Maybe printing the error message only when xenforeignmemory_map_resource
fails, would be better? i.e. after checking errno value.
> + if (errno != EOPNOTSUPP) {
> + return -1;
> + }
> + }
> +
> rc = xen_get_ioreq_server_info(xen_domid, state->ioservid,
> - &ioreq_pfn, &bufioreq_pfn,
> + (state->shared_page == NULL) ?
> + &ioreq_pfn : NULL,
> + (state->buffered_io_page == NULL) ?
> + &bufioreq_pfn : NULL,
> &bufioreq_evtchn);
> if (rc < 0) {
> error_report("failed to get ioreq server info: error %d handle=%p",
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 5f1402b494..d925751040 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -119,6 +119,20 @@ static inline int xendevicemodel_pin_memory_cacheattr(
> return xc_domain_pin_memory_cacheattr(xen_xc, domid, start, end, type);
> }
>
> +typedef void xenforeignmemory_resource_handle;
> +
> +#define XENMEM_resource_ioreq_server_frame_bufioreq 0
> +#define XENMEM_resource_ioreq_server_frame_ioreq(n) (1 + (n))
> +
> +static inline xenforeignmemory_resource_handle *xenforeignmemory_map_resource(
> + xenforeignmemory_handle *fmem, domid_t domid, unsigned int type,
> + unsigned int id, unsigned long frame, unsigned long nr_frames,
> + void **paddr, int prot, int flags)
> +{
> + errno = EOPNOTSUPP;
I think ENOSYS would be better. EOPNOTSUPP seems to be for sockets.
> + return -1;
Should this return NULL instead? That doesn't build on Xen 4.10 and earlier.
> +}
> +
> #endif /* CONFIG_XEN_CTRL_INTERFACE_VERSION < 41100 */
>
> #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000
Thanks,
--
Anthony PERARD
next prev parent reply other threads:[~2018-05-15 15:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 9:15 [Qemu-devel] [PATCH v2 0/2] xen-hvm: use new resource mapping API Paul Durrant
2018-05-10 9:15 ` [Qemu-devel] [PATCH v2 1/3] xen-hvm: create separate function for ioreq server initialization Paul Durrant
2018-05-15 14:40 ` Anthony PERARD
2018-05-10 9:15 ` [Qemu-devel] [PATCH v2 2/3] checkpatch: generalize xen handle matching in the list of types Paul Durrant
2018-05-10 13:26 ` Eric Blake
2018-05-10 9:15 ` [Qemu-devel] [PATCH v2 3/3] xen-hvm: try to use xenforeignmemory_map_resource() to map ioreq pages Paul Durrant
2018-05-15 15:38 ` Anthony PERARD [this message]
2018-05-15 15:45 ` Paul Durrant
2018-05-15 16:16 ` Anthony PERARD
2018-05-15 16:26 ` Paul Durrant
2018-05-15 16:42 ` Eric Blake
2018-05-14 9:38 ` [Qemu-devel] [PATCH v2 0/2] xen-hvm: use new resource mapping API Paul Durrant
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=20180515153821.GD2057@perard.uk.xensource.com \
--to=anthony.perard@citrix.com \
--cc=paul.durrant@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.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 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).