From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E004EB64DD for ; Tue, 25 Jul 2023 06:07:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97B0C6B007B; Tue, 25 Jul 2023 02:07:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92CAA6B007D; Tue, 25 Jul 2023 02:07:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81B588E0002; Tue, 25 Jul 2023 02:07:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 71FB86B007B for ; Tue, 25 Jul 2023 02:07:49 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3BE321A0C98 for ; Tue, 25 Jul 2023 06:07:49 +0000 (UTC) X-FDA: 81049103058.27.C7CEEA3 Received: from out-11.mta1.migadu.com (out-11.mta1.migadu.com [95.215.58.11]) by imf26.hostedemail.com (Postfix) with ESMTP id 3E710140015 for ; Tue, 25 Jul 2023 06:07:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Z1mmOZtv; spf=pass (imf26.hostedemail.com: domain of enze.li@linux.dev designates 95.215.58.11 as permitted sender) smtp.mailfrom=enze.li@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690265266; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9RhR3Z+kw1Y/Wd/w+yq7BdbxI7CNxW0pkaVU5PxwFqo=; b=KULE6lGXnYTYqyX+S01lRQmxuZuoZHG15o2LJGCCA3LLOuZ/RQbYj7FW8Q3SlclITXQXEB 6T+8rXX+63XcyZYZgJGpWbBmDlMh4L+YpF5Yuf5nqyYri2gUHp5VC4BEIR25TDSvm8c4iL 2GHODoeOW31ppse7KexEy3Yguy2PjuU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690265266; a=rsa-sha256; cv=none; b=OdR55l4CCUY587sXow6L1b6nhO/r4bC3cvCyR1ej4bjK16Z25CrqfZoI94ky7rdeeLwvhS uTNkt8w5GGsInATY/4A5Csi3FB/OnVUQ43VeQJUlri47UASC7qtWpR2RG5Gyahi3eZCDig 7x6PuYFIEYoS2HzAlHmeQqJ6dLjdIx0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Z1mmOZtv; spf=pass (imf26.hostedemail.com: domain of enze.li@linux.dev designates 95.215.58.11 as permitted sender) smtp.mailfrom=enze.li@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690265264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9RhR3Z+kw1Y/Wd/w+yq7BdbxI7CNxW0pkaVU5PxwFqo=; b=Z1mmOZtv2jbqNze2prcEPMtDaBP+yh6AcU5wgRgGPLE53INartfSH86VP3UTVDg6Sd9/Mv 9AlKlsmDHJZyemDn2KQjK5RIfe6w7ygPEqi+vSfVhn2nOF5BcFYNaFs1h5KW6yureqQxL1 UeHKGIvS3VQGsfoNxCHnlyImPxX6HBo= From: Enze Li To: Huacai Chen Cc: Enze Li , kernel@xen0n.name, loongarch@lists.linux.dev, glider@google.com, elver@google.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, zhangqing@loongson.cn, yangtiezhu@loongson.cn, dvyukov@google.com Subject: Re: [PATCH 1/4] LoongArch: mm: Add page table mapped mode support In-Reply-To: (Huacai Chen's message of "Tue, 25 Jul 2023 10:06:01 +0800") References: <20230719082732.2189747-1-lienze@kylinos.cn> <20230719082732.2189747-2-lienze@kylinos.cn> <87pm4mf1xl.fsf@kylinos.cn> <87lef7ayha.fsf@kylinos.cn> Date: Tue, 25 Jul 2023 14:07:27 +0800 Message-ID: <87bkg0zfq8.fsf@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 3E710140015 X-Rspam-User: X-Stat-Signature: ckwmsbjwsh4btpmuxp3q7mkqcz4f5ki4 X-Rspamd-Server: rspam03 X-HE-Tag: 1690265265-431534 X-HE-Meta: U2FsdGVkX1+dc1WfNBXomvdDA6jfMIFEX+w6hze9ECT0EkJJDlQKpx6rHOHCp7h1w5ZDQuvD9ycM9RENWVOw8GS8kGVoGapm5yi3BJi86lTLuFRdbhAyMPMxc5wxciW8A4cwyebULy0N+R7/HkO+8/16RHqgnydZbuO9qc9900mQ9uFkNmmazHDShz6asQ9LS4+e2r1hZfn3sPR5kgT8KcAZEYtyykhlhIWWiWyDTrNL0pR2UcUL+lge+e+yVdQMo+P+zNQkyVJ3HCqfxgB8914hkkVFimYtjqzBXkBlB0x/J3+168995nEuXQpm+0L9i6gLl4QUFhs74j7bQ0jFGyvc5eifTGiEjQj5Ad6w5sRCaArR+waMO//iKxLw7knM4HJYraCLP1U7qbmCnh07A2rKJZb6FWCpMNgP8nsR1SdhZlk9fnHDEOVV4IFBoeDYaGuefvuNbgkm0TiyBsUBCxHGohzfx2Ij9Dc/Gx2Vj0DwH18aSNpPtAzsHT6pehj1fpMeLuuQrzX+1IRgcKgQ5xvCKRnFqGkBgsSLrvfJYsIC2tWcg95avDFZpE5Sb9pF6tDKtvet3YmWLtRFw3lGoYU1Sq4mhWHClRzpQuE0MAdz4zC9ETCEJDnyQ7tf604bYT5ZaCLgOxrStIwGlOMACJIfiC+weNKSubDL1h1+q4zWNnNd4pMjgPGZqMlYnvynImGEn6CNP9c/7VEm66lHmK9dfXbjWu8jhJHjjhhk9t9Gwf8WPZNVjtUB7wS9J6acylOky69dXqP7yisRkK4GZNWNK1BYpCXFKeXqC1Mnvst/lfetVTuTAW4fAlOWGNDlqJ6MMfTlVtncEFFMq0yzUi65rdpGkcL9jRUbGgfgjiZB/r5k/R8aWwV3SjB0aO8SwCjyrt9EdO4l5TDc1r7RcISByPqnBfhyPYXDYJA+xDxVzZII/cYV8+WaNHebDPxMEmVMomoyMQUZT7eDeDH HBp3ZGJA 6nfwHgftN2pJG6Z+ZOt4HKrwRexQ9k98OK1qUV2ICe+ivnb23dUfJbkkjg0EjVoXo0yoEXfZe4vWLHBeZVwIn56JeSQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jul 25 2023 at 10:06:01 AM +0800, Huacai Chen wrote: > On Sun, Jul 23, 2023 at 3:17=E2=80=AFPM Enze Li wrote: >> >> On Fri, Jul 21 2023 at 10:21:38 AM +0800, Huacai Chen wrote: >> >> > On Fri, Jul 21, 2023 at 10:12=E2=80=AFAM Enze Li w= rote: >> >> >> >> On Wed, Jul 19 2023 at 11:29:37 PM +0800, Huacai Chen wrote: >> >> >> >> > Hi, Enze, >> >> > >> >> > On Wed, Jul 19, 2023 at 4:34=E2=80=AFPM Enze Li = wrote: >> I've also tried to include mm_types.h in advance, but in this case that >> doesn't work because the _LINUX_MM_TYPES_H macro already exists. >> The "forward declaration" was also taken into account, in the end it was >> found to be unavailable as well. >> >> In summary, I'm afraid that rewriting tlb_virt_to_page in asm/page.h as >> a macro or inline function is not possible. The root case of this is >> that both 'struct mm_struct' and 'virt_to_kpte' belong to high-level >> data structures, and if they are referenced in asm/page.h at the >> low-level, dependency problems arise. >> >> Anyway, we can at least define it as a normal function in asm/pgtable.h, >> is that Okay with you? >> >> It may be a bit wordy, so please bear with me. In addition, all of the >> above is my understanding, am I missing something? > Well, you can define the helpers in .c files at present, but I have > another question. > > Though other archs (e.g., RISC-V) have no DMW addresses, they still > have linear area. In other words, both LoongArch and RISC-V have > linear area and vmalloc-like areas. The only difference is LoongArch's > linear area is DMW-mapped but RISC-V's linear area is TLB-mapped. > > For linear area, the translation is pfn_to_page(virt_to_pfn(kaddr)), > no matter LoongArch or RISC-V; > For vmalloc-like areas, the translation is > pte_page(*virt_to_kpte(kaddr)), no matter LoongArch or RISC-V. > Hi Huacai, Thanks for your reply. > My question is: why RISC-V only care about the linear area for > virt_to_page(), but you are caring about the vmalloc-like areas? This patch is a preparation to make LoongArch support KFENCE. One of the core principles of KFENCE is that pages are tagged in the PTE and then synchronized to the TLB. When the MMU detects an improper access, it can generate an interrupt signal, which is subsequently handled by a handler function (kfence_handle_page_fault) provided by KFENCE. In short, KFENCE requires the support of the TLB. There's no need to take this into account on RISC-V because TLB mapping is already supported in linear area. Best Regards, Enze > > Huacai