Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4408679pxa; Mon, 10 Aug 2020 08:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAhbPEe/ePZ2GNkFe1kitX9KpzOA84tz5Ya2XSgcyUETUMwX7sB3M6Alvzx6Zl0NSvqZXF X-Received: by 2002:a17:906:3b83:: with SMTP id u3mr21841894ejf.55.1597073120720; Mon, 10 Aug 2020 08:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073120; cv=none; d=google.com; s=arc-20160816; b=RSmKy9TSNOC9+pBl2OH0WrMVVIk6GKfXOCM1tNFTn3QS1X1WShqQ0fpvah8/HYnP5k P05UT5a2+c1/+2JNx1Ul1lY1yl4Y+rdN+acRwopivs1ryUPczl3OcvpLD4xy00BcAMUH KZLaRU1fd6xttBM+8cJYZxUg2POhPU2N5F+/0XRMuQSQaO9nBdaat+RSol9dlTwd+3Xx BbWlF3pSk8wNKR0NnMXg8G4mmV5nhuYS6CfeU9kFRZSEctSU4KiF+C5HetsIfURhouao 7UUFplvmAw9TE1nWQo7b8Lsci4xhi/KmLE2jcW+70Z1CJpgCyx9d0H9pxM6xNeOxrqw6 rAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=32e3pp1m2aLcanTKnrSu1qOVS9b7m+0+hXcx620sp3U=; b=hTNyuJhDGs6fwutZ6uvwgppdkjf0fhq3UEtr69LkI1dY8UWi+hBYMbCfN8G8GaK+Ae cuCogMfuGO2TyDpfl2qZnBfcmj+IvkRCNjrI4MhqwwODXQ/2HMxGel9bjP2pH32Vmqse NDHx7rFNjpGecIdw+a7rQNMWX9F9isMC+IXj+MAyh8PSgE7yDwHR8nyBmawSBSa4c3PN /SDuqioyOUPsuHnwdXjnJu/TtCRZVlRF/V+TVlys7A8n2c/QwhmdvwQLBw7dT5izOONq QR+5CoMTvNsIbEoxXIlo1HJLe83juZYNaZqiRttx227ZuRxNV4GMXsd1ufa97uNC9tfc e/og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="00tdQgL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by25si10836768ejb.281.2020.08.10.08.24.56; Mon, 10 Aug 2020 08:25:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="00tdQgL/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgHJPVm (ORCPT + 99 others); Mon, 10 Aug 2020 11:21:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:51006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbgHJPUb (ORCPT ); Mon, 10 Aug 2020 11:20:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 621AB2065D; Mon, 10 Aug 2020 15:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072831; bh=9S8YiSc3vW1bhf2xH176cs4MfoTmSUmDo6XkcRs+yRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=00tdQgL/IFvnmnx94OukjjEEnEww8+SRvkLPFb+72wl0DN5+l4tNMg5KKrPvrf0eK 4h5ML2yAig/dawBPY99xpXVxl7UDKZ8C8tQ0EMFckbqA0/9GYW6x+7JYHyg5TRWMgm /0G+7/AjhMIbLUdJ88D/iDWysJVcUhBnwzhT6it4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Erhard F." , Christophe Leroy , Michael Ellerman Subject: [PATCH 5.8 33/38] powerpc/kasan: Fix shadow pages allocation failure Date: Mon, 10 Aug 2020 17:19:23 +0200 Message-Id: <20200810151805.545372811@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151803.920113428@linuxfoundation.org> References: <20200810151803.920113428@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy commit 41ea93cf7ba4e0f0cc46ebfdda8b6ff27c67bc91 upstream. 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") Fixes: d2a91cef9bbd ("powerpc/kasan: Fix shadow pages allocation failure") Cc: stable@vger.kernel.org Reported-by: Erhard F. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://bugzilla.kernel.org/show_bug.cgi?id=208181 Link: https://lore.kernel.org/r/63048fcea8a1c02f75429ba3152f80f7853f87fc.1593690707.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/kasan/kasan_init_32.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -120,11 +120,24 @@ static void __init kasan_unmap_early_sha void __init kasan_mmu_init(void) { int ret; + + if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE) || + IS_ENABLED(CONFIG_KASAN_VMALLOC)) { + ret = kasan_init_shadow_page_tables(KASAN_SHADOW_START, KASAN_SHADOW_END); + + if (ret) + panic("kasan: kasan_init_shadow_page_tables() failed"); + } +} + +void __init kasan_init(void) +{ struct memblock_region *reg; for_each_memblock(memory, reg) { phys_addr_t base = reg->base; phys_addr_t top = min(base + reg->size, total_lowmem); + int ret; if (base >= top) continue; @@ -134,18 +147,6 @@ void __init kasan_mmu_init(void) panic("kasan: kasan_init_region() failed"); } - if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE) || - IS_ENABLED(CONFIG_KASAN_VMALLOC)) { - ret = kasan_init_shadow_page_tables(KASAN_SHADOW_START, KASAN_SHADOW_END); - - if (ret) - panic("kasan: kasan_init_shadow_page_tables() failed"); - } - -} - -void __init kasan_init(void) -{ kasan_remap_early_shadow_ro(); clear_page(kasan_early_shadow_page);