cva6 icon indicating copy to clipboard operation
cva6 copied to clipboard

[mmu question] Is it ok for the tlb_flush/flush to arrive during an ongoing translation ?

Open khandelwaltanuj opened this issue 11 months ago • 7 comments

Hello

I have a question regarding the flush of MMU. In my UVM TB tlb_flush and flush may arrive anytime randomly. I get a feeling that when a tlb_flush arrives during an ongoing transaction, it may cause spurious memory access. Though I have been wondering if its really a valid use case ?

Here is one scenerio in my waveform, where I am observing some spurious memory access after lsu_valid_o.

Image

Regards

khandelwaltanuj avatar May 20 '25 14:05 khandelwaltanuj

Hello @khandelwaltanuj,

After a quick read of the cva6/core/controller.sv file, it looks that this use case is valid. You can have both flush and flush_tlb valid at the same time.

Look into this code snippet:

    // ---------------------------------
    // SFENCE.VMA
    // ---------------------------------
    if (CVA6Cfg.RVS && sfence_vma_i) begin
      set_pc_commit_o        = 1'b1;
      flush_if_o             = 1'b1;
      flush_unissued_instr_o = 1'b1;
      flush_id_o             = 1'b1;
      flush_ex_o             = 1'b1;

      if (CVA6Cfg.RVH && v_i) flush_tlb_vvma_o = 1'b1;
      else flush_tlb_o = 1'b1;
    end

When committing a sfence.vma instructions, both signals are set to 1.

It should be easy to run a test executing the sfence.vma instruction to watch it in simulation.

cfuguet avatar May 20 '25 16:05 cfuguet

Thanks @cfuguet for your reply.

My questions is more about, if flush can arrive during an ongoing translation ? When lsu_req_i is high and flush is inserted.

Regards Tanuj Khandelwal

khandelwaltanuj avatar May 21 '25 05:05 khandelwaltanuj

If you have the sfence.vma instruction immediately followed by a load instruction, I have the feeling that it is possible.

It would be interesting to run that unitary test.

cfuguet avatar May 21 '25 05:05 cfuguet

You can see the waves in my original message, its where tlb_flush inserted as lsu translation is ongoing. It seems to make some spurious memory accesses.

My UVM bench is still not open sourced yet. Once it is done, I can provide you with the seed.

Thanks

khandelwaltanuj avatar May 21 '25 05:05 khandelwaltanuj

If you think its not normal, I can mark it as a bug.

khandelwaltanuj avatar May 21 '25 05:05 khandelwaltanuj

As the target of this mmu is the CVA6, we should make sure that case can actually happen with the CVA6.

My feeling is that yes, with the example I gave before, but because of some buffering, may be it is not possible.

We should check first

cfuguet avatar May 21 '25 06:05 cfuguet

Ok,

In that case, we need to wait until I start the top level bench.

Thanks

khandelwaltanuj avatar May 21 '25 06:05 khandelwaltanuj

👋 Hi there!

This issue seems inactive. Need more help? Feel free to update us. If there are no updates within the next few days, we'll go ahead and close this issue. 😊

github-actions[bot] avatar Jun 21 '25 02:06 github-actions[bot]