/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR MIT) */1/******************************************************************************2* privcmd.h3*4* Interface to /proc/xen/privcmd.5*6* Copyright (c) 2003-2005, K A Fraser7*8* This program is free software; you can redistribute it and/or9* modify it under the terms of the GNU General Public License version 210* as published by the Free Software Foundation; or, when distributed11* separately from the Linux kernel or incorporated into other12* software packages, subject to the following license:13*14* Permission is hereby granted, free of charge, to any person obtaining a copy15* of this source file (the "Software"), to deal in the Software without16* restriction, including without limitation the rights to use, copy, modify,17* merge, publish, distribute, sublicense, and/or sell copies of the Software,18* and to permit persons to whom the Software is furnished to do so, subject to19* the following conditions:20*21* The above copyright notice and this permission notice shall be included in22* all copies or substantial portions of the Software.23*24* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR25* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,26* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE27* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER28* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING29* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS30* IN THE SOFTWARE.31*/3233#ifndef __LINUX_PUBLIC_PRIVCMD_H__34#define __LINUX_PUBLIC_PRIVCMD_H__3536#include <linux/types.h>37#include <linux/compiler.h>38#include <xen/interface/xen.h>3940struct privcmd_hypercall {41__u64 op;42__u64 arg[5];43};4445struct privcmd_mmap_entry {46__u64 va;47/*48* This should be a GFN. It's not possible to change the name because49* it's exposed to the user-space.50*/51__u64 mfn;52__u64 npages;53};5455struct privcmd_mmap {56int num;57domid_t dom; /* target domain */58struct privcmd_mmap_entry __user *entry;59};6061struct privcmd_mmapbatch {62int num; /* number of pages to populate */63domid_t dom; /* target domain */64__u64 addr; /* virtual address */65xen_pfn_t __user *arr; /* array of mfns - or'd with66PRIVCMD_MMAPBATCH_*_ERROR on err */67};6869#define PRIVCMD_MMAPBATCH_MFN_ERROR 0xf0000000U70#define PRIVCMD_MMAPBATCH_PAGED_ERROR 0x80000000U7172struct privcmd_mmapbatch_v2 {73unsigned int num; /* number of pages to populate */74domid_t dom; /* target domain */75__u64 addr; /* virtual address */76const xen_pfn_t __user *arr; /* array of mfns */77int __user *err; /* array of error codes */78};7980struct privcmd_dm_op_buf {81void __user *uptr;82size_t size;83};8485struct privcmd_dm_op {86domid_t dom;87__u16 num;88const struct privcmd_dm_op_buf __user *ubufs;89};9091struct privcmd_mmap_resource {92domid_t dom;93__u32 type;94__u32 id;95__u32 idx;96__u64 num;97__u64 addr;98};99100/* For privcmd_irqfd::flags */101#define PRIVCMD_IRQFD_FLAG_DEASSIGN (1 << 0)102103struct privcmd_irqfd {104__u64 dm_op;105__u32 size; /* Size of structure pointed by dm_op */106__u32 fd;107__u32 flags;108domid_t dom;109__u8 pad[2];110};111112/* For privcmd_ioeventfd::flags */113#define PRIVCMD_IOEVENTFD_FLAG_DEASSIGN (1 << 0)114115struct privcmd_ioeventfd {116__u64 ioreq;117__u64 ports;118__u64 addr;119__u32 addr_len;120__u32 event_fd;121__u32 vcpus;122__u32 vq;123__u32 flags;124domid_t dom;125__u8 pad[2];126};127128struct privcmd_pcidev_get_gsi {129__u32 sbdf;130__u32 gsi;131};132133/*134* @cmd: IOCTL_PRIVCMD_HYPERCALL135* @arg: &privcmd_hypercall_t136* Return: Value returned from execution of the specified hypercall.137*138* @cmd: IOCTL_PRIVCMD_MMAPBATCH_V2139* @arg: &struct privcmd_mmapbatch_v2140* Return: 0 on success (i.e., arg->err contains valid error codes for141* each frame). On an error other than a failed frame remap, -1 is142* returned and errno is set to EINVAL, EFAULT etc. As an exception,143* if the operation was otherwise successful but any frame failed with144* -ENOENT, then -1 is returned and errno is set to ENOENT.145*/146#define IOCTL_PRIVCMD_HYPERCALL \147_IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall))148#define IOCTL_PRIVCMD_MMAP \149_IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap))150#define IOCTL_PRIVCMD_MMAPBATCH \151_IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch))152#define IOCTL_PRIVCMD_MMAPBATCH_V2 \153_IOC(_IOC_NONE, 'P', 4, sizeof(struct privcmd_mmapbatch_v2))154#define IOCTL_PRIVCMD_DM_OP \155_IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_dm_op))156#define IOCTL_PRIVCMD_RESTRICT \157_IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))158#define IOCTL_PRIVCMD_MMAP_RESOURCE \159_IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource))160#define IOCTL_PRIVCMD_IRQFD \161_IOW('P', 8, struct privcmd_irqfd)162#define IOCTL_PRIVCMD_IOEVENTFD \163_IOW('P', 9, struct privcmd_ioeventfd)164#define IOCTL_PRIVCMD_PCIDEV_GET_GSI \165_IOC(_IOC_NONE, 'P', 10, sizeof(struct privcmd_pcidev_get_gsi))166167#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */168169170