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 C10E4D80281 for ; Wed, 21 Feb 2024 05:47:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=73VY4fXBno+RI6/BWA/Nlq/KGOPcoJD/9VlfZQCy50o=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version: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=1708494429; v=1; b=dZxTJx4mA1nP6KUg7A4fQehHew5Lhj//FxE/qmccyXRgaLqXGRazlb9n4CAbsHmfvTNAIn/F 4Qv6pS1JGmO9kG0uXzf+53/qlpeSfX0QlbvuTmSQhQqEIdFecC67ibI4O3oIs26+EV2WBnFE46f luGuNWySiblJa37lKlf4iX9E= X-Received: by 127.0.0.2 with SMTP id bQEMYY7687511xzBpad0DMx7; Tue, 20 Feb 2024 21:47:09 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mx.groups.io with SMTP id smtpd.web10.7012.1708494428679774602 for ; Tue, 20 Feb 2024 21:47:08 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10990"; a="28078208" X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="28078208" X-Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 21:47:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,174,1705392000"; d="scan'208";a="9714122" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Feb 2024 21:47:09 -0800 X-Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 20 Feb 2024 21:47:07 -0800 X-Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 20 Feb 2024 21:47:07 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 20 Feb 2024 21:47:07 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fCuGOAu2gtsTh51c2Oj88TWQgkyS0peKyZqEWZJT0UghqFHg+q9L/uEBezTu6//38RT8kFDMu9uihXNMcplQEhwUj9o6FDupmmMwu/8AnpDV+efZcMhdhFDaLbWREoxvujbwOZqntqdK7WNgi6muLTwRKEq0L7hAQqDJdhF6+q2DoR7NLAzUk6imiyN7zTZInmNNszT0LiVxANIB8ClOwrYndE1RE/I1fpvdFSSVUNIiXmPdAMzCSraioPTl29SyS9uj0wI7gLIRfFrMYU62PW6u8WJFt/Aroo1K1H33pOo4ZDD6WKH6Jlet0OD89Gz2fV75gnPIthXbvXa5jvb41Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SltAYiJwhr0uaG6poHyjwNfgA8LylA7JHnC8fBE1Q+c=; b=RAu8Z5gS7dxNnos43CEnaSoR/co8O3SVNORif69VfcMQ3KxSEG8f5lM3SKHAYkkLwRW5GDqmOOoVYys53NOa4RRR3fo3jCJoNgiURSvxDLxvba5+uN5KsX7Au5nKrm7RGD7zJ4xRX3acCKy1HCSKhOZ0AffvkP/M9By095lnzxMcGrQOaMb5G+BnZf1CEZd67/9FZavFqU+qEhwvYv1giywn8HQ/9cZ6njhx8Q9GIPxJ41272vd9JwVk0YeYuWUXGYbdM7OTrToJuQaitT++W3MSpOap/Z8RNSB/UBV/HBihkeUyj56ikd9vb2+jWlKKEmTcUA5LDJ24cBTssItt4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by PH7PR11MB6554.namprd11.prod.outlook.com (2603:10b6:510:1a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.21; Wed, 21 Feb 2024 05:47:04 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::8985:d1bc:9df6:61cf]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::8985:d1bc:9df6:61cf%7]) with mapi id 15.20.7292.036; Wed, 21 Feb 2024 05:47:04 +0000 From: "Ni, Ray" To: "Zhou, Jianfeng" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: add volatile qualifier to page table related variable Thread-Topic: [PATCH] UefiCpuPkg: add volatile qualifier to page table related variable Thread-Index: AQHaZGTeUvpAnVfStU6EXxBPcPFdVLEUSbjQ Date: Wed, 21 Feb 2024 05:47:04 +0000 Message-ID: References: <20240221012513.27453-1-jianfeng.zhou@intel.com> In-Reply-To: <20240221012513.27453-1-jianfeng.zhou@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|PH7PR11MB6554:EE_ x-ms-office365-filtering-correlation-id: a6dae860-4e3c-4b68-1031-08dc32a088a8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: UHua4gm47oHDytsPiHicN24GaO8CiyFBKp6/cOKuvnc1hGiAj9+DfQUhyhhf9h+P4l2Sko27avsp3hfdeNjXTBGv9faqx/LdBIkGosS2wr7mhC/hZ+B6HybpWkQAoyt1FlaSKF6YstnqLfhismqhkh7Yoj+/YYvL1ndQMfrbD6CtOxszEJfSTmQLS/ZoFSX1ZEBeJtfvaNoZuY3aiWOSnN23x7rdXGkYkkkcpm/bnV9XTAkX7hR77xSUate8ch8PRpTsKQKCNZlYIHrXhn1cU7sCghwT1sfGMq/t8Tr5B/yFCMtlY1gzqWKIe1n5mLjZNmaHz1JHgu2cpR4RoZ4Zf0aGDepybAJ/qkRtU97Rv4O2Z37pDObSlmVDgHJINmnj1bUnr73Ti6Jch2Mk0WUp2zAfeZywvTb4IQmKwznMU7tDOkLwx99g8sv0a7RRv/41/TpriYKvD7Wt7f9MMNJwjbv2JWjmLHI3h7NKqhd0A86tWiOFK8Iqjsvys2puVyGtBo4anIcmyA6FAe7EKxmO7Qs5Ta2mRqcID+qs+vdGmLrTzjyaWrWoQs4hgo+uZ8OzFgJF2qCbV7uYmn0qcLwgMmXHzyzVo2ln/cxRRlHxd6e5yz4/j+8ispOONf7q4YOP x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?qmVEQ6icP2l620sAdoCYczTcjfDZcjt9G3ss7NFUIhFoWpOgZuoLjSXO+JTS?= =?us-ascii?Q?4tWW/kR8KyoiQiSNgOEehL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= =?us-ascii?Q?j3SozmQ1DC/OXhA7fBCl+Qlqzc4AF6xsj1g1nn18NKE90Hokx8T1Pp1hXaQ/?= =?us-ascii?Q?jm6E0J9T1802dZV6hTyt3rqADnmd9+o1xXwlbC/Di9eLSFD4PKb/DSX4sXaH?= =?us-ascii?Q?r6Vyewy/L+SK5XKhWmXRaM4LoWJK11sBBqLoQSmWQs9CjDf/psgA5Nap8kr0?= =?us-ascii?Q?gUXWmk4AU7x/UDst3saVNqx7cfHZZx3kIf1efuREDZB4YCMlVSLHdq63vNjc?= =?us-ascii?Q?qN26oZKZzvm3GdY3lyK+xPDUzQLnWAMfAXsWFuGurNd9d95TjlaQUtOCvTU7?= =?us-ascii?Q?LfeRCIeVOEQ+xLwSja5ioGIuOhUSwN6e20HDkTY2XnqG80vTAb7jvYNKwBzX?= =?us-ascii?Q?kBaOMtqNhflTCKuGTS6q/6zNYCH7YdVYSexw7sHz1Ti+C+jN/hhOrBR+5A9S?= =?us-ascii?Q?Du13bjsif7qchu4oKYnLHFTUeZ4Vt3JCMYzPaw/oKTnFwjHNIaVdrvOKbsvb?= =?us-ascii?Q?FAVUyZxCa4ADTJ0WalNhfr6qCoWKPGJkL4AEDx+UqutbGXdkijcYWgdB1gtH?= =?us-ascii?Q?ojIVOrSNNaF/6lyJkiUxXfVJM1gAtH1vdrO54isKcHcsNaLv4fNl2J1sODTw?= =?us-ascii?Q?F5gSp/wPLMRhRy2BTGA=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6dae860-4e3c-4b68-1031-08dc32a088a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Feb 2024 05:47:04.8001 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: sQ2pgUIGGXObuOSzDlAG7zNKdYNb/Uo9j9m4dG+mtksjTSzI00CSZowOBdW7HcYuNGiICzNgaSGv7/hfPKywzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6554 X-OriginatorOrg: intel.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,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZgDATEeCUGUbtLt7hJzezfRfx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" 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=dZxTJx4m; 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=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Reviewed-by: Ray Ni Thanks, Ray > -----Original Message----- > From: Zhou, Jianfeng > Sent: Wednesday, February 21, 2024 9:25 AM > To: devel@edk2.groups.io > Cc: Zhou, Jianfeng ; Ni, Ray ; > Laszlo Ersek ; Kumar, Rahul R > ; Gerd Hoffmann > Subject: [PATCH] UefiCpuPkg: add volatile qualifier to page table related > variable >=20 > Add volatile qualifier to page table related variable to prevent > compiler from optimizing away the variables which may lead to > unexpected result. >=20 > Signed-off-by: Zhou Jianfeng > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 12 > ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > index 2ea40666cc..5cf6e8fea0 100644 > --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > @@ -26,7 +26,7 @@ PageTableLibSetPte4K ( > IN IA32_MAP_ATTRIBUTE *Mask >=20 > ) >=20 > { >=20 > - IA32_PTE_4K LocalPte4K; >=20 > + volatile IA32_PTE_4K LocalPte4K; >=20 >=20 >=20 > LocalPte4K.Uint64 =3D Pte4K->Uint64; >=20 > if (Mask->Bits.PageTableBaseAddressLow || > Mask->Bits.PageTableBaseAddressHigh) { >=20 > @@ -78,7 +78,7 @@ PageTableLibSetPte4K ( > } >=20 >=20 >=20 > if (Pte4K->Uint64 !=3D LocalPte4K.Uint64) { >=20 > - Pte4K->Uint64 =3D LocalPte4K.Uint64; >=20 > + *(volatile UINT64 *)&(Pte4K->Uint64) =3D LocalPte4K.Uint64; >=20 > } >=20 > } >=20 >=20 >=20 > @@ -100,7 +100,7 @@ PageTableLibSetPleB ( > IN IA32_MAP_ATTRIBUTE *Mask >=20 > ) >=20 > { >=20 > - IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE LocalPleB; >=20 > + volatile IA32_PAGE_LEAF_ENTRY_BIG_PAGESIZE LocalPleB; >=20 >=20 >=20 > LocalPleB.Uint64 =3D PleB->Uint64; >=20 > if (Mask->Bits.PageTableBaseAddressLow || > Mask->Bits.PageTableBaseAddressHigh) { >=20 > @@ -154,7 +154,7 @@ PageTableLibSetPleB ( > } >=20 >=20 >=20 > if (PleB->Uint64 !=3D LocalPleB.Uint64) { >=20 > - PleB->Uint64 =3D LocalPleB.Uint64; >=20 > + *(volatile UINT64 *)&(PleB->Uint64) =3D LocalPleB.Uint64; >=20 > } >=20 > } >=20 >=20 >=20 > @@ -200,7 +200,7 @@ PageTableLibSetPnle ( > IN IA32_MAP_ATTRIBUTE *Mask >=20 > ) >=20 > { >=20 > - IA32_PAGE_NON_LEAF_ENTRY LocalPnle; >=20 > + volatile IA32_PAGE_NON_LEAF_ENTRY LocalPnle; >=20 >=20 >=20 > LocalPnle.Uint64 =3D Pnle->Uint64; >=20 > if (Mask->Bits.Present) { >=20 > @@ -231,7 +231,7 @@ PageTableLibSetPnle ( > LocalPnle.Bits.WriteThrough =3D 0; >=20 > LocalPnle.Bits.CacheDisabled =3D 0; >=20 > if (Pnle->Uint64 !=3D LocalPnle.Uint64) { >=20 > - Pnle->Uint64 =3D LocalPnle.Uint64; >=20 > + *(volatile UINT64 *)&(Pnle->Uint64) =3D LocalPnle.Uint64; >=20 > } >=20 > } >=20 >=20 >=20 > -- > 2.31.1.windows.1 -=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 (#115712): https://edk2.groups.io/g/devel/message/115712 Mute This Topic: https://groups.io/mt/104483610/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-