ArmPkg/ArmDmaLib: interpret GCD attributes as a bit field

Comparing a GCD attribute field directly against EFI_MEMORY_UC and
EFI_MEMORY_WT is incorrect, since it may have other bits set as well
which are not related to the cacheability of the region. So instead,
test explicitly against the flags EFI_MEMORY_WB and EFI_MEMORY_WT,
which must be set if the region may be mapped with cacheable attributes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Ard Biesheuvel 2016-04-19 16:19:02 +02:00
parent 80e5a33da1
commit 885d57ef09
1 changed files with 1 additions and 3 deletions

View File

@ -102,9 +102,7 @@ DmaMap (
}
// If the mapped buffer is not an uncached buffer
if ( (GcdDescriptor.Attributes != EFI_MEMORY_WC) &&
(GcdDescriptor.Attributes != EFI_MEMORY_UC) )
{
if ((GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) != 0) {
//
// If the buffer does not fill entire cache lines we must double buffer into
// uncached memory. Device (PCI) address becomes uncached page.