From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/6] x86/kasan, mm: introduce generic kasan_populate_zero_shadow()
Date: Tue, 11 Aug 2015 16:41:18 +0100 [thread overview]
Message-ID: <20150811154117.GH23307@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <1439259499-13913-3-git-send-email-ryabinin.a.a@gmail.com>
On Tue, Aug 11, 2015 at 05:18:15AM +0300, Andrey Ryabinin wrote:
> --- /dev/null
> +++ b/mm/kasan/kasan_init.c
[...]
> +#if CONFIG_PGTABLE_LEVELS > 3
> +pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss;
> +#endif
> +#if CONFIG_PGTABLE_LEVELS > 2
> +pmd_t kasan_zero_pmd[PTRS_PER_PMD] __page_aligned_bss;
> +#endif
> +pte_t kasan_zero_pte[PTRS_PER_PTE] __page_aligned_bss;
Is there any problem if you don't add the #ifs here? Wouldn't the linker
remove them if they are not used?
Original hunk copied here for easy comparison:
> -static int __init zero_pte_populate(pmd_t *pmd, unsigned long addr,
> - unsigned long end)
> -{
> - pte_t *pte = pte_offset_kernel(pmd, addr);
> -
> - while (addr + PAGE_SIZE <= end) {
> - WARN_ON(!pte_none(*pte));
> - set_pte(pte, __pte(__pa_nodebug(kasan_zero_page)
> - | __PAGE_KERNEL_RO));
> - addr += PAGE_SIZE;
> - pte = pte_offset_kernel(pmd, addr);
> - }
> - return 0;
> -}
[...]
> +static void __init zero_pte_populate(pmd_t *pmd, unsigned long addr,
> + unsigned long end)
> +{
> + pte_t *pte = pte_offset_kernel(pmd, addr);
> + pte_t zero_pte;
> +
> + zero_pte = pfn_pte(PFN_DOWN(__pa(kasan_zero_page)), PAGE_KERNEL);
> + zero_pte = pte_wrprotect(zero_pte);
> +
> + while (addr + PAGE_SIZE <= end) {
> + set_pte_at(&init_mm, addr, pte, zero_pte);
> + addr += PAGE_SIZE;
> + pte = pte_offset_kernel(pmd, addr);
> + }
> +}
I think there are some differences with the original x86 code. The first
one is the use of __pa_nodebug, does it cause any problems if
CONFIG_DEBUG_VIRTUAL is enabled?
The second is the use of a read-only attribute when mapping
kasan_zero_page on x86. Can it cope with a writable mapping?
If there are no issues, it should be documented in the commit log.
--
Catalin
next prev parent reply other threads:[~2015-08-11 15:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 2:18 [PATCH v5 0/6] KASAN for amr64 Andrey Ryabinin
2015-08-11 2:18 ` [PATCH v5 1/6] x86/kasan: define KASAN_SHADOW_OFFSET per architecture Andrey Ryabinin
2015-08-11 2:18 ` [PATCH v5 2/6] x86/kasan, mm: introduce generic kasan_populate_zero_shadow() Andrey Ryabinin
2015-08-11 15:41 ` Catalin Marinas [this message]
2015-08-11 16:25 ` Andrey Ryabinin
2015-08-11 16:40 ` Catalin Marinas
2015-08-12 9:30 ` Andrey Ryabinin
2015-08-12 9:37 ` Will Deacon
2015-08-12 12:19 ` Andrey Ryabinin
2015-08-12 13:41 ` Will Deacon
2015-08-11 16:30 ` Andrey Ryabinin
2015-08-11 2:18 ` [PATCH v5 3/6] arm64: introduce VA_START macro - the first kernel virtual address Andrey Ryabinin
2015-08-11 2:18 ` [PATCH v5 4/6] arm64: move PGD_SIZE definition to pgalloc.h Andrey Ryabinin
2015-08-11 2:18 ` [PATCH v5 5/6] arm64: add KASAN support Andrey Ryabinin
2015-08-11 16:37 ` Catalin Marinas
2015-08-11 2:18 ` [PATCH v5 6/6] ARM64: kasan: print memory assignment Andrey Ryabinin
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=20150811154117.GH23307@e104818-lin.cambridge.arm.com \
--to=catalin.marinas@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).