From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.79]) by mx.groups.io with SMTP id smtpd.web11.9712.1582731992821292883 for ; Wed, 26 Feb 2020 07:46:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=C34RAIjR; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.220.79, mailfrom: leo.duran@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K2/e7r6prBXd/aJ6M30HKF3WrqM1WFw6fdMO5/fRPgfVQbcqqDDvAth0muHdIO5RbibInCYUpylMHzBvtUw3gZMQkG1V57ms2nF1wqn00X/nTOReS1k+Lxza6OhnZwea5c7qGVGEGTgXGmFjLqsUA0EMqfXjS7VPPOKswMQP/6jo7relWomURCRg7RIPN7rpzi/tfGX5s0aI3e/0+m8FwJzMdL4yw4uWqw/rai3iWyCkXturOgSaajmyrnWT1UMnUGs62I19okcOPVN0VkjBVY7N1UcxyOOstuQfC//CWTX+s9bwairZJ10tWnIvFAoJb6SuljzKNStX6u0YpIn5+A== 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-SenderADCheck; bh=+AMeYk3hat/tAA/q2joODVLH1jqONbz7XJQKgNs1Jq0=; b=iXssxO7raz12ML1q/JKKBaJw+BV9EMgm98zpa1GlSxF6J5KcpMqZkb45h+RwaZu4+lfMO9w+ll+Ow0xIIh3A7k/wPCWHOYZTXRbsSbaPjEg2WlURHk9GDmhCB7MjAFGd0j5TbYRaWx+ncACwTePaadO85DTqAysLV725F7mv/AHVQixxYu7SZY6xiwAhieY+I75ulkZxRlbJI8rt4FccDyWHbMWB8/uzxYh1YMYJkYqKVKTjXlpQ7rRehiuWdoPKiLC0RA2O3xb9eIDi3bqlwMf1nxuiz5AJIkV1SSA0jN91jC9raH3toMU90PXr2mKyxiJGoHUoYTGD8Xhgkshb1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+AMeYk3hat/tAA/q2joODVLH1jqONbz7XJQKgNs1Jq0=; b=C34RAIjRVuoBm/clRV09bDEfA9WN94lMtK3lsiT4p2kx8onXZ+gWooeRHVGKr+1HIv+du39NIi1d8wWg9F7J0WpH3WmrTdXJ3/q/3XL1Es/dV+13u6XqCR8ZHgYabxFzlrv1Kp7HEPTki6MkcbUZhjH6qVpLLThjulxQJYmDVA0= Received: from BN6PR12MB1922.namprd12.prod.outlook.com (2603:10b6:404:106::14) by BN6PR12MB1411.namprd12.prod.outlook.com (2603:10b6:404:1f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Wed, 26 Feb 2020 15:46:28 +0000 Received: from BN6PR12MB1922.namprd12.prod.outlook.com ([fe80::d931:1942:a6b5:d74c]) by BN6PR12MB1922.namprd12.prod.outlook.com ([fe80::d931:1942:a6b5:d74c%7]) with mapi id 15.20.2750.021; Wed, 26 Feb 2020 15:46:27 +0000 From: "Duran, Leo" To: "Ni, Ray" , Laszlo Ersek , "devel@edk2.groups.io" , "Wu, Hao A" , "Fu, Siyuan" CC: "Dong, Eric" Subject: Re: [edk2-devel] [PATCH 0/2] UefiCpuPkg/Library: Fix bug in MpInitLib Thread-Topic: [edk2-devel] [PATCH 0/2] UefiCpuPkg/Library: Fix bug in MpInitLib Thread-Index: AQHV7BNuZBsSC+kbJkGHn9DFW2NUaKgspoeAgAB2EYCAAHmSsIAABrIA Date: Wed, 26 Feb 2020 15:46:27 +0000 Message-ID: References: <1582659566-9893-1-git-send-email-leo.duran@amd.com> <734D49CCEBEEF84792F5B80ED585239D5C4542DA@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; x-originating-ip: [173.170.80.115] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f034377c-7693-4fb1-b5ea-08d7bad30ae6 x-ms-traffictypediagnostic: BN6PR12MB1411: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0325F6C77B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6029001)(4636009)(39860400002)(346002)(376002)(396003)(366004)(136003)(199004)(189003)(19627235002)(5660300002)(66556008)(33656002)(66946007)(66446008)(64756008)(110136005)(6506007)(2940100002)(7696005)(52536014)(71200400001)(8936002)(76116006)(2906002)(66476007)(86362001)(9686003)(55016002)(478600001)(186003)(8676002)(26005)(316002)(81156014)(81166006)(4326008)(53546011);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1411;H:BN6PR12MB1922.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Jsx3ShOzhaL2IR97Vdxyt19sJkmCMg9OIFh0O2aHt463AbswvLAzBf0qihahLLGCY05a9ibLj6TQs7HmviYS53n6Wd9ky8o96pzk53KV5Ec+UChWoo/RcW609Xxg56+5qW4QmQRIXH6pomuYrzknXlpZlFFI1ojKKjiQJC7/Qy77HEx6EMxvW4j9EJkIojC/8hhPei19B/37F5GFV0AbfRovNqQnIDw4WQlWrt12Vf5e3CUEIhJV55kPjjmQMeYD1pELoGtTv5WX6v9MFJi0iPvDFWIg/6OEnj2Mz4yzmEkBDIj+UgYJc3POX6rg+RqVcVRgIPg6Ty9uSJXBpPcqrz0XZd9CmAZmBQZS6W4Wvabgj1G9ryVTNaBxm28KT0R6KZjyl2geu3QsnrqPmp82eUHAEc5AY0X/LtLxO+JpIecGPhmE9JiL0V+YgZ/9UWu3 x-ms-exchange-antispam-messagedata: xivJKS16Jb5peWent3+9CR0UkRQdtkzHqrjxRPastRFR8Y3F5pXz0Mz2y2OCPYRFq7N8DRrKTeSXMDAix+NDkj5mMO2yu+/2OJ/smy51F4iiK5/0WpssT5RfbVOEdYXEywA3ANz+341E0JQVpZbakQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f034377c-7693-4fb1-b5ea-08d7bad30ae6 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2020 15:46:27.8522 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LTMZjb8RUevcRigVPh9EErrP2A56gKBEDx9owLi3/sIt3mSxinRfzbR16xWyQwjL X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1411 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable BTW, I also considered adding a flag to CPU_MP_DATA to make the usage of Platfor= mId a bit more explicit. E.g., something like CpuMpData->CpuData[ProcessorNumber].IsValidPlatformId.= .. So the init code would look like this: // // NOTE: PlatformId is not relevant on AMD platforms. // if (StandardSignatureIsAuthenticAMD ()) { CpuMpData->CpuData[ProcessorNumber].IsValidPlatformId =3D FALSE; else { PlatformIdMsr.Uint64 =3D AsmReadMsr64 (MSR_IA32_PLATFORM_ID); CpuMpData->CpuData[ProcessorNumber].PlatformId =3D (UINT8)PlatformIdMsr= .Bits.PlatformId; CpuMpData->CpuData[ProcessorNumber].IsValidPlatformId =3D TRUE; } This way "IsValidPlatformId" could be checked prior to using "PlatformId". Anyway, that seemed a bit overkill, so I opted against it... thoughts? Leo. > -----Original Message----- > From: Duran, Leo > Sent: Wednesday, February 26, 2020 10:25 AM > To: Ni, Ray ; Laszlo Ersek ; > devel@edk2.groups.io; Wu, Hao A ; Fu, Siyuan > > Cc: Dong, Eric > Subject: RE: [edk2-devel] [PATCH 0/2] UefiCpuPkg/Library: Fix bug in > MpInitLib >=20 >=20 >=20 > > -----Original Message----- > > From: Ni, Ray [mailto:ray.ni@intel.com] > > Sent: Wednesday, February 26, 2020 2:57 AM > > To: Laszlo Ersek ; devel@edk2.groups.io; Duran, Leo > > ; Wu, Hao A ; Fu, Siyuan > > > > Cc: Dong, Eric > > Subject: RE: [edk2-devel] [PATCH 0/2] UefiCpuPkg/Library: Fix bug in > > MpInitLib > > > > Leo, > > > > > > BTW, reading the PlatformId MSR was already being done by > > > > MicrocodeDetect(), but it never affected AMD-based platforms as > > > > the flow never gets that far, since the Detect routine bails out > > > > early when it > > finds the size of the patch is zero. > > > > You are saying that PlatformId MSR access is not performed by CPU in > > old code because of the zero size uCode. > > But now with Hao or Siyuan's change, the PlatformId MSR access is > > always performed even when there is no uCode. It sounds like a > > regression to optimization to me. > > Did you evaluate the path to avoid accessing PlatformID MSR when uCode > > doesn't exist? So that the API to detect AMD processor is not needed at= all. > [Duran, Leo] > Hi Ray, > I think your summary is pretty accurate, except that I'd say that avoidin= g a > READ from the PlatformId MSR should happen solely based on the fact that > the MSR simply does not exist on AMD processors. > Then as a result of that, the usage of the PlatformId (as it relates to = microcode > or anything else) must then be dealt with separately. >=20 > To that end, I think I covered all cases where the MSR is being read, and= also > where PlatformId is being used. > (I also added comments for each case) >=20 > Thanks, > Leo. >=20 > > > > Thanks, > > Ray