From nobody Tue Feb 10 03:39:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52714+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52714+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578020683; cv=none; d=zohomail.com; s=zohoarc; b=FZmqKhq2MDHfK70eylN/OBoiXupLc/6B4FxhjndM8mn1JS9vh2EPwPkbKmUrso927gL3H9Yol4v9n42A1w2qXMIvRYgN4q+XvLEUKD2bjUmB0Q11+uZdP9NV5gimJQvbdjgqYJx3wOFINdJmn/3OUvosyHUJ5IlInsfIcT/AOQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578020683; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l4UJdOqhTjlpsJXEPohy6bNLpiWMawZGim1jH+V/w3A=; b=GDl7PxqPdtLX5ZaYEKgQo3TNRpTpPFjgprellx/nYfZxkmLC9MjMbvbppTzWqeUTqaEINFRLfbXOsNQlbBvG1R6B/Yg9/q34hH6NG2j0AFa6Su6wXhOFXrgfZULNqvYlMlQNcj+fDBsmY5pEhWpNBbTvykqGPcjilg8U+JLQfBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52714+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1578020683795110.19100873479545; Thu, 2 Jan 2020 19:04:43 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Y8KOYY1788612x35t8zfCsvO; Thu, 02 Jan 2020 19:04:43 -0800 X-Received: from mga04.intel.com (mga04.intel.com []) by mx.groups.io with SMTP id smtpd.web09.3729.1578020675360032184 for ; Thu, 02 Jan 2020 19:04:43 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2020 19:04:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,389,1571727600"; d="scan'208";a="252455123" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga002.fm.intel.com with ESMTP; 02 Jan 2020 19:04:42 -0800 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang Subject: [edk2-devel] [PATCH 07/13] SecurityPkg/Tcg2PhysicalPresenceLib: Use Pcd for user resp wait time Date: Fri, 3 Jan 2020 11:04:21 +0800 Message-Id: <20200103030428.28176-8-zhichao.gao@intel.com> In-Reply-To: <20200103030428.28176-1-zhichao.gao@intel.com> References: <20200103030428.28176-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com X-Gm-Message-State: toS7G4tOFMOnwMDWD4bC8USEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578020683; bh=vvoHPlk6/5+rbu1O8CafDrEV62iVh/L7s3m+/N7IY2Y=; h=Cc:Date:From:Reply-To:Subject:To; b=DV0KisMAgySF9cXtdY+Lz3Oo4XMIWaRsqTtGBhi1F/3TEM90gQQOwj8y052GRknTQ5d 4SMLtzT2kIK3d/NOhZvrSnHGAzAafT3wScdec49+I3i4Bhrr6dyNTEGdIHospI+lqByXe DHzOiaszMbEh5/hR5PEcBFX8U5f7UhSRfaw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2443 Use the pcd PcdPhysicalPresenceUserConfirmTimeout to control the wait time of user response. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Signed-off-by: Zhichao Gao --- .../DxeTcg2PhysicalPresenceLib.c | 61 ++++++++++++++----- .../DxeTcg2PhysicalPresenceLib.inf | 4 +- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physical= PresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physi= calPresenceLib.c index 081605f26c..1ae19436c2 100644 --- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c +++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.c @@ -31,6 +31,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include +#include =20 #define CONFIRM_BUFFER_SIZE 4096 =20 @@ -267,28 +269,57 @@ Tcg2ReadUserKey ( { EFI_STATUS Status; EFI_INPUT_KEY Key; - UINT16 InputKey; + UINT16 ConfirmKey; + UINTN Interval; + INT64 Timeout; =20 - InputKey =3D 0; + // + // delay 100 milli-second + // + Interval =3D 100; + ConfirmKey =3D (CautionKey) ? SCAN_F12 : SCAN_F10; + Timeout =3D (INT64)PcdGet32 (PcdPhysicalPresenceUserConfirmTimeout); + if (Timeout > 0) { + Timeout =3D (INT64)MultU64x32 ((UINT64)Timeout, 1000); + } else { + // + // Wait forever + // + Timeout =3D MAX_INT64; + } + + // + // Wait for user response within the time-out + // do { + MicroSecondDelay (Interval * 1000); + Status =3D gBS->CheckEvent (gST->ConIn->WaitForKey); if (!EFI_ERROR (Status)) { Status =3D gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); - if (Key.ScanCode =3D=3D SCAN_ESC) { - InputKey =3D Key.ScanCode; - } - if ((Key.ScanCode =3D=3D SCAN_F10) && !CautionKey) { - InputKey =3D Key.ScanCode; - } - if ((Key.ScanCode =3D=3D SCAN_F12) && CautionKey) { - InputKey =3D Key.ScanCode; + if (!EFI_ERROR (Status)) { + if (Key.ScanCode =3D=3D ConfirmKey) { + // + // User Confirmation + // + return TRUE; + } + + if (Key.ScanCode =3D=3D SCAN_ESC) { + // + // User Rejection + // + return FALSE; + } + } else if (Status =3D=3D EFI_DEVICE_ERROR) { + // + // If error, assume User Rejection + // + return FALSE; } } - } while (InputKey =3D=3D 0); - - if (InputKey !=3D SCAN_ESC) { - return TRUE; - } + Timeout -=3D Interval; + } while (Timeout > 0); =20 return FALSE; } diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Physical= PresenceLib.inf b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2Phy= sicalPresenceLib.inf index e1c7c20d52..afca48356e 100644 --- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.inf +++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenc= eLib.inf @@ -8,7 +8,7 @@ # This driver will have external input - variable. # This external input must be validated carefully to avoid security issue. # -# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2020, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -50,6 +50,7 @@ HobLib Tpm2CommandLib Tcg2PpVendorLib + TimerLib =20 [Protocols] gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES @@ -57,6 +58,7 @@ =20 [Pcd] gEfiSecurityPkgTokenSpaceGuid.PcdTcg2PhysicalPresenceFlags ## SOME= TIMES_CONSUMES + gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceUserConfirmTimeout =20 [Guids] ## SOMETIMES_CONSUMES ## HII --=20 2.21.0.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 (#52714): https://edk2.groups.io/g/devel/message/52714 Mute This Topic: https://groups.io/mt/69392334/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-