Skip to content

Commit

Permalink
Protect out of bounds ram access using the cpu mintor
Browse files Browse the repository at this point in the history
not by filtering access in mem system

Signed-off-by: Joachim Strömbergson <[email protected]>
  • Loading branch information
secworks committed Mar 18, 2024
1 parent ab8ca02 commit 4a827f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 4 additions & 0 deletions hw/application_fpga/core/tk1/rtl/tk1.v
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ module tk1(
tmp_force_trap = 1'h1;
end

if (~cpu_addr[31] & cpu_addr[30] & |cpu_addr[29 : 17]) begin
tmp_force_trap = 1'h1;
end

if (cpu_mon_en_reg) begin
if ((cpu_addr >= cpu_mon_first_reg) &&
(cpu_addr <= cpu_mon_last_reg)) begin
Expand Down
15 changes: 4 additions & 11 deletions hw/application_fpga/rtl/application_fpga.v
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,10 @@ module application_fpga(
end

RAM_PREFIX: begin
if (|cpu_addr[29 : 17]) begin
muxed_rdata_new = 32'hdeadbeef;
muxed_ready_new = 1'h1;
ram_cs = 1'h0;
ram_we = 4'h0;
end else begin
ram_cs = 1'h1;
ram_we = cpu_wstrb;
muxed_rdata_new = ram_read_data ^ ram_scramble ^ {2{cpu_addr[15 : 0]}};
muxed_ready_new = ram_ready;
end
ram_cs = 1'h1;
ram_we = cpu_wstrb;
muxed_rdata_new = ram_read_data ^ ram_scramble ^ {2{cpu_addr[15 : 0]}};
muxed_ready_new = ram_ready;
end

RESERVED_PREFIX: begin
Expand Down

0 comments on commit 4a827f2

Please sign in to comment.