Skip to content

Commit

Permalink
add missing too wide device_id check
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed May 10, 2024
1 parent 6f8ad27 commit 19873d8
Showing 1 changed file with 79 additions and 4 deletions.
83 changes: 79 additions & 4 deletions iommu_ref_model/test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ main(void) {
exp_msg.MSGCODE = PRGR_MSG_CODE;
exp_msg.TAG = 0;
exp_msg.RID = 0x1234;
exp_msg.PV = 0;
exp_msg.PID = 0;
exp_msg.PV = 1;
exp_msg.PID = 0xbabec;
exp_msg.PRIV = 0;
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
Expand Down Expand Up @@ -185,11 +185,86 @@ main(void) {
send_translation_request(0x000145, 0, 0x99, 0, 0, 0, 0,
UNTRANSLATED_REQUEST, 0, 1, READ, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 260, 0) < 0 ) );
pr.MSGCODE = PAGE_REQ_MSG_CODE;
pr.TAG = 0;
pr.RID = 0x1234;
pr.PV = 0;
pr.PID = 0;
pr.PRIV = 0;
pr.EXEC_REQ = 0;
pr.DSV = 1;
pr.DSEG = 0x43;
pr.PAYLOAD = 0xdeadbeef00000007; // Set last, PRG index = 0
exp_msg.MSGCODE = PRGR_MSG_CODE;
exp_msg.TAG = 0;
exp_msg.RID = 0x1234;
exp_msg.PV = 0;
exp_msg.PID = 0;
exp_msg.PRIV = 0;
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
handle_page_request(&pr);
fail_if( ( exp_msg_received == 0 ) );
fail_if( ( check_msg_faults(260, pr.PV, pr.PID, pr.PRIV, 0x431234, PAGE_REQ_MSG_CODE) < 0 ) );

fail_if( ( enable_iommu(DDT_2LVL) < 0 ) );
send_translation_request(0x012345, 0, 0x99, 0, 0, 0, 0,
UNTRANSLATED_REQUEST, 0, 1, READ, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 260, 0) < 0 ) );

pr.MSGCODE = PAGE_REQ_MSG_CODE;
pr.TAG = 0;
pr.RID = 0x1234;
pr.PV = 0;
pr.PID = 0;
pr.PRIV = 0;
pr.EXEC_REQ = 0;
pr.DSV = 1;
pr.DSEG = 0x43;
pr.PAYLOAD = 0xdeadbeef00000007; // Set last, PRG index = 0
exp_msg.MSGCODE = PRGR_MSG_CODE;
exp_msg.TAG = 0;
exp_msg.RID = 0x1234;
exp_msg.PV = 0;
exp_msg.PID = 0;
exp_msg.PRIV = 0;
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
handle_page_request(&pr);
fail_if( ( exp_msg_received == 0 ) );
fail_if( ( check_msg_faults(260, pr.PV, pr.PID, pr.PRIV, 0x431234, PAGE_REQ_MSG_CODE) < 0 ) );

// Change to MSI flat mode
g_reg_file.capabilities.msi_flat = 0;
pr.MSGCODE = PAGE_REQ_MSG_CODE;
pr.TAG = 0;
pr.RID = 0x1234;
pr.PV = 0;
pr.PID = 0;
pr.PRIV = 0;
pr.EXEC_REQ = 0;
pr.DSV = 1;
pr.DSEG = 0x43;
pr.PAYLOAD = 0xdeadbeef00000007; // Set last, PRG index = 0
exp_msg.MSGCODE = PRGR_MSG_CODE;
exp_msg.TAG = 0;
exp_msg.RID = 0x1234;
exp_msg.PV = 0;
exp_msg.PID = 0;
exp_msg.PRIV = 0;
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
handle_page_request(&pr);
fail_if( ( exp_msg_received == 0 ) );
fail_if( ( check_msg_faults(260, pr.PV, pr.PID, pr.PRIV, 0x431234, PAGE_REQ_MSG_CODE) < 0 ) );
g_reg_file.capabilities.msi_flat = 1;

END_TEST();

// Enable IOMMU
Expand Down Expand Up @@ -2893,8 +2968,8 @@ main(void) {
exp_msg.MSGCODE = PRGR_MSG_CODE;
exp_msg.TAG = 0;
exp_msg.RID = 0x1234;
exp_msg.PV = 0;
exp_msg.PID = 0;
exp_msg.PV = 1;
exp_msg.PID = 0xbabec;
exp_msg.PRIV = 0;
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
Expand Down

0 comments on commit 19873d8

Please sign in to comment.