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
66bf006e
Commit
66bf006e
authored
Jun 08, 2021
by
Mark Dykes
Committed by
TrustedFirmware Code Review
Jun 08, 2021
Browse files
Merge "fix(security): Set MDCR_EL3.MCCD bit" into integration
parents
8055bbf7
12f6c064
Changes
3
Show whitespace changes
Inline
Side-by-side
include/arch/aarch64/arch.h
View file @
66bf006e
...
@@ -434,8 +434,16 @@
...
@@ -434,8 +434,16 @@
#define SCR_RESET_VAL SCR_RES1_BITS
#define SCR_RESET_VAL SCR_RES1_BITS
/* MDCR_EL3 definitions */
/* MDCR_EL3 definitions */
#define MDCR_EnPMSN_BIT (ULL(1) << 36)
#define MDCR_MPMX_BIT (ULL(1) << 35)
#define MDCR_MCCD_BIT (ULL(1) << 34)
#define MDCR_MTPME_BIT (ULL(1) << 28)
#define MDCR_MTPME_BIT (ULL(1) << 28)
#define MDCR_TDCC_BIT (ULL(1) << 27)
#define MDCR_SCCD_BIT (ULL(1) << 23)
#define MDCR_SCCD_BIT (ULL(1) << 23)
#define MDCR_EPMAD_BIT (ULL(1) << 21)
#define MDCR_EDAD_BIT (ULL(1) << 20)
#define MDCR_TTRF_BIT (ULL(1) << 19)
#define MDCR_STE_BIT (ULL(1) << 18)
#define MDCR_SPME_BIT (ULL(1) << 17)
#define MDCR_SPME_BIT (ULL(1) << 17)
#define MDCR_SDD_BIT (ULL(1) << 16)
#define MDCR_SDD_BIT (ULL(1) << 16)
#define MDCR_SPD32(x) ((x) << 14)
#define MDCR_SPD32(x) ((x) << 14)
...
...
include/arch/aarch64/el3_common_macros.S
View file @
66bf006e
/*
/*
*
Copyright
(
c
)
2015
-
202
0
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
Copyright
(
c
)
2015
-
202
1
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
*
*
SPDX
-
License
-
Identifier
:
BSD
-
3
-
Clause
*
SPDX
-
License
-
Identifier
:
BSD
-
3
-
Clause
*/
*/
...
@@ -113,8 +113,13 @@
...
@@ -113,8 +113,13 @@
*
*
*
MDCR_EL3
.
SCCD
:
Set
to
one
so
that
cycle
counting
by
PMCCNTR_EL0
is
*
MDCR_EL3
.
SCCD
:
Set
to
one
so
that
cycle
counting
by
PMCCNTR_EL0
is
*
prohibited
in
Secure
state
.
This
bit
is
RES0
in
versions
of
the
*
prohibited
in
Secure
state
.
This
bit
is
RES0
in
versions
of
the
*
architecture
earlier
than
ARMv8
.5
,
setting
it
to
1
doesn
't have any
*
architecture
with
FEAT_PMUv3p5
not
implemented
,
setting
it
to
1
*
effect
on
them
.
*
doesn
't have any effect on them.
*
*
MDCR_EL3
.
MCCD
:
Set
to
one
so
that
cycle
counting
by
PMCCNTR_EL0
is
*
prohibited
in
EL3
.
This
bit
is
RES0
in
versions
of
the
*
architecture
with
FEAT_PMUv3p7
not
implemented
,
setting
it
to
1
*
doesn
't have any effect on them.
*
*
*
MDCR_EL3
.
SPME
:
Set
to
zero
so
that
event
counting
by
the
programmable
*
MDCR_EL3
.
SPME
:
Set
to
zero
so
that
event
counting
by
the
programmable
*
counters
PMEVCNTR
<
n
>
_EL0
is
prohibited
in
Secure
state
.
If
ARMv8
.2
*
counters
PMEVCNTR
<
n
>
_EL0
is
prohibited
in
Secure
state
.
If
ARMv8
.2
...
@@ -124,9 +129,9 @@
...
@@ -124,9 +129,9 @@
*
---------------------------------------------------------------------
*
---------------------------------------------------------------------
*/
*/
mov_imm
x0
,
((
MDCR_EL3_RESET_VAL
| MDCR_SDD_BIT |
\
mov_imm
x0
,
((
MDCR_EL3_RESET_VAL
| MDCR_SDD_BIT |
\
MDCR_SPD32
(
MDCR_SPD32_DISABLE
)
|
MDCR_SCCD_BIT
)
&
\
MDCR_SPD32
(
MDCR_SPD32_DISABLE
)
| MDCR_SCCD_BIT
|
\
~(
MDCR_SPME_BIT
| MDCR_TDOSA_BIT |
MDCR_TDA_BIT
|
\
MDCR_MCCD_BIT
)
&
~
(
MDCR_SPME_BIT
| MDCR_TDOSA_BIT |
\
MDCR_TPM_BIT
))
MDCR_TDA_BIT
|
MDCR_TPM_BIT
))
msr
mdcr_el3
,
x0
msr
mdcr_el3
,
x0
...
...
lib/el3_runtime/aarch64/context.S
View file @
66bf006e
...
@@ -697,13 +697,14 @@ func save_gp_pmcr_pauth_regs
...
@@ -697,13 +697,14 @@ func save_gp_pmcr_pauth_regs
str
x18
,
[
sp
,
#
CTX_GPREGS_OFFSET
+
CTX_GPREG_SP_EL0
]
str
x18
,
[
sp
,
#
CTX_GPREGS_OFFSET
+
CTX_GPREG_SP_EL0
]
/
*
----------------------------------------------------------
/
*
----------------------------------------------------------
*
Check
if
earlier
initialization
MDCR_EL3
.
SCCD
to
1
failed
,
*
Check
if
earlier
initialization
MDCR_EL3
.
SCCD
/
MCCD
to
1
*
meaning
that
ARMv8
-
PMU
is
not
implemented
and
PMCR_EL0
*
failed
,
meaning
that
FEAT_PMUv3p5
/
7
is
not
implemented
and
*
should
be
saved
in
non
-
secure
context
.
*
PMCR_EL0
should
be
saved
in
non
-
secure
context
.
*
----------------------------------------------------------
*
----------------------------------------------------------
*/
*/
mov_imm
x10
,
(
MDCR_SCCD_BIT
|
MDCR_MCCD_BIT
)
mrs
x9
,
mdcr_el3
mrs
x9
,
mdcr_el3
tst
x9
,
#
MDCR_SCCD_BIT
tst
x9
,
x10
bne
1
f
bne
1
f
/
*
Secure
Cycle
Counter
is
not
disabled
*/
/
*
Secure
Cycle
Counter
is
not
disabled
*/
...
@@ -792,13 +793,14 @@ func restore_gp_pmcr_pauth_regs
...
@@ -792,13 +793,14 @@ func restore_gp_pmcr_pauth_regs
/
*
----------------------------------------------------------
/
*
----------------------------------------------------------
*
Back
to
Non
-
secure
state
.
*
Back
to
Non
-
secure
state
.
*
Check
if
earlier
initialization
MDCR_EL3
.
SCCD
to
1
failed
,
*
Check
if
earlier
initialization
MDCR_EL3
.
SCCD
/
MCCD
to
1
*
meaning
that
ARMv8
-
PMU
is
not
implemented
and
PMCR_EL0
*
failed
,
meaning
that
FEAT_PMUv3p5
/
7
is
not
implemented
and
*
should
be
restored
from
non
-
secure
context
.
*
PMCR_EL0
should
be
restored
from
non
-
secure
context
.
*
----------------------------------------------------------
*
----------------------------------------------------------
*/
*/
mov_imm
x1
,
(
MDCR_SCCD_BIT
|
MDCR_MCCD_BIT
)
mrs
x0
,
mdcr_el3
mrs
x0
,
mdcr_el3
tst
x0
,
#
MDCR_SCCD_BIT
tst
x0
,
x1
bne
2
f
bne
2
f
ldr
x0
,
[
sp
,
#
CTX_EL3STATE_OFFSET
+
CTX_PMCR_EL0
]
ldr
x0
,
[
sp
,
#
CTX_EL3STATE_OFFSET
+
CTX_PMCR_EL0
]
msr
pmcr_el0
,
x0
msr
pmcr_el0
,
x0
...
...
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