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:
@@ -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, ®s.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);
|
||||
|
||||
@@ -78,6 +78,8 @@ enum ihSourceId
|
||||
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h#L46
|
||||
*
|
||||
*/
|
||||
constexpr uint32_t INTR_COOKIE_SIZE = 32; // in bytes
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t clientId : 8;
|
||||
@@ -98,6 +100,7 @@ typedef struct
|
||||
uint32_t source_data_dw3;
|
||||
uint32_t source_data_dw4;
|
||||
} AMDGPUInterruptCookie;
|
||||
static_assert(sizeof(AMDGPUInterruptCookie) == INTR_COOKIE_SIZE);
|
||||
|
||||
/**
|
||||
* Struct to contain all interrupt handler related registers.
|
||||
@@ -116,8 +119,6 @@ typedef struct
|
||||
uint32_t IH_Doorbell;
|
||||
} AMDGPUIHRegs;
|
||||
|
||||
constexpr uint32_t INTR_COOKIE_SIZE = 32; // in bytes
|
||||
|
||||
class AMDGPUInterruptHandler : public DmaDevice
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user