Skip to content

Commit d75109a

Browse files
committed
Register client-side DMA allow lists and update tests for removed server-side allow list check
1 parent 8b4a532 commit d75109a

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

test/wh_test_clientserver.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,6 @@ static int _testDma(whServerContext* server, whClientContext* client)
351351
WH_TEST_ASSERT_RETURN(0 == memcmp(testMem.srvBufAllow, testMem.cliBuf,
352352
sizeof(testMem.srvBufAllow)));
353353

354-
/* Now try and copy from the denylisted addresses */
355-
WH_TEST_ASSERT_RETURN(WH_ERROR_ACCESS ==
356-
whServerDma_CopyFromClient(server, testMem.srvBufDeny,
357-
(uintptr_t)testMem.cliBuf,
358-
sizeof(testMem.cliBuf),
359-
(whServerDmaFlags){0}));
360-
WH_TEST_ASSERT_RETURN(
361-
WH_ERROR_ACCESS ==
362-
whServerDma_CopyToClient(server, (uintptr_t)testMem.cliBuf,
363-
testMem.srvBufDeny, sizeof(testMem.srvBufDeny),
364-
(whServerDmaFlags){0}));
365-
366354
/* Check that zero-sized copies fail, even from allowed addresses */
367355
WH_TEST_ASSERT_RETURN(WH_ERROR_BADARGS == whServerDma_CopyFromClient(
368356
server, testMem.srvBufAllow,

test/wh_test_multiclient.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static int _testGlobalKeyDma(whClientContext* client1, whServerContext* server1,
460460
sizeof("GlobalDmaExportTestKey12345!") - 1);
461461
memset(outBuf, 0, sizeof(outBuf));
462462

463-
/* Register DMA allow list for both servers */
463+
/* Register DMA allow list for both servers and clients */
464464
dmaAllowList.readList[0].addr = keyData1;
465465
dmaAllowList.readList[0].size = sizeof(keyData1);
466466
dmaAllowList.readList[1].addr = keyData2;
@@ -471,6 +471,10 @@ static int _testGlobalKeyDma(whClientContext* client1, whServerContext* server1,
471471
wh_Server_DmaRegisterAllowList(server1, &dmaAllowList));
472472
WH_TEST_RETURN_ON_FAIL(
473473
wh_Server_DmaRegisterAllowList(server2, &dmaAllowList));
474+
WH_TEST_RETURN_ON_FAIL(
475+
wh_Client_DmaRegisterAllowList(client1, &dmaAllowList));
476+
WH_TEST_RETURN_ON_FAIL(
477+
wh_Client_DmaRegisterAllowList(client2, &dmaAllowList));
474478

475479
WH_TEST_PRINT("Test: DMA operations with global keys\n");
476480

test/wh_test_posix_threadsafe_stress.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ typedef struct {
505505
/* DMA configuration */
506506
whServerDmaConfig dmaConfig;
507507
whServerDmaAddrAllowList dmaAllowList;
508+
whClientDmaConfig clientDmaConfig;
509+
whDmaAddrAllowList clientDmaAllowList;
508510
#endif
509511
} ClientServerPair;
510512

@@ -676,6 +678,23 @@ static int initClientServerPair(StressTestContext* ctx, int pairIndex)
676678
memset(&pair->dmaConfig, 0, sizeof(pair->dmaConfig));
677679
pair->dmaConfig.dmaAddrAllowList = &pair->dmaAllowList;
678680
pair->serverConfig.dmaConfig = &pair->dmaConfig;
681+
682+
/* Configure client DMA allow list (same buffers) */
683+
memset(&pair->clientDmaAllowList, 0, sizeof(pair->clientDmaAllowList));
684+
pair->clientDmaAllowList.readList[0].addr = pair->dmaKeyBuffer;
685+
pair->clientDmaAllowList.readList[0].size = sizeof(pair->dmaKeyBuffer);
686+
pair->clientDmaAllowList.readList[1].addr = pair->dmaNvmBuffer;
687+
pair->clientDmaAllowList.readList[1].size = sizeof(pair->dmaNvmBuffer);
688+
pair->clientDmaAllowList.readList[2].addr = &pair->dmaNvmMeta;
689+
pair->clientDmaAllowList.readList[2].size = sizeof(pair->dmaNvmMeta);
690+
pair->clientDmaAllowList.writeList[0].addr = pair->dmaKeyBuffer;
691+
pair->clientDmaAllowList.writeList[0].size = sizeof(pair->dmaKeyBuffer);
692+
pair->clientDmaAllowList.writeList[1].addr = pair->dmaNvmBuffer;
693+
pair->clientDmaAllowList.writeList[1].size = sizeof(pair->dmaNvmBuffer);
694+
695+
memset(&pair->clientDmaConfig, 0, sizeof(pair->clientDmaConfig));
696+
pair->clientDmaConfig.dmaAddrAllowList = &pair->clientDmaAllowList;
697+
pair->clientConfig.dmaConfig = &pair->clientDmaConfig;
679698
#endif
680699

681700
/* Initialize client in the main thread to avoid concurrent calls to

0 commit comments

Comments
 (0)