lib: sbi/hart: preserve csr validation value.
PATCH 1/1 lib: sbi/hart: preserve csr validation value.
Quoted 9 lines
The OpenSBI hart init function
hart_detect_features()try to read important CSRs but reasign the last read value to the variable that initially contains write probe value. So for series of CSRs (like PMPADDRx) the secong CSR probe value will became the initial value of first probing CSR. To avoid of this issue the CSR read value should be saved in different variable. In this configuration the count of PMP will detect rightly if any PMPADDR is hardwired to zero.Signed-off-by Dmitry Dunaev <[email protected]>
only change name from val to oldval?
Regards,
Xiang W
Quoted 41 lines
--- lib/sbi/sbi_hart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/sbi/sbi_hart.c +1
-1@@ -478,7 +478,7 @@ static void hart_detect_features(struct sbi_scratch *scratch) {struct sbi_trap_info trap = {0 };struct hart_features *hfeatures; -unsigned long val; +unsigned long val, oldval;/* Reset hart features */ hfeatures = sbi_scratch_offset_ptr(scratch, hart_features_offset);lib/sbi/sbi_hart.c +2
-2@@ -487,14 +487,14 @@ static void hart_detect_features(struct sbi_scratch *scratch) hfeatures->mhpm_count = 0;#define __check_csr (__csr, __rdonly, __wrval, __field, __skip) \ - val = csr_read_allowed(__csr, (ulong)&trap); \ + oldval = csr_read_allowed(__csr, (ulong)&trap); \ if (!trap.cause) { \ if (__rdonly) { \ (hfeatures->__field)++; \ } else { \ csr_write_allowed(__csr, (ulong)&trap, __wrval);\ if (!trap.cause) { \ - if (csr_swap(__csr, val) == __wrval) \ + if (csr_swap(__csr, oldval) == __wrval) \ (hfeatures->__field)++; \ else \goto __skip; \--
2.25.1---
BW, Dmitry
PATCH 1/1 lib: sbi/hart: preserve csr validation value.
Quoted 10 lines · Xiang W
Quoted 10 lines
The OpenSBI hart init function
hart_detect_features()try to read important CSRs but reasign the last read value to the variable that initially contains write probe value. So for series of CSRs (like PMPADDRx) the secong CSR probe value will became the initial value of first probing CSR. To avoid of this issue the CSR read value should be saved in different variable. In this configuration the count of PMP will detect rightly if any PMPADDR is hardwired to zero.Signed-off-by Dmitry Dunaev <[email protected]>
I think this patch was not correctly sent using "git send-email". I am seeing tabs being converted to spaces. In any case, please use "git format-patch" to generate patches and "git send-email" to send them to opensbi at lists.infradead.org
Otherwise, this patch looks good to me.
I have taken care of the patch formatting issue at the time of merging this patch. Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 53 lines
only change name from val to oldval?
Regards,
Xiang WQuoted 36 lines
--- lib/sbi/sbi_hart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/sbi/sbi_hart.c +1
-1@@ -478,7 +478,7 @@ static void hart_detect_features(struct sbi_scratch *scratch) {struct sbi_trap_info trap = {0 };struct hart_features *hfeatures; -unsigned long val; +unsigned long val, oldval;/* Reset hart features */ hfeatures = sbi_scratch_offset_ptr(scratch, hart_features_offset);lib/sbi/sbi_hart.c +2
-2@@ -487,14 +487,14 @@ static void hart_detect_features(struct sbi_scratch *scratch) hfeatures->mhpm_count = 0;#define __check_csr (__csr, __rdonly, __wrval, __field, __skip) \ - val = csr_read_allowed(__csr, (ulong)&trap); \ + oldval = csr_read_allowed(__csr, (ulong)&trap); \ if (!trap.cause) { \ if (__rdonly) { \ (hfeatures->__field)++; \ } else { \ csr_write_allowed(__csr, (ulong)&trap, __wrval);\ if (!trap.cause) { \ - if (csr_swap(__csr, val) == __wrval) \ + if (csr_swap(__csr, oldval) == __wrval) \ (hfeatures->__field)++; \ else \goto __skip; \Quoted 5 lines
--
2.25.1---
BW, Dmitry--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi