Skip to content

Commit

Permalink
Fixed a bug in Branch targeting, validate spectre attack
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziang95 committed Nov 28, 2019
1 parent 5e9eda2 commit 96bb66e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion FU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ A: at_rising_edge(next_vdd);
{
if (branch)
{
CPU_BTB.addEntry(R->instr_i, ((R->instr_i)/8)*8 + (R->instr_i + 1 + task.offset)%8);
CPU_BTB.addEntry(R->instr_i, (R->instr_i + 1 + task.offset)%8);
brcUnit.to_target(R->instr_i + 1 + task.offset);
msg_log("Begin Squash", 3);
brcUnit.to_squash(task.dest);
Expand Down
1 change: 0 additions & 1 deletion InputTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ CDB buffer entries = 1
R1=12, R2=32, F20=3.0
Mem[4]=3.0, Mem[8]=2.0, Mem[12]=1.0, Mem[24]=6.0, Mem[28]=5.0, Mem[32]=4.0

NOP
ld F2, 0(R1)
mult.d F4, F2, F20
ld F6, 0(R2)
Expand Down
5 changes: 2 additions & 3 deletions issue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ void get_reg_or_rob(string regName, int &Q, memCell &V)

bool check_squash()
{
msg_log("Checking squash status", 3);
msg_log("Checking squash status", 4);
if (brcUnit.squash_ROB_i() > -1)
{
pthread_mutex_lock(&squash_mutex);
msg_log("", 3);
instr_Q->squash = true;
pthread_cond_broadcast(&squash_cond);
pthread_mutex_unlock(&squash_mutex);
Expand Down Expand Up @@ -265,7 +264,7 @@ void *issue_automat(void *arg)
if (BTBEntry* predctr = CPU_BTB.getEntry(R->instr_i))
{
if (predctr->taken)
instr_Q->move_ptr(predctr->target);
instr_Q->move_ptr(((R->instr_i)/8)*8 + predctr->target);
else
instr_Q->ptr_advance();
}
Expand Down
6 changes: 5 additions & 1 deletion victim_code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ Load/store unit 3 1 5 1
ROB entries = 64
CDB buffer entries = 1

R1=0
R0=0
Mem[4]=3.0

Beq R0, R0, 2
NOP
NOP
NOP
Addi R2, R0, -2
Addi R3, R0, 4
Addi R2, R2, 2
Expand Down

0 comments on commit 96bb66e

Please sign in to comment.