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.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 8F511C4727E for ; Thu, 1 Oct 2020 16:46:57 +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 3FA092075F for ; Thu, 1 Oct 2020 16:46:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DbNq4Tpx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TmgjR+es" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FA092075F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VzFSq3rHJws42sW3En4aeLFBm/LTgtHuFe8YQsVYYCU=; b=DbNq4TpxOIjW9Gno8ta5mUQxr 5JT9mJijoSZk42H1HCehW9gj03mnSQ9hkdFtW4C+xGbH+XNO11kbuKE1PKdd0P+6D/nJX4XRcEsht C9DT5aSNZAr5jwHYIX1lfNXxrvbsYknrThEPhaSUDPiePtK4Sqsj4amagxc8+AwwIW4jYTN3bJW/I 1PIQFm93rplgDqyKoi+XscjqKkwdjulUC0/6WHYNITl/WGrKf/qI1li/G+dljoFYr/LuELmL+8zXa NZMljVmZ4PXd7xsr6sBbAkRt76/AGeVMlPkC5WpVpAgwWPT3XkhQwpA9ro8shdGLSo7XbVAEKH104 G8EpXUSmQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kO1i4-0000SQ-Vf; Thu, 01 Oct 2020 16:45:37 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kO1i2-0000RO-UN for linux-arm-kernel@lists.infradead.org; Thu, 01 Oct 2020 16:45:35 +0000 Received: by mail-pg1-x544.google.com with SMTP id 197so4455782pge.8 for ; Thu, 01 Oct 2020 09:45:31 -0700 (PDT) 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=k3UPNY3xQhmO0a44ELp/lbtMg59MTagdqfBm/xh/waA=; b=TmgjR+eszJvbuM+T8h/kxRsRperagYa3be5SZnjVPFkptuJWXj8r7rbR/f5PR+wqEt Q0/FXg0vqKn1jTjW4i+jGd1VCHrk0Tc5ICYcYKc9mZFshn+SuKr5pWIEKFSTEd++Xnob M9SXopnKaI7zn7W95kwjxigUv2cZeReYbdUpmj+nMUkfKnNwcpQAl9YC4Y3Xyz36nGzD QTee4XcaLkNeq3t0u+BV0OIGbA1hFXYdB7II0lRopa15awUKL7W41AagZEqQ/i0VRAJ1 bt2ZWx/EKEfbkHc3enEsj1WFZd9jiZ4r9Xv6tQ0luTKJMuAhpyqHpGVlSuiPauxM76vp zrJg== 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=k3UPNY3xQhmO0a44ELp/lbtMg59MTagdqfBm/xh/waA=; b=ss+b+RtxkcqgXMkxknNhj/ha0D+NEn0j3VMYv6LFwoSpRc5V/zviSVAkm+B6+uQZj2 kd7ZgHjtfjN6tsvPg4e53ACx52gX6YUZ1JIoRX9aGHaWug9ck43+x3pQmex+ThpCxVMm SdpotyfTV2A4HKQZptze0sBV5Q488tkZfpsletHeQ93UPv0dKlvUmaL+8LfTYCCfQjjO 6MCKCbkkcGG6T0bvyjMHJNeYXtD88Lwu3AwL4YNfwul50CkrPhsLhH6Lae33IPu9VoEC XqY37iZ/hjujUvhlNgFqMCvFyBNEfuJWyJtpCHZ4NlS52VDeVEdTK92AspFgqnnqO2Mr cVRQ== X-Gm-Message-State: AOAM532/pk5VVMGoSU4SZ95i59F6iTsBBdZU47qnjP5pIq3S6NxZFjFk nj8eCn4lWLt1FWHscK9Ag6m7MdIQHn/MHg== X-Google-Smtp-Source: ABdhPJy19ihWoH2SKAgdHJp4mmxXfWXJJ/GTTE69lfyBmYkmCh/SX/pkhTdWyUnr6xCy1ME95G+7Jg== X-Received: by 2002:a65:5cc5:: with SMTP id b5mr6918105pgt.417.1601570729445; Thu, 01 Oct 2020 09:45:29 -0700 (PDT) Received: from [10.230.29.112] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 131sm7056117pfy.5.2020.10.01.09.45.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Oct 2020 09:45:28 -0700 (PDT) Subject: Re: [PATCH 1/6 v14] ARM: Handle a device tree in lowmem To: Linus Walleij , Abbott Liu , Russell King , Ard Biesheuvel , Andrey Ryabinin , Mike Rapoport References: <20201001152232.274367-1-linus.walleij@linaro.org> <20201001152232.274367-2-linus.walleij@linaro.org> From: Florian Fainelli Message-ID: Date: Thu, 1 Oct 2020 09:45:26 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201001152232.274367-2-linus.walleij@linaro.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201001_124534_994283_61B58B13 X-CRM114-Status: GOOD ( 24.84 ) 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: Arnd Bergmann , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/1/2020 8:22 AM, Linus Walleij wrote: > If the kernel grows big, it can happen that the kernel does not > fit in the first memory block. This is normally out-of-spec > but it turns out that the boot usually survives this. > > What it does not survive is that the prepare_page_table() code > wipes all PMDs (page table pointers for the virtual memory) > over lowmem, including the PMD where the attached DTB is > stored. (The variable is named atags but this only really > happens for DTBs.) > > Let's deal with this. > > First, this makes the code jump over two PMDs where the DTB > is stored if it ends up in lowmem: it could happen that the > DTB crosses a PMD_SIZE boundary so to be on the safe side we > need to skip over the one we know it starts in and also the > next. > > Next we make ARM use unflatten_and_copy_device_tree() instead > of just unflattening it where it is. Currently we just assume > that the device tree will be in some kind of "safe" memory and > as proven by KASan it will sometimes end up in the kernel lowmem > which will create crashes as the kernel will clear all lowmem > PMDs while initializing the memory manager. > > Finally, we add a new call to the MMU code to go in and clear > out the PMDs in lowmem if the device tree was there. > > Example boot log on an affected system: > > ATAGs/DTB found in lowmem, skip clearing PMD @0xc3000000 > ATAGs/DTB found in lowmem, skip clearing PMD @0xc3200000 > (...) > DTB @430af0e0 (physical) copied to @cc394d80 (virtual) > Clear ATAGs/DTB PMD @0xc3000000 > Clear ATAGs/DTB PMD @0xc3200000 > > This fixes the problem where the Qualcomm APQ8060 would not > boot while using KASan. > > Signed-off-by: Linus Walleij This is a much cleaner version than what we had been carrying in our STB Linux distribution which was: https://github.com/Broadcom/stblinux-4.9/blob/master/linux/arch/arm/kernel/head.S#L251 https://github.com/Broadcom/stblinux-4.9/blob/master/linux/drivers/of/fdt.c#L688 -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel