Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 May 2022 11:14:48 -0700
From:      Kyle Evans <kevans@freebsd.org>
To:        Ruslan Bukin <br@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org
Subject:   Re: git: 0c0bfa0f6f2f - main - Fix ofw_bus_iommu_map() since there is no limit on amount of maps described in "iommu-map" DTS property.
Message-ID:  <CACNAnaHub84FjFE4yaWMgYi9Gtj6v-5MrMHMc7=%2B%2BTqSH=H1Zw@mail.gmail.com>
In-Reply-To: <202205061710.246HAYCB067849@gitrepo.freebsd.org>
References:  <202205061710.246HAYCB067849@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 6, 2022 at 10:10 AM Ruslan Bukin <br@freebsd.org> wrote:
>
> The branch main has been updated by br:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=0c0bfa0f6f2f3415f139aa65019f43f498883a89
>
> commit 0c0bfa0f6f2f3415f139aa65019f43f498883a89
> Author:     Ruslan Bukin <br@FreeBSD.org>
> AuthorDate: 2022-05-06 17:03:52 +0000
> Commit:     Ruslan Bukin <br@FreeBSD.org>
> CommitDate: 2022-05-06 17:09:42 +0000
>
>     Fix ofw_bus_iommu_map() since there is no limit on amount of maps
>     described in "iommu-map" DTS property.
>
>     Pointed out by: rpokala
>     Sponsored by:   UKRI
> ---
>  sys/dev/ofw/ofw_bus_subr.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
> index 408d554b3c7f..404bed3c73fa 100644
> --- a/sys/dev/ofw/ofw_bus_subr.c
> +++ b/sys/dev/ofw/ofw_bus_subr.c
> @@ -495,19 +495,15 @@ int
>  ofw_bus_iommu_map(phandle_t node, uint16_t pci_rid, phandle_t *iommu_parent,
>      uint32_t *iommu_rid)
>  {
> -       pcell_t mask, iommu_base, rid_base, rid_length;
> -       uint32_t masked_rid;
> -       pcell_t map[4];
> +       pcell_t *map, mask, iommu_base, rid_base, rid_length;
>         ssize_t len;
> +       uint32_t masked_rid;
>         int err, i;
>
> -       len = OF_getproplen(node, "iommu-map");
> +       len = OF_getencprop_alloc_multi(node, "iommu-map", sizeof(*map),
> +           (void **)&map);
>         if (len <= 0)
>                 return (ENOENT);
> -        if (len > sizeof(map))
> -                return (ENOMEM);
> -
> -       len = OF_getencprop(node, "iommu-map", map, 16);
>
>         err = ENOENT;
>         mask = 0xffffffff;

The loop condition under this that I pointed out in response to
rpokala is still wrong, AFAICT. `i` isn't directly comparable to `len` and we
should fix that in both msimap and iommu_map.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaHub84FjFE4yaWMgYi9Gtj6v-5MrMHMc7=%2B%2BTqSH=H1Zw>