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 C97F4740040 for ; Tue, 19 Dec 2023 05:45:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BIqFLoBRI74aLxhYgPzvcalg0KW1/dMVfVIhNyha1fk=; 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=1702964707; v=1; b=kSlhJeoH8Kqx2N50zjes4jM7dj+Xmt4d7RPZA25NPXnu7KvASubI7UCP9HA0P137unaWOEaz l+nCJ7YEBNf7e0iuJpkbDNUw969EtC5wW8hX5DfwsSda+QdhGT+VoWBezN3eU2XgJKliSt0PLZw 7XKxbPPQZ5vGbfv698rb49Zo= X-Received: by 127.0.0.2 with SMTP id 6hMpYY7687511xAvtOo9gTpn; Mon, 18 Dec 2023 21:45:07 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.6371.1702964706565750463 for ; Mon, 18 Dec 2023 21:45:06 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="462062570" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="462062570" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 21:45:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="804778673" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="804778673" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 18 Dec 2023 21:45:05 -0800 X-Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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; Mon, 18 Dec 2023 21:45:05 -0800 X-Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 18 Dec 2023 21:45:05 -0800 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.40) 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; Mon, 18 Dec 2023 21:45:04 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HmT/KsOfBWouBtFMtFggi8d242LqXgoxR3yhcr4TLAo9vKg6662v0oJOqHAvb5e7ugRLkvBnbVsZ5Vde/i6yuDV3H2iSClmpebk6DBK3qUWmtbJFNjrWor55lrDXeVKtfLxwrsUlHJD0kLtOPSk8au6S/H7qdF1RysbuZLo5nAHQVikSTFfVthrYZi9Ykje4R8Zfa61JOORWikl06i3psxAG4GTPFNK39EYyNHy8YoDlZCmQYaZ0satYOHUrpjaPMD8ct70Lk8TqtO1Peu4ttSY0hpIdnix0E/+w8OfrXxIgksElyex7TqwizRqMLUpWQ3oelimho4PvpCCdIL2qUQ== 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=6SUHaeI/bRA69kMgAyA/zqtiBKMwMvB6VX01/DtDWU8=; b=XWSP+pLrBm7tbFnSCwLx/ThgZslkXtO7fbXIolbla/B/LPery+CXNcsqSUYjyjFJAnwE0K9LEROhbjmlmAAo8zexGZpi6ohShwJleOAXhVVWuHjPlV58AEgSy7YGySkXMrVkxw7vo3mQSIIzr2mECWCsuVJ6UvisS4ALIi9GvGscB5FV+bc3h9fEVYxwh38KF95XmPuchlNW6Gn/Qwd7ivN9rb4GRGB4mcDm8EkyqEVfXWYtUtziQ0vaoa3AdW4DqjbGlCM4tb6klq2NX0fNP2Fh80Uxw+dsWAd9v9We6DZtN/3+H6rZrxstsa/sku8LtUhlo9GfPVBqT9bJTYLy3w== 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 MN0PR11MB6158.namprd11.prod.outlook.com (2603:10b6:208:3ca::18) by DS0PR11MB7969.namprd11.prod.outlook.com (2603:10b6:8:120::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Tue, 19 Dec 2023 05:44:57 +0000 X-Received: from MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::864d:d91a:4674:e0f7]) by MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::864d:d91a:4674:e0f7%7]) with mapi id 15.20.7091.034; Tue, 19 Dec 2023 05:44:57 +0000 From: "Wu, Jiaxin" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Dong, Eric" , "Zeng, Star" , Gerd Hoffmann , "Kumar, Rahul R" Subject: Re: [edk2-devel] [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance Thread-Topic: [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance Thread-Index: AQHaLzzbnSBsrNIwkE6IIje5dI7GG7CugsPAgAGaQRA= Date: Tue, 19 Dec 2023 05:44:56 +0000 Message-ID: References: <20231215095515.9484-1-jiaxin.wu@intel.com> <20231215095515.9484-5-jiaxin.wu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN0PR11MB6158:EE_|DS0PR11MB7969:EE_ x-ms-office365-filtering-correlation-id: 6f212572-38bd-4edb-17c2-08dc0055a1cb x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: tu6NlqK6KQprzRIqy+ihUcHHWDM063sBBgk51z82mKTQta32sWxbnI64mTuJWBS8+VtUFtlSQjF/VsN/QNZJ7k5ZUVw000EyO63woE1TeFs7+s+NK8y/sCk5XC/ZHoRfee2MIp38twwSSL+lbQoGJj7dIyQJN/ni1UtH1bwYhfpKnRkOh6a5pX0pcAeUTr399u2bdM3FbvERy//Pg1i+bXk3dnF/bVzYum/7hShQgsN8RxOFWEOadsIsgvEdBmR/TN+6ahtkkK4hqYaxf/B6RJIrvj4i/7zUB3jiw8edcszR3KtsEm5QXIuReCnFDIKpaUsJkpASKbF7LT+dnyefd3LSDv8ld76CFlrYJo9oyJ+KWiyYGHuhUM9P3tN5UTx2g64VPZ5GfqikFrInrnW3row6SmaOvSjS3EHm3asAeGzYvvwOtBa69dutEStg8v5QnN2haC2cLLaJzoFqLrmm0fI/RZ6KIEhIFEniVTF9fXAxRZo7mJGXNjsbrN74z3AyLzDFqiCS+1ueqniYQ3IiHNgu0rNbkLIsua1VeEDTLfiZrrrUQjKA43fCXJ1i6jeDwKy6a+mabOlA7UZMrNYUq1wqYjesxnmQh3BjaZnrwhZY11XvQVX6bFBb0rxw6aPoBR2uczd2VIwzrX7gzKogI6XNk1lhFPNGsfAtMS7yBGc= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam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1JLMnYqCw91EQV99jdFOIDJDhihCgOzjvH4PLZid?= =?us-ascii?Q?KpOTBx9/dxwRNU6Mmfv3bfykyZkgcXrY3o9Vk6M5YOxhWWG2KJdIUZ2KSWZF?= =?us-ascii?Q?kWlU3V6+zRo/yBaiZNsh469+Arsqe6z/b/kUB1FoapOnXHvTIHkMKVQ2bZW1?= =?us-ascii?Q?G1vG3PnjdY+dvpYr+3l8s2dFJeTOuv4DgFTyZfkJx44VtM0OPxM4kwt4ntPV?= =?us-ascii?Q?iZUhMcQLKTDKy4DMx5cK6+SoEnCb+DfSabQ9SaI8l6paviyAAezNgMQuIbr1?= =?us-ascii?Q?diukxQzCIFad5VnF7NkcmkuC6cHYNgphdYBXHIzIW6RV0FiJMAKooz2Hb+LK?= =?us-ascii?Q?YrZgmmAfdsrU/oCrc0OnyiVLZCF5cJC2aAAd1RfZxJfmE0JIHuJfb5cdy0aL?= =?us-ascii?Q?lcnwl/lvB+MmsbDc0kBYu8RV4FQwCqor9MBMpcB7VNurzlvh6tg9rJuf9Kkb?= =?us-ascii?Q?Rm7aM82d7SU1OKxBEFH4W684cm9ptqOvTSduJpw5O6RrZYwXUQi2gm1Ktt+u?= =?us-ascii?Q?GpEhgA2IpRumv3GteomxuYmqVWr/3RnIpDytCUrjdQCyo4QGGAOoPYHNdTTN?= =?us-ascii?Q?Pz+dFqDXGhCqlUZCw5D8ly8HBy/MWDhPneGk1PV/72i0L63/yUoWPa2RJWI8?= =?us-ascii?Q?UfHE7okcq6wLi53jQMXu7XXvr49JDgdIJbkhLG7FsXvbqKYzFmqfAdmCXRjH?= =?us-ascii?Q?W0+I7ogcL/jTkZdcVTv6yr73KCYyBdQrEDjywtx2?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6158.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f212572-38bd-4edb-17c2-08dc0055a1cb X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2023 05:44:56.5858 (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: e7DvcQbXtoT4ugnV0MfQ0cgKZRPfnWBg8MelI/mBFWg6w9jzRTZt6cUs7e7HKrur5R1m0XpAAyHQQYTeJvXQdQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7969 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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: OTuN0NNmXpUAD0HfXkQy79vNx7686176AA= 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=kSlhJeoH; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.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; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Thanks Ray. >=20 > 1. It's not "LockedCpuCount". It's "ArrivedCpuCountUponLock". > Comments can be: > Before the door is locked, CpuCount stores the arrived CPU count. > After the door is locked, CpuCount is set to -1 indicating the door i= s locked. > ArrivedCpuCpuntUponLock stores the arrived CPU count then. >=20 >=20 Ok, I will update. > > +/** > > + Performs an atomic compare exchange operation to get semaphore. > > + The compare exchange operation must be performed using MP safe > > + mechanisms. > > + > > + @param[in,out] Sem IN: 32-bit unsigned integer > > + OUT: original integer - 1 if Sem is not locke= d. > > + OUT: original integer if Sem is locked > > (MAX_UINT32). > > + > > + @retval Original integer - 1 if Sem is not locked. > > + Original integer if Sem is locked (MAX_UINT32). >=20 > 2. Can just say "MAX_UINT32 if Sem is locked". >=20 >=20 Agree. > > + > > + // > > + // Assign CPU Semaphore pointer > > + // > > + CpuSem =3D (*Context)->CpuSem; > > + for (CpuIndex =3D 0; CpuIndex < NumberOfCpus; CpuIndex++) { > > + CpuSem->Run =3D (SMM_CPU_SYNC_SEMAPHORE *)SemAddr; > > + *CpuSem->Run =3D 0; > > + > > + CpuSem++; > > + SemAddr +=3D OneSemSize; >=20 > 5. SafeIntLib was used earlier to make sure no integer overflow. > But "SemAddr +=3D OneSemSize" is simply ignoring the danger of integer > overflow. > I agree (NumberOfCpus + 1) * OneSemSize shouldn't cause integer overflo= w > when code runs to here. > But initial value of SemAddr is not zero. It's still possible the SemAd= dr + > (NumberOfCpus+1)*OneSemSize causes integer overflow. > I am ok if you don't fix it as I don't believe the integer overflow cou= ld happen > in 5 years. SemAddr is the address of allocated buffer (SemBuffer), "SemAddr +=3D O= neSemSize" will make SemAddr point to the part of allocated buffer. is it p= ossible integer overflow? If so, the allocatepage should fail? Thanks, Jiaxin =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 (#112690): https://edk2.groups.io/g/devel/message/112690 Mute This Topic: https://groups.io/mt/103187894/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-