18c2ecf20Sopenharmony_ci/****************************************************************************** 28c2ecf20Sopenharmony_ci * gntalloc.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Interface to /dev/xen/gntalloc. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This file is in the public domain. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __LINUX_PUBLIC_GNTALLOC_H__ 128c2ecf20Sopenharmony_ci#define __LINUX_PUBLIC_GNTALLOC_H__ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* 178c2ecf20Sopenharmony_ci * Allocates a new page and creates a new grant reference. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci#define IOCTL_GNTALLOC_ALLOC_GREF \ 208c2ecf20Sopenharmony_ci_IOC(_IOC_NONE, 'G', 5, sizeof(struct ioctl_gntalloc_alloc_gref)) 218c2ecf20Sopenharmony_cistruct ioctl_gntalloc_alloc_gref { 228c2ecf20Sopenharmony_ci /* IN parameters */ 238c2ecf20Sopenharmony_ci /* The ID of the domain to be given access to the grants. */ 248c2ecf20Sopenharmony_ci __u16 domid; 258c2ecf20Sopenharmony_ci /* Flags for this mapping */ 268c2ecf20Sopenharmony_ci __u16 flags; 278c2ecf20Sopenharmony_ci /* Number of pages to map */ 288c2ecf20Sopenharmony_ci __u32 count; 298c2ecf20Sopenharmony_ci /* OUT parameters */ 308c2ecf20Sopenharmony_ci /* The offset to be used on a subsequent call to mmap(). */ 318c2ecf20Sopenharmony_ci __u64 index; 328c2ecf20Sopenharmony_ci /* The grant references of the newly created grant, one per page */ 338c2ecf20Sopenharmony_ci /* Variable size, depending on count */ 348c2ecf20Sopenharmony_ci __u32 gref_ids[1]; 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define GNTALLOC_FLAG_WRITABLE 1 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* 408c2ecf20Sopenharmony_ci * Deallocates the grant reference, allowing the associated page to be freed if 418c2ecf20Sopenharmony_ci * no other domains are using it. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci#define IOCTL_GNTALLOC_DEALLOC_GREF \ 448c2ecf20Sopenharmony_ci_IOC(_IOC_NONE, 'G', 6, sizeof(struct ioctl_gntalloc_dealloc_gref)) 458c2ecf20Sopenharmony_cistruct ioctl_gntalloc_dealloc_gref { 468c2ecf20Sopenharmony_ci /* IN parameters */ 478c2ecf20Sopenharmony_ci /* The offset returned in the map operation */ 488c2ecf20Sopenharmony_ci __u64 index; 498c2ecf20Sopenharmony_ci /* Number of references to unmap */ 508c2ecf20Sopenharmony_ci __u32 count; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * Sets up an unmap notification within the page, so that the other side can do 558c2ecf20Sopenharmony_ci * cleanup if this side crashes. Required to implement cross-domain robust 568c2ecf20Sopenharmony_ci * mutexes or close notification on communication channels. 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * Each mapped page only supports one notification; multiple calls referring to 598c2ecf20Sopenharmony_ci * the same page overwrite the previous notification. You must clear the 608c2ecf20Sopenharmony_ci * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it 618c2ecf20Sopenharmony_ci * to occur. 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_ci#define IOCTL_GNTALLOC_SET_UNMAP_NOTIFY \ 648c2ecf20Sopenharmony_ci_IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntalloc_unmap_notify)) 658c2ecf20Sopenharmony_cistruct ioctl_gntalloc_unmap_notify { 668c2ecf20Sopenharmony_ci /* IN parameters */ 678c2ecf20Sopenharmony_ci /* Offset in the file descriptor for a byte within the page (same as 688c2ecf20Sopenharmony_ci * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to 698c2ecf20Sopenharmony_ci * be cleared. Otherwise, it can be any byte in the page whose 708c2ecf20Sopenharmony_ci * notification we are adjusting. 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci __u64 index; 738c2ecf20Sopenharmony_ci /* Action(s) to take on unmap */ 748c2ecf20Sopenharmony_ci __u32 action; 758c2ecf20Sopenharmony_ci /* Event channel to notify */ 768c2ecf20Sopenharmony_ci __u32 event_channel_port; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Clear (set to zero) the byte specified by index */ 808c2ecf20Sopenharmony_ci#define UNMAP_NOTIFY_CLEAR_BYTE 0x1 818c2ecf20Sopenharmony_ci/* Send an interrupt on the indicated event channel */ 828c2ecf20Sopenharmony_ci#define UNMAP_NOTIFY_SEND_EVENT 0x2 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#endif /* __LINUX_PUBLIC_GNTALLOC_H__ */ 85