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

Secure dmabuf support #101

Open
wants to merge 18 commits into
base: optee
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c4773cd
arm64: dt: Remove timer from mt8173 **not for mainline**
jbech-linaro Apr 1, 2016
45f9fc0
arm64: dt: OP-TEE for foundation-v8 **not for mainline**
jenswi-linaro Aug 17, 2016
eb0ec8c
arm64: dt: OP-TEE for Juno **not for mainline**
jenswi-linaro Mar 29, 2016
eac59af
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for foun…
jenswi-linaro Dec 2, 2016
148262a
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for juno…
jenswi-linaro Jan 3, 2017
56253d9
arm64: dt: Add OP-TEE firmware to mt8173 **not for mainline**
jbech-linaro Mar 24, 2016
11248bc
arm64: dts: hi3798cv200-poplar: memreserve for bootloader
igoropaniuk May 11, 2020
b212910
arm64: dts: hi3798cv200-poplar: add optee node
igoropaniuk May 11, 2020
1eb611e
ARM: dts: stm32: Define OP-TEE resources on stm32mp15 and enable on DK2
etienne-lms May 27, 2020
29258f7
Enable Microsoft fTPM driver on Arm Foundation v8 models.
javieralso-arm Feb 2, 2021
17edde0
stm32mp157c-ev1.dts: Fix optee status to 'okay'
Mar 2, 2021
688e135
arm: dts: define OP-TEE resources for STM32MP1 ED1 and EV1
etienne-lms Apr 27, 2021
7927f02
ANDROID: dma-buf: heaps: Add deferred-free-helper library code
johnstultz-work Dec 9, 2020
5f8d693
ANDROID: dma-buf: heaps: Add a shrinker controlled page pool
johnstultz-work Oct 2, 2020
b7a3d9f
dma-buf: heaps: add Linaro secure dmabuf heap support
omasse-linaro May 31, 2022
96e394d
dt-bindings: reserved-memory: add linaro,secure-heap
omasse-linaro May 25, 2022
112e3e1
plat-hikey: Add linaro,secure-heap compatible
omasse-linaro May 3, 2022
00093f6
tee: new ioctl to a register tee_shm from a dmabuf file descriptor
etienne-lms Oct 27, 2016
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/reserved-memory/linaro,secure-heap.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Linaro Secure DMABUF Heap

maintainers:
- Olivier Masse <[email protected]>

description:
Linaro OP-TEE firmware needs a reserved memory for the
Secure Data Path feature (aka SDP).
The purpose is to provide a secure memory heap which allow
non-secure OS to allocate/free secure buffers.
The TEE is reponsible for protecting the SDP memory buffers.
TEE Trusted Application can access secure memory references
provided as parameters (DMABUF file descriptor).

allOf:
- $ref: "reserved-memory.yaml"

properties:
compatible:
const: linaro,secure-heap

reg:
description:
Region of memory reserved for OP-TEE SDP feature

no-map:
$ref: /schemas/types.yaml#/definitions/flag
description:
Avoid creating a virtual mapping of the region as part of the OS'
standard mapping of system memory.

unevaluatedProperties: false

required:
- compatible
- reg
- no-map

examples:
- |
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;

sdp@3e800000 {
compatible = "linaro,secure-heap";
no-map;
reg = <0 0x3E800000 0 0x00400000>;
};
};
8 changes: 8 additions & 0 deletions arch/arm/boot/dts/stm32mp151.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
method = "smc";
};

firmware {
optee: optee {
compatible = "linaro,optee-tz";
method = "smc";
status = "disabled";
};
};

intc: interrupt-controller@a0021000 {
compatible = "arm,cortex-a7-gic";
#interrupt-cells = <3>;
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/boot/dts/stm32mp157c-dk2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
model = "STMicroelectronics STM32MP157C-DK2 Discovery Board";
compatible = "st,stm32mp157c-dk2", "st,stm32mp157";

reserved-memory {
optee_memory: optee@0xde000000 {
reg = <0xde000000 0x02000000>;
no-map;
};
};

aliases {
ethernet0 = &ethernet0;
serial0 = &uart4;
Expand Down Expand Up @@ -99,3 +106,7 @@
pinctrl-2 = <&usart2_idle_pins_c>;
status = "disabled";
};

&optee {
status = "okay";
};
9 changes: 9 additions & 0 deletions arch/arm/boot/dts/stm32mp157c-ed1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
reg = <0xe8000000 0x8000000>;
no-map;
};

optee_memory: optee@fe000000 {
reg = <0xfe000000 0x2000000>;
no-map;
};
};

aliases {
Expand Down Expand Up @@ -320,6 +325,10 @@
status = "okay";
};

&optee {
status = "okay";
};

&pwr_regulators {
vdd-supply = <&vdd>;
vdd_3v3_usbfs-supply = <&vdd_usb>;
Expand Down
32 changes: 23 additions & 9 deletions arch/arm64/boot/dts/arm/foundation-v8.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@

aliases {
serial0 = &v2m_serial0;
serial1 = &v2m_serial1;
serial2 = &v2m_serial2;
serial3 = &v2m_serial3;
};

ftpm {
compatible = "microsoft,ftpm";
};

cpus {
#address-cells = <2>;
#size-cells = <0>;
Expand Down Expand Up @@ -67,6 +70,17 @@
<0x00000008 0x80000000 0 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

optee@0x83000000 {
reg = <0x00000000 0x83000000 0 0x01000000>;
no-map;
};
};

timer {
compatible = "arm,armv8-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
Expand Down Expand Up @@ -196,14 +210,6 @@
clock-names = "uartclk", "apb_pclk";
};

v2m_serial1: serial@a0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0a0000 0x1000>;
interrupts = <6>;
clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
clock-names = "uartclk", "apb_pclk";
};

v2m_serial2: serial@b0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0b0000 0x1000>;
Expand All @@ -227,4 +233,12 @@
};
};
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};

};
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/arm/juno-base.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,18 @@
<0x00000008 0x80000000 0x1 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

/* Shared memory between secure and non-secure world */
optee@0xfee00000 {
reg = <0x00000000 0xfee00000 0 0x00200000>;
no-map;
};
};

bus@8000000 {
#interrupt-cells = <1>;
interrupt-map-mask = <0 0 15>;
Expand Down Expand Up @@ -827,4 +839,11 @@
interrupt-map-mask = <0 0>;
interrupt-map = <0 0 &gic 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/dts-v1/;
/memreserve/ 0x00000000 0x04080000;

#include <dt-bindings/gpio/gpio.h>
#include "hi3798cv200.dtsi"
Expand Down Expand Up @@ -70,6 +71,13 @@
gpio = <&gpio6 7 0>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&ehci {
Expand Down
11 changes: 11 additions & 0 deletions arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@
};
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;

sdp@3e800000 {
compatible = "linaro,secure-heap";
no-map;
reg = <0 0x3E800000 0 0x00400000>;
};
};

sound_card {
compatible = "audio-graph-card";
dais = <&i2s0_port0>;
Expand Down
7 changes: 7 additions & 0 deletions arch/arm64/boot/dts/mediatek/mt8173-evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
gpio = <&pio 9 GPIO_ACTIVE_HIGH>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&mfg_async {
Expand Down
9 changes: 0 additions & 9 deletions arch/arm64/boot/dts/mediatek/mt8173.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,6 @@
reg = <0 0x10007000 0 0x100>;
};

timer: timer@10008000 {
compatible = "mediatek,mt8173-timer",
"mediatek,mt6577-timer";
reg = <0 0x10008000 0 0x1000>;
interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg CLK_INFRA_CLK_13M>,
<&topckgen CLK_TOP_RTC_SEL>;
};

pwrap: pwrap@1000d000 {
compatible = "mediatek,mt8173-pwrap";
reg = <0 0x1000d000 0 0x1000>;
Expand Down
4 changes: 4 additions & 0 deletions arch/arm64/configs/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,10 @@ CONFIG_CRYPTO_DEV_HISI_SEC2=m
CONFIG_CRYPTO_DEV_HISI_ZIP=m
CONFIG_CRYPTO_DEV_HISI_HPRE=m
CONFIG_CRYPTO_DEV_HISI_TRNG=m
CONFIG_DMABUF_HEAPS=y
CONFIG_DMABUF_HEAPS_DEFERRED_FREE=y
CONFIG_DMABUF_HEAPS_PAGE_POOL=y
CONFIG_DMABUF_HEAPS_SECURE=y
CONFIG_CMA_SIZE_MBYTES=32
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_INFO=y
Expand Down
19 changes: 19 additions & 0 deletions drivers/dma-buf/heaps/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
menuconfig DMABUF_HEAPS_DEFERRED_FREE
bool "DMA-BUF heaps deferred-free library"
help
Choose this option to enable the DMA-BUF heaps deferred-free library.

menuconfig DMABUF_HEAPS_PAGE_POOL
bool "DMA-BUF heaps page-pool library"
help
Choose this option to enable the DMA-BUF heaps page-pool library.

config DMABUF_HEAPS_SYSTEM
bool "DMA-BUF System Heap"
depends on DMABUF_HEAPS
Expand All @@ -12,3 +22,12 @@ config DMABUF_HEAPS_CMA
Choose this option to enable dma-buf CMA heap. This heap is backed
by the Contiguous Memory Allocator (CMA). If your system has these
regions, you should say Y here.

config DMABUF_HEAPS_SECURE
tristate "DMA-BUF Secure Heap"
depends on DMABUF_HEAPS && DMABUF_HEAPS_DEFERRED_FREE
help
Choose this option to enable the secure dmabuf heap. The secure heap
pools are defined according to the DT. Heaps are allocated
in the pools using gen allocater.
If in doubt, say Y.
3 changes: 3 additions & 0 deletions drivers/dma-buf/heaps/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_DMABUF_HEAPS_DEFERRED_FREE) += deferred-free-helper.o
obj-$(CONFIG_DMABUF_HEAPS_PAGE_POOL) += page_pool.o
obj-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o
obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o
obj-$(CONFIG_DMABUF_HEAPS_SECURE) += secure_heap.o
Loading