diff options
| author | Nikita Shubin <[email protected]> | 2021-12-08 14:16:54 +0300 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2021-12-11 16:26:15 +0530 |
| commit | 460041c816f1b174899a3bf1147ce5d2e95731f4 (patch) | |
| tree | 4d731c5d72db0eca6b4062439bdfd21373fac7f0 | |
| parent | 66fbcc03df0444bb6ce2286d3605cbc13b361cb1 (diff) | |
lib: pmu: check SSCOF before masking
We should check if SSCOF extension is present,
before applying inhibit mask and clearing overflow,
otherwise undesirable value can be written
in MHPMEVENT_N CSR.
Signed-off-by: Nikita Shubin <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Reviewed-by: Xiang W <[email protected]>
| -rw-r--r-- | lib/sbi/sbi_pmu.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c index 10668a35..5b845f83 100644 --- a/lib/sbi/sbi_pmu.c +++ b/lib/sbi/sbi_pmu.c @@ -467,7 +467,8 @@ static int pmu_update_hw_mhpmevent(struct sbi_pmu_hw_event *hw_evt, int ctr_idx, return SBI_EFAIL; /* Always clear the OVF bit and inhibit countin of events in M-mode */ - mhpmevent_val = (mhpmevent_val & ~MHPMEVENT_SSCOF_MASK) | MHPMEVENT_MINH; + if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF)) + mhpmevent_val = (mhpmevent_val & ~MHPMEVENT_SSCOF_MASK) | MHPMEVENT_MINH; /* Update the inhibit flags based on inhibit flags received from supervisor */ pmu_update_inhibit_flags(flags, &mhpmevent_val); |
