From nobody Thu Apr 25 10:23:45 2024 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+63177+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+63177+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595492106879982.3702924097295; Thu, 23 Jul 2020 01:15:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FbdtYY1788612xo6RfWpRCtS; Thu, 23 Jul 2020 01:15:06 -0700 X-Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [51.163.158.102]) by mx.groups.io with SMTP id smtpd.web11.7826.1595492104561349660 for ; Thu, 23 Jul 2020 01:15:05 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-7-JChFf7lfOsSOO-7JiB0giQ-1; Thu, 23 Jul 2020 10:14:59 +0200 X-MC-Unique: JChFf7lfOsSOO-7JiB0giQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XA1qNkfMqPqOTcnGoRzzAkvtt6Q/1RsOT+/I5UXUq3v2UqyWnjzcrZuLr7AaFR6W5E6I9GDkP7n79hJfJmrxXV9Fvste+V4CtR+eCJMDZG555KD3brVD+GmNK1vaiyacrLa6jbINYdeyyyqeKTUUBMyyNnXKgTl9/ak2MNtQOVUpeXeIKJGZSmKo9kaU3zZb9jaZ8IZ+Yyyzt4hdo72j/Stbu42ne80UlH7dCKrKQJN5wtCZXKsJdjVDp6Y0fXJdVWkXIhb2e7FeG8npPovJeIh7FbxuneXGk1xcqupMVBbSih4nl8pRQT9ug2F4tWOcMcvfOgOS9ldPxUzT2Jr8tg== 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=dqbb7JfMGuLK4L3QUsYGIrDQQ0aQIzeKaKgrNRfUe1Q=; b=UEL8uApGAGYBeTYMN/A1u5ofV+w+4Y2DuNfRxnDemZKjlOYI9ApzqCNbyRzMrTbuf72nA9N0eJGk1Ro48xX7R3tXKzAIlGs9tnfoBx5C56gGAN8G9Kvnou6nnx1LVa0exX2S9fbhP1pBeljZnFxUGzXr358532PemrAA9bRTPGkupC8LPc92I6N9iOvbjccbftRliV6LCe4gIaYEtYbRGWWh5gPF/hpK0QpEWBV5hpaIEUuAD1jHtANzKRK3nB5utcYjIGbkRLj2jlDQuZm2wfwPFETi9DCzjzHj/wNDoaGKlX+chR1dPterBBgWsB4zE0/LMX0Dzdf5dkn5aEAyOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none X-Received: from AM0PR0402MB3809.eurprd04.prod.outlook.com (2603:10a6:208:10::30) by AM0PR04MB6530.eurprd04.prod.outlook.com (2603:10a6:208:16a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.20; Thu, 23 Jul 2020 08:14:59 +0000 X-Received: from AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::a14c:d441:c8a9:77ba]) by AM0PR0402MB3809.eurprd04.prod.outlook.com ([fe80::a14c:d441:c8a9:77ba%6]) with mapi id 15.20.3216.020; Thu, 23 Jul 2020 08:14:58 +0000 From: "Gary Lin" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH] SecurityPkg/Library: Adjust the status codes for SubmitCommand Date: Thu, 23 Jul 2020 16:14:37 +0800 Message-Id: <20200723081437.5644-1-glin@suse.com> X-ClientProxiedBy: AM0P190CA0006.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::16) To AM0PR0402MB3809.eurprd04.prod.outlook.com (2603:10a6:208:10::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from GaryWorkstation.suse.cz (60.251.47.115) by AM0P190CA0006.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:190::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23 via Frontend Transport; Thu, 23 Jul 2020 08:14:54 +0000 X-Originating-IP: [60.251.47.115] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3467a00-b8dd-4aa0-bf32-08d82ee07c0f X-MS-TrafficTypeDiagnostic: AM0PR04MB6530: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: N67YmjGkKO/OUTLaFO4NX30OhwFlGkEYIuAUALBGI+h7YeuQTuZvkHpEtPvZTOn8dha2CsvYCXdL+YOWLs1PJYQjB4SFp2LToX6fNNESYcdbnYIrLHPAdD4ytExGbE6r62uLDcQAKoVtXQbFoHAAS0MLtV8fM3Sjewwu/jnSsD4/9W6GWWgvQHAayBwdMv/hDdycjlHgSINbCE71PkTCJ7gZNP31IzibDQfLukcfGPtkviNwU/2dqY2DtpYJmlnUOgI+ITja0yAjzQ+SSfnY8R+MEPyZT2xpzzpQrsWBY0QnU3InzbCMiCJvdWzTxNBF X-MS-Exchange-AntiSpam-MessageData: gWXd1bZItj25MV0R41leoY+A8sKaVwUaEv/Y1IIa7FUqqa8+aUp0Tr+9FVgU/N6xtGqxdSDvlbxbE5g8kyHzaVdw6MqQz9B5L0kK4GFFivqiq9s4Z4gCOtFoAbd3+gBbGHwAkNYHNIms0zY79yG4fihkr1D2wtZRfeuy6DzdgBICxxOxOwuN0XqFxgFaPzaK5Z+2Mk09uqQ7f1SpxYIC/85otUgWTqeEavDUYaSYTW3xyp3KPbOtXkgl5H6Hy3OY7cdZi5rpRmD69hyvqoCxT3mlhyEmYwmkL/3PBMHqXxm9zNNYosbo0cdaTbNlzsaF4EpwApBqg+NNP1tKi+3znM+6S5YCDgb1IEpFHdX/M6JuBj/QwBf5YkgBaEgXBTYysJBAW5jZaxocRgk5kDWstfdK1meOS2jLVai7JkCnvqHH9JI5V8KSsQNlQ9rjqb2EDrWJbhgEglDjLm5hOdbweIAjpD4ktzqkhH7IrSQmc+o= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3467a00-b8dd-4aa0-bf32-08d82ee07c0f X-MS-Exchange-CrossTenant-AuthSource: AM0PR0402MB3809.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2020 08:14:58.8009 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uLy5tA+BkQaBjmbHTflq8LJr8hBwRrOnfoJun1fB0ls7NBGohfJrEVhvLdsYQjY9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6530 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,glin@suse.com X-Gm-Message-State: OTSYLElJ0wJghTv85AQYAwiKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595492106; bh=AqakiDm1ht4c7YtSVKRvZcBUwFZWNZTg08GUhWBJsGY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=MP251c6e+mnM9uM0kVl4Jn5pgpQraxBPre0fQfO8qECacyHPNPNlwV4j1hZlsskGnQn Vz7bl2oqw69OBUXnPyFo0Z6vx0daOYSx1GbtwMa3+CH8iVp0lWiJSuRWrg8bdaIKnIjgR IhrWaW71CYd+n5hJJMEjRKM71EDYGH6GMOw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The status codes of EFI_TCG2_PROTOCOL.SubmitCommand() defined in "TCG EFI Protocol Specification for TPM 2.0" Version 1.0 Revision 0.13 are EFI_SUCCESS, EFI_DEVICE_ERROR, EFI_INVALID_PARAMETER, and EFI_BUFFER_TOO_SMALL. Since Tcg2SubmitCommand() returns the status code of Tpm2SubmitCommand() directly, Tpm2SubmitCommand() should follow the spec to return the status codes. However, Tpm2SubmitCommand() may return the status codes other than those defined in the spec in the following call path: Tpm2SubmitCommand() -> DTpm2SubmitCommand() -+-> PtpCrbTpmCommand() | +-> Tpm2TisTpmCommand() 1. Tpm2SubmitCommand() returned EFI_UNSUPPORTED if the function isn't implemented in mInternalTpm2DeviceInterface. Change it to EFI_DEVICE_ERROR to align the spec. 2. DTpm2SubmitCommand() returned EFI_NOT_FOUND when PtpInterface doesn't match any interface. Change it to EFI_DEVICE_ERROR to align the spec. 3. PtpCrbTpmCommand() returned EFI_UNSUPPORTED in a conditional check. Change it to EFI_DEVICE_ERROR. Also update the comment to reflect this change. 4. At the end of PtpCrbTpmCommand(), it returns the status code from PtpCrbWaitRegisterBits() directly. However, PtpCrbWaitRegisterBits() may return EFI_TIMEOUT. Convert EFI_TIMEOUT to EFI_DEVICE_ERROR instead of returning it directly. 5. Tpm2TisTpmCommand() returned EFI_UNSUPPORTED in a conditional check. Change it to EFI_DEVICE_ERROR. Also update the comment to reflect the change. Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Gary Lin --- SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 9 +++++---- SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c | 3 +-- .../Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c b/SecurityPkg/= Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c index 2c73385b6ce5..91b5b16095ac 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c @@ -130,7 +130,6 @@ PtpCrbRequestUseTpm ( @retval EFI_SUCCESS Operation completed successfully. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small. @retval EFI_DEVICE_ERROR Unexpected device behavior. - @retval EFI_UNSUPPORTED Unsupported TPM version =20 **/ EFI_STATUS @@ -296,7 +295,7 @@ PtpCrbTpmCommand ( // TPM2 should not use this RSP_COMMAND if (SwapBytes16 (Data16) =3D=3D TPM_ST_RSP_COMMAND) { DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMA= ND)); - Status =3D EFI_UNSUPPORTED; + Status =3D EFI_DEVICE_ERROR; goto GoIdle_Exit; } =20 @@ -357,6 +356,9 @@ GoIdle_Exit: 0, PTP_TIMEOUT_C ); + if (EFI_ERROR(Status)) { + Status =3D EFI_DEVICE_ERROR; + } } =20 return Status; @@ -374,7 +376,6 @@ GoIdle_Exit: @retval EFI_SUCCESS Operation completed successfully. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small. @retval EFI_DEVICE_ERROR Unexpected device behavior. - @retval EFI_UNSUPPORTED Unsupported TPM version =20 **/ EFI_STATUS @@ -584,7 +585,7 @@ DTpm2SubmitCommand ( OutputParameterBlockSize ); default: - return EFI_NOT_FOUND; + return EFI_DEVICE_ERROR; } } =20 diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c b/SecurityPkg/= Library/Tpm2DeviceLibDTpm/Tpm2Tis.c index 9a809612b3d9..1fb9cfccc46c 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c @@ -199,7 +199,6 @@ TisPcRequestUseTpm ( @retval EFI_SUCCESS Operation completed successfully. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small. @retval EFI_DEVICE_ERROR Unexpected device behavior. - @retval EFI_UNSUPPORTED Unsupported TPM version =20 **/ EFI_STATUS @@ -346,7 +345,7 @@ Tpm2TisTpmCommand ( // TPM2 should not use this RSP_COMMAND if (SwapBytes16 (Data16) =3D=3D TPM_ST_RSP_COMMAND) { DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMA= ND)); - Status =3D EFI_UNSUPPORTED; + Status =3D EFI_DEVICE_ERROR; goto Exit; } =20 diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe= .c b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c index 227aa406bda2..d97c4d65fd0a 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c +++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.c @@ -38,7 +38,7 @@ Tpm2SubmitCommand ( ) { if (mInternalTpm2DeviceInterface.Tpm2SubmitCommand =3D=3D NULL) { - return EFI_UNSUPPORTED; + return EFI_DEVICE_ERROR; } return mInternalTpm2DeviceInterface.Tpm2SubmitCommand ( InputParameterBlockSize, --=20 2.27.0 -=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 (#63177): https://edk2.groups.io/g/devel/message/63177 Mute This Topic: https://groups.io/mt/75741903/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-