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

fix(csr): add support virtual interrupt for hvictl csr injection #457

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

sinceforYy
Copy link
Contributor

No description provided.

@@ -144,6 +144,7 @@ class RefProxyConfig {
f(ref_skip_one, difftest_skip_one, void, bool, bool, uint32_t, uint64_t) \
f(ref_guided_exec, difftest_guided_exec, void, void*) \
f(raise_nmi_intr, difftest_raise_nmi_intr, void, bool) \
f(ref_interrupt_injection, difftest_interrupt_injection, void, bool) \
Copy link
Member

Choose a reason for hiding this comment

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

Is the name "interrupt injection" specifically used for this hvictl? This name looks like injecting interrupts to the REF to me, including the normal interrupts (by raise_interrupt)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll modify the name for easier look.

@klin02
Copy link
Member

klin02 commented Sep 4, 2024

Format check failed.
Please run pip install --user clang-format==18.1.4 and make format locally.

@@ -398,6 +398,7 @@ int Difftest::step() {

void Difftest::do_interrupt() {
state->record_interrupt(dut->event.exceptionPC, dut->event.exceptionInst, dut->event.interrupt);
proxy->hvictl_interrupt_injection(dut->event.intrInj);
Copy link
Member

Choose a reason for hiding this comment

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

Should we implement them as:

if (dut->event.intrInj) {
  // call hvictl_...
}
else if (dut->event.hasNMI) {
  // call nmi
}
else {
 // call raise_intr
}

The bool arguments seem useless (and may bring minor performance degradation)

@@ -54,6 +54,7 @@ class ArchEvent extends DifftestBaseBundle with HasValid {
val exceptionPC = UInt(64.W)
val exceptionInst = UInt(32.W)
val hasNMI = Bool()
val intrInj = Bool()
Copy link
Member

Choose a reason for hiding this comment

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

This name also seems generally applicable for interrupts. I don't know much about hvictl but may we need a more specific name

} else if (dut->event.virtualInterruptIsHvictlInject) {
proxy->virtual_interrupt_is_hvictl_inject(dut->event.virtualInterruptIsHvictlInject);
} else {
printf("No NMI interrupt and virtual interrupt is not hvictl inject\n");
Copy link
Member

Choose a reason for hiding this comment

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

Why is the printf here? For normal interrupts (should be the most common case), it will print this.

Copy link
Member

@poemonsense poemonsense left a comment

Choose a reason for hiding this comment

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

The code looks good to me except for the printf. If there's the printf, there will be too many outputs because every normal interrupt (external interrupt, timer interrupt, software interrupt, ...) will cause a printf output.

I don't know much about the modern RISC-V interrupts. But I have a general concern on the implementation here. Previously without NMI/virtualization, there's only the normal interrupts and different interrupt sources (causes) can be determined by the interrupt cause number. Is there any similar approach to determine the NMI/virt interrupts? The current code adds a bool for each type of interrupt. But I'm thinking of a more general approach to cover all interrupt types to reduce the cosim overhead, including normal interrupts, NMI, virtual, .... I'm just raising this concern for discussions. I'm glad for approving and merging after the printf is removed.

@poemonsense poemonsense merged commit 8aff29b into OpenXiangShan:master Sep 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants