From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C095AAC16DE for ; Mon, 11 Dec 2023 14:27:41 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=v7CUHKp/tClZROdYW4kmfZKFwl50+pazCy4J3ntNqRQ=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1702304860; v=1; b=uWdlpVJ/h7iJdeYneRmEuhqLRWekeGksJU+HRxvAcih8VNH9Ak0h7PDPkf2Fx82dJHIDKT11 BM8tZFJTKq2ksCUyX0vQi0PF1kdzqKJ6n0UEpwy+s/5yE6nVOSO8OjUhwwYePopzgfxGnA3vWMw WPvggbhL7jlTw7Bu1uz0v/nM= X-Received: by 127.0.0.2 with SMTP id htOQYY7687511xx7f6sVwzDi; Mon, 11 Dec 2023 06:27:40 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.9499.1702304859622739456 for ; Mon, 11 Dec 2023 06:27:39 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-0av3jJD-NMWfbibiBBb5Eg-1; Mon, 11 Dec 2023 09:27:35 -0500 X-MC-Unique: 0av3jJD-NMWfbibiBBb5Eg-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E157884AC63; Mon, 11 Dec 2023 14:27:34 +0000 (UTC) X-Received: from [10.39.194.43] (unknown [10.39.194.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30144492BE6; Mon, 11 Dec 2023 14:27:33 +0000 (UTC) Message-ID: Date: Mon, 11 Dec 2023 15:27:26 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2] ArmVirt: Allow memory attributes protocol to be disabled on first boot To: Ard Biesheuvel Cc: devel@edk2.groups.io, Gerd Hoffmann , Oliver Steffen , Alexander Graf , Oliver Smith-Denny , Taylor Beebe , Peter Jones , Leif Lindholm References: <20231207100603.2654084-1-ardb@google.com> From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JWvNzBCXdPMH18PGIwj6XdDcx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="uWdlpVJ/"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 12/8/23 16:34, Ard Biesheuvel wrote: > On Fri, 8 Dec 2023 at 15:34, Laszlo Ersek wrote: >>> diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec >>> index 0f2d7873279f..c55978f75c19 100644 >>> --- a/ArmVirtPkg/ArmVirtPkg.dec >>> +++ b/ArmVirtPkg/ArmVirtPkg.dec >>> @@ -68,3 +68,9 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] >>> # Cloud Hypervisor has no other way to pass Rsdp address to the gues= t except use a PCD. >>> >>> # >>> >>> gArmVirtTokenSpaceGuid.PcdCloudHvAcpiRsdpBaseAddress|0x0|UINT64|0x00= 000005 >>> >>> + >>> >>> + ## >>> >>> + # Whether the EFI memory attribus protocol should be uninstalled bef= ore >>> >>> + # invoking the OS loader on the first boot. This may be needed to wo= rk around >>> >>> + # problematic builds of shim that use the protocol incorrectly. >>> >>> + gArmVirtTokenSpaceGuid.PcdUninstallMemAttrProtocolOnFirstBoot|FALSE|= BOOLEAN|0x00000006 >>> >> >> (1) could be a feature PCD (although it couldn't be patchable-in-module >> then, and perhaps we don't consider this a "feature") >> >=20 > Is this a general remark on the similarity between feature PCDs and > boolean PCDs? Yes, just a general remark; I generally don't have a surefire handle on when to use a feature PCD versus a fixed-at-build (and/or patchable-in-module) BOOLEAN PCD. >> (4) Why the change from an explicit call from AfterConsole to a >> constructor? Was AfterConsole too late somehow? >> >=20 > Yes. Checking for the existence of "BootOrder" needs to occur earlier, > or it will have been created by the BDS. >=20 >> I think constructors should be the last resort. >> >=20 > Not disagreeing with that. >=20 >> (5) Is the depex really necessary? BDS is supposed to start when all >> drivers have been dispatched, and so by that time, all of the UEFI >> architectural protocols should be available. (BDS will launch UEFI >> drivers, and all the UEFI drivers have an implicit depex on all the >> architectural protocols.) >> >=20 > The BDS arch protocol will be invoked at that point. but the BdsDxe > itself could be dispatched much earlier, at which point the > constructor of this library will be invoked. >=20 > And I'll need to include the CPU arch protocol as well here, as this > is installed at the same time as the EFI memory attributes protocol by > the CPU dxe driver. Ah, so the idea is to inject code between the memory attributes protocol's installation and BdsDxe launching. >> (7) Tying back to my point (4) -- I understand this is a hack anyway, >> but I'm still uncomfortable with platform BDS uninstalling a protocol >> that is owned by / provided by the CPU driver. Feels like a significant >> layering violation. >> >=20 > It is. >=20 >> Can we modify the CPU driver instead, to listen to a new event group, >> upon which being signaled, the CPU driver would uninstall the protocol >> (and close the listening event)? >> >> This PlatformBootManagerLib instance would act more or less the same >> (I'd suggest signaling the event group from within AfterConsole, in case >> the PCD default and/or the fw_cfg knob dictated that), but the protocol >> uninstallation would occur in "ArmPkg/Drivers/CpuDxe". >> >> In more technical terms, the layering violation IMO is that we mess with >> CpuDxe's "mCpuHandle" and "mMemoryAttribute" static variables from >> within BDS. Adding the new event group requires more boiler-plate code >> for sure, but there's a small code-size benefit as well: we'd not have >> to look up either the handle (with LocateHandle) or the protocol >> interface (with HandleProtocol), as CpuDxe inherently knows those >> (mCpuHandle, mMemoryAttribute). >> >=20 > I agree with your analysis here. But I am reluctant to introduce > elaborate infrastructure across drivers to implement a feature that > should not exist in the first place. >=20 > As I mentioned a couple of times, I am rather unhappy with the > complete lack of involvement of the people who created this mess in > the first place, and what I am after is really a minimal, local hack > that unblocks the actual end users (people running LIMA on ARM based > Macs) without creating building blocks that will be used by the distro > forks to erode the original functionality even further, Understood. I agree to keep this contained, location-wise. (I notice Gerd reports downthread though that limiting the protocol's masking time-wise as well (i.e. to first boot) is not helpful, because even rhel-9.3 grubaa64 has problems when the protocol is exposed. So a simpler but broader approach could be better.) Thanks! Laszlo -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112300): https://edk2.groups.io/g/devel/message/112300 Mute This Topic: https://groups.io/mt/103031504/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-