From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web09.2602.1659387045488076620 for ; Mon, 01 Aug 2022 13:50:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=USJ7J/Rk; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3E844B816A0 for ; Mon, 1 Aug 2022 20:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E452BC433D7 for ; Mon, 1 Aug 2022 20:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659387041; bh=hfIECOM268rHCtgCckC9LehBTQlIXi1yJYz5L36jFlE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=USJ7J/Rk5KIhPYQYwSw2SQ+4f7aDtXuDz6rlrIOFUw9J/tDM5nrP5v13JG++QS9Bc wfbIBCUbKFTY9vrzNVEHUH1oHx0KXMMmX9n5cnN+/NrlNBNAJWbDs3sw886Pz+amvD iky5Xvz/FxN2vfr3ZVdgqhWED2amv25PlucKPWuj9hwnZsPhZFfNZqvvuCT+xx/uP2 Pwjoc7D7yfSIQlOFCo64y4mP9UgWPceKetjLuxcF1fxv804uvLBzvaZg95EexAHLmg GCoOYtlcGrpUK9TRoVXYkc0V/NSsslIRW1BnZ47TahAff+WH4IgyTcy9LGnhoETCzS yf1QpAU0sDWow== Received: by mail-oi1-f180.google.com with SMTP id i4so14425839oif.2 for ; Mon, 01 Aug 2022 13:50:41 -0700 (PDT) X-Gm-Message-State: AJIora8yZdLUMsCsDjcAPUqU/FviD+68hTx1Nauvv4lD6JQyFfrcnBA+ FcULjzG1aMazJcOAyngasUv5nyZYHmuQogOwuLw= X-Google-Smtp-Source: AGRyM1ub7PxHqdhTBmxO2fOX70ALdb8XPznRYWul5obu5yyOkqEsjX+q5Y3XqCZ6Ghzek34HKMRI6fEFGLsE/y9ec6g= X-Received: by 2002:a05:6808:1489:b0:33a:861c:838e with SMTP id e9-20020a056808148900b0033a861c838emr6941174oiw.228.1659387041030; Mon, 01 Aug 2022 13:50:41 -0700 (PDT) MIME-Version: 1.0 References: <20220728213042.2145-1-Dimitrije.Pavlov@arm.com> In-Reply-To: <20220728213042.2145-1-Dimitrije.Pavlov@arm.com> From: "Ard Biesheuvel" Date: Mon, 1 Aug 2022 22:50:30 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode To: Dimitrije Pavlov Cc: edk2-devel-groups-io , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Jeff Booher-Kaeding , Samer El-Haj-Mahmoud , Sunny Wang , Jeremy Linton Content-Type: text/plain; charset="UTF-8" On Thu, 28 Jul 2022 at 23:31, Dimitrije Pavlov wrote: > > Ensure that the PixelInformation field of the > EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is zeroed out in > EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode() and > EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() when PixelFormat is > PixelBlueGreenRedReserved8BitPerColor. > > According to UEFI 2.9 Section 12.9, PixelInformation field of the > EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is valid only if > PixelFormat is PixelBitMask. This means that firmware is not required > to fill out the PixelInformation field for other PixelFormat types, > which implies that the QemuVideoDxe implementation is technically > correct. > > However, not zeroing out those fields will leak the contents of the > memory returned by the memory allocator, so it is better to explicitly > set them to zero. > > In addition, the SCT test suite relies on PixelInformation always > having a consistent value, which causes failures. > > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Cc: Jeff Booher-Kaeding > Cc: Samer El-Haj-Mahmoud > Cc: Sunny Wang > Cc: Jeremy Linton > > Signed-off-by: Dimitrije Pavlov > > Acked-by: Gerd Hoffmann Merged as #3164 Thanks, > --- > OvmfPkg/QemuVideoDxe/Gop.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c > index 0c4dea7fb6f2..7a9fe208c99c 100644 > --- a/OvmfPkg/QemuVideoDxe/Gop.c > +++ b/OvmfPkg/QemuVideoDxe/Gop.c > @@ -31,7 +31,14 @@ QemuVideoCompleteModeInfo ( > Info->PixelInformation.ReservedMask = 0; > } else if (ModeData->ColorDepth == 32) { > DEBUG ((DEBUG_INFO, "PixelBlueGreenRedReserved8BitPerColor\n")); > - Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; > + Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; > + Info->PixelInformation.RedMask = 0; > + Info->PixelInformation.GreenMask = 0; > + Info->PixelInformation.BlueMask = 0; > + Info->PixelInformation.ReservedMask = 0; > + } else { > + DEBUG ((DEBUG_ERROR, "%a: Invalid ColorDepth %u", __FUNCTION__, ModeData->ColorDepth)); > + ASSERT (FALSE); > } > > Info->PixelsPerScanLine = Info->HorizontalResolution; > -- > 2.34.1 >