Files
xen/tools/libs/call/private.h
T
Jan Beulich 6409210a5f libxencall: osdep_hypercall() should return long
Some hypercalls, memory-op in particular, can return values requiring
more than 31 bits to represent. Hence the underlying layers need to make
sure they won't truncate such values. (Note that for Solaris the
function also gets renamed, to match the other OSes.)

Due to them merely propagating ioctl()'s return value, this change is
benign on Linux and Solaris. IOW there's an actual effect here only for
the BSDs and MiniOS, but even then further adjustments are needed at the
xencall<N>() level.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <iwj@xenproject.org>
2021-06-24 16:38:37 +02:00

78 lines
1.9 KiB
C

#ifndef XENCALL_PRIVATE_H
#define XENCALL_PRIVATE_H
#include <xentoollog.h>
#include <xentoolcore_internal.h>
#include <xencall.h>
#include <xen/xen.h>
#include <xen/sys/privcmd.h>
#ifndef PAGE_SHIFT /* Mini-os, Yukk */
#define PAGE_SHIFT 12
#endif
#ifndef PAGE_SIZE
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#endif
#ifndef PAGE_MASK
#define PAGE_MASK (~(PAGE_SIZE-1))
#endif
struct xencall_handle {
xentoollog_logger *logger, *logger_tofree;
unsigned flags;
/* partially with /dev/ no /dev/ */
/* initialised xen/hypercall xen/hypercall */
int fd; /* any >= 0 >= 0 */
int buf_fd; /* any >= 0 -1 */
Xentoolcore__Active_Handle tc_ah;
/*
* A simple cache of unused, single page, hypercall buffers
*
* Protected by a global lock.
*/
#define BUFFER_CACHE_SIZE 4
int buffer_cache_nr;
void *buffer_cache[BUFFER_CACHE_SIZE];
/*
* Hypercall buffer statistics. All protected by the global
* buffer_cache lock.
*/
int buffer_total_allocations;
int buffer_total_releases;
int buffer_current_allocations;
int buffer_maximum_allocations;
int buffer_cache_hits;
int buffer_cache_misses;
int buffer_cache_toobig;
};
int osdep_xencall_open(xencall_handle *xcall);
int osdep_xencall_close(xencall_handle *xcall);
long osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall);
void *osdep_alloc_pages(xencall_handle *xcall, size_t nr_pages);
void osdep_free_pages(xencall_handle *xcall, void *p, size_t nr_pages);
void buffer_release_cache(xencall_handle *xcall);
#define PERROR(_f...) xtl_log(xcall->logger, XTL_ERROR, errno, "xencall", _f)
#endif
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/