privcmd.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR MIT) */
  2. /******************************************************************************
  3. * privcmd.h
  4. *
  5. * Interface to /proc/xen/privcmd.
  6. *
  7. * Copyright (c) 2003-2005, K A Fraser
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation; or, when distributed
  12. * separately from the Linux kernel or incorporated into other
  13. * software packages, subject to the following license:
  14. *
  15. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16. * of this source file (the "Software"), to deal in the Software without
  17. * restriction, including without limitation the rights to use, copy, modify,
  18. * merge, publish, distribute, sublicense, and/or sell copies of the Software,
  19. * and to permit persons to whom the Software is furnished to do so, subject to
  20. * the following conditions:
  21. *
  22. * The above copyright notice and this permission notice shall be included in
  23. * all copies or substantial portions of the Software.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  27. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  28. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  30. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  31. * IN THE SOFTWARE.
  32. */
  33. #ifndef __LINUX_PUBLIC_PRIVCMD_H__
  34. #define __LINUX_PUBLIC_PRIVCMD_H__
  35. #include <linux/types.h>
  36. #include <xen/interface/xen.h>
  37. struct privcmd_hypercall {
  38. __u64 op;
  39. __u64 arg[5];
  40. };
  41. struct privcmd_mmap_entry {
  42. __u64 va;
  43. /*
  44. * This should be a GFN. It's not possible to change the name because
  45. * it's exposed to the user-space.
  46. */
  47. __u64 mfn;
  48. __u64 npages;
  49. };
  50. struct privcmd_mmap {
  51. int num;
  52. domid_t dom; /* target domain */
  53. struct privcmd_mmap_entry *entry;
  54. };
  55. struct privcmd_mmapbatch {
  56. int num; /* number of pages to populate */
  57. domid_t dom; /* target domain */
  58. __u64 addr; /* virtual address */
  59. xen_pfn_t *arr; /* array of mfns - or'd with
  60. PRIVCMD_MMAPBATCH_*_ERROR on err */
  61. };
  62. #define PRIVCMD_MMAPBATCH_MFN_ERROR 0xf0000000U
  63. #define PRIVCMD_MMAPBATCH_PAGED_ERROR 0x80000000U
  64. struct privcmd_mmapbatch_v2 {
  65. unsigned int num; /* number of pages to populate */
  66. domid_t dom; /* target domain */
  67. __u64 addr; /* virtual address */
  68. const xen_pfn_t *arr; /* array of mfns */
  69. int *err; /* array of error codes */
  70. };
  71. struct privcmd_dm_op_buf {
  72. void *uptr;
  73. size_t size;
  74. };
  75. struct privcmd_dm_op {
  76. domid_t dom;
  77. __u16 num;
  78. const struct privcmd_dm_op_buf *ubufs;
  79. };
  80. struct privcmd_mmap_resource {
  81. domid_t dom;
  82. __u32 type;
  83. __u32 id;
  84. __u32 idx;
  85. __u64 num;
  86. __u64 addr;
  87. };
  88. /* For privcmd_irqfd::flags */
  89. #define PRIVCMD_IRQFD_FLAG_DEASSIGN (1 << 0)
  90. struct privcmd_irqfd {
  91. __u64 dm_op;
  92. __u32 size; /* Size of structure pointed by dm_op */
  93. __u32 fd;
  94. __u32 flags;
  95. domid_t dom;
  96. __u8 pad[2];
  97. };
  98. /*
  99. * @cmd: IOCTL_PRIVCMD_HYPERCALL
  100. * @arg: &privcmd_hypercall_t
  101. * Return: Value returned from execution of the specified hypercall.
  102. *
  103. * @cmd: IOCTL_PRIVCMD_MMAPBATCH_V2
  104. * @arg: &struct privcmd_mmapbatch_v2
  105. * Return: 0 on success (i.e., arg->err contains valid error codes for
  106. * each frame). On an error other than a failed frame remap, -1 is
  107. * returned and errno is set to EINVAL, EFAULT etc. As an exception,
  108. * if the operation was otherwise successful but any frame failed with
  109. * -ENOENT, then -1 is returned and errno is set to ENOENT.
  110. */
  111. #define IOCTL_PRIVCMD_HYPERCALL \
  112. _IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall))
  113. #define IOCTL_PRIVCMD_MMAP \
  114. _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap))
  115. #define IOCTL_PRIVCMD_MMAPBATCH \
  116. _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))
  117. #define IOCTL_PRIVCMD_MMAPBATCH_V2 \
  118. _IOC(_IOC_NONE, 'P', 4, sizeof(struct privcmd_mmapbatch_v2))
  119. #define IOCTL_PRIVCMD_DM_OP \
  120. _IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_dm_op))
  121. #define IOCTL_PRIVCMD_RESTRICT \
  122. _IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))
  123. #define IOCTL_PRIVCMD_MMAP_RESOURCE \
  124. _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))
  125. #define IOCTL_PRIVCMD_IRQFD \
  126. _IOW('P', 8, struct privcmd_irqfd)
  127. #endif /* __LINUX_PUBLIC_PRIVCMD_H__ */