All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Will Deacon <will@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	sparclinux@vger.kernel.org, kernel-team@android.com
Subject: [RESEND PATCH 1/4] sparc32: mm: Fix argument checking in __srmmu_get_nocache()
Date: Tue, 14 Apr 2020 22:40:08 +0100	[thread overview]
Message-ID: <20200414214011.2699-2-will@kernel.org> (raw)
In-Reply-To: <20200414214011.2699-1-will@kernel.org>

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 b7c94de70cca..cb9ded8a68b7 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);
 
-- 
2.26.0.110.g2183baf09c-goog


WARNING: multiple messages have this Message-ID
From: Will Deacon <will@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Will Deacon <will@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	sparclinux@vger.kernel.org, kernel-team@android.com
Subject: [RESEND PATCH 1/4] sparc32: mm: Fix argument checking in __srmmu_get_nocache()
Date: Tue, 14 Apr 2020 21:40:08 +0000	[thread overview]
Message-ID: <20200414214011.2699-2-will@kernel.org> (raw)
In-Reply-To: <20200414214011.2699-1-will@kernel.org>

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 b7c94de70cca..cb9ded8a68b7 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);
 
-- 
2.26.0.110.g2183baf09c-goog

  reply	other threads:[~2020-04-14 21:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 21:40 [RESEND PATCH 0/4] Rework sparc32 page-table layout Will Deacon
2020-04-14 21:40 ` Will Deacon
2020-04-14 21:40 ` Will Deacon [this message]
2020-04-14 21:40   ` [RESEND PATCH 1/4] sparc32: mm: Fix argument checking in __srmmu_get_nocache() Will Deacon
2020-04-14 21:40 ` [RESEND PATCH 2/4] sparc32: mm: Restructure sparc32 MMU page-table layout Will Deacon
2020-04-14 21:40   ` Will Deacon
2020-04-14 21:40 ` [RESEND PATCH 3/4] sparc32: mm: Change pgtable_t type to pte_t * instead of struct page * Will Deacon
2020-04-14 21:40   ` Will Deacon
2020-04-14 21:40 ` [RESEND PATCH 4/4] sparc32: mm: Reduce allocation size for PMD and PTE tables Will Deacon
2020-04-14 21:40   ` Will Deacon
2020-05-13 22:32 ` [RESEND PATCH 0/4] Rework sparc32 page-table layout David Miller
2020-05-13 22:32   ` David Miller
2020-05-14  7:26   ` Will Deacon
2020-05-14  7:26     ` Will Deacon
2020-05-15  0:41     ` David Miller
2020-05-15  0:41       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200414214011.2699-2-will@kernel.org \
    --to=will@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=sparclinux@vger.kernel.org \
    --subject='Re: [RESEND PATCH 1/4] sparc32: mm: Fix argument checking in __srmmu_get_nocache()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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.