Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions Documentation/devicetree/bindings/tee/riscv,rpmi-mpxy-tee.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
%YAML 1.2
---
$id: http://devicetree.org/schemas/tee/riscv,rpmi-mpxy-tee.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: RISC-V RPMI TEE service group based message proxy

maintainers:
- Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>

description: |
The RISC-V Platform Management Interface (RPMI) [1] defines a messaging
protocol which is modular and extensible. The supervisor software can
send/receive RPMI messages via the SBI MPXY extension [2] or some dedicated
supervisor-mode RPMI transport.

The RPMI specification [1] defines a TEE service group which is the RISC-V
analog of Arm FF-A: OP-TEE and the rich execution environment (REE, i.e.
Linux) are peer endpoints and the RPMI framework (machine mode firmware)
mediates every message. Entering OP-TEE on a hart runs it on that hart until
it responds, so the SBI implementation provides one SBI MPXY channel per
hart; all of them are listed, in hart order, on a single node.

===========================================
References
===========================================

[1] RISC-V Platform Management Interface (RPMI) v1.0 (or higher)
https://github.com/riscv-non-isa/riscv-rpmi/releases

[2] RISC-V Supervisor Binary Interface (SBI) v3.0 (or higher)
https://github.com/riscv-non-isa/riscv-sbi-doc/releases

properties:
compatible:
const: riscv,rpmi-mpxy-tee

mboxes:
minItems: 1
description:
One SBI MPXY channel implementing the RPMI TEE service group per hart,
listed in the same order as the CPU nodes.

interrupts:
maxItems: 1
description:
Availability doorbell raised by OP-TEE to signal asynchronous
notifications over the RPMI TEE signal bus. Optional; when absent
asynchronous notification is disabled.

required:
- compatible
- mboxes

additionalProperties: false

examples:
- |
tee {
compatible = "riscv,rpmi-mpxy-tee";
mboxes = <&mpxy_mbox 0x10 0x0>, <&mpxy_mbox 0x11 0x0>;
};
...
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -20420,6 +20420,7 @@ M: Jens Wiklander <jenswi@kernel.org>
L: op-tee@lists.trustedfirmware.org (moderated for non-subscribers)
S: Maintained
F: Documentation/ABI/testing/sysfs-bus-optee-devices
F: Documentation/devicetree/bindings/tee/riscv,rpmi-mpxy-tee.yaml
F: drivers/tee/optee/

OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
Expand Down
1 change: 1 addition & 0 deletions drivers/tee/optee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ optee-objs += supp.o
optee-objs += device.o
optee-objs += smc_abi.o
optee-objs += ffa_abi.o
optee-$(CONFIG_RISCV_SBI_MPXY_MBOX) += optee_riscv.o

# for tracing framework to find optee_trace.h
CFLAGS_smc_abi.o := -I$(src)
8 changes: 6 additions & 2 deletions drivers/tee/optee/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ void optee_remove_common(struct optee *optee)

static int smc_abi_rc;
static int ffa_abi_rc;
static int riscv_abi_rc;
static bool intf_is_regged;

static int __init optee_core_init(void)
Expand All @@ -245,9 +246,10 @@ static int __init optee_core_init(void)

smc_abi_rc = optee_smc_abi_register();
ffa_abi_rc = optee_ffa_abi_register();
riscv_abi_rc = optee_riscv_abi_register();

/* If both failed there's no point with this module */
if (smc_abi_rc && ffa_abi_rc) {
/* If all failed there's no point with this module */
if (smc_abi_rc && ffa_abi_rc && riscv_abi_rc) {
if (IS_REACHABLE(CONFIG_RPMB)) {
rpmb_interface_unregister(&rpmb_class_intf);
intf_is_regged = false;
Expand All @@ -270,6 +272,8 @@ static void __exit optee_core_exit(void)
optee_smc_abi_unregister();
if (!ffa_abi_rc)
optee_ffa_abi_unregister();
if (!riscv_abi_rc)
optee_riscv_abi_unregister();
}
module_exit(optee_core_exit);

Expand Down
47 changes: 47 additions & 0 deletions drivers/tee/optee/optee_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,44 @@ struct optee_ffa {
struct work_struct notif_work;
};

/**
* struct optee_riscv - RPMI TEE communication struct
* @chan: per-hart RPMI TEE service group mailbox channels
* @client: RPMI mailbox client used to request @chan
* @dev: device backing the RPMI TEE mailbox client
* @nr_chan: number of entries in @chan
* @max_msg_data_size: maximum RPMI message data size of the TEE channel
* @next_nonce: monotonic nonce source for memory parcel creation
* @mutex: serializes access to @global_ids
* @global_ids: memory parcel id to tee_shm translation table
* @notif_wq: workqueue for signal-bus asynchronous notification
* @notif_work: work for signal-bus asynchronous notification
* @signal_irq: availability doorbell IRQ, or 0 if async notif unused
* @sender_signals: number of signals OP-TEE may raise to the REE
* @bottom_half_value: signal value that requests an RPC bottom half, or
* U32_MAX if async notif is unused
*
* This is the RISC-V analog of struct optee_ffa: communication with secure
* world OP-TEE OS rides the RPMI TEE service group (RPMI spec section 4.16)
* over the SBI MPXY mailbox instead of Arm FF-A.
*/
struct optee_riscv {
struct mbox_chan **chan;
struct mbox_client *client;
struct device *dev;
unsigned int nr_chan;
u32 max_msg_data_size;
atomic_t next_nonce;
/* Serializes access to @global_ids */
struct mutex mutex;
struct rhashtable global_ids;
struct workqueue_struct *notif_wq;
struct work_struct notif_work;
unsigned int signal_irq;
u32 sender_signals;
u32 bottom_half_value;
};

struct optee;

/**
Expand Down Expand Up @@ -231,6 +269,7 @@ struct optee_ops {
* @ctx: driver internal TEE context
* @smc: specific to SMC ABI
* @ffa: specific to FF-A ABI
* @riscv: specific to RPMI TEE ABI
* @shm_arg_cache: shared memory cache argument
* @call_queue: queue of threads waiting to call @invoke_fn
* @notif: notification synchronization struct
Expand Down Expand Up @@ -259,6 +298,7 @@ struct optee {
union {
struct optee_smc smc;
struct optee_ffa ffa;
struct optee_riscv riscv;
};
struct optee_shm_arg_cache shm_arg_cache;
struct optee_call_queue call_queue;
Expand Down Expand Up @@ -426,5 +466,12 @@ int optee_smc_abi_register(void);
void optee_smc_abi_unregister(void);
int optee_ffa_abi_register(void);
void optee_ffa_abi_unregister(void);
#ifdef CONFIG_RISCV_SBI_MPXY_MBOX
int optee_riscv_abi_register(void);
void optee_riscv_abi_unregister(void);
#else
static inline int optee_riscv_abi_register(void) { return -EOPNOTSUPP; }
static inline void optee_riscv_abi_unregister(void) { }
#endif

#endif /*OPTEE_PRIVATE_H*/
Loading
Loading