dev-amdgpu: Fix size issue in interrupt handler

The data allocated for the DMA request used to send an interrupt cookie
was too large. This was causing the memcpy to occasionally seg fault due
to reading past the bounds of the source parameter (the interrupt cookie
struct). Correct the size and add a compile time check to ensure it is
the correct number of bytes expected by the driver.

Change-Id: Ie9757cb52ce8f72354582c36cfd3a7e8a1525484
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/58969
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Alexandru Duțu <alexandru.dutu@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Maintainer: Matt Sinclair <mattdsinclair@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
Matthew Poremba
2022-04-18 12:11:25 -05:00
parent 11ccc87c91
commit c170994676
2 changed files with 5 additions and 4 deletions

View File

@@ -114,7 +114,7 @@ void
AMDGPUInterruptHandler::submitWritePointer()
{
uint8_t *dataPtr = new uint8_t[sizeof(uint32_t)];
regs.IH_Wptr += INTR_COOKIE_SIZE;
regs.IH_Wptr += sizeof(AMDGPUInterruptCookie);
Addr paddr = regs.WptrAddr;
std::memcpy(dataPtr, &regs.IH_Wptr, sizeof(uint32_t));
@@ -127,7 +127,7 @@ AMDGPUInterruptHandler::submitInterruptCookie()
{
assert(!interruptQueue.empty());
auto cookie = interruptQueue.front();
size_t cookieSize = INTR_COOKIE_SIZE * sizeof(uint32_t);
size_t cookieSize = sizeof(AMDGPUInterruptCookie);
uint8_t *dataPtr = new uint8_t[cookieSize];
std::memcpy(dataPtr, cookie, cookieSize);