[PATCH v3 4/6] lib: sbi: Fixed memory permission check in sbi_dbtr_setup_shmem
Xiang W
wxjstz at 126.com
Fri May 3 06:53:36 PDT 2024
The previous code detected shmem_phys_hi and shmem_phys_lo as two
addresses. fix this bug
Signed-off-by: Xiang W <wxjstz at 126.com>
Reviewed-by: Himanshu Chauhan <hchauhan at ventanamicro.com>
---
lib/sbi/sbi_dbtr.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c
index 94fd049..a95f087 100644
--- a/lib/sbi/sbi_dbtr.c
+++ b/lib/sbi/sbi_dbtr.c
@@ -293,17 +293,11 @@ int sbi_dbtr_setup_shmem(const struct sbi_domain *dom, unsigned long smode,
if (shmem_phys_lo & SBI_DBTR_SHMEM_ALIGN_MASK)
return SBI_ERR_INVALID_PARAM;
- if (dom && !sbi_domain_check_addr(dom, shmem_phys_lo, smode,
- SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))
+ if (dom && !sbi_domain_check_addr(dom,
+ DBTR_SHMEM_MAKE_PHYS(shmem_phys_hi, shmem_phys_lo), smode,
+ SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))
return SBI_ERR_INVALID_ADDRESS;
- if (shmem_phys_hi != SBI_DBTR_SHMEM_INVALID_ADDR) {
- if (dom &&
- !sbi_domain_check_addr(dom, shmem_phys_hi, smode,
- SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))
- return SBI_ERR_INVALID_ADDRESS;
- }
-
hart_state = dbtr_thishart_state_ptr();
if (!hart_state)
return SBI_ERR_FAILED;
--
2.43.0
More information about the opensbi
mailing list