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 531979411AF for ; Fri, 15 Mar 2024 09:34:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Big0Rrrb/2hYmGWe45fOGlVgxPqB3k/4dOD3Ybg4gBQ=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1710495291; v=1; b=ljhrxy+Brf6WI/GT/ya+469jOrgRfI1DNgvMwZLoC9X18kVi+xLH0EzStHvMyWFq7ttYRm8O rrpp6U+wXqW88Fy/SXrepWOnTkMZh/VaSmnrl5m/UUdkUkr+vT9Nt4719ORXxybxhNHaUIja10Z pY+pL0OcgOkcz4Hmvhmo1xfC65QgVCEWqv5E0+ZOjXcitGelMvanpl+BZcbeamFEeaNF4u7woUT h4KeREwZCyonTlci7gLxgHrfx3GwImqqvlzXs+Yx8/a9OxtdwRgpMYA9glbp7tSJ+/xTAX0jejb VKeKPKzLHG0kQB0FKcKkj4zYoMaHCE9n9922rXv5bhduQ== X-Received: by 127.0.0.2 with SMTP id rGpHYY7687511xwUHff5AWj2; Fri, 15 Mar 2024 02:34:51 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.17462.1710495290123017677 for ; Fri, 15 Mar 2024 02:34:50 -0700 X-Received: from loongson.cn (unknown [10.40.24.149]) by gateway (Coremail) with SMTP id _____8BxyuhBFfRlMmsZAA--.41767S3; Fri, 15 Mar 2024 17:30:42 +0800 (CST) X-Received: from [10.40.24.149] (unknown [10.40.24.149]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxnhM7FfRlztJaAA--.53036S3; Fri, 15 Mar 2024 17:30:35 +0800 (CST) Message-ID: <3876d014-48b4-44d3-bf77-f41dc5d11b72@loongson.cn> Date: Fri, 15 Mar 2024 17:30:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 09/26] UefiCpuPkg: Added a new PCD named PcdCpuMmuIsEnabled To: devel@edk2.groups.io, kraxel@redhat.com Cc: Ray Ni , Rahul Kumar References: <20240311093631.1251466-1-lichao@loongson.cn> <20240311093817.1253752-1-lichao@loongson.cn> From: "Chao Li" In-Reply-To: X-CM-TRANSID: AQAAf8BxnhM7FfRlztJaAA--.53036S3 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQARCGX0BucBaAABsA X-Coremail-Antispam: 1Uk129KBj93XoW7Cw4Dury3Ar1ktryDCr43twc_yoW8tr1Dpr 4kZryDKa4kKF1I9rW8JryUXr1SyFW0yFyUGFyqkw48tF4xJ3Zag3Z2krW7Kay7Ka9IvF4U ZF45t34UZrW7u3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJUUUyKb4IE77IF4wAF F20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r 1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAF wI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1UM2AIxVAIcxkEcVAq 07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1lYx0E2Ix0cI8IcVAFwI0_Jrv_JF 1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCj r7xvwVCIw2I0I7xG6c02F41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr 1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE 14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7 IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E 87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73Uj IFyTuYvjxUw6pBDUUUU X-Gw-Check: 35eccaf8ce65f800 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 Resent-Date: Fri, 15 Mar 2024 02:34:50 -0700 Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: aAdgr7B6rRlWQ3TX2MgW0aiEx7686176AA= Content-Type: multipart/alternative; boundary="------------w0wfmEQTJ6UMj7tjmo9dpZYq" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=ljhrxy+B; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --------------w0wfmEQTJ6UMj7tjmo9dpZYq Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Gerd, Thanks, Chao On 2024/3/15 17:09, Gerd Hoffmann wrote: > On Mon, Mar 11, 2024 at 05:38:17PM +0800, Chao Li wrote: >> Added PcdCpuMmuIsEnabled to instruct that the CPU MMU is enabled. >> >> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D4584 >> >> Cc: Ray Ni >> Cc: Rahul Kumar >> Cc: Gerd Hoffmann >> Signed-off-by: Chao Li >> --- >> UefiCpuPkg/UefiCpuPkg.dec | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec >> index a23a90ec99..b27cf88aee 100644 >> --- a/UefiCpuPkg/UefiCpuPkg.dec >> +++ b/UefiCpuPkg/UefiCpuPkg.dec >> @@ -486,5 +486,10 @@ [PcdsDynamic, PcdsDynamicEx] >> # @Prompt GHCB Hypervisor Features >> gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures|0x0|UINT64|0x600= 00018 >> =20 >> + ## This dynamic PCD indicates whether CPU MMU is enabled. >> + # TRUE - CPU MMU is enabled. >> + # FASLE - CPU MMU have not enabled. >> + gUefiCpuPkgTokenSpaceGuid.PcdCpuMmuIsEnabled|FALSE|BOOLEAN|0x60000023 > Why create a PCD for this? Can't you simply read the control register > to figure whenever paging is enabled or not? This is a good question. When I designed the API of=20 SetMemoryRegionAttributes, it only contained 4 parameters, namely Start,=20 Size, Attribut and Mask(refer to ARM version), and the MmuInitLib needs=20 call this API to configure or initialize the MMU.=20 SetMemoryRegionAttributes will call a private function called=20 UpdateRegionMapping, it needs to know if the MMU is started to do=20 different logic(such as wether should be invalidated TLB when filling=20 the tables for the first time, etc), therefore, there create a new PCD=20 to let it know this. BTW, ARM and RISC-V have the same logic. > > take care, > Gerd > > > >=20 > -=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 (#116793): https://edk2.groups.io/g/devel/message/116793 Mute This Topic: https://groups.io/mt/104859880/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- --------------w0wfmEQTJ6UMj7tjmo9dpZYq Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Hi Gerd,


=
Thanks,
Chao
On 2024/3/15 17:09, Gerd Hoffmann wrote:
On Mon, Mar 11, 2024 at 05:38:=
17PM +0800, Chao Li wrote:
Added PcdCpuMmuIsEnabled to =
instruct that the CPU MMU is enabled.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=
=3D4584

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
---
 UefiCpuPkg/UefiCpuPkg.dec | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index a23a90ec99..b27cf88aee 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -486,5 +486,10 @@ [PcdsDynamic, PcdsDynamicEx]
   # @Prompt GHCB Hypervisor Features
   gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures|0x0|UINT64|0x6000001=
8
=20
+  ## This dynamic PCD indicates whether CPU MMU is enabled.
+  #  TRUE  - CPU MMU is enabled.
+  #  FASLE - CPU MMU have not enabled.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMmuIsEnabled|FALSE|BOOLEAN|0x60000023
Why create a PCD for this?  Can't you simply read the control register
to figure whenever paging is enabled or not?
This is a good question. When I designed the API of SetMemoryRegionAttributes, it only contained 4 parameters, namely Start, Size, Attribut and Mask(refer to ARM version), and the MmuInitLib needs call this API to configure or initialize the MMU. SetMemoryRegionAttributes will call a private function called UpdateRegionMapping, it needs to know if the MMU is started to do different logic(such as wether should be invalidated TLB when filling the tables for the first time, etc), therefore, there create a new PCD to let it know this. BTW, ARM and RISC-V have the same logic.

take care,
  Gerd





_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#116793) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--------------w0wfmEQTJ6UMj7tjmo9dpZYq--