Skip to content

Commit

Permalink
Merge pull request riscv-non-isa#315 from ved-rivos/0510_1
Browse files Browse the repository at this point in the history
Update response code for too wide device ID
  • Loading branch information
ved-rivos authored May 10, 2024
2 parents 9a1f34e + b02959c commit f82f78b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions iommu_ref_model/libiommu/src/iommu_ats.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,17 @@ handle_page_request(
// a. `ddtp.iommu_mode` is `2LVL` and `DDI[2]` is not 0
// b. `ddtp.iommu_mode` is `1LVL` and either `DDI[2]` is not 0 or `DDI[1]` is not 0
if ( g_reg_file.ddtp.iommu_mode == DDT_2LVL && DDI[2] != 0 ) {
report_fault(260, PAGE_REQ_MSG_CODE, 0, PCIE_MESSAGE_REQUEST, 0,
cause = 260; // "Transaction type disallowed"
report_fault(cause, PAGE_REQ_MSG_CODE, 0, PCIE_MESSAGE_REQUEST, 0,
device_id, pr->PV, pr->PID, pr->PRIV);
response_code = RESPONSE_FAILURE;
response_code = INVALID_REQUEST;
goto send_prgr;
}
if ( g_reg_file.ddtp.iommu_mode == DDT_1LVL && (DDI[2] != 0 || DDI[1] != 0) ) {
report_fault(260, PAGE_REQ_MSG_CODE, 0, PCIE_MESSAGE_REQUEST, 0,
cause = 260; // "Transaction type disallowed"
report_fault(cause, PAGE_REQ_MSG_CODE, 0, PCIE_MESSAGE_REQUEST, 0,
device_id, pr->PV, pr->PID, pr->PRIV);
response_code = RESPONSE_FAILURE;
response_code = INVALID_REQUEST;
goto send_prgr;
}
// To process a "Page Request" or "Stop Marker" message, the IOMMU first
Expand Down
6 changes: 3 additions & 3 deletions iommu_ref_model/test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ main(void) {
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (INVALID_REQUEST << 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 ) );
Expand Down Expand Up @@ -233,7 +233,7 @@ main(void) {
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (INVALID_REQUEST << 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 ) );
Expand All @@ -259,7 +259,7 @@ main(void) {
exp_msg.EXEC_REQ = 0;
exp_msg.DSV = 1;
exp_msg.DSEG = 0x43;
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (RESPONSE_FAILURE << 44UL);
exp_msg.PAYLOAD = (0x1234UL << 48UL) | (INVALID_REQUEST << 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 ) );
Expand Down

0 comments on commit f82f78b

Please sign in to comment.