mirror of
https://github.com/ipxe/ipxe
synced 2026-05-18 10:00:30 +03:00
[iobuf] Ensure I/O buffer data sits within unshared cachelines
On platforms where DMA devices are not in the same coherency domain as the CPU cache, we must ensure that DMA I/O buffers do not share cachelines with other data. Align the start and end of I/O buffers to IOB_ZLEN, which is larger than any cacheline size we expect to encounter. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -62,7 +62,7 @@ static inline void alloc_iob_okx ( size_t len, size_t align, size_t offset,
|
||||
"offset %#zx\n", iobuf, virt_to_phys ( iobuf->data ),
|
||||
iob_tailroom ( iobuf ), len, align, offset );
|
||||
|
||||
/* Validate requested length and alignment */
|
||||
/* Validate requested length and data alignment */
|
||||
okx ( ( ( ( intptr_t ) iobuf ) & ( __alignof__ ( *iobuf ) - 1 ) ) == 0,
|
||||
file, line );
|
||||
okx ( iob_tailroom ( iobuf ) >= len, file, line );
|
||||
@@ -70,6 +70,12 @@ static inline void alloc_iob_okx ( size_t len, size_t align, size_t offset,
|
||||
( ( virt_to_phys ( iobuf->data ) & ( align - 1 ) ) ==
|
||||
( offset & ( align - 1 ) ) ) ), file, line );
|
||||
|
||||
/* Validate overall buffer alignment */
|
||||
okx ( ( ( ( intptr_t ) iobuf->head ) & ( IOB_ZLEN - 1 ) ) == 0,
|
||||
file, line );
|
||||
okx ( ( ( ( intptr_t ) iobuf->end ) & ( IOB_ZLEN - 1 ) ) == 0,
|
||||
file, line );
|
||||
|
||||
/* Overwrite entire content of I/O buffer (for Valgrind) */
|
||||
memset ( iob_put ( iobuf, len ), 0x55, len );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user