Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
28e2daa9
"plat/git@web.lueluesay.top:root/arm-trusted-firmware.git" did not exist on "9272a8fd7bd40089fadd91889fe1b0ea22b7bc75"
Commit
28e2daa9
authored
Aug 03, 2020
by
Madhukar Pappireddy
Committed by
TrustedFirmware Code Review
Aug 03, 2020
Browse files
Merge "Aarch32 xlat_tables lib: Fix MISRA-2012 defects" into integration
parents
adca03e6
77a38690
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/xlat_tables/aarch32/nonlpae_tables.c
View file @
28e2daa9
/*
/*
* Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
* Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
* Copyright (c) 2014-20
19
, Arm Limited. All rights reserved.
* Copyright (c) 2014-20
20
, Arm Limited. All rights reserved.
* Copyright (c) 2014, STMicroelectronics International N.V.
* Copyright (c) 2014, STMicroelectronics International N.V.
* All rights reserved.
* All rights reserved.
*
*
...
@@ -30,8 +30,8 @@ This module is to be used when LPAE is not supported"
...
@@ -30,8 +30,8 @@ This module is to be used when LPAE is not supported"
CASSERT
(
PLAT_VIRT_ADDR_SPACE_SIZE
==
(
1ULL
<<
32
),
invalid_vaddr_space_size
);
CASSERT
(
PLAT_VIRT_ADDR_SPACE_SIZE
==
(
1ULL
<<
32
),
invalid_vaddr_space_size
);
CASSERT
(
PLAT_PHY_ADDR_SPACE_SIZE
==
(
1ULL
<<
32
),
invalid_paddr_space_size
);
CASSERT
(
PLAT_PHY_ADDR_SPACE_SIZE
==
(
1ULL
<<
32
),
invalid_paddr_space_size
);
#define MMU32B_UNSET_DESC ~0
ul
#define MMU32B_UNSET_DESC ~0
UL
#define MMU32B_INVALID_DESC 0
ul
#define MMU32B_INVALID_DESC 0
UL
#define MT_UNKNOWN ~0U
#define MT_UNKNOWN ~0U
...
@@ -40,38 +40,38 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
...
@@ -40,38 +40,38 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
*/
*/
/* Sharable */
/* Sharable */
#define MMU32B_TTB_S (1 << 1)
#define MMU32B_TTB_S (1
U
<< 1)
/* Not Outer Sharable */
/* Not Outer Sharable */
#define MMU32B_TTB_NOS (1 << 5)
#define MMU32B_TTB_NOS (1
U
<< 5)
/* Normal memory, Inner Non-cacheable */
/* Normal memory, Inner Non-cacheable */
#define MMU32B_TTB_IRGN_NC 0
#define MMU32B_TTB_IRGN_NC 0
U
/* Normal memory, Inner Write-Back Write-Allocate Cacheable */
/* Normal memory, Inner Write-Back Write-Allocate Cacheable */
#define MMU32B_TTB_IRGN_WBWA (1 << 6)
#define MMU32B_TTB_IRGN_WBWA (1
U
<< 6)
/* Normal memory, Inner Write-Through Cacheable */
/* Normal memory, Inner Write-Through Cacheable */
#define MMU32B_TTB_IRGN_WT 1
#define MMU32B_TTB_IRGN_WT 1
U
/* Normal memory, Inner Write-Back no Write-Allocate Cacheable */
/* Normal memory, Inner Write-Back no Write-Allocate Cacheable */
#define MMU32B_TTB_IRGN_WB (1 | (1 << 6))
#define MMU32B_TTB_IRGN_WB (1
U
| (1
U
<< 6))
/* Normal memory, Outer Write-Back Write-Allocate Cacheable */
/* Normal memory, Outer Write-Back Write-Allocate Cacheable */
#define MMU32B_TTB_RNG_WBWA (1 << 3)
#define MMU32B_TTB_RNG_WBWA (1
U
<< 3)
#define MMU32B_DEFAULT_ATTRS \
#define MMU32B_DEFAULT_ATTRS \
(MMU32B_TTB_S | MMU32B_TTB_NOS | \
(MMU32B_TTB_S | MMU32B_TTB_NOS | \
MMU32B_TTB_IRGN_WBWA | MMU32B_TTB_RNG_WBWA)
MMU32B_TTB_IRGN_WBWA | MMU32B_TTB_RNG_WBWA)
/* armv7 memory mapping attributes: section mapping */
/* armv7 memory mapping attributes: section mapping */
#define SECTION_SECURE (0 << 19)
#define SECTION_SECURE (0
U
<< 19)
#define SECTION_NOTSECURE (1 << 19)
#define SECTION_NOTSECURE (1
U
<< 19)
#define SECTION_SHARED (1 << 16)
#define SECTION_SHARED (1
U
<< 16)
#define SECTION_NOTGLOBAL (1 << 17)
#define SECTION_NOTGLOBAL (1
U
<< 17)
#define SECTION_ACCESS_FLAG (1 << 10)
#define SECTION_ACCESS_FLAG (1
U
<< 10)
#define SECTION_UNPRIV (1 << 11)
#define SECTION_UNPRIV (1
U
<< 11)
#define SECTION_RO (1 << 15)
#define SECTION_RO (1
U
<< 15)
#define SECTION_TEX(tex) ((((tex) >> 2) << 12) | \
#define SECTION_TEX(tex) ((((tex) >> 2) << 12) | \
((((tex) >> 1) & 0x1) << 3) | \
((((tex) >> 1) & 0x1) << 3) | \
(((tex) & 0x1) << 2))
(((tex) & 0x1) << 2))
...
@@ -80,16 +80,16 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
...
@@ -80,16 +80,16 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
#define SECTION_NORMAL_CACHED \
#define SECTION_NORMAL_CACHED \
SECTION_TEX(MMU32B_ATTR_IWBWA_OWBWA_INDEX)
SECTION_TEX(MMU32B_ATTR_IWBWA_OWBWA_INDEX)
#define SECTION_XN (1 << 4)
#define SECTION_XN (1
U
<< 4)
#define SECTION_PXN (1 << 0)
#define SECTION_PXN (1
U
<< 0)
#define SECTION_SECTION (2 << 0)
#define SECTION_SECTION (2
U
<< 0)
#define SECTION_PT_NOTSECURE (1 << 3)
#define SECTION_PT_NOTSECURE (1
U
<< 3)
#define SECTION_PT_PT (1 << 0)
#define SECTION_PT_PT (1
U
<< 0)
#define SMALL_PAGE_SMALL_PAGE (1 << 1)
#define SMALL_PAGE_SMALL_PAGE (1
U
<< 1)
#define SMALL_PAGE_SHARED (1 << 10)
#define SMALL_PAGE_SHARED (1
U
<< 10)
#define SMALL_PAGE_NOTGLOBAL (1 << 11)
#define SMALL_PAGE_NOTGLOBAL (1
U
<< 11)
#define SMALL_PAGE_TEX(tex) ((((tex) >> 2) << 6) | \
#define SMALL_PAGE_TEX(tex) ((((tex) >> 2) << 6) | \
((((tex) >> 1) & 0x1) << 3) | \
((((tex) >> 1) & 0x1) << 3) | \
(((tex) & 0x1) << 2))
(((tex) & 0x1) << 2))
...
@@ -99,39 +99,39 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
...
@@ -99,39 +99,39 @@ CASSERT(PLAT_PHY_ADDR_SPACE_SIZE == (1ULL << 32), invalid_paddr_space_size);
SMALL_PAGE_TEX(MMU32B_ATTR_DEVICE_INDEX)
SMALL_PAGE_TEX(MMU32B_ATTR_DEVICE_INDEX)
#define SMALL_PAGE_NORMAL_CACHED \
#define SMALL_PAGE_NORMAL_CACHED \
SMALL_PAGE_TEX(MMU32B_ATTR_IWBWA_OWBWA_INDEX)
SMALL_PAGE_TEX(MMU32B_ATTR_IWBWA_OWBWA_INDEX)
#define SMALL_PAGE_ACCESS_FLAG (1 << 4)
#define SMALL_PAGE_ACCESS_FLAG (1
U
<< 4)
#define SMALL_PAGE_UNPRIV (1 << 5)
#define SMALL_PAGE_UNPRIV (1
U
<< 5)
#define SMALL_PAGE_RO (1 << 9)
#define SMALL_PAGE_RO (1
U
<< 9)
#define SMALL_PAGE_XN (1 << 0)
#define SMALL_PAGE_XN (1
U
<< 0)
/* The TEX, C and B bits concatenated */
/* The TEX, C and B bits concatenated */
#define MMU32B_ATTR_DEVICE_INDEX
0x
0
#define MMU32B_ATTR_DEVICE_INDEX 0
U
#define MMU32B_ATTR_IWBWA_OWBWA_INDEX
0x
1
#define MMU32B_ATTR_IWBWA_OWBWA_INDEX 1
U
#define MMU32B_PRRR_IDX(idx, tr, nos) (((tr) << (2 * (idx))) | \
#define MMU32B_PRRR_IDX(idx, tr, nos) (((tr) << (2 * (idx))) | \
((uint32_t)(nos) << ((idx) + 24)))
((uint32_t)(nos) << ((idx) + 24)))
#define MMU32B_NMRR_IDX(idx, ir, or) (((ir) << (2 * (idx))) | \
#define MMU32B_NMRR_IDX(idx, ir, or) (((ir) << (2 * (idx))) | \
((uint32_t)(or) << (2 * (idx) + 16)))
((uint32_t)(or) << (2 * (idx) + 16)))
#define MMU32B_PRRR_DS0 (1 << 16)
#define MMU32B_PRRR_DS0 (1
U
<< 16)
#define MMU32B_PRRR_DS1 (1 << 17)
#define MMU32B_PRRR_DS1 (1
U
<< 17)
#define MMU32B_PRRR_NS0 (1 << 18)
#define MMU32B_PRRR_NS0 (1
U
<< 18)
#define MMU32B_PRRR_NS1 (1 << 19)
#define MMU32B_PRRR_NS1 (1
U
<< 19)
#define DACR_DOMAIN(num, perm) ((perm) << ((num) * 2))
#define DACR_DOMAIN(num, perm) ((perm) << ((num) * 2))
#define DACR_DOMAIN_PERM_NO_ACCESS 0
x0
#define DACR_DOMAIN_PERM_NO_ACCESS 0
U
#define DACR_DOMAIN_PERM_CLIENT
0x
1
#define DACR_DOMAIN_PERM_CLIENT 1
U
#define DACR_DOMAIN_PERM_MANAGER
0x
3
#define DACR_DOMAIN_PERM_MANAGER 3
U
#define NUM_1MB_IN_4GB (1U << 12)
#define NUM_1MB_IN_4GB (1U
L
<< 12)
#define NUM_4K_IN_1MB (1U << 8)
#define NUM_4K_IN_1MB (1U
L
<< 8)
#define ONE_MB_SHIFT 20
#define ONE_MB_SHIFT 20
/* mmu 32b integration */
/* mmu 32b integration */
#define MMU32B_L1_TABLE_SIZE (NUM_1MB_IN_4GB * 4)
#define MMU32B_L1_TABLE_SIZE (NUM_1MB_IN_4GB * 4)
#define MMU32B_L2_TABLE_SIZE (NUM_4K_IN_1MB * 4)
#define MMU32B_L2_TABLE_SIZE (NUM_4K_IN_1MB * 4)
#define MMU32B_L1_TABLE_ALIGN (1 << 14)
#define MMU32B_L1_TABLE_ALIGN (1
U
<< 14)
#define MMU32B_L2_TABLE_ALIGN (1 << 10)
#define MMU32B_L2_TABLE_ALIGN (1
U
<< 10)
static
unsigned
int
next_xlat
;
static
unsigned
int
next_xlat
;
static
unsigned
long
long
xlat_max_pa
;
static
unsigned
long
long
xlat_max_pa
;
...
@@ -190,8 +190,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
...
@@ -190,8 +190,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
assert
(
IS_PAGE_ALIGNED
(
base_va
));
assert
(
IS_PAGE_ALIGNED
(
base_va
));
assert
(
IS_PAGE_ALIGNED
(
size
));
assert
(
IS_PAGE_ALIGNED
(
size
));
if
(
size
==
0U
)
if
(
size
==
0U
)
{
return
;
return
;
}
assert
(
base_pa
<
end_pa
);
/* Check for overflows */
assert
(
base_pa
<
end_pa
);
/* Check for overflows */
assert
(
base_va
<
end_va
);
assert
(
base_va
<
end_va
);
...
@@ -249,8 +250,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
...
@@ -249,8 +250,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
#endif
/* ENABLE_ASSERTIONS */
#endif
/* ENABLE_ASSERTIONS */
/* Find correct place in mmap to insert new region */
/* Find correct place in mmap to insert new region */
while
((
mm
->
base_va
<
base_va
)
&&
(
mm
->
size
!=
0U
))
while
((
mm
->
base_va
<
base_va
)
&&
(
mm
->
size
!=
0U
))
{
++
mm
;
++
mm
;
}
/*
/*
* If a section is contained inside another one with the same base
* If a section is contained inside another one with the same base
...
@@ -263,8 +265,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
...
@@ -263,8 +265,9 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
* This is required for mmap_region_attr() to get the attributes of the
* This is required for mmap_region_attr() to get the attributes of the
* small region correctly.
* small region correctly.
*/
*/
while
((
mm
->
base_va
==
base_va
)
&&
(
mm
->
size
>
size
))
while
((
mm
->
base_va
==
base_va
)
&&
(
mm
->
size
>
size
))
{
++
mm
;
++
mm
;
}
/* Make room for new region by moving other regions up by one place */
/* Make room for new region by moving other regions up by one place */
(
void
)
memmove
(
mm
+
1
,
mm
,
(
uintptr_t
)
mm_last
-
(
uintptr_t
)
mm
);
(
void
)
memmove
(
mm
+
1
,
mm
,
(
uintptr_t
)
mm_last
-
(
uintptr_t
)
mm
);
...
@@ -277,10 +280,12 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
...
@@ -277,10 +280,12 @@ void mmap_add_region(unsigned long long base_pa, uintptr_t base_va,
mm
->
size
=
size
;
mm
->
size
=
size
;
mm
->
attr
=
attr
;
mm
->
attr
=
attr
;
if
(
end_pa
>
xlat_max_pa
)
if
(
end_pa
>
xlat_max_pa
)
{
xlat_max_pa
=
end_pa
;
xlat_max_pa
=
end_pa
;
if
(
end_va
>
xlat_max_va
)
}
if
(
end_va
>
xlat_max_va
)
{
xlat_max_va
=
end_va
;
xlat_max_va
=
end_va
;
}
}
}
/* map all memory as shared/global/domain0/no-usr access */
/* map all memory as shared/global/domain0/no-usr access */
...
@@ -290,42 +295,44 @@ static uint32_t mmap_desc(unsigned attr, unsigned int addr_pa,
...
@@ -290,42 +295,44 @@ static uint32_t mmap_desc(unsigned attr, unsigned int addr_pa,
uint32_t
desc
;
uint32_t
desc
;
switch
(
level
)
{
switch
(
level
)
{
case
1
:
case
1
U
:
assert
(
!
(
addr_pa
&
(
MMU32B_L1_TABLE_ALIGN
-
1
)));
assert
((
addr_pa
&
(
MMU32B_L1_TABLE_ALIGN
-
1
))
==
0U
);
desc
=
SECTION_SECTION
|
SECTION_SHARED
;
desc
=
SECTION_SECTION
|
SECTION_SHARED
;
desc
|=
attr
&
MT_NS
?
SECTION_NOTSECURE
:
0
;
desc
|=
(
attr
&
MT_NS
)
!=
0U
?
SECTION_NOTSECURE
:
0
U
;
desc
|=
SECTION_ACCESS_FLAG
;
desc
|=
SECTION_ACCESS_FLAG
;
desc
|=
attr
&
MT_RW
?
0
:
SECTION_RO
;
desc
|=
(
attr
&
MT_RW
)
!=
0U
?
0
U
:
SECTION_RO
;
desc
|=
attr
&
MT_MEMORY
?
desc
|=
(
attr
&
MT_MEMORY
)
!=
0U
?
SECTION_NORMAL_CACHED
:
SECTION_DEVICE
;
SECTION_NORMAL_CACHED
:
SECTION_DEVICE
;
if
((
attr
&
MT_RW
)
||
!
(
attr
&
MT_MEMORY
)
)
if
((
(
attr
&
MT_RW
)
!=
0U
)
||
(
(
attr
&
MT_MEMORY
)
==
0U
))
{
desc
|=
SECTION_XN
;
desc
|=
SECTION_XN
;
}
break
;
break
;
case
2
:
case
2
U
:
assert
(
!
(
addr_pa
&
(
MMU32B_L2_TABLE_ALIGN
-
1
)));
assert
((
addr_pa
&
(
MMU32B_L2_TABLE_ALIGN
-
1
))
==
0U
);
desc
=
SMALL_PAGE_SMALL_PAGE
|
SMALL_PAGE_SHARED
;
desc
=
SMALL_PAGE_SMALL_PAGE
|
SMALL_PAGE_SHARED
;
desc
|=
SMALL_PAGE_ACCESS_FLAG
;
desc
|=
SMALL_PAGE_ACCESS_FLAG
;
desc
|=
attr
&
MT_RW
?
0
:
SMALL_PAGE_RO
;
desc
|=
(
attr
&
MT_RW
)
!=
0U
?
0
U
:
SMALL_PAGE_RO
;
desc
|=
attr
&
MT_MEMORY
?
desc
|=
(
attr
&
MT_MEMORY
)
!=
0U
?
SMALL_PAGE_NORMAL_CACHED
:
SMALL_PAGE_DEVICE
;
SMALL_PAGE_NORMAL_CACHED
:
SMALL_PAGE_DEVICE
;
if
((
attr
&
MT_RW
)
||
!
(
attr
&
MT_MEMORY
)
)
if
((
(
attr
&
MT_RW
)
!=
0U
)
||
(
(
attr
&
MT_MEMORY
)
==
0U
))
{
desc
|=
SMALL_PAGE_XN
;
desc
|=
SMALL_PAGE_XN
;
}
break
;
break
;
default:
default:
panic
();
panic
();
}
}
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
/* dump only the non-lpae level 2 tables */
/* dump only the non-lpae level 2 tables */
if
(
level
==
2
)
{
if
(
level
==
2
U
)
{
printf
(
attr
&
MT_MEMORY
?
"MEM"
:
"dev"
);
printf
(
attr
&
MT_MEMORY
?
"MEM"
:
"dev"
);
printf
(
attr
&
MT_RW
?
"-rw"
:
"-RO"
);
printf
(
attr
&
MT_RW
?
"-rw"
:
"-RO"
);
printf
(
attr
&
MT_NS
?
"-NS"
:
"-S"
);
printf
(
attr
&
MT_NS
?
"-NS"
:
"-S"
);
...
@@ -357,26 +364,31 @@ static unsigned int mmap_region_attr(const mmap_region_t *mm, uintptr_t base_va,
...
@@ -357,26 +364,31 @@ static unsigned int mmap_region_attr(const mmap_region_t *mm, uintptr_t base_va,
*/
*/
for
(
;
;
++
mm
)
{
for
(
;
;
++
mm
)
{
if
(
mm
->
size
==
0U
)
if
(
mm
->
size
==
0U
)
{
return
ret
;
/* Reached end of list */
return
ret
;
/* Reached end of list */
}
if
(
mm
->
base_va
>
(
base_va
+
size
-
1U
))
if
(
mm
->
base_va
>
(
base_va
+
size
-
1U
))
{
return
ret
;
/* Next region is after area so end */
return
ret
;
/* Next region is after area so end */
}
if
((
mm
->
base_va
+
mm
->
size
-
1U
)
<
base_va
)
if
((
mm
->
base_va
+
mm
->
size
-
1U
)
<
base_va
)
{
continue
;
/* Next region has already been overtaken */
continue
;
/* Next region has already been overtaken */
}
if
((
ret
==
0U
)
&&
(
mm
->
attr
==
*
attr
))
if
((
ret
==
0U
)
&&
(
mm
->
attr
==
*
attr
))
{
continue
;
/* Region doesn't override attribs so skip */
continue
;
/* Region doesn't override attribs so skip */
}
if
((
mm
->
base_va
>
base_va
)
||
if
((
mm
->
base_va
>
base_va
)
||
((
mm
->
base_va
+
mm
->
size
-
1U
)
<
(
base_va
+
size
-
1U
)))
((
mm
->
base_va
+
mm
->
size
-
1U
)
<
(
base_va
+
size
-
1U
)))
{
return
MT_UNKNOWN
;
/* Region doesn't fully cover area */
return
MT_UNKNOWN
;
/* Region doesn't fully cover area */
}
*
attr
=
mm
->
attr
;
*
attr
=
mm
->
attr
;
ret
=
0U
;
ret
=
0U
;
}
}
return
ret
;
}
}
static
mmap_region_t
*
init_xlation_table_inner
(
mmap_region_t
*
mm
,
static
mmap_region_t
*
init_xlation_table_inner
(
mmap_region_t
*
mm
,
...
@@ -384,16 +396,16 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
...
@@ -384,16 +396,16 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
uint32_t
*
table
,
uint32_t
*
table
,
unsigned
int
level
)
unsigned
int
level
)
{
{
unsigned
int
level_size_shift
=
(
level
==
1
)
?
unsigned
int
level_size_shift
=
(
level
==
1
U
)
?
ONE_MB_SHIFT
:
FOUR_KB_SHIFT
;
ONE_MB_SHIFT
:
FOUR_KB_SHIFT
;
unsigned
int
level_size
=
1
<<
level_size_shift
;
unsigned
int
level_size
=
1
U
<<
level_size_shift
;
unsigned
int
level_index_mask
=
(
level
==
1
)
?
unsigned
int
level_index_mask
=
(
level
==
1
U
)
?
(
NUM_1MB_IN_4GB
-
1
)
<<
ONE_MB_SHIFT
:
(
NUM_1MB_IN_4GB
-
1
)
<<
ONE_MB_SHIFT
:
(
NUM_4K_IN_1MB
-
1
)
<<
FOUR_KB_SHIFT
;
(
NUM_4K_IN_1MB
-
1
)
<<
FOUR_KB_SHIFT
;
assert
(
level
==
1
||
level
==
2
);
assert
(
(
level
==
1
U
)
||
(
level
==
2
U
)
);
VERBOSE
(
"init xlat table at %p (level%1
d
)
\n
"
,
(
void
*
)
table
,
level
);
VERBOSE
(
"init xlat table at %p (level%1
u
)
\n
"
,
(
void
*
)
table
,
level
);
do
{
do
{
uint32_t
desc
=
MMU32B_UNSET_DESC
;
uint32_t
desc
=
MMU32B_UNSET_DESC
;
...
@@ -405,15 +417,17 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
...
@@ -405,15 +417,17 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
}
}
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
/* dump only non-lpae level 2 tables content */
/* dump only non-lpae level 2 tables content */
if
(
level
==
2
)
if
(
level
==
2
U
)
{
printf
(
" 0x%lx %x "
+
6
-
2
*
level
,
printf
(
" 0x%lx %x "
+
6
-
2
*
level
,
base_va
,
level_size
);
base_va
,
level_size
);
}
#endif
#endif
if
(
mm
->
base_va
>=
base_va
+
level_size
)
{
if
(
mm
->
base_va
>=
base_va
+
level_size
)
{
/* Next region is after area so nothing to map yet */
/* Next region is after area so nothing to map yet */
desc
=
MMU32B_INVALID_DESC
;
desc
=
MMU32B_INVALID_DESC
;
}
else
if
(
mm
->
base_va
<=
base_va
&&
mm
->
base_va
+
mm
->
size
>=
}
else
if
((
mm
->
base_va
<=
base_va
)
&&
base_va
+
level_size
)
{
(
mm
->
base_va
+
mm
->
size
)
>=
(
base_va
+
level_size
))
{
/* Next region covers all of area */
/* Next region covers all of area */
unsigned
int
attr
=
mm
->
attr
;
unsigned
int
attr
=
mm
->
attr
;
unsigned
int
r
=
mmap_region_attr
(
mm
,
base_va
,
unsigned
int
r
=
mmap_region_attr
(
mm
,
base_va
,
...
@@ -436,8 +450,8 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
...
@@ -436,8 +450,8 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
*/
*/
if
(
*
table
)
{
if
(
*
table
)
{
assert
((
*
table
&
3
)
==
SECTION_PT_PT
);
assert
((
*
table
&
3
)
==
SECTION_PT_PT
);
assert
(
!
(
*
table
&
SECTION_PT_NOTSECURE
)
==
assert
(
(
(
*
table
&
SECTION_PT_NOTSECURE
)
==
0U
)
!
(
mm
->
attr
&
MT_NS
));
==
(
(
mm
->
attr
&
MT_NS
)
==
0U
)
);
xlat_table
=
(
*
table
)
&
xlat_table
=
(
*
table
)
&
~
(
MMU32B_L1_TABLE_ALIGN
-
1
);
~
(
MMU32B_L1_TABLE_ALIGN
-
1
);
...
@@ -447,11 +461,11 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
...
@@ -447,11 +461,11 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
next_xlat
*
MMU32B_L2_TABLE_SIZE
;
next_xlat
*
MMU32B_L2_TABLE_SIZE
;
next_xlat
++
;
next_xlat
++
;
assert
(
next_xlat
<=
MAX_XLAT_TABLES
);
assert
(
next_xlat
<=
MAX_XLAT_TABLES
);
memset
((
char
*
)
xlat_table
,
0
,
(
void
)
memset
((
char
*
)
xlat_table
,
0
,
MMU32B_L2_TABLE_SIZE
);
MMU32B_L2_TABLE_SIZE
);
desc
=
xlat_table
|
SECTION_PT_PT
;
desc
=
xlat_table
|
SECTION_PT_PT
;
desc
|=
mm
->
attr
&
MT_NS
?
desc
|=
(
mm
->
attr
&
MT_NS
)
!=
0U
?
SECTION_PT_NOTSECURE
:
0
;
SECTION_PT_NOTSECURE
:
0
;
}
}
/* Recurse to fill in new table */
/* Recurse to fill in new table */
...
@@ -461,12 +475,13 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
...
@@ -461,12 +475,13 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
}
}
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
/* dump only non-lpae level 2 tables content */
/* dump only non-lpae level 2 tables content */
if
(
level
==
2
)
if
(
level
==
2
U
)
{
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
#endif
#endif
*
table
++
=
desc
;
*
table
++
=
desc
;
base_va
+=
level_size
;
base_va
+=
level_size
;
}
while
(
mm
->
size
&&
(
base_va
&
level_index_mask
));
}
while
(
(
mm
->
size
!=
0U
)
&&
(
(
base_va
&
level_index_mask
)
!=
0U
)
);
return
mm
;
return
mm
;
}
}
...
@@ -475,17 +490,16 @@ void init_xlat_tables(void)
...
@@ -475,17 +490,16 @@ void init_xlat_tables(void)
{
{
print_mmap
();
print_mmap
();
assert
(
!
((
unsigned
int
)
mmu_l1_base
&
(
MMU32B_L1_TABLE_ALIGN
-
1
)));
assert
(((
unsigned
int
)
mmu_l1_base
&
(
MMU32B_L1_TABLE_ALIGN
-
1
))
==
0U
);
assert
(
!
((
unsigned
int
)
mmu_l2_base
&
(
MMU32B_L2_TABLE_ALIGN
-
1
)));
assert
(((
unsigned
int
)
mmu_l2_base
&
(
MMU32B_L2_TABLE_ALIGN
-
1
))
==
0U
);
memset
(
mmu_l1_base
,
0
,
MMU32B_L1_TABLE_SIZE
);
(
void
)
memset
(
mmu_l1_base
,
0
,
MMU32B_L1_TABLE_SIZE
);
init_xlation_table_inner
(
mmap
,
0
,
(
uint32_t
*
)
mmu_l1_base
,
1
);
init_xlation_table_inner
(
mmap
,
0
,
(
uint32_t
*
)
mmu_l1_base
,
1
);
VERBOSE
(
"init xlat - max_va=%p, max_pa=%llx
\n
"
,
VERBOSE
(
"init xlat - max_va=%p, max_pa=%llx
\n
"
,
(
void
*
)
xlat_max_va
,
xlat_max_pa
);
(
void
*
)
xlat_max_va
,
xlat_max_pa
);
assert
(
xlat_max_va
<=
PLAT_VIRT_ADDR_SPACE_SIZE
-
1
);
assert
(
xlat_max_pa
<=
(
PLAT_VIRT_ADDR_SPACE_SIZE
-
1
));
assert
(
xlat_max_pa
<=
PLAT_VIRT_ADDR_SPACE_SIZE
-
1
);
}
}
/*******************************************************************************
/*******************************************************************************
...
@@ -499,7 +513,7 @@ void enable_mmu_svc_mon(unsigned int flags)
...
@@ -499,7 +513,7 @@ void enable_mmu_svc_mon(unsigned int flags)
unsigned
int
sctlr
;
unsigned
int
sctlr
;
assert
(
IS_IN_SECURE
());
assert
(
IS_IN_SECURE
());
assert
((
read_sctlr
()
&
SCTLR_M_BIT
)
==
0
);
assert
((
read_sctlr
()
&
SCTLR_M_BIT
)
==
0
U
);
/* Enable Access flag (simplified access permissions) and TEX remap */
/* Enable Access flag (simplified access permissions) and TEX remap */
write_sctlr
(
read_sctlr
()
|
SCTLR_AFE_BIT
|
SCTLR_TRE_BIT
);
write_sctlr
(
read_sctlr
()
|
SCTLR_AFE_BIT
|
SCTLR_TRE_BIT
);
...
@@ -522,7 +536,7 @@ void enable_mmu_svc_mon(unsigned int flags)
...
@@ -522,7 +536,7 @@ void enable_mmu_svc_mon(unsigned int flags)
/* set MMU base xlat table entry (use only TTBR0) */
/* set MMU base xlat table entry (use only TTBR0) */
write_ttbr0
((
uint32_t
)
mmu_l1_base
|
MMU32B_DEFAULT_ATTRS
);
write_ttbr0
((
uint32_t
)
mmu_l1_base
|
MMU32B_DEFAULT_ATTRS
);
write_ttbr1
(
0
);
write_ttbr1
(
0
U
);
/*
/*
* Ensure all translation table writes have drained
* Ensure all translation table writes have drained
...
@@ -535,14 +549,15 @@ void enable_mmu_svc_mon(unsigned int flags)
...
@@ -535,14 +549,15 @@ void enable_mmu_svc_mon(unsigned int flags)
sctlr
=
read_sctlr
();
sctlr
=
read_sctlr
();
sctlr
|=
SCTLR_M_BIT
;
sctlr
|=
SCTLR_M_BIT
;
#if ARMV7_SUPPORTS_VIRTUALIZATION
#if
def
ARMV7_SUPPORTS_VIRTUALIZATION
sctlr
|=
SCTLR_WXN_BIT
;
sctlr
|=
SCTLR_WXN_BIT
;
#endif
#endif
if
(
flags
&
DISABLE_DCACHE
)
if
(
(
flags
&
DISABLE_DCACHE
)
!=
0U
)
{
sctlr
&=
~
SCTLR_C_BIT
;
sctlr
&=
~
SCTLR_C_BIT
;
else
}
else
{
sctlr
|=
SCTLR_C_BIT
;
sctlr
|=
SCTLR_C_BIT
;
}
write_sctlr
(
sctlr
);
write_sctlr
(
sctlr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment