Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1575116pxb; Thu, 4 Mar 2021 15:15:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyJKZ4DDijPasv6YYv4Y2R/Ue7gcXmBYICaBHK+LyFEDaXetyi0CWPSNZOAMYZfcDdRzKW X-Received: by 2002:a02:605d:: with SMTP id d29mr6525078jaf.81.1614899756838; Thu, 04 Mar 2021 15:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899756; cv=none; d=google.com; s=arc-20160816; b=XSkIcO/Tc/E2KT9UwjbgPHplEezaJpV6cp2k37u4BWZv7WuKGcUP2drriAouQA6qqe vksuLlA0EnLQQe6ooefXdZzMth5O1V/TKG77mG3iLAWGCZNOLfSauEz1VTCT5YnMDsqc eStqA7aY1uUwFtmk3jA4eFQOztwXLrDXr/PWjAIPOVHW8393MTsvX2VHr5u0lhaBmdhM C77PKuYYE62YmnhbPex5vUj1NzedTQrJ+xOman9A5G1oHZcTYVvPfUH6MnBtpqqROzDu E1V9/Lpr41RzF5JD55uO386VDPE/see2qEEygybYZPdnsIWGJO9CLhkzGTC+ri15Nq4s 91CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=EvHZT0p4Le7UZRKjfUV3x7wqUfU9REamTWGjHb4B32c=; b=Q72qscmqLa6SeIsh3f74/GJbRcsxUGFNlRDeDlWT+mtaQ4+/pku76u9MVxxM4Gjjj+ xilUBTJGr2y8uVAuy9Ohu6z/x3GC8dJ2JoPnmOA+Db05/eM+481sWCS3jMdoNI6i+uin EMb00BldYon3pyFXsBSU6CQ9aYdRWZOkS+u+DdeMyYarJ9dbuhlTBBf02lpkLN8iW8WJ SlXjOLSWb28nCzL8kK/B3y3i2lWtQ+c7iwTZHaNbz9n8ZJyQmMtPeK/ehNWS8WF6cI2g aho0Ajut1KRZrfVSQG+KGnBUSQxRgKF6wpQHVd2P4vAXr05Gjrf7y7dQooFwBg6COviS FKpw== ARC-Authentication-Results: i=1; mx.google.com; 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 b16si760652iob.27.2021.03.04.15.15.37; Thu, 04 Mar 2021 15:15:56 -0800 (PST) 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; 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 S1344871AbhCCQH1 (ORCPT + 99 others); Wed, 3 Mar 2021 11:07:27 -0500 Received: from elvis.franken.de ([193.175.24.41]:39192 "EHLO elvis.franken.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349800AbhCCLfS (ORCPT ); Wed, 3 Mar 2021 06:35:18 -0500 Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1lHO0q-0005hN-00; Wed, 03 Mar 2021 10:41:48 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 4E8B9C0477; Wed, 3 Mar 2021 10:41:34 +0100 (CET) Date: Wed, 3 Mar 2021 10:41:34 +0100 From: Thomas Bogendoerfer To: Florian Fainelli Cc: linux-mips@vger.kernel.org, rppt@kernel.org, fancer.lancer@gmail.com, guro@fb.com, akpm@linux-foundation.org, paul@crapouillou.net, Serge Semin , Kamal Dasu , Yanteng Si , Huacai Chen , "open list:BROADCOM BMIPS MIPS ARCHITECTURE" , open list Subject: Re: [PATCH] MIPS: BMIPS: Reserve exception base to prevent corruption Message-ID: <20210303094134.GA18354@alpha.franken.de> References: <20210301092241.i7dxo7zbg3ar55d6@mobilestation> <20210302041940.3663823-1-f.fainelli@gmail.com> <20210302235411.GA3897@alpha.franken.de> <4e3640d4-7fc2-96dc-de00-599b3ac80757@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e3640d4-7fc2-96dc-de00-599b3ac80757@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 02, 2021 at 05:30:18PM -0800, Florian Fainelli wrote: > > > On 3/2/2021 3:54 PM, Thomas Bogendoerfer wrote: > > On Mon, Mar 01, 2021 at 08:19:38PM -0800, Florian Fainelli wrote: > >> BMIPS is one of the few platforms that do change the exception base. > >> After commit 2dcb39645441 ("memblock: do not start bottom-up allocations > >> with kernel_end") we started seeing BMIPS boards fail to boot with the > >> built-in FDT being corrupted. > >> > >> Before the cited commit, early allocations would be in the [kernel_end, > >> RAM_END] range, but after commit they would be within [RAM_START + > >> PAGE_SIZE, RAM_END]. > >> > >> The custom exception base handler that is installed by > >> bmips_ebase_setup() done for BMIPS5000 CPUs ends-up trampling on the > >> memory region allocated by unflatten_and_copy_device_tree() thus > >> corrupting the FDT used by the kernel. > >> > >> To fix this, we need to perform an early reservation of the custom > >> exception that is going to be installed and this needs to happen at > >> plat_mem_setup() time to ensure that unflatten_and_copy_device_tree() > >> finds a space that is suitable, away from reserved memory. > >> > >> Huge thanks to Serget for analysing and proposing a solution to this > >> issue. > >> > >> Fixes: Fixes: 2dcb39645441 ("memblock: do not start bottom-up allocations with kernel_end") > >> Debugged-by: Serge Semin > >> Reported-by: Kamal Dasu > >> Signed-off-by: Florian Fainelli > >> --- > >> Thomas, > >> > >> This is intended as a stop-gap solution for 5.12-rc1 and to be picked up > >> by the stable team for 5.11. We should find a safer way to avoid these > >> problems for 5.13 maybe. > > > > let's try to make it in one ago. Hwo about reserving vector space in > > cpu_probe, if it's known there and leave the rest to trap_init() ? > > > > Below patch got a quick test on IP22 (real hardware) and malta (qemu). > > Not sure, if I got all BMIPS parts correct, so please check/test. > > Works for me here: perfect, I only forgot about R3k... I'll submit a formal patch submission later today. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]