xref: /linux/include/uapi/linux/fsl_hypervisor.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Freescale hypervisor ioctl and kernel interface
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (C) 2008-2011 Freescale Semiconductor, Inc.
6607ca46eSDavid Howells  * Author: Timur Tabi <timur@freescale.com>
7607ca46eSDavid Howells  *
8607ca46eSDavid Howells  * Redistribution and use in source and binary forms, with or without
9607ca46eSDavid Howells  * modification, are permitted provided that the following conditions are met:
10607ca46eSDavid Howells  *     * Redistributions of source code must retain the above copyright
11607ca46eSDavid Howells  *       notice, this list of conditions and the following disclaimer.
12607ca46eSDavid Howells  *     * Redistributions in binary form must reproduce the above copyright
13607ca46eSDavid Howells  *       notice, this list of conditions and the following disclaimer in the
14607ca46eSDavid Howells  *       documentation and/or other materials provided with the distribution.
15607ca46eSDavid Howells  *     * Neither the name of Freescale Semiconductor nor the
16607ca46eSDavid Howells  *       names of its contributors may be used to endorse or promote products
17607ca46eSDavid Howells  *       derived from this software without specific prior written permission.
18607ca46eSDavid Howells  *
19607ca46eSDavid Howells  *
20607ca46eSDavid Howells  * ALTERNATIVELY, this software may be distributed under the terms of the
21607ca46eSDavid Howells  * GNU General Public License ("GPL") as published by the Free Software
22607ca46eSDavid Howells  * Foundation, either version 2 of that License or (at your option) any
23607ca46eSDavid Howells  * later version.
24607ca46eSDavid Howells  *
25607ca46eSDavid Howells  * This software is provided by Freescale Semiconductor "as is" and any
26607ca46eSDavid Howells  * express or implied warranties, including, but not limited to, the implied
27607ca46eSDavid Howells  * warranties of merchantability and fitness for a particular purpose are
28607ca46eSDavid Howells  * disclaimed. In no event shall Freescale Semiconductor be liable for any
29607ca46eSDavid Howells  * direct, indirect, incidental, special, exemplary, or consequential damages
30607ca46eSDavid Howells  * (including, but not limited to, procurement of substitute goods or services;
31607ca46eSDavid Howells  * loss of use, data, or profits; or business interruption) however caused and
32607ca46eSDavid Howells  * on any theory of liability, whether in contract, strict liability, or tort
33607ca46eSDavid Howells  * (including negligence or otherwise) arising in any way out of the use of this
34607ca46eSDavid Howells  * software, even if advised of the possibility of such damage.
35607ca46eSDavid Howells  *
36607ca46eSDavid Howells  * This file is used by the Freescale hypervisor management driver.  It can
37607ca46eSDavid Howells  * also be included by applications that need to communicate with the driver
38607ca46eSDavid Howells  * via the ioctl interface.
39607ca46eSDavid Howells  */
40607ca46eSDavid Howells 
41607ca46eSDavid Howells #ifndef _UAPIFSL_HYPERVISOR_H
42607ca46eSDavid Howells #define _UAPIFSL_HYPERVISOR_H
43607ca46eSDavid Howells 
44607ca46eSDavid Howells #include <linux/types.h>
45607ca46eSDavid Howells 
46607ca46eSDavid Howells /**
47607ca46eSDavid Howells  * struct fsl_hv_ioctl_restart - restart a partition
48607ca46eSDavid Howells  * @ret: return error code from the hypervisor
49607ca46eSDavid Howells  * @partition: the ID of the partition to restart, or -1 for the
50607ca46eSDavid Howells  *             calling partition
51607ca46eSDavid Howells  *
52607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_PARTITION_RESTART
53607ca46eSDavid Howells  */
54607ca46eSDavid Howells struct fsl_hv_ioctl_restart {
55607ca46eSDavid Howells 	__u32 ret;
56607ca46eSDavid Howells 	__u32 partition;
57607ca46eSDavid Howells };
58607ca46eSDavid Howells 
59607ca46eSDavid Howells /**
60607ca46eSDavid Howells  * struct fsl_hv_ioctl_status - get a partition's status
61607ca46eSDavid Howells  * @ret: return error code from the hypervisor
62607ca46eSDavid Howells  * @partition: the ID of the partition to query, or -1 for the
63607ca46eSDavid Howells  *             calling partition
64607ca46eSDavid Howells  * @status: The returned status of the partition
65607ca46eSDavid Howells  *
66607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_PARTITION_GET_STATUS
67607ca46eSDavid Howells  *
68607ca46eSDavid Howells  * Values of 'status':
69607ca46eSDavid Howells  *    0 = Stopped
70607ca46eSDavid Howells  *    1 = Running
71607ca46eSDavid Howells  *    2 = Starting
72607ca46eSDavid Howells  *    3 = Stopping
73607ca46eSDavid Howells  */
74607ca46eSDavid Howells struct fsl_hv_ioctl_status {
75607ca46eSDavid Howells 	__u32 ret;
76607ca46eSDavid Howells 	__u32 partition;
77607ca46eSDavid Howells 	__u32 status;
78607ca46eSDavid Howells };
79607ca46eSDavid Howells 
80607ca46eSDavid Howells /**
81607ca46eSDavid Howells  * struct fsl_hv_ioctl_start - start a partition
82607ca46eSDavid Howells  * @ret: return error code from the hypervisor
83607ca46eSDavid Howells  * @partition: the ID of the partition to control
84607ca46eSDavid Howells  * @entry_point: The offset within the guest IMA to start execution
85607ca46eSDavid Howells  * @load: If non-zero, reload the partition's images before starting
86607ca46eSDavid Howells  *
87607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_PARTITION_START
88607ca46eSDavid Howells  */
89607ca46eSDavid Howells struct fsl_hv_ioctl_start {
90607ca46eSDavid Howells 	__u32 ret;
91607ca46eSDavid Howells 	__u32 partition;
92607ca46eSDavid Howells 	__u32 entry_point;
93607ca46eSDavid Howells 	__u32 load;
94607ca46eSDavid Howells };
95607ca46eSDavid Howells 
96607ca46eSDavid Howells /**
97607ca46eSDavid Howells  * struct fsl_hv_ioctl_stop - stop a partition
98607ca46eSDavid Howells  * @ret: return error code from the hypervisor
99607ca46eSDavid Howells  * @partition: the ID of the partition to stop, or -1 for the calling
100607ca46eSDavid Howells  *             partition
101607ca46eSDavid Howells  *
102607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_PARTITION_STOP
103607ca46eSDavid Howells  */
104607ca46eSDavid Howells struct fsl_hv_ioctl_stop {
105607ca46eSDavid Howells 	__u32 ret;
106607ca46eSDavid Howells 	__u32 partition;
107607ca46eSDavid Howells };
108607ca46eSDavid Howells 
109607ca46eSDavid Howells /**
110607ca46eSDavid Howells  * struct fsl_hv_ioctl_memcpy - copy memory between partitions
111607ca46eSDavid Howells  * @ret: return error code from the hypervisor
112607ca46eSDavid Howells  * @source: the partition ID of the source partition, or -1 for this
113607ca46eSDavid Howells  *          partition
114607ca46eSDavid Howells  * @target: the partition ID of the target partition, or -1 for this
115607ca46eSDavid Howells  *          partition
116607ca46eSDavid Howells  * @reserved: reserved, must be set to 0
117607ca46eSDavid Howells  * @local_addr: user-space virtual address of a buffer in the local
118607ca46eSDavid Howells  *              partition
119607ca46eSDavid Howells  * @remote_addr: guest physical address of a buffer in the
120607ca46eSDavid Howells  *           remote partition
121607ca46eSDavid Howells  * @count: the number of bytes to copy.  Both the local and remote
122607ca46eSDavid Howells  *         buffers must be at least 'count' bytes long
123607ca46eSDavid Howells  *
124607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_MEMCPY
125607ca46eSDavid Howells  *
126607ca46eSDavid Howells  * The 'local' partition is the partition that calls this ioctl.  The
127607ca46eSDavid Howells  * 'remote' partition is a different partition.  The data is copied from
128607ca46eSDavid Howells  * the 'source' paritition' to the 'target' partition.
129607ca46eSDavid Howells  *
130607ca46eSDavid Howells  * The buffer in the remote partition must be guest physically
131607ca46eSDavid Howells  * contiguous.
132607ca46eSDavid Howells  *
133607ca46eSDavid Howells  * This ioctl does not support copying memory between two remote
134607ca46eSDavid Howells  * partitions or within the same partition, so either 'source' or
135607ca46eSDavid Howells  * 'target' (but not both) must be -1.  In other words, either
136607ca46eSDavid Howells  *
137607ca46eSDavid Howells  *      source == local and target == remote
138607ca46eSDavid Howells  * or
139607ca46eSDavid Howells  *      source == remote and target == local
140607ca46eSDavid Howells  */
141607ca46eSDavid Howells struct fsl_hv_ioctl_memcpy {
142607ca46eSDavid Howells 	__u32 ret;
143607ca46eSDavid Howells 	__u32 source;
144607ca46eSDavid Howells 	__u32 target;
145607ca46eSDavid Howells 	__u32 reserved;	/* padding to ensure local_vaddr is aligned */
146607ca46eSDavid Howells 	__u64 local_vaddr;
147607ca46eSDavid Howells 	__u64 remote_paddr;
148607ca46eSDavid Howells 	__u64 count;
149607ca46eSDavid Howells };
150607ca46eSDavid Howells 
151607ca46eSDavid Howells /**
152607ca46eSDavid Howells  * struct fsl_hv_ioctl_doorbell - ring a doorbell
153607ca46eSDavid Howells  * @ret: return error code from the hypervisor
154607ca46eSDavid Howells  * @doorbell: the handle of the doorbell to ring doorbell
155607ca46eSDavid Howells  *
156607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_DOORBELL
157607ca46eSDavid Howells  */
158607ca46eSDavid Howells struct fsl_hv_ioctl_doorbell {
159607ca46eSDavid Howells 	__u32 ret;
160607ca46eSDavid Howells 	__u32 doorbell;
161607ca46eSDavid Howells };
162607ca46eSDavid Howells 
163607ca46eSDavid Howells /**
164607ca46eSDavid Howells  * struct fsl_hv_ioctl_prop - get/set a device tree property
165607ca46eSDavid Howells  * @ret: return error code from the hypervisor
166607ca46eSDavid Howells  * @handle: handle of partition whose tree to access
167607ca46eSDavid Howells  * @path: virtual address of path name of node to access
168607ca46eSDavid Howells  * @propname: virtual address of name of property to access
169607ca46eSDavid Howells  * @propval: virtual address of property data buffer
170607ca46eSDavid Howells  * @proplen: Size of property data buffer
171607ca46eSDavid Howells  * @reserved: reserved, must be set to 0
172607ca46eSDavid Howells  *
173607ca46eSDavid Howells  * Used by FSL_HV_IOCTL_DOORBELL
174607ca46eSDavid Howells  */
175607ca46eSDavid Howells struct fsl_hv_ioctl_prop {
176607ca46eSDavid Howells 	__u32 ret;
177607ca46eSDavid Howells 	__u32 handle;
178607ca46eSDavid Howells 	__u64 path;
179607ca46eSDavid Howells 	__u64 propname;
180607ca46eSDavid Howells 	__u64 propval;
181607ca46eSDavid Howells 	__u32 proplen;
182607ca46eSDavid Howells 	__u32 reserved;	/* padding to ensure structure is aligned */
183607ca46eSDavid Howells };
184607ca46eSDavid Howells 
185607ca46eSDavid Howells /* The ioctl type, documented in ioctl-number.txt */
186607ca46eSDavid Howells #define FSL_HV_IOCTL_TYPE	0xAF
187607ca46eSDavid Howells 
188607ca46eSDavid Howells /* Restart another partition */
189607ca46eSDavid Howells #define FSL_HV_IOCTL_PARTITION_RESTART \
190607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 1, struct fsl_hv_ioctl_restart)
191607ca46eSDavid Howells 
192607ca46eSDavid Howells /* Get a partition's status */
193607ca46eSDavid Howells #define FSL_HV_IOCTL_PARTITION_GET_STATUS \
194607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 2, struct fsl_hv_ioctl_status)
195607ca46eSDavid Howells 
196607ca46eSDavid Howells /* Boot another partition */
197607ca46eSDavid Howells #define FSL_HV_IOCTL_PARTITION_START \
198607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 3, struct fsl_hv_ioctl_start)
199607ca46eSDavid Howells 
200607ca46eSDavid Howells /* Stop this or another partition */
201607ca46eSDavid Howells #define FSL_HV_IOCTL_PARTITION_STOP \
202607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 4, struct fsl_hv_ioctl_stop)
203607ca46eSDavid Howells 
204607ca46eSDavid Howells /* Copy data from one partition to another */
205607ca46eSDavid Howells #define FSL_HV_IOCTL_MEMCPY \
206607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 5, struct fsl_hv_ioctl_memcpy)
207607ca46eSDavid Howells 
208607ca46eSDavid Howells /* Ring a doorbell */
209607ca46eSDavid Howells #define FSL_HV_IOCTL_DOORBELL \
210607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 6, struct fsl_hv_ioctl_doorbell)
211607ca46eSDavid Howells 
212607ca46eSDavid Howells /* Get a property from another guest's device tree */
213607ca46eSDavid Howells #define FSL_HV_IOCTL_GETPROP \
214607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 7, struct fsl_hv_ioctl_prop)
215607ca46eSDavid Howells 
216607ca46eSDavid Howells /* Set a property in another guest's device tree */
217607ca46eSDavid Howells #define FSL_HV_IOCTL_SETPROP \
218607ca46eSDavid Howells 	_IOWR(FSL_HV_IOCTL_TYPE, 8, struct fsl_hv_ioctl_prop)
219607ca46eSDavid Howells 
220607ca46eSDavid Howells 
221607ca46eSDavid Howells #endif /* _UAPIFSL_HYPERVISOR_H */
222