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.75]) by mx.groups.io with SMTP id smtpd.web10.12176.1595392278275583880 for ; Tue, 21 Jul 2020 21:31:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=apoCQ1WS; spf=pass (domain: vmware.com, ip: 40.107.220.75, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hWIH9VC7ycd7MYMhpxm0hwAgqjv6fh1XKreBZoXA5qvArbjQvWZd77RJjEEohfjlcGfKWrRowQVnrFw0JkuX+67OpfPhrYHGVGbUPA5JDh6V7FsAfan2+qMBPKMDKuBmngKlvhh1YnnyzGOBhY8beG3zB8qQagp7DqteGvgdXftCbvORJ56WN0lcG/qHXbv5gqifJZ6hIydoW05noqDsh4I/+XQ0wlZ7TyHM+NYyi/vRCUZ5SAyRqi2lAST9iSUyFGbUCpSGcwlnpW3RiKEjaCPRjDIkrjWyegujoOgeY66fHUhMgO6RHWrma7q+NVZvMlaucSwiBE80j0zQJtyLog== 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=i1wBtGQT0lY4ecJ/d89XZE7MarX2b8ZqQl9pRJshQfo=; b=dyTEx7CZtsuJB4UcE6+t3gyE+JJ8DR8c+ZN2KnZHBQZHfMXa75bfo7LRnFUero7Wt8yG7Y/KT7w42QKgEKOB4JVa9pBNFZ6n5SQWgt/GqMUDtxDy6GcfoG2gmmkB6V3ynryOYbJJ/yaA/gnJXv8M32VUZ9+YrESbMTJQEyQF+yVbQ1GgqDrKs+bfU5mD9454apQah3iW3FYJxFnpia4Klg5+1JO4U0j3r2Ni8MinYrzz+OSPlJJz9zBX6EebHFvV29/AzKf6t2IB/gOyD1nQeWbhseQyVpJIUKjWTt0d/hPv1zrDXrzmZnjOBo2iKHBZjmIg2W0P+h4iY7EYAcfMPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i1wBtGQT0lY4ecJ/d89XZE7MarX2b8ZqQl9pRJshQfo=; b=apoCQ1WSH/WwcgXnXRg8ajHcFvgqONN/fcca5xaprkUEvuHE6fygkFB3gcBp/EKrdWDHXW3tnX1/EBGoNg0mmJy7U4HYJ/JBre/Pp1IEr6VF5mZuHQ4p0N5jtsaRi8uJ70LKwAq5lC5BD3B8aUyvuhF0SsHvARQgorDU/3oVQ9s= Received: from BN6PR05MB3411.namprd05.prod.outlook.com (2603:10b6:405:43::23) by BN8PR05MB5986.namprd05.prod.outlook.com (2603:10b6:408:42::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.17; Wed, 22 Jul 2020 04:31:16 +0000 Received: from BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::e1ef:31eb:c802:aef0]) by BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::e1ef:31eb:c802:aef0%3]) with mapi id 15.20.3216.017; Wed, 22 Jul 2020 04:31:16 +0000 From: "Andrei Warkentin" To: Samer El-Haj-Mahmoud , "devel@edk2.groups.io" CC: Leif Lindholm , Pete Batard , Ard Biesheuvel Subject: Re: [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GOP parameter handling Thread-Topic: [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GOP parameter handling Thread-Index: AQHWX8v3ve+hIvlX8ECkTZtlpJpCAakTAc+N Date: Wed, 22 Jul 2020 04:31:16 +0000 Message-ID: References: <20200722020103.11808-1-Samer.El-Haj-Mahmoud@arm.com>,<20200722020103.11808-2-Samer.El-Haj-Mahmoud@arm.com> In-Reply-To: <20200722020103.11808-2-Samer.El-Haj-Mahmoud@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-originating-ip: [98.214.99.181] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: eeae5af8-9813-4304-3c1e-08d82df8130a x-ms-traffictypediagnostic: BN8PR05MB5986: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6qymb/3bOeeqCqCHufgCCdNWV056bhT88A2Jq4vVZtSkWspz9k2RToVoa1gIuo8z6rARnYhbtRz7d+DIXplN+4iS1x/Kos9TTOaCv+0tfiS5HdaPggfxmznWf/P2aYZzBdJgUDziEYuObLhlXv1jggr5sKZlkNFppXbPLz3LNRplH32vlhBzlMxByQL4+tzLrYO/jklEXfRTETc/85XD01BjKw7S/jOXNokAgCNXv6bkN5Cl1Ez8vsKXNdJjMqSxzp9LyCLI2KIpmgfJDOaqXdKDpHWLYjt9M6eSB4gKjbCMVZ+yPakR7HH3ONGBnZ2tV4GrJmr0ja0bX/117QCHsG34noV62DiaQb4LVYZQmqOfnr1BxmIxcPhVakCYik1MQL4HBn7rRm2t8Zt3Fc4yEw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR05MB3411.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(366004)(376002)(136003)(346002)(39860400002)(83380400001)(7696005)(45080400002)(71200400001)(55016002)(166002)(9686003)(4326008)(66946007)(8936002)(33656002)(66556008)(66446008)(19627405001)(76116006)(86362001)(5660300002)(316002)(2906002)(8676002)(66476007)(186003)(6506007)(966005)(53546011)(64756008)(110136005)(478600001)(54906003)(52536014)(26005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: 5LM0YJA3jM0QeViy36pdeY8VJaLLk75rn6/3hYLpdlhD9It+noWVVwcRWfp1HfDPF+v3G+W9DZIQSXJMfpY3Nx790/VorHV14USDTxLwmEpp9b14eBMBu4PblydB1OB3stKfeKYY9cRdjYWodjliVBBQPW/f8WEyQRl2DmOya9EmwUyw9iCXkY+CqZKjIiEXLSot3p2lb6i0XdvWaOfiLhuX7xLzmVR7nyhZc4TreVHRleY2ftOLh9yCezOvAUA8NhcbT9TjIvKL5oz6sBE27oXUHUkJIuMcabugaZMsNjLFriHQ/fGVAj5MuVl8Rk0cP2KsXu/kqTEts7QBjOp+bLiz21wC64bPBV+LynUFaPKN/Teo6VPSdETpuYfTC36MDjYHU7GwqJFHgFrp9pEQUTnFt8WF8Y0ajcpWdKMFRwZeJ7eSKU2j9F9Fs19KqKe3jj18iNFdUdGJTYZCbAGOPBHtKtkoHrJeRF2tt01u1ppcGR/uGRO4VPtZdKjzZdPX x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN6PR05MB3411.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeae5af8-9813-4304-3c1e-08d82df8130a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jul 2020 04:31:16.6013 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: STtoQKt2jE1QE5LZi2MgEThAWopGAyL0WmrbhtDqWbNd5KjAGw/HByEQriHzVHOZ9y2O5gua7laKnWHoyYixXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR05MB5986 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BN6PR05MB34110F0C8E84738493210834B9790BN6PR05MB3411namp_" --_000_BN6PR05MB34110F0C8E84738493210834B9790BN6PR05MB3411namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Andrei Warkentin Not using mLastMode is definitely an improvement, thanks. Esp. since mLastM= ode isn't a very good name for the variable (i.e. it's not the last mode se= t, it's the last possible/valid mode index, based on the virtual resolution= modes enabled via Pcd/HII) ________________________________ From: Samer El-Haj-Mahmoud Sent: Tuesday, July 21, 2020 9:01 PM To: devel@edk2.groups.io Cc: Leif Lindholm ; Pete Batard ; Andrei W= arkentin ; Ard Biesheuvel Subject: [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GOP param= eter handling Handle incorrect parameters passed to DisplayDxe GOP functions QueryMode(), SetMode(), and Blt(). This fixes Blt_Conf and QueryMode_Conf failures reported by SCT tests at: https://nam04.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgithub.= com%2Fpftf%2FRPi4%2Fissues%2F73&data=3D02%7C01%7Cawarkentin%40vmware.co= m%7C34c31d6924ca4f871d1b08d82de317b2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0= %7C1%7C637309800678733611&sdata=3D3BSdjglhhk%2FqRrP0mDOxV8YydE4vf0FdDkM= nzabV5qY%3D&reserved=3D0 Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platfor= m/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c index b880ca827bd6..80d0f7b2cb3c 100644 --- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c +++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2020, ARM Limited. All rights reserved. * Copyright (c) 2017-2018, Andrei Warkentin * Copyright (c) Microsoft Corporation. All rights reserved. * @@ -170,7 +171,7 @@ DisplayQueryMode ( EFI_STATUS Status; GOP_MODE_DATA *Mode; - if (ModeNumber > mLastMode) { + if (Info =3D=3D NULL || SizeOfInfo =3D=3D NULL || ModeNumber >=3D This->= Mode->MaxMode) { return EFI_INVALID_PARAMETER; } @@ -227,7 +228,7 @@ DisplaySetMode ( EFI_PHYSICAL_ADDRESS FbBase; GOP_MODE_DATA *Mode =3D &mGopModeData[ModeNumber]; - if (ModeNumber > mLastMode) { + if (ModeNumber >=3D This->Mode->MaxMode) { return EFI_UNSUPPORTED; } @@ -299,6 +300,14 @@ DisplayBlt ( UINT8 *VidBuf, *BltBuf, *VidBuf1; UINTN i; + if ((UINTN)BltOperation >=3D EfiGraphicsOutputBltOperationMax) { + return EFI_INVALID_PARAMETER; + } + + if (Width =3D=3D 0 || Height =3D=3D 0) { + return EFI_INVALID_PARAMETER; + } + switch (BltOperation) { case EfiBltVideoFill: BltBuf =3D (UINT8*)BltBuffer; @@ -349,7 +358,7 @@ DisplayBlt ( break; default: - ASSERT_EFI_ERROR (EFI_SUCCESS); + return EFI_INVALID_PARAMETER; break; } -- 2.17.1 --_000_BN6PR05MB34110F0C8E84738493210834B9790BN6PR05MB3411namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Andrei Warken= tin <awarkentin@vmware.com>

Not using mLastMode is def= initely an improvement, thanks. Esp. since mLastMode isn't a very good name= for the variable (i.e. it's not the last mode set, it's the last possible/valid mode index, based on the virtu= al resolution modes enabled via Pcd/HII)

From: Samer El-Haj-Mahmoud = <Samer.El-Haj-Mahmoud@arm.com>
Sent: Tuesday, July 21, 2020 9:01 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Leif Lindholm <leif@nuviainc.com>; Pete Batard <pete@ak= eo.ie>; Andrei Warkentin <awarkentin@vmware.com>; Ard Biesheuvel &= lt;ard.biesheuvel@arm.com>
Subject: [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GO= P parameter handling
 
Handle incorrect parameters passed to DisplayDxe G= OP functions
QueryMode(), SetMode(), and Blt().

This fixes Blt_Conf and QueryMode_Conf failures
reported by SCT tests at:
https://nam04.safelink= s.protection.outlook.com/?url=3Dhttps%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fis= sues%2F73&amp;data=3D02%7C01%7Cawarkentin%40vmware.com%7C34c31d6924ca4f= 871d1b08d82de317b2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C63730980067= 8733611&amp;sdata=3D3BSdjglhhk%2FqRrP0mDOxV8YydE4vf0FdDkMnzabV5qY%3D&am= p;amp;reserved=3D0

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com> ---
 Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 15 +++++++++++= +---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platfor= m/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
index b880ca827bd6..80d0f7b2cb3c 100644
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c
@@ -1,5 +1,6 @@
 /** @file
  *
+ *  Copyright (c) 2020, ARM Limited. All rights reserved.
  *  Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkent= in@gmail.com>
  *  Copyright (c) Microsoft Corporation. All rights reserved.   *
@@ -170,7 +171,7 @@ DisplayQueryMode (
   EFI_STATUS Status;
   GOP_MODE_DATA *Mode;
 
-  if (ModeNumber > mLastMode) {
+  if (Info =3D=3D NULL || SizeOfInfo =3D=3D NULL || ModeNumber >= =3D This->Mode->MaxMode) {
     return EFI_INVALID_PARAMETER;
   }
 
@@ -227,7 +228,7 @@ DisplaySetMode (
   EFI_PHYSICAL_ADDRESS FbBase;
   GOP_MODE_DATA *Mode =3D &mGopModeData[ModeNumber];
 
-  if (ModeNumber > mLastMode) {
+ if (ModeNumber >=3D This->Mode->MaxMode) {
     return EFI_UNSUPPORTED;
   }
 
@@ -299,6 +300,14 @@ DisplayBlt (
   UINT8 *VidBuf, *BltBuf, *VidBuf1;
   UINTN i;
 
+  if ((UINTN)BltOperation >=3D EfiGraphicsOutputBltOperationMax) {=
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (Width =3D=3D 0 || Height =3D=3D 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   switch (BltOperation) {
   case EfiBltVideoFill:
     BltBuf =3D (UINT8*)BltBuffer;
@@ -349,7 +358,7 @@ DisplayBlt (
     break;
 
   default:
-    ASSERT_EFI_ERROR (EFI_SUCCESS);
+    return EFI_INVALID_PARAMETER;
     break;
   }
 
--
2.17.1

--_000_BN6PR05MB34110F0C8E84738493210834B9790BN6PR05MB3411namp_--