From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D9AC6D8062F for ; Tue, 6 Feb 2024 16:45:57 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=aFNYFw+Wnjs1cKkKV65l0dKrIl+BEJmRz9Lw15y4lvg=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707237956; v=1; b=CgfRyoXJiHjg6jTeCTBc0we/hneS8MeKCQGNMlihrrKfmpq8iaFPE3o9kZ86MVmc7yuF+nhH OFhnJtML060KZsZtSQJGVhnpMWWxtNglO2D4ViYM2PWr7qt5zIBkhVo8Au/JVuM2ODbQDRaPg9l fFrGrlVVwTXRuBl/4/egak0E= X-Received: by 127.0.0.2 with SMTP id iSDmYY7687511x3pLeDxfQjV; Tue, 06 Feb 2024 08:45:56 -0800 X-Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) by mx.groups.io with SMTP id smtpd.web11.26154.1707237955735549329 for ; Tue, 06 Feb 2024 08:45:55 -0800 X-Received: by mail-ua1-f53.google.com with SMTP id a1e0cc1a2514c-7d2e15193bbso2880201241.0 for ; Tue, 06 Feb 2024 08:45:55 -0800 (PST) X-Gm-Message-State: UHcTe0xvHmPcrs1YDNNXHLhAx7686176AA= X-Google-Smtp-Source: AGHT+IFRJUR06Nv5rUNwHDFUyCnxiUw0Er84vFNf821pD0QOFghWQklDJ6FJ2kk5VRaxHoVjJD6Fecq7j3qGFMsmGGI= X-Received: by 2002:a67:ba12:0:b0:46d:2d96:c439 with SMTP id l18-20020a67ba12000000b0046d2d96c439mr150538vsn.0.1707237954718; Tue, 06 Feb 2024 08:45:54 -0800 (PST) MIME-Version: 1.0 References: <20240126062715.3099433-1-lichao@loongson.cn> <20240126062919.3101691-1-lichao@loongson.cn> <3fe0fda8-d32e-679e-2f71-6cc35e7772b8@redhat.com> <17B0898B4883051D.13964@groups.io> <6914d79c-582a-4108-b733-7d5b15537ab4@loongson.cn> In-Reply-To: From: "Pedro Falcato" Date: Tue, 6 Feb 2024 16:45:43 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH v8 14/37] UefiCpuPkg: Add CpuMmuLib to UefiCpuPkg To: Laszlo Ersek Cc: devel@edk2.groups.io, lichao@loongson.cn, Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Baoqi Zhang , Dongyan Qian , Xianglai Li , Bibo Mao , Andrew Fish , "Kinney, Michael D" , Leif Lindholm Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=CgfRyoXJ; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) On Tue, Feb 6, 2024 at 2:32=E2=80=AFPM Laszlo Ersek wro= te: > > On 2/6/24 03:57, Chao Li wrote: > > Hi Pedro, Laszlo, > > > > I have double-check this patch and I'd like to point out the following: > > > > 1. Some of the code in this patch actually refers to the Linux kernel. > > But only used the name of kernel code , such as PUD, PMD, PTE, Swapper > > Page Dir, etc. > > > > 2. Refer to the LoongArch TLB rules, if we use the multi-level page > > table to search and filling, the usual logic is as follows: > > > > a. Get the first level page table, called PGD, in reigster PGDL or = PGDH. > > > > b. PGD will index the 2st Dir, and the 2st Dir will index the 3st > > Dir, and so on. > > > > c. We would like to use the four-level page table, because if we us= e > > two- or three-level page tables, the page tables will larger and must b= e > > continuous, so we think the four-level is better(Linux kernel also uses > > the four-level page tables). > > > > d. LoongArch paging logic is shown in the image below(URL: > > https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.ht= ml#memory-management-of-page-table-mapping): > > > > Referring to the above, should I use the old logic, rewrite the Linux > > kernel-like code to EFI style and clean up some unused code and redesig= n > > the PEI library, it that OK? > > I don't like the expression "rewrite the Linux kernel-like code to EFI > style". > > You should not start with, or incorporate, anything that comes from > Linux. Whatever you do, make sure it is not a derivative of Linux. Don't > *derive* your edk2 contribution from Linux code. > > I think you are fine to implement any paging logic you prefer, as long > as you start with an empty source file, and consult only the public > LoongArch architecture specs, plus the rest of edk2 while writing the cod= e. > > Consider the current source files from this patch "tainted". I don't > encourage a piecemeal approach on this, "replace this", "rewrite that". > The files look like they are a derivative of Linux code, so any further > modifications in these files will just result in more derived code. > Let's not play "where does this line come from" games. Scrap it all; > implement it again from the ground up, using only the public arch specs. > > Just my opinion. > Laszlo I completely agree. Note that (AFAIK) you can also consult other *license-compatible* code (BSD licenses, MIT, ISC, whatever). --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115183): https://edk2.groups.io/g/devel/message/115183 Mute This Topic: https://groups.io/mt/103971653/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-