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 0A526D81194 for ; Wed, 31 Jan 2024 10:33:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=H/+LdiFbgXZmSXtLaIVBSNnuKBMdgHXhDa4WGLNcWwk=; 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=1706697223; v=1; b=tDlwE7g3RyRT4WHpvdoJroG+XOAu6kBnLBZPeTa8f2IU3Z13yD/LiBGo9UoAPL0fSAW9yLuw qcareBSLaUKr8FxhJyPoTjPIVqBDmIwdrUqrwmU9L32ztsXdghkAOBAJmWQvHCgbIvjUM9Fj0w1 P3ZTlEYaQHkQeJiMoGqDqXh0= X-Received: by 127.0.0.2 with SMTP id AfKCYY7687511xoQkNAzD8cm; Wed, 31 Jan 2024 02:33:43 -0800 X-Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) by mx.groups.io with SMTP id smtpd.web10.11141.1706697222876556929 for ; Wed, 31 Jan 2024 02:33:43 -0800 X-Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-7d6104e6c7aso174862241.2 for ; Wed, 31 Jan 2024 02:33:42 -0800 (PST) X-Gm-Message-State: VZKoftIrlCQxsXCzlwWpUFqPx7686176AA= X-Google-Smtp-Source: AGHT+IF3rQh7DYbC5C8g7V7/XilKZ0N56Ng0k6Vz3goiuut4uGrgAWGZ7TCyjn8Bn8UImc05pWozdSsGTM/pjja+o2U= X-Received: by 2002:a05:6122:4c03:b0:4b6:cb66:778c with SMTP id ff3-20020a0561224c0300b004b6cb66778cmr847772vkb.16.1706697221650; Wed, 31 Jan 2024 02:33:41 -0800 (PST) MIME-Version: 1.0 References: <20240126062715.3099433-1-lichao@loongson.cn> <20240126062919.3101691-1-lichao@loongson.cn> In-Reply-To: <20240126062919.3101691-1-lichao@loongson.cn> From: "Pedro Falcato" Date: Wed, 31 Jan 2024 10:33:30 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH v8 14/37] UefiCpuPkg: Add CpuMmuLib to UefiCpuPkg To: devel@edk2.groups.io, lichao@loongson.cn Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Gerd Hoffmann , Baoqi Zhang , Dongyan Qian , Xianglai Li , Bibo Mao 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=tDlwE7g3; 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 Fri, Jan 26, 2024 at 6:29=E2=80=AFAM Chao Li wrote: > > Add a new library named CpuMmuLib and add a LoongArch64 instance with in > the library. > It provides two-stage MMU libraryinstances, PEI and DXE. > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4584 >[...] > diff --git a/UefiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c b/Ue= fiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c > new file mode 100644 > index 0000000000..2e852c3371 > --- /dev/null > +++ b/UefiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c > @@ -0,0 +1,988 @@ > +/** @file > + > + CPU Memory Map Unit Handler Library common functions. > + > + Copyright (c) 2024 Loongson Technology Corporation Limited. All rights= reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > + @par Glossary: > + - Pgd or Pgd or PGD - Page Global Directory > + - Pud or Pud or PUD - Page Upper Directory > + - Pmd or Pmd or PMD - Page Middle Directory > + - Pte or pte or PTE - Page Table Entry > + - Val or VAL or val - Value > + - Dir - Directory > +**/ Wow, this is one of the most bizarre patches I've seen in EDK2. You took essentially Linux code (and the Linux way of doing paging) and EDK2-ify'd it. Congrats, this is cursed. You even include the way they botched what a "PTE" means back in Linux 1.0. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "Tlb.h" > +#include "Page.h" > + > +#define SWAP_PAGE_DIR CsrRead(LOONGARCH_CSR_PGDL) swapper_pg_dir? :P You should seriously unscrew this patch's cursedness: disambiguate pte_t and pteval_t (I would suggest having a PTABLE (for the lower level page table) and a PTE for their entries), and... rename swapper_pd_dir which makes no sense in this EFI firmware context, where swapper is a really old, traditional UNIX name. > +BOOLEAN mMmuInited =3D FALSE; Should probably be a STATIC, you also don't need to explicitly init it to FALSE, as it's a static duration variable. --=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 (#114877): https://edk2.groups.io/g/devel/message/114877 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-