Skip to content

Commit

Permalink
Merge pull request riscv-non-isa#288 from ved-rivos/issue_287
Browse files Browse the repository at this point in the history
Missing reserved  check - issue 287
  • Loading branch information
ved-rivos authored Apr 11, 2024
2 parents 818ccee + 1d3ee7a commit a9a6967
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions iommu_ref_model/libiommu/src/iommu_msi_trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ msi_address_translation(
// set within msipte, stop and report "MSI PTE misconfigured" (cause = 263).
// b. Compute the translated address as `msipte.PPN << 12 | A[11:0]`.
if ( msipte.M == 3 ) {
if ( msipte.translate_rw.reserved != 0 ) {
if ( msipte.translate_rw.reserved != 0 || msipte.translate_rw.reserved0 != 0 ) {
*cause = 263;
return 1;
}
Expand All @@ -136,7 +136,7 @@ msi_address_translation(
}

// b. If any bits or encoding that are reserved for future standard use are
// set within `msipte`, stop and report "MSI PTE misconfigured" (cause = 262).
// set within `msipte`, stop and report "MSI PTE misconfigured" (cause = 263).
if ( msipte.mrif.reserved1 != 0 || msipte.mrif.reserved2 != 0 ||
msipte.mrif.reserved3 != 0 || msipte.mrif.reserved4 != 0 ) {
*cause = 263;
Expand Down
46 changes: 46 additions & 0 deletions iommu_ref_model/test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -3244,8 +3244,54 @@ main(void) {
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0 ) );

msipte.C = 0;
msipte.M = 0x3;
msipte.translate_rw.reserved = 0x1;
msipte.translate_rw.reserved0 = 0x0;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );
msipte.translate_rw.reserved = 0x0;
msipte.translate_rw.reserved = 0x4;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );

msipte.C = 0;
msipte.M = 0x3;
msipte.translate_rw.reserved = 0x0;
msipte.translate_rw.reserved0 = 0x1;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );
msipte.translate_rw.reserved = 0x0;
msipte.translate_rw.reserved = 0x4;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );

msipte.C = 0;
msipte.M = 0x3;
msipte.translate_rw.reserved = 0x1;
msipte.translate_rw.reserved0 = 0x1;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );
msipte.translate_rw.reserved = 0x0;
msipte.translate_rw.reserved = 0x4;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
send_translation_request(0x042874, 0, 0x0000, 0,
0, 0, 0, ADDR_TYPE_UNTRANSLATED, gpa, 4, WRITE, &req, &rsp);
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 263, 0) < 0) );

// Write through PTE
msipte.translate_rw.reserved = 0x0;
msipte.translate_rw.reserved0 = 0x0;
msipte.translate_rw.M = 0x3;
msipte.translate_rw.PPN = 0xdeadbeef;
write_memory((char *)&msipte, ((DC.msiptp.PPN * PAGESIZE) + 3 * 16), 16);
Expand Down

0 comments on commit a9a6967

Please sign in to comment.