Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1416480pxy; Thu, 29 Apr 2021 06:44:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqtuevna4pvkJ0hFV5X2Ou9RaXT0PoQ9E9USr+FsLCBENeXc7j2IBUAVIigL1ByD9OQuJY X-Received: by 2002:a50:fc0b:: with SMTP id i11mr18821886edr.259.1619703880227; Thu, 29 Apr 2021 06:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619703880; cv=none; d=google.com; s=arc-20160816; b=Emlcg1HOzbyrg2p9h6/IPgkwCSyCTrlJqyjnJlcDuZsIhIs0gJGqNGn+SEIv9MWCJR H6x27N9v2YJ+eYBQp7OD07PfF24FvMohOvL+9d9weOI6IPjG7cA0Vod2zIEqdDQZBTCe 0JDqJFPt4Z95dBJRnpVZgBOZFxUxu71MTNS3S3AwX/WIioR03sCDTaNbsJyyae6I0MPD cCg0qoNEgGbJmevz8d1wMo3+Rq63agVLcd8KVgs8CfzK6tID5Yfq9Ou75fvKHKoU+yzP rKZBLG+qrulOgheVRp1BQl2iGmPyrpqbLi6ttfE3BPjy3ysA4/SXa2jDbWRih0vyCeQx WviA== 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=XZER40fbm0StF/i9ee6KEEUSzD8I796XUa9Elf7XvI4=; b=zTHURfUAxQhU6nsx+9LIw27RKTJxiirRcEhhAlvOp2tXN8SwXF+3BIx5UlU9pvs/pi yKhEqQvW5V4W60zv6cudErCEF5HZiVtLMpuaTTNJ8XiWNL4aQDaRAgilYYSu/DUtlNet uow0HUrqGOXt2QykkJGBxfXwek69Rx0of0dKZt0P7iSH18uxpB9fFmtZniFHoRuxfqMf FjfQtJq7E/eqjPGvxdlUI7IKKSlfSTVj5OYMnww/9n668wTCAtBiftniaYeqjBc1OAyZ VHpHyYAh/x/5IDMNqOsWZ/II4rdtGBqslnEFcsXYireJoFYmB/Q59cTOhFHhgkFqfqkg yE/g== 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 s7si9241ejd.402.2021.04.29.06.44.16; Thu, 29 Apr 2021 06:44:40 -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 S236514AbhD2Nn6 (ORCPT + 99 others); Thu, 29 Apr 2021 09:43:58 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:54285 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbhD2Nn5 (ORCPT ); Thu, 29 Apr 2021 09:43:57 -0400 X-Originating-IP: 2.7.49.219 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 relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 934956000F; Thu, 29 Apr 2021 13:43:06 +0000 (UTC) Subject: Re: [PATCH v2] RISC-V: Always define XIP_FIXUP To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: Paul Walmsley , aou@eecs.berkeley.edu, Atish Patra , akpm@linux-foundation.org, rppt@kernel.org, Anup Patel , wangkefeng.wang@huawei.com, vitaly.wool@konsulko.com, greentime.hu@sifive.com, 0x7f454c46@gmail.com, chenhuang5@huawei.com, linux-kernel@vger.kernel.org, kernel-team@android.com, Palmer Dabbelt , Guenter Roeck References: <20210428214512.551153-1-palmer@dabbelt.com> From: Alex Ghiti Message-ID: Date: Thu, 29 Apr 2021 09:43:05 -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: <20210428214512.551153-1-palmer@dabbelt.com> 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/28/21 ? 5:45 PM, Palmer Dabbelt a ?crit?: > From: Palmer Dabbelt > > XIP depends on MMU, but XIP_FIXUP is used throughout the kernel in > order to avoid excessive ifdefs. This just makes sure to always define > XIP_FIXUP, which will fix MMU=n builds. XIP_OFFSET is used by assembly > but XIP_FIXUP is C-only, so they're split. > > Fixes: 44c922572952 ("RISC-V: enable XIP") > Reported-by: Guenter Roeck > Signed-off-by: Palmer Dabbelt > --- > Changes since v1: > > * Clean up the commit text. > * Define XIP_OFFSET for assembly. > --- > arch/riscv/include/asm/pgtable.h | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > index 2f1384e14e31..9469f464e71a 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -73,18 +73,10 @@ > #endif > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > +#endif > + > #ifdef CONFIG_XIP_KERNEL > #define XIP_OFFSET SZ_8M > -#define XIP_FIXUP(addr) ({ \ > - uintptr_t __a = (uintptr_t)(addr); \ > - (__a >= CONFIG_XIP_PHYS_ADDR && __a < CONFIG_XIP_PHYS_ADDR + SZ_16M) ? \ > - __a - CONFIG_XIP_PHYS_ADDR + CONFIG_PHYS_RAM_BASE - XIP_OFFSET :\ > - __a; \ > - }) > -#else > -#define XIP_FIXUP(addr) (addr) > -#endif /* CONFIG_XIP_KERNEL */ > - > #endif > > #ifndef __ASSEMBLY__ > @@ -101,6 +93,17 @@ > #include > #endif /* CONFIG_64BIT */ > > +#ifdef CONFIG_XIP_KERNEL > +#define XIP_FIXUP(addr) ({ \ > + uintptr_t __a = (uintptr_t)(addr); \ > + (__a >= CONFIG_XIP_PHYS_ADDR && __a < CONFIG_XIP_PHYS_ADDR + SZ_16M) ? \ > + __a - CONFIG_XIP_PHYS_ADDR + CONFIG_PHYS_RAM_BASE - XIP_OFFSET :\ > + __a; \ > + }) > +#else > +#define XIP_FIXUP(addr) (addr) > +#endif /* CONFIG_XIP_KERNEL */ > + > #ifdef CONFIG_MMU > /* Number of entries in the page global directory */ > #define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t)) > XIP_KERNEL works now and !MMU compiles so you can add: Tested-by: Alexandre Ghiti Thanks!