mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
Versions of linux privcmd prior to commit dc9eab6fd94d ("return -ENOTTY
for unimplemented IOCTLs") will return -EINVAL rather than the conventional
-ENOTTY for unimplemented codes. This breaks the error path in
libxenforeignmemory resource mapping, which only translates ENOTTY into
EOPNOTSUPP to inform callers of the need to use an alternative (legacy)
mechanism.
This patch adds a new 'unimplemented' [1] ioctl code into the local
privcmd header which is then used to probe for the appropriate errno to
translate in the resource mapping error path
[1] this is a code that has, so far, never been used in any version of
privcmd and will be added to future versions of the header in the
linux source, to make sure it stays unimplemented.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
100 lines
2.7 KiB
C
100 lines
2.7 KiB
C
#ifndef XENFOREIGNMEMORY_PRIVATE_H
|
|
#define XENFOREIGNMEMORY_PRIVATE_H
|
|
|
|
#include <xentoollog.h>
|
|
|
|
#include <xenforeignmemory.h>
|
|
|
|
#include <xentoolcore_internal.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;
|
|
Xentoolcore__Active_Handle tc_ah;
|
|
int unimpl_errno;
|
|
};
|
|
|
|
int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem);
|
|
int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem);
|
|
|
|
void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
|
|
uint32_t dom, void *addr,
|
|
int prot, int flags, size_t num,
|
|
const xen_pfn_t arr[num], int err[num]);
|
|
int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
|
|
void *addr, size_t num);
|
|
|
|
#if defined(__NetBSD__) || defined(__sun__)
|
|
/* Strictly compat for those two only only */
|
|
void *compat_mapforeign_batch(xenforeignmem_handle *fmem, uint32_t dom,
|
|
void *addr, int prot, int flags,
|
|
xen_pfn_t *arr, int num);
|
|
#endif
|
|
|
|
struct xenforeignmemory_resource_handle {
|
|
domid_t domid;
|
|
unsigned int type;
|
|
unsigned int id;
|
|
unsigned long frame;
|
|
unsigned long nr_frames;
|
|
void *addr;
|
|
int prot;
|
|
int flags;
|
|
};
|
|
|
|
#ifndef __linux__
|
|
static inline int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
|
domid_t domid)
|
|
{
|
|
errno = EOPNOTSUPP;
|
|
return -1;
|
|
}
|
|
|
|
static inline int osdep_xenforeignmemory_map_resource(
|
|
xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres)
|
|
{
|
|
errno = EOPNOTSUPP;
|
|
return -1;
|
|
}
|
|
|
|
static inline int osdep_xenforeignmemory_unmap_resource(
|
|
xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres)
|
|
{
|
|
return 0;
|
|
}
|
|
#else
|
|
int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
|
|
domid_t domid);
|
|
int osdep_xenforeignmemory_map_resource(
|
|
xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres);
|
|
int osdep_xenforeignmemory_unmap_resource(
|
|
xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres);
|
|
#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:
|
|
*/
|