* [PATCH 0/5] Build libxc on rump kernels
@ 2015-02-26 11:56 Wei Liu
2015-02-26 11:56 ` [PATCH 1/5] NetBSDRump: provide evtchn.h Wei Liu
` (4 more replies)
0 siblings, 5 replies; 23+ messages in thread
From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw)
To: xen-devel; +Cc: wei.liu2, ian.jackson, ian.campbell
This is a series done by Ian Jackson. I only changed a few macros and rewrote
some commit logs.
With this series we can build libxc with rump kernels.
Wei.
Ian Jackson (5):
NetBSDRump: provide evtchn.h
libxc: Split off xc_minios_privcmd.c
libxc: Split off xc_netbsd_user.c
libxc: minios: Introduce abstraction for files[]
libxc: rumpxen: Provide xc_osdep_info
tools/include/xen-sys/NetBSDRump/evtchn.h | 86 ++++++++
tools/libxc/Makefile | 6 +-
tools/libxc/xc_minios.c | 243 +---------------------
tools/libxc/xc_minios_privcmd.c | 322 ++++++++++++++++++++++++++++++
tools/libxc/xc_netbsd.c | 168 +---------------
tools/libxc/xc_netbsd_rumpkern.c | 62 ++++++
tools/libxc/xc_netbsd_user.c | 196 ++++++++++++++++++
tools/libxc/xc_private.h | 3 +
8 files changed, 678 insertions(+), 408 deletions(-)
create mode 100644 tools/include/xen-sys/NetBSDRump/evtchn.h
create mode 100644 tools/libxc/xc_minios_privcmd.c
create mode 100644 tools/libxc/xc_netbsd_rumpkern.c
create mode 100644 tools/libxc/xc_netbsd_user.c
--
1.9.1
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH 1/5] NetBSDRump: provide evtchn.h 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu @ 2015-02-26 11:56 ` Wei Liu 2015-03-02 17:28 ` Ian Campbell 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu ` (3 subsequent siblings) 4 siblings, 1 reply; 23+ messages in thread From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, ian.jackson, ian.campbell From: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> [ wei: write commit message ] Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- tools/include/xen-sys/NetBSDRump/evtchn.h | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tools/include/xen-sys/NetBSDRump/evtchn.h diff --git a/tools/include/xen-sys/NetBSDRump/evtchn.h b/tools/include/xen-sys/NetBSDRump/evtchn.h new file mode 100644 index 0000000..2d8a1f9 --- /dev/null +++ b/tools/include/xen-sys/NetBSDRump/evtchn.h @@ -0,0 +1,86 @@ +/* $NetBSD: evtchn.h,v 1.1.1.1 2007/06/14 19:39:45 bouyer Exp $ */ +/****************************************************************************** + * evtchn.h + * + * Interface to /dev/xen/evtchn. + * + * Copyright (c) 2003-2005, K A Fraser + * + * This file may be distributed separately from the Linux kernel, or + * incorporated into other software packages, subject to the following license: + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this source file (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __NetBSD_EVTCHN_H__ +#define __NetBSD_EVTCHN_H__ + +/* + * Bind a fresh port to VIRQ @virq. + */ +#define IOCTL_EVTCHN_BIND_VIRQ \ + _IOWR('E', 4, struct ioctl_evtchn_bind_virq) +struct ioctl_evtchn_bind_virq { + unsigned int virq; + unsigned int port; +}; + +/* + * Bind a fresh port to remote <@remote_domain, @remote_port>. + */ +#define IOCTL_EVTCHN_BIND_INTERDOMAIN \ + _IOWR('E', 5, struct ioctl_evtchn_bind_interdomain) +struct ioctl_evtchn_bind_interdomain { + unsigned int remote_domain, remote_port; + unsigned int port; +}; + +/* + * Allocate a fresh port for binding to @remote_domain. + */ +#define IOCTL_EVTCHN_BIND_UNBOUND_PORT \ + _IOWR('E', 6, struct ioctl_evtchn_bind_unbound_port) +struct ioctl_evtchn_bind_unbound_port { + unsigned int remote_domain; + unsigned int port; +}; + +/* + * Unbind previously allocated @port. + */ +#define IOCTL_EVTCHN_UNBIND \ + _IOW('E', 7, struct ioctl_evtchn_unbind) +struct ioctl_evtchn_unbind { + unsigned int port; +}; + +/* + * Send event to previously allocated @port. + */ +#define IOCTL_EVTCHN_NOTIFY \ + _IOW('E', 8, struct ioctl_evtchn_notify) +struct ioctl_evtchn_notify { + unsigned int port; +}; + +/* Clear and reinitialise the event buffer. Clear error condition. */ +#define IOCTL_EVTCHN_RESET \ + _IO('E', 9) + +#endif /* __NetBSD_EVTCHN_H__ */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/5] NetBSDRump: provide evtchn.h 2015-02-26 11:56 ` [PATCH 1/5] NetBSDRump: provide evtchn.h Wei Liu @ 2015-03-02 17:28 ` Ian Campbell 2015-03-02 17:31 ` Wei Liu 0 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:28 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> > > [ wei: write commit message ] How long did that take ;-) Or did the intended text go missing? ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/5] NetBSDRump: provide evtchn.h 2015-03-02 17:28 ` Ian Campbell @ 2015-03-02 17:31 ` Wei Liu 2015-03-02 17:40 ` Ian Campbell 0 siblings, 1 reply; 23+ messages in thread From: Wei Liu @ 2015-03-02 17:31 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:28:39PM +0000, Ian Campbell wrote: > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> > > > > [ wei: write commit message ] > > How long did that take ;-) > Less than 20 seconds. > Or did the intended text go missing? > No. I added Ian's SoB and a proper title to this changeset. That's all. :-) Wei. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/5] NetBSDRump: provide evtchn.h 2015-03-02 17:31 ` Wei Liu @ 2015-03-02 17:40 ` Ian Campbell 2015-03-02 17:42 ` Wei Liu 0 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:40 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Mon, 2015-03-02 at 17:31 +0000, Wei Liu wrote: > On Mon, Mar 02, 2015 at 05:28:39PM +0000, Ian Campbell wrote: > > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > > > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> > > > > > > [ wei: write commit message ] > > > > How long did that take ;-) > > > > Less than 20 seconds. > > > Or did the intended text go missing? > > > > No. I added Ian's SoB and a proper title to this changeset. That's all. > :-) ;-) Can you describe the background of the file a bit. In particular where does it come from, is it just a copy of the NetBSD one? Or is it somehow RumpKernel specific (or expected to become so)? Where does the "otherend" (i.e. the implementation) live. Ian. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/5] NetBSDRump: provide evtchn.h 2015-03-02 17:40 ` Ian Campbell @ 2015-03-02 17:42 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-03-02 17:42 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:40:45PM +0000, Ian Campbell wrote: > On Mon, 2015-03-02 at 17:31 +0000, Wei Liu wrote: > > On Mon, Mar 02, 2015 at 05:28:39PM +0000, Ian Campbell wrote: > > > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > > > > > Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> > > > > > > > > [ wei: write commit message ] > > > > > > How long did that take ;-) > > > > > > > Less than 20 seconds. > > > > > Or did the intended text go missing? > > > > > > > No. I added Ian's SoB and a proper title to this changeset. That's all. > > :-) > > ;-) > > Can you describe the background of the file a bit. In particular where > does it come from, is it just a copy of the NetBSD one? Or is it somehow > RumpKernel specific (or expected to become so)? Where does the > "otherend" (i.e. the implementation) live. > No problem. I will do that in next version. Wei. > Ian. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/5] libxc: Split off xc_minios_privcmd.c 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu 2015-02-26 11:56 ` [PATCH 1/5] NetBSDRump: provide evtchn.h Wei Liu @ 2015-02-26 11:56 ` Wei Liu 2015-02-26 13:08 ` Wei Liu ` (2 more replies) 2015-02-26 11:56 ` [PATCH 3/5] libxc: Split off xc_netbsd_user.c Wei Liu ` (2 subsequent siblings) 4 siblings, 3 replies; 23+ messages in thread From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, Ian Jackson, ian.campbell From: Ian Jackson <ian.jackson@eu.citrix.com> We are going to want to use some but not all of the machinery previously in xc_minios.c. Split the privcmd and gnttab code into its own file. This part is pure code motion. But we also have to: - Alter the Makefile to build and link xc_minios_privcmd.c too. - Rename some of the minios_*_ops symbols to have proper namespaceing and make them have external linkage, so that the init code (which remains in xc_minios.c) can reference them. - Call these *_ops symbols xc_*_ops so that we can mix and match in the future. This does not impede the existing mechanisms for run-time overriding. (But leave a comment next to the new declarations in xc_private.h saying not to use these.) - Change map_frames_ex to minios_map_frames_ex if compiling on rump kernel. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> [ wei: wrap long lines, use __RUMPRUN__ and define macro for map_frames_ex ] Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- tools/libxc/Makefile | 2 +- tools/libxc/xc_minios.c | 243 +-------------------------------- tools/libxc/xc_minios_privcmd.c | 291 ++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_private.h | 3 + 4 files changed, 299 insertions(+), 240 deletions(-) create mode 100644 tools/libxc/xc_minios_privcmd.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 6fa88c7..4ace2b6 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -47,7 +47,7 @@ CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c -CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c +CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c GUEST_SRCS-y := GUEST_SRCS-y += xg_private.c xc_suspend.c diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index e703684..90e3363 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -41,164 +41,10 @@ #include "xc_private.h" -void minios_interface_close_fd(int fd); void minios_evtchn_close_fd(int fd); -void minios_gnttab_close_fd(int fd); - -extern void minios_interface_close_fd(int fd); -extern void minios_evtchn_close_fd(int fd); extern struct wait_queue_head event_queue; -static xc_osdep_handle minios_privcmd_open(xc_interface *xch) -{ - int fd = alloc_fd(FTYPE_XC); - - if ( fd == -1) - return XC_OSDEP_OPEN_ERROR; - - return (xc_osdep_handle)fd; -} - -static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) -{ - int fd = (int)h; - return close(fd); -} - -void minios_interface_close_fd(int fd) -{ - files[fd].type = FTYPE_NONE; -} - -static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, int npages) -{ - return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); -} - -static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, void *ptr, int npages) -{ - free(ptr); -} - -static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall) -{ - multicall_entry_t call; - int i, ret; - - call.op = hypercall->op; - for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) - call.args[i] = hypercall->arg[i]; - - ret = HYPERVISOR_multicall(&call, 1); - - if (ret < 0) { - errno = -ret; - return -1; - } - if ((long) call.result < 0) { - errno = - (long) call.result; - return -1; - } - return call.result; -} - -static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h, - uint32_t dom, int prot, - const xen_pfn_t *arr, int *err, unsigned int num) -{ - unsigned long pt_prot = 0; - if (prot & PROT_READ) - pt_prot = L1_PROT_RO; - if (prot & PROT_WRITE) - pt_prot = L1_PROT; - return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); -} - -static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h, - uint32_t dom, int prot, - xen_pfn_t *arr, int num) -{ - unsigned long pt_prot = 0; - int err[num]; - int i; - unsigned long addr; - - if (prot & PROT_READ) - pt_prot = L1_PROT_RO; - if (prot & PROT_WRITE) - pt_prot = L1_PROT; - - addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); - for (i = 0; i < num; i++) { - if (err[i]) - arr[i] |= 0xF0000000; - } - return (void *) addr; -} - -static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h, - uint32_t dom, - int size, int prot, - unsigned long mfn) -{ - unsigned long pt_prot = 0; - - if (prot & PROT_READ) - pt_prot = L1_PROT_RO; - if (prot & PROT_WRITE) - pt_prot = L1_PROT; - - assert(!(size % getpagesize())); - return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, pt_prot); -} - -static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h, - uint32_t dom, - size_t size, int prot, size_t chunksize, - privcmd_mmap_entry_t entries[], int nentries) -{ - unsigned long *mfns; - int i, j, n; - unsigned long pt_prot = 0; - void *ret; - - if (prot & PROT_READ) - pt_prot = L1_PROT_RO; - if (prot & PROT_WRITE) - pt_prot = L1_PROT; - - mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); - - n = 0; - for (i = 0; i < nentries; i++) - for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) - mfns[n++] = entries[i].mfn + j; - - ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); - free(mfns); - return ret; -} - - -static struct xc_osdep_ops minios_privcmd_ops = { - .open = &minios_privcmd_open, - .close = &minios_privcmd_close, - - .u.privcmd = { - .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, - .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, - - .hypercall = &minios_privcmd_hypercall, - - .map_foreign_batch = &minios_privcmd_map_foreign_batch, - .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, - .map_foreign_range = &minios_privcmd_map_foreign_range, - .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, - }, -}; - - /* XXX Note: This is not threadsafe */ static struct evtchn_port_info* port_alloc(int fd) { struct evtchn_port_info *port_info; @@ -409,7 +255,7 @@ static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t return 0; } -static struct xc_osdep_ops minios_evtchn_ops = { +struct xc_osdep_ops xc_evtchn_ops = { .open = &minios_evtchn_open, .close = &minios_evtchn_close, @@ -437,97 +283,16 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) return memalign(alignment, size); } -static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) -{ - int fd = alloc_fd(FTYPE_GNTMAP); - if ( fd == -1 ) - return XC_OSDEP_OPEN_ERROR; - gntmap_init(&files[fd].gntmap); - return (xc_osdep_handle)fd; -} - -static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) -{ - int fd = (int)h; - return close(fd); -} - -void minios_gnttab_close_fd(int fd) -{ - gntmap_fini(&files[fd].gntmap); - files[fd].type = FTYPE_NONE; -} - -static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, - uint32_t count, int flags, int prot, - uint32_t *domids, uint32_t *refs, - uint32_t notify_offset, - evtchn_port_t notify_port) -{ - int fd = (int)h; - int stride = 1; - if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) - stride = 0; - if (notify_offset != -1 || notify_port != -1) { - errno = ENOSYS; - return NULL; - } - return gntmap_map_grant_refs(&files[fd].gntmap, - count, domids, stride, - refs, prot & PROT_WRITE); -} - -static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, - void *start_address, - uint32_t count) -{ - int fd = (int)h; - int ret; - ret = gntmap_munmap(&files[fd].gntmap, - (unsigned long) start_address, - count); - if (ret < 0) { - errno = -ret; - return -1; - } - return ret; -} - -static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, - uint32_t count) -{ - int fd = (int)h; - int ret; - ret = gntmap_set_max_grants(&files[fd].gntmap, - count); - if (ret < 0) { - errno = -ret; - return -1; - } - return ret; -} - -static struct xc_osdep_ops minios_gnttab_ops = { - .open = &minios_gnttab_open, - .close = &minios_gnttab_close, - - .u.gnttab = { - .grant_map = &minios_gnttab_grant_map, - .munmap = &minios_gnttab_munmap, - .set_max_grants = &minios_gnttab_set_max_grants, - }, -}; - static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum xc_osdep_type type) { switch ( type ) { case XC_OSDEP_PRIVCMD: - return &minios_privcmd_ops; + return &xc_privcmd_ops; case XC_OSDEP_EVTCHN: - return &minios_evtchn_ops; + return &xc_evtchn_ops; case XC_OSDEP_GNTTAB: - return &minios_gnttab_ops; + return &xc_gnttab_ops; default: return NULL; } diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c new file mode 100644 index 0000000..7766b86 --- /dev/null +++ b/tools/libxc/xc_minios_privcmd.c @@ -0,0 +1,291 @@ +/****************************************************************************** + * + * Copyright 2007-2008 Samuel Thibault <samuel.thibault@eu.citrix.com>. + * All rights reserved. + * Use is subject to license terms. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#undef NDEBUG +#include "xen-external/bsd-sys-queue.h" +#include <mini-os/types.h> +#include <mini-os/os.h> +#include <mini-os/mm.h> +#include <mini-os/lib.h> +#include <mini-os/gntmap.h> +#include <mini-os/events.h> +#include <mini-os/wait.h> +#include <sys/mman.h> + +#include <xen/memory.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdio.h> +#include <assert.h> +#include <stdint.h> +#include <inttypes.h> +#include <malloc.h> + +#include "xc_private.h" + +#ifdef __RUMPRUN___ +# define map_frames_ex minios_map_frames_ex +#endif /* __RUMPRUN__ */ + +void minios_interface_close_fd(int fd); +void minios_gnttab_close_fd(int fd); + +static xc_osdep_handle minios_privcmd_open(xc_interface *xch) +{ + int fd = alloc_fd(FTYPE_XC); + + if ( fd == -1) + return XC_OSDEP_OPEN_ERROR; + + return (xc_osdep_handle)fd; +} + +static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) +{ + int fd = (int)h; + return close(fd); +} + +void minios_interface_close_fd(int fd) +{ + files[fd].type = FTYPE_NONE; +} + +static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, + xc_osdep_handle h, + int npages) +{ + return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); +} + +static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, + xc_osdep_handle h, + void *ptr, int npages) +{ + free(ptr); +} + +static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, + privcmd_hypercall_t *hypercall) +{ + multicall_entry_t call; + int i, ret; + + call.op = hypercall->op; + for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) + call.args[i] = hypercall->arg[i]; + + ret = HYPERVISOR_multicall(&call, 1); + + if (ret < 0) { + errno = -ret; + return -1; + } + if ((long) call.result < 0) { + errno = - (long) call.result; + return -1; + } + return call.result; +} + +static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, + xc_osdep_handle h, + uint32_t dom, int prot, + const xen_pfn_t *arr, + int *err, unsigned int num) +{ + unsigned long pt_prot = 0; + if (prot & PROT_READ) + pt_prot = L1_PROT_RO; + if (prot & PROT_WRITE) + pt_prot = L1_PROT; + return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); +} + +static void *minios_privcmd_map_foreign_batch(xc_interface *xch, + xc_osdep_handle h, + uint32_t dom, int prot, + xen_pfn_t *arr, int num) +{ + unsigned long pt_prot = 0; + int err[num]; + int i; + unsigned long addr; + + if (prot & PROT_READ) + pt_prot = L1_PROT_RO; + if (prot & PROT_WRITE) + pt_prot = L1_PROT; + + addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); + for (i = 0; i < num; i++) { + if (err[i]) + arr[i] |= 0xF0000000; + } + return (void *) addr; +} + +static void *minios_privcmd_map_foreign_range(xc_interface *xch, + xc_osdep_handle h, + uint32_t dom, + int size, int prot, + unsigned long mfn) +{ + unsigned long pt_prot = 0; + + if (prot & PROT_READ) + pt_prot = L1_PROT_RO; + if (prot & PROT_WRITE) + pt_prot = L1_PROT; + + assert(!(size % getpagesize())); + return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, + NULL, pt_prot); +} + +static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, + xc_osdep_handle h, + uint32_t dom, + size_t size, int prot, + size_t chunksize, + privcmd_mmap_entry_t entries[], + int nentries) +{ + unsigned long *mfns; + int i, j, n; + unsigned long pt_prot = 0; + void *ret; + + if (prot & PROT_READ) + pt_prot = L1_PROT_RO; + if (prot & PROT_WRITE) + pt_prot = L1_PROT; + + mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); + + n = 0; + for (i = 0; i < nentries; i++) + for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) + mfns[n++] = entries[i].mfn + j; + + ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); + free(mfns); + return ret; +} + +struct xc_osdep_ops xc_privcmd_ops = { + .open = &minios_privcmd_open, + .close = &minios_privcmd_close, + + .u.privcmd = { + .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, + .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, + + .hypercall = &minios_privcmd_hypercall, + + .map_foreign_batch = &minios_privcmd_map_foreign_batch, + .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, + .map_foreign_range = &minios_privcmd_map_foreign_range, + .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, + }, +}; + +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) +{ + int fd = alloc_fd(FTYPE_GNTMAP); + if ( fd == -1 ) + return XC_OSDEP_OPEN_ERROR; + gntmap_init(&files[fd].gntmap); + return (xc_osdep_handle)fd; +} + +static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) +{ + int fd = (int)h; + return close(fd); +} + +void minios_gnttab_close_fd(int fd) +{ + gntmap_fini(&files[fd].gntmap); + files[fd].type = FTYPE_NONE; +} + +static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, + uint32_t count, int flags, int prot, + uint32_t *domids, uint32_t *refs, + uint32_t notify_offset, + evtchn_port_t notify_port) +{ + int fd = (int)h; + int stride = 1; + if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) + stride = 0; + if (notify_offset != -1 || notify_port != -1) { + errno = ENOSYS; + return NULL; + } + return gntmap_map_grant_refs(&files[fd].gntmap, + count, domids, stride, + refs, prot & PROT_WRITE); +} + +static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, + void *start_address, + uint32_t count) +{ + int fd = (int)h; + int ret; + ret = gntmap_munmap(&files[fd].gntmap, + (unsigned long) start_address, + count); + if (ret < 0) { + errno = -ret; + return -1; + } + return ret; +} + +static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, + uint32_t count) +{ + int fd = (int)h; + int ret; + ret = gntmap_set_max_grants(&files[fd].gntmap, + count); + if (ret < 0) { + errno = -ret; + return -1; + } + return ret; +} + +struct xc_osdep_ops xc_gnttab_ops = { + .open = &minios_gnttab_open, + .close = &minios_gnttab_close, + + .u.gnttab = { + .grant_map = &minios_gnttab_grant_map, + .munmap = &minios_gnttab_munmap, + .set_max_grants = &minios_gnttab_set_max_grants, + }, +}; + diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index 45b8644..152465f 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -111,6 +111,9 @@ struct xc_interface_core { xc_osdep_handle ops_handle; /* opaque data for xc_osdep_ops */ }; +/* Do not use these directly; go via the handle you already have. */ +extern struct xc_osdep_ops xc_privcmd_ops, xc_evtchn_ops, xc_gnttab_ops; + void xc_report_error(xc_interface *xch, int code, const char *fmt, ...) __attribute__((format(printf,3,4))); void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, -- 1.9.1 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] libxc: Split off xc_minios_privcmd.c 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu @ 2015-02-26 13:08 ` Wei Liu 2015-02-26 13:09 ` Samuel Thibault 2015-03-02 17:31 ` Ian Campbell 2 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-02-26 13:08 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, ian.jackson, ian.campbell On Thu, Feb 26, 2015 at 11:56:18AM +0000, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to use some but not all of the machinery > previously in xc_minios.c. Split the privcmd and gnttab code into its > own file. This part is pure code motion. > > But we also have to: > > - Alter the Makefile to build and link xc_minios_privcmd.c too. > > - Rename some of the minios_*_ops symbols to have proper namespaceing > and make them have external linkage, so that the init code (which > remains in xc_minios.c) can reference them. > > - Call these *_ops symbols xc_*_ops so that we can mix and match in > the future. This does not impede the existing mechanisms for > run-time overriding. (But leave a comment next to the new > declarations in xc_private.h saying not to use these.) > > - Change map_frames_ex to minios_map_frames_ex if compiling on rump > kernel. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > > [ wei: wrap long lines, use __RUMPRUN__ and define macro for map_frames_ex ] > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > --- > tools/libxc/Makefile | 2 +- > tools/libxc/xc_minios.c | 243 +-------------------------------- > tools/libxc/xc_minios_privcmd.c | 291 ++++++++++++++++++++++++++++++++++++++++ > tools/libxc/xc_private.h | 3 + > 4 files changed, 299 insertions(+), 240 deletions(-) > create mode 100644 tools/libxc/xc_minios_privcmd.c > > diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile > index 6fa88c7..4ace2b6 100644 > --- a/tools/libxc/Makefile > +++ b/tools/libxc/Makefile > @@ -47,7 +47,7 @@ CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c > CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c > CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c > CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c > -CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c > +CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c > > GUEST_SRCS-y := > GUEST_SRCS-y += xg_private.c xc_suspend.c > diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c > index e703684..90e3363 100644 > --- a/tools/libxc/xc_minios.c > +++ b/tools/libxc/xc_minios.c > @@ -41,164 +41,10 @@ > > #include "xc_private.h" > > -void minios_interface_close_fd(int fd); > void minios_evtchn_close_fd(int fd); > -void minios_gnttab_close_fd(int fd); > - > -extern void minios_interface_close_fd(int fd); > -extern void minios_evtchn_close_fd(int fd); > > extern struct wait_queue_head event_queue; > > -static xc_osdep_handle minios_privcmd_open(xc_interface *xch) > -{ > - int fd = alloc_fd(FTYPE_XC); > - > - if ( fd == -1) > - return XC_OSDEP_OPEN_ERROR; > - > - return (xc_osdep_handle)fd; > -} > - > -static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_interface_close_fd(int fd) > -{ > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, int npages) > -{ > - return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); > -} > - > -static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, void *ptr, int npages) > -{ > - free(ptr); > -} > - > -static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall) > -{ > - multicall_entry_t call; > - int i, ret; > - > - call.op = hypercall->op; > - for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) > - call.args[i] = hypercall->arg[i]; > - > - ret = HYPERVISOR_multicall(&call, 1); > - > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - if ((long) call.result < 0) { > - errno = - (long) call.result; > - return -1; > - } > - return call.result; > -} > - > -static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - const xen_pfn_t *arr, int *err, unsigned int num) > -{ > - unsigned long pt_prot = 0; > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - xen_pfn_t *arr, int num) > -{ > - unsigned long pt_prot = 0; > - int err[num]; > - int i; > - unsigned long addr; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > - for (i = 0; i < num; i++) { > - if (err[i]) > - arr[i] |= 0xF0000000; > - } > - return (void *) addr; > -} > - > -static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - int size, int prot, > - unsigned long mfn) > -{ > - unsigned long pt_prot = 0; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - assert(!(size % getpagesize())); > - return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - size_t size, int prot, size_t chunksize, > - privcmd_mmap_entry_t entries[], int nentries) > -{ > - unsigned long *mfns; > - int i, j, n; > - unsigned long pt_prot = 0; > - void *ret; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); > - > - n = 0; > - for (i = 0; i < nentries; i++) > - for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) > - mfns[n++] = entries[i].mfn + j; > - > - ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); > - free(mfns); > - return ret; > -} > - > - > -static struct xc_osdep_ops minios_privcmd_ops = { > - .open = &minios_privcmd_open, > - .close = &minios_privcmd_close, > - > - .u.privcmd = { > - .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, > - .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, > - > - .hypercall = &minios_privcmd_hypercall, > - > - .map_foreign_batch = &minios_privcmd_map_foreign_batch, > - .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, > - .map_foreign_range = &minios_privcmd_map_foreign_range, > - .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, > - }, > -}; > - > - > /* XXX Note: This is not threadsafe */ > static struct evtchn_port_info* port_alloc(int fd) { > struct evtchn_port_info *port_info; > @@ -409,7 +255,7 @@ static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t > return 0; > } > > -static struct xc_osdep_ops minios_evtchn_ops = { > +struct xc_osdep_ops xc_evtchn_ops = { > .open = &minios_evtchn_open, > .close = &minios_evtchn_close, > > @@ -437,97 +283,16 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) > return memalign(alignment, size); > } > > -static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > -{ > - int fd = alloc_fd(FTYPE_GNTMAP); > - if ( fd == -1 ) > - return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > - return (xc_osdep_handle)fd; > -} > - > -static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_gnttab_close_fd(int fd) > -{ > - gntmap_fini(&files[fd].gntmap); > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count, int flags, int prot, > - uint32_t *domids, uint32_t *refs, > - uint32_t notify_offset, > - evtchn_port_t notify_port) > -{ > - int fd = (int)h; > - int stride = 1; > - if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > - stride = 0; > - if (notify_offset != -1 || notify_port != -1) { > - errno = ENOSYS; > - return NULL; > - } > - return gntmap_map_grant_refs(&files[fd].gntmap, > - count, domids, stride, > - refs, prot & PROT_WRITE); > -} > - > -static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > - void *start_address, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > - (unsigned long) start_address, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static struct xc_osdep_ops minios_gnttab_ops = { > - .open = &minios_gnttab_open, > - .close = &minios_gnttab_close, > - > - .u.gnttab = { > - .grant_map = &minios_gnttab_grant_map, > - .munmap = &minios_gnttab_munmap, > - .set_max_grants = &minios_gnttab_set_max_grants, > - }, > -}; > - > static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum xc_osdep_type type) > { > switch ( type ) > { > case XC_OSDEP_PRIVCMD: > - return &minios_privcmd_ops; > + return &xc_privcmd_ops; > case XC_OSDEP_EVTCHN: > - return &minios_evtchn_ops; > + return &xc_evtchn_ops; > case XC_OSDEP_GNTTAB: > - return &minios_gnttab_ops; > + return &xc_gnttab_ops; > default: > return NULL; > } > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > new file mode 100644 > index 0000000..7766b86 > --- /dev/null > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -0,0 +1,291 @@ > +/****************************************************************************** > + * > + * Copyright 2007-2008 Samuel Thibault <samuel.thibault@eu.citrix.com>. > + * All rights reserved. > + * Use is subject to license terms. > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#undef NDEBUG > +#include "xen-external/bsd-sys-queue.h" > +#include <mini-os/types.h> > +#include <mini-os/os.h> > +#include <mini-os/mm.h> > +#include <mini-os/lib.h> > +#include <mini-os/gntmap.h> > +#include <mini-os/events.h> > +#include <mini-os/wait.h> > +#include <sys/mman.h> > + > +#include <xen/memory.h> > +#include <unistd.h> > +#include <fcntl.h> > +#include <stdio.h> > +#include <assert.h> > +#include <stdint.h> > +#include <inttypes.h> > +#include <malloc.h> > + > +#include "xc_private.h" > + > +#ifdef __RUMPRUN___ There is one formatting error here, I will fix it in next round. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] libxc: Split off xc_minios_privcmd.c 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu 2015-02-26 13:08 ` Wei Liu @ 2015-02-26 13:09 ` Samuel Thibault 2015-03-02 17:31 ` Ian Campbell 2 siblings, 0 replies; 23+ messages in thread From: Samuel Thibault @ 2015-02-26 13:09 UTC (permalink / raw) To: Wei Liu; +Cc: Ian Jackson, ian.campbell, xen-devel Wei Liu, le Thu 26 Feb 2015 11:56:18 +0000, a écrit : > We are going to want to use some but not all of the machinery > previously in xc_minios.c. Split the privcmd and gnttab code into its > own file. This part is pure code motion. > > But we also have to: > > - Alter the Makefile to build and link xc_minios_privcmd.c too. > > - Rename some of the minios_*_ops symbols to have proper namespaceing > and make them have external linkage, so that the init code (which > remains in xc_minios.c) can reference them. > > - Call these *_ops symbols xc_*_ops so that we can mix and match in > the future. This does not impede the existing mechanisms for > run-time overriding. (But leave a comment next to the new > declarations in xc_private.h saying not to use these.) > > - Change map_frames_ex to minios_map_frames_ex if compiling on rump > kernel. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > > [ wei: wrap long lines, use __RUMPRUN__ and define macro for map_frames_ex ] > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > --- > tools/libxc/Makefile | 2 +- > tools/libxc/xc_minios.c | 243 +-------------------------------- > tools/libxc/xc_minios_privcmd.c | 291 ++++++++++++++++++++++++++++++++++++++++ > tools/libxc/xc_private.h | 3 + > 4 files changed, 299 insertions(+), 240 deletions(-) > create mode 100644 tools/libxc/xc_minios_privcmd.c > > diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile > index 6fa88c7..4ace2b6 100644 > --- a/tools/libxc/Makefile > +++ b/tools/libxc/Makefile > @@ -47,7 +47,7 @@ CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c > CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c > CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c > CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c > -CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c > +CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c > > GUEST_SRCS-y := > GUEST_SRCS-y += xg_private.c xc_suspend.c > diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c > index e703684..90e3363 100644 > --- a/tools/libxc/xc_minios.c > +++ b/tools/libxc/xc_minios.c > @@ -41,164 +41,10 @@ > > #include "xc_private.h" > > -void minios_interface_close_fd(int fd); > void minios_evtchn_close_fd(int fd); > -void minios_gnttab_close_fd(int fd); > - > -extern void minios_interface_close_fd(int fd); > -extern void minios_evtchn_close_fd(int fd); > > extern struct wait_queue_head event_queue; > > -static xc_osdep_handle minios_privcmd_open(xc_interface *xch) > -{ > - int fd = alloc_fd(FTYPE_XC); > - > - if ( fd == -1) > - return XC_OSDEP_OPEN_ERROR; > - > - return (xc_osdep_handle)fd; > -} > - > -static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_interface_close_fd(int fd) > -{ > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, int npages) > -{ > - return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); > -} > - > -static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, void *ptr, int npages) > -{ > - free(ptr); > -} > - > -static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall) > -{ > - multicall_entry_t call; > - int i, ret; > - > - call.op = hypercall->op; > - for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) > - call.args[i] = hypercall->arg[i]; > - > - ret = HYPERVISOR_multicall(&call, 1); > - > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - if ((long) call.result < 0) { > - errno = - (long) call.result; > - return -1; > - } > - return call.result; > -} > - > -static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - const xen_pfn_t *arr, int *err, unsigned int num) > -{ > - unsigned long pt_prot = 0; > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - xen_pfn_t *arr, int num) > -{ > - unsigned long pt_prot = 0; > - int err[num]; > - int i; > - unsigned long addr; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > - for (i = 0; i < num; i++) { > - if (err[i]) > - arr[i] |= 0xF0000000; > - } > - return (void *) addr; > -} > - > -static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - int size, int prot, > - unsigned long mfn) > -{ > - unsigned long pt_prot = 0; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - assert(!(size % getpagesize())); > - return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - size_t size, int prot, size_t chunksize, > - privcmd_mmap_entry_t entries[], int nentries) > -{ > - unsigned long *mfns; > - int i, j, n; > - unsigned long pt_prot = 0; > - void *ret; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); > - > - n = 0; > - for (i = 0; i < nentries; i++) > - for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) > - mfns[n++] = entries[i].mfn + j; > - > - ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); > - free(mfns); > - return ret; > -} > - > - > -static struct xc_osdep_ops minios_privcmd_ops = { > - .open = &minios_privcmd_open, > - .close = &minios_privcmd_close, > - > - .u.privcmd = { > - .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, > - .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, > - > - .hypercall = &minios_privcmd_hypercall, > - > - .map_foreign_batch = &minios_privcmd_map_foreign_batch, > - .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, > - .map_foreign_range = &minios_privcmd_map_foreign_range, > - .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, > - }, > -}; > - > - > /* XXX Note: This is not threadsafe */ > static struct evtchn_port_info* port_alloc(int fd) { > struct evtchn_port_info *port_info; > @@ -409,7 +255,7 @@ static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t > return 0; > } > > -static struct xc_osdep_ops minios_evtchn_ops = { > +struct xc_osdep_ops xc_evtchn_ops = { > .open = &minios_evtchn_open, > .close = &minios_evtchn_close, > > @@ -437,97 +283,16 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) > return memalign(alignment, size); > } > > -static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > -{ > - int fd = alloc_fd(FTYPE_GNTMAP); > - if ( fd == -1 ) > - return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > - return (xc_osdep_handle)fd; > -} > - > -static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_gnttab_close_fd(int fd) > -{ > - gntmap_fini(&files[fd].gntmap); > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count, int flags, int prot, > - uint32_t *domids, uint32_t *refs, > - uint32_t notify_offset, > - evtchn_port_t notify_port) > -{ > - int fd = (int)h; > - int stride = 1; > - if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > - stride = 0; > - if (notify_offset != -1 || notify_port != -1) { > - errno = ENOSYS; > - return NULL; > - } > - return gntmap_map_grant_refs(&files[fd].gntmap, > - count, domids, stride, > - refs, prot & PROT_WRITE); > -} > - > -static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > - void *start_address, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > - (unsigned long) start_address, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static struct xc_osdep_ops minios_gnttab_ops = { > - .open = &minios_gnttab_open, > - .close = &minios_gnttab_close, > - > - .u.gnttab = { > - .grant_map = &minios_gnttab_grant_map, > - .munmap = &minios_gnttab_munmap, > - .set_max_grants = &minios_gnttab_set_max_grants, > - }, > -}; > - > static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum xc_osdep_type type) > { > switch ( type ) > { > case XC_OSDEP_PRIVCMD: > - return &minios_privcmd_ops; > + return &xc_privcmd_ops; > case XC_OSDEP_EVTCHN: > - return &minios_evtchn_ops; > + return &xc_evtchn_ops; > case XC_OSDEP_GNTTAB: > - return &minios_gnttab_ops; > + return &xc_gnttab_ops; > default: > return NULL; > } > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > new file mode 100644 > index 0000000..7766b86 > --- /dev/null > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -0,0 +1,291 @@ > +/****************************************************************************** > + * > + * Copyright 2007-2008, 2015 Samuel Thibault <samuel.thibault@eu.citrix.com>. > + * All rights reserved. > + * Use is subject to license terms. > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#undef NDEBUG > +#include "xen-external/bsd-sys-queue.h" > +#include <mini-os/types.h> > +#include <mini-os/os.h> > +#include <mini-os/mm.h> > +#include <mini-os/lib.h> > +#include <mini-os/gntmap.h> > +#include <mini-os/events.h> > +#include <mini-os/wait.h> > +#include <sys/mman.h> > + > +#include <xen/memory.h> > +#include <unistd.h> > +#include <fcntl.h> > +#include <stdio.h> > +#include <assert.h> > +#include <stdint.h> > +#include <inttypes.h> > +#include <malloc.h> > + > +#include "xc_private.h" > + > +#ifdef __RUMPRUN___ > +# define map_frames_ex minios_map_frames_ex > +#endif /* __RUMPRUN__ */ > + > +void minios_interface_close_fd(int fd); > +void minios_gnttab_close_fd(int fd); > + > +static xc_osdep_handle minios_privcmd_open(xc_interface *xch) > +{ > + int fd = alloc_fd(FTYPE_XC); > + > + if ( fd == -1) > + return XC_OSDEP_OPEN_ERROR; > + > + return (xc_osdep_handle)fd; > +} > + > +static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) > +{ > + int fd = (int)h; > + return close(fd); > +} > + > +void minios_interface_close_fd(int fd) > +{ > + files[fd].type = FTYPE_NONE; > +} > + > +static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, > + xc_osdep_handle h, > + int npages) > +{ > + return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); > +} > + > +static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, > + xc_osdep_handle h, > + void *ptr, int npages) > +{ > + free(ptr); > +} > + > +static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, > + privcmd_hypercall_t *hypercall) > +{ > + multicall_entry_t call; > + int i, ret; > + > + call.op = hypercall->op; > + for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) > + call.args[i] = hypercall->arg[i]; > + > + ret = HYPERVISOR_multicall(&call, 1); > + > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + if ((long) call.result < 0) { > + errno = - (long) call.result; > + return -1; > + } > + return call.result; > +} > + > +static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, int prot, > + const xen_pfn_t *arr, > + int *err, unsigned int num) > +{ > + unsigned long pt_prot = 0; > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > +} > + > +static void *minios_privcmd_map_foreign_batch(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, int prot, > + xen_pfn_t *arr, int num) > +{ > + unsigned long pt_prot = 0; > + int err[num]; > + int i; > + unsigned long addr; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > + for (i = 0; i < num; i++) { > + if (err[i]) > + arr[i] |= 0xF0000000; > + } > + return (void *) addr; > +} > + > +static void *minios_privcmd_map_foreign_range(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, > + int size, int prot, > + unsigned long mfn) > +{ > + unsigned long pt_prot = 0; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + assert(!(size % getpagesize())); > + return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, > + NULL, pt_prot); > +} > + > +static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, > + size_t size, int prot, > + size_t chunksize, > + privcmd_mmap_entry_t entries[], > + int nentries) > +{ > + unsigned long *mfns; > + int i, j, n; > + unsigned long pt_prot = 0; > + void *ret; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); > + > + n = 0; > + for (i = 0; i < nentries; i++) > + for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) > + mfns[n++] = entries[i].mfn + j; > + > + ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); > + free(mfns); > + return ret; > +} > + > +struct xc_osdep_ops xc_privcmd_ops = { > + .open = &minios_privcmd_open, > + .close = &minios_privcmd_close, > + > + .u.privcmd = { > + .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, > + .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, > + > + .hypercall = &minios_privcmd_hypercall, > + > + .map_foreign_batch = &minios_privcmd_map_foreign_batch, > + .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, > + .map_foreign_range = &minios_privcmd_map_foreign_range, > + .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, > + }, > +}; > + > +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > +{ > + int fd = alloc_fd(FTYPE_GNTMAP); > + if ( fd == -1 ) > + return XC_OSDEP_OPEN_ERROR; > + gntmap_init(&files[fd].gntmap); > + return (xc_osdep_handle)fd; > +} > + > +static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > +{ > + int fd = (int)h; > + return close(fd); > +} > + > +void minios_gnttab_close_fd(int fd) > +{ > + gntmap_fini(&files[fd].gntmap); > + files[fd].type = FTYPE_NONE; > +} > + > +static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > + uint32_t count, int flags, int prot, > + uint32_t *domids, uint32_t *refs, > + uint32_t notify_offset, > + evtchn_port_t notify_port) > +{ > + int fd = (int)h; > + int stride = 1; > + if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > + stride = 0; > + if (notify_offset != -1 || notify_port != -1) { > + errno = ENOSYS; > + return NULL; > + } > + return gntmap_map_grant_refs(&files[fd].gntmap, > + count, domids, stride, > + refs, prot & PROT_WRITE); > +} > + > +static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > + void *start_address, > + uint32_t count) > +{ > + int fd = (int)h; > + int ret; > + ret = gntmap_munmap(&files[fd].gntmap, > + (unsigned long) start_address, > + count); > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + return ret; > +} > + > +static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > + uint32_t count) > +{ > + int fd = (int)h; > + int ret; > + ret = gntmap_set_max_grants(&files[fd].gntmap, > + count); > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + return ret; > +} > + > +struct xc_osdep_ops xc_gnttab_ops = { > + .open = &minios_gnttab_open, > + .close = &minios_gnttab_close, > + > + .u.gnttab = { > + .grant_map = &minios_gnttab_grant_map, > + .munmap = &minios_gnttab_munmap, > + .set_max_grants = &minios_gnttab_set_max_grants, > + }, > +}; > + > diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h > index 45b8644..152465f 100644 > --- a/tools/libxc/xc_private.h > +++ b/tools/libxc/xc_private.h > @@ -111,6 +111,9 @@ struct xc_interface_core { > xc_osdep_handle ops_handle; /* opaque data for xc_osdep_ops */ > }; > > +/* Do not use these directly; go via the handle you already have. */ > +extern struct xc_osdep_ops xc_privcmd_ops, xc_evtchn_ops, xc_gnttab_ops; > + > void xc_report_error(xc_interface *xch, int code, const char *fmt, ...) > __attribute__((format(printf,3,4))); > void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, > -- > 1.9.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > -- Samuel <Y> C'ETAIT PAS UN BUG ! <y> :ppp <y> c ce qu'on dit ;) <Y> (j'ai appuye sur ON, ca peut arriver, non ?) -+- #hp debuggue IRCprime -+- ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] libxc: Split off xc_minios_privcmd.c 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu 2015-02-26 13:08 ` Wei Liu 2015-02-26 13:09 ` Samuel Thibault @ 2015-03-02 17:31 ` Ian Campbell 2015-03-03 15:15 ` Wei Liu 2 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:31 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to use some but not all of the machinery > previously in xc_minios.c. Split the privcmd and gnttab code into its > own file. Does it make sense to put gnttab code in a file called privcmd.c? I don't think there is much of a link between the two, is there? I'm not sure which half of this rump libxc is going to want but perhaps either _common or _standalone would be a better suffix, depending which way it goes? > This part is pure code motion. > > But we also have to: > > - Alter the Makefile to build and link xc_minios_privcmd.c too. > > - Rename some of the minios_*_ops symbols to have proper namespaceing > and make them have external linkage, so that the init code (which > remains in xc_minios.c) can reference them. > > - Call these *_ops symbols xc_*_ops so that we can mix and match in > the future. This does not impede the existing mechanisms for > run-time overriding. (But leave a comment next to the new > declarations in xc_private.h saying not to use these.) > > - Change map_frames_ex to minios_map_frames_ex if compiling on rump > kernel. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > > [ wei: wrap long lines, use __RUMPRUN__ and define macro for map_frames_ex ] > > Signed-off-by: Wei Liu <wei.liu2@citrix.com> > --- > tools/libxc/Makefile | 2 +- > tools/libxc/xc_minios.c | 243 +-------------------------------- > tools/libxc/xc_minios_privcmd.c | 291 ++++++++++++++++++++++++++++++++++++++++ > tools/libxc/xc_private.h | 3 + > 4 files changed, 299 insertions(+), 240 deletions(-) > create mode 100644 tools/libxc/xc_minios_privcmd.c > > diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile > index 6fa88c7..4ace2b6 100644 > --- a/tools/libxc/Makefile > +++ b/tools/libxc/Makefile > @@ -47,7 +47,7 @@ CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c > CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c > CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c > CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c > -CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c > +CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c > > GUEST_SRCS-y := > GUEST_SRCS-y += xg_private.c xc_suspend.c > diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c > index e703684..90e3363 100644 > --- a/tools/libxc/xc_minios.c > +++ b/tools/libxc/xc_minios.c > @@ -41,164 +41,10 @@ > > #include "xc_private.h" > > -void minios_interface_close_fd(int fd); > void minios_evtchn_close_fd(int fd); > -void minios_gnttab_close_fd(int fd); > - > -extern void minios_interface_close_fd(int fd); > -extern void minios_evtchn_close_fd(int fd); > > extern struct wait_queue_head event_queue; > > -static xc_osdep_handle minios_privcmd_open(xc_interface *xch) > -{ > - int fd = alloc_fd(FTYPE_XC); > - > - if ( fd == -1) > - return XC_OSDEP_OPEN_ERROR; > - > - return (xc_osdep_handle)fd; > -} > - > -static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_interface_close_fd(int fd) > -{ > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, int npages) > -{ > - return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); > -} > - > -static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, void *ptr, int npages) > -{ > - free(ptr); > -} > - > -static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall) > -{ > - multicall_entry_t call; > - int i, ret; > - > - call.op = hypercall->op; > - for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) > - call.args[i] = hypercall->arg[i]; > - > - ret = HYPERVISOR_multicall(&call, 1); > - > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - if ((long) call.result < 0) { > - errno = - (long) call.result; > - return -1; > - } > - return call.result; > -} > - > -static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - const xen_pfn_t *arr, int *err, unsigned int num) > -{ > - unsigned long pt_prot = 0; > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, int prot, > - xen_pfn_t *arr, int num) > -{ > - unsigned long pt_prot = 0; > - int err[num]; > - int i; > - unsigned long addr; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > - for (i = 0; i < num; i++) { > - if (err[i]) > - arr[i] |= 0xF0000000; > - } > - return (void *) addr; > -} > - > -static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - int size, int prot, > - unsigned long mfn) > -{ > - unsigned long pt_prot = 0; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - assert(!(size % getpagesize())); > - return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, NULL, pt_prot); > -} > - > -static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle h, > - uint32_t dom, > - size_t size, int prot, size_t chunksize, > - privcmd_mmap_entry_t entries[], int nentries) > -{ > - unsigned long *mfns; > - int i, j, n; > - unsigned long pt_prot = 0; > - void *ret; > - > - if (prot & PROT_READ) > - pt_prot = L1_PROT_RO; > - if (prot & PROT_WRITE) > - pt_prot = L1_PROT; > - > - mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); > - > - n = 0; > - for (i = 0; i < nentries; i++) > - for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) > - mfns[n++] = entries[i].mfn + j; > - > - ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); > - free(mfns); > - return ret; > -} > - > - > -static struct xc_osdep_ops minios_privcmd_ops = { > - .open = &minios_privcmd_open, > - .close = &minios_privcmd_close, > - > - .u.privcmd = { > - .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, > - .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, > - > - .hypercall = &minios_privcmd_hypercall, > - > - .map_foreign_batch = &minios_privcmd_map_foreign_batch, > - .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, > - .map_foreign_range = &minios_privcmd_map_foreign_range, > - .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, > - }, > -}; > - > - > /* XXX Note: This is not threadsafe */ > static struct evtchn_port_info* port_alloc(int fd) { > struct evtchn_port_info *port_info; > @@ -409,7 +255,7 @@ static int minios_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t > return 0; > } > > -static struct xc_osdep_ops minios_evtchn_ops = { > +struct xc_osdep_ops xc_evtchn_ops = { > .open = &minios_evtchn_open, > .close = &minios_evtchn_close, > > @@ -437,97 +283,16 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) > return memalign(alignment, size); > } > > -static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > -{ > - int fd = alloc_fd(FTYPE_GNTMAP); > - if ( fd == -1 ) > - return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > - return (xc_osdep_handle)fd; > -} > - > -static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -void minios_gnttab_close_fd(int fd) > -{ > - gntmap_fini(&files[fd].gntmap); > - files[fd].type = FTYPE_NONE; > -} > - > -static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count, int flags, int prot, > - uint32_t *domids, uint32_t *refs, > - uint32_t notify_offset, > - evtchn_port_t notify_port) > -{ > - int fd = (int)h; > - int stride = 1; > - if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > - stride = 0; > - if (notify_offset != -1 || notify_port != -1) { > - errno = ENOSYS; > - return NULL; > - } > - return gntmap_map_grant_refs(&files[fd].gntmap, > - count, domids, stride, > - refs, prot & PROT_WRITE); > -} > - > -static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > - void *start_address, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > - (unsigned long) start_address, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > - uint32_t count) > -{ > - int fd = (int)h; > - int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > - count); > - if (ret < 0) { > - errno = -ret; > - return -1; > - } > - return ret; > -} > - > -static struct xc_osdep_ops minios_gnttab_ops = { > - .open = &minios_gnttab_open, > - .close = &minios_gnttab_close, > - > - .u.gnttab = { > - .grant_map = &minios_gnttab_grant_map, > - .munmap = &minios_gnttab_munmap, > - .set_max_grants = &minios_gnttab_set_max_grants, > - }, > -}; > - > static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum xc_osdep_type type) > { > switch ( type ) > { > case XC_OSDEP_PRIVCMD: > - return &minios_privcmd_ops; > + return &xc_privcmd_ops; > case XC_OSDEP_EVTCHN: > - return &minios_evtchn_ops; > + return &xc_evtchn_ops; > case XC_OSDEP_GNTTAB: > - return &minios_gnttab_ops; > + return &xc_gnttab_ops; > default: > return NULL; > } > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > new file mode 100644 > index 0000000..7766b86 > --- /dev/null > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -0,0 +1,291 @@ > +/****************************************************************************** > + * > + * Copyright 2007-2008 Samuel Thibault <samuel.thibault@eu.citrix.com>. > + * All rights reserved. > + * Use is subject to license terms. > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#undef NDEBUG > +#include "xen-external/bsd-sys-queue.h" > +#include <mini-os/types.h> > +#include <mini-os/os.h> > +#include <mini-os/mm.h> > +#include <mini-os/lib.h> > +#include <mini-os/gntmap.h> > +#include <mini-os/events.h> > +#include <mini-os/wait.h> > +#include <sys/mman.h> > + > +#include <xen/memory.h> > +#include <unistd.h> > +#include <fcntl.h> > +#include <stdio.h> > +#include <assert.h> > +#include <stdint.h> > +#include <inttypes.h> > +#include <malloc.h> > + > +#include "xc_private.h" > + > +#ifdef __RUMPRUN___ > +# define map_frames_ex minios_map_frames_ex > +#endif /* __RUMPRUN__ */ > + > +void minios_interface_close_fd(int fd); > +void minios_gnttab_close_fd(int fd); > + > +static xc_osdep_handle minios_privcmd_open(xc_interface *xch) > +{ > + int fd = alloc_fd(FTYPE_XC); > + > + if ( fd == -1) > + return XC_OSDEP_OPEN_ERROR; > + > + return (xc_osdep_handle)fd; > +} > + > +static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) > +{ > + int fd = (int)h; > + return close(fd); > +} > + > +void minios_interface_close_fd(int fd) > +{ > + files[fd].type = FTYPE_NONE; > +} > + > +static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, > + xc_osdep_handle h, > + int npages) > +{ > + return xc_memalign(xch, PAGE_SIZE, npages * PAGE_SIZE); > +} > + > +static void minios_privcmd_free_hypercall_buffer(xc_interface *xch, > + xc_osdep_handle h, > + void *ptr, int npages) > +{ > + free(ptr); > +} > + > +static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, > + privcmd_hypercall_t *hypercall) > +{ > + multicall_entry_t call; > + int i, ret; > + > + call.op = hypercall->op; > + for (i = 0; i < ARRAY_SIZE(hypercall->arg); i++) > + call.args[i] = hypercall->arg[i]; > + > + ret = HYPERVISOR_multicall(&call, 1); > + > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + if ((long) call.result < 0) { > + errno = - (long) call.result; > + return -1; > + } > + return call.result; > +} > + > +static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, int prot, > + const xen_pfn_t *arr, > + int *err, unsigned int num) > +{ > + unsigned long pt_prot = 0; > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > +} > + > +static void *minios_privcmd_map_foreign_batch(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, int prot, > + xen_pfn_t *arr, int num) > +{ > + unsigned long pt_prot = 0; > + int err[num]; > + int i; > + unsigned long addr; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + addr = (unsigned long) map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); > + for (i = 0; i < num; i++) { > + if (err[i]) > + arr[i] |= 0xF0000000; > + } > + return (void *) addr; > +} > + > +static void *minios_privcmd_map_foreign_range(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, > + int size, int prot, > + unsigned long mfn) > +{ > + unsigned long pt_prot = 0; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + assert(!(size % getpagesize())); > + return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, > + NULL, pt_prot); > +} > + > +static void *minios_privcmd_map_foreign_ranges(xc_interface *xch, > + xc_osdep_handle h, > + uint32_t dom, > + size_t size, int prot, > + size_t chunksize, > + privcmd_mmap_entry_t entries[], > + int nentries) > +{ > + unsigned long *mfns; > + int i, j, n; > + unsigned long pt_prot = 0; > + void *ret; > + > + if (prot & PROT_READ) > + pt_prot = L1_PROT_RO; > + if (prot & PROT_WRITE) > + pt_prot = L1_PROT; > + > + mfns = malloc((size / XC_PAGE_SIZE) * sizeof(*mfns)); > + > + n = 0; > + for (i = 0; i < nentries; i++) > + for (j = 0; j < chunksize / XC_PAGE_SIZE; j++) > + mfns[n++] = entries[i].mfn + j; > + > + ret = map_frames_ex(mfns, n, 1, 0, 1, dom, NULL, pt_prot); > + free(mfns); > + return ret; > +} > + > +struct xc_osdep_ops xc_privcmd_ops = { > + .open = &minios_privcmd_open, > + .close = &minios_privcmd_close, > + > + .u.privcmd = { > + .alloc_hypercall_buffer = &minios_privcmd_alloc_hypercall_buffer, > + .free_hypercall_buffer = &minios_privcmd_free_hypercall_buffer, > + > + .hypercall = &minios_privcmd_hypercall, > + > + .map_foreign_batch = &minios_privcmd_map_foreign_batch, > + .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, > + .map_foreign_range = &minios_privcmd_map_foreign_range, > + .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, > + }, > +}; > + > +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > +{ > + int fd = alloc_fd(FTYPE_GNTMAP); > + if ( fd == -1 ) > + return XC_OSDEP_OPEN_ERROR; > + gntmap_init(&files[fd].gntmap); > + return (xc_osdep_handle)fd; > +} > + > +static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > +{ > + int fd = (int)h; > + return close(fd); > +} > + > +void minios_gnttab_close_fd(int fd) > +{ > + gntmap_fini(&files[fd].gntmap); > + files[fd].type = FTYPE_NONE; > +} > + > +static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > + uint32_t count, int flags, int prot, > + uint32_t *domids, uint32_t *refs, > + uint32_t notify_offset, > + evtchn_port_t notify_port) > +{ > + int fd = (int)h; > + int stride = 1; > + if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > + stride = 0; > + if (notify_offset != -1 || notify_port != -1) { > + errno = ENOSYS; > + return NULL; > + } > + return gntmap_map_grant_refs(&files[fd].gntmap, > + count, domids, stride, > + refs, prot & PROT_WRITE); > +} > + > +static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > + void *start_address, > + uint32_t count) > +{ > + int fd = (int)h; > + int ret; > + ret = gntmap_munmap(&files[fd].gntmap, > + (unsigned long) start_address, > + count); > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + return ret; > +} > + > +static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > + uint32_t count) > +{ > + int fd = (int)h; > + int ret; > + ret = gntmap_set_max_grants(&files[fd].gntmap, > + count); > + if (ret < 0) { > + errno = -ret; > + return -1; > + } > + return ret; > +} > + > +struct xc_osdep_ops xc_gnttab_ops = { > + .open = &minios_gnttab_open, > + .close = &minios_gnttab_close, > + > + .u.gnttab = { > + .grant_map = &minios_gnttab_grant_map, > + .munmap = &minios_gnttab_munmap, > + .set_max_grants = &minios_gnttab_set_max_grants, > + }, > +}; > + > diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h > index 45b8644..152465f 100644 > --- a/tools/libxc/xc_private.h > +++ b/tools/libxc/xc_private.h > @@ -111,6 +111,9 @@ struct xc_interface_core { > xc_osdep_handle ops_handle; /* opaque data for xc_osdep_ops */ > }; > > +/* Do not use these directly; go via the handle you already have. */ > +extern struct xc_osdep_ops xc_privcmd_ops, xc_evtchn_ops, xc_gnttab_ops; > + > void xc_report_error(xc_interface *xch, int code, const char *fmt, ...) > __attribute__((format(printf,3,4))); > void xc_reportv(xc_interface *xch, xentoollog_logger *lg, xentoollog_level, ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/5] libxc: Split off xc_minios_privcmd.c 2015-03-02 17:31 ` Ian Campbell @ 2015-03-03 15:15 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-03-03 15:15 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:31:53PM +0000, Ian Campbell wrote: > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > We are going to want to use some but not all of the machinery > > previously in xc_minios.c. Split the privcmd and gnttab code into its > > own file. > > Does it make sense to put gnttab code in a file called privcmd.c? > > I don't think there is much of a link between the two, is there? > > I'm not sure which half of this rump libxc is going to want but perhaps > either _common or _standalone would be a better suffix, depending which > way it goes? > I will name it xc_minios_common.c because the factored out code will be used by both mini-os and rump kernel. Wei. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 3/5] libxc: Split off xc_netbsd_user.c 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu 2015-02-26 11:56 ` [PATCH 1/5] NetBSDRump: provide evtchn.h Wei Liu 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu @ 2015-02-26 11:56 ` Wei Liu 2015-03-02 17:33 ` Ian Campbell 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu 2015-02-26 11:56 ` [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info Wei Liu 4 siblings, 1 reply; 23+ messages in thread From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, Ian Jackson, ian.campbell From: Ian Jackson <ian.jackson@eu.citrix.com> We are going to want to use some but not all of the machinery previously in xc_netbsd.c Split the evtchn and ancillary code into its own file. This part is pure code motion. But we also have to alter the Makefile, and rename some symbols, as with xc_minios*.c. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- tools/libxc/Makefile | 2 +- tools/libxc/xc_netbsd.c | 168 +------------------------------------ tools/libxc/xc_netbsd_user.c | 196 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 168 deletions(-) create mode 100644 tools/libxc/xc_netbsd_user.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 4ace2b6..0f3396c 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -46,7 +46,7 @@ CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c -CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c +CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c xc_netbsd_user.c CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c GUEST_SRCS-y := diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c index 8a90ef3..f940607 100644 --- a/tools/libxc/xc_netbsd.c +++ b/tools/libxc/xc_netbsd.c @@ -224,172 +224,6 @@ static struct xc_osdep_ops netbsd_privcmd_ops = { }, }; -#define EVTCHN_DEV_NAME "/dev/xenevt" - -static xc_osdep_handle netbsd_evtchn_open(xc_evtchn *xce) -{ - int fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); - if ( fd == -1 ) - return XC_OSDEP_OPEN_ERROR; - - return (xc_osdep_handle)fd; -} - -static int netbsd_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) -{ - int fd = (int)h; - return close(fd); -} - -static int netbsd_evtchn_fd(xc_evtchn *xce, xc_osdep_handle h) -{ - return (int)h; -} - -static int netbsd_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) -{ - int fd = (int)h; - struct ioctl_evtchn_notify notify; - - notify.port = port; - - return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); -} - -static evtchn_port_or_error_t -netbsd_evtchn_bind_unbound_port(xc_evtchn * xce, xc_osdep_handle h, int domid) -{ - int fd = (int)h; - struct ioctl_evtchn_bind_unbound_port bind; - int ret; - - bind.remote_domain = domid; - - ret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); - if (ret == 0) - return bind.port; - else - return -1; -} - -static evtchn_port_or_error_t -netbsd_evtchn_bind_interdomain(xc_evtchn *xce, xc_osdep_handle h, int domid, - evtchn_port_t remote_port) -{ - int fd = (int)h; - struct ioctl_evtchn_bind_interdomain bind; - int ret; - - bind.remote_domain = domid; - bind.remote_port = remote_port; - - ret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); - if (ret == 0) - return bind.port; - else - return -1; -} - -static int netbsd_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) -{ - int fd = (int)h; - struct ioctl_evtchn_unbind unbind; - - unbind.port = port; - - return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); -} - -static evtchn_port_or_error_t -netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq) -{ - int fd = (int)h; - struct ioctl_evtchn_bind_virq bind; - int err; - - bind.virq = virq; - - err = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); - if (err) - return -1; - else - return bind.port; -} - -static evtchn_port_or_error_t -netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h) -{ - int fd = (int)h; - evtchn_port_t port; - - if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) - return -1; - - return port; -} - -static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) -{ - int fd = (int)h; - return write_exact(fd, (char *)&port, sizeof(port)); -} - -static struct xc_osdep_ops netbsd_evtchn_ops = { - .open = &netbsd_evtchn_open, - .close = &netbsd_evtchn_close, - - .u.evtchn = { - .fd = &netbsd_evtchn_fd, - .notify = &netbsd_evtchn_notify, - .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, - .bind_interdomain = &netbsd_evtchn_bind_interdomain, - .bind_virq = &netbsd_evtchn_bind_virq, - .unbind = &netbsd_evtchn_unbind, - .pending = &netbsd_evtchn_pending, - .unmask = &netbsd_evtchn_unmask, - }, -}; - -/* Optionally flush file to disk and discard page cache */ -void discard_file_cache(xc_interface *xch, int fd, int flush) -{ - off_t cur = 0; - int saved_errno = errno; - - if ( flush && (fsync(fd) < 0) ) - { - /*PERROR("Failed to flush file: %s", strerror(errno));*/ - goto out; - } - - /* - * Calculate last page boundry of amount written so far - * unless we are flushing in which case entire cache - * is discarded. - */ - if ( !flush ) - { - if ( ( cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 ) - cur = 0; - cur &= ~(PAGE_SIZE - 1); - } - - /* Discard from the buffer cache. */ - if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 ) - { - /*PERROR("Failed to discard cache: %s", strerror(errno));*/ - goto out; - } - - out: - errno = saved_errno; -} - -void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) -{ - return valloc(size); -} - static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_type type) { switch ( type ) @@ -397,7 +231,7 @@ static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_t case XC_OSDEP_PRIVCMD: return &netbsd_privcmd_ops; case XC_OSDEP_EVTCHN: - return &netbsd_evtchn_ops; + return &xc_evtchn_ops; default: return NULL; } diff --git a/tools/libxc/xc_netbsd_user.c b/tools/libxc/xc_netbsd_user.c new file mode 100644 index 0000000..b5c2491 --- /dev/null +++ b/tools/libxc/xc_netbsd_user.c @@ -0,0 +1,196 @@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * xc_gnttab functions: + * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "xc_private.h" + +#include <xen/sys/evtchn.h> +#include <unistd.h> +#include <fcntl.h> +#include <malloc.h> +#include <sys/mman.h> + +#define EVTCHN_DEV_NAME "/dev/xenevt" + +static xc_osdep_handle netbsd_evtchn_open(xc_evtchn *xce) +{ + int fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); + if ( fd == -1 ) + return XC_OSDEP_OPEN_ERROR; + + return (xc_osdep_handle)fd; +} + +static int netbsd_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) +{ + int fd = (int)h; + return close(fd); +} + +static int netbsd_evtchn_fd(xc_evtchn *xce, xc_osdep_handle h) +{ + return (int)h; +} + +static int netbsd_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) +{ + int fd = (int)h; + struct ioctl_evtchn_notify notify; + + notify.port = port; + + return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); +} + +static evtchn_port_or_error_t +netbsd_evtchn_bind_unbound_port(xc_evtchn * xce, xc_osdep_handle h, int domid) +{ + int fd = (int)h; + struct ioctl_evtchn_bind_unbound_port bind; + int ret; + + bind.remote_domain = domid; + + ret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); + if (ret == 0) + return bind.port; + else + return -1; +} + +static evtchn_port_or_error_t +netbsd_evtchn_bind_interdomain(xc_evtchn *xce, xc_osdep_handle h, int domid, + evtchn_port_t remote_port) +{ + int fd = (int)h; + struct ioctl_evtchn_bind_interdomain bind; + int ret; + + bind.remote_domain = domid; + bind.remote_port = remote_port; + + ret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); + if (ret == 0) + return bind.port; + else + return -1; +} + +static int netbsd_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) +{ + int fd = (int)h; + struct ioctl_evtchn_unbind unbind; + + unbind.port = port; + + return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); +} + +static evtchn_port_or_error_t +netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq) +{ + int fd = (int)h; + struct ioctl_evtchn_bind_virq bind; + int err; + + bind.virq = virq; + + err = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); + if (err) + return -1; + else + return bind.port; +} + +static evtchn_port_or_error_t +netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h) +{ + int fd = (int)h; + evtchn_port_t port; + + if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) + return -1; + + return port; +} + +static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) +{ + int fd = (int)h; + return write_exact(fd, (char *)&port, sizeof(port)); +} + +struct xc_osdep_ops xc_evtchn_ops = { + .open = &netbsd_evtchn_open, + .close = &netbsd_evtchn_close, + + .u.evtchn = { + .fd = &netbsd_evtchn_fd, + .notify = &netbsd_evtchn_notify, + .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, + .bind_interdomain = &netbsd_evtchn_bind_interdomain, + .bind_virq = &netbsd_evtchn_bind_virq, + .unbind = &netbsd_evtchn_unbind, + .pending = &netbsd_evtchn_pending, + .unmask = &netbsd_evtchn_unmask, + }, +}; + +/* Optionally flush file to disk and discard page cache */ +void discard_file_cache(xc_interface *xch, int fd, int flush) +{ + off_t cur = 0; + int saved_errno = errno; + + if ( flush && (fsync(fd) < 0) ) + { + /*PERROR("Failed to flush file: %s", strerror(errno));*/ + goto out; + } + + /* + * Calculate last page boundry of amount written so far + * unless we are flushing in which case entire cache + * is discarded. + */ + if ( !flush ) + { + if ( ( cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 ) + cur = 0; + cur &= ~(PAGE_SIZE - 1); + } + + /* Discard from the buffer cache. */ + if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 ) + { + /*PERROR("Failed to discard cache: %s", strerror(errno));*/ + goto out; + } + + out: + errno = saved_errno; +} + +void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) +{ + return valloc(size); +} -- 1.9.1 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 3/5] libxc: Split off xc_netbsd_user.c 2015-02-26 11:56 ` [PATCH 3/5] libxc: Split off xc_netbsd_user.c Wei Liu @ 2015-03-02 17:33 ` Ian Campbell 2015-03-03 15:20 ` Wei Liu 0 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:33 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to use some but not all of the machinery > previously in xc_netbsd.c Split the evtchn and ancillary code into its > own file. This part is pure code motion. Why not xc_netbsd_evtchn? > But we also have to alter the Makefile, and rename some symbols, as > with xc_minios*.c. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > --- > tools/libxc/Makefile | 2 +- > tools/libxc/xc_netbsd.c | 168 +------------------------------------ > tools/libxc/xc_netbsd_user.c | 196 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 198 insertions(+), 168 deletions(-) > create mode 100644 tools/libxc/xc_netbsd_user.c > > diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile > index 4ace2b6..0f3396c 100644 > --- a/tools/libxc/Makefile > +++ b/tools/libxc/Makefile > @@ -46,7 +46,7 @@ CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c > CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c > CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c > CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c > -CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c > +CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c xc_netbsd_user.c > CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c > > GUEST_SRCS-y := > diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c > index 8a90ef3..f940607 100644 > --- a/tools/libxc/xc_netbsd.c > +++ b/tools/libxc/xc_netbsd.c > @@ -224,172 +224,6 @@ static struct xc_osdep_ops netbsd_privcmd_ops = { > }, > }; > > -#define EVTCHN_DEV_NAME "/dev/xenevt" > - > -static xc_osdep_handle netbsd_evtchn_open(xc_evtchn *xce) > -{ > - int fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); > - if ( fd == -1 ) > - return XC_OSDEP_OPEN_ERROR; > - > - return (xc_osdep_handle)fd; > -} > - > -static int netbsd_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) > -{ > - int fd = (int)h; > - return close(fd); > -} > - > -static int netbsd_evtchn_fd(xc_evtchn *xce, xc_osdep_handle h) > -{ > - return (int)h; > -} > - > -static int netbsd_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > -{ > - int fd = (int)h; > - struct ioctl_evtchn_notify notify; > - > - notify.port = port; > - > - return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); > -} > - > -static evtchn_port_or_error_t > -netbsd_evtchn_bind_unbound_port(xc_evtchn * xce, xc_osdep_handle h, int domid) > -{ > - int fd = (int)h; > - struct ioctl_evtchn_bind_unbound_port bind; > - int ret; > - > - bind.remote_domain = domid; > - > - ret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); > - if (ret == 0) > - return bind.port; > - else > - return -1; > -} > - > -static evtchn_port_or_error_t > -netbsd_evtchn_bind_interdomain(xc_evtchn *xce, xc_osdep_handle h, int domid, > - evtchn_port_t remote_port) > -{ > - int fd = (int)h; > - struct ioctl_evtchn_bind_interdomain bind; > - int ret; > - > - bind.remote_domain = domid; > - bind.remote_port = remote_port; > - > - ret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); > - if (ret == 0) > - return bind.port; > - else > - return -1; > -} > - > -static int netbsd_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > -{ > - int fd = (int)h; > - struct ioctl_evtchn_unbind unbind; > - > - unbind.port = port; > - > - return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); > -} > - > -static evtchn_port_or_error_t > -netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq) > -{ > - int fd = (int)h; > - struct ioctl_evtchn_bind_virq bind; > - int err; > - > - bind.virq = virq; > - > - err = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); > - if (err) > - return -1; > - else > - return bind.port; > -} > - > -static evtchn_port_or_error_t > -netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h) > -{ > - int fd = (int)h; > - evtchn_port_t port; > - > - if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) > - return -1; > - > - return port; > -} > - > -static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > -{ > - int fd = (int)h; > - return write_exact(fd, (char *)&port, sizeof(port)); > -} > - > -static struct xc_osdep_ops netbsd_evtchn_ops = { > - .open = &netbsd_evtchn_open, > - .close = &netbsd_evtchn_close, > - > - .u.evtchn = { > - .fd = &netbsd_evtchn_fd, > - .notify = &netbsd_evtchn_notify, > - .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, > - .bind_interdomain = &netbsd_evtchn_bind_interdomain, > - .bind_virq = &netbsd_evtchn_bind_virq, > - .unbind = &netbsd_evtchn_unbind, > - .pending = &netbsd_evtchn_pending, > - .unmask = &netbsd_evtchn_unmask, > - }, > -}; > - > -/* Optionally flush file to disk and discard page cache */ > -void discard_file_cache(xc_interface *xch, int fd, int flush) > -{ > - off_t cur = 0; > - int saved_errno = errno; > - > - if ( flush && (fsync(fd) < 0) ) > - { > - /*PERROR("Failed to flush file: %s", strerror(errno));*/ > - goto out; > - } > - > - /* > - * Calculate last page boundry of amount written so far > - * unless we are flushing in which case entire cache > - * is discarded. > - */ > - if ( !flush ) > - { > - if ( ( cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 ) > - cur = 0; > - cur &= ~(PAGE_SIZE - 1); > - } > - > - /* Discard from the buffer cache. */ > - if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 ) > - { > - /*PERROR("Failed to discard cache: %s", strerror(errno));*/ > - goto out; > - } > - > - out: > - errno = saved_errno; > -} > - > -void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) > -{ > - return valloc(size); > -} > - > static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_type type) > { > switch ( type ) > @@ -397,7 +231,7 @@ static struct xc_osdep_ops *netbsd_osdep_init(xc_interface *xch, enum xc_osdep_t > case XC_OSDEP_PRIVCMD: > return &netbsd_privcmd_ops; > case XC_OSDEP_EVTCHN: > - return &netbsd_evtchn_ops; > + return &xc_evtchn_ops; > default: > return NULL; > } > diff --git a/tools/libxc/xc_netbsd_user.c b/tools/libxc/xc_netbsd_user.c > new file mode 100644 > index 0000000..b5c2491 > --- /dev/null > +++ b/tools/libxc/xc_netbsd_user.c > @@ -0,0 +1,196 @@ > +/****************************************************************************** > + * > + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + * > + * xc_gnttab functions: > + * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk> > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "xc_private.h" > + > +#include <xen/sys/evtchn.h> > +#include <unistd.h> > +#include <fcntl.h> > +#include <malloc.h> > +#include <sys/mman.h> > + > +#define EVTCHN_DEV_NAME "/dev/xenevt" > + > +static xc_osdep_handle netbsd_evtchn_open(xc_evtchn *xce) > +{ > + int fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); > + if ( fd == -1 ) > + return XC_OSDEP_OPEN_ERROR; > + > + return (xc_osdep_handle)fd; > +} > + > +static int netbsd_evtchn_close(xc_evtchn *xce, xc_osdep_handle h) > +{ > + int fd = (int)h; > + return close(fd); > +} > + > +static int netbsd_evtchn_fd(xc_evtchn *xce, xc_osdep_handle h) > +{ > + return (int)h; > +} > + > +static int netbsd_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > +{ > + int fd = (int)h; > + struct ioctl_evtchn_notify notify; > + > + notify.port = port; > + > + return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); > +} > + > +static evtchn_port_or_error_t > +netbsd_evtchn_bind_unbound_port(xc_evtchn * xce, xc_osdep_handle h, int domid) > +{ > + int fd = (int)h; > + struct ioctl_evtchn_bind_unbound_port bind; > + int ret; > + > + bind.remote_domain = domid; > + > + ret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); > + if (ret == 0) > + return bind.port; > + else > + return -1; > +} > + > +static evtchn_port_or_error_t > +netbsd_evtchn_bind_interdomain(xc_evtchn *xce, xc_osdep_handle h, int domid, > + evtchn_port_t remote_port) > +{ > + int fd = (int)h; > + struct ioctl_evtchn_bind_interdomain bind; > + int ret; > + > + bind.remote_domain = domid; > + bind.remote_port = remote_port; > + > + ret = ioctl(fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind); > + if (ret == 0) > + return bind.port; > + else > + return -1; > +} > + > +static int netbsd_evtchn_unbind(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > +{ > + int fd = (int)h; > + struct ioctl_evtchn_unbind unbind; > + > + unbind.port = port; > + > + return ioctl(fd, IOCTL_EVTCHN_UNBIND, &unbind); > +} > + > +static evtchn_port_or_error_t > +netbsd_evtchn_bind_virq(xc_evtchn *xce, xc_osdep_handle h, unsigned int virq) > +{ > + int fd = (int)h; > + struct ioctl_evtchn_bind_virq bind; > + int err; > + > + bind.virq = virq; > + > + err = ioctl(fd, IOCTL_EVTCHN_BIND_VIRQ, &bind); > + if (err) > + return -1; > + else > + return bind.port; > +} > + > +static evtchn_port_or_error_t > +netbsd_evtchn_pending(xc_evtchn *xce, xc_osdep_handle h) > +{ > + int fd = (int)h; > + evtchn_port_t port; > + > + if ( read_exact(fd, (char *)&port, sizeof(port)) == -1 ) > + return -1; > + > + return port; > +} > + > +static int netbsd_evtchn_unmask(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port) > +{ > + int fd = (int)h; > + return write_exact(fd, (char *)&port, sizeof(port)); > +} > + > +struct xc_osdep_ops xc_evtchn_ops = { > + .open = &netbsd_evtchn_open, > + .close = &netbsd_evtchn_close, > + > + .u.evtchn = { > + .fd = &netbsd_evtchn_fd, > + .notify = &netbsd_evtchn_notify, > + .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, > + .bind_interdomain = &netbsd_evtchn_bind_interdomain, > + .bind_virq = &netbsd_evtchn_bind_virq, > + .unbind = &netbsd_evtchn_unbind, > + .pending = &netbsd_evtchn_pending, > + .unmask = &netbsd_evtchn_unmask, > + }, > +}; > + > +/* Optionally flush file to disk and discard page cache */ > +void discard_file_cache(xc_interface *xch, int fd, int flush) > +{ > + off_t cur = 0; > + int saved_errno = errno; > + > + if ( flush && (fsync(fd) < 0) ) > + { > + /*PERROR("Failed to flush file: %s", strerror(errno));*/ > + goto out; > + } > + > + /* > + * Calculate last page boundry of amount written so far > + * unless we are flushing in which case entire cache > + * is discarded. > + */ > + if ( !flush ) > + { > + if ( ( cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 ) > + cur = 0; > + cur &= ~(PAGE_SIZE - 1); > + } > + > + /* Discard from the buffer cache. */ > + if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 ) > + { > + /*PERROR("Failed to discard cache: %s", strerror(errno));*/ > + goto out; > + } > + > + out: > + errno = saved_errno; > +} > + > +void *xc_memalign(xc_interface *xch, size_t alignment, size_t size) > +{ > + return valloc(size); > +} ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/5] libxc: Split off xc_netbsd_user.c 2015-03-02 17:33 ` Ian Campbell @ 2015-03-03 15:20 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-03-03 15:20 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:33:13PM +0000, Ian Campbell wrote: > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > We are going to want to use some but not all of the machinery > > previously in xc_netbsd.c Split the evtchn and ancillary code into its > > own file. This part is pure code motion. > > Why not xc_netbsd_evtchn? > Ack. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu ` (2 preceding siblings ...) 2015-02-26 11:56 ` [PATCH 3/5] libxc: Split off xc_netbsd_user.c Wei Liu @ 2015-02-26 11:56 ` Wei Liu 2015-02-26 12:47 ` Jürgen Groß ` (2 more replies) 2015-02-26 11:56 ` [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info Wei Liu 4 siblings, 3 replies; 23+ messages in thread From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, Ian Jackson, ian.campbell From: Ian Jackson <ian.jackson@eu.citrix.com> We are going to want to reuse this code for NetBSD rump kernels, where there is no gntmap device and we just want to call the MiniOS gntmap code directly. As part of this we want to abstract away the use of files[] inside the actual functions. Do this with a #define whose definition we are going to make conditional in just a moment. No functional change in this patch. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c index 7766b86..27d9076 100644 --- a/tools/libxc/xc_minios_privcmd.c +++ b/tools/libxc/xc_minios_privcmd.c @@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops = { }, }; +#define GNTMAP(h) (files[(int)(h)].gntmap) + static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) { int fd = alloc_fd(FTYPE_GNTMAP); if ( fd == -1 ) return XC_OSDEP_OPEN_ERROR; - gntmap_init(&files[fd].gntmap); + gntmap_init(&GNTMAP(h)); return (xc_osdep_handle)fd; } @@ -225,7 +227,7 @@ static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) void minios_gnttab_close_fd(int fd) { - gntmap_fini(&files[fd].gntmap); + gntmap_fini(&GNTMAP(h)); files[fd].type = FTYPE_NONE; } @@ -235,7 +237,6 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, uint32_t notify_offset, evtchn_port_t notify_port) { - int fd = (int)h; int stride = 1; if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) stride = 0; @@ -243,7 +244,7 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, errno = ENOSYS; return NULL; } - return gntmap_map_grant_refs(&files[fd].gntmap, + return gntmap_map_grant_refs(&GNTMAP(h), count, domids, stride, refs, prot & PROT_WRITE); } @@ -252,9 +253,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, void *start_address, uint32_t count) { - int fd = (int)h; int ret; - ret = gntmap_munmap(&files[fd].gntmap, + ret = gntmap_munmap(&GNTMAP(h), (unsigned long) start_address, count); if (ret < 0) { @@ -267,9 +267,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, uint32_t count) { - int fd = (int)h; int ret; - ret = gntmap_set_max_grants(&files[fd].gntmap, + ret = gntmap_set_max_grants(&GNTMAP(h), count); if (ret < 0) { errno = -ret; -- 1.9.1 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu @ 2015-02-26 12:47 ` Jürgen Groß 2015-02-26 12:56 ` Wei Liu 2015-02-26 13:10 ` Samuel Thibault 2015-03-02 17:34 ` Ian Campbell 2 siblings, 1 reply; 23+ messages in thread From: Jürgen Groß @ 2015-02-26 12:47 UTC (permalink / raw) To: Wei Liu, xen-devel; +Cc: Ian Jackson, ian.campbell On 02/26/2015 12:56 PM, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to reuse this code for NetBSD rump kernels, where > there is no gntmap device and we just want to call the MiniOS gntmap > code directly. > > As part of this we want to abstract away the use of files[] inside the > actual functions. Do this with a #define whose definition we are > going to make conditional in just a moment. > > No functional change in this patch. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > --- > tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > index 7766b86..27d9076 100644 > --- a/tools/libxc/xc_minios_privcmd.c > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops = { > }, > }; > > +#define GNTMAP(h) (files[(int)(h)].gntmap) > + > static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > { > int fd = alloc_fd(FTYPE_GNTMAP); > if ( fd == -1 ) > return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > + gntmap_init(&GNTMAP(h)); GNTMAP(fd)? Same multiple times below. Juergen > return (xc_osdep_handle)fd; > } > > @@ -225,7 +227,7 @@ static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > > void minios_gnttab_close_fd(int fd) > { > - gntmap_fini(&files[fd].gntmap); > + gntmap_fini(&GNTMAP(h)); > files[fd].type = FTYPE_NONE; > } > > @@ -235,7 +237,6 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t notify_offset, > evtchn_port_t notify_port) > { > - int fd = (int)h; > int stride = 1; > if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > stride = 0; > @@ -243,7 +244,7 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > errno = ENOSYS; > return NULL; > } > - return gntmap_map_grant_refs(&files[fd].gntmap, > + return gntmap_map_grant_refs(&GNTMAP(h), > count, domids, stride, > refs, prot & PROT_WRITE); > } > @@ -252,9 +253,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > void *start_address, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > + ret = gntmap_munmap(&GNTMAP(h), > (unsigned long) start_address, > count); > if (ret < 0) { > @@ -267,9 +267,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > + ret = gntmap_set_max_grants(&GNTMAP(h), > count); > if (ret < 0) { > errno = -ret; > ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-02-26 12:47 ` Jürgen Groß @ 2015-02-26 12:56 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-02-26 12:56 UTC (permalink / raw) To: Jürgen Groß; +Cc: Ian Jackson, Wei Liu, ian.campbell, xen-devel On Thu, Feb 26, 2015 at 01:47:47PM +0100, Jürgen Groß wrote: > On 02/26/2015 12:56 PM, Wei Liu wrote: > >From: Ian Jackson <ian.jackson@eu.citrix.com> > > > >We are going to want to reuse this code for NetBSD rump kernels, where > >there is no gntmap device and we just want to call the MiniOS gntmap > >code directly. > > > >As part of this we want to abstract away the use of files[] inside the > >actual functions. Do this with a #define whose definition we are > >going to make conditional in just a moment. > > > >No functional change in this patch. > > > >Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > >--- > > tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- > > 1 file changed, 7 insertions(+), 8 deletions(-) > > > >diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > >index 7766b86..27d9076 100644 > >--- a/tools/libxc/xc_minios_privcmd.c > >+++ b/tools/libxc/xc_minios_privcmd.c > >@@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops = { > > }, > > }; > > > >+#define GNTMAP(h) (files[(int)(h)].gntmap) > >+ > > static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > > { > > int fd = alloc_fd(FTYPE_GNTMAP); > > if ( fd == -1 ) > > return XC_OSDEP_OPEN_ERROR; > >- gntmap_init(&files[fd].gntmap); > >+ gntmap_init(&GNTMAP(h)); > > GNTMAP(fd)? > > Same multiple times below. > Good catch. I will fix this, thanks. Wei. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu 2015-02-26 12:47 ` Jürgen Groß @ 2015-02-26 13:10 ` Samuel Thibault 2015-03-02 17:34 ` Ian Campbell 2 siblings, 0 replies; 23+ messages in thread From: Samuel Thibault @ 2015-02-26 13:10 UTC (permalink / raw) To: Wei Liu; +Cc: Ian Jackson, ian.campbell, xen-devel Wei Liu, le Thu 26 Feb 2015 11:56:20 +0000, a écrit : > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to reuse this code for NetBSD rump kernels, where > there is no gntmap device and we just want to call the MiniOS gntmap > code directly. > > As part of this we want to abstract away the use of files[] inside the > actual functions. Do this with a #define whose definition we are > going to make conditional in just a moment. > > No functional change in this patch. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > --- > tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > index 7766b86..27d9076 100644 > --- a/tools/libxc/xc_minios_privcmd.c > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops = { > }, > }; > > +#define GNTMAP(h) (files[(int)(h)].gntmap) > + > static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > { > int fd = alloc_fd(FTYPE_GNTMAP); > if ( fd == -1 ) > return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > + gntmap_init(&GNTMAP(h)); > return (xc_osdep_handle)fd; > } > > @@ -225,7 +227,7 @@ static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > > void minios_gnttab_close_fd(int fd) > { > - gntmap_fini(&files[fd].gntmap); > + gntmap_fini(&GNTMAP(h)); > files[fd].type = FTYPE_NONE; > } > > @@ -235,7 +237,6 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t notify_offset, > evtchn_port_t notify_port) > { > - int fd = (int)h; > int stride = 1; > if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > stride = 0; > @@ -243,7 +244,7 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > errno = ENOSYS; > return NULL; > } > - return gntmap_map_grant_refs(&files[fd].gntmap, > + return gntmap_map_grant_refs(&GNTMAP(h), > count, domids, stride, > refs, prot & PROT_WRITE); > } > @@ -252,9 +253,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > void *start_address, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > + ret = gntmap_munmap(&GNTMAP(h), > (unsigned long) start_address, > count); > if (ret < 0) { > @@ -267,9 +267,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > + ret = gntmap_set_max_grants(&GNTMAP(h), > count); > if (ret < 0) { > errno = -ret; > -- > 1.9.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > -- Samuel I am the "ILOVEGNU" signature virus. Just copy me to your signature. This email was infected under the terms of the GNU General Public License. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu 2015-02-26 12:47 ` Jürgen Groß 2015-02-26 13:10 ` Samuel Thibault @ 2015-03-02 17:34 ` Ian Campbell 2015-03-02 17:37 ` Wei Liu 2 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:34 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > From: Ian Jackson <ian.jackson@eu.citrix.com> > > We are going to want to reuse this code for NetBSD rump kernels, where > there is no gntmap device and we just want to call the MiniOS gntmap > code directly. > > As part of this we want to abstract away the use of files[] inside the > actual functions. Do this with a #define whose definition we are > going to make conditional in just a moment. > > No functional change in this patch. > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Wei -- did you not want to Ack- or S-o-b this yourself? > --- > tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c > index 7766b86..27d9076 100644 > --- a/tools/libxc/xc_minios_privcmd.c > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops = { > }, > }; > > +#define GNTMAP(h) (files[(int)(h)].gntmap) > + > static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > { > int fd = alloc_fd(FTYPE_GNTMAP); > if ( fd == -1 ) > return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > + gntmap_init(&GNTMAP(h)); > return (xc_osdep_handle)fd; > } > > @@ -225,7 +227,7 @@ static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) > > void minios_gnttab_close_fd(int fd) > { > - gntmap_fini(&files[fd].gntmap); > + gntmap_fini(&GNTMAP(h)); > files[fd].type = FTYPE_NONE; > } > > @@ -235,7 +237,6 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t notify_offset, > evtchn_port_t notify_port) > { > - int fd = (int)h; > int stride = 1; > if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > stride = 0; > @@ -243,7 +244,7 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, > errno = ENOSYS; > return NULL; > } > - return gntmap_map_grant_refs(&files[fd].gntmap, > + return gntmap_map_grant_refs(&GNTMAP(h), > count, domids, stride, > refs, prot & PROT_WRITE); > } > @@ -252,9 +253,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > void *start_address, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_munmap(&files[fd].gntmap, > + ret = gntmap_munmap(&GNTMAP(h), > (unsigned long) start_address, > count); > if (ret < 0) { > @@ -267,9 +267,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, > static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle h, > uint32_t count) > { > - int fd = (int)h; > int ret; > - ret = gntmap_set_max_grants(&files[fd].gntmap, > + ret = gntmap_set_max_grants(&GNTMAP(h), > count); > if (ret < 0) { > errno = -ret; ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] 2015-03-02 17:34 ` Ian Campbell @ 2015-03-02 17:37 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-03-02 17:37 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:34:32PM +0000, Ian Campbell wrote: > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > From: Ian Jackson <ian.jackson@eu.citrix.com> > > > > We are going to want to reuse this code for NetBSD rump kernels, where > > there is no gntmap device and we just want to call the MiniOS gntmap > > code directly. > > > > As part of this we want to abstract away the use of files[] inside the > > actual functions. Do this with a #define whose definition we are > > going to make conditional in just a moment. > > > > No functional change in this patch. > > > > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > > Wei -- did you not want to Ack- or S-o-b this yourself? > I forgot to do that. Sorry. It will have my S-o-B in next version because I will fix a bug in this patch. Wei. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu ` (3 preceding siblings ...) 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu @ 2015-02-26 11:56 ` Wei Liu 2015-03-02 17:36 ` Ian Campbell 4 siblings, 1 reply; 23+ messages in thread From: Wei Liu @ 2015-02-26 11:56 UTC (permalink / raw) To: xen-devel; +Cc: wei.liu2, Ian Jackson, ian.campbell From: Ian Jackson <ian.jackson@eu.citrix.com> This allows programs which use the bulk of libxc to link. We use /dev/xenevt for event channels, the raw minios functions for privcmd and gnttab, and the netbsd versions of discard_file_cache and xc_memalign. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> [ wei: wrap long lines, adapt to changes in previous patch ] Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- tools/libxc/Makefile | 2 ++ tools/libxc/xc_minios_privcmd.c | 36 +++++++++++++++++++++-- tools/libxc/xc_netbsd_rumpkern.c | 62 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 tools/libxc/xc_netbsd_rumpkern.c diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index 0f3396c..bce2dd2 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -48,6 +48,8 @@ CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c xc_freebsd_osdep.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c xc_netbsd_user.c CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c xc_minios_privcmd.c +CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd_rumpkern.c xc_netbsd_user.c +CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_minios_privcmd.c GUEST_SRCS-y := GUEST_SRCS-y += xg_private.c xc_suspend.c diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_privcmd.c index 27d9076..a8b1102 100644 --- a/tools/libxc/xc_minios_privcmd.c +++ b/tools/libxc/xc_minios_privcmd.c @@ -41,9 +41,19 @@ #include "xc_private.h" -#ifdef __RUMPRUN___ +#ifdef __RUMPRUN__ # define map_frames_ex minios_map_frames_ex -#endif /* __RUMPRUN__ */ + +static xc_osdep_handle minios_privcmd_open(xc_interface *xch) +{ + return 1; +} +static int minios_privcmd_close(xc_interface *xch, xc_osdep_handle h) +{ + return 0; +} + +#else /* !__RUMPRUN__ */ void minios_interface_close_fd(int fd); void minios_gnttab_close_fd(int fd); @@ -69,6 +79,8 @@ void minios_interface_close_fd(int fd) files[fd].type = FTYPE_NONE; } +#endif /* !__RUMPRUN__ */ + static void *minios_privcmd_alloc_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, int npages) @@ -208,6 +220,24 @@ struct xc_osdep_ops xc_privcmd_ops = { }, }; +#ifdef __RUMPRUN__ + +static struct gntmap static_gntmap; + +#define GNTMAP(h) static_gntmap + +static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) +{ + return 1; +} + +static int minios_gnttab_close(xc_gnttab *xcg, xc_osdep_handle h) +{ + return 0; +} + +#else /* !__RUMPRUN__ */ + #define GNTMAP(h) (files[(int)(h)].gntmap) static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) @@ -231,6 +261,8 @@ void minios_gnttab_close_fd(int fd) files[fd].type = FTYPE_NONE; } +#endif /* !__RUMPRUN__ */ + static void *minios_gnttab_grant_map(xc_gnttab *xcg, xc_osdep_handle h, uint32_t count, int flags, int prot, uint32_t *domids, uint32_t *refs, diff --git a/tools/libxc/xc_netbsd_rumpkern.c b/tools/libxc/xc_netbsd_rumpkern.c new file mode 100644 index 0000000..11d4a63 --- /dev/null +++ b/tools/libxc/xc_netbsd_rumpkern.c @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright 2013 Citrix. + * Use is subject to license terms. + * + * xc_gnttab functions: + * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "xc_private.h" + +#include <xen/sys/evtchn.h> +#include <unistd.h> +#include <fcntl.h> +#include <malloc.h> +#include <sys/mman.h> + +static struct xc_osdep_ops *rumpxen_osdep_init(xc_interface *xch, + enum xc_osdep_type type) +{ + switch ( type ) + { + case XC_OSDEP_PRIVCMD: + return &xc_privcmd_ops; + case XC_OSDEP_EVTCHN: + return &xc_evtchn_ops; + case XC_OSDEP_GNTTAB: + return &xc_gnttab_ops; + default: + return NULL; + } +} + +xc_osdep_info_t xc_osdep_info = { + .name = "Rump kernel OS interface", + .init = &rumpxen_osdep_init, + .fake = 0, +}; + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ -- 1.9.1 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info 2015-02-26 11:56 ` [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info Wei Liu @ 2015-03-02 17:36 ` Ian Campbell 2015-03-03 15:36 ` Wei Liu 0 siblings, 1 reply; 23+ messages in thread From: Ian Campbell @ 2015-03-02 17:36 UTC (permalink / raw) To: Wei Liu; +Cc: ian.jackson, xen-devel On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > diff --git a/tools/libxc/xc_netbsd_rumpkern.c b/tools/libxc/xc_netbsd_rumpkern.c > new file mode 100644 > index 0000000..11d4a63 > --- /dev/null > +++ b/tools/libxc/xc_netbsd_rumpkern.c > @@ -0,0 +1,62 @@ > +/****************************************************************************** > + * > + * Copyright 2013 Citrix. > + * Use is subject to license terms. > + * > + * xc_gnttab functions: > + * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk> It doesn't seem like any of that remains. In fact I suspect this is just a cut-and-paste error? ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info 2015-03-02 17:36 ` Ian Campbell @ 2015-03-03 15:36 ` Wei Liu 0 siblings, 0 replies; 23+ messages in thread From: Wei Liu @ 2015-03-03 15:36 UTC (permalink / raw) To: Ian Campbell; +Cc: ian.jackson, Wei Liu, xen-devel On Mon, Mar 02, 2015 at 05:36:33PM +0000, Ian Campbell wrote: > On Thu, 2015-02-26 at 11:56 +0000, Wei Liu wrote: > > diff --git a/tools/libxc/xc_netbsd_rumpkern.c b/tools/libxc/xc_netbsd_rumpkern.c > > new file mode 100644 > > index 0000000..11d4a63 > > --- /dev/null > > +++ b/tools/libxc/xc_netbsd_rumpkern.c > > @@ -0,0 +1,62 @@ > > +/****************************************************************************** > > + * > > + * Copyright 2013 Citrix. > > + * Use is subject to license terms. > > + * > > + * xc_gnttab functions: > > + * Copyright (c) 2007-2008, D G Murray <Derek.Murray@cl.cam.ac.uk> > > It doesn't seem like any of that remains. In fact I suspect this is just > a cut-and-paste error? > Yes, cut-and-paste error. Deleted now. Wei. ^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2015-03-03 15:36 UTC | newest] Thread overview: 23+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-02-26 11:56 [PATCH 0/5] Build libxc on rump kernels Wei Liu 2015-02-26 11:56 ` [PATCH 1/5] NetBSDRump: provide evtchn.h Wei Liu 2015-03-02 17:28 ` Ian Campbell 2015-03-02 17:31 ` Wei Liu 2015-03-02 17:40 ` Ian Campbell 2015-03-02 17:42 ` Wei Liu 2015-02-26 11:56 ` [PATCH 2/5] libxc: Split off xc_minios_privcmd.c Wei Liu 2015-02-26 13:08 ` Wei Liu 2015-02-26 13:09 ` Samuel Thibault 2015-03-02 17:31 ` Ian Campbell 2015-03-03 15:15 ` Wei Liu 2015-02-26 11:56 ` [PATCH 3/5] libxc: Split off xc_netbsd_user.c Wei Liu 2015-03-02 17:33 ` Ian Campbell 2015-03-03 15:20 ` Wei Liu 2015-02-26 11:56 ` [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Wei Liu 2015-02-26 12:47 ` Jürgen Groß 2015-02-26 12:56 ` Wei Liu 2015-02-26 13:10 ` Samuel Thibault 2015-03-02 17:34 ` Ian Campbell 2015-03-02 17:37 ` Wei Liu 2015-02-26 11:56 ` [PATCH 5/5] libxc: rumpxen: Provide xc_osdep_info Wei Liu 2015-03-02 17:36 ` Ian Campbell 2015-03-03 15:36 ` Wei Liu
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.