From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Thu, 26 Sep 2019 05:43:18 -0700 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 287B04FCC7; Thu, 26 Sep 2019 12:43:18 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-49.rdu2.redhat.com [10.10.120.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 531E0165F0; Thu, 26 Sep 2019 12:43:14 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 25/35] OvmfPkg/VideoDxe: document EFI_EDID_OVERRIDE_PROTOCOL.GetEdid() call To: devel@edk2.groups.io, philmd@redhat.com Cc: Ard Biesheuvel , David Woodhouse , Jordan Justen References: <20190917194935.24322-1-lersek@redhat.com> <20190917194935.24322-26-lersek@redhat.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 26 Sep 2019 14:43:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Sep 2019 12:43:18 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 09/23/19 17:59, Philippe Mathieu-Daud=C3=A9 wrote: > Hi Laszlo, >=20 > On 9/17/19 9:49 PM, Laszlo Ersek wrote: >> According to the UEFI spec -- and to the edk2 header >> "MdePkg/Include/Protocol/EdidOverride.h" too --, >> EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID takes an (EFI_HANDLE*), and not an >> EFI_HANDLE, as second parameter ("ChildHandle"). >> >> This is probably [*] a bug in the UEFI spec. Given that this CSM module >> (VideoDxe) had been used for a long time on physical platforms before i= t >> was moved to OvmfPkg, keep the current "ChildHandle" argument, just cas= t >> it explicitly. >> >> [*] The edk2 tree contains no other GetEdid() call, and also no GetEdid= () >> implementation. >> >> The edk2-platforms tree contains two GetEdid() calls, at commit >> 022c212167e0, in files >> - "Drivers/DisplayLink/DisplayLinkPkg/DisplayLinkGop/Edid.c", >> - "Drivers/OptionRomPkg/CirrusLogic5430Dxe/Edid.c". >> >> From these, the first passes an (EFI_HANDLE*) as "ChildHandle", the >> second passes an EFI_HANDLE. It's difficult to draw a conclusion. := / >> >> No functional changes. >> >> (I've also requested a non-normative (informative) clarification for th= e >> UEFI spec: , in the >> direction that matches this patch.) >=20 > (EFI_HANDLE*) makes sense to me, but I'd rather wait for the spec > clarification before Acking this patch, I don't want we silent a bug > with this cast. Right, there's been some movement in Mantis#2018. It looks like the spec is wrong, but all [*] consumers and producers of GetEdid(), investigated thus far, have simply ignored the mistake in the spec, and done the right thing in practice. So there seems to be a chance for the spec to be fixed. That would be followed by fixing the GetEdid() prototype in edk2. And then this patch would be dropped. [*] the only exception found thus far is the call site in edk2-platform's "DisplayLinkPkg", mentioned above in the commit message. However, that is a very recent code addition (commit 9df63499ea01, 2019-09-09), and it might not reflect "historical" usage, but an attempt to write brand new code, conforming to the *letter* of the spec. So in case the spec gets fixed, the DisplayLinkPkg code could be fixed in tandem, perhaps. Thanks Laszlo >=20 >> Cc: Ard Biesheuvel >> Cc: David Woodhouse >> Cc: Jordan Justen >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> build-tested only >> >> OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c b/OvmfPkg/Csm/B= iosThunk/VideoDxe/BiosVideo.c >> index 0640656dba14..995136adee27 100644 >> --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c >> +++ b/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c >> @@ -1402,9 +1402,13 @@ BiosVideoCheckForVbe ( >> goto Done; >> } >> >> + // >> + // Cast "ChildHandle" to (EFI_HANDLE*) in order to work around the= spec bug >> + // in UEFI v2.8, reported as Mantis#2018. >> + // >> Status =3D EdidOverride->GetEdid ( >> EdidOverride, >> - BiosVideoPrivate->Handle, >> + (EFI_HANDLE *) BiosVideoPrivate->Handle, >> &EdidAttributes, >> &EdidOverrideDataSize, >> (UINT8 **) &EdidOverrideDataBlock >> >=20 >=20 >=20