From d9131e3b1dc571a657f9615903d1b7220c7c7d7f Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:40:01 -0700 Subject: Remove mcontrol_t.type. It's not writable anyway. --- riscv/triggers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 69888bf..1bcda2a 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -4,7 +4,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : - type(2), maskmax(0), select(false), timing(false), chain_bit(false), + maskmax(0), select(false), timing(false), chain_bit(false), match(MATCH_EQUAL), m(false), h(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { @@ -13,7 +13,7 @@ mcontrol_t::mcontrol_t() : reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { reg_t v = 0; auto xlen = proc->get_xlen(); - v = set_field(v, MCONTROL_TYPE(xlen), type); + v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), maskmax); v = set_field(v, MCONTROL_SELECT, select); -- cgit v1.1 From 16413646bb44d8752c25f0f36745b6b74a2a1025 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:48:00 -0700 Subject: Remove maskmax as a variable. --- riscv/triggers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 1bcda2a..99e3597 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -4,7 +4,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : - maskmax(0), select(false), timing(false), chain_bit(false), + select(false), timing(false), chain_bit(false), match(MATCH_EQUAL), m(false), h(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { @@ -15,7 +15,7 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { auto xlen = proc->get_xlen(); v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); - v = set_field(v, MCONTROL_MASKMAX(xlen), maskmax); + v = set_field(v, MCONTROL_MASKMAX(xlen), 0); v = set_field(v, MCONTROL_SELECT, select); v = set_field(v, MCONTROL_TIMING, timing); v = set_field(v, MCONTROL_ACTION, action); -- cgit v1.1 From f2f6037fea9313f43f7e94872304ab18ead0181d Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 22 Apr 2022 10:57:31 -0700 Subject: Remove mcontrol_t.h It was removed from the spec a long time ago. --- riscv/triggers.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 99e3597..7f6be44 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -5,7 +5,7 @@ namespace triggers { mcontrol_t::mcontrol_t() : select(false), timing(false), chain_bit(false), - match(MATCH_EQUAL), m(false), h(false), s(false), u(false), + match(MATCH_EQUAL), m(false), s(false), u(false), execute_bit(false), store_bit(false), load_bit(false) { } @@ -22,7 +22,6 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { v = set_field(v, MCONTROL_CHAIN, chain_bit); v = set_field(v, MCONTROL_MATCH, match); v = set_field(v, MCONTROL_M, m); - v = set_field(v, MCONTROL_H, h); v = set_field(v, MCONTROL_S, s); v = set_field(v, MCONTROL_U, u); v = set_field(v, MCONTROL_EXECUTE, execute_bit); @@ -56,7 +55,6 @@ bool mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val) noexcep break; } m = get_field(val, MCONTROL_M); - h = get_field(val, MCONTROL_H); s = get_field(val, MCONTROL_S); u = get_field(val, MCONTROL_U); execute_bit = get_field(val, MCONTROL_EXECUTE); -- cgit v1.1 From 85fbd75d44c369ccb358d70bb4adc3a82a23c495 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 28 Apr 2022 10:27:42 -0700 Subject: Implement mcontrol trigger hit bit. --- riscv/triggers.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 7f6be44..ed9105e 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -1,3 +1,4 @@ +#include "debug_defines.h" #include "processor.h" #include "triggers.h" @@ -16,6 +17,7 @@ reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { v = set_field(v, MCONTROL_TYPE(xlen), 2); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), 0); + v = set_field(v, CSR_MCONTROL_HIT, hit); v = set_field(v, MCONTROL_SELECT, select); v = set_field(v, MCONTROL_TIMING, timing); v = set_field(v, MCONTROL_ACTION, action); @@ -36,6 +38,7 @@ bool mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val) noexcep } auto xlen = proc->get_xlen(); dmode = get_field(val, MCONTROL_DMODE(xlen)); + hit = get_field(val, CSR_MCONTROL_HIT); select = get_field(val, MCONTROL_SELECT); timing = get_field(val, MCONTROL_TIMING); action = (triggers::action_t) get_field(val, MCONTROL_ACTION); @@ -131,6 +134,9 @@ match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operati } if (simple_match(xlen, value)) { + /* This is OK because this function is only called if the trigger was not + * inhibited by the previous trigger in the chain. */ + hit = true; if (timing) return MATCH_FIRE_AFTER; else @@ -165,6 +171,12 @@ match_result_t module_t::memory_access_match(action_t * const action, operation_ continue; } + /* Note: We call memory_access_match for each trigger in a chain as long as + * the triggers are matching. This results in "temperature coding" so that + * `hit` is set on each of the consecutive triggers that matched, even if the + * entire chain did not match. This is allowed by the spec, because the final + * trigger in the chain will never get `hit` set unless the entire chain + * matches. */ match_result_t result = triggers[i]->memory_access_match(proc, operation, address, data); if (result != MATCH_NONE && !triggers[i]->chain()) { *action = triggers[i]->action; -- cgit v1.1 From 62ecca6f8a8fdceb0e2bf54bc21ea5899e100ea8 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Mon, 2 May 2022 09:26:46 -0700 Subject: Use MCONTROL_TYPE_MATCH macro instead of 2 --- riscv/triggers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index ed9105e..4d16a58 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -14,7 +14,7 @@ mcontrol_t::mcontrol_t() : reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { reg_t v = 0; auto xlen = proc->get_xlen(); - v = set_field(v, MCONTROL_TYPE(xlen), 2); + v = set_field(v, MCONTROL_TYPE(xlen), MCONTROL_TYPE_MATCH); v = set_field(v, MCONTROL_DMODE(xlen), dmode); v = set_field(v, MCONTROL_MASKMAX(xlen), 0); v = set_field(v, CSR_MCONTROL_HIT, hit); -- cgit v1.1 From 2aedbdd01911a42565cd6d154f82fa00a66410cd Mon Sep 17 00:00:00 2001 From: Weiwei Li Date: Fri, 1 Jul 2022 16:09:02 +0800 Subject: remove multi blank lines --- riscv/triggers.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 4d16a58..c9d6161 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -212,5 +212,4 @@ bool module_t::tdata2_write(processor_t * const proc, unsigned index, const reg_ return result; } - }; -- cgit v1.1 From 95f36bc28eb79bb9d7a8681dcb2a83b364842b62 Mon Sep 17 00:00:00 2001 From: Scott Johnson Date: Thu, 15 Sep 2022 10:29:28 -0700 Subject: Initialize triggers using default member initializers Instead of constructor member initializer lists, which require repeating the list of members, and cause ugly merge conflicts when the list of members changes. --- riscv/triggers.cc | 7 ------- 1 file changed, 7 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index c9d6161..4b73715 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -4,13 +4,6 @@ namespace triggers { -mcontrol_t::mcontrol_t() : - select(false), timing(false), chain_bit(false), - match(MATCH_EQUAL), m(false), s(false), u(false), - execute_bit(false), store_bit(false), load_bit(false) -{ -} - reg_t mcontrol_t::tdata1_read(const processor_t * const proc) const noexcept { reg_t v = 0; auto xlen = proc->get_xlen(); -- cgit v1.1 From b724db52f9d7be3e3068e5bf01ac939ece8d032b Mon Sep 17 00:00:00 2001 From: YenHaoChen Date: Fri, 30 Sep 2022 11:48:44 +0800 Subject: Add has_data argument to trigger checking functions The mcontrol trigger can select either address or data for checking. The The selection decides the priority of the trigger. For instance, the address trigger has a higher priority over the page fault, and the page fault has a higher priority over the data trigger. The previous implementation only has the checking functions for data trigger, which results in incorrect priority of address trigger. This commit adds a has_data argument to indicate address trigger and the priority of the trigger. --- riscv/triggers.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 4b73715..e357b4a 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -101,7 +101,7 @@ bool mcontrol_t::simple_match(unsigned xlen, reg_t value) const { assert(0); } -match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operation_t operation, reg_t address, reg_t data) { +match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operation_t operation, reg_t address, bool has_data, reg_t data) { state_t * const state = proc->get_state(); if ((operation == triggers::OPERATION_EXECUTE && !execute_bit) || (operation == triggers::OPERATION_STORE && !store_bit) || @@ -115,6 +115,8 @@ match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operati reg_t value; if (select) { value = data; + if (!has_data) + return MATCH_NONE; } else { value = address; } @@ -150,7 +152,7 @@ module_t::~module_t() { } } -match_result_t module_t::memory_access_match(action_t * const action, operation_t operation, reg_t address, reg_t data) +match_result_t module_t::memory_access_match(action_t * const action, operation_t operation, reg_t address, bool has_data, reg_t data) { state_t * const state = proc->get_state(); if (state->debug_mode) @@ -170,7 +172,7 @@ match_result_t module_t::memory_access_match(action_t * const action, operation_ * entire chain did not match. This is allowed by the spec, because the final * trigger in the chain will never get `hit` set unless the entire chain * matches. */ - match_result_t result = triggers[i]->memory_access_match(proc, operation, address, data); + match_result_t result = triggers[i]->memory_access_match(proc, operation, address, has_data, data); if (result != MATCH_NONE && !triggers[i]->chain()) { *action = triggers[i]->action; return result; -- cgit v1.1 From 3c9cfac9b1f7f1ddf07816f948c15f88aac27dcf Mon Sep 17 00:00:00 2001 From: YenHaoChen <39526191+YenHaoChen@users.noreply.github.com> Date: Wed, 5 Oct 2022 06:22:15 +0800 Subject: Fix trigger mcontrol.chain match issue #599 #627 (#1083) The variable chain_ok is used to indicate if the current trigger is suppressed by the trigger chain. A true value means the trigger is either un-chained or matches all previous triggers in the chain, and a false value means the trigger is chained and mismatches previous triggers. A false condition of variable chain_ok is missing. The false condition should be mcontrol.chain=1 and not matching; otherwise, the chain_ok=true (including initialization). The bug results in issues #559 and #627. Related issues: - https://github.com/riscv-software-src/riscv-isa-sim/issues/599 - https://github.com/riscv-software-src/riscv-isa-sim/issues/627 This PR fixes the issues #559 and #627. --- riscv/triggers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 4b73715..ef05551 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -176,7 +176,7 @@ match_result_t module_t::memory_access_match(action_t * const action, operation_ return result; } - chain_ok = true; + chain_ok = result != MATCH_NONE || !triggers[i]->chain(); } return MATCH_NONE; } -- cgit v1.1 From ce69fb5db97ecf240336b7826dd9dddeb32e5dca Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 22 Sep 2022 17:34:33 -0700 Subject: Suppress most unused variable warnings --- riscv/triggers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index ef05551..390ebe4 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -62,7 +62,7 @@ bool mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val) noexcep return true; } -reg_t mcontrol_t::tdata2_read(const processor_t * const proc) const noexcept { +reg_t mcontrol_t::tdata2_read(const processor_t UNUSED * const proc) const noexcept { return tdata2; } -- cgit v1.1 From 062ef8868033605b56269b185e3584ef2370ac12 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 13 Oct 2022 13:57:08 -0700 Subject: In triggers, use optional instead of {has_data, data} --- riscv/triggers.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'riscv/triggers.cc') diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 5e2d1f6..90d9d54 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -101,7 +101,7 @@ bool mcontrol_t::simple_match(unsigned xlen, reg_t value) const { assert(0); } -match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operation_t operation, reg_t address, bool has_data, reg_t data) { +match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operation_t operation, reg_t address, std::optional data) { state_t * const state = proc->get_state(); if ((operation == triggers::OPERATION_EXECUTE && !execute_bit) || (operation == triggers::OPERATION_STORE && !store_bit) || @@ -114,9 +114,9 @@ match_result_t mcontrol_t::memory_access_match(processor_t * const proc, operati reg_t value; if (select) { - value = data; - if (!has_data) + if (!data.has_value()) return MATCH_NONE; + value = *data; } else { value = address; } @@ -152,7 +152,7 @@ module_t::~module_t() { } } -match_result_t module_t::memory_access_match(action_t * const action, operation_t operation, reg_t address, bool has_data, reg_t data) +match_result_t module_t::memory_access_match(action_t * const action, operation_t operation, reg_t address, std::optional data) { state_t * const state = proc->get_state(); if (state->debug_mode) @@ -172,7 +172,7 @@ match_result_t module_t::memory_access_match(action_t * const action, operation_ * entire chain did not match. This is allowed by the spec, because the final * trigger in the chain will never get `hit` set unless the entire chain * matches. */ - match_result_t result = triggers[i]->memory_access_match(proc, operation, address, has_data, data); + match_result_t result = triggers[i]->memory_access_match(proc, operation, address, data); if (result != MATCH_NONE && !triggers[i]->chain()) { *action = triggers[i]->action; return result; -- cgit v1.1