Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp837921pxb; Sat, 6 Mar 2021 20:18:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU5VVSaNHflisYHezGQWbXjwJth0bVnMoljj+hHTqtz4FGLe51tca+8oDN5X24pyMR88MB X-Received: by 2002:a17:906:8308:: with SMTP id j8mr8941966ejx.339.1615090688875; Sat, 06 Mar 2021 20:18:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615090688; cv=none; d=google.com; s=arc-20160816; b=DdBOUbmjFeJB5+y9nQKpxlZlBg9g4NUgiEvTr3so8MLkY8AIBQHOu6OplYsDODmwip ORT/3LKSSPJPI2n2B3IA0PBwP5H6haiwUVRZOhuUuYjBrMpRzESg3N6VDRs3ZfPH9hHQ hLclxVwd4JvxCZBGPVL7ycGpV8F7Jh4QGBNOcykzasZqaxJtI6c+wmijAdcXab5ilLMV rmDCYBsznh4PvzjDRP6+PhoqAZVpAS4pSf+uzGorVk6a+R+UGdOofWnBwx5IDzeLQQTF 8B0s20Tt3qtMNnnrxtEmOp/+zsn36bUdnbM17ZrBf9JVh91VXD93KU+yNJQrz0mx7xpr mCLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=aNQ8It84bE/zbP5TAlSKFSi5Ijz+ILHaleTfFj87zv0=; b=Qvi8RJRb/1Oce8oXFWc40ZRe1EFOD7WfJ8nh6qLTAIy3aLwR3no1Z6X3IM1CpHCRDR ZIlL3qOvI0+vjX0l6/YYpRhWOA0kLJTT6jxHMot3ibrp8Lfdq7cRflSgysj21wgzZ6Bp gsIbywbt3KbqImXBlTLrM8+qbnpXXfd4vLkZrI14Ho7XFRTrtoXM/1gIkQxvbE8NwvTe qnFW5S1PORmgnj6WmJKsE8+j5nSy8fxcRdScQy1X/mglLuhBYq9AdIZe76oRuP8c5XJ3 iXaDtb6zt+5WfpRBQaLYAK24eBP5fL6wvlB59/dZk4iNdDLMJrCbcLGXip95YvGfyEXr cydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bSux60A6; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si4993339edc.221.2021.03.06.20.17.45; Sat, 06 Mar 2021 20:18:08 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bSux60A6; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbhCGEOg (ORCPT + 99 others); Sat, 6 Mar 2021 23:14:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbhCGEOK (ORCPT ); Sat, 6 Mar 2021 23:14:10 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B144C06174A; Sat, 6 Mar 2021 20:13:59 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id nh23-20020a17090b3657b02900c0d5e235a8so1293386pjb.0; Sat, 06 Mar 2021 20:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aNQ8It84bE/zbP5TAlSKFSi5Ijz+ILHaleTfFj87zv0=; b=bSux60A6elleCiFzeCr4s8KQuPi7mdyvy0RZdt+5FzTgDmhGOBJiogOYnAKSOXgc9J eMGSZ/RY9nb8wnt2wZITIsW1uE4LbpKZsOxD5iEKexjn/3JoG2IuBjeVtC/+ryaaZH3H hZAxPQoRedZHBc0QiZ5Xel96sox+6V3EdXd4tYryEon7p43//Nn9xsuUyvB9WVU27n4B 4tgavUy36u0XVQgdU3opx/9BZdF/CP1g1Kbx4Pxs7cypMBDNPv9+ZnobXo8deJ6PJJ/L 49rXBV2lq1d+qGSNoWhjEVfuog2iroFUu9pcswmu8Yt+Q6Xaa6MWrErLmMv5jwrozcvs 1rUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aNQ8It84bE/zbP5TAlSKFSi5Ijz+ILHaleTfFj87zv0=; b=cUEyq71I9dleK7UadenXTAn5oZZF4EJYnXWxIv8pC5J4l1pegr2sZzIIPS83CyZlf3 xxYF3F+S1uSpLKh+FgLkJTHh7N7c73nq9TzughvQWiuRiETstT/2UJLUO6bB6GQp2olv udXRjWUdFhRhZQ6tqPowkhM9Je5LyTwk88VdzACgVIc8neJ4/iieqqSxADiiYzYSeR6a tgO4vUEKTTPoElXc67XXooRzaLKUg5ho9uHJJtpeIlPS1NmsirEKXTqP6b644IiS+9Xr ZvUs+1McuzKQRpjRWaTfyU+kppcpNATwmwBODJkue/3yHjPWw9aOcxBrbjnBHK4B/MIc YJ2Q== X-Gm-Message-State: AOAM532gGRVqXDOFnLbxOnOdpZGIbE3UZnXyqgokSJsAZB5pDNkD+Bzq 1uL/15RjuY9bEcSCsgABVRvyZe1iWAs= X-Received: by 2002:a17:902:b711:b029:e3:71f1:e08e with SMTP id d17-20020a170902b711b02900e371f1e08emr15459859pls.18.1615090438531; Sat, 06 Mar 2021 20:13:58 -0800 (PST) Received: from [10.230.29.30] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s27sm6150227pgk.77.2021.03.06.20.13.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Mar 2021 20:13:57 -0800 (PST) Subject: Re: [PATCH v2] MIPS: kernel: Reserve exception base early to prevent corruption To: Thomas Bogendoerfer , Mike Rapoport , Andrew Morton , Roman Gushchin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kamal Dasu , Serge Semin References: <20210306082910.3472-1-tsbogend@alpha.franken.de> From: Florian Fainelli Message-ID: Date: Sat, 6 Mar 2021 20:13:53 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210306082910.3472-1-tsbogend@alpha.franken.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/6/2021 12:29 AM, Thomas Bogendoerfer 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 space. So we reserve it already in cpu_probe() for the CPUs > where this is fixed. For CPU with an ebase config register allocation > of exception space will be done in trap_init(). > > Huge thanks to Serget for analysing and proposing a solution to this > issue. I made a typo on Sergey's name in my original version here. > > Fixes: 2dcb39645441 ("memblock: do not start bottom-up allocations with kernel_end") > Reported-by: Kamal Dasu > Debugged-by: Serge Semin > Signed-off-by: Thomas Bogendoerfer Tested-by: Florian Fainelli Thanks! -- Florian