Skip to content

Commit

Permalink
Merge pull request #323 from ved-rivos/0520_1
Browse files Browse the repository at this point in the history
Add missing did too wide check to inval_pdt
  • Loading branch information
ved-rivos authored May 20, 2024
2 parents f82f78b + ca1dad2 commit 40367b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iommu_ref_model/libiommu/src/iommu_command_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ process_commands(
// the DID operand must not be wider than that supported by
// the ddtp.iommu_mode.
if ( command.iodir.dv != 1 ) goto command_illegal;
// When DV operand is 1, the value of the DID operand must not
// be wider than that supported by the ddtp.iommu_mode.
if ( command.iodir.did & ~g_max_devid_mask )
goto command_illegal;
// The PID operand of IODIR.INVAL_PDT must not be wider than
// the width supported by the IOMMU (see Section 5.3)
if ( g_reg_file.capabilities.pd20 == 0 &&
Expand Down
8 changes: 8 additions & 0 deletions iommu_ref_model/test/test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,14 @@ main(void) {
write_memory((char *)&cmd, ((cqb.ppn * PAGESIZE) | (cqh.index * 16)), 16);
write_register(CQCSR_OFFSET, 4, cqcsr.raw);

// Invalidate PC - DID must not be too wide
g_max_devid_mask = 0x3F;
process_commands();
cqcsr.raw = read_register(CQCSR_OFFSET, 4);
fail_if( ( cqcsr.cmd_ill != 1 ) );
g_max_devid_mask = 0xFFFFFF;
write_register(CQCSR_OFFSET, 4, cqcsr.raw);

// Process the fixed up command
process_commands();

Expand Down

0 comments on commit 40367b0

Please sign in to comment.