libhsakmt: query svm info from userptrs at fault events
Get more debug information about user pointers that were registered through SVM API, and triggered by memory exception events. A new kfdtest with this use case was also included inside KFDExceptionTest. Signed-off-by: Alex Sierra <alex.sierra@amd.com> Change-Id: I8e9df3c1c6c3f42d7b9235d12406d80d31746443
This commit is contained in:
committed by
Alejandro Sierra Guiza
parent
178a619b80
commit
45fad29752
@@ -27,6 +27,7 @@
|
||||
#include "SDMAPacket.hpp"
|
||||
#include "SDMAQueue.hpp"
|
||||
#include "Dispatch.hpp"
|
||||
#include <sys/mman.h>
|
||||
|
||||
void KFDExceptionTest::SetUp() {
|
||||
ROUTINE_START
|
||||
@@ -253,6 +254,53 @@ TEST_F(KFDExceptionTest, PermissionFault) {
|
||||
TEST_END
|
||||
}
|
||||
|
||||
/* Allocate Read Only user pointer buffer. Test Memory Exception failure by
|
||||
* attempting to write to that buffer in the child process.
|
||||
*/
|
||||
TEST_F(KFDExceptionTest, PermissionFaultUserPointer) {
|
||||
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
|
||||
TEST_START(TESTPROFILE_RUNALL)
|
||||
|
||||
int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode();
|
||||
ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node";
|
||||
|
||||
if (m_FamilyId == FAMILY_RV) {
|
||||
LOG() << "Skipping test: IOMMU issues on Raven." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
m_ChildPid = fork();
|
||||
if (m_ChildPid == 0) {
|
||||
KFDBaseComponentTest::TearDown();
|
||||
KFDBaseComponentTest::SetUp();
|
||||
|
||||
void *pBuf = mmap(NULL, PAGE_SIZE, PROT_READ,
|
||||
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||
ASSERT_NE(pBuf, MAP_FAILED);
|
||||
EXPECT_SUCCESS(hsaKmtRegisterMemory(pBuf, PAGE_SIZE));
|
||||
EXPECT_SUCCESS(hsaKmtMapMemoryToGPU(pBuf, PAGE_SIZE, NULL));
|
||||
HsaMemoryBuffer srcSysBuffer(PAGE_SIZE, defaultGPUNode, false);
|
||||
|
||||
srcSysBuffer.Fill(0xAA55AA55);
|
||||
|
||||
TestMemoryException(defaultGPUNode, srcSysBuffer.As<HSAuint64>(),
|
||||
(HSAuint64)pBuf);
|
||||
} else {
|
||||
int childStatus;
|
||||
|
||||
waitpid(m_ChildPid, &childStatus, 0);
|
||||
if (is_dgpu()) {
|
||||
EXPECT_EQ(WIFEXITED(childStatus), true);
|
||||
EXPECT_EQ(WEXITSTATUS(childStatus), HSAKMT_STATUS_SUCCESS);
|
||||
} else {
|
||||
EXPECT_EQ(WIFSIGNALED(childStatus), true);
|
||||
EXPECT_EQ(WTERMSIG(childStatus), SIGSEGV);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_END
|
||||
}
|
||||
|
||||
/* Test VM fault storm handling by copying to/from invalid pointers
|
||||
* with lots of work items at the same time
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user