Skip to content

Commit

Permalink
check return values
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Nov 10, 2023
1 parent 07e62b1 commit 15f41b0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions iommu_ref_model/test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ main(void) {
fail_if( ( check_rsp_and_faults(&req, &rsp, UNSUPPORTED_REQUEST, 266, 0) < 0 ) );

// Access viol on non-leaf PDTE
translate_gpa(DC.iohgatp, DC.fsc.pdtp.PPN * PAGESIZE, &temp);
fail_if( (translate_gpa(DC.iohgatp, DC.fsc.pdtp.PPN * PAGESIZE, &temp) == -1) );
access_viol_addr = (temp) | (get_bits(19, 17, 0xBABEC) * 8);
send_translation_request(0x112233, 1, 0xBABEC, 0,
0, 1, 0, ADDR_TYPE_UNTRANSLATED, 0xdeadbeef,
Expand Down Expand Up @@ -2117,10 +2117,10 @@ main(void) {
PC.ta.ENS = 1;
PC.ta.SUM = 1;
PC_addr = add_process_context(&DC, &PC, 0xBABEC);
read_memory(PC_addr, 16, (char *)&PC);
fail_if( (read_memory(PC_addr, 16, (char *)&PC) != 0) );

// misconfigured NL PTE
translate_gpa(DC.iohgatp, DC.fsc.pdtp.PPN * PAGESIZE, &temp);
fail_if( (translate_gpa(DC.iohgatp, DC.fsc.pdtp.PPN * PAGESIZE, &temp) == -1) );
temp = (temp) | (get_bits(19, 17, 0xBABEC) * 8);
read_memory(temp, 8, (char *)&pdte);
pdte.reserved0 = 1;
Expand Down Expand Up @@ -2207,6 +2207,7 @@ main(void) {
// guest page fault on PC walk
gpa = (DC.fsc.pdtp.PPN * PAGESIZE) | (get_bits(19, 17, 0xBABEC) * 8);
temp = translate_gpa(DC.iohgatp, gpa, &temp);
fail_if( (temp == -1) );
read_memory(temp, 8, (char *)&gpte);
gpte.V = 0;
write_memory((char *)&gpte, temp, 8);
Expand Down Expand Up @@ -2476,6 +2477,7 @@ main(void) {

// Guest-Page fault on NL S-stage PTE
gpte_addr = translate_gpa(DC.iohgatp, (PC.fsc.iosatp.PPN * PAGESIZE), &temp);
fail_if( (gpte_addr == -1) );
read_memory(gpte_addr, 8, (char *)&gpte);
gpte.V = 0;
write_memory((char *)&gpte.raw, gpte_addr, 8);
Expand Down

0 comments on commit 15f41b0

Please sign in to comment.