Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp2838454pjo; Mon, 16 Mar 2020 05:40:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuOAcncIGHJmaBJrlIUCix2ZCsNphoWHRptKWbHnLB9Op2KJte9bOop2OsaxknztkpDKgYW X-Received: by 2002:a05:6830:1447:: with SMTP id w7mr22641544otp.267.1584362401031; Mon, 16 Mar 2020 05:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584362401; cv=none; d=google.com; s=arc-20160816; b=kw/MUOWfpOUHhWV/CcLT20Mz++lsRepPPk5STiA06XVwdCJFY+FfJ6nKf/4PtA7a5c U6NnHHDsXeDDVPkN48FRspU6vMs3Yh6OhYdfOsUIEBzmt2JJbbxx/psM3nmu1geEw6yT hkk/2oKJNGPf7n04fjv485YNiZgnTmZdv4DrICYS5KOghW/m3U/cjfofy095y/fgdldt ziA2Py8Pl/Dz2dI0AzLI+NfDl/mUp3OqsbYsV3nnSa2/W0K5KjUcRmlOSimW2ioyrlmh 69WvU/Mf1vmSVjYdb/CqKxMkpLYB9CQBEYhh65hUyjnDBhG5ikeoyJ8uoftTGkg9FdLM LuYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=5WUKsDojFO+GspdkRQEOQEnnTjy4ob7MojEwS0VGkfQ=; b=KIyg2xhsiGz0CjP8z+uh/U2+o1MRp02e3YV5uuK/bS/W1Xahk2JKEATp/fSsaipTuf 8+oCsXCugW/HYmO3EqhBRlfx/TOabzC5tl6r3cO5RGM6dRcWWB+WDmxOUnRUcd6sCmX4 1o3CCvnfE/RJAwydQqdy6lJeNp5QKrhvgqZbvCck7A/NaWBJMPc1VCBUytWKZUiFfSZ4 cpnpPEnOYYKQnJQsYGc2w0O/MQF/PLpHVh3p2Q2SUrjN2Glm60BmURZtfa+ffgINeLDe Vyv8N7DZEMJ0d4sVS8mikoeV0enXruHOx4kiL2rjkeUd/HWHGYAu5eXTVDKAVlgeUv0g yLQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=sk1CzpXJ; 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 w29si10690699oth.24.2020.03.16.05.39.48; Mon, 16 Mar 2020 05:40:01 -0700 (PDT) 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; dkim=pass header.i=@c-s.fr header.s=mail header.b=sk1CzpXJ; 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 S1731061AbgCPMfw (ORCPT + 99 others); Mon, 16 Mar 2020 08:35:52 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:63177 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731047AbgCPMfv (ORCPT ); Mon, 16 Mar 2020 08:35:51 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48gwkm2nx1z9tygP; Mon, 16 Mar 2020 13:35:44 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=sk1CzpXJ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id qSIZkA-dpywE; Mon, 16 Mar 2020 13:35:44 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48gwkm1d50z9tyg5; Mon, 16 Mar 2020 13:35:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584362144; bh=5WUKsDojFO+GspdkRQEOQEnnTjy4ob7MojEwS0VGkfQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=sk1CzpXJiMpuRqBIgugyphpxZqVBiuamJ2a22doKbJrBhUDxi/y3O06F19hZq1Ha9 xuiLfgXV/hGSh3GFKhX3mY7z/Gi1n3AbOy0EMedsCeLUHqH0YX1BtswEStZi2ix4XP F/Pa7PBB6iTq66Z0XHMcNo8jvMCLSO06TV8pvPbM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 31B6F8B7D0; Mon, 16 Mar 2020 13:35:49 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Mhdg6mZ9kUvn; Mon, 16 Mar 2020 13:35:49 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 112BF8B7CB; Mon, 16 Mar 2020 13:35:49 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 09D4365595; Mon, 16 Mar 2020 12:35:49 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 04/46] powerpc/kasan: Fix shadow pages allocation failure To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Mar 2020 12:35:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Doing kasan pages allocation in MMU_init is too early, kernel doesn't have access yet to the entire memory space and memblock_alloc() fails when the kernel is a bit big. Do it from kasan_init() instead. Fixes: 2edb16efc899 ("powerpc/32: Add KASAN support") Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/kasan.h | 2 -- arch/powerpc/mm/init_32.c | 2 -- arch/powerpc/mm/kasan/kasan_init_32.c | 4 +++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h index fc900937f653..4769bbf7173a 100644 --- a/arch/powerpc/include/asm/kasan.h +++ b/arch/powerpc/include/asm/kasan.h @@ -27,12 +27,10 @@ #ifdef CONFIG_KASAN void kasan_early_init(void); -void kasan_mmu_init(void); void kasan_init(void); void kasan_late_init(void); #else static inline void kasan_init(void) { } -static inline void kasan_mmu_init(void) { } static inline void kasan_late_init(void) { } #endif diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index 872df48ae41b..a6991ef8727d 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c @@ -170,8 +170,6 @@ void __init MMU_init(void) btext_unmap(); #endif - kasan_mmu_init(); - setup_kup(); /* Shortly after that, the entire linear mapping will be available */ diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 60c2acdf73a7..c41e700153da 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -131,7 +131,7 @@ static void __init kasan_unmap_early_shadow_vmalloc(void) flush_tlb_kernel_range(k_start, k_end); } -void __init kasan_mmu_init(void) +static void __init kasan_mmu_init(void) { int ret; struct memblock_region *reg; @@ -159,6 +159,8 @@ void __init kasan_mmu_init(void) void __init kasan_init(void) { + kasan_mmu_init(); + kasan_remap_early_shadow_ro(); clear_page(kasan_early_shadow_page); -- 2.25.0