Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2208974imj; Mon, 18 Feb 2019 01:50:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBugbjwhY8Kdwng1sipotHzc4sO+ZEAB4rgPp0FyvizZc9sw37pYWqawuiSZaEBOXQEkzC X-Received: by 2002:a63:7f46:: with SMTP id p6mr21973316pgn.54.1550483411062; Mon, 18 Feb 2019 01:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550483411; cv=none; d=google.com; s=arc-20160816; b=xljM8cV/vL36/ywW1/S1AiAmKu4ZctH9yWCdDmT6Ou1two6MQONd/Od5UcRI+QqE0l NtOkA2wjz442BlsZfFi8laf8Q7IzBoYyBTYxcg6LqNevwN3xumssVAIZQF0YASsA/Y+O FpJalFTQxBngrawU917HXOlbj6U8Baid+tLjJWUUUI5aFpTAEWhzplvmMBYhtZa49z1z CgcvcKhHHC8dj58sJKNe/vSaBUL9aNSuRJwyAsowQmsC69YiIH3kKfb9y73QB8BBJQSt lIDdr3lTHES8si7JsmNKe7VFRxrooJo+pkr9IoOkKrhxW8eGakwPznQd4WFqcouF5VLq PEgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=PZjiJcvfgxMPiW9sIqKOrKGdE27M0UIJb3+NvMR9UcY=; b=UZ4YsmTv9gXKEThuME8matPQQVigsKMLxQXGy5Bx8BdSN3POWISWhLqfAKPyRJkvBl 4imOP9UXE4hZYr4kjznrF9BLU7oc6SjkPf3YLQeUd7rEequ0neKW2eyA8K91B9X9C0vJ wYp12GNBl2DvifZuYsa3qbtRs/HyjgJI8AFGTjrte2vOipnm0CEc9Hmwe8FTUYtza6io sa5WyHBQkwmMEFPONiPUDw5ppjOzWnuf2GYrmoa7KwVkSmmsoAsP248t2GYjC9QMDMWG FNOHeXLkzYoiOf/oozUDxH9DIPTxSOUmv8A1es83wMX1mC9Tt4AEkmV16GsG99JAtc4w pOwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si12620106pgg.522.2019.02.18.01.49.55; Mon, 18 Feb 2019 01:50:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729470AbfBRJ1v (ORCPT + 99 others); Mon, 18 Feb 2019 04:27:51 -0500 Received: from ozlabs.org ([203.11.71.1]:51385 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728447AbfBRJ1v (ORCPT ); Mon, 18 Feb 2019 04:27:51 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 442z6q1sf4z9s7h; Mon, 18 Feb 2019 20:27:47 +1100 (AEDT) From: Michael Ellerman To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Nicholas Piggin , "Aneesh Kumar K.V" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Daniel Axtens Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: Re: [PATCH v5 3/3] powerpc/32: Add KASAN support In-Reply-To: <3429fe33b68206ecc2a725a740937bbaef2d1ac8.1549935251.git.christophe.leroy@c-s.fr> References: <3429fe33b68206ecc2a725a740937bbaef2d1ac8.1549935251.git.christophe.leroy@c-s.fr> Date: Mon, 18 Feb 2019 20:27:47 +1100 Message-ID: <87a7itqwdo.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h > index e0637730a8e7..dba2c1038363 100644 > --- a/arch/powerpc/include/asm/ppc_asm.h > +++ b/arch/powerpc/include/asm/ppc_asm.h > @@ -251,6 +251,10 @@ GLUE(.,name): > > #define _GLOBAL_TOC(name) _GLOBAL(name) > > +#define KASAN_OVERRIDE(x, y) \ > + .weak x; \ > + .set x, y > + Can you add a comment describing what that does and why? > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile > index 879b36602748..fc4c42262694 100644 > --- a/arch/powerpc/kernel/Makefile > +++ b/arch/powerpc/kernel/Makefile > @@ -16,8 +16,9 @@ CFLAGS_prom_init.o += -fPIC > CFLAGS_btext.o += -fPIC > endif > > -CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) > -CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) > +CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING > +CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) -DDISABLE_BRANCH_PROFILING > +CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) -DDISABLE_BRANCH_PROFILING Why do we need to disable branch profiling now? I'd probably be happier if all the CFLAGS changes were done in a leadup patch to make them more obvious. > diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh > index 667df97d2595..da6bb16e0876 100644 > --- a/arch/powerpc/kernel/prom_init_check.sh > +++ b/arch/powerpc/kernel/prom_init_check.sh > @@ -16,8 +16,16 @@ > # If you really need to reference something from prom_init.o add > # it to the list below: > > +grep CONFIG_KASAN=y .config >/dev/null Just to be safe "^CONFIG_KASAN=y$" ? > +if [ $? -eq 0 ] > +then > + MEMFCT="__memcpy __memset" > +else > + MEMFCT="memcpy memset" > +fi MEM_FUNCS ? > diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile > index 3bf9fc6fd36c..ce8d4a9f810a 100644 > --- a/arch/powerpc/lib/Makefile > +++ b/arch/powerpc/lib/Makefile > @@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) > CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE) > CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE) > > +KASAN_SANITIZE_code-patching.o := n > +KASAN_SANITIZE_feature-fixups.o := n > + > +ifdef CONFIG_KASAN > +CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING > +CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING > +endif There's that branch profiling again, though here it's only if KASAN is enabled. > diff --git a/arch/powerpc/mm/kasan_init.c b/arch/powerpc/mm/kasan_init.c > new file mode 100644 > index 000000000000..bd8e0a263e12 > --- /dev/null > +++ b/arch/powerpc/mm/kasan_init.c > @@ -0,0 +1,114 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#define DISABLE_BRANCH_PROFILING > + > +#include > +#include > +#include > +#include > +#include > + > +void __init kasan_early_init(void) > +{ > + unsigned long addr = KASAN_SHADOW_START; > + unsigned long end = KASAN_SHADOW_END; > + unsigned long next; > + pmd_t *pmd = pmd_offset(pud_offset(pgd_offset_k(addr), addr), addr); Can none of those fail? cheers