Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp269924pxx; Wed, 28 Oct 2020 04:37:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVZEDmXWgIwaXdff77chTGcZ9aIUQmASmVUBu3AKgE/cORW5eGscfHxo4vbQLCC4ZYonXq X-Received: by 2002:a17:906:6d99:: with SMTP id h25mr7035130ejt.281.1603885024368; Wed, 28 Oct 2020 04:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603885024; cv=none; d=google.com; s=arc-20160816; b=SUSzwEhBntWRZJZ4+PUkkuMi3aBwpSWWPCzwTB3OixGuVDIoqK6jWFMqFDDADge8NP +QwX5XmD4UC+db5H7o7Bk1CO603quab3E5ryoVOdYIHLOq3iIjQbrPW2s+fdWF+R0POv g5bxTuBSF1pR3e4ZwVoKMZtbWvLKIIslRlnpfzrVUBguN2TmVYTkc0nrcKgHnxvm2IkR nhOMgubPou5yTTqmE+6rZsU7Qfs2CriQlVPtCj/46Tz+yQRO8Io6VLjWvddeFx5KeAmq hOCYyJBQcxzVjHcHZS364aVmvG+V2YVVFTCpFmJNBHcIMsySYeKN/bjML//ccY8jlfCC yS4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q37a4iw5GxiwraW/TzCg+OCB58xNCsb/m38SNgEZFk8=; b=ACIFELjkHlYAL1UZzNqAlqzuwiGZePYglRjlqmFMu0uSwURSojNaCkiRX5Fdc3b4EC IaWRm5KKICSi5UeegglXgd0XE1m8tY9K15RwEsPLIyVV/4nHoHNz6VWMdG9npsaALkKO 5kS4ThJAPjqImEf9LGXTf2Owo3LVGH/5hRsEGkGg8S2SNg61K1FGdJkdV2wanUkP5GpU HcYlTjs+Y4YtH0zOk3tLotkgpNp7Me6BNPlSUE//wvkVXrRxuRjowA33O9hND7SbOfSK mGhqqTT6h6fQ04wukH0BRlsw0f4uJDsF9R6uLUuArx9Yd0Vnx3ZYN1PhL6m4K7mVPhb3 DBHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WETBNtol; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si2698178edr.173.2020.10.28.04.36.42; Wed, 28 Oct 2020 04:37:04 -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=WETBNtol; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794004AbgJ0PJi (ORCPT + 99 others); Tue, 27 Oct 2020 11:09:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1790937AbgJ0PEu (ORCPT ); Tue, 27 Oct 2020 11:04:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 436572071A; Tue, 27 Oct 2020 15:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811089; bh=D6CmrTf6q2KupTEsc6y18uYP+IEiFGZ/b2GEyFpSSHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WETBNtolt9vVXO72xOmRBehIJcK7KKL8POAp7fX7N0AlTcETwQnr5JhsfH25YxaoE tvp9XRDgrMguIGQdXCpAgChfMScxYXrs+7/Lm3qhmEM1ixSW5lPbZCpnBZUk5PLQjp +3lHL3ZYilEHulf2ncN+aaWbhX+VqCLnxX1p8Alo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.8 369/633] powerpc/kasan: Fix CONFIG_KASAN_VMALLOC for 8xx Date: Tue, 27 Oct 2020 14:51:52 +0100 Message-Id: <20201027135540.011627138@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit 4c42dc5c69a8f24c467a6c997909d2f1d4efdc7f ] Before the commit identified below, pages tables allocation was performed after the allocation of final shadow area for linear memory. But that commit switched the order, leading to page tables being already allocated at the time 8xx kasan_init_shadow_8M() is called. Due to this, kasan_init_shadow_8M() doesn't map the needed shadow entries because there are already page tables. kasan_init_shadow_8M() installs huge PMD entries instead of page tables. We could at that time free the page tables, but there is no point in creating page tables that get freed before being used. Only book3s/32 hash needs early allocation of page tables. For other variants, we can keep the initial order and create remaining page tables after the allocation of final shadow memory for linear mem. Move back the allocation of shadow page tables for CONFIG_KASAN_VMALLOC into kasan_init() after the loop which creates final shadow memory for linear mem. Fixes: 41ea93cf7ba4 ("powerpc/kasan: Fix shadow pages allocation failure") Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/8ae4554357da4882612644a74387ae05525b2aaa.1599800716.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/mm/kasan/kasan_init_32.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 019b0c0bbbf31..ca91d04d0a7ae 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -121,8 +121,7 @@ void __init kasan_mmu_init(void) { int ret; - if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE) || - IS_ENABLED(CONFIG_KASAN_VMALLOC)) { + if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE)) { ret = kasan_init_shadow_page_tables(KASAN_SHADOW_START, KASAN_SHADOW_END); if (ret) @@ -133,11 +132,11 @@ void __init kasan_mmu_init(void) void __init kasan_init(void) { struct memblock_region *reg; + int ret; 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; @@ -147,6 +146,13 @@ void __init kasan_init(void) panic("kasan: kasan_init_region() failed"); } + if (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"); + } + kasan_remap_early_shadow_ro(); clear_page(kasan_early_shadow_page); -- 2.25.1