After updating to ATF v2.5 on the Xilinx ZynqMP platform, I was having issues
with the FPGA PL logic not loading successfully from U-Boot, it was failing
with this error:
PL FPGA LOAD failed with err: 0x000007d6
which is PM_RET_ERROR_TIMEOUT. The following commit introduced the timeout:
commit 4d9b9b2352f9a67849faf2d4484f5fcdd2788b01
Author: Tejas Patel <tejas.patel(a)xilinx.com>
Date: Thu Feb 25 02:37:09 2021 -0800
plat: xilinx: Add timeout while waiting for IPI Ack
Return timeout error if, IPI is not acked in specified timeout.
Signed-off-by: Tejas Patel <tejas.patel(a)xilinx.com>
Change-Id: I27be3d4d4eb5bc57f6a84c839e2586278c0aec19
The timeout value (TIMEOUT_COUNT_US) is set to 0x4000 (16384) usec, which
appears to be too short for the FPGA loading operation (at least on the ZCU102
board with XCZU9EG device), causing it to always timeout. Increasing the
timeout to 0xF4240 usec (i.e. 1 second) fixes the issue, though some lower
value may also be sufficient.
--
Robert Hancock
Senior Hardware Designer, Calian Advanced Technologies
www.calian.com
>> Our initial ask was to only bump the SP image entrypoint past the DTB boundary while generating SP.pkg using sptool. IIUC, the issue you brought up is for passing the manifest base address to the SP at runtime. I think these two are independent issues. Please advise.
[RK] Agree here. Passing information through the manifest to the SP is orthogonal to the main problem at hand where we are assuming that the size of manifest cannot be > 4K and the entrypoint offset is always at 0x100.
-Raghu
-----Original Message-----
From: TF-A <tf-a-bounces(a)lists.trustedfirmware.org> On Behalf Of Varun Wadekar via TF-A
Sent: Tuesday, June 22, 2021 7:35 AM
To: Olivier Deprez <Olivier.Deprez(a)arm.com>; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy <raghupathyk(a)nvidia.com>; Nicolas Benech <nbenech(a)nvidia.com>
Subject: Re: [TF-A] SP manifest: avoid manual updates to "entrypoint-offset"
Hi Olivier,
>> [OD] The two questions are which entity is loading boot data (can be a DT blob) that is to be consumed by the SP? And how is the address for boot data conveyed to the SP?
The SP manifest is made for the SPMC consumption. I guess it's ok to conflate DT information required by the SP into the SP manifest. It means the bootloader loads both the SP manifest and the SP boot data in a single "SP package". In current implementation the SP has no standard way to know where the DT blob is loaded in its own memory range. We have experimental patches around the FF-A boot protocol which may help.
[VW] You are right - bootloader loads SP.pkg (header+manifest+image) into memory. Can you please help me understand what "SP boot data" contains? For passing the SP manifest pointer to the SP we should ask for ideas from the community.
Some ideas to get the discussion started:
1. SPMC creates a mapping for the manifest in the SP's virtual address space. SP issues a SVC call to get the virtual address from the SPMC 2. SPMC creates a mapping for the manifest in the SP's virtual address space and passes the pointer to SP via X0 3. SP manifest contains an entry to publish the virtual address for its manifest. SPMC reads this entry and maps the manifest at that virtual address during boot.
>> [OD] If the assumptions (implementation defined) are that the SP boot data fits into the SP manifest, and that the SP finds this data at a fixed address (e.g. offset 0 in the SP package) then yes it can be a way to go.
[VW] Our initial ask was to only bump the SP image entrypoint past the DTB boundary while generating SP.pkg using sptool. IIUC, the issue you brought up is for passing the manifest base address to the SP at runtime. I think these two are independent issues. Please advise.
-Varun
-----Original Message-----
From: Olivier Deprez <Olivier.Deprez(a)arm.com>
Sent: Tuesday, June 22, 2021 8:17 AM
To: Varun Wadekar <vwadekar(a)nvidia.com>; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy <raghupathyk(a)nvidia.com>; Nicolas Benech <nbenech(a)nvidia.com>
Subject: Re: SP manifest: avoid manual updates to "entrypoint-offset"
External email: Use caution opening links or attachments
Hi Varun,
(sorry last message sent too fast)
See few comments inline [OD].
Regards,
Olivier.
________________________________________
From: Varun Wadekar <vwadekar(a)nvidia.com>
Sent: 17 June 2021 12:33
To: Olivier Deprez; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy; Nicolas Benech
Subject: RE: SP manifest: avoid manual updates to "entrypoint-offset"
Hi,
>> [OD] Ok. How is the SP informed about where to find the dtb (IPA address)? Saying this because the boot protocol between Hafnium and SPs is very much implementation specific at this moment and does not strictly follow the FF-A spec recommendations (data passing as TLVs). There is a trick that the manifest blob remains fortunately mapped from offset 0 in the SP IPA range. So it may be able to extract manifest data by mapping it the Stage-1 translation regime. But as said this does not follow a standard.
[VW] We don't have a policy for all SPs, yet. At least I don't know of one. But in our experimental setup we plan to work on some assumptions e.g. assume the manifest blob to always be present at a certain address.
[OD] The two questions are which entity is loading boot data (can be a DT blob) that is to be consumed by the SP? And how is the address for boot data conveyed to the SP?
The SP manifest is made for the SPMC consumption. I guess it's ok to conflate DT information required by the SP into the SP manifest. It means the bootloader loads both the SP manifest and the SP boot data in a single "SP package". In current implementation the SP has no standard way to know where the DT blob is loaded in its own memory range. We have experimental patches around the FF-A boot protocol which may help.
>> [OD] I think review link is mysteriously broken and the review lost. But Joao can provide the new link if necessary. I understand the intent of not making things too complex.
[VW] Can we list down the next steps? Do we agree in principle that sptool needs to be upgraded to handle this use case? We can collaborate on an implementation, once we agree on the direction.
[OD] If the assumptions (implementation defined) are that the SP boot data fits into the SP manifest, and that the SP finds this data at a fixed address (e.g. offset 0 in the SP package) then yes it can be a way to go.
Cheers.
-----Original Message-----
From: Olivier Deprez <Olivier.Deprez(a)arm.com>
Sent: Thursday, June 17, 2021 8:40 AM
To: Varun Wadekar <vwadekar(a)nvidia.com>; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy <raghupathyk(a)nvidia.com>; Nicolas Benech <nbenech(a)nvidia.com>
Subject: Re: SP manifest: avoid manual updates to "entrypoint-offset"
External email: Use caution opening links or attachments
Hi Varun,
Few comments [OD]
Regards,
Olivier.
________________________________________
From: Varun Wadekar <vwadekar(a)nvidia.com>
Sent: 16 June 2021 14:37
To: Olivier Deprez; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy; Nicolas Benech
Subject: RE: SP manifest: avoid manual updates to "entrypoint-offset"
Hi,
>> Just a small heads up VHE SEL0 changes are tested within the Hafnium CI presently and do not relate to TF-A CI. sptool is a TF-A tool and there is no link to the Hafnium CI.
[VW] Thanks for the heads up.
>> what is the order in size for the manifest dtb you require in Tegra platform? Are the supplementary nodes in this manifest consumed by Hafnium or the SP itself?
[VW] We can assume tens of KB. In the worst case, a few hundred KB. The manifest is targeted towards the SP and not meant for Hafnium. Just curious, do you see any pitfalls?
[OD] Ok. How is the SP informed about where to find the dtb (IPA address)? Saying this because the boot protocol between Hafnium and SPs is very much implementation specific at this moment and does not strictly follow the FF-A spec recommendations (data passing as TLVs). There is a trick that the manifest blob remains fortunately mapped from offset 0 in the SP IPA range. So it may be able to extract manifest data by mapping it the Stage-1 translation regime. But as said this does not follow a standard.
>> To set the complete picture, Joao had made some exploration around more dynamic SP configuration [2], maybe there are ideas to gather from there.
[VW] Thanks for the links. I will review and leave comments - although we are not looking at introducing yet another script.
[OD] I think review link is mysteriously broken and the review lost. But Joao can provide the new link if necessary. I understand the intent of not making things too complex.
Cheers.
-----Original Message-----
From: Olivier Deprez <Olivier.Deprez(a)arm.com>
Sent: Wednesday, June 16, 2021 12:59 PM
To: Varun Wadekar <vwadekar(a)nvidia.com>; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy <raghupathyk(a)nvidia.com>; Nicolas Benech <nbenech(a)nvidia.com>
Subject: Re: SP manifest: avoid manual updates to "entrypoint-offset"
External email: Use caution opening links or attachments
Hi Varun,
See inline [OD]
Regards,
Olivier.
________________________________________
From: Varun Wadekar <vwadekar(a)nvidia.com>
Sent: 16 June 2021 13:07
To: Olivier Deprez; tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy; Nicolas Benech
Subject: RE: SP manifest: avoid manual updates to "entrypoint-offset"
HI Olivier,
>> [OD] Just to be clear, is this about SEL0 partitions using an SEL1
>> shim
No, this issue can be seen even without the shim. I don't think the usage of shim or VHE really matters here.
[OD] All right. Just a small heads up VHE SEL0 changes are tested within the Hafnium CI presently and do not relate to TF-A CI. sptool is a TF-A tool and there is no link to the Hafnium CI. Not an issue as such but just making sure you have the full picture. At some point in time, when Hf VHE changes are merged we can create a specific TF-A test config to cover this case if necessary.
Out of curiosity what is the order in size for the manifest dtb you require in Tegra platform? Are the supplementary nodes in this manifest consumed by Hafnium or the SP itself?
>> [OD] This does not relate exactly to your problem but the effect is the "same" (aka there is more room for the manifest dtb). Agree this still requires hard-coding the entry point. At this stage I had thought of pushing the entry point even farther at a reasonably large 64KB aligned offset such that it helps with both problems.
I agree, this approach is good for the short term. But I propose we craft a forward-looking solution. Are you planning on merging the sptool patch[1]? If not, I propose we come up with a way to dynamically update the SP manifest - I understand this involves adding libfdt to update the manifest.
[OD] There is no pressing need to merge [1] in the short term so this can wait for a better solution.
To set the complete picture, Joao had made some exploration around more dynamic SP configuration [2], maybe there are ideas to gather from there.
-Varun
[1] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freview.tr…
[2] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.tru…
-----Original Message-----
From: Olivier Deprez <Olivier.Deprez(a)arm.com>
Sent: Wednesday, June 16, 2021 11:42 AM
To: tf-a(a)lists.trustedfirmware.org; Nicolas Benech <nbenech(a)nvidia.com>
Cc: Raghupathy Krishnamurthy <raghupathyk(a)nvidia.com>; Varun Wadekar <vwadekar(a)nvidia.com>
Subject: Re: SP manifest: avoid manual updates to "entrypoint-offset"
External email: Use caution opening links or attachments
Hi,
See few comments inline [OD]
Regards,
Olivier.
________________________________________
From: TF-A <tf-a-bounces(a)lists.trustedfirmware.org> on behalf of Varun Wadekar via TF-A <tf-a(a)lists.trustedfirmware.org>
Sent: 16 June 2021 11:41
To: tf-a(a)lists.trustedfirmware.org
Cc: Raghupathy Krishnamurthy; Nicolas Benech
Subject: [TF-A] SP manifest: avoid manual updates to "entrypoint-offset"
Hello,
We (Nico/Raghu) have been implementing SEL0 partitions for Tegra platforms
[OD] Just to be clear, is this about SEL0 partitions using an SEL1 shim (as per https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freview.tr… )?
and recently hit an issue, where the "entrypoint-offset" field of the SP manifest [1] cannot cope with increasing manifest blobs. The way the SP manifest is created today, the "entrypoint-offset" field is set to a value *statically* by the implementer. Down the line if the manifest grows past the value written in the "entrypoint-offset", we must manually update it. This needs to be fixed.
We believe there is an opportunity to upgrade the sptool to handle this situation during SP package creation, where sptool calculates the manifest size and bumps the "entrypoint-offset" past the end of the manifest. There are other ways of patching the SP manifest at runtime, but they seem sub-optimal.
Please let me know if there are other ideas to solve this problem. I will post a patch to update the sptool shortly but wanted to get the ball rolling.
[OD] We had an attempt (https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freview.tr…) to move the entry point farther in the image such that we can support 64KB granules in the Stage-1 translation regime. This does not relate exactly to your problem but the effect is the "same" (aka there is more room for the manifest dtb). Agree this still requires hard-coding the entry point. At this stage I had thought of pushing the entry point even farther at a reasonably large 64KB aligned offset such that it helps with both problems.
Cheers.
[1] 14. FF-A manifest binding to device tree - Trusted Firmware-A documentation<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftrustedfi…>
--
TF-A mailing list
TF-A(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-a
Hi Boaz,
It appears that you have included plat/arm files in your platform porting which is causing Arm platform function definition to be included.
Along with providing generic implementations Arm also has its own platforms(like any other partner platforms), code under plat/arm is meant only for Arm platforms.
Check your make file and make sure that you don't include plat/arm/common/arm_pm.c(to avoid plat_setup_psci_ops) and plat/arm/common/aarch64/arm_helpers.S(for other functions you mentioned) this will avoid multiple definition errors.
Hope this helps
thanks
Manish
________________________________
From: TF-A <tf-a-bounces(a)lists.trustedfirmware.org> on behalf of IS20 Boaz Baron via TF-A <tf-a(a)lists.trustedfirmware.org>
Sent: 29 July 2021 09:12
To: Madhukar Pappireddy <Madhukar.Pappireddy(a)arm.com>
Cc: tf-a(a)lists.trustedfirmware.org <tf-a(a)lists.trustedfirmware.org>; IN20 Hila Miranda-Kuzi <Hila.Miranda-Kuzi(a)nuvoton.com>
Subject: Re: [TF-A] A Q about TZ porting guide
Also, those functions aren’t defined as WEAK so I encountered the same problem (multiple definitions)
plat_crash_console_putc
plat_crash_console_flush
platform_mem_init
From: IS20 Boaz Baron
Sent: Thursday, July 29, 2021 10:14 AM
To: Madhukar Pappireddy <Madhukar.Pappireddy(a)arm.com>
Cc: tf-a(a)lists.trustedfirmware.org; IN20 Hila Miranda-Kuzi <Hila.Miranda-Kuzi(a)nuvoton.com>
Subject: RE: [TF-A] A Q about TZ porting guide
Thanks Madhukar for your answer,
I think I wasn’t so clear.
plat_setup_psci_ops is listed as mandatory in the porting guide.
I implemented it locally but linkage fails because it is also defined in arm_pm.c.
How do you suggest to avoid this multiple definition?
Thanks,
Boaz.
From: Madhukar Pappireddy <Madhukar.Pappireddy(a)arm.com<mailto:Madhukar.Pappireddy@arm.com>>
Sent: Wednesday, July 28, 2021 10:44 PM
To: IS20 Boaz Baron <boaz.baron(a)nuvoton.com<mailto:boaz.baron@nuvoton.com>>
Cc: tf-a(a)lists.trustedfirmware.org<mailto:tf-a@lists.trustedfirmware.org>
Subject: RE: [TF-A] A Q about TZ porting guide
Hi Boaz
Yes, plat_setup_psci_ops() is mandatory. Every platform needs to implement it independently. You can use the implementation from [1] as a reference. I don’t think you have to delete any original function. If your platform does not support PSCI spec, you can implement a dummy function. Hope it helps.
int plat_setup_psci_ops(uintptr_t sec_entrypoint,
const plat_psci_ops_t **psci_ops)
{
return 0;
}
[1] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/arm/c…<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.trust…>
Thanks,
Madhukar
From: TF-A <tf-a-bounces(a)lists.trustedfirmware.org<mailto:tf-a-bounces@lists.trustedfirmware.org>> On Behalf Of IS20 Boaz Baron via TF-A
Sent: Wednesday, July 28, 2021 7:58 AM
To: tf-a(a)lists.trustedfirmware.org<mailto:tf-a@lists.trustedfirmware.org>
Subject: [TF-A] A Q about TZ porting guide
Hi all,
I have a Q about plat_setup_psci_ops() function implementation ,
In the porting guide, that function is defined as mandatory BUT the original (arm) function isn’t defined as #pargam WEAK.
what should I do? to use/ delete the original function?
Thanks,
Boaz.
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Hi Boaz
Yes, plat_setup_psci_ops() is mandatory. Every platform needs to implement it independently. You can use the implementation from [1] as a reference. I don't think you have to delete any original function. If your platform does not support PSCI spec, you can implement a dummy function. Hope it helps.
int plat_setup_psci_ops(uintptr_t sec_entrypoint,
const plat_psci_ops_t **psci_ops)
{
return 0;
}
[1] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/arm/c…
Thanks,
Madhukar
From: TF-A <tf-a-bounces(a)lists.trustedfirmware.org> On Behalf Of IS20 Boaz Baron via TF-A
Sent: Wednesday, July 28, 2021 7:58 AM
To: tf-a(a)lists.trustedfirmware.org
Subject: [TF-A] A Q about TZ porting guide
Hi all,
I have a Q about plat_setup_psci_ops() function implementation ,
In the porting guide, that function is defined as mandatory BUT the original (arm) function isn't defined as #pargam WEAK.
what should I do? to use/ delete the original function?
Thanks,
Boaz.
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Hi all,
I have a Q about plat_setup_psci_ops() function implementation ,
In the porting guide, that function is defined as mandatory BUT the original (arm) function isn't defined as #pargam WEAK.
what should I do? to use/ delete the original function?
Thanks,
Boaz.
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Hi, I’m trying to implement a secure boot on a STM32MP1 without using the FIP file.
For now , I am not able to use FIP format during the boot process so I use a depreciated boot process with TF-Av2.2 as FSBL and U-Boot as SSBL to boot my Board.
My boot process do Romcode -> TF-A (BL2) -> SP_min (BL32) -> U-Boot (BL33) -> Linux kernel
I succefully implemented signature authentification between U-Boot and Linux image, but between TF-A and U-Boot it’s a little bit harder.
I learned on ST wiki how to sign my u-boot binary with the STM32MP_SigningTool_CLI, but when I sign my binary with a custom private key, TF-A don’t authentified it on boot, even if i tryed to pass my key to TF-A at compilation time with the BL33_KEY argument, which i think is dedicated to the FIP usage.
I found, in the sources of TF-A, what I think being a developpement key, named « arm_rotpk_ecdsa.pem ».
And when I sign my binary with this key, I am able to perform the signature check and continu my boot process. So I tryed to change this key with a custom one and recompile TF-A to update the key in the final binary, but it seem that it is not so simple.
I found yesterday that the auth_mod_init() function wasn’t call because I had forgotten the TUSTED_BOARD_BOOT=1 compilation argument. But when I activate it, the compilation doesn’t work and i see
« build/arm-trusted-firmware-v2.2/bl2/bl2_main.c:91: undefined reference to `auth_mod_init' »
Whitch traditionnaly append when linker don’t find the .o where the functions are implemented.
I would like to know if it is possible to implement some kind of authentification with custom keys without FIP and if yes where can i find some hints/ressources/tutorial ?
I don’t find a lot of ressources about secure boot without FIP so I hope you will be able to help me.
Hi Alexey,
On Thu, Jul 22, 2021 at 10:14 AM Alexey Kazantsev via TF-A
<tf-a(a)lists.trustedfirmware.org> wrote:
>
> Hello!
>
> Please add a build option for selecting GICv3 instead of GICv2 for QEMU
> platform.
>
> There is the following line in plat/qemu/qemu/platform.mk :
> QEMU_USE_GIC_DRIVER := QEMU_GICV2
>
> It doesn't imply setting GICv3 externally by build system of other
> projects, like OP-TEE.
When building with OP-TEE we're overriding this assignment by passing
"QEMU_USE_GIC_DRIVER=$(TFA_GIC_DRIVER)" (where TFA_GIC_DRIVER is
either QEMU_GICV3 or QEMU_GICV2) on the command line.
This is now tested on a regular basis since we've recently added Xen
support to the OP-TEE build setup on QEMU V8 and this depends on using
GICv3 instead of GICv2.
Does this help in your case?
Cheers,
Jens
Hello!
Please add a build option for selecting GICv3 instead of GICv2 for QEMU
platform.
There is the following line in plat/qemu/qemu/platform.mk :
QEMU_USE_GIC_DRIVER := QEMU_GICV2
It doesn't imply setting GICv3 externally by build system of other
projects, like OP-TEE.
Best regards, Aleksey.
Hi Tom,
Thanks for your interest in the SC7180 TF-A port! You're asking fair
questions about a difficult situation, so let me try to add some
background:
The binary component policy was actually written specifically as part
of the discussions about adding the SC7180 port, to lay some
guidelines and ground rules about how to deal with binary components
(which already existed in some other platform ports beforehand). This
case was discussed in-depth with the project leaders and the
trustedfirmware.org Board beforehand, and it was always understood
that this would have to be a tricky compromise. As you may know,
devices (e.g. Android phones) with Qualcomm chipsets generally do not
run TF-A, but instead run Qualcomm's proprietary trusted OS and secure
monitor (QTEE). The TF-A port was more of an experimental side project
(which has by now resulted in a few SC7180-based Chromebooks being
sold with TF-A, but the much larger phone market continues to use
QTEE), so unfortunately the TF project's position to make demands is
not yet as solid as you may think. Basically, we could have either
made these compromises or continue to not support Qualcomm chipsets at
all, so due to their prevalence in the ecosystem we decided it would
be worth it to start like this, try to make the situation as good as
it can get, and then hopefully improve on that in future chipset
generations.
The binary policy is meant as more of a decision guideline and
individual cases are ultimately up to the Board. FWIW maybe I slightly
mis-summarized the policy in the text added to the contributing.rst
document -- I think saying that the *majority* of the platform port
(in terms of bytes of code) should be open source, while a good
ambition in general, was never realistic for SC7180. The full document
in https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst
instead says "Binary components that contain all meaningful
functionality of a platform port" are not accepted -- the intention is
that there are pieces large enough to be worth modifying in the open
source part, while allowing vendors to keep functionality proprietary
that they absolutely do not want (or are not allowed) to disclose. For
SC7180, things like UART, SPMI, PMIC and RNG drivers as well as SMC
validation are implemented in open source (and as you noticed some of
those were ported piecemeal at later points of the development
process). I'll be the first to admit that this isn't a lot and we
absolutely want to do more, but it is a tricky and very time-consuming
process both in identifying the exact parts that can be open-sourced
without IP concerns and then actually doing the work (since the
qtiseclib code is still proprietary even if there is a Linux driver
for the same subsystem, we can't just copy things over, it has to be
carefully rewritten and revalidated). The state you see the SC7180
port in right now is basically just as far as we got over the course
of this project (and believe me it took a lot of effort already, even
if it may not look like much). Hopefully we can make further progress
with the next chipset.
Also, just as a note, we didn't actually end up hosting qtiseclib in
the TF binary repository in the end, due to concerns about details in
the license text that couldn't be resolved. It is instead hosted by
the coreboot.org project at the moment. I'm not sure if this
technically means that the TF binary component policy applies to this
blob or not (from a strict reading of the text I would say it
doesn't), but that's not really that relevant... like I said, in the
end the Board makes final decisions about whether a platform port is
accepted into the repository or not on a case by case basis, and the
policy is just a general guideline. The general goal is to make sure
the TF-A ports are actually useful to open source developers while
allowing for pragmatic compromises in tricky situations like this, and
in this case we decided that allowing this port would be more useful
than not (although it's certainly on the edge).
On Tue, Jul 20, 2021 at 2:05 AM Tom Johnsen <tomjohnsen(a)protonmail.com> wrote:
>
> Hello!
>
> I recently discovered the TF-A port for QTI SC7180 and was very happy
> to see this. I always thought it would have been great if Qualcomm made
> (open-source) TF-A ports for their platforms. For example, I would be
> interested in TF-A for the DragonBoard 820c (APQ8096E).
> Unfortunately, after talking to some other people I have been told
> it is unlikely that Qualcomm will ever have this. :-/
>
> I am not much of a firmware developer but I was curious so I wanted to
> check how much SoC-specific code is actually needed for a TF-A port. At
> first I was surprised - the QTI platform ports seem fairly simple, there
> is not much SoC-specific code at all. However, it looks like the reason for
> that is that almost all of the SoC-specific code is actually contained in a
> proprietary "qtiseclib" blob that is statically linked into the bl31.bin.
>
> I did not really expect to see something like that in a public
> open-source project, especially not one as security-critical as TF-A.
> It looks like some binary components are indeed allowed as per the
> Contribution Guidelines (1). Yet, after reading them and looking at the
> code again I wonder how the amount of functionality implemented
> in the "qtiseclib" could really conform to these guidelines?
>
> I quote them here (from (1)) for convenience:
>
> > Binary components must be restricted to only the specific
> > functionality that cannot be open-sourced and must be linked into a
> > larger open-source platform port. The majority of the platform port
> > must still be implemented in open source. Platform ports that are
> > merely a thin wrapper around a binary component that contains all the
> > actual code will not be accepted.
>
> There are two main reasons why I do not think that the "qtiseclib"
> conforms to these guidelines.
>
> --- 1. "Majority of the platform port must be open-source" ---
>
> I have built TF-A for QTI SC7180 according to the documentation (2).
> The resulting bl31.bin has a size of 182088 bytes. The linker conveniently
> produces a "bl31.map" file that shows exactly which part of the binary
> comes from which component of the TF-A port. It can be analyzed easily,
> for example with fpv-gcc (3).
>
> The following table shows the distribution of the bl31.bin:
>
> +-------------+----------+-----+
> | Component | Size (B) | % |
> +-------------+----------+-----+
> | libqtisec.a | 147344 | 81% |
> | Other BL31 | 23838 | 13% |
> | plat/qti | 5222 | 3% |
> | Padding | 3863 | 2% |
> | libc.a | 1821 | 1% |
> +-------------+----------+-----+
>
> Clearly, the libqtisec.a dominates with 81%. The open-source part of the
> QTI TF-A platform port (plat/qti) is merely 3% of the final binary.
>
> Perhaps it is just large static data tables? The following table shows
> only the distribution of .text symbols (excluding libc and "Other BL31"):
>
> +-------------+----------+-----+
> | Component | Size (B) | % |
> +-------------+----------+-----+
> | libqtisec.a | 75792 | 95% |
> | plat/qti | 3920 | 5% |
> +-------------+----------+-----+
>
> I do not see any way to interpret this as "the majority of the platform
> port is open-source". It is hard to find any substantial functionality
> that does not end up calling into the proprietary qtiseclib. In my
> opinion, the port is hardly more than "a thin wrapper around a binary
> component" which is explicitly forbidden in the guidelines.
>
> --- 2. "Binary components should be as minimal as possible" ---
>
> It is hard to judge this given that the license for "qtiseclib" (obviously)
> does not allow reverse-engineering. However, just judging from some of the
> symbol names that I see visibly in the "bl31.map" Qualcomm seems to have
> spent little effort to keep the binary component actually minimal.
>
> "qtiseclib" also contains code for IP blocks that have public
> open-source drivers in Linux, including for:
>
> - TLMM (GPIO)
> - GCC (Clocks)
> - rpmh
>
> Perhaps some "secret" registers are programmed there but it is hard to
> believe that there is no overlap that could have been made open-source.
>
> This is also quite visible based on changes that were made later.
> The PRNG and SPMI driver were moved out of "qtiseclib" later (4, 5)
> and both can be found similarly in Linux.
>
> --- Conclusion ---
>
> How does this conform to the Binary Components policy that is part of
> the contribution guidelines? Was this not checked during review?
>
> All in all I cannot help but get the feeling that Qualcomm has fairly
> little interest to have open-source firmware. Not even simple hardware
> initialization that probably exists similarly in open-source drivers
> has been implemented in open-source code. The resulting bl31.bin can
> be hardly called "open-source" when 81% of it is actually proprietary.
>
> If this is intended and considered acceptable I suggest rewriting the
> "Binary Components" policy to explicitly allow vendors to require
> any amount of proprietary code for their TF-A ports. Personally, I think
> this is a very bad idea though and just encourages all other vendors to
> do the same in the future. TF-A (as a trusted reference implementation)
> is in a good position to make certain demands that must be met for
> inclusion in the upstream tree.
>
> I am mainly sad about this because this certainly means that only
> Qualcomm can make such ports by providing the "qtiseclib" that contains
> most of the functionality. Perhaps open-source code could have been
> adjusted by the community to other platforms with some effort.
>
> Thanks for reading.
> ~ Tom
>
> (1) https://trustedfirmware-a.readthedocs.io/en/latest/process/contributing.htm…
> (2) https://trustedfirmware-a.readthedocs.io/en/latest/plat/qti.html
> (3) https://github.com/ebs-universe/fpv-gcc
> (4) https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/4885
> (5) https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/4409