Skip to contentSkip to conversation

xen/arm: add a primitive FF-A mediator

PATCH Michal Orzel 2 participants 2 messages Aug 24, 2022 – Aug 31, 2022

lore
Share & tools
lore
#0 lore raw

Hi Jens,

Quoted 57 lines · Jens Wiklander

Adds a FF-A version 1.1 [1] mediator to communicate with a Secure Partition in secure world.

This commit brings in only the parts needed to negotiate FF-A version number with guest and SPMC.

A guest configuration variable "ffa_enabled" is used to indicate if a guest is trusted to use FF-A.

This is loosely based on the TEE mediator framework and the OP-TEE mediator.

[1] https://developer.arm.com/documentation/den0077/latest

---
 SUPPORT.md                        |   7 +
 docs/man/xl.cfg.5.pod.in          |  15 ++
 tools/include/libxl.h             |   6 +
 tools/libs/light/libxl_arm.c      |   3 +
 tools/libs/light/libxl_types.idl  |   1 +
 tools/xl/xl_parse.c               |   3 +
 xen/arch/arm/Kconfig              |  11 +
 xen/arch/arm/Makefile             |   1 +
 xen/arch/arm/domain.c             |  10 +
 xen/arch/arm/domain_build.c       |   1 +
 xen/arch/arm/ffa.c                | 354 ++++++++++++++++++++++++++++++
 xen/arch/arm/include/asm/domain.h |   4 +
 xen/arch/arm/include/asm/ffa.h    |  71 ++++++
 xen/arch/arm/vsmc.c               |  17 +-
 xen/include/public/arch-arm.h     |   2 +
 15 files changed, 503 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/arm/ffa.c
 create mode 100644 xen/arch/arm/include/asm/ffa.h
SUPPORT.md +7 -0
index 70e98964cbc0..215bb3c9043b 100644
@@ -785,6 +785,13 @@ that covers the DMA of the device to be passed through.
 
 No support for QEMU backends in a 16K or 64K domain.
 
+### ARM: Firmware Framework for Arm A-profile (FF-A) Mediator
+
+    Status, Arm64: Tech Preview
+
+There are still some code paths where a vCPU may hog a pCPU longer than
+necessary. The FF-A mediator is not yet implemented for Arm32.
+
 ### ARM: Guest Device Tree support
 
     Status: Supported
docs/man/xl.cfg.5.pod.in +0 -0
index b98d1613987e..234c036aecb1 100644

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1619

Quoted 4 lines
docs/man/xl.cfg.5.pod.in +1 -0
@@ -1616,6 +1616,21 @@ This feature is a B<technology preview>.
 
 =back
 
+=item B<ffa_enabled=BOOLEAN>

Looking at other config options, we usually have <feature>=BOOLEAN (without _enabled), so I would just stick to "ffa". This would require changes in other places accordingly.

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1624

Quoted 5 lines
docs/man/xl.cfg.5.pod.in +5 -0
+
+B<Arm only.> Allow a guest to communicate via FF-A with Secure Partitions
+(SP), default false.
+
+Currently is only a small subset of the FF-A specification supported. Just

Should be:
"Currently only a small subset of the FF-A specification is supported"

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1625

Quoted 1 line
docs/man/xl.cfg.5.pod.in +1 -0
+enough to communicate with OP-TEE. In general all the basic things and

"basic things" sounds a bit ambiguous.

tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[

Quoted 5 lines
tools/libs/light/libxl_types.idl +0 -0
index 2a42da2f7d78..bf4544bef399 100644
@@ -646,6 +646,7 @@ libxl_domain_build_info = Struct("domain_build_info",[

Applying this patch results in a failure here so you need to rebase it on top of latest status.

Also, FWICS (can be checked by the toolstack maintainers) you are missing the required changes in:
- tools/golang/xenlight/helpers.gen.go
- tools/golang/xenlight/types.gen.go
- tools/ocaml/libs/xc/xenctrl.ml
- tools/ocaml/libs/xc/xenctrl.mli

~Michal

#1 lore raw

Hi Michal,

Quoted 62 lines · Michal Orzel

Hi Jens,

Quoted 58 lines · Jens Wiklander

Adds a FF-A version 1.1 [1] mediator to communicate with a Secure Partition in secure world.

This commit brings in only the parts needed to negotiate FF-A version number with guest and SPMC.

A guest configuration variable "ffa_enabled" is used to indicate if a guest is trusted to use FF-A.

This is loosely based on the TEE mediator framework and the OP-TEE mediator.

[1] https://developer.arm.com/documentation/den0077/latest

---
 SUPPORT.md                        |   7 +
 docs/man/xl.cfg.5.pod.in          |  15 ++
 tools/include/libxl.h             |   6 +
 tools/libs/light/libxl_arm.c      |   3 +
 tools/libs/light/libxl_types.idl  |   1 +
 tools/xl/xl_parse.c               |   3 +
 xen/arch/arm/Kconfig              |  11 +
 xen/arch/arm/Makefile             |   1 +
 xen/arch/arm/domain.c             |  10 +
 xen/arch/arm/domain_build.c       |   1 +
 xen/arch/arm/ffa.c                | 354 ++++++++++++++++++++++++++++++
 xen/arch/arm/include/asm/domain.h |   4 +
 xen/arch/arm/include/asm/ffa.h    |  71 ++++++
 xen/arch/arm/vsmc.c               |  17 +-
 xen/include/public/arch-arm.h     |   2 +
 15 files changed, 503 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/arm/ffa.c
 create mode 100644 xen/arch/arm/include/asm/ffa.h
SUPPORT.md +7 -0
index 70e98964cbc0..215bb3c9043b 100644
@@ -785,6 +785,13 @@ that covers the DMA of the device to be passed through.
 
 No support for QEMU backends in a 16K or 64K domain.
 
+### ARM: Firmware Framework for Arm A-profile (FF-A) Mediator
+
+    Status, Arm64: Tech Preview
+
+There are still some code paths where a vCPU may hog a pCPU longer than
+necessary. The FF-A mediator is not yet implemented for Arm32.
+
 ### ARM: Guest Device Tree support
 
     Status: Supported
docs/man/xl.cfg.5.pod.in +0 -0
index b98d1613987e..234c036aecb1 100644
@@ -1616,6 +1616,21 @@ This feature is a B<technology preview>.
 
Quoted 5 lines

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1619

Quoted 3 lines
docs/man/xl.cfg.5.pod.in +1 -0
 =back
 
+=item B<ffa_enabled=BOOLEAN>

Looking at other config options, we usually have <feature>=BOOLEAN (without _enabled), so I would just stick to "ffa". This would require changes in other places accordingly.

OK, I'll update.

Quoted 11 lines

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1624

Quoted 6 lines
docs/man/xl.cfg.5.pod.in +5 -0
+
+B<Arm only.> Allow a guest to communicate via FF-A with Secure Partitions
+(SP), default false.
+
+Currently is only a small subset of the FF-A specification supported. Just

Should be:
"Currently only a small subset of the FF-A specification is supported"

docs/man/xl.cfg.5.pod.in This feature is a B<technology preview>. · line 1625

Quoted 1 line
docs/man/xl.cfg.5.pod.in +1 -0
+enough to communicate with OP-TEE. In general all the basic things and

"basic things" sounds a bit ambiguous.

I'll rephrase.

Quoted 7 lines

tools/libs/light/libxl_types.idl libxl_domain_build_info = Struct("domain_build_info",[

Quoted 6 lines
tools/libs/light/libxl_types.idl +0 -0
index 2a42da2f7d78..bf4544bef399 100644
@@ -646,6 +646,7 @@ libxl_domain_build_info = Struct("domain_build_info",[

Applying this patch results in a failure here so you need to rebase it on top of latest status.

OK, I'll rebase the next patchset.

Quoted 7 lines

Also, FWICS (can be checked by the toolstack maintainers) you are missing the required changes in:
- tools/golang/xenlight/helpers.gen.go
- tools/golang/xenlight/types.gen.go
- tools/ocaml/libs/xc/xenctrl.ml
- tools/ocaml/libs/xc/xenctrl.mli

I'll update.

Thanks for the review.

Cheers,
Jens