From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.7511.1615552412591036643 for ; Fri, 12 Mar 2021 04:33:32 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=KdZvUrJC; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: eric.dong@intel.com) IronPort-SDR: YbXNBNeyTriKkb66gGKTDNob6yRFH+dyhEwawb81kCc226YpIXJhUDFxerSse752Uwqg58MvNi NgfQxkogZWOg== X-IronPort-AV: E=McAfee;i="6000,8403,9920"; a="208665036" X-IronPort-AV: E=Sophos;i="5.81,243,1610438400"; d="scan'208";a="208665036" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 04:33:31 -0800 IronPort-SDR: 7DI77RIB6esP+Nwv7WdcPZ6W6ViE/35MU4czTFHaM2xCV674dDbYXIDS5C6JoYJ2RpMbarVqeM dutYiYWizolQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,243,1610438400"; d="scan'208";a="510317960" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga001.fm.intel.com with ESMTP; 12 Mar 2021 04:33:31 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 12 Mar 2021 04:33:31 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Fri, 12 Mar 2021 04:33:31 -0800 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.58) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Fri, 12 Mar 2021 04:33:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEmjsM/4yoojE8rzSEQzg31uyN7Wu+SzP49+xAKtzYexrCio2ZLgnDnzglusIacqTGolXN7DjdyOufJ7geYyhN4CWw2P6REI0btr0K7SL6Vb3jKZ43Cc1jkzwt142NFCBDZJCNzFFZ883APg9f2ugLNxvYfamECrz3Z/O8pugPg1V2G/siVh4DjdSMbbCkpwE596VLFzyXJtLK2cErPrpgyXRiwILk68Pxi2Zz+lcHbRNZIk4OltgqeksB4v7sVdtBE7DeBAGxON/9J4+CHjmvP1MIdrf2GuI/AUQyYSuoZVBeypzI2v+QWwUkw5zSyRUBhZagCPHTqoazH+TTBNHQ== 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=x9ApOlwUtFKSZ6zN1o1Qc2MsjjThKJv3eJdk9lbaKmo=; b=di+vwzA6FcvvWvL/TMCi0QiurDKn0ptlHnzrhGfmIprjOVHbq42CjbS0ZcZl1kpyYkii9Weud6Pw86ystr5e/ft243+80jUJ8CsrcVWBlAyph5CGuytNGPpSsUdkfW58hWFKCMJupec8P8cW2RYYSjgVkUDM6YP9MvQKYJemCXIk9OBXsdIoLy7+UPqOduWps2K3xgfJpl2hXrM20tKpPB9cRHA+NOa3IyDmy2Q5wDj5ejgyvgy8FNk75TYL7Zztn1gusyeykMJMfOn70eKKG6kzL1YRuHQMJtnv6O94ms6l0PSF/qTIeLyBQhebpaI29vF7XQve+nBHiUVZly8NSA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x9ApOlwUtFKSZ6zN1o1Qc2MsjjThKJv3eJdk9lbaKmo=; b=KdZvUrJCOH7zJjg1MR3qsATVB8fXfVK5qpOv1R0zfC9kkJKzUGhm6OsfQw6ilnNgzvXkAwKVycL7axG89dkYlX3MHVJMtsz6JWn1D9M2AcNovX1z1Jck84vsl3k4bMrVYx+o4OCUbAN8iNA1I0mviG9yS56rfHwtK9/dnORyfSE= Received: from CY4PR11MB1272.namprd11.prod.outlook.com (2603:10b6:903:29::9) by CY4PR1101MB2070.namprd11.prod.outlook.com (2603:10b6:910:1c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17; Fri, 12 Mar 2021 12:33:29 +0000 Received: from CY4PR11MB1272.namprd11.prod.outlook.com ([fe80::918c:7df3:f688:d5e9]) by CY4PR11MB1272.namprd11.prod.outlook.com ([fe80::918c:7df3:f688:d5e9%5]) with mapi id 15.20.3912.031; Fri, 12 Mar 2021 12:33:29 +0000 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: avoid printing debug messages in AP Thread-Topic: [PATCH] UefiCpuPkg/MpInitLib: avoid printing debug messages in AP Thread-Index: AQHXFzWaMnhLpPr1B0GdFwvevZ9zL6qASUdg Date: Fri, 12 Mar 2021 12:33:29 +0000 Message-ID: References: <20210312114804.2-1-ray.ni@intel.com> In-Reply-To: <20210312114804.2-1-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [61.155.142.106] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a4028fad-14da-41c3-b54e-08d8e5530a7d x-ms-traffictypediagnostic: CY4PR1101MB2070: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5ucXbqEco+P55rSPhTEYmR5lqYpSr4b8eGrhIEiDW0tX0WdAXkzxeyrgmW7cB980IC0G9k/E7Ls6Jkz7qrS2xMJn2MJzvR28JxykHB3D7xc6rUbzcUeMunK/noQ82CqbA/9b0ZgCC48SI1pLwsT5jY9ZvJNBQSxH9V/bkgJSlr3jNmahM1EytT3053ONzNwJGIbL8gyQ4grs/27A8HvnWsq7YeYWH5bZ9WVTzDO1p3LRMTGnZ4q+08vPov3oKDdafI09iXpGH2dcyVR4tG7hxC2q2nLj1vCIRaebdOfkL4EDNVzWHOD/3XscVe+tmmLDqXRQMSasJkGSBSuJYWBMmGzHdroiWlMyoYt16DWOn/ePzbr8GwNOvt2F+yVvfNQBRGzj9kGAEBKOJObgRbN8TjYbwCwei7muGoUioNOSkhxZU6L6yqjyphKUXSHTQd3AplBwIRK4dObLMwQYe700JkzceV5BuuQwb704WUlB33f/MiVZ/vbdFAWgtuwH8kVptMhhZ8/rONzANPvUIQ7Gog== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1272.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(366004)(396003)(376002)(136003)(39860400002)(346002)(478600001)(8676002)(7696005)(15650500001)(83380400001)(4326008)(5660300002)(316002)(2906002)(86362001)(55016002)(52536014)(9686003)(53546011)(107886003)(71200400001)(64756008)(6506007)(66446008)(66556008)(186003)(66946007)(66476007)(76116006)(8936002)(33656002)(26005)(110136005)(54906003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?MCtW6kpmVxPUjIBfvsNRt+dW3XxEtggJt8Wgor4ZM2OohKm9J2QHSL5sBMW3?= =?us-ascii?Q?H5+OgBO528yVgUlJvTDXDgplbi9zHV/hYEhY2UlR0TN/Uj3Ym0s8LJoFOBhz?= =?us-ascii?Q?Y8fDBdM2xoZLQdj54qlNQYH0Ln5l1nOk3M5i2TwOCp92wP7Up378OjqaYC0s?= =?us-ascii?Q?mx1MohcZEgsj69X48+TTwSX4jiY63V/x0aWY1MsMWhw4c5fQvoqFPj3frMk8?= =?us-ascii?Q?EKrHaki7AjVgnPz5dLb7seez20BUchvdPPbUYbYxlCAZ2F6MkgrskeMrNowf?= =?us-ascii?Q?x8aFnEj3NfwBNeZo2arYIMBDjQcvEzQeosJRMk8fMzIUCWofO/TfmcyulxbK?= =?us-ascii?Q?l0Is9n1+XExAqjohvByEo1ReHJ6z+8s7IvWb5z/PVjjkGk8aElyAfvwUMC8y?= =?us-ascii?Q?qOp5wCSE0Kd/8yu9k7x+syPjwwqtJCDDR34VE5A1I0m3g61eWb6+UVFnhp6m?= =?us-ascii?Q?D+uPXBguwmgHqmTq3FQWtIc7GyIsyMJ/903Pf2X+QJbPDLCOAsPxSWrSSH/p?= =?us-ascii?Q?nLQU8lIApZPAix0nQa8pbsjx6chBBbqYY4C6wpNG84YSFOYJMAIOBtCKAhYl?= =?us-ascii?Q?0AgJAcU+Wtdg3U9redFLEn9u2XeJ7VQa+REibeN+lCWT7Xyc0H7MsLPwKett?= =?us-ascii?Q?LMd5E4K8AYFz0BqkYznWG4dZhZciHXO6WIvNyct2fxMgtE96rzYgqxYnL9o3?= =?us-ascii?Q?huVY04FGUIcSD1MnsjPvmCWnxx+jEuLJLJRyRSVp3xnmYd0eD+NRgCwxzZz7?= =?us-ascii?Q?ijmEaHOqjWmOQVU+Pdjy+zqPTwk4cUg+NNHrJbfdxFCsZTYn3ro1FyqaBpr+?= =?us-ascii?Q?VY1kkUz2B6JVGH4szs+UqGAJJUhy6otiWFqy/z2C5j6wLSnTQKcYaHF7ty1E?= =?us-ascii?Q?2h8WbPoHSV6WmW0zDAR7Sko2MGL5NFso6q7TPsZx70Fz10U0brc47KvWLHY/?= =?us-ascii?Q?J6eT7loidtK86Qu5yGwewn2MgkQOjvdbFJ2+0jJnoaReNrpkVDNBIh6Jvxfw?= =?us-ascii?Q?WKs/Yiu4d67AyGgvnp2gx68pdoFhZhDO1L60nkdCo0dHCf69YoNlchcDx3SG?= =?us-ascii?Q?/fBR4ni7UOzDErnUHajIatcgWSrOSmmR3QXV3es5/p7B6hjT539tCKl3oCql?= =?us-ascii?Q?sEqSHpdJyW3Yc+8E+oxnYrQAJ5Ufkq5I0EcB8vR+0u0RbIcHkcK9MOzclJa7?= =?us-ascii?Q?rGJNOkLXoj4ZOdPi4w5mdAp/Op++lKVzWoay1Z9jm8EP7b6H7Wr9Pz6nPwn0?= =?us-ascii?Q?oiCDAAzk+/qHWxl33U3zCJBo8+6II9+DmtC8CBRCv9BcIIxXeFHqO0JpUP+i?= =?us-ascii?Q?RaG4oWTZx7jn7TE+rTqUQ1Qv?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1272.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4028fad-14da-41c3-b54e-08d8e5530a7d X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Mar 2021 12:33:29.3012 (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: LC2iUKbiF+Ny2ZJNA48DNY+vq7Drpm6EbUTNtiRXWEhHhhjDCeCuCXlwmwm+g/9lSSyuJPwfxAvYp1bSa5xoNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1101MB2070 Return-Path: eric.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Ni, Ray =20 Sent: Friday, March 12, 2021 7:48 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Laszlo Ersek ; Kum= ar, Rahul1 Subject: [PATCH] UefiCpuPkg/MpInitLib: avoid printing debug messages in AP MpInitLib contains a function MicrocodeDetect() which is called by all threads as an AP procedure. Today this function contains below code: if (CurrentRevision !=3D LatestRevision) { AcquireSpinLock(&CpuMpData->MpLock); DEBUG (( EFI_D_ERROR, "Updated microcode signature [0x%08x] does not match \ loaded microcode signature [0x%08x]\n", CurrentRevision, LatestRevision )); ReleaseSpinLock(&CpuMpData->MpLock); } When the if-check is passed, the code may call into PEI services: 1. AcquireSpinLock When the PcdSpinTimeout is not 0, TimerLib GetPerformanceCounterProperties() is called. And some of the TimerLib implementations would get the information cached in HOB. But AP procedure cannot call PEI services to retrieve the HOB list. 2. DEBUG Certain DebugLib relies on ReportStatusCode services and the ReportStatusCode PPI is retrieved through the PEI services. DebugLibSerialPort should be used. But when SerialPortLib is implemented to depend on PEI services, even using DebugLibSerialPort can still cause AP calls PEI services resulting hang. It causes a lot of debugging effort on the platform side. There are 2 options to fix the problem: 1. make sure platform DSC chooses the proper DebugLib and set the PcdSpinTimeout to 0. So that AcquireSpinLock and DEBUG don't call PEI services. 2. remove the AcquireSpinLock and DEBUG call from the procedure. Option #2 is preferred because it's not practical to ask every platform DSC to be written properly. Following option #2, there are two sub-options: 2.A. Just remove the if-check. 2.B. Capture the CurrentRevision and ExpectedRevision in the memory for each AP and print them together from BSP. The patch follows option 2.B. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar --- UefiCpuPkg/Library/MpInitLib/Microcode.c | 11 +---------- UefiCpuPkg/Library/MpInitLib/MpLib.c | 9 +++++++++ UefiCpuPkg/Library/MpInitLib/MpLib.h | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/= MpInitLib/Microcode.c index 15629591e2..297c2abcd1 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -315,17 +315,8 @@ Done: MSR_IA32_BIOS_UPDT_TRIG, (UINT64) (UINTN) MicrocodeData ); - // - // Get and check new microcode signature - // - CurrentRevision =3D GetCurrentMicrocodeSignature (); - if (CurrentRevision !=3D LatestRevision) { - AcquireSpinLock(&CpuMpData->MpLock); - DEBUG ((EFI_D_ERROR, "Updated microcode signature [0x%08x] does not = match \ - loaded microcode signature [0x%08x]\n", CurrentRevision, L= atestRevision)); - ReleaseSpinLock(&CpuMpData->MpLock); - } } + CpuMpData->CpuData[ProcessorNumber].MicrocodeRevision =3D GetCurrentMicr= ocodeSignature (); } =20 /** diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 5040053dad..e4baeff894 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1947,6 +1947,7 @@ MpInitLibInitialize ( UINTN ApResetVectorSize; UINTN BackupBufferAddr; UINTN ApIdtBase; + UINT32 ExpectedMicrocodeRevision; =20 OldCpuMpData =3D GetCpuMpDataFromGuidedHob (); if (OldCpuMpData =3D=3D NULL) { @@ -2131,6 +2132,14 @@ MpInitLibInitialize ( CpuMpData->InitFlag =3D ApInitDone; } for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { + ExpectedMicrocodeRevision =3D 0; + if (CpuMpData->CpuData[Index].MicrocodeEntryAddr !=3D 0) { + ExpectedMicrocodeRevision =3D ((CPU_MICROCODE_HEADER *)(UINTN)CpuM= pData->CpuData[Index].MicrocodeEntryAddr)->UpdateRevision; + } + DEBUG (( + DEBUG_INFO, "CPU[%04d]: Microcode revision =3D %08x, expected =3D = %08x\n", + Index, CpuMpData->CpuData[Index].MicrocodeRevision, ExpectedMicroc= odeRevision + )); SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); } } diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h index 0bd60388b1..66f9eb2304 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -144,6 +144,7 @@ typedef struct { UINT32 ProcessorSignature; UINT8 PlatformId; UINT64 MicrocodeEntryAddr; + UINT32 MicrocodeRevision; } CPU_AP_DATA; =20 // --=20 2.27.0.windows.1