MdeModulePkg/XhciDxe: Add boundary check for TRB ring allocation
According the Xhci Spec, TRB Rings may be larger than a Page, however they shall not cross a 64K byte boundary, so add a parameter to indicate whether the memory allocation is for TRB Rings or not. It will ensure the allocation not crossing 64K boundary in UsbHcAllocMemFromBlock if the memory is allocated for TRB Rings. Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
@@ -48,6 +48,8 @@ typedef struct _USBHC_MEM_POOL {
|
||||
|
||||
#define USBHC_MEM_ROUND(Len) (((Len) + USBHC_MEM_UNIT_MASK) & (~USBHC_MEM_UNIT_MASK))
|
||||
|
||||
#define USBHC_MEM_TRB_RINGS_BOUNDARY SIZE_64KB
|
||||
|
||||
//
|
||||
// Advance the byte and bit to the next bit, adjust byte accordingly.
|
||||
//
|
||||
@@ -92,8 +94,9 @@ UsbHcFreeMemPool (
|
||||
Allocate some memory from the host controller's memory pool
|
||||
which can be used to communicate with host controller.
|
||||
|
||||
@param Pool The host controller's memory pool.
|
||||
@param Size Size of the memory to allocate.
|
||||
@param Pool The host controller's memory pool.
|
||||
@param Size Size of the memory to allocate.
|
||||
@param AllocationForRing The allocated memory is for Ring or not.
|
||||
|
||||
@return The allocated memory or NULL.
|
||||
|
||||
@@ -101,7 +104,8 @@ UsbHcFreeMemPool (
|
||||
VOID *
|
||||
UsbHcAllocateMem (
|
||||
IN USBHC_MEM_POOL *Pool,
|
||||
IN UINTN Size
|
||||
IN UINTN Size,
|
||||
IN BOOLEAN AllocationForRing
|
||||
);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user