From: a.ryabinin@samsung.com (Andrey Ryabinin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 5/5] arm64: add KASan support
Date: Thu, 16 Jul 2015 18:30:11 +0300 [thread overview]
Message-ID: <55A7CE03.301@samsung.com> (raw)
In-Reply-To: <20150715163732.GF20186@e104818-lin.cambridge.arm.com>
On 07/15/2015 07:37 PM, Catalin Marinas wrote:
> Ok, so simply taking the call out of the loop won't work unless we
> conditionally define these functions (wouldn't be too bad since we have
> some #if CONFIG_PGTABLE_LEVELS already introduced by this patch but it
> would be nicer without).
>
> Anyway, I think we can keep the current iterations but exit early if
> !pud_none() because it means we already populated it (reworked to match
> other such patterns throughout the kernel with pgd_populate called from
> the pud function; and untested):
>
> void kasan_early_pmd_populate(pud_t *pud, unsigned long addr, unsigned long end)
> {
> pmd_t *pmd;
> unsigned long next;
>
> if (pud_none(*pud))
> pud_populate(&init_mm, pud, kasan_zero_pmd);
>
> pmd = pmd_offset(pud, addr);
> do {
> next = pmd_addr_end(addr, end);
> kasan_early_pte_populate(pmd, addr, next);
> } while (pmd++, addr = next, addr != end && pmd_none(*pmd));
> }
>
> void kasan_early_pud_populate(pgd_t *pgd, unsigned long addr, unsigned long end)
> {
> pud_t *pud;
> unsigned long next;
>
> if (pgd_none(*pgd))
> pgd_populate(&init_mm, pgd, kasan_zero_pud);
>
> pud = pud_offset(pgd, addr);
> do {
> next = pud_addr_end(addr, end);
> kasan_early_pmd_populate(pud, addr, next);
> } while (pud++, addr = next, addr != end && pud_none(*pud));
> }
>
> Given that we check pud_none() after the first iterations, it covers the
> lower levels if needed.
>
I think this may work, if pud_none(*pud) will be replaced with !pud_val(*pud).
We can't use pud_none() because with 2-level page tables it's always false, so
we will never go down to pmd level where swapper_pg_dir populated.
But you gave me another idea how we could use p?d_none() and avoid rewriting table entries:
void kasan_early_pmd_populate(unsigned long start, unsigned long end, pte_t *pte)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
pmd_t *pmd = pmd_offset(pud, addr);
if (!pmd_none(*pmd))
break;
pmd_populate_kernel(&init_mm, pmd, pte);
next = pgd_addr_end(addr, end);
next = pud_addr_end(addr, next)
next = pmd_addr_end(addr, next);
} while(addr = next, addr != end);
}
void kasan_early_pud_populate(unsigned long start, unsigned long end, pmd_t *pmd)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
if (!pud_none(*pud))
break;
pud_populate(&init_mm, pud, pmd);
next = pud_addr_end(addr, pgd_addr_end(addr, end));
} while(addr = next, addr != end);
}
void kasan_early_pgd_populate(...)
{
//something similar to above
....
}
static void __init kasan_map_early_shadow(void)
{
kasan_early_pgd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pud);
kasan_early_pud_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pmd);
kasan_early_pmd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pte);
kasan_early_pte_populate();
}
WARNING: multiple messages have this Message-ID (diff)
From: Andrey Ryabinin <a.ryabinin@samsung.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-mm@kvack.org, Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org,
David Keitel <dkeitel@codeaurora.org>,
Alexander Potapenko <glider@google.com>,
linux-arm-kernel@lists.infradead.org,
Andrew Morton <akpm@linux-foundation.org>,
Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v2 5/5] arm64: add KASan support
Date: Thu, 16 Jul 2015 18:30:11 +0300 [thread overview]
Message-ID: <55A7CE03.301@samsung.com> (raw)
In-Reply-To: <20150715163732.GF20186@e104818-lin.cambridge.arm.com>
On 07/15/2015 07:37 PM, Catalin Marinas wrote:
> Ok, so simply taking the call out of the loop won't work unless we
> conditionally define these functions (wouldn't be too bad since we have
> some #if CONFIG_PGTABLE_LEVELS already introduced by this patch but it
> would be nicer without).
>
> Anyway, I think we can keep the current iterations but exit early if
> !pud_none() because it means we already populated it (reworked to match
> other such patterns throughout the kernel with pgd_populate called from
> the pud function; and untested):
>
> void kasan_early_pmd_populate(pud_t *pud, unsigned long addr, unsigned long end)
> {
> pmd_t *pmd;
> unsigned long next;
>
> if (pud_none(*pud))
> pud_populate(&init_mm, pud, kasan_zero_pmd);
>
> pmd = pmd_offset(pud, addr);
> do {
> next = pmd_addr_end(addr, end);
> kasan_early_pte_populate(pmd, addr, next);
> } while (pmd++, addr = next, addr != end && pmd_none(*pmd));
> }
>
> void kasan_early_pud_populate(pgd_t *pgd, unsigned long addr, unsigned long end)
> {
> pud_t *pud;
> unsigned long next;
>
> if (pgd_none(*pgd))
> pgd_populate(&init_mm, pgd, kasan_zero_pud);
>
> pud = pud_offset(pgd, addr);
> do {
> next = pud_addr_end(addr, end);
> kasan_early_pmd_populate(pud, addr, next);
> } while (pud++, addr = next, addr != end && pud_none(*pud));
> }
>
> Given that we check pud_none() after the first iterations, it covers the
> lower levels if needed.
>
I think this may work, if pud_none(*pud) will be replaced with !pud_val(*pud).
We can't use pud_none() because with 2-level page tables it's always false, so
we will never go down to pmd level where swapper_pg_dir populated.
But you gave me another idea how we could use p?d_none() and avoid rewriting table entries:
void kasan_early_pmd_populate(unsigned long start, unsigned long end, pte_t *pte)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
pmd_t *pmd = pmd_offset(pud, addr);
if (!pmd_none(*pmd))
break;
pmd_populate_kernel(&init_mm, pmd, pte);
next = pgd_addr_end(addr, end);
next = pud_addr_end(addr, next)
next = pmd_addr_end(addr, next);
} while(addr = next, addr != end);
}
void kasan_early_pud_populate(unsigned long start, unsigned long end, pmd_t *pmd)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
if (!pud_none(*pud))
break;
pud_populate(&init_mm, pud, pmd);
next = pud_addr_end(addr, pgd_addr_end(addr, end));
} while(addr = next, addr != end);
}
void kasan_early_pgd_populate(...)
{
//something similar to above
....
}
static void __init kasan_map_early_shadow(void)
{
kasan_early_pgd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pud);
kasan_early_pud_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pmd);
kasan_early_pmd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pte);
kasan_early_pte_populate();
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Andrey Ryabinin <a.ryabinin@samsung.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-mm@kvack.org, Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org,
David Keitel <dkeitel@codeaurora.org>,
Alexander Potapenko <glider@google.com>,
linux-arm-kernel@lists.infradead.org,
Andrew Morton <akpm@linux-foundation.org>,
Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v2 5/5] arm64: add KASan support
Date: Thu, 16 Jul 2015 18:30:11 +0300 [thread overview]
Message-ID: <55A7CE03.301@samsung.com> (raw)
In-Reply-To: <20150715163732.GF20186@e104818-lin.cambridge.arm.com>
On 07/15/2015 07:37 PM, Catalin Marinas wrote:
> Ok, so simply taking the call out of the loop won't work unless we
> conditionally define these functions (wouldn't be too bad since we have
> some #if CONFIG_PGTABLE_LEVELS already introduced by this patch but it
> would be nicer without).
>
> Anyway, I think we can keep the current iterations but exit early if
> !pud_none() because it means we already populated it (reworked to match
> other such patterns throughout the kernel with pgd_populate called from
> the pud function; and untested):
>
> void kasan_early_pmd_populate(pud_t *pud, unsigned long addr, unsigned long end)
> {
> pmd_t *pmd;
> unsigned long next;
>
> if (pud_none(*pud))
> pud_populate(&init_mm, pud, kasan_zero_pmd);
>
> pmd = pmd_offset(pud, addr);
> do {
> next = pmd_addr_end(addr, end);
> kasan_early_pte_populate(pmd, addr, next);
> } while (pmd++, addr = next, addr != end && pmd_none(*pmd));
> }
>
> void kasan_early_pud_populate(pgd_t *pgd, unsigned long addr, unsigned long end)
> {
> pud_t *pud;
> unsigned long next;
>
> if (pgd_none(*pgd))
> pgd_populate(&init_mm, pgd, kasan_zero_pud);
>
> pud = pud_offset(pgd, addr);
> do {
> next = pud_addr_end(addr, end);
> kasan_early_pmd_populate(pud, addr, next);
> } while (pud++, addr = next, addr != end && pud_none(*pud));
> }
>
> Given that we check pud_none() after the first iterations, it covers the
> lower levels if needed.
>
I think this may work, if pud_none(*pud) will be replaced with !pud_val(*pud).
We can't use pud_none() because with 2-level page tables it's always false, so
we will never go down to pmd level where swapper_pg_dir populated.
But you gave me another idea how we could use p?d_none() and avoid rewriting table entries:
void kasan_early_pmd_populate(unsigned long start, unsigned long end, pte_t *pte)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
pmd_t *pmd = pmd_offset(pud, addr);
if (!pmd_none(*pmd))
break;
pmd_populate_kernel(&init_mm, pmd, pte);
next = pgd_addr_end(addr, end);
next = pud_addr_end(addr, next)
next = pmd_addr_end(addr, next);
} while(addr = next, addr != end);
}
void kasan_early_pud_populate(unsigned long start, unsigned long end, pmd_t *pmd)
{
unsigned long addr = start;
long next;
do {
pgd_t *pgd = pgd_offset_k(addr);
pud_t *pud = pud_offset(pgd, addr);
if (!pud_none(*pud))
break;
pud_populate(&init_mm, pud, pmd);
next = pud_addr_end(addr, pgd_addr_end(addr, end));
} while(addr = next, addr != end);
}
void kasan_early_pgd_populate(...)
{
//something similar to above
....
}
static void __init kasan_map_early_shadow(void)
{
kasan_early_pgd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pud);
kasan_early_pud_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pmd);
kasan_early_pmd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, kasan_zero_pte);
kasan_early_pte_populate();
}
next prev parent reply other threads:[~2015-07-16 15:30 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 13:58 [PATCH v2 0/5] KASan for arm64 Andrey Ryabinin
2015-05-15 13:58 ` Andrey Ryabinin
2015-05-15 13:58 ` Andrey Ryabinin
2015-05-15 13:59 ` [PATCH v2 1/5] kasan, x86: move KASAN_SHADOW_OFFSET to the arch Kconfig Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-16 11:27 ` Paul Bolle
2015-05-16 11:27 ` Paul Bolle
2015-05-16 11:27 ` Paul Bolle
2015-05-18 7:43 ` Andrey Ryabinin
2015-05-18 7:43 ` Andrey Ryabinin
2015-05-18 7:43 ` Andrey Ryabinin
2015-05-18 8:34 ` Paul Bolle
2015-05-18 8:34 ` Paul Bolle
2015-05-18 8:34 ` Paul Bolle
2015-05-15 13:59 ` [PATCH v2 2/5] x86: kasan: fix types in kasan page tables declarations Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` [PATCH v2 3/5] x86: kasan: generalize populate_zero_shadow() code Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` [PATCH v2 4/5] kasan, x86: move populate_zero_shadow() out of arch directory Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` [PATCH v2 5/5] arm64: add KASan support Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-15 13:59 ` Andrey Ryabinin
2015-05-26 13:35 ` Linus Walleij
2015-05-26 13:35 ` Linus Walleij
2015-05-26 13:35 ` Linus Walleij
2015-05-26 14:12 ` Andrey Ryabinin
2015-05-26 14:12 ` Andrey Ryabinin
2015-05-26 14:12 ` Andrey Ryabinin
2015-05-26 14:22 ` Andrey Ryabinin
2015-05-26 14:22 ` Andrey Ryabinin
2015-05-26 14:22 ` Andrey Ryabinin
2015-05-26 20:28 ` Linus Walleij
2015-05-26 20:28 ` Linus Walleij
2015-05-26 20:28 ` Linus Walleij
2015-05-27 12:40 ` Linus Walleij
2015-05-27 12:40 ` Linus Walleij
2015-05-27 12:40 ` Linus Walleij
2015-06-11 13:39 ` Linus Walleij
2015-06-11 13:39 ` Linus Walleij
2015-06-11 13:39 ` Linus Walleij
2015-06-12 18:14 ` Andrey Ryabinin
2015-06-12 18:14 ` Andrey Ryabinin
2015-06-12 18:14 ` Andrey Ryabinin
2015-06-13 15:25 ` Linus Walleij
2015-06-13 15:25 ` Linus Walleij
2015-06-13 15:25 ` Linus Walleij
2015-06-17 21:32 ` Andrey Ryabinin
2015-06-17 21:32 ` Andrey Ryabinin
2015-06-17 21:32 ` Andrey Ryabinin
2015-07-21 10:36 ` Linus Walleij
2015-07-21 10:36 ` Linus Walleij
2015-07-21 10:36 ` Linus Walleij
2015-07-21 14:27 ` Andrey Ryabinin
2015-07-21 14:27 ` Andrey Ryabinin
2015-07-21 14:27 ` Andrey Ryabinin
2015-07-21 21:27 ` Linus Walleij
2015-07-21 21:27 ` Linus Walleij
2015-07-21 21:27 ` Linus Walleij
2015-07-22 17:54 ` Andrey Ryabinin
2015-07-22 17:54 ` Andrey Ryabinin
2015-07-22 17:54 ` Andrey Ryabinin
2015-08-19 12:14 ` Linus Walleij
2015-08-19 12:14 ` Linus Walleij
2015-08-19 12:14 ` Linus Walleij
2015-08-19 14:51 ` Andrey Ryabinin
2015-08-19 14:51 ` Andrey Ryabinin
2015-08-19 14:51 ` Andrey Ryabinin
2015-08-24 13:02 ` Linus Walleij
2015-08-24 13:02 ` Linus Walleij
2015-08-24 13:02 ` Linus Walleij
2015-08-24 13:15 ` Russell King - ARM Linux
2015-08-24 13:15 ` Russell King - ARM Linux
2015-08-24 13:15 ` Russell King - ARM Linux
2015-08-24 13:45 ` Linus Walleij
2015-08-24 13:45 ` Linus Walleij
2015-08-24 13:45 ` Linus Walleij
2015-08-24 14:15 ` Andrey Ryabinin
2015-08-24 14:15 ` Andrey Ryabinin
2015-08-24 14:15 ` Andrey Ryabinin
2015-08-24 15:44 ` Vladimir Murzin
2015-08-24 15:44 ` Vladimir Murzin
2015-08-24 15:44 ` Vladimir Murzin
2015-08-24 16:00 ` Andrey Ryabinin
2015-08-24 16:00 ` Andrey Ryabinin
2015-08-24 16:00 ` Andrey Ryabinin
2015-08-24 16:16 ` Vladimir Murzin
2015-08-24 16:16 ` Vladimir Murzin
2015-08-24 16:16 ` Vladimir Murzin
2015-08-24 16:18 ` Andrey Ryabinin
2015-08-24 16:18 ` Andrey Ryabinin
2015-08-24 16:18 ` Andrey Ryabinin
2015-08-24 17:47 ` Russell King - ARM Linux
2015-08-24 17:47 ` Russell King - ARM Linux
2015-08-24 17:47 ` Russell King - ARM Linux
2015-08-25 9:15 ` Will Deacon
2015-08-25 9:15 ` Will Deacon
2015-08-25 9:15 ` Will Deacon
2015-07-08 15:48 ` Catalin Marinas
2015-07-08 15:48 ` Catalin Marinas
2015-07-08 15:48 ` Catalin Marinas
2015-07-10 17:11 ` Andrey Ryabinin
2015-07-10 17:11 ` Andrey Ryabinin
2015-07-10 17:11 ` Andrey Ryabinin
2015-07-14 15:04 ` Catalin Marinas
2015-07-14 15:04 ` Catalin Marinas
2015-07-14 15:04 ` Catalin Marinas
2015-07-15 8:55 ` Andrey Ryabinin
2015-07-15 8:55 ` Andrey Ryabinin
2015-07-15 8:55 ` Andrey Ryabinin
2015-07-15 16:37 ` Catalin Marinas
2015-07-15 16:37 ` Catalin Marinas
2015-07-15 16:37 ` Catalin Marinas
2015-07-16 15:30 ` Andrey Ryabinin [this message]
2015-07-16 15:30 ` Andrey Ryabinin
2015-07-16 15:30 ` Andrey Ryabinin
2015-07-16 16:03 ` Catalin Marinas
2015-07-16 16:03 ` Catalin Marinas
2015-07-16 16:03 ` Catalin Marinas
2015-07-17 13:13 ` Andrey Ryabinin
2015-07-17 13:13 ` Andrey Ryabinin
2015-07-17 13:13 ` Andrey Ryabinin
2015-07-18 2:44 ` Patrick Daly
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=55A7CE03.301@samsung.com \
--to=a.ryabinin@samsung.com \
--cc=linux-arm-kernel@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 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.