diff mbox series

[2/3] lib: sbi: verbose sbi_domain_root_add_memregion

Message ID 20220211111155.16121-3-nikita.shubin@maquefel.me
State Accepted
Headers show
Series sbi_domain fixes | expand

Commit Message

Nikita Shubin Feb. 11, 2022, 11:11 a.m. UTC
From: Nikita Shubin <n.shubin@yadro.com>

Be more verbose on region confict, print addresses in conflict.

Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
---
 include/sbi/sbi_domain.h | 4 +++-
 lib/sbi/sbi_domain.c     | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Xiang W Feb. 14, 2022, 4:48 p.m. UTC | #1
在 2022-02-11星期五的 14:11 +0300,Nikita Shubin写道:
> From: Nikita Shubin <n.shubin@yadro.com>
> 
> Be more verbose on region confict, print addresses in conflict.
> 
> Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
Look good to me.

Reviewed-by: Xiang W <wxjstz@126.com>
> ---
>  include/sbi/sbi_domain.h | 4 +++-
>  lib/sbi/sbi_domain.c     | 8 ++++++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h
> index 15e3a53..b90f59c 100644
> --- a/include/sbi/sbi_domain.h
> +++ b/include/sbi/sbi_domain.h
> @@ -174,7 +174,9 @@ int sbi_domain_register(struct sbi_domain *dom,
>   * Add a memory region to the root domain
>   * @param reg pointer to the memory region to be added
>   *
> - * @return 0 on success and negative error code on failure
> + * @return 0 on success
> + * @return SBI_EALREADY if memory region conflicts with existing
> + * @return SBI_EINVAL otherwise
>   */
>  int sbi_domain_root_add_memregion(const struct sbi_domain_memregion
> *reg);
>  
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index a1ac1bb..4e4c1e1 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -471,8 +471,12 @@ int sbi_domain_root_add_memregion(const struct
> sbi_domain_memregion *reg)
>  
>         /* Check for conflicts */
>         sbi_domain_for_each_memregion(&root, nreg) {
> -               if (is_region_conflict(reg, nreg))
> -                       return SBI_EINVAL;
> +               if (is_region_conflict(reg, nreg)) {
> +                       sbi_printf("%s: is_region_conflict check
> failed"
> +                       " 0x%lx conflicts existing 0x%lx\n", __func__,
> +                                  reg->base, nreg->base);
> +                       return SBI_EALREADY;
> +               }
>         }
>  
>         /* Append the memregion to root memregions */
> -- 
> 2.31.1
> 
>
Anup Patel Feb. 15, 2022, 4:12 p.m. UTC | #2
On Fri, Feb 11, 2022 at 4:42 PM Nikita Shubin <nikita.shubin@maquefel.me> wrote:
>
> From: Nikita Shubin <n.shubin@yadro.com>
>
> Be more verbose on region confict, print addresses in conflict.
>
> Signed-off-by: Nikita Shubin <n.shubin@yadro.com>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  include/sbi/sbi_domain.h | 4 +++-
>  lib/sbi/sbi_domain.c     | 8 ++++++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h
> index 15e3a53..b90f59c 100644
> --- a/include/sbi/sbi_domain.h
> +++ b/include/sbi/sbi_domain.h
> @@ -174,7 +174,9 @@ int sbi_domain_register(struct sbi_domain *dom,
>   * Add a memory region to the root domain
>   * @param reg pointer to the memory region to be added
>   *
> - * @return 0 on success and negative error code on failure
> + * @return 0 on success
> + * @return SBI_EALREADY if memory region conflicts with existing
> + * @return SBI_EINVAL otherwise
>   */
>  int sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg);
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
> index a1ac1bb..4e4c1e1 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -471,8 +471,12 @@ int sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg)
>
>         /* Check for conflicts */
>         sbi_domain_for_each_memregion(&root, nreg) {
> -               if (is_region_conflict(reg, nreg))
> -                       return SBI_EINVAL;
> +               if (is_region_conflict(reg, nreg)) {
> +                       sbi_printf("%s: is_region_conflict check failed"
> +                       " 0x%lx conflicts existing 0x%lx\n", __func__,
> +                                  reg->base, nreg->base);
> +                       return SBI_EALREADY;
> +               }
>         }
>
>         /* Append the memregion to root memregions */
> --
> 2.31.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
diff mbox series

Patch

diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h
index 15e3a53..b90f59c 100644
--- a/include/sbi/sbi_domain.h
+++ b/include/sbi/sbi_domain.h
@@ -174,7 +174,9 @@  int sbi_domain_register(struct sbi_domain *dom,
  * Add a memory region to the root domain
  * @param reg pointer to the memory region to be added
  *
- * @return 0 on success and negative error code on failure
+ * @return 0 on success
+ * @return SBI_EALREADY if memory region conflicts with existing
+ * @return SBI_EINVAL otherwise
  */
 int sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg);
 
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index a1ac1bb..4e4c1e1 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -471,8 +471,12 @@  int sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg)
 
 	/* Check for conflicts */
 	sbi_domain_for_each_memregion(&root, nreg) {
-		if (is_region_conflict(reg, nreg))
-			return SBI_EINVAL;
+		if (is_region_conflict(reg, nreg)) {
+			sbi_printf("%s: is_region_conflict check failed"
+			" 0x%lx conflicts existing 0x%lx\n", __func__,
+				   reg->base, nreg->base);
+			return SBI_EALREADY;
+		}
 	}
 
 	/* Append the memregion to root memregions */