Skip to content

Commit c0073f6

Browse files
committed
Fix CI: register DMA allow lists in tests and remove erroneous server-side allow list check in CopyFromClient/CopyToClient
1 parent b3030d9 commit c0073f6

2 files changed

Lines changed: 42 additions & 32 deletions

File tree

src/wh_server_dma.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,7 @@ int whServerDma_CopyFromClient(struct whServerContext_t* server,
131131
return WH_ERROR_BADARGS;
132132
}
133133

134-
/* Check the server address against the allow list */
135-
rc = wh_Dma_CheckMemOperAgainstAllowList(server->dma.dmaAddrAllowList,
136-
WH_DMA_OPER_CLIENT_READ_PRE,
137-
serverPtr, len);
138-
if (rc != WH_ERROR_OK) {
139-
return rc;
140-
}
141-
142-
/* Process the client address pre-read */
134+
/* Process the client address pre-read (includes allow list check) */
143135
rc = wh_Server_DmaProcessClientAddress(
144136
server, clientAddr, &transformedAddr, len, WH_DMA_OPER_CLIENT_READ_PRE,
145137
flags);
@@ -185,15 +177,7 @@ int whServerDma_CopyToClient(struct whServerContext_t* server,
185177
return WH_ERROR_BADARGS;
186178
}
187179

188-
/* Check the server address against the allow list */
189-
rc = wh_Dma_CheckMemOperAgainstAllowList(server->dma.dmaAddrAllowList,
190-
WH_DMA_OPER_CLIENT_WRITE_PRE,
191-
serverPtr, len);
192-
if (rc != WH_ERROR_OK) {
193-
return rc;
194-
}
195-
196-
/* Process the client address pre-write */
180+
/* Process the client address pre-write (includes allow list check) */
197181
rc = wh_Server_DmaProcessClientAddress(server, clientAddr, &transformedAddr,
198182
len, WH_DMA_OPER_CLIENT_WRITE_PRE,
199183
flags);

test/wh_test_clientserver.c

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -972,16 +972,28 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType)
972972
WH_TEST_ASSERT_RETURN(avail_objects == WOLFHSM_CFG_NVM_OBJECT_COUNT);
973973

974974
#ifdef WOLFHSM_CFG_DMA
975+
{
976+
/* Register DMA allow list for the buffers used in DMA NVM tests.
977+
* meta is declared here so its address is stable for the allow list */
978+
whNvmMetadata meta = {0};
979+
whServerDmaAddrAllowList nvm_dma_allow = {0};
980+
nvm_dma_allow.readList[0].addr = send_buffer;
981+
nvm_dma_allow.readList[0].size = sizeof(send_buffer);
982+
nvm_dma_allow.readList[1].addr = &meta;
983+
nvm_dma_allow.readList[1].size = sizeof(meta);
984+
nvm_dma_allow.writeList[0].addr = recv_buffer;
985+
nvm_dma_allow.writeList[0].size = sizeof(recv_buffer);
986+
WH_TEST_RETURN_ON_FAIL(
987+
wh_Server_DmaRegisterAllowList(server, &nvm_dma_allow));
988+
975989
/* Same writeback test, but with DMA */
976990
for (counter = 0; counter < 5; counter++) {
977-
whNvmMetadata meta = {
978-
.id = counter + 40,
979-
.access = WH_NVM_ACCESS_ANY,
980-
.flags = WH_NVM_FLAGS_NONE,
981-
.len = 0,
982-
.label = {0},
983-
};
984991
whNvmSize len = 0;
992+
meta.id = counter + 40;
993+
meta.access = WH_NVM_ACCESS_ANY;
994+
meta.flags = WH_NVM_FLAGS_NONE;
995+
meta.len = 0;
996+
memset(meta.label, 0, sizeof(meta.label));
985997

986998
whNvmId gid = 0;
987999
whNvmAccess gaccess = 0;
@@ -1121,6 +1133,7 @@ int whTest_ClientServerSequential(whTestNvmBackendType nvmType)
11211133
WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK);
11221134
WH_TEST_ASSERT_RETURN(avail_objects == WOLFHSM_CFG_NVM_OBJECT_COUNT);
11231135

1136+
} /* DMA allow list scope */
11241137
#endif /* WOLFHSM_CFG_DMA */
11251138

11261139
/* Test custom registered callbacks */
@@ -1350,16 +1363,28 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg)
13501363
WH_TEST_ASSERT_RETURN(avail_objects == WOLFHSM_CFG_NVM_OBJECT_COUNT);
13511364

13521365
#ifdef WOLFHSM_CFG_DMA
1366+
{
1367+
/* Register DMA allow list for the buffers used in DMA NVM tests.
1368+
* meta is declared here so its address is stable for the allow list */
1369+
whNvmMetadata meta = {0};
1370+
whServerDmaAddrAllowList nvm_dma_allow = {0};
1371+
nvm_dma_allow.readList[0].addr = send_buffer;
1372+
nvm_dma_allow.readList[0].size = sizeof(send_buffer);
1373+
nvm_dma_allow.readList[1].addr = &meta;
1374+
nvm_dma_allow.readList[1].size = sizeof(meta);
1375+
nvm_dma_allow.writeList[0].addr = recv_buffer;
1376+
nvm_dma_allow.writeList[0].size = sizeof(recv_buffer);
1377+
WH_TEST_RETURN_ON_FAIL(
1378+
wh_Server_DmaRegisterAllowList(server, &nvm_dma_allow));
1379+
13531380
/* Same writeback test, but with DMA */
13541381
for (counter = 0; counter < 5; counter++) {
1355-
whNvmMetadata meta = {
1356-
.id = counter + 40,
1357-
.access = WH_NVM_ACCESS_ANY,
1358-
.flags = WH_NVM_FLAGS_NONE,
1359-
.len = 0,
1360-
.label = {0},
1361-
};
13621382
whNvmSize len = 0;
1383+
meta.id = counter + 40;
1384+
meta.access = WH_NVM_ACCESS_ANY;
1385+
meta.flags = WH_NVM_FLAGS_NONE;
1386+
meta.len = 0;
1387+
memset(meta.label, 0, sizeof(meta.label));
13631388

13641389
whNvmId gid = 0;
13651390
whNvmAccess gaccess = 0;
@@ -1464,6 +1489,7 @@ int whTest_ClientServerClientConfig(whClientConfig* clientCfg)
14641489
WH_TEST_ASSERT_RETURN(server_rc == WH_ERROR_OK);
14651490
WH_TEST_ASSERT_RETURN(avail_objects == WOLFHSM_CFG_NVM_OBJECT_COUNT);
14661491

1492+
} /* DMA allow list scope */
14671493
#endif /* WOLFHSM_CFG_DMA */
14681494

14691495
/* Test client counter API */

0 commit comments

Comments
 (0)