From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22533C433DB for ; Sat, 9 Jan 2021 17:29:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0ACE22240 for ; Sat, 9 Jan 2021 17:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbhAIR3Z (ORCPT ); Sat, 9 Jan 2021 12:29:25 -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-Google-Smtp-Source: ABdhPJyuYRpnBjCFbxkqJITK444Ml1UXvaBjbxw2SBMSyflkmUAqHuZ9avGkKRgfDOmC1UTTEIXnHA== 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