privcmd.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 <linux/compiler.h>
  37. #include <xen/interface/xen.h>
  38. struct privcmd_hypercall {
  39. __u64 op;
  40. __u64 arg[5];
  41. };
  42. struct privcmd_mmap_entry {
  43. __u64 va;
  44. /*
  45. * This should be a GFN. It's not possible to change the name because
  46. * it's exposed to the user-space.
  47. */
  48. __u64 mfn;
  49. __u64 npages;
  50. };
  51. struct privcmd_mmap {
  52. int num;
  53. domid_t dom; /* target domain */
  54. struct privcmd_mmap_entry __user *entry;
  55. };
  56. struct privcmd_mmapbatch {
  57. int num; /* number of pages to populate */
  58. domid_t dom; /* target domain */
  59. __u64 addr; /* virtual address */
  60. xen_pfn_t __user *arr; /* array of mfns - or'd with
  61. PRIVCMD_MMAPBATCH_*_ERROR on err */
  62. };
  63. #define PRIVCMD_MMAPBATCH_MFN_ERROR 0xf0000000U
  64. #define PRIVCMD_MMAPBATCH_PAGED_ERROR 0x80000000U
  65. struct privcmd_mmapbatch_v2 {
  66. unsigned int num; /* number of pages to populate */
  67. domid_t dom; /* target domain */
  68. __u64 addr; /* virtual address */
  69. const xen_pfn_t __user *arr; /* array of mfns */
  70. int __user *err; /* array of error codes */
  71. };
  72. struct privcmd_dm_op_buf {
  73. void __user *uptr;
  74. size_t size;
  75. };
  76. struct privcmd_dm_op {
  77. domid_t dom;
  78. __u16 num;
  79. const struct privcmd_dm_op_buf __user *ubufs;
  80. };
  81. struct privcmd_mmap_resource {
  82. domid_t dom;
  83. __u32 type;
  84. __u32 id;
  85. __u32 idx;
  86. __u64 num;
  87. __u64 addr;
  88. };
  89. /*
  90. * @cmd: IOCTL_PRIVCMD_HYPERCALL
  91. * @arg: &privcmd_hypercall_t
  92. * Return: Value returned from execution of the specified hypercall.
  93. *
  94. * @cmd: IOCTL_PRIVCMD_MMAPBATCH_V2
  95. * @arg: &struct privcmd_mmapbatch_v2
  96. * Return: 0 on success (i.e., arg->err contains valid error codes for
  97. * each frame). On an error other than a failed frame remap, -1 is
  98. * returned and errno is set to EINVAL, EFAULT etc. As an exception,
  99. * if the operation was otherwise successful but any frame failed with
  100. * -ENOENT, then -1 is returned and errno is set to ENOENT.
  101. */
  102. #define IOCTL_PRIVCMD_HYPERCALL \
  103. _IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall))
  104. #define IOCTL_PRIVCMD_MMAP \
  105. _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap))
  106. #define IOCTL_PRIVCMD_MMAPBATCH \
  107. _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))
  108. #define IOCTL_PRIVCMD_MMAPBATCH_V2 \
  109. _IOC(_IOC_NONE, 'P', 4, sizeof(struct privcmd_mmapbatch_v2))
  110. #define IOCTL_PRIVCMD_DM_OP \
  111. _IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_dm_op))
  112. #define IOCTL_PRIVCMD_RESTRICT \
  113. _IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))
  114. #define IOCTL_PRIVCMD_MMAP_RESOURCE \
  115. _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))
  116. #endif /* __LINUX_PUBLIC_PRIVCMD_H__ */