* [bug report] iommu: rockchip: Add support for iommu v2
@ 2021-06-18 9:15 Dan Carpenter
2021-06-18 10:01 ` Benjamin Gaignard
2021-06-18 10:26 ` Robin Murphy
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-06-18 9:15 UTC (permalink / raw)
To: benjamin.gaignard; +Cc: linux-rockchip
Hello Benjamin Gaignard,
The patch c55356c534aa: "iommu: rockchip: Add support for iommu v2"
from Jun 4, 2021, leads to the following static checker warning:
drivers/iommu/rockchip-iommu.c:552 rk_dte_addr_phys_v2()
warn: potential shift truncation. '0xff00000000 (0,4294967296-1095216660480) << 28'
drivers/iommu/rockchip-iommu.c
544 }
545
546 #define DT_HI_MASK GENMASK_ULL(39, 32)
^^^^^^^^^^^^^^^^^^^
547 #define DT_SHIFT 28
548
549 static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
550 {
551 return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
552 ((addr & DT_HI_MASK) << DT_SHIFT);
^^^^^^^^^^^^^^^^^
Is addr supposed to be a u64?
553 }
regards,
dan carpenter
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] iommu: rockchip: Add support for iommu v2
2021-06-18 9:15 [bug report] iommu: rockchip: Add support for iommu v2 Dan Carpenter
@ 2021-06-18 10:01 ` Benjamin Gaignard
2021-06-18 10:26 ` Robin Murphy
1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Gaignard @ 2021-06-18 10:01 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-rockchip
Le 18/06/2021 à 11:15, Dan Carpenter a écrit :
> Hello Benjamin Gaignard,
>
> The patch c55356c534aa: "iommu: rockchip: Add support for iommu v2"
> from Jun 4, 2021, leads to the following static checker warning:
>
> drivers/iommu/rockchip-iommu.c:552 rk_dte_addr_phys_v2()
> warn: potential shift truncation. '0xff00000000 (0,4294967296-1095216660480) << 28'
>
> drivers/iommu/rockchip-iommu.c
> 544 }
> 545
> 546 #define DT_HI_MASK GENMASK_ULL(39, 32)
> ^^^^^^^^^^^^^^^^^^^
>
> 547 #define DT_SHIFT 28
> 548
> 549 static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
> 550 {
> 551 return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
> 552 ((addr & DT_HI_MASK) << DT_SHIFT);
> ^^^^^^^^^^^^^^^^^
> Is addr supposed to be a u64?
The error is to use DT_HI_MASK here.
It should be:
#define DTE_BASE_HI_MASK GENMASK(11, 4)
static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
{
return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
((addr & DTE_BASE_HI_MASK) << DT_SHIFT);
}
I will send a patch.
Thanks for the finding.
Regards,
Benjamin
>
> 553 }
>
> regards,
> dan carpenter
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] iommu: rockchip: Add support for iommu v2
2021-06-18 9:15 [bug report] iommu: rockchip: Add support for iommu v2 Dan Carpenter
2021-06-18 10:01 ` Benjamin Gaignard
@ 2021-06-18 10:26 ` Robin Murphy
1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2021-06-18 10:26 UTC (permalink / raw)
To: Dan Carpenter, benjamin.gaignard; +Cc: linux-rockchip
On 2021-06-18 10:15, Dan Carpenter wrote:
> Hello Benjamin Gaignard,
>
> The patch c55356c534aa: "iommu: rockchip: Add support for iommu v2"
> from Jun 4, 2021, leads to the following static checker warning:
>
> drivers/iommu/rockchip-iommu.c:552 rk_dte_addr_phys_v2()
> warn: potential shift truncation. '0xff00000000 (0,4294967296-1095216660480) << 28'
>
> drivers/iommu/rockchip-iommu.c
> 544 }
> 545
> 546 #define DT_HI_MASK GENMASK_ULL(39, 32)
> ^^^^^^^^^^^^^^^^^^^
>
> 547 #define DT_SHIFT 28
> 548
> 549 static inline phys_addr_t rk_dte_addr_phys_v2(u32 addr)
> 550 {
> 551 return (phys_addr_t)(addr & RK_DTE_PT_ADDRESS_MASK) |
> 552 ((addr & DT_HI_MASK) << DT_SHIFT);
> ^^^^^^^^^^^^^^^^^
> Is addr supposed to be a u64?
Hmm, the cast is in the wrong place to be useful, but the shifting and
masking to unpack the high address bits also looks backwards anyway. I
think the whole expression should probably be something more like:
(((phys_addr_t)addr << DT_SHIFT) & DT_HI_MASK) |
(addr & RK_DTE_PT_ADDRESS_MASK);
Robin.
>
> 553 }
>
> regards,
> dan carpenter
>
> _______________________________________________
> Linux-rockchip mailing list
> Linux-rockchip@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-18 10:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 9:15 [bug report] iommu: rockchip: Add support for iommu v2 Dan Carpenter
2021-06-18 10:01 ` Benjamin Gaignard
2021-06-18 10:26 ` Robin Murphy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.