Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5351740rwp; Mon, 17 Jul 2023 02:31:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEGEWvumqBdyAjaqjonDvf3il9Pioayu9lsVmJ9vT77e/+orTsSpYbKDw4B9IyMQUN5RyP4 X-Received: by 2002:a05:651c:14a:b0:2b9:3916:3fad with SMTP id c10-20020a05651c014a00b002b939163fadmr2046492ljd.22.1689586304433; Mon, 17 Jul 2023 02:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689586304; cv=none; d=google.com; s=arc-20160816; b=Y2FJG02b4pTop1WG04TuT+tMnCYWwfyrNHPTHGxrtCaUDBDZtqwYGdalk2Y/hr22cF LoBx9Ei5Qz44sF1zCNZbsQpU8BrzUtk2RnsSidtoMxjEfw6AgVI4/M+sexsOw/Gw0cP5 DBAy+G41RejQ/xWcSIS1j641bk9zpkdWO9SufNh3xrWQGN/SzsemT8awp9ZeiEJv2g3X KhqW7nbqAJASsZmaDV0YgJu7nO0fk8XvFbYkDXV6O1Jddvs2xtN4OxUXYcw9BPFmAi9Z dfuA715A+orwrlDT1aqRoKjrX47VdQaZm+JE3zjyJdOWkAlTG343gLpfoh4/hGL77VwI QnGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=0ycp8JgGzKbI11o2rnnlhYDaxbS+CHs6gJI2s0EE2fc=; fh=E8o3RS7ID98D822CXYnigpZkQl9WKwQos8YVyvpInqQ=; b=NN8MMZnZsvOXv32k/r0/RPifAc/0y5nRh7P9jSjLCQRSAuB+14bkOoIzT1CooI74xn oS/HQ4Ro7mDrDOEuF6xSLhv7GouLX+h2OHNhuwzkBxqTEw7OBW8Er5TThmjoir6MSvEm 4Y0v/Z2ZSHEP2HbRgfKi8804V+SGLuZo1xCdqRMAfyv2eAwvqj9Hunjvw6ks2JCAORgt gEb8fZYYZTNee146X1o5dPGcDemeZRUlfyNDRWCkirGlvUAbgODPVpulQH8z4HLf2wB5 u7IwGQAEAE4lMMt0Ti0u48FFBDo+HK3TxORsZT0euycZxXFUtioi8+/j5TxafYyN5y1s Pshw== ARC-Authentication-Results: i=1; mx.google.com; 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 lf12-20020a170907174c00b009934d29d956si4231840ejc.92.2023.07.17.02.31.20; Mon, 17 Jul 2023 02:31:44 -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; 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 S229928AbjGQJHW (ORCPT + 99 others); Mon, 17 Jul 2023 05:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjGQJHU (ORCPT ); Mon, 17 Jul 2023 05:07:20 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE201E55; Mon, 17 Jul 2023 02:07:18 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9DA961C0012; Mon, 17 Jul 2023 09:07:13 +0000 (UTC) Message-ID: Date: Mon, 17 Jul 2023 11:07:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] riscv: Add HAVE_IOREMAP_PROT support To: guoren@kernel.org, palmer@rivosinc.com, paul.walmsley@sifive.com, falcon@tinylab.org, bjorn@kernel.org, conor.dooley@microchip.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren References: <20230716152033.3713581-1-guoren@kernel.org> Content-Language: en-US From: Alexandre Ghiti In-Reply-To: <20230716152033.3713581-1-guoren@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guo, On 16/07/2023 17:20, guoren@kernel.org wrote: > From: Guo Ren > > Add pte_pgprot macro, then riscv could have HAVE_IOREMAP_PROT, > which will enable generic_access_phys() code, it is useful for > debug, eg, gdb. I don't understand, we already have the generic ioremap_prot() implementation since we select GENERIC_IOREMAP: shouldn't HAVE_IOREMAP_PROT imply that we have our own implementation? Thanks, Alex > Because generic_access_phys() would call ioremap_prot()-> > pgprot_nx() to disable excutable attribute, add definition > of pgprot_nx() for riscv. > > Signed-off-by: Guo Ren > Signed-off-by: Guo Ren > --- > .../features/vm/ioremap_prot/arch-support.txt | 2 +- > arch/riscv/Kconfig | 1 + > arch/riscv/include/asm/pgtable.h | 15 +++++++++++++++ > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/Documentation/features/vm/ioremap_prot/arch-support.txt b/Documentation/features/vm/ioremap_prot/arch-support.txt > index a24149e59d73..ea8c8a361455 100644 > --- a/Documentation/features/vm/ioremap_prot/arch-support.txt > +++ b/Documentation/features/vm/ioremap_prot/arch-support.txt > @@ -21,7 +21,7 @@ > | openrisc: | TODO | > | parisc: | TODO | > | powerpc: | ok | > - | riscv: | TODO | > + | riscv: | ok | > | s390: | ok | > | sh: | ok | > | sparc: | TODO | > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 4c07b9189c86..15900fa20797 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -117,6 +117,7 @@ config RISCV > select HAVE_FUNCTION_ERROR_INJECTION > select HAVE_GCC_PLUGINS > select HAVE_GENERIC_VDSO if MMU && 64BIT > + select HAVE_IOREMAP_PROT > select HAVE_IRQ_TIME_ACCOUNTING > select HAVE_KPROBES if !XIP_KERNEL > select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > index 75970ee2bda2..c9552a161f90 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -415,6 +415,11 @@ static inline pte_t pte_mkhuge(pte_t pte) > return pte; > } > > +static inline pgprot_t pte_pgprot(pte_t pte) > +{ > + return __pgprot(pte_val(pte) & ~_PAGE_PFN_MASK); > +} > + > #ifdef CONFIG_NUMA_BALANCING > /* > * See the comment in include/asm-generic/pgtable.h > @@ -573,6 +578,16 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, > return ptep_test_and_clear_young(vma, address, ptep); > } > > +#define pgprot_nx pgprot_nx > +static inline pgprot_t pgprot_nx(pgprot_t _prot) > +{ > + unsigned long prot = pgprot_val(_prot); > + > + prot &= ~_PAGE_EXEC; > + > + return __pgprot(prot); > +} > + > #define pgprot_noncached pgprot_noncached > static inline pgprot_t pgprot_noncached(pgprot_t _prot) > {