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 1022AAC1416 for ; Tue, 15 Aug 2023 16:31:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=W0FOWPo4LzsnYbwrfxAo+Kp6MNpAq3+YDGmPLJA1RS0=; c=relaxed/simple; d=groups.io; h=MIME-version:Subject:From:In-reply-to:Date:Cc:Message-id:References:To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-type:Content-transfer-encoding; s=20140610; t=1692117061; v=1; b=CsmkulNu8l37wfuvOX4zszx5svq1tXwaMOhqO5IuPAo6zwkorZP5BuxC7ZoNaQPEmJd9xmW5 NZytMEo3GpXJPDvl9GuJxRehqVsvh63mrdBaWNoId9ehOsffuXDSQRTrd9r/UJaw+Cc9W0IxhFs 5uRXSNEmJryL9oC2AG5ZQDpI= X-Received: by 127.0.0.2 with SMTP id s2QcYY7687511xetDDD8gGlX; Tue, 15 Aug 2023 09:31:01 -0700 X-Received: from ma-mailsvcp-mx-lapp03.apple.com (ma-mailsvcp-mx-lapp03.apple.com [17.32.222.24]) by mx.groups.io with SMTP id smtpd.web10.138888.1692117060924563617 for ; Tue, 15 Aug 2023 09:31:01 -0700 X-Received: from rn-mailsvcp-mta-lapp02.rno.apple.com (rn-mailsvcp-mta-lapp02.rno.apple.com [10.225.203.150]) by ma-mailsvcp-mx-lapp03.apple.com (Oracle Communications Messaging Server 8.1.0.23.20230328 64bit (built Mar 28 2023)) with ESMTPS id <0RZF000MGXVFLB20@ma-mailsvcp-mx-lapp03.apple.com> for devel@edk2.groups.io; Tue, 15 Aug 2023 09:31:00 -0700 (PDT) X-Proofpoint-ORIG-GUID: 31LePjnwlTciu9Dqhwm6EIfAlNzuSEVH X-Proofpoint-GUID: 31LePjnwlTciu9Dqhwm6EIfAlNzuSEVH X-Received: from rn-mailsvcp-policy-lapp01.rno.apple.com (rn-mailsvcp-policy-lapp01.rno.apple.com [17.179.253.18]) by rn-mailsvcp-mta-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.23.20230328 64bit (built Mar 28 2023)) with ESMTPS id <0RZF00ICUXVGAI00@rn-mailsvcp-mta-lapp02.rno.apple.com>; Tue, 15 Aug 2023 09:30:52 -0700 (PDT) X-Received: from process_milters-daemon.rn-mailsvcp-policy-lapp01.rno.apple.com by rn-mailsvcp-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.22.20230228 64bit (built Feb 28 2023)) id <0RZF01100XSW2B00@rn-mailsvcp-policy-lapp01.rno.apple.com>; Tue, 15 Aug 2023 09:30:52 -0700 (PDT) X-Va-A: X-Va-T-CD: fb9ca77e010fb2e9e052c364a80d126f X-Va-E-CD: a79fd2dfc6232e7fdb69a3f9586137f7 X-Va-R-CD: e4c78c371ebf7c6b093b9a3c3edfe85c X-Va-ID: c97b468c-03ee-4bcc-95a6-e93fcc80f459 X-Va-CD: 0 X-V-A: X-V-T-CD: fb9ca77e010fb2e9e052c364a80d126f X-V-E-CD: a79fd2dfc6232e7fdb69a3f9586137f7 X-V-R-CD: e4c78c371ebf7c6b093b9a3c3edfe85c X-V-ID: e4a5e51d-858d-44f0-b95c-36a2f313ac5c X-V-CD: 0 X-Received: from smtpclient.apple (unknown [17.115.2.193]) by rn-mailsvcp-policy-lapp01.rno.apple.com (Oracle Communications Messaging Server 8.1.0.22.20230228 64bit (built Feb 28 2023)) with ESMTPSA id <0RZF00412XVGEZ00@rn-mailsvcp-policy-lapp01.rno.apple.com>; Tue, 15 Aug 2023 09:30:52 -0700 (PDT) MIME-version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [edk2-devel] About EDK2 supports Self Modifying Code From: "Andrew Fish via groups.io" In-reply-to: Date: Tue, 15 Aug 2023 09:30:41 -0700 Cc: lichao@loongson.cn, Ard Biesheuvel , Liming Gao , Bob Feng , Yuwei Chen Message-id: <360DC97D-9F0F-4B86-B441-1C9789912AC6@apple.com> References: <22642530-3177-d5d9-426a-d5a68ebfe8c6@loongson.cn> <4EB062B0-6C13-480F-A2CC-95C715A08ECD@apple.com> <0026aa43-c2d6-92bf-77a0-391a608e8b22@loongson.cn> <30CC4A49-0827-4960-A8F5-F44F534051F9@apple.com> To: edk2-devel-groups-io , Pedro Falcato 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,afish@apple.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: DrE2kLoO7QOhF71JDhXuR5oyx7686176AA= 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=CsmkulNu; dmarc=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 Aug 15, 2023, at 8:39 AM, Pedro Falcato wrot= e: >=20 > On Tue, Aug 15, 2023 at 4:05=E2=80=AFPM Andrew Fish via groups.io > wrote: >>=20 >> Chao, >>=20 >> From a quick google it looks like CSR* is used to access banks of regist= ers that relate to things like performance counters and debug infrastructur= e and the number of banks of these register sets is likely implementation d= efined. Seems like we could introduce some Fixed At Build PCD values that d= efine the maximum number of elements in a given bank. >>=20 >> If we are forced to use assembler it might be possible to write some mac= ros that used the fixed at build values to only generate functions for bank= s that are needed for a given build. Then I think it becomes an exercise in= dead code stripping the assembler. Most compilers generate assembler that = contains functions that can be stripped as long as those functions follow c= ertain rules. >>=20 >> As a side note it would be good for us to have an FAQ/Wiki entry for the= dead code stripping rules for the various flavors of assembler. I know the= Apple assembler has a unique take on this. >=20 > FWIW, I'm almost positive there's no DCE in GNU as (or llvm-as as > well). Unless you use something ffunction-sections > -fdata-sections-like, but then you're relying on the linker + > gc-sections to take care of it, just like GCC/clang would. >=20 I guess I usually think of DCE as a linker job, since the linker knows the = functions that are NOT called. At least from the Apple tools the DCE has th= e same rules if you are using Link Time Optimization or not. It is basicall= y a flag in the object that tells the inker it is OK to follow the DCE rule= s around labels and remove stuff.=20 Worst case it seems like we could have macros that generate assembly files = based on build time constants so we have one function per file. This might = take a tweak to the build system, but I=E2=80=99d rather do that than have = library functions that magically turn on Self Modifying Code.=20 Regardless of the answer I think documenting the rules is a useful exercise= s since needing to save size in firmware images is not an uncommon task.=20 Thanks, Andrew Fish > --=20 > Pedro >=20 >=20 >=20 >=20 >=20 -=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 (#107770): https://edk2.groups.io/g/devel/message/107770 Mute This Topic: https://groups.io/mt/100751724/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-