mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/libxencalls: add new function to query hypercall buffer safety
Add a new function to query whether hypercall buffers are always safe to access by the hypervisor or might result in EFAULT. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
33be2c3858
commit
171d6ecec1
8 files changed
+38
-1
No files matched your search
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
|
||||
include $(XEN_ROOT)/tools/Rules.mk
|
||||
|
||||
MAJOR = 1
|
||||
MINOR = 0
|
||||
MINOR = 1
|
||||
SHLIB_LDFLAGS += -Wl,--version-script=libxencall.map
|
||||
|
||||
CFLAGS += -Werror -Wmissing-prototypes
|
||||
|
||||
@@ -107,6 +107,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -115,6 +115,13 @@ void xencall_free_buffer_pages(xencall_handle *xcall, void *p, size_t nr_pages);
|
||||
void *xencall_alloc_buffer(xencall_handle *xcall, size_t size);
|
||||
void xencall_free_buffer(xencall_handle *xcall, void *p);
|
||||
|
||||
/*
|
||||
* Are allocated hypercall buffers safe to be accessed by the hypervisor all
|
||||
* the time?
|
||||
* Returns 0 if EFAULT might be possible.
|
||||
*/
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,3 +17,8 @@ VERS_1.0 {
|
||||
xencall_free_buffer_pages;
|
||||
local: *; /* Do not expose anything by default */
|
||||
};
|
||||
|
||||
VERS_1.1 {
|
||||
global:
|
||||
xencall_buffers_never_fault;
|
||||
} VERS_1.0;
|
||||
@@ -171,6 +171,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall)
|
||||
{
|
||||
return xcall->buf_fd >= 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -70,6 +70,11 @@ void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -110,6 +110,11 @@ int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
|
||||
return hypercall->retval;
|
||||
}
|
||||
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
@@ -86,6 +86,11 @@ int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall)
|
||||
return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
|
||||
}
|
||||
|
||||
int xencall_buffers_never_fault(xencall_handle *xcall)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||