Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2019166pxb; Mon, 12 Apr 2021 12:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDm2tHQMZfLL0Mq72jWzdiJd9+2EZxSXvswpNhORTriz8igNIH7Lt+2WXV4GhUUbpgATAT X-Received: by 2002:a63:dc56:: with SMTP id f22mr28334244pgj.287.1618254413293; Mon, 12 Apr 2021 12:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618254413; cv=none; d=google.com; s=arc-20160816; b=stiz11vF94RUrE+bujCHxZbArYl3SFKYGgggqUuYobPsVWrKuoPraYqoKuC4SY38XI 3e+KdIkpVok8qHA+aNEIreV8HKdOEgyR5bcU7TAU/y7aLpyghnBiHpH9Y+wj2YRKTw7d cZHNOYYNc3bragVnvLvV0GrN4nDlzCPLo4fSlnZeoM7qQTPwSHajthOFf79W0YkTW64G KluQ60q7YfUktxCSI3R6XCVi11GlnCqT//3qBAv9TmiB5KjJDjB3GANR9gSHvJGtgJCu R/J+DAgOgaa43hFzAiupcjLvJzgtqC+OYAF7cdfw4MywImyM1lu5xyajUh5XPnxD4I/u 0j7w== 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=qFK3ymFR+8IkY/EyN1emVbVTfc7jJvlULyoMvBmBots=; b=H7sME3dD4SUrR7bWJR2eLMLT4si+CfY0I43w9Ks642GyVHuoCC8rTDBCq9X5+wUOGC p2KDrJ1SWEJV5HvuOxvuhhpDyglFpnYJn8Z0VnawJ31XoeO89dg4IihQNGcOvLktqN6c bM3ndF5yJcxasGRKgRk22pMH3Pfuq6EVJhtBPyiA4cINVqLyTR5HLnO1wdS+gUezB/0j WmMAsKPZQEGyRItBYbLdh5zwLqhERS2N1MMxCLPGlIp8ck3c5tjfS/E6Y5bpu2sLE4wJ NO/ws8fiqzMcygJVbyhr1TR/KFdjVW4I8opp58HV92vFV64NoJxiPue/TjnbeKZyvRv/ r8HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=Soa1Rlqo; 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 m15si14740479plx.61.2021.04.12.12.06.40; Mon, 12 Apr 2021 12:06:53 -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; dkim=pass header.i=@konsulko.com header.s=google header.b=Soa1Rlqo; 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 S237083AbhDLHtv (ORCPT + 99 others); Mon, 12 Apr 2021 03:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237081AbhDLHtv (ORCPT ); Mon, 12 Apr 2021 03:49:51 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B71EBC06138C for ; Mon, 12 Apr 2021 00:49:33 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id n138so19887284lfa.3 for ; Mon, 12 Apr 2021 00:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=qFK3ymFR+8IkY/EyN1emVbVTfc7jJvlULyoMvBmBots=; b=Soa1RlqoeN2pveBDhZJ7t62minjfgT/bCsZg0/EBGI558bQ/bao3frHXP0Rz7qclWJ XlL0cuJODa1mwy5dDSETOj5ECqGIfCVjJ14QfQ6C5VOOVsvvjSbiWgX64VQqQHkhUMIC eOC6tA7GhvnTU36knNTYZi4yN5tdqRic44hco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=qFK3ymFR+8IkY/EyN1emVbVTfc7jJvlULyoMvBmBots=; b=iYTeLsUZgmEgly0zQWhp88ZKFoaOo+/dPedJdI04T/mwHeqMxLyyGIi/M7fkRVx+oL JKlDM88cVlUHpRKCSzHDhE0+FMtAWs+vtrXTxdrOb3PDkgNvFoD/PfG+K/qZmNqZ5v6w S5bvjYVNjhDbkfRKTUaiySaTNM4mthlOepR8XaX6t7u/RhnVNBi2FluIlEqbO1au4RS5 7ma2vfle2/x6rLMg7qN368Y4KdsjNtwKv9zTaHX+A7lOMjH/2uEEugPUS2NRiUsRgq0o 0+a7TPH8cunc/+xlmS3ONcy5GXKTUnVDIMckDc7w7Lk2WM4PFATVZacQP3MGoMIi6Sev R1RA== X-Gm-Message-State: AOAM533CPvDEZ0zVvKkLHTlPLOI2fKvI4sMGTwzq+2Mb5KzvxJFofA4q lZAlPVcNHDjLuthKfhHkfq4WOXAXQ4SefqZ+txUUsA== X-Received: by 2002:ac2:59c2:: with SMTP id x2mr4535970lfn.407.1618213771658; Mon, 12 Apr 2021 00:49:31 -0700 (PDT) MIME-Version: 1.0 References: <20210409065115.11054-1-alex@ghiti.fr> <3500f3cb-b660-5bbc-ae8d-0c9770e4a573@ghiti.fr> In-Reply-To: From: Vitaly Wool Date: Mon, 12 Apr 2021 09:49:20 +0200 Message-ID: Subject: Re: [PATCH v7] RISC-V: enable XIP To: Alex Ghiti Cc: Mike Rapoport , David Hildenbrand , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , LKML , linux-arch@vger.kernel.org, Linux-MM 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 Mon, Apr 12, 2021 at 7:12 AM Alex Ghiti wrote: > > Le 4/9/21 =C3=A0 10:42 AM, Vitaly Wool a =C3=A9crit : > > On Fri, Apr 9, 2021 at 3:59 PM Mike Rapoport wrote= : > >> > >> On Fri, Apr 09, 2021 at 02:46:17PM +0200, David Hildenbrand wrote: > >>>>>> Also, will that memory properly be exposed in the resource tree as > >>>>>> System RAM (e.g., /proc/iomem) ? Otherwise some things (/proc/kcor= e) > >>>>>> won't work as expected - the kernel won't be included in a dump. > >>>> Do we really need a XIP kernel to included in kdump? > >>>> And does not it sound weird to expose flash as System RAM in /proc/i= omem? ;-) > >>> > >>> See my other mail, maybe we actually want something different. > >>> > >>>> > >>>>> 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 imple= ment this > >>>>> version then using memblock as you described. > >>>> > >>>> I'm not sure this is required. With XIP kernel text never gets into = RAM, so > >>>> it does not seem to require struct page. > >>>> > >>>> XIP by definition has some limitations relatively to "normal" operat= ion, > >>>> so lack of kdump could be one of them. > >>> > >>> I agree. > >>> > >>>> > >>>> I might be wrong, but IMHO, artificially creating a memory map for p= art of > >>>> flash would cause more problems in the long run. > >>> > >>> Can you elaborate? > >> > >> Nothing particular, just a gut feeling. Usually, when you force someth= ing > >> it comes out the wrong way later. > > > > It's possible still that MTD_XIP is implemented allowing to write to > > the flash used for XIP. While flash is being written, memory map > > doesn't make sense at all. I can't come up with a real life example > > when it can actually lead to problems but it is indeed weird when > > System RAM suddenly becomes unreadable. I really don't think exposing > > it in /proc/iomem is a good idea. > > > >>>> BTW, how does XIP account the kernel text on other architectures tha= t > >>>> implement it? > >>> > >>> Interesting point, I thought XIP would be something new on RISC-V (we= ll, at > >>> least to me :) ). If that concept exists already, we better mimic wha= t > >>> existing implementations do. > >> > >> I had quick glance at ARM, it seems that kernel text does not have mem= ory > >> map and does not show up in System RAM. > > > > Exactly, and I believe ARM64 won't do that too when it gets its own > > XIP support (which is underway). > > > > > memmap does not seem necessary and ARM/ARM64 do not use it. > > But if someone tries to get a struct page from a physical address that > lies in flash, as mentioned by David, that could lead to silent > corruptions if something exists at the address where the struct page > should be. And it is hard to know which features in the kernel depends > on that. > > Regarding SPARSEMEM, the vmemmap lies in its own region so that's > unlikely to happen, so we will catch those invalid accesses (and that's > what I observed on riscv). > > But for FLATMEM, memmap is in the linear mapping, then that could very > likely happen silently. > > Could a simple solution be to force SPARSEMEM for those XIP kernels ? > Then wrong things could happen, but we would see those and avoid > spending hours to debug :) > > I will at least send a v8 to remove the pfn_valid modifications for > FLATMEM that now returns true to pfn in flash. That sounds good to me. I am not very keen on spending 200K on struct pages for flash (we can think of this as of an option but I would definitely like to have the option to compile it out in the end), so let's remove pfn_valid and fix things that will eventually break, if some. Best regards, Vitaly