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 841E2740037 for ; Tue, 15 Aug 2023 18:48:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=N09xxIKLkkdQNQB95xyfspKpQ9ghEEcj46rgggXakoY=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: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=1692125312; v=1; b=nXJiP+Eak1S33qvuC4ogggiL6HEmfoWr5gthlfxUfEU1wG9KlxfU3LcsDOvyqdyi/7r8adDd e6T8IwLjA9/GhOw1nBbuYXQW/IycJbWfkjFkVii7OXQLy40ZmfSr37GdzRIGdMclOHUKzE9ws9r /Du7ULpUx1b5FSzG3pGtFglE= X-Received: by 127.0.0.2 with SMTP id 4n4cYY7687511xemwmr9uZTh; Tue, 15 Aug 2023 11:48:32 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.142442.1692125311378302040 for ; Tue, 15 Aug 2023 11:48:31 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D24AA62A66 for ; Tue, 15 Aug 2023 18:48:30 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F47AC433C8 for ; Tue, 15 Aug 2023 18:48:30 +0000 (UTC) X-Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4fe389d6f19so9008141e87.3 for ; Tue, 15 Aug 2023 11:48:30 -0700 (PDT) X-Gm-Message-State: X0O6O8ASslx8zF2TXVYvfJDOx7686176AA= X-Google-Smtp-Source: AGHT+IFa8SNe+St3aT00lpup9uJoK7w2lJpMPxDQ4aX6haaMzS1NKN12bEu0zeqfnn8CekHTAbqrec3CAmqH3k47Dx0= X-Received: by 2002:a19:710b:0:b0:4fd:d470:203b with SMTP id m11-20020a19710b000000b004fdd470203bmr8267080lfc.69.1692125308294; Tue, 15 Aug 2023 11:48:28 -0700 (PDT) MIME-Version: 1.0 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> <360DC97D-9F0F-4B86-B441-1C9789912AC6@apple.com> In-Reply-To: <360DC97D-9F0F-4B86-B441-1C9789912AC6@apple.com> From: "Ard Biesheuvel" Date: Tue, 15 Aug 2023 20:48:16 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] About EDK2 supports Self Modifying Code To: devel@edk2.groups.io, afish@apple.com Cc: Pedro Falcato , lichao@loongson.cn, Liming Gao , Bob Feng , Yuwei Chen 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,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: 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=nXJiP+Ea; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (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 Tue, 15 Aug 2023 at 18:31, Andrew Fish via groups.io wrote: > > > > > On Aug 15, 2023, at 8:39 AM, Pedro Falcato wr= ote: > > > > On Tue, Aug 15, 2023 at 4:05=E2=80=AFPM Andrew Fish via groups.io > > wrote: > >> > >> Chao, > >> > >> From a quick google it looks like CSR* is used to access banks of regi= sters that relate to things like performance counters and debug infrastruct= ure and the number of banks of these register sets is likely implementation= defined. Seems like we could introduce some Fixed At Build PCD values that= define the maximum number of elements in a given bank. > >> > >> If we are forced to use assembler it might be possible to write some m= acros that used the fixed at build values to only generate functions for ba= nks that are needed for a given build. Then I think it becomes an exercise = in dead code stripping the assembler. Most compilers generate assembler tha= t contains functions that can be stripped as long as those functions follow= certain rules. > >> > >> As a side note it would be good for us to have an FAQ/Wiki entry for t= he dead code stripping rules for the various flavors of assembler. I know t= he Apple assembler has a unique take on this. > > > > 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. > > > > I guess I usually think of DCE as a linker job, since the linker knows th= e functions that are NOT called. At least from the Apple tools the DCE has = the same rules if you are using Link Time Optimization or not. It is basica= lly a flag in the object that tells the inker it is OK to follow the DCE ru= les around labels and remove stuff. > > Worst case it seems like we could have macros that generate assembly file= s based on build time constants so we have one function per file. This migh= t take a tweak to the build system, but I=E2=80=99d rather do that than hav= e library functions that magically turn on Self Modifying Code. > > Regardless of the answer I think documenting the rules is a useful exerci= ses since needing to save size in firmware images is not an uncommon task. > There is already prior art in MdePkg where code targeting both GCC and VS uses inline asm, so I don't see why we would make our lives difficult and deviate from that for LoongArch. -=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 (#107771): https://edk2.groups.io/g/devel/message/107771 Mute This Topic: https://groups.io/mt/100751724/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-