Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add m-mode, s-mode CLIC interrupt testcases #436

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

dansmathers
Copy link
Contributor

Description

Provide a detailed description of the changes performed by the PR.

This is a draft version of the m-mode (Smclic) and s-mode (Ssclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note: pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development.

This pull requires:
riscv-software-src/riscv-config#169,
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include m-mode CLIC interrupt tests in riscof testlist flow, add Smclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
ISA: RV32IMCZicsr_Zifencei_Smclic

To include s-mode CLIC interrupt tests in riscof testlist flow, add Ssclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
ISA: RV32IMCZicsr_Zifencei_Ssclic

Related Issues

Please list all the issues related to this PR. Use NA if no issues exist

Ratified/Unratified Extensions

  • Ratified
  • [x ] Unratified

List Extensions

List the extensions that your PR affects. In case of unratified extensions, please provide a link to the spec draft that was referred to make this PR.

Smclic, Ssclic

Reference Model Used

  • [x ] SAIL - No CLIC implementation available yet. Tests complete but signatures will not match with actual implementations.
  • [x ] Spike - No CLIC implementation available yet. Tests complete but signatures will not match with actual implementations.
  • [x ] Other - < Dut with CLIC implemented >

Mandatory Checklist:

  • [ x] All tests are compliant with the test-format spec present in this repo ?
  • [ x] Ran the new tests on RISCOF with SAIL/Spike as reference model successfully ?
  • [ x] Ran the new tests on RISCOF in coverage mode
  • Link to Google-Drive folder containing the new coverage reports (See this for more info): N/A, CLIC not implemented on SAIL or spike yet.
  • Link to PR in RISCV-ISAC from which the reports were generated : N/A
  • Changelog entry created with a minor patch

Optional Checklist:

  • RISCV-V CTG PR link if tests were generated using it : < SPECIFY HERE >
  • Were the tests hand-written/modified ?
  • [X ] Have you run these on any hard DUT model ? Please specify name and provide link if possible in the description
  • If you have modified arch_test.h Please provide a detailed description of the changes in the Description section above.

dansmathers added a commit to riscv/riscv-fast-interrupt that referenced this pull request Feb 9, 2024
smclic and ssclic testcases 
riscv-non-isa/riscv-arch-test#436

Signed-off-by: Dan Smathers <[email protected]>
dansmathers added a commit to riscv/riscv-fast-interrupt that referenced this pull request Feb 9, 2024
@silabs-kjetil
Copy link

I notice that this PR includes specific test cases for CLIC, do you use CLINT mode when running the other non-CLIC related test cases that include a trap handler like ebreak and ecall?

In my case I am looking for a way to run the arch-test suite on a device that only supports CLIC mode. It looks like this scenario is not yet supported in the arch-test trap handling code.

Do you know of any effort to include CLIC support in the trap handling code inside the arch_test.h file?

@dansmathers
Copy link
Contributor Author

Can you point me and @allenjbaum to the line you are having problems with in arch_test.h? arch_test.h is not supposed to be changing mtvec.mode (briefly looking at it, I think it looks like it is trying to do read/modify/write to mtvec). Allen developed arch_test.h and I'm sure would be willing to update it to fix any issues.

@silabs-kjetil
Copy link

Sure @dansmathers and @allenjbaum. It looks like the init_Mtvec function is preserving the mode bits, so that part should be fine. So far I have identified 3 potential issues in arch_test.h that makes it hard to use a pure CLIC device for the test cases that includes a trap handler.

ecall check fails
https://github.com/riscv-non-isa/riscv-arch-test/blob/main/riscv-test-suite/env/arch_test.h#L1160

This code is supposed to check for ecall, and exit early when it is detected. However the way the code is doing this does not work correctly when mcause contains extra bits like in the case when CLIC is used. Typically bits 29:28 will contain 0b11 so mcause will somtimes have the value 0x3000000B when read by the handler and the code will not detect that this is actually an ecall with exception code = 0xB

mcause is directly stored in the signature
https://github.com/riscv-non-isa/riscv-arch-test/blob/main/riscv-test-suite/env/arch_test.h#L1243

This means that any DUT using CLIC will never match the signature of a non-CLIC reference. This might be by design, however if the signature could filter out the exception/interrupt code then the signature would be equal between a CLIC DUT and a non-CLIC reference.

mode bits inside "vector" entry in signature
https://github.com/riscv-non-isa/riscv-arch-test/blob/main/riscv-test-suite/env/arch_test.h#L1222

It looks like the signature should contain the trampoline table (mtvec) offset (excluding mode bits), however the code brings in all the bits from mtvec including bits 1:0 containing the mode. These mode bits which are 0b11 in the CLIC case will cause artifacts in the signature. It also looks like the vector offset signature is supposed to be placed at bits 15:6 so shifted 5 bits to the left, however the code only shifts 4 bits left.

@allenjbaum
Copy link
Collaborator

allenjbaum commented Mar 9, 2024 via email

@silabs-kjetil
Copy link

Thank you @allenjbaum, if there are some changes that I can help out with then please reach out. I can start by creating issues in this project for the 1st and 3rd point so we can track it.

@silabs-kjetil
Copy link

Here are the two new issues created:

#440
#441

@jamesbeyond jamesbeyond added unratified size-L Large efforts required labels Jun 6, 2024
dansmathers and others added 9 commits June 6, 2024 11:05
This is a draft version of the m-mode (Smclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note, pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. 

This pull requires:
riscv-software-src/riscv-config#169, 
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include m-mode CLIC interrupt tests in riscof testlist flow, add Smclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Smclic


Signed-off-by: Dan Smathers <[email protected]>
This is a draft version of the m-mode (Smclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note, pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. 

This pull requires:
riscv-software-src/riscv-config#169, 
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include m-mode CLIC interrupt tests in riscof testlist flow, add Smclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Smclic

Signed-off-by: Dan Smathers <[email protected]>
his is a draft version of the s-mode (Ssclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note: pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. 

This pull requires:
riscv-software-src/riscv-config#169, 
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include s-mode CLIC interrupt tests in riscof testlist flow, add Ssclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Ssclic


Signed-off-by: Dan Smathers <[email protected]>
This is a draft version of the s-mode (Ssclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note: pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. 

This pull requires:
riscv-software-src/riscv-config#169, 
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include s-mode CLIC interrupt tests in riscof testlist flow, add Ssclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Ssclic


Signed-off-by: Dan Smathers <[email protected]>
This is a draft version of the m-mode (Smclic), s-mode (Ssclic) CLIC interrupt testcases using clint MSW and MTIMER macros.

Note: pulls are not yet available for spike or sail that support CLIC but these testcases should help enable their development. 

This pull requires:
riscv-software-src/riscv-config#169, 
riscv-software-src/riscof#106
riscv-software-src/riscv-isa-sim#1596

To include m-mode CLIC interrupt tests in riscof testlist flow, add Smclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Smclic

To include s-mode CLIC interrupt tests in riscof testlist flow, add Ssclic to riscof yaml file, e.g.:
spike/spike_isa.yaml:
  ISA: RV32IMCZicsr_Zifencei_Ssclic


Signed-off-by: Dan Smathers <[email protected]>
to allow different elf files between dut and ref, compare xnxti value to xtvt value
increased size of signature region. 32 was too small.

Signed-off-by: Dan Smathers <[email protected]>
to allow comparison between compiles at different code locations, xnxti signature value is compared to xtvt value.

Signed-off-by: Dan Smathers <[email protected]>
Signed-off-by: Dan Smathers <[email protected]>
Signed-off-by: Dan Smathers <[email protected]>
#define RVMODEL_TEST_INHV 0x1
#endif
#ifndef RVMODEL_INT1_CLICINTIE
#define RVMODEL_INT1_CLICINTIE 0x0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 9 mentions "enable clicintie (default)".
However, will this default setting on Line 33 result in lines 211-213, which program interrupt1 CLICINTIE, being set to 0x0 (i.e., disabling clicintie)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this testcase, there is no active interrupt. This testcase tests the behavior of the mcause.inhv bit. The inhv bit indicates that the hardware vectoring had an exception during the read of the hardware vector (e.g. page fault). after software clears the reason for the exception, mret sees inhv bit set and treats mepc as an address of an address in the hardware vector table instead of as an address of an instruction. It looks like I had a cut and paste error with the comments. Only this line is accurate: set mepc to shv table entry, set inhv, mret

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please confirm whether the test logic for set mepc to SHV table entry, set inhv, mret is located between lines 246 and 256? If that is the case, it's worth noting that RVMODEL_WFI will result in the hart being halted in the WFI state, as interrupts are disabled by lines 32 to 37, meaning the test logic will not be triggered. Please correct me if I’m mistaken.

location_1:

    RVMODEL_WFI

    LI(     t0, RVMODEL_TEST_INHV)
    beqz t0, finish
    LA(     t0,mtvtval)
    csrw    CSR_MEPC, t0
    LI(     t0,0x40000000)
    csrrs   x0, CSR_MCAUSE, t0
    mret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants