Skip to content

Commit ea31c7a

Browse files
Correctly forward GPA on gvma flush (#3227)
GVMA flushes takes as parameter a shifted address, but the un-shifting was wrongly computed compared to the TLB's implementation. Fixing that, and minor formatting on cvs6_tlb.sv. Co-authored-by: JeanRochCoulon <jean-roch.coulon@thalesgroup.com>
1 parent aef009c commit ea31c7a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

core/cva6_mmu/cva6_tlb.sv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ module cva6_tlb
155155
// Identify `vpage_match` (matching page type) and deduce `vaddr_level` match (hit at all level on the virtual addr to be flushed
156156
// and matching page type).
157157
for (z_gen = 0; z_gen < HYP_EXT + 1; z_gen++) begin
158-
assign vpage_match[i_gen][z_gen][x_gen] = x_gen == 0 ? 1 : tags_q[i_gen].is_page[CVA6Cfg.PtLevels-1-x_gen][z_gen];
158+
assign vpage_match [i_gen][z_gen][x_gen] = x_gen == 0 ? 1 : tags_q[i_gen].is_page[CVA6Cfg.PtLevels-1-x_gen][z_gen];
159159
assign vaddr_level_match[i_gen][z_gen][x_gen] = &vaddr_vpn_match[i_gen][z_gen][CVA6Cfg.PtLevels-1:x_gen] && vpage_match[i_gen][z_gen][x_gen];
160160
end
161-
//identify if virtual address vpn matches at all PT levels for all TLB entries
162-
assign vaddr_vpn_match[i_gen][0][x_gen] = vaddr_to_be_flushed_i[12+((CVA6Cfg.VpnLen/CVA6Cfg.PtLevels)*(x_gen+1))-1:12+((CVA6Cfg.VpnLen/CVA6Cfg.PtLevels)*x_gen)] == tags_q[i_gen].vpn[x_gen];
163161

162+
// Identify if virtual address vpn matches at all PT levels for all TLB entries
163+
assign vaddr_vpn_match[i_gen][0][x_gen] = vaddr_to_be_flushed_i[12+((CVA6Cfg.VpnLen/CVA6Cfg.PtLevels)*(x_gen+1))-1:12+((CVA6Cfg.VpnLen/CVA6Cfg.PtLevels)*x_gen)] == tags_q[i_gen].vpn[x_gen];
164164
end
165165

166166
// Identify if the input virtual address matches a stored NAPOT tag
@@ -366,9 +366,9 @@ module cva6_tlb
366366
// flush everything if vmid is 0 and addr is 0 ("HFENCE.GVMA x0 x0" case)
367367
if (vmid_to_be_flushed_is0 && gpaddr_to_be_flushed_is0) tags_n[i].valid = 1'b0;
368368
// flush gpaddr in all addressing space ("HFENCE.GVMA gpaddr x0" case), it should happen only for leaf pages
369-
else if (vmid_to_be_flushed_is0 && (|vaddr_level_match[i][HYP_EXT] ) && (~gpaddr_to_be_flushed_is0))
369+
else if (vmid_to_be_flushed_is0 && (|vaddr_level_match[i][HYP_EXT]) && (~gpaddr_to_be_flushed_is0))
370370
tags_n[i].valid = 1'b0;
371-
// the entry vmid and gpaddr both matches with the entry to be flushed ("HFENCE.GVMA gpaddr vmid" case)
371+
// the entry vmid and gpaddr both match with the entry to be flushed ("HFENCE.GVMA gpaddr vmid" case)
372372
else if ((|vaddr_level_match[i][HYP_EXT]) && (vmid_to_be_flushed_i == tags_q[i].vmid) && (~gpaddr_to_be_flushed_is0) && (~vmid_to_be_flushed_is0))
373373
tags_n[i].valid = 1'b0;
374374
// the entry is flushed if the vmid matches and gpaddr is 0. ("HFENCE.GVMA 0 vmid" case)

core/ex_stage.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ module ex_stage
707707
// if the current instruction in EX_STAGE is a sfence.vma, in the next cycle no writes will happen
708708
end else if ((~(current_instruction_is_sfence_vma || current_instruction_is_hfence_vvma || current_instruction_is_hfence_gvma)) && (~((fu_data_i[0].operation == SFENCE_VMA || fu_data_i[0].operation == HFENCE_VVMA || fu_data_i[0].operation == HFENCE_GVMA ) && |csr_valid_i))) begin
709709
vaddr_to_be_flushed <= rs1_forwarding;
710-
gpaddr_to_be_flushed <= {2'b00, rs1_forwarding[CVA6Cfg.GPLEN-1:2]};
710+
gpaddr_to_be_flushed <= {rs1_forwarding[CVA6Cfg.GPLEN-3:0], 2'b00};
711711
asid_to_be_flushed <= rs2_forwarding[CVA6Cfg.ASID_WIDTH-1:0];
712712
vmid_to_be_flushed <= rs2_forwarding[CVA6Cfg.VMID_WIDTH-1:0];
713713
end

0 commit comments

Comments
 (0)