libs: implement some missing functions on FreeBSD
cover libs: implement some missing functions on FreeBSD
Add support for dm_op, restrict and map resource ioctls on FreeBSD.
Roger Pau Monne (2):
libs/foreignmemory: implement the missing functions on FreeBSD libs/devicemodel: add dm_op support for FreeBSD
tools/include/xen-sys/FreeBSD/privcmd.h | 29 +++++++++++
tools/libs/devicemodel/Makefile | 4 +-
tools/libs/devicemodel/{linux.c => common.c} | 0
tools/libs/foreignmemory/freebsd.c | 51 ++++++++++++++++++++
tools/libs/foreignmemory/private.h | 2 +-
5 files changed, 83 insertions(+), 3 deletions(-)
rename tools/libs/devicemodel/{linux.c => common.c} (100%)Signature · 1 line
2.29.2
PATCH 1/2 libs/foreignmemory: implement the missing functions on FreeBSD
Implement restrict, map resource and unmap resource helpers on FreeBSD.
---
Note the implementation is fairly similar to the Linux one, so could likely be merged with some ifdefary. Note sure it's worth it given that we already have a split file.
--- tools/include/xen-sys/FreeBSD/privcmd.h | 14 +++++++ tools/libs/foreignmemory/freebsd.c | 51 +++++++++++++++++++++++++ tools/libs/foreignmemory/private.h | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-)
tools/include/xen-sys/FreeBSD/privcmd.h +14 -0
@@ -56,9 +56,23 @@ typedef struct privcmd_mmap_entry { unsigned long npages; } privcmd_mmap_entry_t; +struct ioctl_privcmd_mmapresource { +domid_t dom;/* target domain */ +unsigned int type;/* type of resource to map */ +unsigned int id;/* type-specific resource identifier */ +unsigned int idx;/* the index of the initial frame to be mapped */ +unsigned long num;/* number of frames of the resource to be mapped */ +unsigned long addr;/* physical address to map into */ +}; +typedef struct ioctl_privcmd_mmapresource privcmd_mmap_resource_t ; +#define IOCTL_PRIVCMD_HYPERCALL \ _IOWR('E', 0, struct ioctl_privcmd_hypercall)#define IOCTL_PRIVCMD_MMAPBATCH \ _IOWR('E', 1, struct ioctl_privcmd_mmapbatch) +#define IOCTL_PRIVCMD_MMAP_RESOURCE \ + _IOW('E', 2, struct ioctl_privcmd_mmapresource) +#define IOCTL_PRIVCMD_RESTRICT \ + _IOW('E', 4, domid_t)#endif /* !__XEN_PRIVCMD_H__ */
tools/libs/foreignmemory/freebsd.c +51 -0
57 lines not on this page · raw message
tools/libs/foreignmemory/private.h +1 -1
@@ -54,7 +54,7 @@ struct xenforeignmemory_resource_handle {int flags; }; -#ifndef __linux__ +#if !defined(__linux__) && !defined(__FreeBSD__)static inline int osdep_xenforeignmemory_restrict (xenforeignmemory_handle *fmem,domid_t domid) {
Signature · 1 line
2.29.2
PATCH 2/2 libs/devicemodel: add dm_op support for FreeBSD
In reply to Roger Pau MonneThe FreeBSD ioctls have the same fields has the Linux ones, so the same file can be shared between both OSes.
No functional change for OSes different than FreeBSD.
---
tools/include/xen-sys/FreeBSD/privcmd.h | 15 +++++++++++++++
tools/libs/devicemodel/Makefile | 4 ++--
tools/libs/devicemodel/{linux.c => common.c} | 0
3 files changed, 17 insertions(+), 2 deletions(-)
rename tools/libs/devicemodel/{linux.c => common.c} (100%)tools/include/xen-sys/FreeBSD/privcmd.h +15 -0
@@ -66,12 +66,27 @@ struct ioctl_privcmd_mmapresource { };typedef struct ioctl_privcmd_mmapresource privcmd_mmap_resource_t ; +struct privcmd_dmop_buf { +void *uptr;/* pointer to memory (in calling process) */ +size_t size;/* size of the buffer */ +}; +typedef struct privcmd_dmop_buf privcmd_dm_op_buf_t ; + +struct ioctl_privcmd_dmop { +domid_t dom;/* target domain */ +unsigned int num;/* num of buffers */ +const struct privcmd_dmop_buf *ubufs;/* array of buffers */ +}; +typedef struct ioctl_privcmd_dmop privcmd_dm_op_t ; +#define IOCTL_PRIVCMD_HYPERCALL \ _IOWR('E', 0, struct ioctl_privcmd_hypercall)#define IOCTL_PRIVCMD_MMAPBATCH \ _IOWR('E', 1, struct ioctl_privcmd_mmapbatch)#define IOCTL_PRIVCMD_MMAP_RESOURCE \ _IOW('E', 2, struct ioctl_privcmd_mmapresource) +#define IOCTL_PRIVCMD_DM_OP \ + _IOW('E', 3, struct ioctl_privcmd_dmop)#define IOCTL_PRIVCMD_RESTRICT \ _IOW('E', 4, domid_t)
tools/libs/devicemodel/Makefile +2 -2
@@ -5,8 +5,8 @@ MAJOR = 1 MINOR = 3 SRCS-y += core.c -SRCS-$(CONFIG_Linux) += linux.c -SRCS-$(CONFIG_FreeBSD) += compat.c +SRCS-$(CONFIG_Linux) += common.c +SRCS-$(CONFIG_FreeBSD) += common.c SRCS-$(CONFIG_SunOS) += compat.c SRCS-$(CONFIG_NetBSD) += compat.c SRCS-$(CONFIG_MiniOS) += compat.c
tools/libs/devicemodel/common.c renamed from tools/libs/devicemodel/linux.c +0 -0
Signature · 1 line
2.29.2
Quoted 5 lines · Roger Pau Monne
Add support for
dm_op, restrict and map resource ioctls on FreeBSD.Roger Pau Monne (2):
libs/foreignmemory: implement the missing functions on FreeBSD libs/devicemodel: adddm_opsupport for FreeBSD