Skip to content

Conversation

@vonhust
Copy link

@vonhust vonhust commented Aug 8, 2018

This PR is initial implementation of some kind of TEE support for ARC.

As the TEE design/framework in zephyr matures, more work will be needed.

It includes necessary commits to let zephyr run in normal mode of
arc processors equipped with SecureShield.

In this PR, zephyr can be built into:

  1. imgage for secure mode (CONFIG_ARC_SECURE_FIRMWARE <- TRUSTED_EXECUTION_SECURE)
    • full access to system resource
    • full zephyr features are supported, USERSPACE, stack protection
  2. image for normal mode (CONFIG_ARC_NORMAL_FIRMWARE)
  • no mpu support in normal mode, i.e., no USERSPACE
  • to run this normal image, it requires a secure bootloader or secure zephyr application to
    boot, as when processor is reset, it's secure mode.

To show how normal zephyr application works with secure zephyr applicaiton, an example is provided in samples/boards/arc_secure_services, more details, pls go to the README.rst of this example.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's actually ok to read ERSEC_STAT from Normal mode as well - fields without access will be 0 (IOW/RAZ)

Copy link
Author

Choose a reason for hiding this comment

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

read is ok, but no write. It will make codes simpler

Copy link
Member

Choose a reason for hiding this comment

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

I assume this is a temporary, minimal initialization for Secure Mode when Zephyr runs in Normal mode. To be replaced later with a Secure firmware that can be extended to provide more functions as well.

Copy link
Author

Choose a reason for hiding this comment

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

It's removed in latest codes

Copy link
Member

Choose a reason for hiding this comment

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

maybe add comment that these are initialized in Secure mode initialization code instead.

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

See earlier remark on ERSEC_STAT, I think it's ok to access from Normal mode as well.

Copy link
Member

Choose a reason for hiding this comment

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

Is reading the current contents best way to initialize the SEC_STAT in the initial context? Can't it be some constant value?

Copy link
Author

Choose a reason for hiding this comment

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

It could be a constan value. I will consider to change it later.

Copy link
Member

Choose a reason for hiding this comment

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

Assume this is for the temporary secure initialization code, it's not really 'logical' to declare secure stuff in a 'NORMAL_FIRMWARE' conditional section. (maybe add a 'TODO' note)

Copy link
Member

Choose a reason for hiding this comment

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

not sure we cover all combination of options, looks like HAS_SECURE implies we also have USERSPACE - no support for Secure but no userspace?

Copy link
Author

Choose a reason for hiding this comment

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

if no userspace, no need to save and restore USER/KERNEL_SP realted aux regs.

Copy link
Member

Choose a reason for hiding this comment

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

Missing case for HAS_SECURE and NORMAL_FIRMWARE?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

Choose a reason for hiding this comment

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

not sure an sjli call would be required here, this setup is only done once and could be done by Secure firmware before switching to Normal Zephyr.

Copy link
Member

Choose a reason for hiding this comment

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

copy/paste typo: this should be nsim_sem_normal

Copy link
Member

Choose a reason for hiding this comment

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

maybe suspend/resume functionality should have different overall implementation, Secure firmware should probably also support suspend/resume for this to work.

Copy link
Member

Choose a reason for hiding this comment

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

All interrupts either Secure or Normal is probably too strong, some should be allocated to Secure and some to Normal depending on application. For now ok, but add a note (or issue) to support configuration/allocation of interrupts to Secure or Normal.

Copy link
Author

Choose a reason for hiding this comment

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

It requires a mechinism to tell which interrupts are secure, which are normal

@nashif
Copy link
Member

nashif commented Sep 14, 2018

@vonhust @ruuddw can you please rebase and drive to closure? thanks.

@vonhust vonhust force-pushed the arc_normal_mode branch 2 times, most recently from 206078c to ed62684 Compare October 29, 2018 16:02
@nashif
Copy link
Member

nashif commented Nov 15, 2018

@ruuddw are you ok with this?

@ruuddw ruuddw added the DNM This PR should not be merged (Do Not Merge) label Nov 15, 2018
@ruuddw
Copy link
Member

ruuddw commented Nov 15, 2018

@nashif still work in progress, I've marked it DNM for now.

@nashif
Copy link
Member

nashif commented Nov 15, 2018

@nashif still work in progress, I've marked it DNM for now.

ok

@zephyrbot
Copy link

zephyrbot commented Dec 19, 2018

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping me when there's documentation to review...

Copy link
Author

Choose a reason for hiding this comment

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

pls review the documentation.

@vonhust vonhust force-pushed the arc_normal_mode branch 2 times, most recently from 6c52893 to dd88959 Compare December 24, 2018 12:45
@ioannisg ioannisg requested a review from dbkinder August 8, 2019 13:26
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we're referring to the repo name, use an upper case Z on Zephyr.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

let's change this to:

... runs together with a normal Zephyr application.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Start the sentence with an upper-case letter, The secure application ...

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize acronyms: RAM, ROM

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Change to:

* Memory not allocated to the secure application is allocated to
  the normal application.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to:

Run using the bootloader
   The bootloader should load the secure and normal application into the correct place,
   then jump to the entry of the secure application.

Run using the debugger (recommended)
   Use the gdb debugger to load and run the two applications.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

delete please

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Change to:

For nsim sem, you need two consoles: one for
application output, and one for the debugger.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to specify the path of the secure application, or is that on line 120?

Copy link
Author

Choose a reason for hiding this comment

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

means any zephyr image built in line 73, i will make it more clarified

@vonhust vonhust force-pushed the arc_normal_mode branch 4 times, most recently from 63b4e74 to 7820d92 Compare August 9, 2019 09:52
@ioannisg ioannisg requested a review from ruuddw August 9, 2019 10:08
Copy link
Member

@ruuddw ruuddw left a comment

Choose a reason for hiding this comment

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

There's remaining work to do, but this is a good start for people that want to experiment with this on ARC.
Let's get it into v2.0.

@galak galak mentioned this pull request Aug 9, 2019
48 tasks
@ioannisg
Copy link
Member

ioannisg commented Aug 9, 2019

There's remaining work to do, but this is a good start for people that want to experiment with this on ARC.
Let's get it into v2.0.

@vonhust have you addressed the latest feedback by @dbkinder ?

@ioannisg ioannisg requested a review from dbkinder August 9, 2019 13:05
Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

I see you mention my comments were "fixed", but I don't see the changes actually pushed.

@vonhust
Copy link
Author

vonhust commented Aug 9, 2019

, but I don't see the changes actually pushed.

I made a force push, could you check that again?

@ioannisg
Copy link
Member

ioannisg commented Aug 9, 2019

Seems to me the fixes were pushed (but might be missing something @dkinder).

@vonhust
Copy link
Author

vonhust commented Aug 9, 2019

better to merge after PR #18079 and #18142

@ioannisg
Copy link
Member

ioannisg commented Aug 9, 2019

better to merge after PR #18079 and #18142

@vonhust please resolve the conflicts, after merging the above PRs.
Note that the review needs to conclude today, if this is to get to 2.0 release.

Wayne Ren added 4 commits August 10, 2019 09:51
* it's based on ARC SecureShield
* add basic secure service in arch/arc/core/secureshield
* necesssary changes in arch level
   * thread switch
   * irq/exception handling
   * initialization
* add secure time support

Signed-off-by: Wayne Ren <[email protected]>
* Non-secure/normal application: em_starterkit_em7d_normal
* secure application: em_starterkit_em7d

Signed-off-by: Wayne Ren <[email protected]>
normal/non-secure application: nsim_sem_normal

Signed-off-by: Wayne Ren <[email protected]>
* this is a simple sample to show how
 secure applicaiton and non-secure application work
 together. More details are in README.rst

Signed-off-by: Wayne Ren <[email protected]>
@vonhust
Copy link
Author

vonhust commented Aug 10, 2019

better to merge after PR #18079 and #18142

@vonhust please resolve the conflicts, after merging the above PRs.
Note that the review needs to conclude today, if this is to get to 2.0 release.

confilct fixed, ok to merge

@ioannisg
Copy link
Member

better to merge after PR #18079 and #18142

@vonhust please resolve the conflicts, after merging the above PRs.
Note that the review needs to conclude today, if this is to get to 2.0 release.

confilct fixed, ok to merge

There is still a request-for-changes by @dbkinder.
@vonhust can this PR go into 2.0.0 regardless of what happens with #17767?

@vonhust vonhust dismissed dbkinder’s stale review August 10, 2019 14:26

all feedbacks are addressed, neeto merge for zephyr 2.0

@vonhust
Copy link
Author

vonhust commented Aug 10, 2019

better to merge after PR #18079 and #18142

@vonhust please resolve the conflicts, after merging the above PRs.
Note that the review needs to conclude today, if this is to get to 2.0 release.

confilct fixed, ok to merge

There is still a request-for-changes by @dbkinder.
@vonhust can this PR go into 2.0.0 regardless of what happens with #17767?

There is no relation between this PR and #17767. I just dismissed dbkinder's request as i addressed his feedbacks. Let's go for merge

@ioannisg
Copy link
Member

better to merge after PR #18079 and #18142

@vonhust please resolve the conflicts, after merging the above PRs.
Note that the review needs to conclude today, if this is to get to 2.0 release.

confilct fixed, ok to merge

There is still a request-for-changes by @dbkinder.
@vonhust can this PR go into 2.0.0 regardless of what happens with #17767?

There is no relation between this PR and #17767. I just dismissed dbkinder's request as i addressed his feedbacks. Let's go for merge

Yes. @dbkinder if there are still imperfections in documentation, we can definitely address them during the stabilization period.

@ioannisg ioannisg merged commit 5a0acd5 into zephyrproject-rtos:master Aug 10, 2019
@vonhust vonhust deleted the arc_normal_mode branch August 11, 2019 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants