From patchwork Thu Dec 3 12:19:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 11948589 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 92C2AC63777 for ; Thu, 3 Dec 2020 12:20:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 279C022241 for ; Thu, 3 Dec 2020 12:20:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 279C022241 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=EEo1ONZIJ3TIYnTsFfclII/+HqaT96xUwhx2pfjhJfU=; b=pYgFGODxyZBAEx9caGE2F8AdEo daNRdCROggQLmlbLbT/KPAJ8HcnxuCtxv5GhuIKZBmZwRdq+GHdnDSdGG3qCh6W57eL07Nm5iyF94 VqrNR3x3AmXa1kmaoGtjyHbY5/FejhYAMxEmT6SQ3U7sasFZAszCeB4pGojm5kLahxd27Q9D+I2Gs 6CnuGyNXtUzorxCBYz5EazoBhhY/KlQRfPYaOlR5Iz2yKNTHzEtSEeexezR9DsmTqny98lNQ4+RI5 aYLl+OR+wSpSOSkJZhnv7rhAh0NPa74c8RtxOPjGMUuzLqxONRjYHGsjVzN9LFz6CmJNRn9ZzMG/d yuOwt1qQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kknaI-0001Fq-Ar; Thu, 03 Dec 2020 12:19:42 +0000 Received: from andre.telenet-ops.be ([2a02:1800:120:4::f00:15]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kknaB-0001A1-S6 for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2020 12:19:38 +0000 Received: from ramsan.of.borg ([84.195.186.194]) by andre.telenet-ops.be with bizsmtp id zoKN2300V4C55Sk01oKNUN; Thu, 03 Dec 2020 13:19:29 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kknZy-007hFn-IO; Thu, 03 Dec 2020 13:19:22 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1kknZy-00C2t9-2B; Thu, 03 Dec 2020 13:19:22 +0100 From: Geert Uytterhoeven To: Russell King , Nicolas Pitre , Ard Biesheuvel , Marek Szyprowski , Dmitry Osipenko , Linus Walleij Subject: [PATCH v10 0/3] ARM: uncompress: Validate start of physical memory against passed DTB Date: Thu, 3 Dec 2020 13:19:13 +0100 Message-Id: <20201203121916.2870975-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201203_071936_018622_42025B59 X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , Arnd Bergmann , Stephen Boyd , Lukasz Stelmach , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Chris Brandt , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Eric Miao , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, 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, to support booting 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. Compared to v9[*], the major change is a step back, and only supporting this on modern systems that pass the DTB explicitly, with improved validation to avoid regressions. This has been regression-tested on a variety of boards using a passed or appended DTB. Thanks for your comments! [*] "[PATCH v9] ARM: boot: Validate start of physical memory against DTB" (https://lore.kernel.org/r/20200902153606.13652-1-geert+renesas@glider.be) Geert Uytterhoeven (3): ARM: uncompress: Add be32tocpu macro ARM: uncompress: Add OF_DT_MAGIC macro ARM: uncompress: Validate start of physical memory against passed DTB arch/arm/Kconfig | 7 +- arch/arm/boot/compressed/Makefile | 5 +- .../arm/boot/compressed/fdt_check_mem_start.c | 131 ++++++++++++++++++ arch/arm/boot/compressed/head.S | 70 +++++++--- 4 files changed, 187 insertions(+), 26 deletions(-) create mode 100644 arch/arm/boot/compressed/fdt_check_mem_start.c