Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1163126pxb; Sat, 9 Jan 2021 09:34:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL+WNXN7FSF76VE1hs6HMSybeCXaPSUOSj+SPeZ5LrK6pjk17rt+pnxHNgQtdgSRcNAJiA X-Received: by 2002:a17:906:5fc9:: with SMTP id k9mr5870658ejv.70.1610213648702; Sat, 09 Jan 2021 09:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610213648; cv=none; d=google.com; s=arc-20160816; b=D9dtCpOBbhE7zdlEx/soBiir9WHBNn6WlY3wDTYA5PuxiPVILu7Sq2RvVbK4cGStV1 hBkmrtXzgf9yLcOJ+f53gqVjVT8i9qrLBgl+goH2hwjecbL6l3sozB2g++CgEPQa8wLe xiuFJ9pcQPNUq7vh3jhdQG34aktKu4vy9dbjAu2yiw1zeloE6y8gQaYpXvaEv9XknQ5i XPmqPePH0EaAFugvIozXLWy87kLRTphB1blUYcHpmsjAy+RogBjKB8gjRN4kHbILqTdV fz/M2NO/9pQPe9l8tnUWh4nk5UwdOy/HTSZaHHph+XSo4N4TS3ySNOHsIxRlGizAyn0n 5CXw== 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=QTIicvmPPddk2PAdOzD5pKzbNtlq1Pdrc7mdXo8LQ9Q=; b=NNmYPUWvVSc4F8u0Wy/HDgu3qru/NIqbTCX3t+rQ1ZtcpA9unr9wDO2ge6ixbDbR/k okbQZ8H3nvNmtFmCHUhWnpsy048JTMfxkcMy0fM/I5kEpeIvj8kTxK3aE5y2SAuwzZuL m/piLaPwgBLUxs4hvIDE1jp59fy4axGdFDA5kmPZ5AEd3U3s8a69Lx70PHRKaZhgDG5H H8WcJVpQFx4IiZQ4M8IvHK5Ag3MUNz8kfeqJlGTWSuzU0oMEu/gNiAyXYrvLULNcuW2q hskWmnPiT06lB/eZ08W7L4spn2ztfT343dAx0eef0vXQRMn/N5EaOKmeaPXMZlnY6EJr zHXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uv1y5h5M; 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 hs14si3057660ejc.159.2021.01.09.09.33.44; Sat, 09 Jan 2021 09:34: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=Uv1y5h5M; 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 S1726514AbhAIR3Y (ORCPT + 99 others); Sat, 9 Jan 2021 12:29:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726507AbhAIR3X (ORCPT ); Sat, 9 Jan 2021 12:29:23 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B4DAC0617BD; Sat, 9 Jan 2021 09:27:57 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id v67so2511131lfa.0; Sat, 09 Jan 2021 09:27:57 -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=QTIicvmPPddk2PAdOzD5pKzbNtlq1Pdrc7mdXo8LQ9Q=; b=Uv1y5h5MALwpNcP9jIqd8d73lF7eRhLkj1ZnkKdrPuQrakmBp+GCn/SZ9ZsJDZrY7D 88PhCKe3p7Zww0XwLPnbJ9pDnGTbNG7gC06/ulXYuSb3vDi2x+kOwZmWvpkh1lAGUbY2 KCuHHOxvb3QOuSvk+Z6le16Pk7+XM+iYsMHgdkqrhLyHGUtXfwGjKkHz2SLbrRSjDVZH Q6pfQq0ZBlbj5DG3R4RUEHWh74qZ8xeDpXBpZXRY/fZeEtmEBtWRIoq7Vhg2BkMlpvYX UafBUJ7qO+Wg9eYixLGyYWL0bzwI3J01KSborfilpavgOTk9podWFuWDxB4i2M52eUMZ v1Bw== 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=QTIicvmPPddk2PAdOzD5pKzbNtlq1Pdrc7mdXo8LQ9Q=; b=fYLeQ7CCsNKXbv0bPratpD0m8e+zac4ZMeY6ZiU+DDaLsiBsW3pRKPjJhlPkJfFbJS ykLuMOkS1izkgiMZzDRka0K+Ft59TyiK2hE8SzEyApdEAPUOmjc5rwktfu6pnyCmYW7O +li22GhoDaUDwRtIwOaHgChgKV1pZdQ/2L7Fd0u+0faoeAlUMX8KuuV3MV1X+9D6z4aA kIf+qAgIsAV8U0YyFJ3ne43bnb8+w49B6YoZrGBzB0yNpMzM0cRirowRbmkLYfY2IA/N omFyin78vJO+5FjsLxzeU1Aj4JqAfI8y1WVB4t04bn/Wd5F+LETaywHQUdhx1BP+z24c Rl6g== X-Gm-Message-State: AOAM531lvxht92I6TYq+wyo3VX7C792zciTHTA7XJG3lgIaIQ6lxbrIh HRMrkSaHuM6NUDvevvCWqIu30cknTA0= X-Received: by 2002:a2e:8250:: with SMTP id j16mr4145528ljh.354.1610213275842; Sat, 09 Jan 2021 09:27:55 -0800 (PST) Received: from [192.168.2.145] (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.googlemail.com with ESMTPSA id s25sm2595293ljo.106.2021.01.09.09.27.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Jan 2021 09:27:55 -0800 (PST) Subject: Re: [PATCH v12] ARM: uncompress: Validate start of physical memory against passed DTB To: Geert Uytterhoeven , Russell King , Ard Biesheuvel , Nicolas Pitre , Marek Szyprowski , Linus Walleij Cc: Arnd Bergmann , Eric Miao , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Lukasz Stelmach , Stephen Boyd , Chris Brandt , linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210104130111.1269694-1-geert+renesas@glider.be> From: Dmitry Osipenko Message-ID: <5f23561e-4099-8578-2c28-4ba39bbaa071@gmail.com> Date: Sat, 9 Jan 2021 20:27:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.2 MIME-Version: 1.0 In-Reply-To: <20210104130111.1269694-1-geert+renesas@glider.be> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 04.01.2021 16:01, Geert Uytterhoeven пишет: > 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 > --- > Submitted to RMK's patch tracker. > > v12: > - Drop unneeded initialization of r in get_val(), I tested this patch on NVIDIA Tegra and haven't spotted any problems. Tested-by: Dmitry Osipenko