1 /*
2  * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #pragma once
8 
9 /*
10  * When performing a seL4_SysVMEnter seL4 expects certain guest state to be
11  * placed in the message registers. These defines indicates which MRs hold
12  * which values. Whenever a VMEnter returns seL4 will also fill these registers
13  * with the corresponding guest state
14  */
15 #define SEL4_VMENTER_CALL_EIP_MR 0
16 #define SEL4_VMENTER_CALL_CONTROL_PPC_MR 1
17 #define SEL4_VMENTER_CALL_CONTROL_ENTRY_MR 2
18 
19 /*
20  * In addition to the above message registers, if a VMEnter results in
21  * a fault the following constants describe the contents of the message
22  * registers that contain fault specific information
23  */
24 #define SEL4_VMENTER_FAULT_REASON_MR 3
25 #define SEL4_VMENTER_FAULT_QUALIFICATION_MR 4
26 #define SEL4_VMENTER_FAULT_INSTRUCTION_LEN_MR 5
27 #define SEL4_VMENTER_FAULT_GUEST_PHYSICAL_MR 6
28 #define SEL4_VMENTER_FAULT_RFLAGS_MR 7
29 #define SEL4_VMENTER_FAULT_GUEST_INT_MR 8
30 #define SEL4_VMENTER_FAULT_CR3_MR 9
31 #define SEL4_VMENTER_FAULT_EAX 10
32 #define SEL4_VMENTER_FAULT_EBX 11
33 #define SEL4_VMENTER_FAULT_ECX 12
34 #define SEL4_VMENTER_FAULT_EDX 13
35 #define SEL4_VMENTER_FAULT_ESI 14
36 #define SEL4_VMENTER_FAULT_EDI 15
37 #define SEL4_VMENTER_FAULT_EBP 16
38 
39 /*
40  * After performing a seL4_SysVMEnter the msgInfo register is set to indicate
41  * whether a return back to this thread happened due to a fault in the associated
42  * VCPU, or a notification was received on the bound notification object.
43  * If using the seL4_VMEnter wrapper function, then this is the return value
44  *
45  * In the case of a notification the badge register is the received notification
46  * and the message registers are set in the same format as we passed them to
47  * seL4_SysVMEnter
48  *
49  * If a fault is returned then the badge register is empty and the message
50  * format is a combination of the format we passed to seL4_SysVMEnter with
51  * additional registers described with the SEL4_VMENTER_FAULT_ constants
52  */
53 #define SEL4_VMENTER_RESULT_FAULT 1
54 #define SEL4_VMENTER_RESULT_NOTIF 0
55 
56 /*
57  * Constants describing the number of message registers returned by the
58  * kernel for each of the return cases of VMEnter
59  */
60 #define SEL4_VMENTER_RESULT_FAULT_LEN 17
61 #define SEL4_VMENTER_RESULT_NOTIF_LEN 3
62 
63