Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1328244pxf; Fri, 9 Apr 2021 05:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmt2w6EWtCtvgquJV3Y4qDayXPImZgph5v06Xv0XieTTaMSyu9ztyZ75gg/HH5stHbNbP7 X-Received: by 2002:a62:e90c:0:b029:203:90f:6f34 with SMTP id j12-20020a62e90c0000b0290203090f6f34mr12452252pfh.29.1617973145897; Fri, 09 Apr 2021 05:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617973145; cv=none; d=google.com; s=arc-20160816; b=cHocQjtCoZf3Mn7/R752hQ/H8/8/gow9kEMt1FRSkxrnRip/hkhRaOUv9p48H/I2xe 98kdSeIbsZQdAl2xjw1lRW8UnNP9ORqZY1ba2m0FVZ6WHSS3nZUQ6BD5gWx2qtLJQGc+ lEv49jukV9Q3egTuH6QHydN/Y2tol5DFERYO4X6riIKM9poJPHr3KvW4gyjTGhh57bdp ryuTlx/HjwuOLhml+QfpwFA0Cqc942azERY/bifAmjWfy0wPleC55dB+cosA7Atv22Or /cU2oeV3Mj0QBH31xPVWSbBt1M0CrYkx0hiFVwQwZWi0P9MqvdVdmgb9AMn3CeRyNNyJ nDrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=6WC+Zk4gM3t/P83qDLENqpX9uzDLRuXEH7cjC5nOt30=; b=Ly0/ILpsiBBUMC06biwrPepW4fd48k43esnIBoNJgxp9TddJyzgkvotdJ72jObOacC p1mm8zSwy4FirWmpcRRp2LR6U13uX9ajfrPe1Jld01SDER/Tw6eQeFyNCpWL425FiDNs RacHbIcWppG6VHAWhmJ0fwu/7dk1hYMvi2OCMwRF+ZE/BcHIijeZIrf5xSfzfLUEArp7 NuUkZSXpfhkcErY9b5TykejZL+hAMWn4CoqRNMhpkvdYC4fA/qC7PoRQO7t2DgIR5E3N Y7F2cVFkzchh8Htg/zV5PloYj+9dmBNfiqs77euLnjYKhWILK5drshWx6+0CNMX6PmT1 Oq3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si2839735pgq.190.2021.04.09.05.58.54; Fri, 09 Apr 2021 05:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbhDIM6L (ORCPT + 99 others); Fri, 9 Apr 2021 08:58:11 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:38167 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231756AbhDIM6J (ORCPT ); Fri, 9 Apr 2021 08:58:09 -0400 X-Originating-IP: 82.65.183.113 Received: from [172.16.5.113] (82-65-183-113.subs.proxad.net [82.65.183.113]) (Authenticated sender: alex@ghiti.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id BB8BBFF803; Fri, 9 Apr 2021 12:57:51 +0000 (UTC) Subject: Re: [PATCH v7] RISC-V: enable XIP To: David Hildenbrand , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Vitaly Wool , Mike Rapoport References: <20210409065115.11054-1-alex@ghiti.fr> <3500f3cb-b660-5bbc-ae8d-0c9770e4a573@ghiti.fr> From: Alex Ghiti Message-ID: Date: Fri, 9 Apr 2021 08:57:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 4/9/21 à 8:07 AM, David Hildenbrand a écrit : > On 09.04.21 13:39, Alex Ghiti wrote: >> Hi David, >> >> Le 4/9/21 à 4:23 AM, David Hildenbrand a écrit : >>> On 09.04.21 09:14, Alex Ghiti wrote: >>>> Le 4/9/21 à 2:51 AM, Alexandre Ghiti a écrit : >>>>> From: Vitaly Wool >>>>> >>>>> Introduce XIP (eXecute In Place) support for RISC-V platforms. >>>>> It allows code to be executed directly from non-volatile storage >>>>> directly addressable by the CPU, such as QSPI NOR flash which can >>>>> be found on many RISC-V platforms. This makes way for significant >>>>> optimization of RAM footprint. The XIP kernel is not compressed >>>>> since it has to run directly from flash, so it will occupy more >>>>> space on the non-volatile storage. The physical flash address used >>>>> to link the kernel object files and for storing it has to be known >>>>> at compile time and is represented by a Kconfig option. >>>>> >>>>> XIP on RISC-V will for the time being only work on MMU-enabled >>>>> kernels. >>>>> >>>> I added linux-mm and linux-arch to get feedbacks because I noticed that >>>> DEBUG_VM_PGTABLE fails for SPARSEMEM (it works for FLATMEM but I think >>>> it does not do what is expected): the fact that we don't have any >>>> struct >>>> page to back the text and rodata in flash is the problem but to which >>>> extent ? >>> >>> Just wondering, why can't we create a memmap for that memory -- or is it >>> even desireable to not do that explicity? There might be some nasty side >>> effects when not having a memmap for text and rodata. >> >> >> Do you have examples of such effects ? Any feature that will not work >> without that ? >> > > At least if it's not part of /proc/iomem in any way (maybe "System RAM" > is not what we want without a memmap, TBD), kexec-tools won't be able to > handle it properly e.g., for kdump. But not sure if that is really > relevant in your setup. > > Regarding other features, anything that does a pfn_valid(), > pfn_to_page() or pfn_to_online_page() would behave differently now -- > assuming the kernel doesn't fall into a section with other System RAM > (whereby we would still allocate the memmap for the whole section). > > I guess you might stumble over some surprises in some code paths, but > nothing really comes to mind. Not sure if your zeropage is part of the > kernel image on RISC-V (I remember that we sometimes need a memmap > there, but I might be wrong)? It is in the kernel image and is located in bss which will be in RAM and then be backed by a memmap. > > I assume you still somehow create the direct mapping for the kernel, > right? So it's really some memory region with a direct mapping but > without a memmap (and right now, without a resource), correct? > No I don't create any direct mapping for the text and the rodata. > [...] > >>> >>> Also, will that memory properly be exposed in the resource tree as >>> System RAM (e.g., /proc/iomem) ? Otherwise some things (/proc/kcore) >>> won't work as expected - the kernel won't be included in a dump. >> >> >> I have just checked and it does not appear in /proc/iomem. >> >> Ok your conclusion would be to have struct page, I'm going to implement >> this version then using memblock as you described. > > Let's first evaluate what the harm could be. You could (and should?) > create the kernel resource manually - IIRC, that's independent of the > memmap/memblock thing. > > @Mike, what's your take on not having a memmap for kernel text and ro data? >