Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp31337ybi; Tue, 16 Jul 2019 15:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxZmHuUk1JmuCOBM3QkpiJICCtb0dXgQItzPzVYccUXiuiy7mE6Y0RMKlwK4/wiMAWKsi5 X-Received: by 2002:a17:902:20ec:: with SMTP id v41mr36525868plg.142.1563316702921; Tue, 16 Jul 2019 15:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563316702; cv=none; d=google.com; s=arc-20160816; b=T1zx3k76d0fvFo8ubLDn++XeoOnd9epWOA0CU/Jy34FrgO4m0/COtV578gE+X5rPEM R0x6FS77mGGJY8VDRWZuCJUS4z4MhoB3lNTRnkSMMDyIQRKDT9Skof4eb69oQa2s+S4S i33cNFYu12C57iPzxrUbzDYxstkQ7o8Z8vXR85I36Gz6H1F9nYy0Ua4xT71US6VYn9Fk mrYeKsKelJMvXJWbKHH8zBSbHwmIzIeNMk6McW0Y9pJTJrQNROSuRgboPTvKR7DmASBu 6YVYB+xkESLTQOeXNAZ/qR2vgLnRBn+/CgQwHQq0zc3Z/+JxT+J69b/SP7Sj+69oT0eb V2wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:from:cc:to:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=oNKadd/WVCq81IXvSQ0j30TJwkdvFHc6RdF6/To6EAw=; b=sFJ9JBFYH88JZh8iMmTXzy2U8K09YcsQFSwaj8p0/0ZlQLPhRxzCiz11rgOA8LG2GB 2EU29trxTBJ2ZfjuaOKgIl2llCGHMYijEpOjqrnNs8IIDKaIGHxfsCbd3mKPGFYLGF+b 2nknlkT4PWN5MK5KbpsgBxbd4+kXBc87lLwy3v38FdOKJXTPl5p62tO4TOsDSKfWZ7MZ 56b83egbqwzfot4QY1u55sq4V81KgEIVuaI8ahbw9wkwI5O1IUcYeYXHhT2HDFS1AIIQ eheymqlz1yvB7vDtPU7w6Wtlw8CkMCYBT1usB3Kmek0ORAVcLDZosT1uFTdYZ7WQOMhe dUZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PlABOLtx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k193si20276947pge.330.2019.07.16.15.37.52; Tue, 16 Jul 2019 15:38:22 -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=@chromium.org header.s=google header.b=PlABOLtx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387623AbfGPWfr (ORCPT + 99 others); Tue, 16 Jul 2019 18:35:47 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37573 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbfGPWfq (ORCPT ); Tue, 16 Jul 2019 18:35:46 -0400 Received: by mail-pf1-f195.google.com with SMTP id 19so9801092pfa.4 for ; Tue, 16 Jul 2019 15:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:subject:to:cc:from:user-agent:date; bh=oNKadd/WVCq81IXvSQ0j30TJwkdvFHc6RdF6/To6EAw=; b=PlABOLtxKdt3umkPxr+wy+2HNHScTBvq6WU86sEkXCwrWTcMh0G2g2T6kpThh1kisk 7+nncEAlMbqlIRE+f5E+sF92Q0u5QKmJL+9gu+Yup77IlPkp5l7EGMufIUtzof7o8WDP mfFHDWW31G2ojtBEgGD5JV3pdae3gUzylfInc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:subject:to:cc:from :user-agent:date; bh=oNKadd/WVCq81IXvSQ0j30TJwkdvFHc6RdF6/To6EAw=; b=C1s/+8Jodf8extAftgtXZ6igAdPocbq9nhrAMhWf5oJYBzh/sUJXgxO/lJKuXE0flu 4CsQWyHCPsNNATMNF4OECap8QXgczkQg6uvCL19CWQfUkz/j/ktzsmqj0ADzNVxg4hh6 P9BeD/sISaHklQKv72JLIhzhvUtGJKtBuDfsSWGIwsDNQRR2lT6/n/l/YMiMOOuFVPFQ RjaLjZtWv9M19AwB1ufougx6nHKtuF2ZPytg4+cacOOPG7GEFpI29DGsYD7guBxW+YPW fO4puClOGENL/UWxkIOY+B2QlyjrnFax8+dzH40suuCbM2S1qbXdSchm6MvYx12tD93w XhVw== X-Gm-Message-State: APjAAAURqefxTPicDgSshjGEE/OUJ9uov2ZqIWemdGD7BtDxZFHP12k/ HUmbaqWUxsR6Ap9oV5r4MfhhUA== X-Received: by 2002:a63:f959:: with SMTP id q25mr36666426pgk.357.1563316546155; Tue, 16 Jul 2019 15:35:46 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id w18sm28050816pfj.37.2019.07.16.15.35.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 15:35:45 -0700 (PDT) Message-ID: <5d2e5141.1c69fb81.ef731.8450@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190703050827.173284-1-drinkcat@chromium.org> References: <20190703050827.173284-1-drinkcat@chromium.org> Subject: Re: [PATCH] of/fdt: Make sure no-map does not remove already reserved regions To: Nicolas Boichat , Rob Herring Cc: Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ian Campbell , Grant Likely From: Stephen Boyd User-Agent: alot/0.8.1 Date: Tue, 16 Jul 2019 15:35:44 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Nicolas Boichat (2019-07-02 22:08:27) > If the device tree is incorrectly configured, and attempts to > define a "no-map" reserved memory that overlaps with the kernel > data/code, the kernel would crash quickly after boot, with no > obvious clue about the nature of the issue. >=20 > For example, this would happen if we have the kernel mapped at > these addresses (from /proc/iomem): > 40000000-41ffffff : System RAM > 40080000-40dfffff : Kernel code > 40e00000-411fffff : reserved > 41200000-413e0fff : Kernel data >=20 > And we declare a no-map shared-dma-pool region at a fixed address > within that range: > mem_reserved: mem_region { > compatible =3D "shared-dma-pool"; > reg =3D <0 0x40000000 0 0x01A00000>; > no-map; > }; >=20 > To fix this, when removing memory regions at early boot (which is > what "no-map" regions do), we need to make sure that the memory > is not already reserved. If we do, __reserved_mem_reserve_reg > will throw an error: > [ 0.000000] OF: fdt: Reserved memory: failed to reserve memory > for node 'mem_region': base 0x0000000040000000, size 26 MiB > and the code that will try to use the region should also fail, > later on. >=20 > We do not do anything for non-"no-map" regions, as memblock > explicitly allows reserved regions to overlap, and the commit > that this fixes removed the check for that precise reason. >=20 > Fixes: 094cb98179f19b7 ("of/fdt: memblock_reserve /memreserve/ regions in= the case of partial overlap") > Signed-off-by: Nicolas Boichat > --- Reviewed-by: Stephen Boyd