xref: /linux/include/uapi/linux/nitro_enclaves.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
115b760c3SAndra Paraschiv /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
215b760c3SAndra Paraschiv /*
3*059ebe4fSAndra Paraschiv  * Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
415b760c3SAndra Paraschiv  */
515b760c3SAndra Paraschiv 
615b760c3SAndra Paraschiv #ifndef _UAPI_LINUX_NITRO_ENCLAVES_H_
715b760c3SAndra Paraschiv #define _UAPI_LINUX_NITRO_ENCLAVES_H_
815b760c3SAndra Paraschiv 
915b760c3SAndra Paraschiv #include <linux/types.h>
1015b760c3SAndra Paraschiv 
1115b760c3SAndra Paraschiv /**
1215b760c3SAndra Paraschiv  * DOC: Nitro Enclaves (NE) Kernel Driver Interface
1315b760c3SAndra Paraschiv  */
1415b760c3SAndra Paraschiv 
1515b760c3SAndra Paraschiv /**
1615b760c3SAndra Paraschiv  * NE_CREATE_VM - The command is used to create a slot that is associated with
1715b760c3SAndra Paraschiv  *		  an enclave VM.
1815b760c3SAndra Paraschiv  *		  The generated unique slot id is an output parameter.
1915b760c3SAndra Paraschiv  *		  The ioctl can be invoked on the /dev/nitro_enclaves fd, before
2015b760c3SAndra Paraschiv  *		  setting any resources, such as memory and vCPUs, for an
2115b760c3SAndra Paraschiv  *		  enclave. Memory and vCPUs are set for the slot mapped to an enclave.
2215b760c3SAndra Paraschiv  *		  A NE CPU pool has to be set before calling this function. The
2315b760c3SAndra Paraschiv  *		  pool can be set after the NE driver load, using
2415b760c3SAndra Paraschiv  *		  /sys/module/nitro_enclaves/parameters/ne_cpus.
2515b760c3SAndra Paraschiv  *		  Its format is the detailed in the cpu-lists section:
2615b760c3SAndra Paraschiv  *		  https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
2715b760c3SAndra Paraschiv  *		  CPU 0 and its siblings have to remain available for the
2815b760c3SAndra Paraschiv  *		  primary / parent VM, so they cannot be set for enclaves. Full
2915b760c3SAndra Paraschiv  *		  CPU core(s), from the same NUMA node, need(s) to be included
3015b760c3SAndra Paraschiv  *		  in the CPU pool.
3115b760c3SAndra Paraschiv  *
3215b760c3SAndra Paraschiv  * Context: Process context.
3315b760c3SAndra Paraschiv  * Return:
3415b760c3SAndra Paraschiv  * * Enclave file descriptor		- Enclave file descriptor used with
3515b760c3SAndra Paraschiv  *					  ioctl calls to set vCPUs and memory
3615b760c3SAndra Paraschiv  *					  regions, then start the enclave.
3715b760c3SAndra Paraschiv  * *  -1				- There was a failure in the ioctl logic.
3815b760c3SAndra Paraschiv  * On failure, errno is set to:
3915b760c3SAndra Paraschiv  * * EFAULT				- copy_to_user() failure.
4015b760c3SAndra Paraschiv  * * ENOMEM				- Memory allocation failure for internal
4115b760c3SAndra Paraschiv  *					  bookkeeping variables.
4215b760c3SAndra Paraschiv  * * NE_ERR_NO_CPUS_AVAIL_IN_POOL	- No NE CPU pool set / no CPUs available
4315b760c3SAndra Paraschiv  *					  in the pool.
4415b760c3SAndra Paraschiv  * * Error codes from get_unused_fd_flags() and anon_inode_getfile().
4515b760c3SAndra Paraschiv  * * Error codes from the NE PCI device request.
4615b760c3SAndra Paraschiv  */
4715b760c3SAndra Paraschiv #define NE_CREATE_VM			_IOR(0xAE, 0x20, __u64)
4815b760c3SAndra Paraschiv 
4915b760c3SAndra Paraschiv /**
5015b760c3SAndra Paraschiv  * NE_ADD_VCPU - The command is used to set a vCPU for an enclave. The vCPU can
5115b760c3SAndra Paraschiv  *		 be auto-chosen from the NE CPU pool or it can be set by the
5215b760c3SAndra Paraschiv  *		 caller, with the note that it needs to be available in the NE
5315b760c3SAndra Paraschiv  *		 CPU pool. Full CPU core(s), from the same NUMA node, need(s) to
5415b760c3SAndra Paraschiv  *		 be associated with an enclave.
5515b760c3SAndra Paraschiv  *		 The vCPU id is an input / output parameter. If its value is 0,
5615b760c3SAndra Paraschiv  *		 then a CPU is chosen from the enclave CPU pool and returned via
5715b760c3SAndra Paraschiv  *		 this parameter.
5815b760c3SAndra Paraschiv  *		 The ioctl can be invoked on the enclave fd, before an enclave
5915b760c3SAndra Paraschiv  *		 is started.
6015b760c3SAndra Paraschiv  *
6115b760c3SAndra Paraschiv  * Context: Process context.
6215b760c3SAndra Paraschiv  * Return:
63*059ebe4fSAndra Paraschiv  * * 0					- Logic successfully completed.
6415b760c3SAndra Paraschiv  * *  -1				- There was a failure in the ioctl logic.
6515b760c3SAndra Paraschiv  * On failure, errno is set to:
6615b760c3SAndra Paraschiv  * * EFAULT				- copy_from_user() / copy_to_user() failure.
6715b760c3SAndra Paraschiv  * * ENOMEM				- Memory allocation failure for internal
6815b760c3SAndra Paraschiv  *					  bookkeeping variables.
6915b760c3SAndra Paraschiv  * * EIO				- Current task mm is not the same as the one
7015b760c3SAndra Paraschiv  *					  that created the enclave.
7115b760c3SAndra Paraschiv  * * NE_ERR_NO_CPUS_AVAIL_IN_POOL	- No CPUs available in the NE CPU pool.
7215b760c3SAndra Paraschiv  * * NE_ERR_VCPU_ALREADY_USED		- The provided vCPU is already used.
7315b760c3SAndra Paraschiv  * * NE_ERR_VCPU_NOT_IN_CPU_POOL	- The provided vCPU is not available in the
7415b760c3SAndra Paraschiv  *					  NE CPU pool.
7515b760c3SAndra Paraschiv  * * NE_ERR_VCPU_INVALID_CPU_CORE	- The core id of the provided vCPU is invalid
7615b760c3SAndra Paraschiv  *					  or out of range.
7715b760c3SAndra Paraschiv  * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state
7815b760c3SAndra Paraschiv  *					  (init = before being started).
7915b760c3SAndra Paraschiv  * * NE_ERR_INVALID_VCPU		- The provided vCPU is not in the available
8015b760c3SAndra Paraschiv  *					  CPUs range.
8115b760c3SAndra Paraschiv  * * Error codes from the NE PCI device request.
8215b760c3SAndra Paraschiv  */
8315b760c3SAndra Paraschiv #define NE_ADD_VCPU			_IOWR(0xAE, 0x21, __u32)
8415b760c3SAndra Paraschiv 
8515b760c3SAndra Paraschiv /**
8615b760c3SAndra Paraschiv  * NE_GET_IMAGE_LOAD_INFO - The command is used to get information needed for
8715b760c3SAndra Paraschiv  *			    in-memory enclave image loading e.g. offset in
8815b760c3SAndra Paraschiv  *			    enclave memory to start placing the enclave image.
8915b760c3SAndra Paraschiv  *			    The image load info is an input / output parameter.
9015b760c3SAndra Paraschiv  *			    It includes info provided by the caller - flags -
9115b760c3SAndra Paraschiv  *			    and returns the offset in enclave memory where to
9215b760c3SAndra Paraschiv  *			    start placing the enclave image.
9315b760c3SAndra Paraschiv  *			    The ioctl can be invoked on the enclave fd, before
9415b760c3SAndra Paraschiv  *			    an enclave is started.
9515b760c3SAndra Paraschiv  *
9615b760c3SAndra Paraschiv  * Context: Process context.
9715b760c3SAndra Paraschiv  * Return:
98*059ebe4fSAndra Paraschiv  * * 0				- Logic successfully completed.
9915b760c3SAndra Paraschiv  * *  -1			- There was a failure in the ioctl logic.
10015b760c3SAndra Paraschiv  * On failure, errno is set to:
10115b760c3SAndra Paraschiv  * * EFAULT			- copy_from_user() / copy_to_user() failure.
10215b760c3SAndra Paraschiv  * * NE_ERR_NOT_IN_INIT_STATE	- The enclave is not in init state (init =
10315b760c3SAndra Paraschiv  *				  before being started).
10415b760c3SAndra Paraschiv  * * NE_ERR_INVALID_FLAG_VALUE	- The value of the provided flag is invalid.
10515b760c3SAndra Paraschiv  */
10615b760c3SAndra Paraschiv #define NE_GET_IMAGE_LOAD_INFO		_IOWR(0xAE, 0x22, struct ne_image_load_info)
10715b760c3SAndra Paraschiv 
10815b760c3SAndra Paraschiv /**
10915b760c3SAndra Paraschiv  * NE_SET_USER_MEMORY_REGION - The command is used to set a memory region for an
11015b760c3SAndra Paraschiv  *			       enclave, given the allocated memory from the
11115b760c3SAndra Paraschiv  *			       userspace. Enclave memory needs to be from the
11215b760c3SAndra Paraschiv  *			       same NUMA node as the enclave CPUs.
11315b760c3SAndra Paraschiv  *			       The user memory region is an input parameter. It
11415b760c3SAndra Paraschiv  *			       includes info provided by the caller - flags,
11515b760c3SAndra Paraschiv  *			       memory size and userspace address.
11615b760c3SAndra Paraschiv  *			       The ioctl can be invoked on the enclave fd,
11715b760c3SAndra Paraschiv  *			       before an enclave is started.
11815b760c3SAndra Paraschiv  *
11915b760c3SAndra Paraschiv  * Context: Process context.
12015b760c3SAndra Paraschiv  * Return:
121*059ebe4fSAndra Paraschiv  * * 0					- Logic successfully completed.
12215b760c3SAndra Paraschiv  * *  -1				- There was a failure in the ioctl logic.
12315b760c3SAndra Paraschiv  * On failure, errno is set to:
12415b760c3SAndra Paraschiv  * * EFAULT				- copy_from_user() failure.
12515b760c3SAndra Paraschiv  * * EINVAL				- Invalid physical memory region(s) e.g.
12615b760c3SAndra Paraschiv  *					  unaligned address.
12715b760c3SAndra Paraschiv  * * EIO				- Current task mm is not the same as
12815b760c3SAndra Paraschiv  *					  the one that created the enclave.
12915b760c3SAndra Paraschiv  * * ENOMEM				- Memory allocation failure for internal
13015b760c3SAndra Paraschiv  *					  bookkeeping variables.
13115b760c3SAndra Paraschiv  * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state
13215b760c3SAndra Paraschiv  *					  (init = before being started).
13315b760c3SAndra Paraschiv  * * NE_ERR_INVALID_MEM_REGION_SIZE	- The memory size of the region is not
13415b760c3SAndra Paraschiv  *					  multiple of 2 MiB.
13515b760c3SAndra Paraschiv  * * NE_ERR_INVALID_MEM_REGION_ADDR	- Invalid user space address given.
13615b760c3SAndra Paraschiv  * * NE_ERR_UNALIGNED_MEM_REGION_ADDR	- Unaligned user space address given.
13715b760c3SAndra Paraschiv  * * NE_ERR_MEM_REGION_ALREADY_USED	- The memory region is already used.
13815b760c3SAndra Paraschiv  * * NE_ERR_MEM_NOT_HUGE_PAGE		- The memory region is not backed by
13915b760c3SAndra Paraschiv  *					  huge pages.
14015b760c3SAndra Paraschiv  * * NE_ERR_MEM_DIFFERENT_NUMA_NODE	- The memory region is not from the same
14115b760c3SAndra Paraschiv  *					  NUMA node as the CPUs.
14215b760c3SAndra Paraschiv  * * NE_ERR_MEM_MAX_REGIONS		- The number of memory regions set for
14315b760c3SAndra Paraschiv  *					  the enclave reached maximum.
14415b760c3SAndra Paraschiv  * * NE_ERR_INVALID_PAGE_SIZE		- The memory region is not backed by
14515b760c3SAndra Paraschiv  *					  pages multiple of 2 MiB.
14615b760c3SAndra Paraschiv  * * NE_ERR_INVALID_FLAG_VALUE		- The value of the provided flag is invalid.
14715b760c3SAndra Paraschiv  * * Error codes from get_user_pages().
14815b760c3SAndra Paraschiv  * * Error codes from the NE PCI device request.
14915b760c3SAndra Paraschiv  */
15015b760c3SAndra Paraschiv #define NE_SET_USER_MEMORY_REGION	_IOW(0xAE, 0x23, struct ne_user_memory_region)
15115b760c3SAndra Paraschiv 
15215b760c3SAndra Paraschiv /**
15315b760c3SAndra Paraschiv  * NE_START_ENCLAVE - The command is used to trigger enclave start after the
15415b760c3SAndra Paraschiv  *		      enclave resources, such as memory and CPU, have been set.
15515b760c3SAndra Paraschiv  *		      The enclave start info is an input / output parameter. It
15615b760c3SAndra Paraschiv  *		      includes info provided by the caller - enclave cid and
15715b760c3SAndra Paraschiv  *		      flags - and returns the cid (if input cid is 0).
15815b760c3SAndra Paraschiv  *		      The ioctl can be invoked on the enclave fd, after an
15915b760c3SAndra Paraschiv  *		      enclave slot is created and resources, such as memory and
16015b760c3SAndra Paraschiv  *		      vCPUs are set for an enclave.
16115b760c3SAndra Paraschiv  *
16215b760c3SAndra Paraschiv  * Context: Process context.
16315b760c3SAndra Paraschiv  * Return:
164*059ebe4fSAndra Paraschiv  * * 0					- Logic successfully completed.
16515b760c3SAndra Paraschiv  * *  -1				- There was a failure in the ioctl logic.
16615b760c3SAndra Paraschiv  * On failure, errno is set to:
16715b760c3SAndra Paraschiv  * * EFAULT				- copy_from_user() / copy_to_user() failure.
16815b760c3SAndra Paraschiv  * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state
16915b760c3SAndra Paraschiv  *					  (init = before being started).
17015b760c3SAndra Paraschiv  * * NE_ERR_NO_MEM_REGIONS_ADDED	- No memory regions are set.
17115b760c3SAndra Paraschiv  * * NE_ERR_NO_VCPUS_ADDED		- No vCPUs are set.
17215b760c3SAndra Paraschiv  * *  NE_ERR_FULL_CORES_NOT_USED	- Full core(s) not set for the enclave.
17315b760c3SAndra Paraschiv  * * NE_ERR_ENCLAVE_MEM_MIN_SIZE	- Enclave memory is less than minimum
17415b760c3SAndra Paraschiv  *					  memory size (64 MiB).
17515b760c3SAndra Paraschiv  * * NE_ERR_INVALID_FLAG_VALUE		- The value of the provided flag is invalid.
17615b760c3SAndra Paraschiv  * *  NE_ERR_INVALID_ENCLAVE_CID	- The provided enclave CID is invalid.
17715b760c3SAndra Paraschiv  * * Error codes from the NE PCI device request.
17815b760c3SAndra Paraschiv  */
17915b760c3SAndra Paraschiv #define NE_START_ENCLAVE		_IOWR(0xAE, 0x24, struct ne_enclave_start_info)
18015b760c3SAndra Paraschiv 
18115b760c3SAndra Paraschiv /**
18215b760c3SAndra Paraschiv  * DOC: NE specific error codes
18315b760c3SAndra Paraschiv  */
18415b760c3SAndra Paraschiv 
18515b760c3SAndra Paraschiv /**
18615b760c3SAndra Paraschiv  * NE_ERR_VCPU_ALREADY_USED - The provided vCPU is already used.
18715b760c3SAndra Paraschiv  */
18815b760c3SAndra Paraschiv #define NE_ERR_VCPU_ALREADY_USED		(256)
18915b760c3SAndra Paraschiv /**
19015b760c3SAndra Paraschiv  * NE_ERR_VCPU_NOT_IN_CPU_POOL - The provided vCPU is not available in the
19115b760c3SAndra Paraschiv  *				 NE CPU pool.
19215b760c3SAndra Paraschiv  */
19315b760c3SAndra Paraschiv #define NE_ERR_VCPU_NOT_IN_CPU_POOL		(257)
19415b760c3SAndra Paraschiv /**
19515b760c3SAndra Paraschiv  * NE_ERR_VCPU_INVALID_CPU_CORE - The core id of the provided vCPU is invalid
19615b760c3SAndra Paraschiv  *				  or out of range of the NE CPU pool.
19715b760c3SAndra Paraschiv  */
19815b760c3SAndra Paraschiv #define NE_ERR_VCPU_INVALID_CPU_CORE		(258)
19915b760c3SAndra Paraschiv /**
20015b760c3SAndra Paraschiv  * NE_ERR_INVALID_MEM_REGION_SIZE - The user space memory region size is not
20115b760c3SAndra Paraschiv  *				    multiple of 2 MiB.
20215b760c3SAndra Paraschiv  */
20315b760c3SAndra Paraschiv #define NE_ERR_INVALID_MEM_REGION_SIZE		(259)
20415b760c3SAndra Paraschiv /**
20515b760c3SAndra Paraschiv  * NE_ERR_INVALID_MEM_REGION_ADDR - The user space memory region address range
20615b760c3SAndra Paraschiv  *				    is invalid.
20715b760c3SAndra Paraschiv  */
20815b760c3SAndra Paraschiv #define NE_ERR_INVALID_MEM_REGION_ADDR		(260)
20915b760c3SAndra Paraschiv /**
21015b760c3SAndra Paraschiv  * NE_ERR_UNALIGNED_MEM_REGION_ADDR - The user space memory region address is
21115b760c3SAndra Paraschiv  *				      not aligned.
21215b760c3SAndra Paraschiv  */
21315b760c3SAndra Paraschiv #define NE_ERR_UNALIGNED_MEM_REGION_ADDR	(261)
21415b760c3SAndra Paraschiv /**
21515b760c3SAndra Paraschiv  * NE_ERR_MEM_REGION_ALREADY_USED - The user space memory region is already used.
21615b760c3SAndra Paraschiv  */
21715b760c3SAndra Paraschiv #define NE_ERR_MEM_REGION_ALREADY_USED		(262)
21815b760c3SAndra Paraschiv /**
21915b760c3SAndra Paraschiv  * NE_ERR_MEM_NOT_HUGE_PAGE - The user space memory region is not backed by
22015b760c3SAndra Paraschiv  *			      contiguous physical huge page(s).
22115b760c3SAndra Paraschiv  */
22215b760c3SAndra Paraschiv #define NE_ERR_MEM_NOT_HUGE_PAGE		(263)
22315b760c3SAndra Paraschiv /**
22415b760c3SAndra Paraschiv  * NE_ERR_MEM_DIFFERENT_NUMA_NODE - The user space memory region is backed by
22515b760c3SAndra Paraschiv  *				    pages from different NUMA nodes than the CPUs.
22615b760c3SAndra Paraschiv  */
22715b760c3SAndra Paraschiv #define NE_ERR_MEM_DIFFERENT_NUMA_NODE		(264)
22815b760c3SAndra Paraschiv /**
22915b760c3SAndra Paraschiv  * NE_ERR_MEM_MAX_REGIONS - The supported max memory regions per enclaves has
23015b760c3SAndra Paraschiv  *			    been reached.
23115b760c3SAndra Paraschiv  */
23215b760c3SAndra Paraschiv #define NE_ERR_MEM_MAX_REGIONS			(265)
23315b760c3SAndra Paraschiv /**
23415b760c3SAndra Paraschiv  * NE_ERR_NO_MEM_REGIONS_ADDED - The command to start an enclave is triggered
23515b760c3SAndra Paraschiv  *				 and no memory regions are added.
23615b760c3SAndra Paraschiv  */
23715b760c3SAndra Paraschiv #define NE_ERR_NO_MEM_REGIONS_ADDED		(266)
23815b760c3SAndra Paraschiv /**
23915b760c3SAndra Paraschiv  * NE_ERR_NO_VCPUS_ADDED - The command to start an enclave is triggered and no
24015b760c3SAndra Paraschiv  *			   vCPUs are added.
24115b760c3SAndra Paraschiv  */
24215b760c3SAndra Paraschiv #define NE_ERR_NO_VCPUS_ADDED			(267)
24315b760c3SAndra Paraschiv /**
24415b760c3SAndra Paraschiv  * NE_ERR_ENCLAVE_MEM_MIN_SIZE - The enclave memory size is lower than the
24515b760c3SAndra Paraschiv  *				 minimum supported.
24615b760c3SAndra Paraschiv  */
24715b760c3SAndra Paraschiv #define NE_ERR_ENCLAVE_MEM_MIN_SIZE		(268)
24815b760c3SAndra Paraschiv /**
24915b760c3SAndra Paraschiv  * NE_ERR_FULL_CORES_NOT_USED - The command to start an enclave is triggered and
25015b760c3SAndra Paraschiv  *				full CPU cores are not set.
25115b760c3SAndra Paraschiv  */
25215b760c3SAndra Paraschiv #define NE_ERR_FULL_CORES_NOT_USED		(269)
25315b760c3SAndra Paraschiv /**
25415b760c3SAndra Paraschiv  * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state when setting
25515b760c3SAndra Paraschiv  *			      resources or triggering start.
25615b760c3SAndra Paraschiv  */
25715b760c3SAndra Paraschiv #define NE_ERR_NOT_IN_INIT_STATE		(270)
25815b760c3SAndra Paraschiv /**
25915b760c3SAndra Paraschiv  * NE_ERR_INVALID_VCPU - The provided vCPU is out of range of the available CPUs.
26015b760c3SAndra Paraschiv  */
26115b760c3SAndra Paraschiv #define NE_ERR_INVALID_VCPU			(271)
26215b760c3SAndra Paraschiv /**
26315b760c3SAndra Paraschiv  * NE_ERR_NO_CPUS_AVAIL_IN_POOL - The command to create an enclave is triggered
26415b760c3SAndra Paraschiv  *				  and no CPUs are available in the pool.
26515b760c3SAndra Paraschiv  */
26615b760c3SAndra Paraschiv #define NE_ERR_NO_CPUS_AVAIL_IN_POOL		(272)
26715b760c3SAndra Paraschiv /**
26815b760c3SAndra Paraschiv  * NE_ERR_INVALID_PAGE_SIZE - The user space memory region is not backed by pages
26915b760c3SAndra Paraschiv  *			      multiple of 2 MiB.
27015b760c3SAndra Paraschiv  */
27115b760c3SAndra Paraschiv #define NE_ERR_INVALID_PAGE_SIZE		(273)
27215b760c3SAndra Paraschiv /**
27315b760c3SAndra Paraschiv  * NE_ERR_INVALID_FLAG_VALUE - The provided flag value is invalid.
27415b760c3SAndra Paraschiv  */
27515b760c3SAndra Paraschiv #define NE_ERR_INVALID_FLAG_VALUE		(274)
27615b760c3SAndra Paraschiv /**
27715b760c3SAndra Paraschiv  * NE_ERR_INVALID_ENCLAVE_CID - The provided enclave CID is invalid, either
27815b760c3SAndra Paraschiv  *				being a well-known value or the CID of the
27915b760c3SAndra Paraschiv  *				parent / primary VM.
28015b760c3SAndra Paraschiv  */
28115b760c3SAndra Paraschiv #define NE_ERR_INVALID_ENCLAVE_CID		(275)
28215b760c3SAndra Paraschiv 
28315b760c3SAndra Paraschiv /**
28415b760c3SAndra Paraschiv  * DOC: Image load info flags
28515b760c3SAndra Paraschiv  */
28615b760c3SAndra Paraschiv 
28715b760c3SAndra Paraschiv /**
28815b760c3SAndra Paraschiv  * NE_EIF_IMAGE - Enclave Image Format (EIF)
28915b760c3SAndra Paraschiv  */
29015b760c3SAndra Paraschiv #define NE_EIF_IMAGE			(0x01)
29115b760c3SAndra Paraschiv 
29215b760c3SAndra Paraschiv #define NE_IMAGE_LOAD_MAX_FLAG_VAL	(0x02)
29315b760c3SAndra Paraschiv 
29415b760c3SAndra Paraschiv /**
29515b760c3SAndra Paraschiv  * struct ne_image_load_info - Info necessary for in-memory enclave image
29615b760c3SAndra Paraschiv  *			       loading (in / out).
29715b760c3SAndra Paraschiv  * @flags:		Flags to determine the enclave image type
29815b760c3SAndra Paraschiv  *			(e.g. Enclave Image Format - EIF) (in).
29915b760c3SAndra Paraschiv  * @memory_offset:	Offset in enclave memory where to start placing the
30015b760c3SAndra Paraschiv  *			enclave image (out).
30115b760c3SAndra Paraschiv  */
30215b760c3SAndra Paraschiv struct ne_image_load_info {
30315b760c3SAndra Paraschiv 	__u64	flags;
30415b760c3SAndra Paraschiv 	__u64	memory_offset;
30515b760c3SAndra Paraschiv };
30615b760c3SAndra Paraschiv 
30715b760c3SAndra Paraschiv /**
30815b760c3SAndra Paraschiv  * DOC: User memory region flags
30915b760c3SAndra Paraschiv  */
31015b760c3SAndra Paraschiv 
31115b760c3SAndra Paraschiv /**
31215b760c3SAndra Paraschiv  * NE_DEFAULT_MEMORY_REGION - Memory region for enclave general usage.
31315b760c3SAndra Paraschiv  */
31415b760c3SAndra Paraschiv #define NE_DEFAULT_MEMORY_REGION	(0x00)
31515b760c3SAndra Paraschiv 
31615b760c3SAndra Paraschiv #define NE_MEMORY_REGION_MAX_FLAG_VAL	(0x01)
31715b760c3SAndra Paraschiv 
31815b760c3SAndra Paraschiv /**
31915b760c3SAndra Paraschiv  * struct ne_user_memory_region - Memory region to be set for an enclave (in).
32015b760c3SAndra Paraschiv  * @flags:		Flags to determine the usage for the memory region (in).
32115b760c3SAndra Paraschiv  * @memory_size:	The size, in bytes, of the memory region to be set for
32215b760c3SAndra Paraschiv  *			an enclave (in).
32315b760c3SAndra Paraschiv  * @userspace_addr:	The start address of the userspace allocated memory of
32415b760c3SAndra Paraschiv  *			the memory region to set for an enclave (in).
32515b760c3SAndra Paraschiv  */
32615b760c3SAndra Paraschiv struct ne_user_memory_region {
32715b760c3SAndra Paraschiv 	__u64	flags;
32815b760c3SAndra Paraschiv 	__u64	memory_size;
32915b760c3SAndra Paraschiv 	__u64	userspace_addr;
33015b760c3SAndra Paraschiv };
33115b760c3SAndra Paraschiv 
33215b760c3SAndra Paraschiv /**
33315b760c3SAndra Paraschiv  * DOC: Enclave start info flags
33415b760c3SAndra Paraschiv  */
33515b760c3SAndra Paraschiv 
33615b760c3SAndra Paraschiv /**
33715b760c3SAndra Paraschiv  * NE_ENCLAVE_PRODUCTION_MODE - Start enclave in production mode.
33815b760c3SAndra Paraschiv  */
33915b760c3SAndra Paraschiv #define NE_ENCLAVE_PRODUCTION_MODE	(0x00)
34015b760c3SAndra Paraschiv /**
34115b760c3SAndra Paraschiv  * NE_ENCLAVE_DEBUG_MODE - Start enclave in debug mode.
34215b760c3SAndra Paraschiv  */
34315b760c3SAndra Paraschiv #define NE_ENCLAVE_DEBUG_MODE		(0x01)
34415b760c3SAndra Paraschiv 
34515b760c3SAndra Paraschiv #define NE_ENCLAVE_START_MAX_FLAG_VAL	(0x02)
34615b760c3SAndra Paraschiv 
34715b760c3SAndra Paraschiv /**
34815b760c3SAndra Paraschiv  * struct ne_enclave_start_info - Setup info necessary for enclave start (in / out).
34915b760c3SAndra Paraschiv  * @flags:		Flags for the enclave to start with (e.g. debug mode) (in).
35015b760c3SAndra Paraschiv  * @enclave_cid:	Context ID (CID) for the enclave vsock device. If 0 as
35115b760c3SAndra Paraschiv  *			input, the CID is autogenerated by the hypervisor and
35215b760c3SAndra Paraschiv  *			returned back as output by the driver (in / out).
35315b760c3SAndra Paraschiv  */
35415b760c3SAndra Paraschiv struct ne_enclave_start_info {
35515b760c3SAndra Paraschiv 	__u64	flags;
35615b760c3SAndra Paraschiv 	__u64	enclave_cid;
35715b760c3SAndra Paraschiv };
35815b760c3SAndra Paraschiv 
35915b760c3SAndra Paraschiv #endif /* _UAPI_LINUX_NITRO_ENCLAVES_H_ */
360