Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3878947rwd; Sat, 10 Jun 2023 17:37:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sKNb4lnUU6zGMZTqNffM7yNBRor8D5lJqhv6sZrq/Coc+Ug7mbzc5ZvoTdm+qQ1WBzo35 X-Received: by 2002:a17:907:7b95:b0:974:1ef1:81ad with SMTP id ne21-20020a1709077b9500b009741ef181admr6141985ejc.4.1686443859604; Sat, 10 Jun 2023 17:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686443859; cv=none; d=google.com; s=arc-20160816; b=c0oA85JQ7m5490qNiUZzuxwk3UJJImzcSLKRFPmdLl2JRHkzZul+sm20gaxKIQKQTa orpgnSkGwm7VCnw2xPCKEvdc7ce/ycHEPHPHsqy8aQGxRuLKZtZtC4yjzAFY5Pab4Dv3 c786wLGwvJDV9Tnmhy04K0SQVcHyfZ9eMeJRfBSUylNvbmhbw8asc2xgGlq75l2vJiUV MMufutyOUq/V4IPqalH3XaIJyuXFsqN9sfxWSQtvDSkEc0X4+jxgSiETSc865sHg1ovo E0/wkQYGWlSqRz02I1xnNZ60ly75XBXRWNMcRojqn5GuMTN8uK+B7QvhAatSO2AMNmaW V+Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:subject:cc:to:from:date :message-id:dkim-signature; bh=Fn02ERRTdshIy31ivri71MFDl08htZpi5ZW/1B1Yklk=; b=bfGbH9VFtAr5IerFkYfeYKhr5zy6OWe90Iq+ny8N4U/BmkOW2L72k9zBslVk3LgsPV I+zfbTQmcpI8eq68R3gdHksmgT1YWR8NzWAdcbwklkymiPv4ITFhJGxa5CH2L0F6sZMt C7fIFvlh1Tl637GkdPmMzLfQHofFqIK9SAJ2FPG41sacCyT2pFTj6awuek6dQxqQzlYF phFJQi0csD6LGNWx0aV2HL5juBYm7SXo/pY0X+4Pp2TNkl+Yxn6kXN5YPiBiOpx5C3Mg kKvMea7vuSqZViLQUOPGKg61pwLxUykRHhV8AIy3K9LHQq0rws8bHFeyiUkr2JjrexRj v8iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=RoTQNaPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a1709064a0600b0096f4237cc02si1970783eju.376.2023.06.10.17.37.15; Sat, 10 Jun 2023 17:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=RoTQNaPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbjFJX2v (ORCPT + 99 others); Sat, 10 Jun 2023 19:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjFJX2t (ORCPT ); Sat, 10 Jun 2023 19:28:49 -0400 Received: from out203-205-221-233.mail.qq.com (out203-205-221-233.mail.qq.com [203.205.221.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A57C35BB for ; Sat, 10 Jun 2023 16:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1686439723; bh=Fn02ERRTdshIy31ivri71MFDl08htZpi5ZW/1B1Yklk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=RoTQNaPnb3BqEhoxdgH5HaBTxxioANrHFnLd1LukIgrwv45hFloQWpxCw3Ucl5rFO p01sv1k5JffRzrO7Ap0d6Md6efwMx2CVKruiBnk+d6JpC7Eqb2apy7nuWF0BBC5puP ExC7dz8jMm4AVaRDu8/FbF1jxcImz719BYrXABwE= Received: from localhost ([101.224.149.128]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 6C88D4B4; Sun, 11 Jun 2023 07:27:08 +0800 X-QQ-mid: xmsmtpt1686439628t5vxva631 Message-ID: X-QQ-XMAILINFO: MR/iVh5QLeie/ax1XRHrhBLZq6mCcLiuvDNt/91BzhUp23FvjncXJ7GelEe3vM 9OAGxznL5b2IhQ28j88ewmLPJ3lH3nD/j6FA1YP8aNEjbE0aYxSc602m22PyY5pTGqT17iolSgf+ IrqCx4Zi6HmEqVVPMapH0ioVbBJwLiiwVtiv5H4KOxgvH9AM5zb3nR1cHmfn6M7MGjdcodXvggSz gOjRh1qmAXSZDviwLVUP7imhArz3DWJUVDrWFhWbF+muhLKzneucXXx3jmvC+LdPUGC+/D7ZQFLV AUVbzoLaYy95K8y6wrJskoGPruHFjkqe1fSbBH8CDuWjX51RTYucuPkzaVfROFsRQCvO/D2Pb/eO VcNyBBElLm0cC1ia5z0ACkysYN19UqskQ+teQRpSx5TNwnzHrL6+x65ek6j8UkUVCb0OIecbF6+L l80g9Ylm7c6aHQXv0CozzrpJO+Aq7c+NX2lk8poCTzy9y5wVK1rOdRD6OifEVsnwW9h7EB8zVhqQ MJ5kl8gAc2Dk2Akm6Q24MkToF7FIHSj4THhg+9n7/rTP0S/6qYIdOhOeXpNMsMCML5KBek7UUgqf MgeqEeZUFkn2KXLQIkRN000bluhWfugfnziETRgnca2fD9O9PUaKISZWsaaImOB+7gOFwB4k9wPH vmkVNNqTv8Y/KuQFQ6GVcYfYo6Di1bgQyfcQHkafGqtpLCMdma4eNTld0bQNX4vZdewtXL/m08YS QAL0l1gmXF593b5xMriqDT8t/E4BthO2/HrhseEZnzScWyB9QH2hCX6H83R9JHHVE8NbZEjZN9ZD 7waUowtBucgKsyWtuM1ioqh07sAjQFSL2fOVfHnjYtAm/6kNluWJnUTJJX4HiJbNA/sxL7CSQyoU pSpN3w7dotYXlUfdHAGFxZxD+yYRxxgPrV8JbvH2lZMhCqNrRORrG2WiqCNf+HWdVi7inHuS8HYa d6MNI1w9TXpiNO/8u6eA== Date: Sun, 11 Jun 2023 07:27:08 +0800 From: Woody Zhang To: Conor Dooley Cc: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: reserve DTB before possible memblock allocation X-OQ-MSGID: References: <20230607-jogging-grudging-70dede86bc53@spud> <20230610-ability-mockup-f6aa71bad6a1@spud> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230610-ability-mockup-f6aa71bad6a1@spud> X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 10, 2023 at 04:41:17PM +0100, Conor Dooley wrote: >On Thu, Jun 08, 2023 at 09:49:44AM +0200, Alexandre Ghiti wrote: >> On Wed, Jun 7, 2023 at 8:17 PM Conor Dooley wrote: >> > >> > +CC Alex, you should take a look at this patch. >> > >> > On Wed, Jun 07, 2023 at 09:35:19PM +0800, Woody Zhang wrote: >> > > It's possible that early_init_fdt_scan_reserved_mem() allocates memory >> > > from memblock for dynamic reserved memory in `/reserved-memory` node. >> > > Any fixed reservation must be done before that to avoid potential >> > > conflicts. >> > > >> > > Reserve the DTB in memblock just after early scanning it. >> > >> > The rationale makes sense to me, I am just wondering what compelling >> > reason there is to move it away from the memblock_reserve()s for the >> > initd and vmlinux? Moving it above early_init_fdt_scan_reserved_mem() >> > should be the sufficient minimum & would keep things together. > >> Thanks Conor. >> >> So the patch looks good to me. >> >> But I find this fragile: >> >> - we do not check memblock_reserve() return value to make sure the >> reservation really happened (and quickly looking at the code, I'm not >> even sure it returns an error if the region was already allocated). >> - we have to make sure no memblock allocation happens before setup_bootmem(). >> - we also have to check that no fixed memblock_reserve() happens after. >> >> The last 2 points may sound natural, but we'll have to take great care >> when adding some code around here. I'm working on an "early boot >> document" and I'll add something about that, but a runtime thing would >> be way better IMO. >> >> You can add: >> >> Reviewed-by: Alexandre Ghiti > >btw Alex/Woody, what is the appropriate Fixes tag here? In ef69d2559fe9 ("riscv: Move early dtb mapping into the fixmap region"), Alex move early_init_fdt_scan_reserved_mem to setup_bootmem() to prevent memory allocations before of reservations. But it should not be put before DTB reservation. Woody