mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
tools/libxenforeignmemory: add a call to restrict the handle
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>
This commit is contained in:
1 parent
60c59f5876
commit
5823d6eb40
9 files changed
+55
No files matched your search
@@ -106,6 +106,12 @@ int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return osdep_xenforeignmemory_unmap(fmem, addr, num);
|
||||
}
|
||||
|
||||
int xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
return osdep_xenforeignmemory_restrict(fmem, domid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -96,6 +96,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return munmap(addr, num << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
errno = -EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -115,6 +115,17 @@ void *xenforeignmemory_map(xenforeignmemory_handle *fmem, uint32_t dom,
|
||||
int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
void *addr, size_t pages);
|
||||
|
||||
/**
|
||||
* This function restricts the use of this handle to the specified
|
||||
* domain.
|
||||
*
|
||||
* @parm fmem handle to the open foreignmemory interface
|
||||
* @parm domid the domain id
|
||||
* @return 0 on success, -1 on failure.
|
||||
*/
|
||||
int xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -4,5 +4,6 @@ VERS_1.0 {
|
||||
xenforeignmemory_close;
|
||||
xenforeignmemory_map;
|
||||
xenforeignmemory_unmap;
|
||||
xenforeignmemory_restrict;
|
||||
local: *; /* Do not expose anything by default */
|
||||
};
|
||||
@@ -272,6 +272,12 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return munmap(addr, num << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
return ioctl(fmem->fd, IOCTL_PRIVCMD_RESTRICT, &domid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -58,6 +58,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return munmap(addr, num << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
errno = -EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -100,6 +100,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return munmap(addr, num*XC_PAGE_SIZE);
|
||||
}
|
||||
|
||||
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
errno = -EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -32,6 +32,9 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
|
||||
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,
|
||||
|
||||
@@ -98,6 +98,13 @@ int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
||||
return munmap(addr, num*XC_PAGE_SIZE);
|
||||
}
|
||||
|
||||
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
||||
domid_t domid)
|
||||
{
|
||||
errno = -EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||