Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optee-os: add optee rpmb support #326

Merged
merged 3 commits into from
Sep 27, 2022
Merged

Conversation

fr0st61te
Copy link
Contributor

This patch provides rpmb support for IOT2050 on am65 which includes:

  • TISCI protocol support
  • DKEK retrieval
  • DDR setup for DYNSHM
  • compile option changes for optee

Signed-off-by: Ivan Mikhaylov [email protected]

@@ -0,0 +1,460 @@
From cf20f0a4f77eddf47f278f3d20dc786793542ab4 Mon Sep 17 00:00:00 2001
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test it yet just bring it up for discussion.

Copy link
Collaborator

@BaochengSu BaochengSu Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't checked it but I notice this patch already acked by Linaro, so I guess this is already upstreamed or under upstreaming... So I believe somebody else had already tested it...

I think this patch is the prerequisite for the following SCI api patch so it must be picked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if we can pick the patches via upstream, that would be better. But the question is also if there is already a release with the patch included...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with a OPTee version bump as long as it does not generate clearing delta.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More important would be a careful check if security fixes need to be picked up - we are starting to put OP-TEE on the critical path now for real.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. We have CERT report to refer to, maybe that could be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if we can pick the patches via upstream, that would be better. But the question is also if there is already a release with the patch included...

there is no release, it's not under any tags, it's just directly from master which could be to dangerous to bump into that state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't checked it but I notice this patch already acked by Linaro, so I guess this is already upstreamed or under upstreaming... So I believe somebody else had already tested it...

I think this patch is the prerequisite for the following SCI api patch so it must be picked.

Yes, TI and me both did testing but not for 3.16.0, I'll test it out to check if all works from upstream.


require optee-os-iot2050_3.16.0.inc

OPTEE_EXTRA_BUILDARGS += " CFG_RPMB_WRITE_KEY=y"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's control that via an OVERRIDE, something like OPTEE_EXTRA_BUILDARGS_append_rpmb-setup = '...'. Then you can fold both recipes together again. The override would be set by a kas option file, similar to the secure boot enabling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll check how it will goes with OVERRIDE.

@jan-kiszka
Copy link
Collaborator

jan-kiszka commented Jun 24, 2022

We also need that kas option file to enable the special firmware build. And that setup should exclude signing the firmware, ie. detect and reject secure boot mode. With that safety measure, I think we could offer to build the special firmware also via kconfig. That would additionally provide the change to explain the usage and constraints in the help entry.

@fr0st61te
Copy link
Contributor Author

We also need that kas option file to enable the special firmware build.

kas-iot2050-boot-pg1-optee-rpmbw.yml
kas-iot2050-boot-pg2-optee-rpmbw.yml ? Or something else?

@jan-kiszka
Copy link
Collaborator

Do we need pg1/2 differentiation for that? Officially supported will be pg2 only anyway, but we can leave that door technically open. Otherwise maybe kas/opt/rpbm-setup.yml?

@fr0st61te fr0st61te force-pushed the rpmb_support branch 2 times, most recently from e57bf82 to e8b3747 Compare June 27, 2022 18:09
Kconfig Outdated Show resolved Hide resolved
@jan-kiszka
Copy link
Collaborator

What is now the actual testing status of these OP-TEE patches in the backported environment (3.16.0, rather than master)? Can we trust that? Or should we move at least to 3.17.0 (upstream merged them not that many commits after the release)?

@fr0st61te
Copy link
Contributor Author

What is now the actual testing status of these OP-TEE patches in the backported environment (3.16.0, rather than master)? Can we trust that? Or should we move at least to 3.17.0 (upstream merged them not that many commits after the release)?

3.16.0 works fine with backported patches. 3.17.0 and 3.17.0-rc1 don't have these patches, probably in new rc or .18 it will be available.

@fr0st61te fr0st61te force-pushed the rpmb_support branch 2 times, most recently from 0efef04 to c90f3ec Compare September 20, 2022 19:56
@fr0st61te
Copy link
Contributor Author

Last version of commits is not tested with 3.18.0, will do it on the current week.

kas/opt/rpbm-setup.yml Outdated Show resolved Hide resolved
@BaochengSu
Copy link
Collaborator

BaochengSu commented Sep 26, 2022

Testing on PG2, below error print could be confusing.

Security ID 0xc8beb00d-0x7f55c02e
Security policy: none
No options found, skip.
Validating FIT...
Loading image atf...
Loading image tee...
Loading image spl...
Loading image k3-am65-iot2050-spl.dtb...
NOTICE:  BL31: v2.6(release):
NOTICE:  BL31: Built : 02:56:00, Sep 14 2022
I/TC:
I/TC: OP-TEE version: 3.18.0 (gcc version 10.2.1 20210110 (Debian 10.2.1-6)) #1 Mon Sep 26 02:11:06 UTC 2022 aarch64
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0015 '21.9.1--v2021.09a (Terrific Lla')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
E/TC:0 0 ti_sci_get_response:120 Message not acknowledged
E/TC:0 0 ti_sci_do_xfer:149 Failed to get response (-65536)
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot

This happens during Line 64 of core/arch/arm/plat-k3/drivers/sa2ul.c

	/* Try to claim the SA2UL firewall for ourselves */
	ret = ti_sci_change_fwl_owner(fwl_id, sa2ul_region, owner_index,
				      &owner_privid, &owner_permission_bits);
	if (ret) {
		/*
		 * This is not fatal, it just means we are on an HS device
		 * where the DMSC already owns the SA2UL. On GP we need
		 * to do additional setup for access permissions below.
		 */
		DMSG("Could not change SA2UL firewall owner");
	} 

So it is expected on HS device. However, it is still confusing if I am a end user.

Already reported to upstream, see: OP-TEE/optee_os#5552 & https://github.com/OP-TEE/optee_os/pull/5328/files#r979529747

@BaochengSu
Copy link
Collaborator

Seems CONFIG_CMD_OPTEE_RPMB is missing from u-boot?

@BaochengSu
Copy link
Collaborator

I think we should have some wikis regarding how to program the RPMB key, just as what we've done for secure boot otp key programming.

This patch provides rpmb support for IOT2050 on am65 which includes:
* TISCI protocol support
* DKEK retrieval
* DDR setup for DYNSHM
* compile option changes for optee

Signed-off-by: Ivan Mikhaylov <[email protected]>
Signed-off-by: Ivan Mikhaylov <[email protected]>
This patch provides do_patch_prepend for OPTEE recipe which needed for
prevention of usage rpmb-setup and secureboot because rpmb-setup
shouldn't be used on production systems.

Signed-off-by: Ivan Mikhaylov <[email protected]>
@BaochengSu
Copy link
Collaborator

Test passed on PG2 device.

@BaochengSu BaochengSu merged commit 142b0ae into siemens:master Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants