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

NS Interrupt notification over async notif #112

Draft
wants to merge 19 commits into
base: optee
Choose a base branch
from

Conversation

etienne-lms
Copy link

This P-R reflects a change currently under review in the LKML.

Patch v4 https://lore.kernel.org/lkml/20230317171003.974801-2-etienne.carriere@linaro.org/
applies to Linux kernel v6.2 to v6.3-rc3.

Patch v5 https://lore.kernel.org/lkml/20230506073235.2770292-2-etienne.carriere@linaro.org/
is the rebased version for Linux kernel v6.3-rc4 and later.

jbech-linaro and others added 19 commits January 11, 2023 12:41
From the commit below, the mt8173-evb failed to boot to console due to
changes in the mt8173 device tree files.

  commit c0d6fe2
  Merge: b44a3d2 3e4dda7
  Author: Linus Torvalds <torvalds@linux-foundation.org>
  Date:   Tue Nov 10 15:06:26 2015 -0800

      Merge tag 'armsoc-dt' of
      git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc

Until properly solved, let's just remove the section in the device tree
blob that causes this.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Configures foundation-v8 with OP-TEE.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
[jf: rebase onto v5.9-rc7]
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Configures Juno with OP-TEE.

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
[jf: rebase onto v5.9-rc7]
Signed-off-by: Jerome Forissier <jerome@forissier.org>
…dation-v8 **not for mainline**

All the platforms that reserve memory for OP-TEE statically via the
DT (i.e., not those that reserve it via UEFI or that patch the DT
dynamically thanks to OP-TEE's CFG_DT option) have to mark it 'no-map'
so that only the TEE driver may map it.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
… **not for mainline**

All the platforms that reserve memory for OP-TEE statically via the
DT (i.e., not those that reserve it via UEFI or that patch the DT
dynamically thanks to OP-TEE's CFG_DT option) have to mark it 'no-map'
so that only the TEE driver may map it.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reserve memory for bootloader purposes.

Acked-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>
Add optee node, so OP-TEE driver is probed properly.

Acked-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>
Define OP-TEE firmware node for stm32mp15 based platforms. The node
if disable by default.

Enable the OP-TEE node and define OP-TEE reserved memory for
stm32mp157c-dk2.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
[jf: rebase onto v5.9]
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Acked-by: Joakim Bech <joakim.bech@linaro.org>
Link: linaro-swg#85
[jf: not currently intended for upstream; add link to PR]
Signed-off-by: Jerome Forissier <jerome@forissier.org>
The optee device status is disabled by default, change its status to 'okay'
in the dts of the EV1 board

Signed-off-by: Timothée Cercueil <timothee.cercueil@st.com>
[jf: rebase onto v5.17]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
This change fixes EV1 configuration which lacked OP-TEE
reserved memory. This change also makes ED1 board ready
the host OP-TEE by enabling OP-TEE node and defining the
OP-TEE reserved memory for that board. This change defines
these resources in ED1 DTS file which is included in EV1 DTS
file.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jerome Forissier <jerome@forissier.org>
[jf: rebase onto v5.17]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Configures FVP Base RevC with OP-TEE.

With commit 1bf41f5d9b0d ("fvp: add Trusted Services support") in
https://github.com/OP-TEE/build there is support for building running
with the FVP Base RevC model. However, some updates to the DTB passed
to the kernel is missing for the OP-TEE driver to be probed. So fix that
by adding an OP-TEE node in the DTS.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Enable OP-TEE node defined in stm32mp151.dtsi and define OP-TEE
reserverd memory for all boards based on STM32MP15 DHCOM.

Signed-off-by: Johann Neuhauser <jneuhauser@dh-electronics.com>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Enable OP-TEE node defined in stm32mp151.dtsi and define OP-TEE
reserverd memory for all boards based on STM32MP15 DHCOR.

Signed-off-by: Johann Neuhauser <jneuhauser@dh-electronics.com>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
If a USB-A to USB-A cable is used to flash the RockPi4 eMMC as described
in [1], it is likely that the board will be booted with the cable still
plugged into the board and into the computer on the other side. Such a
configuration results in periodic error messages from the kernel:

 [    4.832697] usb usb6-port1: Cannot enable. Maybe the USB cable is bad?
 [    4.833416] usb usb6-port1: config error

That is annoying, especially since the messages are also sent to the
console by default, which could mess up with CI scripts. Therefore,
disable this port (it is the upper USB3 blue port; the lower one will
still work fine).

Link: [1] https://wiki.radxa.com/Rockpi4/dev/usb-install
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Joakim Bech <joakim.bech@linaro.org>
Add optee node as well as reserved memory to the Rockpi4 DT.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Adds an optional interrupt controller property to optee firmware node
in the DT bindings. Optee driver may embeds an irqchip exposing
OP-TEE interrupt events notified by the TEE world. Optee registers up
to 1 interrupt controller and identifies each line with a line
number from 0 to UINT16_MAX.

The identifiers and meaning of the interrupt line number are specific
to the platform and shall be found in the OP-TEE platform documentation.

In the example shown in optee DT binding documentation, the platform SCMI
device controlled by Linux scmi driver uses optee interrupt irq 5 as
signal to trigger processing of an asynchronous incoming SCMI message
in the scope of a CPU DVFS control. A platform can have several SCMI
channels driven this way. Optee irqs also permit small embedded devices
to share e.g. a gpio expander, a group of wakeup sources, etc... between
OP-TEE world (for sensitive services) and Linux world (for non-sensitive
services). The physical controller is driven from the TEE which exposes
some controls to Linux kernel.

This change was posted to the LKML (patch v4 [1]).

Link: [1] https://lore.kernel.org/lkml/20230317171003.974801-1-etienne.carriere@linaro.org/
Co-developed-by: Pascal Paillet <p.paillet@foss.st.com>
Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Implements an irqchip in optee driver for the interrupt events notified
from OP-TEE world to the Linux OS. Optee registers up to 1 interrupt
controller and identifies each line with a line number from 0 to
UINT16_MAX. The identifiers and meaning of the interrupt line number
are specific to the platform and shall be found in the OP-TEE platform
documentation

There already exist an optee asynchronous notification mechanism using
an irq for OP-TEE to signal its optee driver in Linux of a pending
interrupt event. The implementation binds each event to the awaking of
a thread waiting to call the TEE. The interrupt notification service
added by this change allows TEE to send interrupt signals to Linux kernel
on secure event occurrences which end consumer is a Linux sub-system.

When optee driver initializes, TEE tells whether it supports interrupt
notification services or not.

OP-TEE SMC ABI defines 4 new SMC function IDs for non-secure world to
manage interrupt events:
- OPTEE_SMC_GET_NOTIF_ITR allows non-secure world to retrieve pending
  interrupts by grapes up to 5 lines. For efficiency, the function also
  reports whether there are pending async values targeting suspended
  threaded sequences execution and whether TEE has background threaded
  work to do.
- OPTEE_SMC_NOTIF_ITR_SET_MASK allows Linux irq consumer to mask/unmask
  the irq line using a fastcall SMC (uninterruptible) service.
- OPTEE_SMC_NOTIF_ITR_SET_STATE allows Linux irq consumer to enable and
  disable the irq line using a yielded TEE call.
- OPTEE_SMC_NOTIF_ITR_SET_WAKEUP allows Linux irq consumer to enable
  and disable the wakeup from low power capability of the interrupt.

This change was posted to the LKML (patch v4 [1]). A patch v5 [2] exists
and is equivalent to this change but targets kernel v6.3-rc4 and later
to resolve rebase conflicts.

Link: [1] https://lore.kernel.org/lkml/20230317171003.974801-2-etienne.carriere@linaro.org/
Link: [2] https://lore.kernel.org/lkml/20230506073235.2770292-2-etienne.carriere@linaro.org/
Co-developed-by: Pascal Paillet <p.paillet@foss.st.com>
Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Co-developed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
@etienne-lms
Copy link
Author

Closing since rebasing on v6.6 does the jobs.

@etienne-lms etienne-lms closed this Nov 6, 2023
@etienne-lms etienne-lms reopened this Nov 6, 2023
@etienne-lms
Copy link
Author

Wrong manipulation.... I closed the wrong P-R :(Opening back, and putting in Draft state since this needs some rebasing and @jenswi-linaro challenged the API extension.

@etienne-lms etienne-lms marked this pull request as draft November 6, 2023 14:03
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.

7 participants