Skip to content

Commit 3929bca

Browse files
author
Richard Earnshaw
committed
arm: Add command-line option for enabling CVE-2021-35465 mitigation [PR102035]
Add a new option, -mfix-cmse-cve-2021-35465 and document it. Enable it automatically for cortex-m33, cortex-m35p and cortex-m55. gcc: PR target/102035 * config/arm/arm.opt (mfix-cmse-cve-2021-35465): New option. * doc/invoke.texi (Arm Options): Document it. * config/arm/arm-cpus.in (quirk_vlldm): New feature bit. (ALL_QUIRKS): Add quirk_vlldm. (cortex-m33): Add quirk_vlldm. (cortex-m35p, cortex-m55): Likewise. * config/arm/arm.c (arm_option_override): Enable fix_vlldm if targetting an affected CPU and not explicitly controlled on the command line.
1 parent 79fb270 commit 3929bca

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

gcc/config/arm/arm-cpus.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ define feature quirk_armv6kz
186186
# Cortex-M3 LDRD quirk.
187187
define feature quirk_cm3_ldrd
188188

189+
# v8-m/v8.1-m VLLDM errata.
190+
define feature quirk_vlldm
191+
189192
# Don't use .cpu assembly directive
190193
define feature quirk_no_asmcpu
191194

@@ -322,7 +325,7 @@ define implied vfp_base MVE MVE_FP ALL_FP
322325
# architectures.
323326
# xscale isn't really a 'quirk', but it isn't an architecture either and we
324327
# need to ignore it for matching purposes.
325-
define fgroup ALL_QUIRKS quirk_no_volatile_ce quirk_armv6kz quirk_cm3_ldrd xscale quirk_no_asmcpu
328+
define fgroup ALL_QUIRKS quirk_no_volatile_ce quirk_armv6kz quirk_cm3_ldrd quirk_vlldm xscale quirk_no_asmcpu
326329

327330
define fgroup IGNORE_FOR_MULTILIB cdecp0 cdecp1 cdecp2 cdecp3 cdecp4 cdecp5 cdecp6 cdecp7
328331

@@ -1571,6 +1574,7 @@ begin cpu cortex-m33
15711574
architecture armv8-m.main+dsp+fp
15721575
option nofp remove ALL_FP
15731576
option nodsp remove armv7em
1577+
isa quirk_vlldm
15741578
costs v7m
15751579
end cpu cortex-m33
15761580

@@ -1580,6 +1584,7 @@ begin cpu cortex-m35p
15801584
architecture armv8-m.main+dsp+fp
15811585
option nofp remove ALL_FP
15821586
option nodsp remove armv7em
1587+
isa quirk_vlldm
15831588
costs v7m
15841589
end cpu cortex-m35p
15851590

@@ -1591,7 +1596,7 @@ begin cpu cortex-m55
15911596
option nomve remove mve mve_float
15921597
option nofp remove ALL_FP mve_float
15931598
option nodsp remove MVE mve_float
1594-
isa quirk_no_asmcpu
1599+
isa quirk_no_asmcpu quirk_vlldm
15951600
costs v7m
15961601
vendor 41
15971602
end cpu cortex-m55

gcc/config/arm/arm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,6 +3616,15 @@ arm_option_override (void)
36163616
fix_cm3_ldrd = 0;
36173617
}
36183618

3619+
/* Enable fix_vlldm by default if required. */
3620+
if (fix_vlldm == 2)
3621+
{
3622+
if (bitmap_bit_p (arm_active_target.isa, isa_bit_quirk_vlldm))
3623+
fix_vlldm = 1;
3624+
else
3625+
fix_vlldm = 0;
3626+
}
3627+
36193628
/* Hot/Cold partitioning is not currently supported, since we can't
36203629
handle literal pool placement in that case. */
36213630
if (flag_reorder_blocks_and_partition)

gcc/config/arm/arm.opt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ Target Var(fix_cm3_ldrd) Init(2)
268268
Avoid overlapping destination and address registers on LDRD instructions
269269
that may trigger Cortex-M3 errata.
270270

271+
mfix-cmse-cve-2021-35465
272+
Target Var(fix_vlldm) Init(2)
273+
Mitigate issues with VLLDM on some M-profile devices (CVE-2021-35465).
274+
271275
munaligned-access
272276
Target Var(unaligned_access) Init(2) Save
273277
Enable unaligned word and halfword accesses to packed data.

gcc/doc/invoke.texi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ Objective-C and Objective-C++ Dialects}.
808808
-mverbose-cost-dump @gol
809809
-mpure-code @gol
810810
-mcmse @gol
811+
-mfix-cmse-cve-2021-35465 @gol
811812
-mfdpic}
812813

813814
@emph{AVR Options}
@@ -20743,6 +20744,14 @@ Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
2074320744
Development Tools Engineering Specification", which can be found on
2074420745
@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
2074520746

20747+
@item -mfix-cmse-cve-2021-35465
20748+
@opindex mfix-cmse-cve-2021-35465
20749+
Mitigate against a potential security issue with the @code{VLLDM} instruction
20750+
in some M-profile devices when using CMSE (CVE-2021-365465). This option is
20751+
enabled by default when the option @option{-mcpu=} is used with
20752+
@code{cortex-m33}, @code{cortex-m35p} or @code{cortex-m55}. The option
20753+
@option{-mno-fix-cmse-cve-2021-35465} can be used to disable the mitigation.
20754+
2074620755
@item -mfdpic
2074720756
@itemx -mno-fdpic
2074820757
@opindex mfdpic

0 commit comments

Comments
 (0)