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; Tue, 17 Sep 2019 12:50:07 -0700 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A0BA368DA; Tue, 17 Sep 2019 19:50:07 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-37.rdu2.redhat.com [10.10.120.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0885B600C4; Tue, 17 Sep 2019 19:50:05 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Dandan Bi , Hao A Wu , Jian J Wang , Liming Gao Subject: [PATCH 11/35] MdeModulePkg: document workaround for EFI_RUNTIME_EVENT_ENTRY PI spec bug Date: Tue, 17 Sep 2019 21:49:11 +0200 Message-Id: <20190917194935.24322-12-lersek@redhat.com> In-Reply-To: <20190917194935.24322-1-lersek@redhat.com> References: <20190917194935.24322-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 17 Sep 2019 19:50:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable The PI spec (v1.7) correctly specifies "EFI_RUNTIME_EVENT_ENTRY.Event" in natural language, but the field type in the structure definition itself i= s wrong -- it should be EFI_EVENT, not (EFI_EVENT*). This spec bug is likely unfixable for compatibility reasons, and so edk2 works it around already. We should clearly document the workaround. Functionally, this patch is a no-op. (I've also requested a non-normative (informative) clarification for the PI spec: .) Cc: Dandan Bi Cc: Hao A Wu Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Laszlo Ersek --- Notes: lightly tested, as these modules are part of the ArmVirt and/or OVMF platforms MdeModulePkg/Core/Dxe/Event/Event.c | 8 ++++++++ MdeModulePkg/Core/RuntimeDxe/Runtime.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Event/Event.c b/MdeModulePkg/Core/Dxe/= Event/Event.c index 21db38aaf037..c83c572c8f84 100644 --- a/MdeModulePkg/Core/Dxe/Event/Event.c +++ b/MdeModulePkg/Core/Dxe/Event/Event.c @@ -485,6 +485,14 @@ CoreCreateEventInternal ( IEvent->RuntimeData.NotifyTpl =3D NotifyTpl; IEvent->RuntimeData.NotifyFunction =3D NotifyFunction; IEvent->RuntimeData.NotifyContext =3D (VOID *) NotifyContext; + // + // Work around the bug in the Platform Init specification (v1.7), re= ported + // as Mantis#2017: "EFI_RUNTIME_EVENT_ENTRY.Event" should have type + // EFI_EVENT, not (EFI_EVENT*). The PI spec documents the field corr= ectly + // as "The EFI_EVENT returned by CreateEvent()", but the type of the= field + // doesn't match the natural language description. Therefore we need= an + // explicit cast here. + // IEvent->RuntimeData.Event =3D (EFI_EVENT *) IEvent; InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link); } diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.c b/MdeModulePkg/Core/R= untimeDxe/Runtime.c index c52b2b7ecf68..f7220a205d1e 100644 --- a/MdeModulePkg/Core/RuntimeDxe/Runtime.c +++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.c @@ -285,8 +285,16 @@ RuntimeDriverSetVirtualAddressMap ( for (Link =3D mRuntime.EventHead.ForwardLink; Link !=3D &mRuntime.Even= tHead; Link =3D Link->ForwardLink) { RuntimeEvent =3D BASE_CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link); if ((RuntimeEvent->Type & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) =3D=3D = EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) { + // + // Work around the bug in the Platform Init specification (v1.7), + // reported as Mantis#2017: "EFI_RUNTIME_EVENT_ENTRY.Event" should= have + // type EFI_EVENT, not (EFI_EVENT*). The PI spec documents the fie= ld + // correctly as "The EFI_EVENT returned by CreateEvent()", but the= type + // of the field doesn't match the natural language description. Th= erefore + // we need an explicit cast here. + // RuntimeEvent->NotifyFunction ( - RuntimeEvent->Event, + (EFI_EVENT) RuntimeEvent->Event, RuntimeEvent->NotifyContext ); } --=20 2.19.1.3.g30247aa5d201