From nobody Tue May 21 06:27:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107177+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107177+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1690218449754686.120707601128; Mon, 24 Jul 2023 10:07:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=uYTIfO8pIfvgyiLxU1PvFT99vrVmg5cvMvgmccCDK8A=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Received:X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:From:To:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator:msip_labels:x-ms-publictraffictype:x-ms-traffictypediagnostic:x-ms-office365-filtering-correlation-id:x-exotenant:x-ms-exchange-senderadcheck:x-ms-exchange-antispam-relay:x-microsoft-antispam-message-info:x-ms-exchange-antispam-messagedata-chunkcount:x-ms-exchange-antispam-messagedata-0:MIME-Version:X-OriginatorOrg:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-originalarrivaltime:X-MS-Exchange-CrossTenant-fromentityheader:X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype:X-MS-Exchange-CrossTenant-userprincipalname:X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-Proofpoint-GUID:X-Proofpoint-ORIG-GUID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Language:Content-Type; s=20140610; t=1690218449; v=1; b=B21o2e/dj7XcBX7uTz+QlOZiLdT0EfneB0YlN3R5Y7Vyd/UKhHH8ssWbi06TG2tVgyJ1gN9C G787wEfk0tS7CXnDk0emcKuSXwMpLlJjjJlxm/TtLISB4bpF5qHrQH3qp9a+EBFAaiSbqfQzseN rKiEJ9nqd56e+oRrawlBe2d0= X-Received: by 127.0.0.2 with SMTP id 4s8dYY1788612xRZJaK4x4OP; Mon, 24 Jul 2023 10:07:29 -0700 X-Received: from mx0b-00154904.pphosted.com (mx0b-00154904.pphosted.com [148.163.137.20]) by mx.groups.io with SMTP id smtpd.web11.16107.1689969106110554437 for ; Fri, 21 Jul 2023 12:51:46 -0700 X-Received: from pps.filterd (m0170396.ppops.net [127.0.0.1]) by mx0b-00154904.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36LEm13S019604; Fri, 21 Jul 2023 15:51:32 -0400 X-Received: from mx0b-00154901.pphosted.com (mx0b-00154901.pphosted.com [67.231.157.37]) by mx0b-00154904.pphosted.com (PPS) with ESMTPS id 3ryv3hsa05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 15:51:31 -0400 X-Received: from pps.filterd (m0144103.ppops.net [127.0.0.1]) by mx0b-00154901.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36LJUd7P032454; Fri, 21 Jul 2023 15:51:31 -0400 X-Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by mx0b-00154901.pphosted.com (PPS) with ESMTPS id 3rypcx0hwa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 15:51:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PLu+tWTF5Oyu0EIj7VipzIb2Bicvt/OIJpnFYXnomxkfA8UcR6di3dX4ZNwWGId7UZ5HY+RMU3m+zZZyVgsgv62XXDiOh2uatAW65+w4pa1D6cDUNhzftbjDZE0XgYnciIxk9Wv4TClmna+ituMy7NArODBW+4Rkdk0M61IAXP3rDwyi6ZO+k1cYRW/+fjgZX1uywVFBMEZqQ7W7Rw7F83fjqGBsuZp+O7VMvICduDAzngn4CAvdhUxJNe7+6lKzuWQXvu5TBgQEezl2GQn4C49IdNZlFL/WDlcmWvpTZ6e+YiDfMcfP+hYeSZwP23u6tPYva6GNGDLevoUUQuHp2A== 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=DioD+0E7q2VQcyCSq/kVj0a3T5mJdJbkfOwyewoq8pE=; b=LOBYDITIgNBEqLqpzvFL2GlcBzrxzoYRsivxwZMbwFxIJMMTydFLuluCTazyBnbDTPxEFeGnZAq97UGy+aIhHKsRSzvFI4RYMW6mESLozJ5UoS/LRy7IdZKebzbzm++F2YZyonwT46lH8+m2BgtJFs9ArpkA2dRd3PG78GhHUywLUbK+hvtEHjqIdZ5xcpx9ehIJ/cwRR7+k9oEyqVskrhaqB0mfjeLOzFij/NRpJDJ5BdsIAfXuXFQME8yvH157rkShGQ3CGFEG+cV0Xv8ORgV+c0eE9YqCmlNtd+7zSTGjIEcHMXGIqfh3aGfW2QIEZ7QN5SmdhlAiTQeDVEO7Qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=dell.com; dmarc=pass action=none header.from=dell.com; dkim=pass header.d=dell.com; arc=none X-Received: from SA1PR19MB5572.namprd19.prod.outlook.com (2603:10b6:806:229::8) by IA1PR19MB6130.namprd19.prod.outlook.com (2603:10b6:208:3d6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28; Fri, 21 Jul 2023 19:51:27 +0000 X-Received: from SA1PR19MB5572.namprd19.prod.outlook.com ([fe80::450a:af8c:1e79:6116]) by SA1PR19MB5572.namprd19.prod.outlook.com ([fe80::450a:af8c:1e79:6116%4]) with mapi id 15.20.6609.024; Fri, 21 Jul 2023 19:51:27 +0000 From: "Poosapalli, Karunakar via groups.io" To: "jiewen.yao@intel.com" , gaoliming , "devel@edk2.groups.io" Subject: [edk2-devel] [PATCH] SecurityPkg: DxeTcg2PhysicalPresenceLib for Clear Graphics Screen To unblock and Display TPM messages Thread-Topic: [edk2-devel] [PATCH] SecurityPkg: DxeTcg2PhysicalPresenceLib for Clear Graphics Screen To unblock and Display TPM messages Thread-Index: Adm8DJurGgUFmZ0XSiuVHtzYqmi7Vg== Date: Fri, 21 Jul 2023 19:51:27 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Enabled=true; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_SetDate=2023-07-21T19:51:25Z; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Method=Standard; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Name=No Protection (Label Only) - Internal Use; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_SiteId=945c199a-83a2-4e80-9f8c-5a91be5752dd; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_ActionId=54a9fd4a-0692-40ef-a961-67126fdaffb1; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_ContentBits=2 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR19MB5572:EE_|IA1PR19MB6130:EE_ x-ms-office365-filtering-correlation-id: 6d803476-18ad-4124-a07a-08db8a23df19 x-exotenant: 2khUwGVqB6N9v58KS13ncyUmMJd8q4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: r2c2nEEdBYFSkR/yX/s2v/+/of4zIj9YCuiReQtSiaYndGBFO7DCNVDhMezPYC1ZnzTqJuQZHBcjORuTMVz3BGe0py8+LX8NU/o+Sw3xCIq2iKSVKF7++ATSzjPkD6Zt0xm17oUUY46fohHcakWy6DvC3zRL+giKgNFeB9fpuqIu4r74MJsW8K74qAf4I2qS/O6njgtxDPsI8V+rMJS8Clw0L9AtMlT99nKjyEZ0cmAd3E/ZzZ5J60Z6fR8RN/V44+KOK/TsSH6YY08D4p8o1iBEJ6ZRydx2toAJXbKT8nHDEdheN5JHoGqOyC3/4ub1Xs0lM4B5P9oOOcDBcclSDUoeo/jkD2Hgewy8KwMYNxSy8KShZa5t68mougAXiuuw+RXtehAJzTIrpk0JBa7dQK2WmB9FKKPYg5ivtQRDX8K4zyQPre+tlM5sc6B4Pf2O8XqpHSEu1lUCV2CY6uXsKu79mIMgRDn8G6TK4ATWLc7AC0XGQbjoj+ZhQQ3Dv2z4/TgI0b7o3bWXRJmGadrnLBaFHDcowqVNKUw9peuiAqI2C/w0YN6sCwbcboLgcmkkd8suL6bO106Bm9WeaeTZ91POv9CNP2uPGd6Xrtf6SGI= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rTiE/JmwsbNRuHV1pTiCKgQr9Qz1HQqYi6F38sUxlCX3liii2t6favOUUjHU?= =?us-ascii?Q?Nfz49TF5q1AAkyGRtHaB/oVDtdB5D7Oj1UEL+F+fRVdHfy0xselRkD41xrJM?= =?us-ascii?Q?9EGD3ohVSGnwC2Cxk//hBHb/a/hWPHVrtAxh80hzWliA21CcDIrf29/JX+Zl?= =?us-ascii?Q?lGr8++CxatKEllrzcJTx+Z5eTwAJYZxo3/ezPliOk87d7zDTh+eDs7boEodD?= =?us-ascii?Q?0kAJhlCl9Slaub3N0caanhYrw0/fjKXi1WPCAf49Gm7A/L5Q753PRYQ0xLNl?= =?us-ascii?Q?9yTEtstjKGUzetoHwCIlJT55R4guOlWYLORGgjCxTnIVvvtE4WRAGdzeqRDj?= =?us-ascii?Q?lOi/i2Xa40Hbwl8d9r9tFQFZcHOnfHQdNJxW447iEpANqgq/djSSN/5uHknc?= =?us-ascii?Q?aS/A4kSLN79PNCTXLxLqdvxpg3uVvcQ7vW3+j+6hckKSUYedR8ES9e0CeBq4?= =?us-ascii?Q?XZJFtWbeyl/62VJ7YUbSNDQkEAqwFt2SAiflql0/2807zJiaRAjV/jwMq8X8?= =?us-ascii?Q?mcy0SaYDDPD1oSnADJan5o8wPegpcxWhFXAohDMYUZwMi22SrABf2IC5cTwr?= =?us-ascii?Q?lUO4dCfBBkvio7wDUS+p6vcAWvgMFRqP6gz4osr9SczKZTdOImnWr7pf/EiR?= =?us-ascii?Q?AMb4tA0kvGjOtpM4YCvxQXIH5PFh33QmmuD0cqvDw9pq1G7XhVlJTaMgIgTd?= =?us-ascii?Q?N7JmvbAp8evAjlMn7EfmwA0LkevC9ZOh+Xdy4gdbJ1rtyWlKccfYlGmhHrU5?= =?us-ascii?Q?LaHitcaxHd7FS/5I9mB/ES8rEbQ2HUjKBaJMCb5h8Q8Lp57XjvztUFnCR+ES?= =?us-ascii?Q?oqPqySPDVw+lEfL/YyxZSuwKRpUs2k84LiJF+9eI/9MQseZfcC7JOC1/t782?= =?us-ascii?Q?ursXdBw9wK8tgKyIZSHpCEyjysH+WpdEKH9bazYYrIyTWTD7MjGDrRkwiwfR?= =?us-ascii?Q?P/LGRi1NA06L3ncm+jFRpa2F7DnuLRENEgeu+FgANHVXGlelpE4PqEw3rd5+?= =?us-ascii?Q?U7G3X3b86DBuzKqXwxYb1ySyrsXcyKAQ1v3FVFrYBtQm63Dh3hFyn95/pmyD?= =?us-ascii?Q?J7ASnmi5aZdl2p9IlJY+eC9BC+7My0TCSuz66ZQGf1NKBQoMVgSxK4tuhVQt?= =?us-ascii?Q?cIvmF3M5THmD504S34flU10liaQoCN0jrtzrLCffP2tSdON90T6C7qZnjnIm?= =?us-ascii?Q?L8KsI4RKG93iPwFZgXItgRVIRjSjf4TwY4g8gzbdKZjlf15cQwgEbnyHhwMc?= =?us-ascii?Q?55F99isfwpiCTkLCctEm33lyHqdbzad98QfGK7/Z2npkSHNnG43f0c+IXgPY?= =?us-ascii?Q?+Y5g+h6uIgGT+2VgmJNWLwZ2O9J1HVGPOmfqSlGVdrNpKWDcPnzN0xxkFczD?= =?us-ascii?Q?6AcjQUvSC56ANz3cPkLPk/1zLtteK0w7W4LNjsGFbL5TY0n+Fhpc6JpkXPxw?= =?us-ascii?Q?CLgz3+4CMQiOEE/AP+G2CkXGzGHV/OomFa658oZUXRC2wcryhqFfXira34qO?= =?us-ascii?Q?4oTPTKRuSvZANYmFBJZo7iiNtQEByrKx/wGunRMHO2l3RsWZyFY+xl2O1/AU?= =?us-ascii?Q?wCBe3/DgnL0g5TTCcGw3+CHtM6GvUAr+8mVPFm0+YswZSkxTI18JY8c42jvG?= =?us-ascii?Q?IQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: Dell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR19MB5572.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d803476-18ad-4124-a07a-08db8a23df19 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2023 19:51:27.4443 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 945c199a-83a2-4e80-9f8c-5a91be5752dd X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: S8bNwnzk7RdfOehpTajie4ET7N3p9Eb9c6GAovhB/vAIboJGv223+I2sW41LkVYZovzknw4mvJnKwZbwUCy73yrpCCSkE1uKXbDBbTQpPTs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR19MB6130 X-Proofpoint-GUID: 1O6B4-XyDecDBpnvtYkJp6hLbzG5Wtun X-Proofpoint-ORIG-GUID: 1O6B4-XyDecDBpnvtYkJp6hLbzG5Wtun 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,KarunakarPoosapalli@Dell.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 2lya2Bbq79AnkGQ70wOlSDN6x1787277AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_SA1PR19MB55724CF7157B4A94CBB8BF618B3FASA1PR19MB5572namp_" X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690218450360100021 --_000_SA1PR19MB55724CF7157B4A94CBB8BF618B3FASA1PR19MB5572namp_ Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Patch review for Bugzilla - https://bugzilla.tianocore.org/show_bug.cgi?id= =3D4462 From c537f9c5c9e02c54e27466b96fe33555afccd358 Mon Sep 17 00:00:00 2001 From: Karunakar Poosapalli karunakar_poosapalli@dell.com Date: Sat, 22 Jul 2023 01:13:44 +0530 Subject: [PATCH] Patch - Enhance Tcg2 to clear graphics before printing the messages on screen [Background] Tcg2UserConfirm() Function is used to display any user conformation message= s on the console Function Definition Full path - SecurityPkg\Library\DxeTcg2PhysicalPresence= Lib\DxeTcg2PhysicalPresenceLib.c [Issue] In the current Tcg2UserConfirm() implementation, This function forms a dest= ination string to be displayed on the console and directly Print the messag= e on Console. But there is no logic added to clear the graphics before printing the messa= ges on the screen. There are some scenarios where Tcg messages might have been blocked by some= other GUI or messages on Console. 1. When there are some messages or logos already displayed in the content= on the console, TCG message will NOT be displayed or corrupted to the End user. 2. There could be a Custom logo displaying on the screen which actually b= locks the screen. [Solution] 1. As TCG user confirmation is the highest priority and it blocks the POS= T until the user presses the input key. Before TCG messages Print on the console, there= should be logic added to clear the graphics screen Cc: gaoliming gaoliming@byosoft.com.cn Cc: Jiewen Jiewen.yao@intel.com REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4462 Signed-off-by: Karunakar Poosapalli karunakar_poosapalli@dell.com --- .../DxeTcg2PhysicalPresenceLib.c | 74 +++++++++++++++++++ .../DxeTcg2PhysicalPresenceLib.inf | 1 + 2 files changed, 75 insertions(+) diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physical= PresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physi= calPresenceLib.c index de4f5e583d..bd486f3b5b 100644 --- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c +++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c @@ -251,6 +251,74 @@ Tcg2ExecutePhysicalPresence ( } } +/** + Clear Graphics Screen To unblock and Display TPM messages + + @param[in] VOID + @retval EFI_STATUS +**/ +EFI_STATUS +ClearGraphicsScreenToDisplayTpmMessages() +{ + EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + UINTN Index; + EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; + + DEBUG((DEBUG_INFO, "ClearGraphicsScreenToDisplayTpmMessages Entry...\n")= ); + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiGraphicsOutputProtocolGuid, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + DEBUG((DEBUG_INFO, "LocateHandleBuffer Status =3D %r, NumberOfHandles = =3D %x\n", Status, NumberOfHandles)); + + if (EFI_ERROR (Status)) + { + return Status; + } + + for (Index =3D 0; Index < NumberOfHandles; Index++) + { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiDevicePathProtocolGuid, + (VOID *)&GopDevicePath + ); + DEBUG((DEBUG_INFO, "HandleProtocol GopDevicePath Status =3D %r, Inde= x =3D %x\n", Status, Index)); + if (EFI_ERROR (Status)) + { + continue; + } + + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiGraphicsOutputProtocolGuid, + (VOID **) &Gop + ); + DEBUG((DEBUG_INFO, "HandleProtocol Gop Status =3D %r, Index =3D %x\n= ", Status, Index)); + if (EFI_ERROR(Status)) + { + continue; + } + + // Clear the graphics screen to black + Status =3D Gop->Blt(Gop, NULL, EfiBltVideoFill, 0, 0, 0, 0, Gop->Mod= e->Info->HorizontalResolution, Gop->Mode->Info->VerticalResolution, 0); + DEBUG((DEBUG_INFO, "Gop->Blt Status =3D %r, Index =3D %x\n", Status,= Index)); + if (EFI_ERROR(Status)) { + continue; + } + } + + gBS->FreePool (HandleBuffer); + DEBUG((DEBUG_INFO, "ClearGraphicsScreenToDisplayTpmMessages Exit...\n")); + return Status; +} /** Read the specified key for user confirmation. @@ -576,6 +644,12 @@ Tcg2UserConfirm ( BufSize -=3D StrSize (ConfirmText); UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, Tmp= Str2); + // + //Clear Graphics Screen To unblock and Display TPM messages + // + Status =3D ClearGraphicsScreenToDisplayTpmMessages(); + DEBUG((DEBUG_INFO, "ClearGraphicsScreenToDisplayTpmMessages Status =3D %= r\n", Status)); + DstStr[80] =3D L'\0'; for (Index =3D 0; Index < StrLen (ConfirmText); Index +=3D 80) { StrnCpyS (DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Ind= ex, sizeof (DstStr) / sizeof (CHAR16) - 1); diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physical= PresenceLib.inf b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Phy= sicalPresenceLib.inf index e1c7c20d52..de423cfd13 100644 --- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.inf +++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.inf @@ -54,6 +54,7 @@ [Protocols] gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES + gEfiGraphicsOutputProtocolGuid ## CONSUMES [Pcd] gEfiSecurityPkgTokenSpaceGuid.PcdTcg2PhysicalPresenceFlags ## SOME= TIMES_CONSUMES -- 2.17.0.windows.1 Internal Use - Confidential -=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 (#107177): https://edk2.groups.io/g/devel/message/107177 Mute This Topic: https://groups.io/mt/100333271/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_SA1PR19MB55724CF7157B4A94CBB8BF618B3FASA1PR19MB5572namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Patch review for Bugzilla -  https://bugzilla.tianocore.= org/show_bug.cgi?id=3D4462

 

From c537f9c5c9e02c54e27466b96fe33555afccd358 Mon Se= p 17 00:00:00 2001

From: Karunakar Poosapalli karunakar_poosapalli@dell.com

Date: Sat, 22 Jul 2023 01:13:44 +0530

Subject: [PATCH] Patch - Enhance Tcg2 to clear graph= ics before printing the

messages on screen

 

[Background]

Tcg2UserConfirm() Function is used to display any us= er conformation messages on the console

Function Definition Full path - SecurityPkg\Library\= DxeTcg2PhysicalPresenceLib\DxeTcg2PhysicalPresenceLib.c

 

[Issue]

In the current Tcg2UserConfirm() implementation, Thi= s function forms a destination string to be displayed on the console and di= rectly Print the message on Console.

 

But there is no logic added to clear the graphics be= fore printing the messages on the screen.

 

There are some scenarios where Tcg messages might ha= ve been blocked by some other GUI or messages on Console.

  1. When there are some messages or logos alre= ady displayed in the content on the console,

     TCG message will NOT be dis= played or corrupted to the End user.

  2. There could be a Custom logo displaying on= the screen which actually blocks the screen.

 

[Solution]

  1. As TCG user confirmation is the highest pr= iority and it blocks the POST until the user

     presses the input key. Befo= re TCG messages Print on the console, there should be logic

     added to clear the graphics= screen

 

Cc: gaoliming gaoliming@byosoft.com.cn

Cc: Jiewen  Jiewen.yao@intel.com

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4462

Signed-off-by: Karunakar Poosapalli karunakar_poosapalli@dell.com

---

.../DxeTcg2PhysicalPresenceLib.c   &n= bsp;          | 74 +++++++++++= ++++++++

.../DxeTcg2PhysicalPresenceLib.inf   =          |  1 +

2 files changed, 75 insertions(+)

 

diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPres= enceLib/DxeTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalP= resenceLib/DxeTcg2PhysicalPresenceLib.c

index de4f5e583d..bd486f3b5b 100644

--- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib= /DxeTcg2PhysicalPresenceLib.c

+++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib= /DxeTcg2PhysicalPresenceLib.c

@@ -251,6 +251,74 @@ Tcg2ExecutePhysicalPresence (

   }

}

+/**

+  Clear Graphics Screen To unblock and Display= TPM messages 

+

+  @param[in]  VOID

+  @retval     EFI_STATUS

+**/

+EFI_STATUS

+ClearGraphicsScreenToDisplayTpmMessages()

+{

+  EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;

+  EFI_STATUS Status;

+  EFI_HANDLE     &nbs= p;            &= nbsp;           *HandleBu= ffer;

+  UINTN      &nb= sp;            =             &nb= sp;   NumberOfHandles;

+  UINTN      &nb= sp;            =             &nb= sp;   Index;

+  EFI_DEVICE_PATH_PROTOCOL   &n= bsp;            *Gop= DevicePath;

+

+  DEBUG((DEBUG_INFO, "ClearGraphicsScreen= ToDisplayTpmMessages Entry...\n"));

+

+  Status =3D gBS->LocateHandleBuffer (=

+        &nb= sp;   ByProtocol,

+        &nb= sp;   &gEfiGraphicsOutputProtocolGuid,

+        &nb= sp;   NULL,

+        &nb= sp;   &NumberOfHandles,

+        &nb= sp;   &HandleBuffer

+        &nb= sp;   );

+  DEBUG((DEBUG_INFO, "LocateHandleBuffer = Status =3D %r, NumberOfHandles =3D %x\n", Status, NumberOfHandles));

+

+  if (EFI_ERROR (Status))

+  {

+    return Status;

+  }

+  for (Index =3D 0; Index < NumberOfHandles= ; Index++)

+    {

+      Status =3D gBS->H= andleProtocol (

+        &nb= sp;       HandleBuffer[Index],

+        &nb= sp;       &gEfiDevicePathProtocolGuid,

+        &nb= sp;       (VOID *)&GopDevicePath

+        &nb= sp;       );

+      DEBUG((DEBUG_INFO, &= quot;HandleProtocol GopDevicePath Status =3D %r, Index =3D %x\n", Stat= us, Index));

+      if (EFI_ERROR (Statu= s))

+        {

+        &nb= sp; continue;

+        }

+

+      Status =3D gBS->H= andleProtocol (

+        &nb= sp;       HandleBuffer[Index],

+        &nb= sp;       &gEfiGraphicsOutputProtocolGuid= ,

+        &nb= sp;       (VOID **) &Gop

+        &nb= sp;       );

+      DEBUG((DEBUG_INFO, &= quot;HandleProtocol Gop Status =3D %r, Index =3D %x\n", Status, Index)= );

+      if (EFI_ERROR(Status= ))

+        {

+        &nb= sp;   continue;

+        }

+

+      // Clear the graphic= s screen to black

+      Status =3D Gop->B= lt(Gop, NULL, EfiBltVideoFill, 0, 0, 0, 0, Gop->Mode->Info->Horizo= ntalResolution, Gop->Mode->Info->VerticalResolution, 0);

+      DEBUG((DEBUG_INFO, &= quot;Gop->Blt Status =3D %r, Index =3D %x\n", Status, Index));=

+      if (EFI_ERROR(Status= )) {

+        continue= ;

+      }

+    }

+

+  gBS->FreePool (HandleBuffer);<= /p>

+  DEBUG((DEBUG_INFO, "ClearGraphicsScreen= ToDisplayTpmMessages Exit...\n"));

+  return Status;

+}

/**

   Read the specified key for user confirm= ation.

@@ -576,6 +644,12 @@ Tcg2UserConfirm (

   BufSize -=3D StrSize (ConfirmText);

   UnicodeSPrint (ConfirmText + StrLen (Co= nfirmText), BufSize, TmpStr1, TmpStr2);

+  //

+  //Clear Graphics Screen To unblock and Displ= ay TPM messages

+  //

+  Status =3D ClearGraphicsScreenToDisplayTpmMe= ssages();

+  DEBUG((DEBUG_INFO, "ClearGraphicsScreen= ToDisplayTpmMessages Status =3D %r\n", Status));

+

   DstStr[80] =3D L'\0';

   for (Index =3D 0; Index < StrLen (Co= nfirmText); Index +=3D 80) {

     StrnCpyS (DstStr, sizeof (D= stStr) / sizeof (CHAR16), ConfirmText + Index, sizeof (DstStr) / sizeof (CH= AR16) - 1);

diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPres= enceLib/DxeTcg2PhysicalPresenceLib.inf b/SecurityPkg/Library/DxeTcg2Physica= lPresenceLib/DxeTcg2PhysicalPresenceLib.inf

index e1c7c20d52..de423cfd13 100644

--- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib= /DxeTcg2PhysicalPresenceLib.inf

+++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib= /DxeTcg2PhysicalPresenceLib.inf

@@ -54,6 +54,7 @@

[Protocols]

   gEfiTcg2ProtocolGuid   &= nbsp;           &nbs= p; ## SOMETIMES_CONSUMES

   gEdkiiVariableLockProtocolGuid &nb= sp;     ## SOMETIMES_CONSUMES

+  gEfiGraphicsOutputProtocolGuid  &n= bsp;    ## CONSUMES

 [Pcd]

   gEfiSecurityPkgTokenSpaceGuid.PcdTcg2Ph= ysicalPresenceFlags       ## SOMETIMES_CONSUM= ES

--

2.17.0.windows.1

 


Internal Use - Con= fidential

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#107177) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [importer@patchew.org]

_._,_._,_
--_000_SA1PR19MB55724CF7157B4A94CBB8BF618B3FASA1PR19MB5572namp_--