Message ID | 20200324104005.11279-2-will@kernel.org |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | Rework sparc32 page-table layout | expand |
On Tue, Mar 24, 2020 at 3:52 AM Will Deacon <will@kernel.org> wrote: > > The 'size' argument to __srmmu_get_nocache() is a number of bytes not > a shift value, so fix up the sanity checking to treat it properly. > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Will Deacon <will@kernel.org> > --- > arch/sparc/mm/srmmu.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > index f56c3c9a9793..a19863cac0c4 100644 > --- a/arch/sparc/mm/srmmu.c > +++ b/arch/sparc/mm/srmmu.c > @@ -175,18 +175,18 @@ pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address) > */ > static void *__srmmu_get_nocache(int size, int align) > { > - int offset; > + int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT; > unsigned long addr; > > - if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { > + if (size < minsz) { > printk(KERN_ERR "Size 0x%x too small for nocache request\n", > size); > - size = SRMMU_NOCACHE_BITMAP_SHIFT; > + size = minsz; > } > - if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) { > - printk(KERN_ERR "Size 0x%x unaligned int nocache request\n", > + if (size & (minsz - 1)) { > + printk(KERN_ERR "Size 0x%x unaligned in nocache request\n", Was modifying the printk intentional? int vs in ? > size); > - size += SRMMU_NOCACHE_BITMAP_SHIFT - 1; > + size += minsz - 1; > } > BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX); > > -- > 2.20.1 >
On Tue, Mar 24, 2020 at 10:41:52AM -0700, Nick Desaulniers wrote: > On Tue, Mar 24, 2020 at 3:52 AM Will Deacon <will@kernel.org> wrote: > > > > The 'size' argument to __srmmu_get_nocache() is a number of bytes not > > a shift value, so fix up the sanity checking to treat it properly. > > > > Cc: "David S. Miller" <davem@davemloft.net> > > Cc: Peter Zijlstra <peterz@infradead.org> > > Signed-off-by: Will Deacon <will@kernel.org> > > --- > > arch/sparc/mm/srmmu.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > > index f56c3c9a9793..a19863cac0c4 100644 > > --- a/arch/sparc/mm/srmmu.c > > +++ b/arch/sparc/mm/srmmu.c > > @@ -175,18 +175,18 @@ pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address) > > */ > > static void *__srmmu_get_nocache(int size, int align) > > { > > - int offset; > > + int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT; > > unsigned long addr; > > > > - if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { > > + if (size < minsz) { > > printk(KERN_ERR "Size 0x%x too small for nocache request\n", > > size); > > - size = SRMMU_NOCACHE_BITMAP_SHIFT; > > + size = minsz; > > } > > - if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) { > > - printk(KERN_ERR "Size 0x%x unaligned int nocache request\n", > > + if (size & (minsz - 1)) { > > + printk(KERN_ERR "Size 0x%x unaligned in nocache request\n", > > Was modifying the printk intentional? int vs in ? Yes, I think "int" is a typo so I just fixed it up while I was here. Do you prefer the old way? I couldn't parse it at first, but now you mention it I suppose the type of 'size' is int, so *maybe* it makes sense after all! Will
On Tue, Mar 24, 2020 at 10:51 AM Will Deacon <will@kernel.org> wrote: > > On Tue, Mar 24, 2020 at 10:41:52AM -0700, Nick Desaulniers wrote: > > On Tue, Mar 24, 2020 at 3:52 AM Will Deacon <will@kernel.org> wrote: > > > > > > The 'size' argument to __srmmu_get_nocache() is a number of bytes not > > > a shift value, so fix up the sanity checking to treat it properly. > > > > > > Cc: "David S. Miller" <davem@davemloft.net> > > > Cc: Peter Zijlstra <peterz@infradead.org> > > > Signed-off-by: Will Deacon <will@kernel.org> > > > --- > > > arch/sparc/mm/srmmu.c | 12 ++++++------ > > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > > > index f56c3c9a9793..a19863cac0c4 100644 > > > --- a/arch/sparc/mm/srmmu.c > > > +++ b/arch/sparc/mm/srmmu.c > > > @@ -175,18 +175,18 @@ pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address) > > > */ > > > static void *__srmmu_get_nocache(int size, int align) > > > { > > > - int offset; > > > + int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT; > > > unsigned long addr; > > > > > > - if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { > > > + if (size < minsz) { > > > printk(KERN_ERR "Size 0x%x too small for nocache request\n", > > > size); > > > - size = SRMMU_NOCACHE_BITMAP_SHIFT; > > > + size = minsz; > > > } > > > - if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) { > > > - printk(KERN_ERR "Size 0x%x unaligned int nocache request\n", > > > + if (size & (minsz - 1)) { > > > + printk(KERN_ERR "Size 0x%x unaligned in nocache request\n", > > > > Was modifying the printk intentional? int vs in ? > > Yes, I think "int" is a typo so I just fixed it up while I was here. Do you > prefer the old way? I couldn't parse it at first, but now you mention it > I suppose the type of 'size' is int, so *maybe* it makes sense after all! No preference; the code is validating/updating the `size` which as you noted is an `int`.
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index f56c3c9a9793..a19863cac0c4 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -175,18 +175,18 @@ pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address) */ static void *__srmmu_get_nocache(int size, int align) { - int offset; + int offset, minsz = 1 << SRMMU_NOCACHE_BITMAP_SHIFT; unsigned long addr; - if (size < SRMMU_NOCACHE_BITMAP_SHIFT) { + if (size < minsz) { printk(KERN_ERR "Size 0x%x too small for nocache request\n", size); - size = SRMMU_NOCACHE_BITMAP_SHIFT; + size = minsz; } - if (size & (SRMMU_NOCACHE_BITMAP_SHIFT - 1)) { - printk(KERN_ERR "Size 0x%x unaligned int nocache request\n", + if (size & (minsz - 1)) { + printk(KERN_ERR "Size 0x%x unaligned in nocache request\n", size); - size += SRMMU_NOCACHE_BITMAP_SHIFT - 1; + size += minsz - 1; } BUG_ON(align > SRMMU_NOCACHE_ALIGN_MAX);
The 'size' argument to __srmmu_get_nocache() is a number of bytes not a shift value, so fix up the sanity checking to treat it properly. Cc: "David S. Miller" <davem@davemloft.net> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Will Deacon <will@kernel.org> --- arch/sparc/mm/srmmu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)