linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens.net>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH v7 07/11] powerpc/32: prepare shadow area for KASAN
Date: Tue, 26 Feb 2019 16:12:29 +1100	[thread overview]
Message-ID: <87a7ij2kw2.fsf@dja-thinkpad.axtens.net> (raw)
In-Reply-To: <bada5c0051f749565d27da9527ce933aa205bf86.1551098214.git.christophe.leroy@c-s.fr>

Christophe Leroy <christophe.leroy@c-s.fr> writes:

> This patch prepares a shadow area for KASAN.
>
> The shadow area will be at the top of the kernel virtual
> memory space above the fixmap area and will occupy one
> eighth of the total kernel virtual memory space.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/Kconfig              |  5 +++++
>  arch/powerpc/include/asm/fixmap.h |  5 +++++
>  arch/powerpc/include/asm/kasan.h  | 17 +++++++++++++++++
>  arch/powerpc/mm/mem.c             |  4 ++++
>  arch/powerpc/mm/ptdump/ptdump.c   |  8 ++++++++
>  5 files changed, 39 insertions(+)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 652c25260838..f446e016f4a1 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -382,6 +382,11 @@ config PGTABLE_LEVELS
>  	default 3 if PPC_64K_PAGES && !PPC_BOOK3S_64
>  	default 4
>  
> +config KASAN_SHADOW_OFFSET
> +	hex
> +	depends on KASAN
> +	default 0xe0000000
> +

Should this live in Kconfig.debug?

Regards,
Daniel

>  source "arch/powerpc/sysdev/Kconfig"
>  source "arch/powerpc/platforms/Kconfig"
>  
> diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
> index b9fbed84ddca..51a1a309c919 100644
> --- a/arch/powerpc/include/asm/fixmap.h
> +++ b/arch/powerpc/include/asm/fixmap.h
> @@ -22,7 +22,12 @@
>  #include <asm/kmap_types.h>
>  #endif
>  
> +#ifdef CONFIG_KASAN
> +#include <asm/kasan.h>
> +#define FIXADDR_TOP	KASAN_SHADOW_START
> +#else
>  #define FIXADDR_TOP	((unsigned long)(-PAGE_SIZE))
> +#endif
>  
>  /*
>   * Here we define all the compile-time 'special' virtual
> diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h
> index 2efd0e42cfc9..b554d3bd3e2c 100644
> --- a/arch/powerpc/include/asm/kasan.h
> +++ b/arch/powerpc/include/asm/kasan.h
> @@ -12,4 +12,21 @@
>  #define EXPORT_SYMBOL_KASAN(fn)	EXPORT_SYMBOL(fn)
>  #endif
>  
> +#ifndef __ASSEMBLY__
> +
> +#include <asm/page.h>
> +#include <asm/pgtable-types.h>
> +
> +#define KASAN_SHADOW_SCALE_SHIFT	3
> +
> +#define KASAN_SHADOW_OFFSET	ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET)
> +
> +#define KASAN_SHADOW_START	(KASAN_SHADOW_OFFSET + \
> +				 (PAGE_OFFSET >> KASAN_SHADOW_SCALE_SHIFT))
> +
> +#define KASAN_SHADOW_END	0UL
> +
> +#define KASAN_SHADOW_SIZE	(KASAN_SHADOW_END - KASAN_SHADOW_START)
> +
> +#endif /* __ASSEMBLY */
>  #endif
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index f6787f90e158..4e7fa4eb2dd3 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -309,6 +309,10 @@ void __init mem_init(void)
>  	mem_init_print_info(NULL);
>  #ifdef CONFIG_PPC32
>  	pr_info("Kernel virtual memory layout:\n");
> +#ifdef CONFIG_KASAN
> +	pr_info("  * 0x%08lx..0x%08lx  : kasan shadow mem\n",
> +		KASAN_SHADOW_START, KASAN_SHADOW_END);
> +#endif
>  	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
>  #ifdef CONFIG_HIGHMEM
>  	pr_info("  * 0x%08lx..0x%08lx  : highmem PTEs\n",
> diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c
> index 37138428ab55..812ed680024f 100644
> --- a/arch/powerpc/mm/ptdump/ptdump.c
> +++ b/arch/powerpc/mm/ptdump/ptdump.c
> @@ -101,6 +101,10 @@ static struct addr_marker address_markers[] = {
>  	{ 0,	"Fixmap start" },
>  	{ 0,	"Fixmap end" },
>  #endif
> +#ifdef CONFIG_KASAN
> +	{ 0,	"kasan shadow mem start" },
> +	{ 0,	"kasan shadow mem end" },
> +#endif
>  	{ -1,	NULL },
>  };
>  
> @@ -322,6 +326,10 @@ static void populate_markers(void)
>  #endif
>  	address_markers[i++].start_address = FIXADDR_START;
>  	address_markers[i++].start_address = FIXADDR_TOP;
> +#ifdef CONFIG_KASAN
> +	address_markers[i++].start_address = KASAN_SHADOW_START;
> +	address_markers[i++].start_address = KASAN_SHADOW_END;
> +#endif
>  #endif /* CONFIG_PPC64 */
>  }
>  
> -- 
> 2.13.3


  reply	other threads:[~2019-02-26  5:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 13:48 [PATCH v7 00/11] KASAN for powerpc/32 Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 01/11] powerpc/32: Move early_init() in a separate file Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 02/11] powerpc: prepare string/mem functions for KASAN Christophe Leroy
2019-02-25 22:47   ` kbuild test robot
2019-02-25 13:48 ` [PATCH v7 03/11] powerpc/prom_init: don't use string functions from lib/ Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 04/11] powerpc/mm: don't use direct assignation during early boot Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 05/11] powerpc/32: use memset() instead of memset_io() to zero BSS Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 06/11] powerpc/32: make KVIRT_TOP dependant on FIXMAP_START Christophe Leroy
2019-02-26  3:30   ` kbuild test robot
2019-02-25 13:48 ` [PATCH v7 07/11] powerpc/32: prepare shadow area for KASAN Christophe Leroy
2019-02-26  5:12   ` Daniel Axtens [this message]
2019-02-25 13:48 ` [PATCH v7 08/11] powerpc: disable KASAN instrumentation on early/critical files Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 09/11] powerpc/32: Add KASAN support Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 10/11] powerpc/32s: move hash code patching out of MMU_init_hw() Christophe Leroy
2019-02-25 13:48 ` [PATCH v7 11/11] powerpc/32s: set up an early static hash table for KASAN Christophe Leroy
2019-02-25 18:24 ` [PATCH v7 00/11] KASAN for powerpc/32 Christophe Leroy

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=87a7ij2kw2.fsf@dja-thinkpad.axtens.net \
    --to=dja@axtens.net \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=aryabinin@virtuozzo.com \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.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