mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
Commit 8ef5f344d0 "tools/libxendevicemodel: add a call to restrict the
handle" added a function to the devicemodel interface to restrict
operations through the API to a specific domain, where a capable under-
lying privcmd driver exists.
This patch adds similar functionality to the xenforeignmemory API. This
will be necessary (as much as xendevicemodel restriction) for limiting
the scope of device models to specific domains.
NOTE: My patch to the linux kernel [1] added the appropriate checks to
the foreign memory ioctls.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
#ifndef XENFOREIGNMEMORY_PRIVATE_H
|
|
#define XENFOREIGNMEMORY_PRIVATE_H
|
|
|
|
#include <xentoollog.h>
|
|
|
|
#include <xenforeignmemory.h>
|
|
|
|
#include <xen/xen.h>
|
|
#include <xen/sys/privcmd.h>
|
|
|
|
#ifndef PAGE_SHIFT /* Mini-os, Yukk */
|
|
#define PAGE_SHIFT 12
|
|
#endif
|
|
#ifndef __MINIOS__ /* Yukk */
|
|
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
#endif
|
|
|
|
struct xenforeignmemory_handle {
|
|
xentoollog_logger *logger, *logger_tofree;
|
|
unsigned flags;
|
|
int fd;
|
|
};
|
|
|
|
int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem);
|
|
int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem);
|
|
|
|
void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
|
|
uint32_t dom, int prot,
|
|
size_t num,
|
|
const xen_pfn_t arr[num], int err[num]);
|
|
int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
|
void *addr, size_t num);
|
|
|
|
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
|
domid_t domid);
|
|
|
|
#if defined(__NetBSD__) || defined(__sun__)
|
|
/* Strictly compat for those two only only */
|
|
void *compat_mapforeign_batch(xenforeignmem_handle *fmem, uint32_t dom,
|
|
int prot, xen_pfn_t *arr, int num);
|
|
#endif
|
|
|
|
#define PERROR(_f...) \
|
|
xtl_log(fmem->logger, XTL_ERROR, errno, "xenforeignmemory", _f)
|
|
|
|
#endif
|
|
|
|
/*
|
|
* Local variables:
|
|
* mode: C
|
|
* c-file-style: "BSD"
|
|
* c-basic-offset: 4
|
|
* tab-width: 4
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*/
|