mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/2] KASan: fix handling of devices with MMIO above SDRAM memory region
Date: Mon, 12 Dec 2022 17:39:07 +0100	[thread overview]
Message-ID: <20221212163907.2356192-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221212163907.2356192-1-a.fatoum@pengutronix.de>

check_memory_region_inline will discard KASan reports before start of
RAM as false positives. This is sufficient for i.MX SoCs where the RAM
starts after all device MMIO regions. On the AT91, the EBI memory
controller's memory region follows the SDRAM memory region. This
results in a KASan warning the first time NAND is accessed.

Record the end of the shadowed SDRAM area to fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/kasan/generic.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/kasan/generic.c b/lib/kasan/generic.c
index b33a6c1a6c0c..1eccacf2b4b0 100644
--- a/lib/kasan/generic.c
+++ b/lib/kasan/generic.c
@@ -22,6 +22,7 @@
 
 unsigned long kasan_shadow_start;
 unsigned long kasan_shadow_base;
+unsigned long kasan_shadowed_end;
 
 /*
  * All functions below always inlined so compiler could
@@ -160,6 +161,9 @@ static __always_inline bool check_memory_region_inline(unsigned long addr,
 	if (addr < kasan_shadow_start)
 		return true;
 
+	if (addr > kasan_shadowed_end)
+		return true;
+
 	if (unlikely(size == 0))
 		return true;
 
@@ -180,6 +184,7 @@ void kasan_init(unsigned long membase, unsigned long memsize,
 {
 	kasan_shadow_start = membase;
 	kasan_shadow_base = shadow_base;
+	kasan_shadowed_end = membase + memsize - 1;
 
 	kasan_unpoison_shadow((void *)membase, memsize);
 	kasan_initialized = true;
-- 
2.30.2




  reply	other threads:[~2022-12-12 16:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 16:39 [PATCH master 1/2] KASan: test_kasan: silence warning with newer GCC Ahmad Fatoum
2022-12-12 16:39 ` Ahmad Fatoum [this message]
2022-12-13  8:37 ` Sascha Hauer

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=20221212163907.2356192-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox