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.web11.21337.1658936576667897861 for ; Wed, 27 Jul 2022 08:42:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tsQOmqW6; 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 140A3B821AB for ; Wed, 27 Jul 2022 15:42:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCC9AC433B5 for ; Wed, 27 Jul 2022 15:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658936572; bh=0iGaz3C+ayE+JvKLbi0A9w/OqiZA5e4y8ZJJzX7aTeA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=tsQOmqW6/QqgyyWpNY4IKVg3h5JNPtBir4BeX8/P+CcbHwpKrWmuSKWpLF+61h5Bh 1dTZ0CS1KNLL+BWrbhj78lZNd+y7Awa3UtRrvs6/QffsAuVcvXQc96FnH+mRzHCOxT fqM59ARGMuBVPiVSUfuilIWDdV7nOWb3iY2qewRqGEsEhpevq1vKapxh6FwaOLPj4l 9dxXzwUYmskusgZt80qGDMzgv5cL5cPFSW1RBW4AgNq6nih/jB7lLIxkNJtL4a4dJr 4vl1dgKpU9j3ewsQvEdt2+VTv9BB/8hgMsZH3haSOFzLjJPPupgr5ru6QyI2xLcLK1 UimydSwUVsKeg== Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-10e49d9a59bso3992549fac.5 for ; Wed, 27 Jul 2022 08:42:52 -0700 (PDT) X-Gm-Message-State: AJIora/kpVJkvdjh8DTKP+5+IYgZA+xlcDxXN9MfYQaEQdxisablqIUd XUhaLa2hcyHS6rUc311ODlgF/mx/mOICFVTr0vs= X-Google-Smtp-Source: AGRyM1vA6YWsNQbgOCmZQWjIlPkjpr7AgQlCtt72vlvfVFMMOMBz+BISNWSht59pf5iC10QeYPVJsPTWeAj40LpjVZs= X-Received: by 2002:a05:6870:5b91:b0:108:374a:96b0 with SMTP id em17-20020a0568705b9100b00108374a96b0mr2443588oab.126.1658936571957; Wed, 27 Jul 2022 08:42:51 -0700 (PDT) MIME-Version: 1.0 References: <20220628184816.24493-1-Dimitrije.Pavlov@arm.com> In-Reply-To: <20220628184816.24493-1-Dimitrije.Pavlov@arm.com> From: "Ard Biesheuvel" Date: Wed, 27 Jul 2022 08:42:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v1 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode To: edk2-devel-groups-io , Dimitrije Pavlov Cc: 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 Tue, 28 Jun 2022 at 11:48, 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 > --- > 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; Is this valid C? Or is the patch corrupted by email? > + } else { > + DEBUG ((DEBUG_ERROR, "%a: Invalid ColorDepth %u", __FUNCTION__, ModeData->ColorDepth)); > + ASSERT (FALSE); > } > > Info->PixelsPerScanLine Info->HorizontalResolution; > -- > 2.34.1 > > > > ------------ > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#90822): https://edk2.groups.io/g/devel/message/90822 > Mute This Topic: https://groups.io/mt/92050521/1131722 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb@kernel.org] > ------------ > >