1 /*
2  * Copyright 2021 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 #define HF_INVALID_VM_ID 0x7fff
12 
13 /**
14  * The bit of the VM ID which indicates whether the VM ID is allocated by the
15  * normal world or the secure world.
16  */
17 #define HF_VM_ID_WORLD_MASK 0x8000
18 
19 /** The special VM ID reserved for the hypervisor in the normal world. */
20 #define HF_HYPERVISOR_VM_ID 0
21 
22 /**
23  * An offset to use when assigning VM IDs within the current world.
24  * The offset from HF_VM_ID_BASE is needed because VM ID `HF_VM_ID_BASE + 0` is
25  * reserved for the hypervisor/SPM.
26  */
27 #define HF_VM_ID_OFFSET (HF_VM_ID_BASE + 1)
28 
29 /** The index of the primary VM, if it exists in this world. */
30 #define HF_PRIMARY_VM_INDEX 0
31 
32 /**
33  * The special VM ID reserved for the OS or SPMC running in the trusted
34  * execution environment, e.g. secure EL1 or EL2 on AArch64.
35  */
36 #define HF_TEE_VM_ID 0x8000
37 
38 /**
39  * The SPMC VM ID used to reference the SPMC by a SP (at secure virtual FF-A
40  * instance), or by the SPMD at secure physical FF-A instance.
41  */
42 #define HF_SPMC_VM_ID 0x8000
43 
44 /**
45  * The SPMD VM ID used to reference the SPMD by the SPMC at secure physical
46  * FF-A instance. It may be used to exchange special messages with the SPMC
47  * like power management events.
48  */
49 #define HF_SPMD_VM_ID 0xFFFF
50 
51 /* Reserve 63 IDs for SPMD Logical Partitions. */
52 #define EL3_SPMD_LP_ID_END (HF_SPMD_VM_ID - 1)
53 #define EL3_SPMD_LP_ID_START (EL3_SPMD_LP_ID_END - 62)
54