Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp106220pxy; Fri, 30 Apr 2021 01:11:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYnBuEL1L5tSggtwveviu6yXfQQa4ATaWhcrNmEMv2lcds8O8xVQaAm6ctrIu0Zoz1Vnbu X-Received: by 2002:a62:2cce:0:b029:21d:97da:833e with SMTP id s197-20020a622cce0000b029021d97da833emr3716226pfs.40.1619770273506; Fri, 30 Apr 2021 01:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619770273; cv=none; d=google.com; s=arc-20160816; b=giucdKSZFhfwU9payx1dR1Rj3zGTA3m9REkYre4/iIMhvajpc+YjieYTXqEe3SKXOZ iiw5skIsWajCWwL/2u4CbJ2Kzkp866ip3Y+1ZCDO4/hAys0ds4TvJMmRPXiAlAqBZfnb yLvgFIEui5Bxd5zP/FeMqud2YON8kt2TXCdU1O4aDS+CWj/pzsL73AlKrC8zASSKtxPt ZFNZNOWTfIsjrMNLZ4QYQlNXL/5Qr728hBU/sUAaa1Ab4UHTt3+FM/WuXN2pFR/7z4lH kNQZXGRGQSGhCRTVqr6e7fl3fXfWEmoCU7iW97nYG37M0K+orcUQo3QrryPFYg8lu+Yb UnSw== 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:references:cc :to:from:subject; bh=MjnBpm7YmGtZNaEIpsw9cH+Gt5V9+pXDtwyFlsNnTjc=; b=aaE7KYdsMCNWx+WBrAN+/PabbC3aafwbBbIP2HYgJm3ByYlzMuctL4kXOC+3wSEbRm 8ulMD+o/S6QvYX/6Dte1POFnFlFpz3gx4TIeLgA+op42t2WRGq0DA4ZY29ALLfjIOQou i2n7KzIRv15jfdXjusmUD7lUX5BREMCeIH11451iC4IMG0NDd6sM/FrPcf9P9PHlRSIY oTJa6UKLXW01mDCig55sPxHJYUqFNpJn05Sd0iODuAHf2aP2F+FVdgpnK2Ymw987NkxS Zx/XzFh2FWVNcCU5XTnH44rznGTuRz5W3LNwZ/5esw4q2e2XYymWzmjpvB97ZCcBhL/k zLRA== 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 u2si2787556pgp.556.2021.04.30.01.11.00; Fri, 30 Apr 2021 01:11:13 -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 S231150AbhD3IKG (ORCPT + 99 others); Fri, 30 Apr 2021 04:10:06 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:39079 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbhD3IKF (ORCPT ); Fri, 30 Apr 2021 04:10:05 -0400 Received: from [192.168.1.100] (lfbn-lyo-1-457-219.w2-7.abo.wanadoo.fr [2.7.49.219]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 172C6240020; Fri, 30 Apr 2021 08:09:14 +0000 (UTC) Subject: Re: [PATCH] riscv: Disallow to build XIP_KERNEL with SOC_SIFIVE From: Alex Ghiti To: Vitaly Wool Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , LKML References: <20210429084541.28083-1-alex@ghiti.fr> <1a4a0a88-6ff5-66ad-6819-53dd96f76849@ghiti.fr> Message-ID: <35b97408-328a-a9cd-1bb8-6758f42bde2d@ghiti.fr> Date: Fri, 30 Apr 2021 04:09:14 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <1a4a0a88-6ff5-66ad-6819-53dd96f76849@ghiti.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 4/29/21 ? 8:13 AM, Alex Ghiti a ?crit?: > Le 4/29/21 ? 5:11 AM, Vitaly Wool a ?crit?: >> On Thu, Apr 29, 2021 at 10:47 AM Alexandre Ghiti wrote: >>> >>> RISCV_ERRATA_ALTERNATIVE patches text at runtime which is not >>> possible when >>> the kernel is executed from the flash in XIP mode, and as the SIFIVE >>> errata must be fixed somehow, disallow to build a XIP kernel that >>> supports SIFIVE socs. >> >> Could you please hold off this patch for a bit? I will try to come up >> with an alternative solution. It should be possible to define a >> special section within the RW area and place the functions that need >> such patching there. >> Not that I like that much but at least we'll keep the ability to use >> XIP on SiFive. > > Ok, I'm wondering why I did not think of that...I'll give it a try just > to punish myself. > > Thanks Vitaly, > > Alex > I tried what you proposed and it works well, *callers* must be placed into this writable section in RAM and that's it, that may be more complicated if at some point the patched functions are generic but I think we can use an intermediate riscv function to patch instead or something else. The modifications I did only consist in putting alternative section in RAM and place the exception vector table in this section. If you can do the proper patch, I'll let you do it, otherwise I'll do that later as I have other things to do before. So Palmer you can drop this patch. Thanks again, >> >> Best regards, >> ??? Vitaly >> >>> Signed-off-by: Alexandre Ghiti >>> --- >>> ? arch/riscv/Kconfig.erratas | 2 +- >>> ? arch/riscv/Kconfig.socs??? | 1 + >>> ? 2 files changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/riscv/Kconfig.erratas b/arch/riscv/Kconfig.erratas >>> index d5d03ae8d685..9537dbd67357 100644 >>> --- a/arch/riscv/Kconfig.erratas >>> +++ b/arch/riscv/Kconfig.erratas >>> @@ -2,7 +2,7 @@ menu "CPU errata selection" >>> >>> ? config RISCV_ERRATA_ALTERNATIVE >>> ???????? bool "RISC-V alternative scheme" >>> -?????? default y >>> +?????? default y if !XIP_KERNEL >>> ???????? help >>> ?????????? This Kconfig allows the kernel to automatically patch the >>> ?????????? errata required by the execution platform at run time. The >>> diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs >>> index 00c2b205654c..9cb38bc9d7cd 100644 >>> --- a/arch/riscv/Kconfig.socs >>> +++ b/arch/riscv/Kconfig.socs >>> @@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE >>> >>> ? config SOC_SIFIVE >>> ???????? bool "SiFive SoCs" >>> +?????? depends on !XIP_KERNEL >>> ???????? select SERIAL_SIFIVE if TTY >>> ???????? select SERIAL_SIFIVE_CONSOLE if TTY >>> ???????? select CLK_SIFIVE >>> -- >>> 2.20.1 >>> >>> >>> _______________________________________________ >>> linux-riscv mailing list >>> linux-riscv@lists.infradead.org >>> http://lists.infradead.org/mailman/listinfo/linux-riscv >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv >> > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv