Page MenuHomeFreeBSD

dmar: Disable memory protection after initialization
ClosedPublic

Authored by kd on Oct 21 2021, 3:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 29 2024, 3:26 PM
Unknown Object (File)
Mar 14 2024, 8:54 AM
Unknown Object (File)
Feb 12 2024, 2:23 AM
Unknown Object (File)
Feb 10 2024, 9:35 PM
Unknown Object (File)
Jan 17 2024, 8:39 PM
Unknown Object (File)
Jan 12 2024, 8:14 AM
Unknown Object (File)
Nov 21 2023, 11:16 AM
Unknown Object (File)
Oct 27 2023, 3:18 AM
Subscribers

Details

Summary

Some BIOSes protect memory region they reside in by using DMAR to prevent devices from doing any DMA transactions to that part of RAM.
AMI refers to this as "DMA Control Guarantee".
Disable that protection right after address translation is enabled.
I stumbled upon this while investigation a failing coredump on a device which has this feature enabled.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kd requested review of this revision.Oct 21 2021, 3:12 PM
kd created this revision.
sys/x86/iommu/intel_utils.c
507

if ((unit->hw_cap & (DMAR_CAP_PLMR | DMAR_CAP_PHMR)) == 0)

532

I think this should be done before enabling TE, at least for compatibility with older hardware that enables protected regions when translation is enabled.

Also I suggest to add explicit call to dmar_disable_protected_regions() into place that does dmar_enable_translation(), leaving this utility function single-purpose.

Call dmar_disable_protected_regions from outside of dmar_enable_translation.
I've also changed the behaviour so that if the former function fails we still continue after printing a warning.
There is at least one quirk that removes the PMR capabilities - nb_5400_no_low_high_prot_mem and I guess that even if we fail to disable those IOMMU should still be able to operate just fine.

kib added inline comments.
sys/x86/iommu/intel_ctx.c
636
sys/x86/iommu/intel_drv.c
1070
This revision is now accepted and ready to land.Oct 22 2021, 12:08 PM