^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * gntalloc.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Interface to /dev/xen/gntalloc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author: Daniel De Graaf <dgdegra@tycho.nsa.gov>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This file is in the public domain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifndef __LINUX_PUBLIC_GNTALLOC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define __LINUX_PUBLIC_GNTALLOC_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Allocates a new page and creates a new grant reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define IOCTL_GNTALLOC_ALLOC_GREF \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) _IOC(_IOC_NONE, 'G', 5, sizeof(struct ioctl_gntalloc_alloc_gref))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct ioctl_gntalloc_alloc_gref {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* IN parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* The ID of the domain to be given access to the grants. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) __u16 domid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* Flags for this mapping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __u16 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* Number of pages to map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* OUT parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* The offset to be used on a subsequent call to mmap(). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __u64 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /* The grant references of the newly created grant, one per page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* Variable size, depending on count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __u32 gref_ids[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define GNTALLOC_FLAG_WRITABLE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Deallocates the grant reference, allowing the associated page to be freed if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * no other domains are using it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define IOCTL_GNTALLOC_DEALLOC_GREF \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) _IOC(_IOC_NONE, 'G', 6, sizeof(struct ioctl_gntalloc_dealloc_gref))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct ioctl_gntalloc_dealloc_gref {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* IN parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* The offset returned in the map operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __u64 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Number of references to unmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Sets up an unmap notification within the page, so that the other side can do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * cleanup if this side crashes. Required to implement cross-domain robust
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * mutexes or close notification on communication channels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Each mapped page only supports one notification; multiple calls referring to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * the same page overwrite the previous notification. You must clear the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * notification prior to the IOCTL_GNTALLOC_DEALLOC_GREF if you do not want it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * to occur.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define IOCTL_GNTALLOC_SET_UNMAP_NOTIFY \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) _IOC(_IOC_NONE, 'G', 7, sizeof(struct ioctl_gntalloc_unmap_notify))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct ioctl_gntalloc_unmap_notify {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* IN parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* Offset in the file descriptor for a byte within the page (same as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * used in mmap). If using UNMAP_NOTIFY_CLEAR_BYTE, this is the byte to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * be cleared. Otherwise, it can be any byte in the page whose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * notification we are adjusting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __u64 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Action(s) to take on unmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __u32 action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* Event channel to notify */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __u32 event_channel_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* Clear (set to zero) the byte specified by index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define UNMAP_NOTIFY_CLEAR_BYTE 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Send an interrupt on the indicated event channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define UNMAP_NOTIFY_SEND_EVENT 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif /* __LINUX_PUBLIC_GNTALLOC_H__ */