aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mvp/mvpkm/mmu_defs.h
blob: 340b91bfc649bed0f376c4165795a84ceac5262b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
 * Linux 2.6.32 and later Kernel module for VMware MVP Hypervisor Support
 *
 * Copyright (C) 2010-2012 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; see the file COPYING.  If not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#line 5

/**
 *  @file
 *
 *  @brief MMU-related definitions.
 */

#ifndef _MMU_DEFS_H_
#define _MMU_DEFS_H_

#define INCLUDE_ALLOW_MVPD
#define INCLUDE_ALLOW_VMX
#define INCLUDE_ALLOW_MODULE
#define INCLUDE_ALLOW_MONITOR
#define INCLUDE_ALLOW_HOSTUSER
#define INCLUDE_ALLOW_GUESTUSER
#define INCLUDE_ALLOW_PV
#define INCLUDE_ALLOW_GPL
#include "include_check.h"

/**
 * @name ARM address space identifier.
 * @{
 */
#define ARM_ASID_BITS 8
#define ARM_ASID_NUM  (1 << ARM_ASID_BITS)
#define ARM_ASID_MASK (ARM_ASID_NUM - 1)
/*@}*/

/**
 * @name ARM level 1 and 2 page table sizes.
 * @{
 */
#define ARM_L1PT_ORDER        14
#define ARM_L2PT_FINE_ORDER   12
#define ARM_L2PT_COARSE_ORDER 10

#define ARM_L1D_SECTION_ORDER      20
#define ARM_L1D_SUPERSECTION_ORDER 24

#define ARM_L2D_SMALL_ORDER 12
#define ARM_L2D_LARGE_ORDER 16

#define ARM_L1PT_SIZE        (1 << ARM_L1PT_ORDER)
#define ARM_L2PT_FINE_SIZE   (1 << ARM_L2PT_FINE_ORDER)
#define ARM_L2PT_COARSE_SIZE (1 << ARM_L2PT_COARSE_ORDER)

#define ARM_L1D_SECTION_SIZE      (1 << ARM_L1D_SECTION_ORDER)
#define ARM_L1D_SUPERSECTION_SIZE (1 << ARM_L1D_SUPERSECTION_ORDER)

#define ARM_L2D_SMALL_SIZE (1 << ARM_L2D_SMALL_ORDER)
#define ARM_L2D_LARGE_SIZE (1 << ARM_L2D_LARGE_ORDER)

#define ARM_L2PT_COARSE_PER_PAGE (PAGE_SIZE / ARM_L2PT_COARSE_SIZE)

#define ARM_L1PT_ENTRIES        (ARM_L1PT_SIZE / sizeof(ARM_L1D))
#define ARM_L2PT_FINE_ENTRIES   (ARM_L2PT_FINE_SIZE / sizeof(ARM_L2D))
#define ARM_L2PT_COARSE_ENTRIES (ARM_L2PT_COARSE_SIZE / sizeof(ARM_L2D))
/*@}*/

/**
 * @brief Level 1 descriptor type field values.
 * @{
 */
#define ARM_L1D_TYPE_INVALID         0
#define ARM_L1D_TYPE_COARSE          1
#define ARM_L1D_TYPE_SECTION         2
#define ARM_L1D_TYPE_SUPERSECTION    2
/*@}*/

/**
 * @name Decomposition of virtual addresses for page table indexing.
 * @{
 */
#define ARM_L1PT_INDX(addr)        MVP_EXTRACT_FIELD((addr), 20, 12)
#define ARM_L2PT_COARSE_INDX(addr) MVP_EXTRACT_FIELD((addr), 12, 8)
/*@}*/

/**
 * @name Mapping from the VA/PA/MA of a LxD entry to its table index.
 * @{
 */
#define ARM_L1D_PTR_INDX(l1dp) MVP_BITS((uint32)(l1dp), 2, ARM_L1PT_ORDER - 1)
#define ARM_L2D_PTR_INDX(l2dp) MVP_BITS((uint32)(l2dp), 2, ARM_L2PT_COARSE_ORDER - 1)
/*@}*/

/**
 * @name L1D base index <-> MA.
 * @{
 */
#define ARM_L1D_BASE_ADDR(base) ((base) << ARM_L1PT_ORDER)
#define ARM_L1D_ADDR_BASE(addr) ((addr) >> ARM_L1PT_ORDER)
/*@}*/

/**
 * @brief Which 1 MB section of a 16 MB supersection does the given addr lie in?
 */
#define ARM_SUPER_SECTION_INDEX(addr) MVP_EXTRACT_FIELD((addr), 20, 4)

/**
 * @name L1D entry base <-> either MA or MA of a second-level table.
 * @{
 */
#define ARM_L1D_SUPERSECTION_BASE_ADDR(base) ((base) << ARM_L1D_SUPERSECTION_ORDER)
#define ARM_L1D_SUPERSECTION_ADDR_BASE(addr) ((addr) >> ARM_L1D_SUPERSECTION_ORDER)
#define ARM_L1D_SECTION_BASE_ADDR(base) ((base) << ARM_L1D_SECTION_ORDER)
#define ARM_L1D_SECTION_ADDR_BASE(addr) ((addr) >> ARM_L1D_SECTION_ORDER)
#define ARM_L1D_COARSE_BASE_ADDR(base)  ((base) << ARM_L2PT_COARSE_ORDER)
#define ARM_L1D_COARSE_ADDR_BASE(addr)  ((addr) >> ARM_L2PT_COARSE_ORDER)
#define ARM_L1D_FINE_BASE_ADDR(base)    ((base) << ARM_L2PT_FINE_ORDER)
#define ARM_L1D_FINE_ADDR_BASE(addr)    ((addr) >> ARM_L2PT_FINE_ORDER)
/*@}*/

/*
 * The number of L1 page directory pages the service the entire
 * virtual space
 */
#define ARM_L1PT_PAGES (1<<(ARM_L1PT_ORDER - PAGE_ORDER))


/**
 * @name Level 2 descriptor type field values.
 * @{
 */
#define ARM_L2D_TYPE_INVALID       0
#define ARM_L2D_TYPE_LARGE         0
#define ARM_L2D_TYPE_SMALL         1
#define ARM_L2D_XTYPE_LARGE        1
#define ARM_L2D_XTYPE_SMALL        2
#define ARM_L2D_XTYPE_SMALL_NX     3
/*@}*/

/**
 * @name Small/Large L2D (in coarse table) base <-> MA conversion.
 * @{
 */
#define ARM_L2D_LARGE_BASE_ADDR(base)    ((base) << ARM_L2D_LARGE_ORDER)
#define ARM_L2D_LARGE_ADDR_BASE(addr)    ((addr) >> ARM_L2D_LARGE_ORDER)
#define ARM_L2D_SMALL_BASE_ADDR(base)    ((base) << ARM_L2D_SMALL_ORDER)
#define ARM_L2D_SMALL_ADDR_BASE(addr)    ((addr) >> ARM_L2D_SMALL_ORDER)

#define ARM_L2D_SMALL_PAGE_NUMBER(addr)  ARM_L2D_SMALL_ADDR_BASE(addr)
#define ARM_L2D_SMALL_PAGE_OFFSET(addr)  ((addr) & (PAGE_SIZE - 1))
/* @}*/

/**
 * @brief ARM page table descriptor access permissions for the AP field.
 * @{
 */
#define ARM_PERM_NONE       0
#define ARM_PERM_PRIV_RW    1
#define ARM_PERM_USER_RO    2
#define ARM_PERM_USER_RW    3
/*@}*/

/**
 * @name Simplified access permission model introduced in ARMv7.
 *
 * AP[0] is an access flag, AP[2:1] are one of the following.
 *
 * @{
 */
#define ARM_SIMPLE_PERM_KERN_RW 0
#define ARM_SIMPLE_PERM_USER_RW 1
#define ARM_SIMPLE_PERM_KERN_RO 2
#define ARM_SIMPLE_PERM_USER_RO 3

#define ARM_SIMPLE_PERM_AP_KERN 1
#define ARM_SIMPLE_PERM_AP_USER 3

#define ARM_SIMPLE_PERM_APX_RW 0
#define ARM_SIMPLE_PERM_APX_RO 1

#define ARM_SIMPLE_PERM_AP(x)  ((MVP_BIT(x, 0) << 1) | 1)
#define ARM_SIMPLE_PERM_APX(x) MVP_BIT(x, 1)
/*@}*/

/**
 * @name ARM domains.
 * @{
 */
#define ARM_DOMAINS            16

#define ARM_DOMAIN_NOACCESS    0
#define ARM_DOMAIN_CLIENT      1
#define ARM_DOMAIN_RESERVED    2
#define ARM_DOMAIN_MANAGER     3
/*@}*/

#define ARM_DOMAIN_INDEX(dacr,dom)    MVP_EXTRACT_FIELD((dacr), 2*(dom), 2)
#define ARM_DOMAIN_ACCESS(dom,access) ((access) << (2*(dom)))

/*
 * Cache-related definitions.
 */
#define ARM_CACHE_LEVELS_MAX    8
#define ARM_CACHE_LINE_SIZE_MAX 2048

#endif /// _MMU_DEFS_H_