162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR MIT) */ 262306a36Sopenharmony_ci/****************************************************************************** 362306a36Sopenharmony_ci * privcmd.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Interface to /proc/xen/privcmd. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 2003-2005, K A Fraser 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or 1062306a36Sopenharmony_ci * modify it under the terms of the GNU General Public License version 2 1162306a36Sopenharmony_ci * as published by the Free Software Foundation; or, when distributed 1262306a36Sopenharmony_ci * separately from the Linux kernel or incorporated into other 1362306a36Sopenharmony_ci * software packages, subject to the following license: 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 1662306a36Sopenharmony_ci * of this source file (the "Software"), to deal in the Software without 1762306a36Sopenharmony_ci * restriction, including without limitation the rights to use, copy, modify, 1862306a36Sopenharmony_ci * merge, publish, distribute, sublicense, and/or sell copies of the Software, 1962306a36Sopenharmony_ci * and to permit persons to whom the Software is furnished to do so, subject to 2062306a36Sopenharmony_ci * the following conditions: 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 2362306a36Sopenharmony_ci * all copies or substantial portions of the Software. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2662306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2762306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2862306a36Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2962306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 3062306a36Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 3162306a36Sopenharmony_ci * IN THE SOFTWARE. 3262306a36Sopenharmony_ci */ 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#ifndef __LINUX_PUBLIC_PRIVCMD_H__ 3562306a36Sopenharmony_ci#define __LINUX_PUBLIC_PRIVCMD_H__ 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#include <linux/types.h> 3862306a36Sopenharmony_ci#include <linux/compiler.h> 3962306a36Sopenharmony_ci#include <xen/interface/xen.h> 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistruct privcmd_hypercall { 4262306a36Sopenharmony_ci __u64 op; 4362306a36Sopenharmony_ci __u64 arg[5]; 4462306a36Sopenharmony_ci}; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistruct privcmd_mmap_entry { 4762306a36Sopenharmony_ci __u64 va; 4862306a36Sopenharmony_ci /* 4962306a36Sopenharmony_ci * This should be a GFN. It's not possible to change the name because 5062306a36Sopenharmony_ci * it's exposed to the user-space. 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_ci __u64 mfn; 5362306a36Sopenharmony_ci __u64 npages; 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_cistruct privcmd_mmap { 5762306a36Sopenharmony_ci int num; 5862306a36Sopenharmony_ci domid_t dom; /* target domain */ 5962306a36Sopenharmony_ci struct privcmd_mmap_entry __user *entry; 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistruct privcmd_mmapbatch { 6362306a36Sopenharmony_ci int num; /* number of pages to populate */ 6462306a36Sopenharmony_ci domid_t dom; /* target domain */ 6562306a36Sopenharmony_ci __u64 addr; /* virtual address */ 6662306a36Sopenharmony_ci xen_pfn_t __user *arr; /* array of mfns - or'd with 6762306a36Sopenharmony_ci PRIVCMD_MMAPBATCH_*_ERROR on err */ 6862306a36Sopenharmony_ci}; 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define PRIVCMD_MMAPBATCH_MFN_ERROR 0xf0000000U 7162306a36Sopenharmony_ci#define PRIVCMD_MMAPBATCH_PAGED_ERROR 0x80000000U 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_cistruct privcmd_mmapbatch_v2 { 7462306a36Sopenharmony_ci unsigned int num; /* number of pages to populate */ 7562306a36Sopenharmony_ci domid_t dom; /* target domain */ 7662306a36Sopenharmony_ci __u64 addr; /* virtual address */ 7762306a36Sopenharmony_ci const xen_pfn_t __user *arr; /* array of mfns */ 7862306a36Sopenharmony_ci int __user *err; /* array of error codes */ 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_cistruct privcmd_dm_op_buf { 8262306a36Sopenharmony_ci void __user *uptr; 8362306a36Sopenharmony_ci size_t size; 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cistruct privcmd_dm_op { 8762306a36Sopenharmony_ci domid_t dom; 8862306a36Sopenharmony_ci __u16 num; 8962306a36Sopenharmony_ci const struct privcmd_dm_op_buf __user *ubufs; 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistruct privcmd_mmap_resource { 9362306a36Sopenharmony_ci domid_t dom; 9462306a36Sopenharmony_ci __u32 type; 9562306a36Sopenharmony_ci __u32 id; 9662306a36Sopenharmony_ci __u32 idx; 9762306a36Sopenharmony_ci __u64 num; 9862306a36Sopenharmony_ci __u64 addr; 9962306a36Sopenharmony_ci}; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/* For privcmd_irqfd::flags */ 10262306a36Sopenharmony_ci#define PRIVCMD_IRQFD_FLAG_DEASSIGN (1 << 0) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cistruct privcmd_irqfd { 10562306a36Sopenharmony_ci __u64 dm_op; 10662306a36Sopenharmony_ci __u32 size; /* Size of structure pointed by dm_op */ 10762306a36Sopenharmony_ci __u32 fd; 10862306a36Sopenharmony_ci __u32 flags; 10962306a36Sopenharmony_ci domid_t dom; 11062306a36Sopenharmony_ci __u8 pad[2]; 11162306a36Sopenharmony_ci}; 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* 11462306a36Sopenharmony_ci * @cmd: IOCTL_PRIVCMD_HYPERCALL 11562306a36Sopenharmony_ci * @arg: &privcmd_hypercall_t 11662306a36Sopenharmony_ci * Return: Value returned from execution of the specified hypercall. 11762306a36Sopenharmony_ci * 11862306a36Sopenharmony_ci * @cmd: IOCTL_PRIVCMD_MMAPBATCH_V2 11962306a36Sopenharmony_ci * @arg: &struct privcmd_mmapbatch_v2 12062306a36Sopenharmony_ci * Return: 0 on success (i.e., arg->err contains valid error codes for 12162306a36Sopenharmony_ci * each frame). On an error other than a failed frame remap, -1 is 12262306a36Sopenharmony_ci * returned and errno is set to EINVAL, EFAULT etc. As an exception, 12362306a36Sopenharmony_ci * if the operation was otherwise successful but any frame failed with 12462306a36Sopenharmony_ci * -ENOENT, then -1 is returned and errno is set to ENOENT. 12562306a36Sopenharmony_ci */ 12662306a36Sopenharmony_ci#define IOCTL_PRIVCMD_HYPERCALL \ 12762306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 0, sizeof(struct privcmd_hypercall)) 12862306a36Sopenharmony_ci#define IOCTL_PRIVCMD_MMAP \ 12962306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 2, sizeof(struct privcmd_mmap)) 13062306a36Sopenharmony_ci#define IOCTL_PRIVCMD_MMAPBATCH \ 13162306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 3, sizeof(struct privcmd_mmapbatch)) 13262306a36Sopenharmony_ci#define IOCTL_PRIVCMD_MMAPBATCH_V2 \ 13362306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 4, sizeof(struct privcmd_mmapbatch_v2)) 13462306a36Sopenharmony_ci#define IOCTL_PRIVCMD_DM_OP \ 13562306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 5, sizeof(struct privcmd_dm_op)) 13662306a36Sopenharmony_ci#define IOCTL_PRIVCMD_RESTRICT \ 13762306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 6, sizeof(domid_t)) 13862306a36Sopenharmony_ci#define IOCTL_PRIVCMD_MMAP_RESOURCE \ 13962306a36Sopenharmony_ci _IOC(_IOC_NONE, 'P', 7, sizeof(struct privcmd_mmap_resource)) 14062306a36Sopenharmony_ci#define IOCTL_PRIVCMD_IRQFD \ 14162306a36Sopenharmony_ci _IOW('P', 8, struct privcmd_irqfd) 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */ 144