Message ID | 1488283992-32104-2-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | Accepted |
Commit | 25549bda46c581271a303840fb266539c00ede71 |
Headers | show |
Series | [edk2,1/3] ArmPkg/UncachedMemoryAllocationLib: restore mapping attributes after free | expand |
On Tue, Feb 28, 2017 at 12:13:11PM +0000, Ard Biesheuvel wrote: > Uncached pool allocations are aligned to the data cache line length under > the assumption that this is sufficient to prevent cache maintenance from > corrupting adjacent allocations. However, the value to use in such cases > is architecturally called the Cache Writeback Granule (CWG), which is > essentially the maximum Dcache line length rather than the minimum. > > Note that this is mostly a cosmetical fix, given that the pool allocation > is turned into a page allocation later, and rounded up accordingly. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> > --- > ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c > index cd13a7da92e0..0d8abad23433 100644 > --- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c > +++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c > @@ -545,7 +545,7 @@ UncachedInternalAllocatePool ( > IN UINTN AllocationSize > ) > { > - UINTN CacheLineLength = ArmDataCacheLineLength (); > + UINTN CacheLineLength = ArmCacheWritebackGranule (); > return UncachedInternalAllocateAlignedPool (MemoryType, AllocationSize, CacheLineLength); > } > > -- > 2.7.4 > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c index cd13a7da92e0..0d8abad23433 100644 --- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c +++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c @@ -545,7 +545,7 @@ UncachedInternalAllocatePool ( IN UINTN AllocationSize ) { - UINTN CacheLineLength = ArmDataCacheLineLength (); + UINTN CacheLineLength = ArmCacheWritebackGranule (); return UncachedInternalAllocateAlignedPool (MemoryType, AllocationSize, CacheLineLength); }
Uncached pool allocations are aligned to the data cache line length under the assumption that this is sufficient to prevent cache maintenance from corrupting adjacent allocations. However, the value to use in such cases is architecturally called the Cache Writeback Granule (CWG), which is essentially the maximum Dcache line length rather than the minimum. Note that this is mostly a cosmetical fix, given that the pool allocation is turned into a page allocation later, and rounded up accordingly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel