Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp689640pxb; Fri, 8 Jan 2021 16:00:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMQkTnVkyxuVN28Q2PgbDfsNkvaAsa+f6qaLl8zP+i1ORGgaJaKVWa+svul0mrfkoUBSmE X-Received: by 2002:a17:907:7251:: with SMTP id ds17mr4248438ejc.448.1610150411439; Fri, 08 Jan 2021 16:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610150411; cv=none; d=google.com; s=arc-20160816; b=uNSHE0vyKm2uDGrxkVijOAl3czgGKwjPf1jYXnNJ5AEd46ZlUuN+lbUejAD7U+JKyH bMvOKHwswcFqZbr/HdWO6AgA0pz6W9D1wJglQtFps9NWVKwFewfWFgYOTKlCWH56o0xg 0MxJ4AXJX2gbzae5qalMHGO+FSndyc3hxa4KMFne82f+pcRR6I4zho3f1S6+onBK9kUh B9R4FDzx431gJjirElP3Jg8zUwbv1vI5OOHL01hggxQ/soHNsMtVx8u5TEECYqPU8M/x RxWhVBIb8cMZfbxFgox457rWiPytDfQR3RePuNOBcU1038wH8m9MAATRVH0A5oKn0ani 6dDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bXBEV2qwkB08QLhyng3ARCLP/t7+rlKlWr/8GjsMDHc=; b=wqdLMeNFR0QgOGtSLOnmiliBmL9ItIbyMnY0iqEBEXQmSHxLrmaaW/Pu/oU4DRQl58 YNKPnfTmZ7b7Fo4eA4JTXtmuLf1PDYbnOkk0B2gGvLIEkFwl27XN2kQQr6NHlDDO5oWg jRAkQiB0/7O14L9vSpfGbSkqERfeKd5t6AFIrl2EiQ6+U71+CgJc80aiPzsyKFghYPNx ATXUNtfCAcc8SdLo8KvLRhBhW/I3dM6JNwGFT0yZ4anLnPuApjMwapCvDDHRMB01cJ8+ z/28HHeQgm7rAU+CjRnZNTHtH77PWjGf4ejZxKAtntuoeLJ9ue1fkrjh08fd/gHy2Sap j5WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tj1tl2TL; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t5si3911517ejr.740.2021.01.08.15.59.47; Fri, 08 Jan 2021 16:00:11 -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=@linaro.org header.s=google header.b=Tj1tl2TL; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbhAHX6T (ORCPT + 99 others); Fri, 8 Jan 2021 18:58:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbhAHX6T (ORCPT ); Fri, 8 Jan 2021 18:58:19 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E485C061574 for ; Fri, 8 Jan 2021 15:57:38 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id 23so26923340lfg.10 for ; Fri, 08 Jan 2021 15:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bXBEV2qwkB08QLhyng3ARCLP/t7+rlKlWr/8GjsMDHc=; b=Tj1tl2TLCYfPqgeOpyrtiqpGFoAX7LMmfEH9YPhTR84FMrv8mQVDwe984OBfLZMWyJ 2gpMNRgC7pKRC4BR8EHqae6ZujKeVMiBCgvx0S2REOiyZ0Sg2CoQqyvhBZT3iAXBQj3v Fd7RKGj5AC5fPZlr3BVOIMeu7igui1HpEQvtjSpswCopKAl7UZxt9BwbBh2abtxD52mX t28wrwLB1Tg5mKPoYmDACWv8aRUx46+OkywlXuDb2HjfqweqLnJNGbugs6Ag2Gve5xrM UjS/3ouhlOI5+/YSEPHO4yRmKmBkztgFC0aqo3X9+IY7nLSFEBlP52M2NSjDYaYDWsvd gy1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bXBEV2qwkB08QLhyng3ARCLP/t7+rlKlWr/8GjsMDHc=; b=NeBv0F8BSsoc5t4MFbe9GgIFl3Z46ZOqRPSoHaDWWBazAhZA/dYbf4VYBfNjjmK1an WEw+vmMtcj3/SBgz3FkaHLobjM5HEa3GvKN8Eh7bxU+rxl4PhD1UgX7HY+rUGQnqMgB2 emrBDMyL0AZP1fXOfqIJ0MgVU2EB6ld2h8W/9Mvi+M5/CWxbGKGtwE69vBUnXr6FOIPM bhbszDXkkGVBY6tTMfiVjfAz7zIpajZ3z/px9BIMfh07Y+RcYDFZHUPkKCyno8/7Yj3m ZqnbJ8QQLObE899AsoULiWLeu6iKFQcSRJqBrJiVFK9R52019J7vZtrGUKzjBU8XVdze vAEw== X-Gm-Message-State: AOAM532lCCV8MRd0pLVMvqGFJ196qsozHZ6Da0vHejQfulSN2ndKLc57 iiLcw99j+YpGxCd7YdEMu6xOKgVr8ARpHsmiWpowbg== X-Received: by 2002:ac2:5597:: with SMTP id v23mr2421818lfg.649.1610150255894; Fri, 08 Jan 2021 15:57:35 -0800 (PST) MIME-Version: 1.0 References: <20210104130111.1269694-1-geert+renesas@glider.be> In-Reply-To: <20210104130111.1269694-1-geert+renesas@glider.be> From: Linus Walleij Date: Sat, 9 Jan 2021 00:57:24 +0100 Message-ID: Subject: Re: [PATCH v12] ARM: uncompress: Validate start of physical memory against passed DTB To: Geert Uytterhoeven Cc: Russell King , Ard Biesheuvel , Nicolas Pitre , Marek Szyprowski , Dmitry Osipenko , Arnd Bergmann , Eric Miao , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Lukasz Stelmach , Stephen Boyd , Chris Brandt , Linux ARM , Linux-Renesas , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 4, 2021 at 2:01 PM Geert Uytterhoeven wrote: > Currently, the start address of physical memory is obtained by masking > the program counter with a fixed mask of 0xf8000000. This mask value > was chosen as a balance between the requirements of different platforms. > However, this does require that the start address of physical memory is > a multiple of 128 MiB, precluding booting Linux on platforms where this > requirement is not fulfilled. > > Fix this limitation by validating the masked address against the memory > information in the passed DTB. Only use the start address > from DTB when masking would yield an out-of-range address, prefer the > traditional method in all other cases. Note that this applies only to the > explicitly passed DTB on modern systems, and not to a DTB appended to > the kernel, or to ATAGS. The appended DTB may need to be augmented by > information from ATAGS, which may need to rely on knowledge of the start > address of physical memory itself. > > This allows to boot Linux on r7s9210/rza2mevb using the 64 MiB of SDRAM > on the RZA2MEVB sub board, which is located at 0x0C000000 (CS3 space), > i.e. not at a multiple of 128 MiB. > > Suggested-by: Nicolas Pitre > Suggested-by: Ard Biesheuvel > Signed-off-by: Geert Uytterhoeven > Reviewed-by: Ard Biesheuvel > Acked-by: Nicolas Pitre Sorry for the long delay in reading the patch :( I really like the looks of this now, moreover it is very useful. I suppose it is already in the patch tracker, but for the record: Reviewed-by: Linus Walleij > + reg = fdt_getprop(fdt, offset, "linux,usable-memory", &len); I suppose we already had a discussion of why this property is undocumented? Or should we document it? Obviously it is already in widespread use. Yours, Linus Walleij