xen_backend: add grant table helpers

This patch adds grant table helper functions to the xen_backend code to
localize error reporting and use of xen_domid.

The patch also defers the call to xengnttab_open() until just before the
initialise method in XenDevOps is invoked. This method is responsible for
mapping the shared ring. No prior method requires access to the grant table.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Paul Durrant 2018-05-17 16:35:51 +01:00 committed by Stefano Stabellini
parent 5c0d914a9b
commit 9838824aff
2 changed files with 144 additions and 12 deletions

View file

@ -42,6 +42,39 @@ void xen_be_register_common(void);
int xen_be_register(const char *type, struct XenDevOps *ops);
int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state);
int xen_be_bind_evtchn(struct XenDevice *xendev);
void xen_be_set_max_grant_refs(struct XenDevice *xendev,
unsigned int nr_refs);
void *xen_be_map_grant_refs(struct XenDevice *xendev, uint32_t *refs,
unsigned int nr_refs, int prot);
void xen_be_unmap_grant_refs(struct XenDevice *xendev, void *ptr,
unsigned int nr_refs);
typedef struct XenGrantCopySegment {
union {
void *virt;
struct {
uint32_t ref;
off_t offset;
} foreign;
} source, dest;
size_t len;
} XenGrantCopySegment;
int xen_be_copy_grant_refs(struct XenDevice *xendev,
bool to_domain, XenGrantCopySegment segs[],
unsigned int nr_segs);
static inline void *xen_be_map_grant_ref(struct XenDevice *xendev,
uint32_t ref, int prot)
{
return xen_be_map_grant_refs(xendev, &ref, 1, prot);
}
static inline void xen_be_unmap_grant_ref(struct XenDevice *xendev,
void *ptr)
{
return xen_be_unmap_grant_refs(xendev, ptr, 1);
}
/* actual backend drivers */
extern struct XenDevOps xen_console_ops; /* xen_console.c */