public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael Brown" <mcb30@ipxe.org>
To: devel@edk2.groups.io, jianfeng.zhou@intel.com
Cc: Ray Ni <ray.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>,
	 Rahul Kumar <rahul1.kumar@intel.com>,
	 Gerd Hoffmann <kraxel@redhat.com>,
	 Pedro Falcato <pedro.falcato@gmail.com>,
	 Zhang Di <di.zhang@intel.com>, Tan Dun <dun.tan@intel.com>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/CpuPageTableLib: qualify page table accesses as volatile
Date: Fri, 23 Feb 2024 11:59:15 +0000	[thread overview]
Message-ID: <0102018dd5d57f6b-a9056a17-e950-472d-acdc-644ba55bcc65-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <20240222084128.30000-1-jianfeng.zhou@intel.com>

On 22/02/2024 08:41, Zhou Jianfeng wrote:
> --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
> +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
> @@ -20,13 +20,13 @@
>   **/
>   VOID
>   PageTableLibSetPte4K (
> -  IN OUT IA32_PTE_4K         *Pte4K,
> -  IN UINT64                  Offset,
> -  IN IA32_MAP_ATTRIBUTE      *Attribute,
> -  IN IA32_MAP_ATTRIBUTE      *Mask
> +  IN OUT volatile IA32_PTE_4K  *Pte4K,
> +  IN UINT64                    Offset,
> +  IN IA32_MAP_ATTRIBUTE        *Attribute,
> +  IN IA32_MAP_ATTRIBUTE        *Mask
>     )
>   {
> -  IA32_PTE_4K  LocalPte4K;
> +  volatile IA32_PTE_4K  LocalPte4K;

While it may well cause the compiler to generate less optimised code, 
there is absolutely no way that this volatile declaration on a local 
stack variable can possibly change the outcome of the code.

There can never be any meaningful side-effects from reading or writing a 
stack variable.

I would suggest dropping the volatile on LocalPte4K, since its *only* 
possible impact is to confuse a future reader of the code.

> -  IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE  LocalPleB;
> +  volatile IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE  LocalPleB;

Same comment.

> -  IA32_PAGE_NON_LEAF_ENTRY  LocalPnle;
> +  volatile IA32_PAGE_NON_LEAF_ENTRY  LocalPnle;

Same comment.

Thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115883): https://edk2.groups.io/g/devel/message/115883
Mute This Topic: https://groups.io/mt/104524857/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-02-23 11:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22  8:41 [edk2-devel] [PATCH] UefiCpuPkg/CpuPageTableLib: qualify page table accesses as volatile Zhou Jianfeng
2024-02-23 11:59 ` Michael Brown [this message]
2024-02-23 15:12   ` Zhou, Jianfeng
2024-02-23 15:51     ` Michael Brown
2024-02-25 13:47       ` Laszlo Ersek
  -- strict thread matches above, loose matches on Subject: below --
2024-03-01  2:54 Zhou Jianfeng
2024-03-01 11:50 ` Michael Brown
2024-03-01 12:21 ` Laszlo Ersek
2024-03-01 18:56 ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0102018dd5d57f6b-a9056a17-e950-472d-acdc-644ba55bcc65-000000@eu-west-1.amazonses.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox