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 7EDE0D81163 for ; Thu, 18 Jan 2024 14:49:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=mUhCX8JPG0dntJzGPQiZimeZ9PwgbeexyNSJJBnnc6g=; 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=1705589367; v=1; b=oT8qcZDxHdugqvDi1ugfEf+AkkYYiqgFJTnCp5XWrX6o9+qESf7stKtAOb+9+K0zTliszr7x ZJpgjiAjuZ0Bao/Kld33JyVSn1u2VuUpp3sCvPzAf3aBDT4EQ0GDHWL4aSAwQYOXGjl4TZhtR2T E7YKJlCmxFCCBOwez3sV2Ffg= X-Received: by 127.0.0.2 with SMTP id HqqSYY7687511xD2lWQGNQJe; Thu, 18 Jan 2024 06:49:27 -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.13264.1705589366547269976 for ; Thu, 18 Jan 2024 06:49:26 -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-104-r6Lm6HV1Ne6GBO7OkX_5Og-1; Thu, 18 Jan 2024 09:49:23 -0500 X-MC-Unique: r6Lm6HV1Ne6GBO7OkX_5Og-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 C3FCC887E44; Thu, 18 Jan 2024 14:49:22 +0000 (UTC) X-Received: from [10.39.194.70] (unknown [10.39.194.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00E6440C95AD; Thu, 18 Jan 2024 14:49:21 +0000 (UTC) Message-ID: <40d61bec-49c1-e560-7d6b-05c789b2b5f6@redhat.com> Date: Thu, 18 Jan 2024 15:49:20 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] Memory Attribute for depex section To: Nhi Pham , Ard Biesheuvel Cc: "Andrew (EFI) Fish" , edk2-devel-groups-io , "ardb+tianocore@kernel.org" References: <44ca139f-4d78-4322-b5b6-8e9788bb7486@os.amperecomputing.com> <2ad16043-754e-3bb9-3a4a-702d9a50bf63@redhat.com> <45b95719-f1fc-dbc6-a4cc-a022d691844c@redhat.com> <8d745268-263c-c99a-67c6-fe0fb6cd4b8e@redhat.com> <0e0b2e56-30dd-4f5f-9708-98690246efda@os.amperecomputing.com> <20d8728f-daaa-51ed-18ad-3087695d21f1@redhat.com> <8efe1653-7383-44a6-b820-efb1c6132f74@os.amperecomputing.com> From: "Laszlo Ersek" In-Reply-To: <8efe1653-7383-44a6-b820-efb1c6132f74@os.amperecomputing.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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: KMFTjJ3yRcS6PvhfhvLVj4ftx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=oT8qcZDx; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 1/18/24 07:00, Nhi Pham wrote: > Hi Laszlo, > > On 1/16/2024 2:00 AM, Laszlo Ersek wrote: >> On 1/15/24 15:04, Ard Biesheuvel wrote: >>> On Mon, 15 Jan 2024 at 14:07, Nhi Pham >>> wrote: >>>> >>>> On 1/12/2024 4:45 PM, Laszlo Ersek wrote: >>>>> (Independently: I think that's a valid thing to do for *SMM* drivers, >>>>> because the entry point functions of those drivers are permitted to >>>>> use >>>>> both SMM and DXE/UEFI protocols. But whether the same is valid for the >>>>> *standalone* MM drivers -- that looks questionable. Standalone MM >>>>> drivers should not depend on UEFI/DXE protocols ever, IIUC.) >>>>> >>>>>> 3) The issue is patching the grammar in place, why can’t we just >>>>>> make a >>>>>> copy for the dispatcher grammer, and operate on the copy. Maybe via a >>>>>> copy on 1st update strategy? >>>>> >>>>> Yes, copying the depex to the heap, and patching it there, was >>>>> Nhi's #1 >>>>> fix proposal. I think that could be made work. But I'm not sure if the >>>>> perf savings are worth the additional complexity. The heap allocation >>>>> (where the writeable depex would exist) would have to be permanently >>>>> associated with the loaded PE image -- because the dispatcher might >>>>> need >>>>> to reevaluate the depex across multiple rounds of dispatching. So >>>>> that's >>>>> a new field in some image-related structure, it also needs to be freed >>>>> upon unload (?), what if the memory allocation fails during depex eval >>>>> (just consider the depex to eval to FALSE?), etc. Doable, but >>>>> hairy; not >>>>> sure if the perf is worth that effort. >>>>> >>>> >>>> Thanks so much, Laszlo for your valuable insights. >>>> >>>> The approach #1 works for me. I will do further check for your concerns >>>> above. >>>> >>>> I'm trying your suggested patch and investigating the performance being >>>> discussed here. >>>> >>> >>> Not sure what approach #1 means, >> >> (copying the depex to the heap, and maintaining it there, so that it can >> be patched) > > Thanks! > >> >>> but I'd prefer to just remove this >>> optimization from standalone MM, given that not only a) it shouldn't >>> have to deal with a large number of protocol GUIDs, but also b) the >>> driver dispatch is much more straight-forward. (Typically, StMM >>> drivers can be dispatched in the order they appear in the firmware >>> volume, in which case each DEPEX is evaluated only once anyway) >> >> Sounds like a promising basis for removing the optimization indeed! >> > > Your patch suggested earlier works for me. And I don't see significant > performance reduction compared with keeping optimization. > > I don't have strong reason on removing the optimization, but I think it > would be simply good for now. Could you post your patch to edk2-devel > for review and merge? That wouldn't be correct; I don't have any platform for testing StMM. I proposed the patch purely based on code analysis. I prefer not to post untested patches, if I can avoid it. You can however post my patch; simply add your S-o-b at the bottom. You can also preserve my authorship on the patch with --author=... on git-commit; but even that is unnecessary for such a simple patch (you don't even have to pick the patch up from the email, it's trivial to reimplement from scratch, just reading the email). Thanks Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113994): https://edk2.groups.io/g/devel/message/113994 Mute This Topic: https://groups.io/mt/103594587/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-