Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5155869rwd; Mon, 12 Jun 2023 00:20:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SJrWkXDibeUEpGbWX9X9skhrjEWV4G4c5bs41gtigvUuHNVznuQIq4CPZmZOqt2a1pplX X-Received: by 2002:a17:902:ced0:b0:1ac:2f98:e94d with SMTP id d16-20020a170902ced000b001ac2f98e94dmr6453679plg.67.1686554404718; Mon, 12 Jun 2023 00:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686554404; cv=none; d=google.com; s=arc-20160816; b=MQUF73PTT4RTH1sodWiqYJaMxydpv/7kQX6nW7RHuOXeq2FULbIh/hORBzLi4ae91C n7CBoiqEIy9PlEACIkFLQUsge2eCflfRAlw5lgjQbuL1rRNMxEzS+TBxipxwFpFp5QZV Yl28Sceu7cXq78VIiXuSb8V5oesHEAfavAb1j5PDeMIUpaHUXh1YcnUsNaZ+sn7zeFT8 WQxECRYbjscS52tPp3qcFFfXVh3ojudrlODqDNLO9oJbEJke4noFIXX4EP3Ou4xkxlLq 7fAdN5aJ18PgYzIgPXbZs8ZuqZRxg1p5WFS+xFGd9yFz0m8VQIzgPOsbJGIacuL4d/Oz 9b8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=muMBbKlbOgkWCg/h+XMxPqeAhUGmHsuqP1SYaCH/UFY=; b=FEG1Lfbg8LgZRyIoeiyMVgdjJDOtxaDwcvqH5jU4MhI29bItv3cGCCwFLjgRUQvYGy JuHrzvMe62niFG6HmStHclCHdm0RnolaoKjXT1JqKEW6YqIrZFkX3GSckvUMTTMTcs9J MgKzM8mS5ijSlwCKz4XyMoSWTSRpCkRH1Wqsg1jlOX8SJo0uiXeg7L88dpEernj/fpLb twpKg0t1dZtumbZFiQEGXP8ikyPpDjtkqzAr4f2pRNADuy8l11T9js7emNbxZFNMfWOz I/9AiOzpmb4Hf0xpWAY/04kmhIhjgPoUtWMBBywEzr/LU/qNVMyCBwe4WBND3+y+9001 2V5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=u1BzlaXv; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a170902ec8400b001a97262fe53si6813906plg.552.2023.06.12.00.19.52; Mon, 12 Jun 2023 00:20:04 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=u1BzlaXv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbjFLHHR (ORCPT + 99 others); Mon, 12 Jun 2023 03:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbjFLHHQ (ORCPT ); Mon, 12 Jun 2023 03:07:16 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 730E7120 for ; Mon, 12 Jun 2023 00:02:15 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f7f6341b99so28572065e9.2 for ; Mon, 12 Jun 2023 00:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1686553085; x=1689145085; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=muMBbKlbOgkWCg/h+XMxPqeAhUGmHsuqP1SYaCH/UFY=; b=u1BzlaXv/XyxGzixcDsbYA6ou0iLzBYLm+xz8c2f0mzFqrhD6OosEWU0uEvCLlCoqg lrDygREmx13n3/aae1SHNfNQkZvdfSAVKFe5sTX8SZVlwefi4W25BQbZB3Fuxg0t42NE B0GBthaRpdt9jTCcRIHXhqrNOqabbxZPgm6nfQaT9r1LmuvnzYtoCRCFZNsveDw2yvT2 XRAk9s3UZwg2KLM47gSPLpT0G3Fsk5K7R5IqzHdXpS/t8tj3AqRq00ypOSNNlmuTMxK7 7iaiCa2rCHXCmlyo6m6X660ilMWPqmMSFPjk/YWVNdse17EpmOXfb17GQ6oQplXZMpQA 3gug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686553085; x=1689145085; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=muMBbKlbOgkWCg/h+XMxPqeAhUGmHsuqP1SYaCH/UFY=; b=dW/Iv18QYn/F+csQ2Gg9o0qaM6iWhUdSks9vWmUyQ9J3D5Hs4ELGG/2h6UrgGgUdaY 5Rau4DzKM47wQ6zNqTMfshqEqBISA1WvWgfH2GkBFLn8frN/iGzpP3iNv37g9LWd5nGb xEwmbHS6QDkM+xllPcBbBpVDFzIjboNn0aYr3acArvurnrLBzKPSHh/E6Hyv2nim9oju Q3PZv/Ezx7huN1+p+/7f/F+PdAkYFjt/WBiPiveLT2JpRR3+eruYBBnaLFNHyYhtpDpm T0glN34NF64/1STMncTLlNItLcYDbg88QmUc/mrlXZmcvV2lzpgBgWqCzDz6BTqHpfJZ tabw== X-Gm-Message-State: AC+VfDwr1zuQ/7GiweSChBf17r9KIE1UcDup5jlATaLdtvC6MvikaBiy lqvXWeQuxdTwGeVFqImA0xI8IwIyFm028u/PlfVVNA== X-Received: by 2002:a7b:c5d9:0:b0:3f8:2777:188 with SMTP id n25-20020a7bc5d9000000b003f827770188mr295405wmk.11.1686553085028; Sun, 11 Jun 2023 23:58:05 -0700 (PDT) MIME-Version: 1.0 References: <20230607-jogging-grudging-70dede86bc53@spud> <20230610-ability-mockup-f6aa71bad6a1@spud> In-Reply-To: From: Alexandre Ghiti Date: Mon, 12 Jun 2023 08:57:52 +0200 Message-ID: Subject: Re: [PATCH] riscv: reserve DTB before possible memblock allocation To: Woody Zhang Cc: Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 11, 2023 at 1:27=E2=80=AFAM Woody Zhang = wrote: > > 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=E2=80=AFPM 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 me= mory > >> > > from memblock for dynamic reserved memory in `/reserved-memory` no= de. > >> > > 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_boo= tmem(). > >> - 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 befor= e > DTB reservation. > Yep, that's the culprit, let's add the proper tag: Fixes: ef69d2559fe9 ("riscv: Move early dtb mapping into the fixmap region"= ) Thanks! Alex > > Woody >