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

Add vCLIC interface and logic #44

Closed
wants to merge 12 commits into from
Closed

Add vCLIC interface and logic #44

wants to merge 12 commits into from

Conversation

alex96295
Copy link

This PR adds support for virtualized interrupts handled by the RISC-V CLIC interface.

@ezelioli this is the reference PR for this feature, to be updated in Cheshire and other systems using CVA6 + CLIC with virtual extensions enabled for the latter

It would be good if you could use this branch to run your tests, so we see if I missed something during cherry-picking (there were a lot of conflicts because the current codebase has different indentation, causing false negatives)

@ezelioli @niwis we should try to converge on this ASAP

@alex96295 alex96295 requested a review from niwis as a code owner March 4, 2024 14:34
core/branch_unit.sv Outdated Show resolved Hide resolved
core/commit_stage.sv Outdated Show resolved Hide resolved
core/csr_regfile.sv Outdated Show resolved Hide resolved
core/csr_regfile.sv Show resolved Hide resolved
core/cva6_clic_controller.sv Outdated Show resolved Hide resolved
core/load_store_unit.sv Outdated Show resolved Hide resolved
core/load_store_unit.sv Outdated Show resolved Hide resolved
core/load_store_unit.sv Outdated Show resolved Hide resolved
core/load_store_unit.sv Outdated Show resolved Hide resolved
core/mmu_sv39x4/cva6_mmu_sv39x4.sv Outdated Show resolved Hide resolved
core/include/ariane_pkg.sv Outdated Show resolved Hide resolved
core/include/ariane_pkg.sv Outdated Show resolved Hide resolved
core/commit_stage.sv Outdated Show resolved Hide resolved
core/csr_regfile.sv Outdated Show resolved Hide resolved
core/csr_regfile.sv Show resolved Hide resolved
Enrico Zelioli and others added 7 commits March 5, 2024 09:09
@niwis
Copy link
Collaborator

niwis commented Mar 5, 2024

FPGA implementation fails because priv_lvl and trap_to_v are missing in this assignment

cva6/core/acc_dispatcher.sv

Lines 268 to 275 in eff9be5

assign acc_exception_o = '{
cause: riscv::ILLEGAL_INSTR,
tval : '0,
tval2 : '0,
tinst : '0,
gva : '0,
valid: acc_resp_i.error
};

@alex96295
Copy link
Author

FPGA implementation fails because priv_lvl and trap_to_v are missing in this assignment

cva6/core/acc_dispatcher.sv

Lines 268 to 275 in eff9be5

assign acc_exception_o = '{
cause: riscv::ILLEGAL_INSTR,
tval : '0,
tval2 : '0,
tinst : '0,
gva : '0,
valid: acc_resp_i.error
};

Thanks, will fix :)

@alex96295
Copy link
Author

LGTM for me @niwis, maybe we can do some squashing or squash-and-merge, but functionally it's ready for merge

@alex96295
Copy link
Author

@niwis rfc when you have time, so that we can proceed also in cheshire

Copy link
Collaborator

@niwis niwis left a comment

Choose a reason for hiding this comment

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

Thanks a lot @ezelioli and @alex96295 for the extensions and rebase! I have a few general comments and suggestions, the rest in-line.

  1. It seems like of the changes would generally be useful for H extension (also without CLIC). In particular, I'm thinking of a) tracing virtualisation mode, and b) Fixing H interrupt delegation. Do you think you could open dedicated PRs for these changes to this repo and Bruno's "upstream" H-ext branch?

  2. We're still experimenting with the new "integrate" action, so this is not very obvious. But the current integration causes a port mismatch. Can you point the base-ref in integration.yml to a cheshire ref which integrates vCLIC? See CONTRIBUTING-PULP.md

  3. A more open question: Should we have an explicit VCLIC parameter or similar to enable/disable non-specified features? My concern is that H and CLIC have official RISC-V specs whereas vCLIC does not, so implicitly activating vCLIC when H and CLIC are enabled might lead to unexpected behavior.

@@ -35,6 +35,7 @@ class ex_trace_item;
riscv::ST_ACCESS_FAULT: this.cause_s = "Store Access Fault";
riscv::ENV_CALL_UMODE: this.cause_s = "Environment Call User Mode";
riscv::ENV_CALL_SMODE: this.cause_s = "Environment Call Supervisor Mode";
riscv::ENV_CALL_VSMODE: this.cause_s = "Environment Call Virtual Supervisor Mode";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is generally useful for H ext... can we commit this separately so that we can also merge it into upstream H ext?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, seems more related to H ext than to vCLIC

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for the changes in this file (vCLIC->H)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also here (vCLIC->H)

Comment on lines +207 to +209
riscv::priv_lvl_t priv_lvl; // In CLIC mode, keeps information about
// incoming interrupt target privilege level
logic trap_to_v;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These fields might be a bit misleading since they are only used in CLIC mode. Would it be possible to pack them together with the other CLIC-specific data into the cause field? There should be enough space. This would also reduce the overall diff. We can also define a new struct type for better readability if you prefer.

// ------------------
// Interrupt Packager
// ------------------
// Pack interrupt cause to be inserted into the pipeline
assign clic_irq_cause_o = {
1'b1, // This is an irq
{riscv::XLEN - 25{1'b0}}, // XLEN-2...24
clic_irq_level_i, // to mintstatus.mil
{16 - $clog2(CVA6Cfg.CLICNumInterruptSrc) {1'b0}}, // 15...IDWidth
clic_irq_id_i
}; // to mcause

Comment on lines +152 to +164
| riscv::HSTATUS_VGEIN
| riscv::HSTATUS_VTVM
| riscv::HSTATUS_VTW
| riscv::HSTATUS_VTSR;

// hypervisor delegable interrupts
localparam logic [riscv::XLEN-1:0] HS_DELEG_INTERRUPTS = riscv::MIP_VSSIP
localparam logic [riscv::XLEN-1:0] HS_DELEG_INTERRUPTS = riscv::MIP_VSSIP;

localparam logic [63:0] HIE_MASK = riscv::MIP_VSSIP
| riscv::MIP_VSTIP
| riscv::MIP_VSEIP;
| riscv::MIP_VSEIP
| riscv::MIP_SGEIP;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these apply to H ext in general?

@@ -55,12 +64,67 @@ module cva6_clic_controller #(
clic_irq_req_o = clic_irq_valid_i;
// Take S-mode interrupts with higher level
end else if (clic_irq_priv_i == riscv::PRIV_LVL_S) begin
clic_irq_req_o = (clic_irq_level_i > max_sthresh) && (clic_irq_valid_i) && irq_ctrl_i.sie;
// clic_irq_req_o = (clic_irq_level_i > max_sthresh) && (clic_irq_valid_i) && irq_ctrl_i.sie;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this line can be removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are several ToDos in this file. Should we discuss them before merging?

@@ -531,7 +536,7 @@ module csr_regfile
if (CVA6Cfg.RVH) csr_rdata = htinst_q;
else read_access_exception = 1'b1;
riscv::CSR_HGEIE:
if (CVA6Cfg.RVH) csr_rdata = '0;
if (CVA6Cfg.RVH) csr_rdata = {hgeie_q[riscv::XLEN-1:1], 1'b0};
Copy link
Collaborator

Choose a reason for hiding this comment

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

These also look generally useful for H ext

@@ -1478,6 +1494,7 @@ module cva6
assign tracer_if.exception = commit_stage_i.exception_o;
// assign current privilege level
assign tracer_if.priv_lvl = priv_lvl;
assign tracer_if.v = v;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be combined with tracer H-support changes above

@niwis
Copy link
Collaborator

niwis commented Oct 31, 2024

Superseded by #55

@niwis niwis closed this Oct 31, 2024
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