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 6411E7803D9 for ; Fri, 9 Feb 2024 09:56:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eo8hVVAByxacrXlen+QRoCt4B9uE2Kdyt3o+eXdJQ3U=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707472567; v=1; b=F6kjwu4PMtUzByZ4BX8EhbSiApzZ8fpSBQOwkQzHpLslmzLV/+os/swrPTU3+QFikXaJdyn2 x6eUFmpY3LZm9CL60aRcjCJU0t7glAMp/jzt6Yy+d1IgFP0Y0w0Ga5uo6vVDYmuNf/lxooJI14v gZYDCfK/9ya+FlnXPWfROEQg= X-Received: by 127.0.0.2 with SMTP id XIg7YY7687511xeq7Axalb39; Fri, 09 Feb 2024 01:56:07 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.8066.1707472566525565614 for ; Fri, 09 Feb 2024 01:56:06 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-njm-J60-MEqnb5SWWcOPZA-1; Fri, 09 Feb 2024 04:56:02 -0500 X-MC-Unique: njm-J60-MEqnb5SWWcOPZA-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 220DB3C0F240; Fri, 9 Feb 2024 09:56:02 +0000 (UTC) X-Received: from [10.39.193.114] (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 478D92026D06; Fri, 9 Feb 2024 09:56:01 +0000 (UTC) Message-ID: <61f8986a-3e67-b9f9-836b-23e18095e9ce@redhat.com> Date: Fri, 9 Feb 2024 10:56:00 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: code refine To: Zhou Jianfeng , devel@edk2.groups.io Cc: Ray Ni , Rahul Kumar , Gerd Hoffmann References: <20240208021957.15302-1-jianfeng.zhou@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240208021957.15302-1-jianfeng.zhou@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ERI4bkF8gqBcCu14k0Hlq8bYx7686176AA= Content-Language: en-US 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=F6kjwu4P; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=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 On 2/8/24 03:19, Zhou Jianfeng wrote: > Changes: > 1) add volatile to 64bit variable to avoid being tore by compiler. > 2) add OUT for parameter that might be changed. >=20 > Signed-off-by: Zhou Jianfeng > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > .../Library/CpuPageTableLib/CpuPageTableMap.c | 38 +++++++++---------- > 1 file changed, 19 insertions(+), 19 deletions(-) Sorry, just a superficial review for now. - the two changes should be split to separate patches. - the subject line is totally useless. please state (summarize) what happens in the patch in the subject. Laszlo >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiC= puPkg/Library/CpuPageTableLib/CpuPageTableMap.c > index ae4caf8dfe..d96ea5984c 100644 > --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > @@ -20,10 +20,10 @@ > **/ > VOID > PageTableLibSetPte4K ( > - IN IA32_PTE_4K *Pte4K, > - IN UINT64 Offset, > - IN IA32_MAP_ATTRIBUTE *Attribute, > - IN IA32_MAP_ATTRIBUTE *Mask > + IN OUT IA32_PTE_4K *Pte4K, > + IN UINT64 Offset, > + IN IA32_MAP_ATTRIBUTE *Attribute, > + IN IA32_MAP_ATTRIBUTE *Mask > ) > { > IA32_PTE_4K LocalPte4K; > @@ -78,7 +78,7 @@ PageTableLibSetPte4K ( > } >=20 > if (Pte4K->Uint64 !=3D LocalPte4K.Uint64) { > - Pte4K->Uint64 =3D LocalPte4K.Uint64; > + *(volatile UINT64 *)&(Pte4K->Uint64) =3D LocalPte4K.Uint64; > } > } >=20 > @@ -94,10 +94,10 @@ PageTableLibSetPte4K ( > **/ > VOID > PageTableLibSetPleB ( > - IN IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE *PleB, > - IN UINT64 Offset, > - IN IA32_MAP_ATTRIBUTE *Attribute, > - IN IA32_MAP_ATTRIBUTE *Mask > + IN OUT IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE *PleB, > + IN UINT64 Offset, > + IN IA32_MAP_ATTRIBUTE *Attribute, > + IN IA32_MAP_ATTRIBUTE *Mask > ) > { > IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE LocalPleB; > @@ -154,7 +154,7 @@ PageTableLibSetPleB ( > } >=20 > if (PleB->Uint64 !=3D LocalPleB.Uint64) { > - PleB->Uint64 =3D LocalPleB.Uint64; > + *(volatile UINT64 *)&(PleB->Uint64) =3D LocalPleB.Uint64; > } > } >=20 > @@ -171,11 +171,11 @@ PageTableLibSetPleB ( > **/ > VOID > PageTableLibSetPle ( > - IN UINTN Level, > - IN IA32_PAGING_ENTRY *Ple, > - IN UINT64 Offset, > - IN IA32_MAP_ATTRIBUTE *Attribute, > - IN IA32_MAP_ATTRIBUTE *Mask > + IN UINTN Level, > + IN OUT IA32_PAGING_ENTRY *Ple, > + IN UINT64 Offset, > + IN IA32_MAP_ATTRIBUTE *Attribute, > + IN IA32_MAP_ATTRIBUTE *Mask > ) > { > if (Level =3D=3D 1) { > @@ -195,9 +195,9 @@ PageTableLibSetPle ( > **/ > VOID > PageTableLibSetPnle ( > - IN IA32_PAGE_NON_LEAF_ENTRY *Pnle, > - IN IA32_MAP_ATTRIBUTE *Attribute, > - IN IA32_MAP_ATTRIBUTE *Mask > + IN OUT IA32_PAGE_NON_LEAF_ENTRY *Pnle, > + IN IA32_MAP_ATTRIBUTE *Attribute, > + IN IA32_MAP_ATTRIBUTE *Mask > ) > { > IA32_PAGE_NON_LEAF_ENTRY LocalPnle; > @@ -231,7 +231,7 @@ PageTableLibSetPnle ( > LocalPnle.Bits.WriteThrough =3D 0; > LocalPnle.Bits.CacheDisabled =3D 0; > if (Pnle->Uint64 !=3D LocalPnle.Uint64) { > - Pnle->Uint64 =3D LocalPnle.Uint64; > + *(volatile UINT64 *)&(Pnle->Uint64) =3D LocalPnle.Uint64; > } > } >=20 > -- > 2.31.1.windows.1 >=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 (#115293): https://edk2.groups.io/g/devel/message/115293 Mute This Topic: https://groups.io/mt/104256295/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-