@@ -84,21 +84,18 @@ static inline void sbi_dbtr_disable_shmem(void)
static inline void *hart_shmem_base(void)
{
- struct sbi_dbtr_shmem* shmem;
unsigned long phys_hi, phys_lo;
struct sbi_dbtr_hart_triggers_state *hs = NULL;
hs = dbtr_get_hart_state_ptr(sbi_scratch_thishart_ptr());
-
if (!hs)
return NULL;
- shmem = &hs->shmem;
+ phys_hi = hs->shmem.phys_hi;
+ phys_lo = hs->shmem.phys_lo;
- phys_hi = (shmem->phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR
- ? shmem->phys_hi : 0);
- phys_lo = (shmem->phys_lo == SBI_DBTR_SHMEM_INVALID_ADDR
- ? 0 : shmem->phys_lo);
+ if (phys_hi == SBI_DBTR_SHMEM_INVALID_ADDR && phys_hi == phys_lo)
+ return NULL;
return ((void *)(unsigned long)DBTR_SHMEM_MAKE_PHYS(phys_hi, phys_lo));
}
When only phys_hi is equal to SBI_DBTR_SHMEM_INVALID_ADDR, it may be a legal address. The old code would modify the legal address. Signed-off-by: Xiang W <wxjstz@126.com> --- lib/sbi/sbi_dbtr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)