diff mbox series

iommu/io-pgtable-arm-v7s: Don't check PHYS_OFFSET if RAMDOMIZE_BASE is enabled

Message ID 1544619737-6313-1-git-send-email-yong.wu@mediatek.com (mailing list archive)
State New, archived
Headers show
Series iommu/io-pgtable-arm-v7s: Don't check PHYS_OFFSET if RAMDOMIZE_BASE is enabled | expand

Commit Message

Yong Wu (吴勇) Dec. 12, 2018, 1:02 p.m. UTC
If CONFIG_RANDOMIZE_BASE is enabled, the "memstart_addr" will be updated
randomly, then the PHYS_OFFSET may be random.

Fixes: 82db33dc5e49 ("iommu/io-pgtable-arm: Check for v7s-incapable
systems")
Reported-by: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
 drivers/iommu/io-pgtable-arm-v7s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Robin Murphy Dec. 12, 2018, 1:39 p.m. UTC | #1
On 12/12/2018 13:02, Yong Wu wrote:
> If CONFIG_RANDOMIZE_BASE is enabled, the "memstart_addr" will be updated
> randomly, then the PHYS_OFFSET may be random.

Oh, I hadn't ever realised that, good catch. However, since 29859aeb8a6e 
I think we should probably just remove this check altogether.

> Fixes: 82db33dc5e49 ("iommu/io-pgtable-arm: Check for v7s-incapable
> systems")

Note that this alone wouldn't be sufficient for stable prior to 4.18, 
since CONFIG_RANDOMIZE_BASE would then allow the original crash to 
happen again.

Robin.

> Reported-by: CK Hu <ck.hu@mediatek.com>
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
>   drivers/iommu/io-pgtable-arm-v7s.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
> index 445c3bd..70941e6 100644
> --- a/drivers/iommu/io-pgtable-arm-v7s.c
> +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> @@ -709,7 +709,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
>   {
>   	struct arm_v7s_io_pgtable *data;
>   
> -#ifdef PHYS_OFFSET
> +#if defined(PHYS_OFFSET) && !defined(CONFIG_RANDOMIZE_BASE)
>   	if (upper_32_bits(PHYS_OFFSET))
>   		return NULL;
>   #endif
>
Yong Wu (吴勇) Dec. 13, 2018, 2:24 a.m. UTC | #2
On Wed, 2018-12-12 at 13:39 +0000, Robin Murphy wrote:
> On 12/12/2018 13:02, Yong Wu wrote:
> > If CONFIG_RANDOMIZE_BASE is enabled, the "memstart_addr" will be updated
> > randomly, then the PHYS_OFFSET may be random.
> 
> Oh, I hadn't ever realised that, good catch. However, since 29859aeb8a6e 
> I think we should probably just remove this check altogether.

Thanks the hint. It looks that I only need revert 82db33dc5e49.

> 
> > Fixes: 82db33dc5e49 ("iommu/io-pgtable-arm: Check for v7s-incapable
> > systems")
> 
> Note that this alone wouldn't be sufficient for stable prior to 4.18, 
> since CONFIG_RANDOMIZE_BASE would then allow the original crash to 
> happen again.

Yes. the problem always exist. Nicolas is fixing this. I will delete the
tag here.

> 
> Robin.
> 
> > Reported-by: CK Hu <ck.hu@mediatek.com>
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> >   drivers/iommu/io-pgtable-arm-v7s.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
> > index 445c3bd..70941e6 100644
> > --- a/drivers/iommu/io-pgtable-arm-v7s.c
> > +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> > @@ -709,7 +709,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
> >   {
> >   	struct arm_v7s_io_pgtable *data;
> >   
> > -#ifdef PHYS_OFFSET
> > +#if defined(PHYS_OFFSET) && !defined(CONFIG_RANDOMIZE_BASE)
> >   	if (upper_32_bits(PHYS_OFFSET))
> >   		return NULL;
> >   #endif
> > 
> 
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
diff mbox series

Patch

diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
index 445c3bd..70941e6 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -709,7 +709,7 @@  static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
 {
 	struct arm_v7s_io_pgtable *data;
 
-#ifdef PHYS_OFFSET
+#if defined(PHYS_OFFSET) && !defined(CONFIG_RANDOMIZE_BASE)
 	if (upper_32_bits(PHYS_OFFSET))
 		return NULL;
 #endif