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

[RFC] add support for secure partition (SPM-like) #3973

Merged
merged 3 commits into from
Sep 7, 2020

Conversation

apalos
Copy link
Contributor

@apalos apalos commented Jul 15, 2020

Secure variable storage for EFI variables is critical for enabling and
protecting UEFI Secure Boot. Unfortunately due to the fact that SPD and
SPM are mutually exclusive, we can't run StMM from EDK2 and OP-TEE.
An advantage of doing so is that different firmware implementations
can leverage EDK2's StandAloneMM and in cooperation with OP-TEE RPMB
APIs can store UEFI variables in a secure storage.
This makes the variable storage quite generic in any device with an RPMB
partition.

Using a well debugged application is preferable over rewriting the whole
application as a TA. Another advantage is that this inherits the Fault
Tolerant Writes (FTW) functionality built-in on StMM to protect
variables against corruptions during writing. Considering the FFA
changes of the future Arm architectures using an SP that includes
everything seems like a better choice at the moment.
The 'SPM emulation' currently added into OP-TEE only supports
a single SP to be launched. This means that the StMM embedded
application has the RPMB driver built in at the moment. In the future we
can add code (evolving FFA) to launch multiple SPs. So the StMM variable
handling can be decoupled from the RPMB driver, which will reside in a
different SP.

So let's add a user mode secure partition context and support loading
"Standalone MM" of EDK2 into it. A separate syscall handling is added to
serve as different kind of ABI and syscall IDs. The secure partition has
a TA like interface towards normal world, but requests are routed into
the StMM partition instead.

CFG_STMM_PATH is assigned the path of BL32_AP_MM.fd, for instance:
CFG_STMM_PATH=...Build/QemuVirtMmStandalone/DEBUG_GCC5/FV/BL32_AP_MM.fd

Since this is quite tricky to compile and test you can use this [1].
Just clone the repo and run ./build.sh. The script will pick up edk2,
edk2-platforms, op-tee, atf and U-boot and compile all the necessary
binaries for QEMU. A patch (awful hack) has been added to U-boot to
allow RPMB emulation through it's supplicant, since QEMU RPMB emulation
is not yet available.
After compiling and launching QEMU the usual U-boot commands for EFI
variable management will store the variables on an RPMB device.

[1] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Changes Since RFC:

  • Addressed @jenswi-linaro comments
  • Moved I/EMSG to DMSG
  • Removed pointless register restoring
  • Restoring x0-x7 in return_helper() (needed for FFA)
  • cherry picked FFA changes, so those are not included in the current patchset
  • Using mobj_inc_map() to map memory instead of the custom function
  • Added sp_svc_get_mem_attr() to get a page attributes properly (instead of assuming RWX we did in the RFC).
    Also added vm_get_attrs() helper function.
  • Removed the weird masking flags used in sp_svc_set_mem_attr(). This was a result of using hardcoded (RWX flags for reading the current pages attributes)
  • Moved comment to /* .... */ format
  • Used return_helper() when appropriate, instead of manually defining the error flags
  • Masked x3-x7, with 0xffffffff when used for FFA

Changes since v1:

  • renamed vm_get_attrs() -> vm_get_prot() and masked the output. This was also placed on a separate commit.
  • Don't mask x3-x7 with 0xffffffff as it's not needed
  • Initialized all stack variables
  • removed stale thread_[g|s]et_cntkctl_el1 functions
  • Fixed a bug on unti16_t shifting
  • Added a shippable build target
  • removed reduntant checks before reading/writing a file

core/arch/arm/include/ffa.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/thread_a64.S Outdated Show resolved Hide resolved
core/arch/arm/kernel/thread_private.h Outdated Show resolved Hide resolved
core/arch/arm/mm/tee_mmu.c Outdated Show resolved Hide resolved
@jenswi-linaro
Copy link
Contributor

jenswi-linaro commented Jul 21, 2020

We should probably have Shippable target for StMM in .shippable.yml to make sure that the code always compiles.
It should be OK to piggyback on the first PLATFORM=vexpress-qemu_armv8a target.

@apalos
Copy link
Contributor Author

apalos commented Jul 21, 2020

We should probably have Shippable target for StMM in .shippable.yml to make sure that the code always compiles.
It should be OK to piggyback on the first PLATFORM=vexpress-qemu_armv8a target.

Sure. What about the included binary? As you know the EDK2 code is not merged yet, so any suggestions for CFG_STMM_PATH? Touch a dummy file and use that?

@jenswi-linaro
Copy link
Contributor

Yeah, creating a dummy file on the fly should be OK. You could try to make that file the typical size of the StMM binary so we catch eventual overflows in the binary.

@apalos apalos force-pushed the stmm_pr branch 2 times, most recently from a378585 to 5056a23 Compare July 21, 2020 20:31
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/include/pta_stmm.h Outdated Show resolved Hide resolved
core/arch/arm/include/pta_stmm.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/include/mm/tee_mmu.h Outdated Show resolved Hide resolved
.shippable.yml Outdated Show resolved Hide resolved
core/arch/arm/mm/tee_mmu.c Outdated Show resolved Hide resolved
core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
@jenswi-linaro
Copy link
Contributor

Please fix the shippable error.

@jenswi-linaro
Copy link
Contributor

Feel free to squash and fixup the commits. Should hopefully take care the travis errors, except the ones about extern which we'll have to accept.

@jenswi-linaro
Copy link
Contributor

Reviewed-by: Jens Wiklander <[email protected]>
Please rebase while applying the tag.

@jenswi-linaro
Copy link
Contributor

Looks good, please squash and rebase.

core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/include/kernel/secure_partition.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
@jenswi-linaro
Copy link
Contributor

Looks good

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

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

Acked-by: Etienne Carriere <[email protected]> with the 2 "coding style to address:" comments addressed. Other comments are free to consider or not...

core/include/kernel/user_mode_ctx.h Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Show resolved Hide resolved
core/arch/arm/kernel/secure_partition.c Outdated Show resolved Hide resolved
@jenswi-linaro
Copy link
Contributor

For commit "shippable: build secure partition code":
Acked-by: Jens Wiklander <[email protected]>

If all comments are addressed perhaps you can fix up the commits and we should be good to merge.

.shippable.yml Outdated Show resolved Hide resolved
@jforissier
Copy link
Contributor

For "shippable: build secure partition code":

Acked-by: Jerome Forissier <[email protected]>

@apalos
Copy link
Contributor Author

apalos commented Sep 7, 2020

@jforissier anything missing to merge this?

@jforissier
Copy link
Contributor

@apalos yes, the Acked-by tags, please.

@apalos
Copy link
Contributor Author

apalos commented Sep 7, 2020

@apalos yes, the Acked-by tags, please.

@jforissier fixed!

@jforissier
Copy link
Contributor

Etienne's ack is missing on the first and last commits, I think they are applicable (the commits existed when he posted them, and the commits did not evolve substentialy afterwards).

@apalos
Copy link
Contributor Author

apalos commented Sep 7, 2020

Etienne's ack is missing on the first and last commits, I think they are applicable (the commits existed when he posted them, and the commits did not evolve substentialy afterwards).

He only commented on commit patch no. 2, I can add his acked-by tag on the rest if that was what he meant

@jforissier
Copy link
Contributor

When someone gives an ack without citing specific commits, it means all of them.

apalos and others added 3 commits September 7, 2020 10:03
A following commit, related to the StMM functionality needs to read
the current page attributes before modifying them.
So let's add a function to retrieve the current attributes.

Signed-off-by: Ilias Apalodimas <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Secure variable storage for EFI variables is critical for enabling and
protecting UEFI Secure Boot. Unfortunately due to the fact that SPD and
SPM are mutually exclusive, we can't run StMM from EDK2 and OP-TEE.
An advantage of doing so is that different firmware implementations
can leverage EDK2's StandAloneMM and in cooperation with OP-TEE RPMB
APIs can store UEFI variables in a secure storage.
This makes the variable storage quite generic in any device with an RPMB
partition.

Using a well debugged application is preferable over rewriting the whole
application as a TA. Another advantage is that this inherits the Fault
Tolerant Writes (FTW) functionality built-in on StMM to protect
variables against corruptions during writing. Considering the FFA
changes of the future Arm architectures using an SP that includes
everything seems like a better choice at the moment.
The 'SPM emulation' currently added into OP-TEE only supports
a single SP to be launched. This means that the StMM embedded
application has the RPMB driver built in at the moment. In the future we
can add code (evolving FFA) to launch multiple SPs. So the StMM variable
handling can be decoupled from the RPMB driver, which will reside in a
different SP.

So let's add a user mode secure partition context and support loading
"Standalone MM" of EDK2 into it. A separate syscall handling is added to
serve as different kind of ABI and syscall IDs. The secure partition has
a TA like interface towards normal world, but requests are routed into
the StMM partition instead.

CFG_STMM_PATH is assigned the path of BL32_AP_MM.fd, for instance:
CFG_STMM_PATH=...Build/QemuVirtMmStandalone/DEBUG_GCC5/FV/BL32_AP_MM.fd

Since this is quite tricky to compile and test you can use this [1].
Just clone the repo and run ./build.sh. The script will pick up edk2,
edk2-platforms, op-tee, atf and U-boot and compile all the necessary
binaries for QEMU. A patch (awful hack) has been added to U-boot to
allow RPMB emulation through it's supplicant, since QEMU RPMB emulation
is not yet available.
After compiling and launching QEMU the usual U-boot commands for EFI
variable management will store the variables on an RPMB device.

[1] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Signed-off-by: Jens Wiklander <[email protected]>
Co-developed-by: Ilias Apalodimas <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
Co-developed-by: Pipat Methavanitpong <[email protected]>
Signed-off-by: Pipat Methavanitpong <[email protected]>
Co-developed-by: Miklos Balint <[email protected]>
Signed-off-by: Miklos Balint <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
A previous commit adds support for secure partition loading, acting
similarly to SPM in order to launch StandAloneMM.
Let's add this to shippable and make sure the new code at least compiles
properly.

Signed-off-by: Ilias Apalodimas <[email protected]>
Acked-by: Jerome Forissier <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
@apalos
Copy link
Contributor Author

apalos commented Sep 7, 2020

No problem, added the missing ACKs

@jforissier
Copy link
Contributor

Thanks @apalos.

@jforissier jforissier merged commit 493c208 into OP-TEE:master Sep 7, 2020
etienne-lms pushed a commit to etienne-lms/edk2-platforms that referenced this pull request Nov 12, 2020
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Signed-off-by: Ilias Apalodimas <[email protected]>
etienne-lms pushed a commit to etienne-lms/edk2-platforms that referenced this pull request Dec 12, 2020
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Signed-off-by: Ilias Apalodimas <[email protected]>
sughoshg pushed a commit to sughoshg/edk2-platforms that referenced this pull request Dec 14, 2020
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Signed-off-by: Ilias Apalodimas <[email protected]>
etienne-lms pushed a commit to etienne-lms/edk2-platforms that referenced this pull request Feb 15, 2021
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Reviewed-by: Sami Mujawar <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
etienne-lms pushed a commit to etienne-lms/edk2-platforms that referenced this pull request Feb 15, 2021
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Reviewed-by: Sami Mujawar <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
etienne-lms pushed a commit to etienne-lms/edk2-platforms that referenced this pull request Mar 8, 2021
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Reviewed-by: Sami Mujawar <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
samimujawar pushed a commit to tianocore/edk2-platforms that referenced this pull request Mar 28, 2021
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Reviewed-by: Sami Mujawar <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
litchipi pushed a commit to litchipi/edk2-platforms that referenced this pull request Apr 12, 2021
With some recent changes in OP-TEE [1] and U-Boot [2] we can compile StMM
and launch it from an OP-TEE secure partition which is mimicking SPM.

There's a number of advantages in this approach. In Arm world SPM,
currently used for dispatching StMM, and SPD used for OP-TEE, are
mutually exclusive. Since there's no application in OP-TEE for managing
EFI variables, this means that one can have a secure OS or secure
variable storage.

By re-using StMM we have EDK2s approved application controlling
variable storage and the ability to run a secure world OS. This also
allows various firmware implementations to adopt EDK2 way of storing
variables (including the FTW implementation), as long as OP-TEE is
available on that given platform (or any other secure OS that can launch
StMM and has a supplicant for handling the RPMB partition).
Another advantage is that OP-TEE has the ability to access an eMMC RPMB
partition to store those variables. This requires a normal world
supplicant, which is implemented in U-Boot currently. The supplicant
picks up the encrypted buffer from OP-TEE and wires it to the eMMC
driver(s). Similar functionality can be added in EDK2 by porting the
supplicant and adapt it to using the native eMMC drivers.

There's is one drawback in using OP-TEE. The current SPM calls need to run
to completion. This contradicts the current OP-TEE RPC call requirements,
used to access the RPMB storage. Thats leads to two different SMC calls for
entering secure world to access StMM.

So let's add support for a platform that compiles StMM and an RPMB
driver that communicates with OP-TEE to read/write the variables.
For anyone interested in testing this there's repo that builds all the
sources and works on QEMU [3].

[1] OP-TEE/optee_os#3973
[2] http://u-boot.10912.n7.nabble.com/PATCH-0-7-v4-EFI-variable-support-via-OP-TEE-td412499.html
[3] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/

Reviewed-by: Sami Mujawar <[email protected]>
Signed-off-by: Ilias Apalodimas <[email protected]>
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