riscv-non-isa / riscv-iommu

RISC-V IOMMU Specification
https://jira.riscv.org/browse/RVG-55
Creative Commons Attribution 4.0 International
88 stars 17 forks source link

it seems that the fault queue overflow flag in the reference model lake a condition? #265

Closed baimengwei closed 8 months ago

baimengwei commented 11 months ago

https://github.com/riscv-non-isa/riscv-iommu/blob/main/iommu_ref_model/libiommu/src/iommu_faults.c#L124C30-L124C30 if the fqt is 1023 and fqh is 0, and the max queue size is 1024, then the condition will be 1023 == -1, which seems incorrect?

    if ( fqt == (fqh - 1) ) {
        g_reg_file.fqcsr.fqof = 1;
        generate_interrupt(FAULT_QUEUE);
        return;
    }
ved-rivos commented 11 months ago

Thanks for pointing that out. Fix in PR #266

baimengwei commented 8 months ago

if the fqt is 1023 and fqh is 0, and the max queue size is 1024, is this a full condition, which only can store 1023 record item, rather than 1024 item?

baimengwei commented 8 months ago

If c model changes the full condition, should the specification change synchronous? https://github.com/riscv-non-isa/riscv-iommu/blob/main/iommu_registers.adoc#fault-queue-csr-fqcsr

The fault-queue-overflow bit is set to 1 if the IOMMU needs to queue a fault record but the fault-queue is full (i.e., fqt == fqh - 1).

The fault-record is discarded and no more fault records are generated until software clears fqof by writing 1 to the bit.

ved-rivos commented 8 months ago

if the fqt is 1023 and fqh is 0, and the max queue size is 1024, is this a full condition, which only can store 1023 record item, rather than 1024 item?

Yes. Please see Chapter 3 - "A queue is empty if the head is equal to the tail. A queue is full if the tail is the head minus one. The head and tail wrap around when they reach the end of the circular buffer."

baimengwei commented 8 months ago

if the fqt is 1023 and fqh is 0, and the max queue size is 1024, is this a full condition, which only can store 1023 record item, rather than 1024 item?

Yes. Please see Chapter 3 - "A queue is empty if the head is equal to the tail. A queue is full if the tail is the head minus one. The head and tail wrap around when they reach the end of the circular buffer."

Thanks