Skip to content

Commit

Permalink
arm64: Add a DBM errata workaround
Browse files Browse the repository at this point in the history
Add a workaround for Cortex-A55 erratum 1024718 and Cortex-A510 erratum
2051678. Both errata are related to the hardware handling of the dirty
field in page tables and can be worked around by disabling this feature.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D47809
  • Loading branch information
zxombie committed Dec 11, 2024
1 parent fc25f06 commit 26842bb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sys/arm64/arm64/pmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,10 +1629,24 @@ void
pmap_cpu_init(void)
{
uint64_t id_aa64mmfr1, tcr;
bool enable_dbm;

enable_dbm = false;

/* Enable HAFDBS if supported */
id_aa64mmfr1 = READ_SPECIALREG(id_aa64mmfr1_el1);
if (ID_AA64MMFR1_HAFDBS_VAL(id_aa64mmfr1) >=ID_AA64MMFR1_HAFDBS_AF_DBS){
if (ID_AA64MMFR1_HAFDBS_VAL(id_aa64mmfr1) >= ID_AA64MMFR1_HAFDBS_AF_DBS)
enable_dbm = true;
/* Disable on Cortex-A55 for erratum 1024718 - all revisions */
if (CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK, CPU_IMPL_ARM,
CPU_PART_CORTEX_A55, 0, 0))
enable_dbm = false;
/* Disable on Cortex-A510 for erratum 2051678 - r0p0 to r0p2 */
else if (CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK | CPU_VAR_MASK,
CPU_IMPL_ARM, CPU_PART_CORTEX_A510, 0, 0))
if (CPU_REV(PCPU_GET(midr)) < 3)
enable_dbm = false;
if (enable_dbm) {
tcr = READ_SPECIALREG(tcr_el1) | TCR_HD;
WRITE_SPECIALREG(tcr_el1, tcr);
isb();
Expand Down

0 comments on commit 26842bb

Please sign in to comment.