Skip to contentSkip to conversation

firmware: Add initial support for Arm FF-A

PATCH Superseded Sudeep Holla 4 participants 13 messages May 5, 2021 – May 20, 2021

Subsystems (3)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover firmware: Add initial support for Arm FF-A

Hi all,

This is very basic implementation for in-kernel support for Arm FF-A specification.

Arm Firmware Framework for Armv8-A specification[1] describes a software architecture that provides mechanism to utilise the virtualization extension to isolate software images and describes interfaces that standardize communication between the various software images. This includes communication between images in the Secure and Normal world.

The main idea here is to create FFA device to establish any communication with a secure partition. This is currently tested with OPTEE(with changes to OPTEE driver adding FFA as transport)

The series can be fetched from [2]

--
Regards,
Sudeep

[1] https://developer.arm.com/documentation/den0077/latest
[2] git://git.kerniel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git v5.13/ffa

v5->v6:
- Dropped DT dependecy completely and use the discovery APIs for adding FFA partitions on the bus. They is some workaround added as v1.0 doesn't provide UUID as part of the discovery APIs which is used to match the devices and driver on FFA bus.
- Extended SMCCC v1.2 API to support full set of input and output registers.
- Couple of minor bug fixes found as part of testing

v4->v5:
- Fixed couple of comments in DT bindings
- Moved to use native version of RXTX_MAP call, fixed vm_id param to RXTX_UNMAP, dropped couple of unused confusingly named macros (can be added back with correct name when we need to use them)

v3->v4:
- Added support to allow partitions to set 32bit only mode
- Addressed all the comments from Jens Wiklander

v2->v3:
- Dropped hypervisor partitions and userspace support as it is no longer in the list of requirements
- Moved away from ioctl style interface for in-kernel users as there is no need to keep in sync with userspace anymore
- Some kerneldoc fixes as pointed out in earlier reviews

v1->v2:
- Moved userspace code to a separate unit, will move to separate module. Still working on minimizing initcall dependencies and exported functions to reuse some of the code.
- Fixed couple of minor issues pointed out
- Dropped ASYNC send message as I haven't been able to test

Sudeep Holla (6):
arm64: smccc: Add support for SMCCCv1.2 extended input/output registers
firmware: arm_ffa: Add initial FFA bus support for device enumeration
firmware: arm_ffa: Add initial Arm FFA driver support
firmware: arm_ffa: Add support for SMCCC as transport to FFA driver
firmware: arm_ffa: Setup in-kernel users of FFA partitions
firmware: arm_ffa: Add support for MEM_* interfaces

 MAINTAINERS                       |   7 +
 arch/arm64/kernel/asm-offsets.c   |   9 +
 arch/arm64/kernel/smccc-call.S    |  57 +++
 drivers/firmware/Kconfig          |   1 +
 drivers/firmware/Makefile         |   1 +
 drivers/firmware/arm_ffa/Kconfig  |  21 +
 drivers/firmware/arm_ffa/Makefile |   6 +
 drivers/firmware/arm_ffa/bus.c    | 210 +++++++++
 drivers/firmware/arm_ffa/common.h |  31 ++
 drivers/firmware/arm_ffa/driver.c | 719 ++++++++++++++++++++++++++++++
 drivers/firmware/arm_ffa/smccc.c  |  39 ++
 include/linux/arm-smccc.h         |  55 +++
 include/linux/arm_ffa.h           | 266 +++++++++++
 13 files changed, 1422 insertions(+)
 create mode 100644 drivers/firmware/arm_ffa/Kconfig
 create mode 100644 drivers/firmware/arm_ffa/Makefile
 create mode 100644 drivers/firmware/arm_ffa/bus.c
 create mode 100644 drivers/firmware/arm_ffa/common.h
 create mode 100644 drivers/firmware/arm_ffa/driver.c
 create mode 100644 drivers/firmware/arm_ffa/smccc.c
 create mode 100644 include/linux/arm_ffa.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v6 1/6 arm64: smccc: Add support for SMCCCv1.2 extended input/output registers

SMCCC v1.2 allows x8-x17 to be used as parameter registers and x4—x17 to be used as result registers in SMC64/HVC64. Arm Firmware Framework for Armv8-A specification makes use of x0-x7 as parameter and result registers. There are other users like Hyper-V who intend to use beyond x0-x7 as well.

Current SMCCC interface in the kernel just use x0-x7 as parameter and x0-x3 as result registers as required by SMCCCv1.0. Let us add new interface to support this extended set of input/output registers namely x0-x17 as both parameter and result registers.

Cc Michael Kelley <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/kernel/asm-offsets.c |  9 ++++++
 arch/arm64/kernel/smccc-call.S  | 57 +++++++++++++++++++++++++++++++++
 include/linux/arm-smccc.h       | 55 +++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
arch/arm64/kernel/asm-offsets.c +9 -0
index 0cb34ccb6e73..74321bc9a459 100644
@@ -138,6 +138,15 @@ int main(void)
   DEFINE(ARM_SMCCC_RES_X2_OFFS,		offsetof(struct arm_smccc_res, a2));
   DEFINE(ARM_SMCCC_QUIRK_ID_OFFS,	offsetof(struct arm_smccc_quirk, id));
   DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS,	offsetof(struct arm_smccc_quirk, state));
+  DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS,	offsetof(struct arm_smccc_1_2_regs, a0));
+  DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS,	offsetof(struct arm_smccc_1_2_regs, a2));
+  DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS,	offsetof(struct arm_smccc_1_2_regs, a4));
+  DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS,	offsetof(struct arm_smccc_1_2_regs, a6));
+  DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS,	offsetof(struct arm_smccc_1_2_regs, a8));
+  DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS,	offsetof(struct arm_smccc_1_2_regs, a10));
+  DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS,	offsetof(struct arm_smccc_1_2_regs, a12));
+  DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS,	offsetof(struct arm_smccc_1_2_regs, a14));
+  DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS,	offsetof(struct arm_smccc_1_2_regs, a16));
   BLANK();
   DEFINE(HIBERN_PBE_ORIG,	offsetof(struct pbe, orig_address));
   DEFINE(HIBERN_PBE_ADDR,	offsetof(struct pbe, address));
arch/arm64/kernel/smccc-call.S +57 -0

60 lines not on this page · raw message

include/linux/arm-smccc.h +55 -0

61 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer Acked-by on v6 1/6
#2 lore raw

Re: [PATCH v6 1/6] arm64: smccc: Add support for SMCCCv1.2 extended input/output registers

Hi Sudeep,

Quoted 11 lines · Sudeep Holla

SMCCC v1.2 allows x8-x17 to be used as parameter registers and x4—x17 to be used as result registers in SMC64/HVC64. Arm Firmware Framework for Armv8-A specification makes use of x0-x7 as parameter and result registers. There are other users like Hyper-V who intend to use beyond x0-x7 as well.

Current SMCCC interface in the kernel just use x0-x7 as parameter and x0-x3 as result registers as required by SMCCCv1.0. Let us add new interface to support this extended set of input/output registers namely x0-x17 as both parameter and result registers.

Quoted 5 lines
Cc Michael Kelley <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>

I have one minor comment below, otherwise this looks good to me, and regardless:

[...]

Quoted 18 lines
include/linux/arm-smccc.h +18 -0
+/**
+ * arm_smccc_1_2_hvc() - make HVC calls
+ * @args: arguments passed via struct arm_smccc_1_2_regs
+ * @res: result values via struct arm_smccc_1_2_regs
+ *
+ * This function is used to make HVC calls following SMC Calling Convention
+ * v1.2 or above. The content of the supplied param are copied from the
+ * structure to registers prior to the HVC instruction. The return values
+ * are updated with the content from registers on return from the HVC
+ * instruction.
+ */
+asmlinkage void arm_smccc_1_2_hvc(struct arm_smccc_1_2_regs *args,
+				  struct arm_smccc_1_2_regs *res);
+
+/**
+ * arm_smccc_1_2_smc() - make SMC calls
+ * @args: arguments passed via struct arm_smccc_1_2_regs
+ * @res: result values via struct arm_smccc_1_2_regs

include/linux/arm-smccc.h struct arm_smccc_res { · line 283

Quoted 10 lines
include/linux/arm-smccc.h +10 -0
+ *
+ * This function is used to make SMC calls following SMC Calling Convention
+ * v1.2 or above. The content of the supplied param are copied from the
+ * structure to registers prior to the SMC instruction. The return values
+ * are updated with the content from registers on return from the SMC
+ * instruction.
+ */
+asmlinkage void arm_smccc_1_2_smc(struct arm_smccc_1_2_regs *args,
+				  struct arm_smccc_1_2_regs *res);
+#endif

It might be worth making the args parameter to these const, since we never write to it in the asm.

Thanks,
Mark.

#3 lore raw

Re: [PATCH v6 1/6] arm64: smccc: Add support for SMCCCv1.2 extended input/output registers

Quoted 50 lines · Mark Rutland

Hi Sudeep,

Quoted 11 lines · Sudeep Holla

SMCCC v1.2 allows x8-x17 to be used as parameter registers and x4—x17 to be used as result registers in SMC64/HVC64. Arm Firmware Framework for Armv8-A specification makes use of x0-x7 as parameter and result registers. There are other users like Hyper-V who intend to use beyond x0-x7 as well.

Current SMCCC interface in the kernel just use x0-x7 as parameter and x0-x3 as result registers as required by SMCCCv1.0. Let us add new interface to support this extended set of input/output registers namely x0-x17 as both parameter and result registers.

Quoted 5 lines
Cc Michael Kelley <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>

I have one minor comment below, otherwise this looks good to me, and regardless:

[...]

Quoted 23 lines
include/linux/arm-smccc.h +23 -0
+/**
+ * arm_smccc_1_2_hvc() - make HVC calls
+ * @args: arguments passed via struct arm_smccc_1_2_regs
+ * @res: result values via struct arm_smccc_1_2_regs
+ *
+ * This function is used to make HVC calls following SMC Calling Convention
+ * v1.2 or above. The content of the supplied param are copied from the
+ * structure to registers prior to the HVC instruction. The return values
+ * are updated with the content from registers on return from the HVC
+ * instruction.
+ */
+asmlinkage void arm_smccc_1_2_hvc(struct arm_smccc_1_2_regs *args,
+				  struct arm_smccc_1_2_regs *res);
+
+/**
+ * arm_smccc_1_2_smc() - make SMC calls
+ * @args: arguments passed via struct arm_smccc_1_2_regs
+ * @res: result values via struct arm_smccc_1_2_regs
+ *
+ * This function is used to make SMC calls following SMC Calling Convention
+ * v1.2 or above. The content of the supplied param are copied from the
+ * structure to registers prior to the SMC instruction. The return values
+ * are updated with the content from registers on return from the SMC
Quoted 9 lines

include/linux/arm-smccc.h struct arm_smccc_res { · line 283

Quoted 5 lines

+ * instruction.
+ */

include/linux/arm-smccc.h +3 -0
+asmlinkage void arm_smccc_1_2_smc(struct arm_smccc_1_2_regs *args,
+				  struct arm_smccc_1_2_regs *res);
+#endif

It might be worth making the args parameter to these const, since we never write to it in the asm.

Makes sense, will fix it. Thanks for the review.

Signature · 2 lines
Regards,
Sudeep
Tested-by Reviewed-by on v6 1/6
#4 lore raw

RE: [PATCH v6 1/6] arm64: smccc: Add support for SMCCCv1.2 extended input/output registers

In reply to Sudeep Holla

From: Sudeep Holla <[email protected]> Sent: Wednesday, May 5, 2021 2:39 AM

Quoted 93 lines

SMCCC v1.2 allows x8-x17 to be used as parameter registers and x4—x17 to be used as result registers in SMC64/HVC64. Arm Firmware Framework for Armv8-A specification makes use of x0-x7 as parameter and result registers. There are other users like Hyper-V who intend to use beyond x0-x7 as well.

Current SMCCC interface in the kernel just use x0-x7 as parameter and x0-x3 as result registers as required by SMCCCv1.0. Let us add new interface to support this extended set of input/output registers namely x0-x17 as both parameter and result registers.

Cc Michael Kelley <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 arch/arm64/kernel/asm-offsets.c |  9 ++++++
 arch/arm64/kernel/smccc-call.S  | 57 +++++++++++++++++++++++++++++++++
 include/linux/arm-smccc.h       | 55 +++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
arch/arm64/kernel/asm-offsets.c +9 -0
index 0cb34ccb6e73..74321bc9a459 100644
@@ -138,6 +138,15 @@ int main(void)
   DEFINE(ARM_SMCCC_RES_X2_OFFS,		offsetof(struct arm_smccc_res, a2));
   DEFINE(ARM_SMCCC_QUIRK_ID_OFFS,	offsetof(struct arm_smccc_quirk, id));
   DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS,	offsetof(struct arm_smccc_quirk, state));
+  DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS,	offsetof(struct arm_smccc_1_2_regs, a0));
+  DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS,	offsetof(struct arm_smccc_1_2_regs, a2));
+  DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS,	offsetof(struct arm_smccc_1_2_regs, a4));
+  DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS,	offsetof(struct arm_smccc_1_2_regs, a6));
+  DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS,	offsetof(struct arm_smccc_1_2_regs, a8));
+  DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS,	offsetof(struct
 arm_smccc_1_2_regs, a10));
+  DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS,	offsetof(struct
 arm_smccc_1_2_regs, a12));
+  DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS,	offsetof(struct
 arm_smccc_1_2_regs, a14));
+  DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS,	offsetof(struct
arm_smccc_1_2_regs, a16));
   BLANK();
   DEFINE(HIBERN_PBE_ORIG,	offsetof(struct pbe, orig_address));
   DEFINE(HIBERN_PBE_ADDR,	offsetof(struct pbe, address));
arch/arm64/kernel/smccc-call.S +38 -0
index d62447964ed9..7d79c5062c5d 100644
@@ -43,3 +43,60 @@ SYM_FUNC_START(__arm_smccc_hvc)
 	SMCCC	hvc
 SYM_FUNC_END(__arm_smccc_hvc)
 EXPORT_SYMBOL(__arm_smccc_hvc)
+
+	.macro SMCCC_1_2 instr
+	/* Save `res` and free a GPR that won't be clobbered */
+	stp     x1, x19, [sp, #-16]!
+
+	/* Ensure `args` won't be clobbered while loading regs in next step */
+	mov	x19, x0
+
+	/* Load the registers x0 - x17 from the struct arm_smccc_1_2_regs */
+	ldp	x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
+	ldp	x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
+	ldp	x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
+	ldp	x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
+	ldp	x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
+	ldp	x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
+	ldp	x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
+	ldp	x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
+	ldp	x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
+
+	\instr #0
+
+	/* Load the `res` from the stack */
+	ldr	x19, [sp]
+
+	/* Store the registers x0 - x17 into the result structure */
+	stp	x0, x1, [x19, #ARM_SMCCC_1_2_REGS_X0_OFFS]
+	stp	x2, x3, [x19, #ARM_SMCCC_1_2_REGS_X2_OFFS]
+	stp	x4, x5, [x19, #ARM_SMCCC_1_2_REGS_X4_OFFS]
+	stp	x6, x7, [x19, #ARM_SMCCC_1_2_REGS_X6_OFFS]
+	stp	x8, x9, [x19, #ARM_SMCCC_1_2_REGS_X8_OFFS]
+	stp	x10, x11, [x19, #ARM_SMCCC_1_2_REGS_X10_OFFS]
+	stp	x12, x13, [x19, #ARM_SMCCC_1_2_REGS_X12_OFFS]
+	stp	x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
+	stp	x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
+
+	/* Restore original x19 */
+	ldp     xzr, x19, [sp], #16
+	ret

arch/arm64/kernel/smccc-call.S SYM_FUNC_START(__arm_smccc_hvc) · line 93

Quoted 10 lines
arch/arm64/kernel/smccc-call.S +10 -0
+.endm
+
+/*
+ * void arm_smccc_1_2_hvc(struct arm_smccc_1_2_regs *args,
+ *			  struct arm_smccc_1_2_regs *res);
+ */
+SYM_FUNC_START(arm_smccc_1_2_hvc)
+	SMCCC_1_2 hvc
+SYM_FUNC_END(arm_smccc_1_2_hvc)
+EXPORT_SYMBOL(arm_smccc_1_2_hvc)

I've tested the new arm_smccc_1_2_hvc() function in the context of Linux guests making hypercalls on Hyper-V for ARM64, and it
works as intended. But note that my test case only uses X0 thru X7.

#5 lore raw

Re: [PATCH v6 1/6] arm64: smccc: Add support for SMCCCv1.2 extended input/output registers

Hi Michael,

Quoted 13 lines · Michael Kelley

From: Sudeep Holla <[email protected]> Sent: Wednesday, May 5, 2021 2:39 AM

Quoted 12 lines

SMCCC v1.2 allows x8-x17 to be used as parameter registers and x4—x17 to be used as result registers in SMC64/HVC64. Arm Firmware Framework for Armv8-A specification makes use of x0-x7 as parameter and result registers. There are other users like Hyper-V who intend to use beyond x0-x7 as well.

Current SMCCC interface in the kernel just use x0-x7 as parameter and x0-x3 as result registers as required by SMCCCv1.0. Let us add new interface to support this extended set of input/output registers namely x0-x17 as both parameter and result registers.

[...]

Quoted 6 lines

I've tested the new arm_smccc_1_2_hvc() function in the context of Linux guests making hypercalls on Hyper-V for ARM64, and it
works as intended. But note that my test case only uses X0 thru X7.

Thanks!

Signature · 2 lines
Regards,
Sudeep
#6 lore raw

PATCH v6 2/6 firmware: arm_ffa: Add initial FFA bus support for device enumeration

In reply to Sudeep Holla

The Arm FF for Armv8-A specification has concept of endpoints or partitions. In the Normal world, a partition could be a VM when the Virtualization extension is enabled or the kernel itself.

In order to handle multiple partitions, we can create a FFA device for each such partition on a dedicated FFA bus. Similarly, different drivers requiring FFA transport can be registered on the same bus. We can match the device and drivers using UUID. This is mostly for the in-kernel users with FFA drivers.

---
 MAINTAINERS                       |   7 +
 drivers/firmware/Kconfig          |   1 +
 drivers/firmware/Makefile         |   1 +
 drivers/firmware/arm_ffa/Kconfig  |  16 +++
 drivers/firmware/arm_ffa/Makefile |   4 +
 drivers/firmware/arm_ffa/bus.c    | 207 ++++++++++++++++++++++++++++++
 include/linux/arm_ffa.h           |  91 +++++++++++++
 7 files changed, 327 insertions(+)
 create mode 100644 drivers/firmware/arm_ffa/Kconfig
 create mode 100644 drivers/firmware/arm_ffa/Makefile
 create mode 100644 drivers/firmware/arm_ffa/bus.c
 create mode 100644 include/linux/arm_ffa.h
MAINTAINERS +7 -0
index 121b1a12384a..88a988e08d11 100644
@@ -7052,6 +7052,13 @@ F:	include/linux/firewire.h
 F:	include/uapi/linux/firewire*.h
 F:	tools/firewire/
 
+FIRMWARE FRAMEWORK FOR ARMV8-A
+M:	Sudeep Holla <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/firmware/arm_ffa/
+F:	include/linux/arm_ffa.h
+
 FIRMWARE LOADER (request_firmware)
 M:	Luis Chamberlain <[email protected]>
 L:	[email protected]
drivers/firmware/Kconfig +1 -0
index db0ea2d2d75a..b53ac9fc7704 100644
@@ -296,6 +296,7 @@ config TURRIS_MOX_RWTM
 	  other manufacturing data and also utilize the Entropy Bit Generator
 	  for hardware random number generation.
 
+source "drivers/firmware/arm_ffa/Kconfig"
 source "drivers/firmware/broadcom/Kconfig"
 source "drivers/firmware/google/Kconfig"
 source "drivers/firmware/efi/Kconfig"
drivers/firmware/Makefile +1 -0
index 5e013b6a3692..546ac8e7f6d0 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o
 obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
 obj-$(CONFIG_TURRIS_MOX_RWTM)	+= turris-mox-rwtm.o
 
+obj-y				+= arm_ffa/
 obj-y				+= arm_scmi/
 obj-y				+= broadcom/
 obj-y				+= meson/
drivers/firmware/arm_ffa/Kconfig new file +16 -0
new file mode 100644
index 000000000000..261a3660650a
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config ARM_FFA_TRANSPORT
+	tristate "Arm Firmware Framework for Armv8-A"
+	depends on OF
+	depends on ARM64
+	default n
+	help
+	  This Firmware Framework(FF) for Arm A-profile processors describes
+	  interfaces that standardize communication between the various
+	  software images which includes communication between images in
+	  the Secure world and Normal world. It also leverages the
+	  virtualization extension to isolate software images provided
+	  by an ecosystem of vendors from each other.
+
+	  This driver provides interface for all the client drivers making
+	  use of the features offered by ARM FF-A.
drivers/firmware/arm_ffa/Makefile new file +4 -0
new file mode 100644
index 000000000000..bfe4323a8784
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+ffa-bus-y = bus.o
+ffa-module-objs := $(ffa-bus-y)
+obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o
drivers/firmware/arm_ffa/bus.c new file +207 -0

207 lines not on this page · raw message

include/linux/arm_ffa.h new file +91 -0

91 lines not on this page · raw message

Signature · 1 line
2.25.1
#7 lore raw

PATCH v6 3/6 firmware: arm_ffa: Add initial Arm FFA driver support

In reply to Sudeep Holla

This just add a basic driver that sets up the transport(e.g. SMCCC), checks the FFA version implemented, get the partition ID for self and sets up the Tx/Rx buffers for communication.

---
 drivers/firmware/arm_ffa/Makefile |   3 +-
 drivers/firmware/arm_ffa/bus.c    |  14 +-
 drivers/firmware/arm_ffa/common.h |  24 +++
 drivers/firmware/arm_ffa/driver.c | 307 ++++++++++++++++++++++++++++++
 4 files changed, 337 insertions(+), 11 deletions(-)
 create mode 100644 drivers/firmware/arm_ffa/common.h
 create mode 100644 drivers/firmware/arm_ffa/driver.c
drivers/firmware/arm_ffa/Makefile +2 -1
index bfe4323a8784..82d0d35c5324 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 ffa-bus-y = bus.o
-ffa-module-objs := $(ffa-bus-y)
+ffa-driver-y = driver.o
+ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y)
 obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o
drivers/firmware/arm_ffa/bus.c +4 -10
index b743fb2256e9..58441266e60d 100644
@@ -13,6 +13,8 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
+#include "common.h"
+
 static int ffa_device_match(struct device *dev, struct device_driver *drv)
 {
 	const struct ffa_device_id *id_table;
@@ -187,21 +189,13 @@ void ffa_device_unregister(struct ffa_device *ffa_dev)
 }
 EXPORT_SYMBOL_GPL(ffa_device_unregister);
 
-static int __init arm_ffa_bus_init(void)
+int __init arm_ffa_bus_init(void)
 {
 	return bus_register(&ffa_bus_type);
 }
-module_init(arm_ffa_bus_init);
 
-static void __exit arm_ffa_bus_exit(void)
+void __exit arm_ffa_bus_exit(void)
 {
 	ffa_devices_unregister();
 	bus_unregister(&ffa_bus_type);
 }
-
-module_exit(arm_ffa_bus_exit);
-
-MODULE_ALIAS("arm-ffa-bus");
-MODULE_AUTHOR("Sudeep Holla <[email protected]>");
-MODULE_DESCRIPTION("Arm FF-A bus driver");
-MODULE_LICENSE("GPL v2");
drivers/firmware/arm_ffa/common.h new file +24 -0
new file mode 100644
index 000000000000..9195f66f826c
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 ARM Ltd.
+ */
+
+#ifndef _FFA_COMMON_H
+#define _FFA_COMMON_H
+
+#include <linux/arm-smccc.h>
+#include <linux/err.h>
+
+typedef struct arm_smccc_1_2_regs ffa_value_t;
+
+typedef void (ffa_fn)(ffa_value_t, ffa_value_t *);
+
+int __init arm_ffa_bus_init(void);
+void __exit arm_ffa_bus_exit(void);
+
+static inline int __init ffa_transport_init(ffa_fn **invoke_ffa_fn)
+{
+	return -EOPNOTSUPP;
+}
+
+#endif /* _FFA_COMMON_H */
drivers/firmware/arm_ffa/driver.c new file +307 -0

307 lines not on this page · raw message

Signature · 1 line
2.25.1
#8 lore raw

PATCH v6 4/6 firmware: arm_ffa: Add support for SMCCC as transport to FFA driver

In reply to Sudeep Holla

There are requests to keep the transport separate in order to allow other possible transports like virtio. So let us keep the SMCCC transport specific routines abstracted.

It is kept simple for now. Once we add another transport, we can develop better abstraction.

---
 drivers/firmware/arm_ffa/Kconfig  |  5 ++++
 drivers/firmware/arm_ffa/Makefile |  3 ++-
 drivers/firmware/arm_ffa/common.h |  4 ++++
 drivers/firmware/arm_ffa/smccc.c  | 39 +++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 drivers/firmware/arm_ffa/smccc.c
drivers/firmware/arm_ffa/Kconfig +5 -0
index 261a3660650a..5e3ae5cf82e8 100644
@@ -14,3 +14,8 @@ config ARM_FFA_TRANSPORT
 
 	  This driver provides interface for all the client drivers making
 	  use of the features offered by ARM FF-A.
+
+config ARM_FFA_SMCCC
+	bool
+	default ARM_FFA_TRANSPORT
+	depends on ARM64 && HAVE_ARM_SMCCC_DISCOVERY
drivers/firmware/arm_ffa/Makefile +2 -1
index 82d0d35c5324..9d9f37523200 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 ffa-bus-y = bus.o
 ffa-driver-y = driver.o
-ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y)
+ffa-transport-$(CONFIG_ARM_FFA_SMCCC) += smccc.o
+ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y) $(ffa-transport-y)
 obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o
drivers/firmware/arm_ffa/common.h +4 -0
index 9195f66f826c..842451666827 100644
@@ -16,9 +16,13 @@ typedef void (ffa_fn)(ffa_value_t, ffa_value_t *);
 int __init arm_ffa_bus_init(void);
 void __exit arm_ffa_bus_exit(void);
 
+#ifdef CONFIG_ARM_FFA_SMCCC
+int __init ffa_transport_init(ffa_fn **invoke_ffa_fn);
+#else
 static inline int __init ffa_transport_init(ffa_fn **invoke_ffa_fn)
 {
 	return -EOPNOTSUPP;
 }
+#endif
 
 #endif /* _FFA_COMMON_H */
drivers/firmware/arm_ffa/smccc.c new file +39 -0
new file mode 100644
index 000000000000..22c34b788769
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2020 ARM Ltd.
+ */
+
+#include <linux/printk.h>
+
+#include "common.h"
+
+static void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
+{
+	arm_smccc_1_2_smc(&args, res);
+}
+
+static void __arm_ffa_fn_hvc(ffa_value_t args, ffa_value_t *res)
+{
+	arm_smccc_1_2_hvc(&args, res);
+}
+
+int __init ffa_transport_init(ffa_fn **invoke_ffa_fn)
+{
+	enum arm_smccc_conduit conduit;
+
+	if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2)
+		return -EOPNOTSUPP;
+
+	conduit = arm_smccc_1_1_get_conduit();
+	if (conduit == SMCCC_CONDUIT_NONE) {
+		pr_err("%s: invalid SMCCC conduit\n", __func__);
+		return -EOPNOTSUPP;
+	}
+
+	if (conduit == SMCCC_CONDUIT_SMC)
+		*invoke_ffa_fn = __arm_ffa_fn_smc;
+	else
+		*invoke_ffa_fn = __arm_ffa_fn_hvc;
+
+	return 0;
+}
Signature · 1 line
2.25.1
#9 lore raw

PATCH v6 5/6 firmware: arm_ffa: Setup in-kernel users of FFA partitions

In reply to Sudeep Holla

Parse the FFA nodes from the device-tree and register all the partitions whose services will be used in the kernel.

In order to also enable in-kernel users of FFA interface, let us add simple set of operations for such devices.

The in-kernel users are registered without the character device interface.

---
 drivers/firmware/arm_ffa/bus.c    |   9 ++
 drivers/firmware/arm_ffa/common.h |   3 +
 drivers/firmware/arm_ffa/driver.c | 213 ++++++++++++++++++++++++++++++
 include/linux/arm_ffa.h           |  38 +++++-
 4 files changed, 262 insertions(+), 1 deletion(-)
drivers/firmware/arm_ffa/bus.c +9 -0
index 58441266e60d..da23100c2e39 100644
@@ -24,6 +24,15 @@ static int ffa_device_match(struct device *dev, struct device_driver *drv)
 	ffa_dev = to_ffa_dev(dev);
 
 	while (!uuid_is_null(&id_table->uuid)) {
+		/*
+		 * FF-A v1.0 doesn't provide discovery of UUIDs, just the
+		 * partition IDs, so fetch the partitions IDs for this
+		 * id_table UUID and assign the UUID to the device if the
+		 * partition ID matches
+		 */
+		if (uuid_is_null(&ffa_dev->uuid))
+			ffa_device_match_uuid(ffa_dev, &id_table->uuid);
+
 		if (uuid_equal(&ffa_dev->uuid, &id_table->uuid))
 			return 1;
 		id_table++;
drivers/firmware/arm_ffa/common.h +3 -0
index 842451666827..80ad71f02235 100644
@@ -6,6 +6,7 @@
 #ifndef _FFA_COMMON_H
 #define _FFA_COMMON_H
 
+#include <linux/arm_ffa.h>
 #include <linux/arm-smccc.h>
 #include <linux/err.h>
 
@@ -15,6 +16,8 @@ typedef void (ffa_fn)(ffa_value_t, ffa_value_t *);
 
 int __init arm_ffa_bus_init(void);
 void __exit arm_ffa_bus_exit(void);
+bool ffa_device_is_valid(struct ffa_device *ffa_dev);
+void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid);
 
 #ifdef CONFIG_ARM_FFA_SMCCC
 int __init ffa_transport_init(ffa_fn **invoke_ffa_fn);
drivers/firmware/arm_ffa/driver.c +213 -0

246 lines not on this page · raw message

include/linux/arm_ffa.h +37 -1
index aaff89364541..b242fbbce4f0 100644
@@ -6,7 +6,6 @@
 #ifndef _LINUX_ARM_FFA_H
 #define _LINUX_ARM_FFA_H
 
-#include <linux/cdev.h>
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -15,6 +14,7 @@
 /* FFA Bus/Device/Driver related */
 struct ffa_device {
 	int vm_id;
+	bool mode_32bit;
 	uuid_t uuid;
 	struct device dev;
 };
@@ -48,6 +48,7 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
 			const char *mod_name);
 void ffa_driver_unregister(struct ffa_driver *driver);
 bool ffa_device_is_valid(struct ffa_device *ffa_dev);
+const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev);
 
 #else
 static inline
@@ -70,6 +71,10 @@ static inline void ffa_driver_unregister(struct ffa_driver *driver) {}
 static inline
 bool ffa_device_is_valid(struct ffa_device *ffa_dev) { return false; }
 
+const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
+{
+	return NULL;
+}
 #endif /* CONFIG_ARM_FFA_TRANSPORT */
 
 #define ffa_register(driver) \
@@ -88,4 +93,35 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev) { return false; }
 #define module_ffa_driver(__ffa_driver)	\
 	module_driver(__ffa_driver, ffa_register, ffa_unregister)
 
+/* FFA transport related */
+struct ffa_partition_info {
+	u16 id;
+	u16 exec_ctxt;
+/* partition supports receipt of direct requests */
+#define FFA_PARTITION_DIRECT_RECV	BIT(0)
+/* partition can send direct requests. */
+#define FFA_PARTITION_DIRECT_SEND	BIT(1)
+/* partition can send and receive indirect messages. */
+#define FFA_PARTITION_INDIRECT_MSG	BIT(2)
+	u32 properties;
+};
+
+/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
+struct ffa_send_direct_data {
+	unsigned long data0; /* w3/x3 */
+	unsigned long data1; /* w4/x4 */
+	unsigned long data2; /* w5/x5 */
+	unsigned long data3; /* w6/x6 */
+	unsigned long data4; /* w7/x7 */
+};
+
+struct ffa_dev_ops {
+	u32 (*api_version_get)(void);
+	int (*partition_info_get)(const char *uuid_str,
+				  struct ffa_partition_info *buffer);
+	void (*mode_32bit_set)(struct ffa_device *dev);
+	int (*sync_send_receive)(struct ffa_device *dev,
+				 struct ffa_send_direct_data *data);
+};
+
 #endif /* _LINUX_ARM_FFA_H */
Signature · 1 line
2.25.1
#10 lore raw

PATCH v6 6/6 firmware: arm_ffa: Add support for MEM_* interfaces

In reply to Sudeep Holla

Most of the MEM_* APIs share the same parameters, so they can be generalised. Currently only MEM_SHARE is implemented and the user space interface for that is not added yet.

---
 drivers/firmware/arm_ffa/driver.c | 199 ++++++++++++++++++++++++++++++
 include/linux/arm_ffa.h           | 139 +++++++++++++++++++++
 2 files changed, 338 insertions(+)
drivers/firmware/arm_ffa/driver.c +199 -0
index cefbb3edf142..056a3fca14d1 100644
@@ -28,6 +28,8 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
 #include <linux/slab.h>
 #include <linux/uuid.h>
 
@@ -348,6 +350,192 @@ static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit,
 	return -EINVAL;
 }
 
+static int ffa_mem_first_frag(u32 func_id, phys_addr_t buf, u32 buf_sz,
+			      u32 frag_len, u32 len, u64 *handle)
+{
+	ffa_value_t ret;
+
+	invoke_ffa_fn((ffa_value_t){
+		      .a0 = func_id, .a1 = len, .a2 = frag_len,
+		      .a3 = buf, .a4 = buf_sz,
+		      }, &ret);
+
+	while (ret.a0 == FFA_MEM_OP_PAUSE)
+		invoke_ffa_fn((ffa_value_t){
+			      .a0 = FFA_MEM_OP_RESUME,
+			      .a1 = ret.a1, .a2 = ret.a2,
+			      }, &ret);
+
+	if (ret.a0 == FFA_ERROR)
+		return ffa_to_linux_errno((int)ret.a2);
+
+	if (ret.a0 != FFA_SUCCESS)
+		return -EOPNOTSUPP;
+
+	if (handle)
+		*handle = PACK_HANDLE(ret.a2, ret.a3);
+
+	return frag_len;
+}
+
+static int ffa_mem_next_frag(u64 handle, u32 frag_len)
+{
+	ffa_value_t ret;
+
+	invoke_ffa_fn((ffa_value_t){
+		      .a0 = FFA_MEM_FRAG_TX,
+		      .a1 = HANDLE_LOW(handle), .a2 = HANDLE_HIGH(handle),
+		      .a3 = frag_len,
+		      }, &ret);
+
+	while (ret.a0 == FFA_MEM_OP_PAUSE)
+		invoke_ffa_fn((ffa_value_t){
+			      .a0 = FFA_MEM_OP_RESUME,
+			      .a1 = ret.a1, .a2 = ret.a2,
+			      }, &ret);
+
+	if (ret.a0 == FFA_ERROR)
+		return ffa_to_linux_errno((int)ret.a2);
+
+	if (ret.a0 != FFA_MEM_FRAG_RX)
+		return -EOPNOTSUPP;
+
+	return ret.a3;
+}
+
+static int
+ffa_transmit_fragment(u32 func_id, phys_addr_t buf, u32 buf_sz, u32 frag_len,
+		      u32 len, u64 *handle, bool first)
+{
+	if (!first)
+		return ffa_mem_next_frag(*handle, frag_len);
+
+	return ffa_mem_first_frag(func_id, buf, buf_sz, frag_len, len, handle);
+}
+
+static u32 ffa_get_num_pages_sg(struct scatterlist *sg)
+{
+	u32 num_pages = 0;
+
+	do {
+		num_pages += sg->length / FFA_PAGE_SIZE;
+	} while ((sg = sg_next(sg)));
+
+	return num_pages;
+}
+
+static int
+ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize,
+		       struct ffa_mem_ops_args *args)
+{
+	int rc = 0;
+	bool first = true;
+	phys_addr_t addr = 0;
+	struct ffa_composite_mem_region *composite;
+	struct ffa_mem_region_addr_range *constituents;
+	struct ffa_mem_region_attributes *ep_mem_access;
+	struct ffa_mem_region *mem_region = buffer;
+	u32 idx, frag_len, length, buf_sz = 0, num_entries = sg_nents(args->sg);
+
+	mem_region->tag = args->tag;
+	mem_region->flags = args->flags;
+	mem_region->sender_id = drv_info->vm_id;
+	mem_region->attributes = FFA_MEM_NORMAL | FFA_MEM_WRITE_BACK |
+				 FFA_MEM_INNER_SHAREABLE;
+	ep_mem_access = &mem_region->ep_mem_access[0];
+
+	for (idx = 0; idx < args->nattrs; idx++, ep_mem_access++) {
+		ep_mem_access->receiver = args->attrs[idx].receiver;
+		ep_mem_access->attrs = args->attrs[idx].attrs;
+		ep_mem_access->composite_off = COMPOSITE_OFFSET(args->nattrs);
+	}
+	mem_region->ep_count = args->nattrs;
+
+	composite = buffer + COMPOSITE_OFFSET(args->nattrs);
+	composite->total_pg_cnt = ffa_get_num_pages_sg(args->sg);
+	composite->addr_range_cnt = num_entries;
+
+	length = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, num_entries);
+	frag_len = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, 0);
+	if (frag_len > max_fragsize)
+		return -ENXIO;
+
+	if (!args->use_txbuf) {
+		addr = virt_to_phys(buffer);
+		buf_sz = max_fragsize / FFA_PAGE_SIZE;
+	}
+
+	constituents = buffer + frag_len;
+	idx = 0;
+	do {
+		if (frag_len == max_fragsize) {
+			rc = ffa_transmit_fragment(func_id, addr, buf_sz,
+						   frag_len, length,
+						   &args->g_handle, first);
+			if (rc < 0)
+				return -ENXIO;
+
+			first = false;
+			idx = 0;
+			frag_len = 0;
+			constituents = buffer;
+		}
+
+		if ((void *)constituents - buffer > max_fragsize) {
+			pr_err("Memory Region Fragment > Tx Buffer size\n");
+			return -EFAULT;
+		}
+
+		constituents->address = sg_phys(args->sg);
+		constituents->pg_cnt = args->sg->length / FFA_PAGE_SIZE;
+		constituents++;
+		frag_len += sizeof(struct ffa_mem_region_addr_range);
+	} while ((args->sg = sg_next(args->sg)));
+
+	return ffa_transmit_fragment(func_id, addr, buf_sz, frag_len,
+				     length, &args->g_handle, first);
+}
+
+static int ffa_memory_ops(u32 func_id, struct ffa_mem_ops_args *args)
+{
+	int ret;
+	void *buffer;
+
+	if (!args->use_txbuf) {
+		buffer = alloc_pages_exact(RXTX_BUFFER_SIZE, GFP_KERNEL);
+		if (!buffer)
+			return -ENOMEM;
+	} else {
+		buffer = drv_info->tx_buffer;
+		mutex_lock(&drv_info->tx_lock);
+	}
+
+	ret = ffa_setup_and_transmit(func_id, buffer, RXTX_BUFFER_SIZE, args);
+
+	if (args->use_txbuf)
+		mutex_unlock(&drv_info->tx_lock);
+	else
+		free_pages_exact(buffer, RXTX_BUFFER_SIZE);
+
+	return ret < 0 ? ret : 0;
+}
+
+static int ffa_memory_reclaim(u64 g_handle, u32 flags)
+{
+	ffa_value_t ret;
+
+	invoke_ffa_fn((ffa_value_t){
+		      .a0 = FFA_MEM_RECLAIM,
+		      .a1 = HANDLE_LOW(g_handle), .a2 = HANDLE_HIGH(g_handle),
+		      .a3 = flags,
+		      }, &ret);
+
+	if (ret.a0 == FFA_ERROR)
+		return ffa_to_linux_errno((int)ret.a2);
+
+	return 0;
+}
+
 static u32 ffa_api_version_get(void)
 {
 	return drv_info->version;
@@ -386,11 +574,22 @@ static int ffa_sync_send_receive(struct ffa_device *dev,
 				       dev->mode_32bit, data);
 }
 
+static int
+ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
+{
+	if (dev->mode_32bit)
+		return ffa_memory_ops(FFA_MEM_SHARE, args);
+
+	return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
+}
+
 static const struct ffa_dev_ops ffa_ops = {
 	.api_version_get = ffa_api_version_get,
 	.partition_info_get = ffa_partition_info_get,
 	.mode_32bit_set = ffa_mode_32bit_set,
 	.sync_send_receive = ffa_sync_send_receive,
+	.memory_reclaim = ffa_memory_reclaim,
+	.memory_share = ffa_memory_share,
 };
 
 const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
include/linux/arm_ffa.h +139 -0

151 lines not on this page · raw message

Signature · 1 line
2.25.1
Tested-by on the v6 series
#11 lore raw
In reply to Sudeep Holla
Quoted 16 lines · Sudeep Holla

Hi all,

This is very basic implementation for in-kernel support for Arm FF-A specification.

Arm Firmware Framework for Armv8-A specification[1] describes a software architecture that provides mechanism to utilise the virtualization extension to isolate software images and describes interfaces that standardize communication between the various software images. This includes communication between images in the Secure and Normal world.

The main idea here is to create FFA device to establish any communication with a secure partition. This is currently tested with OPTEE(with changes to OPTEE driver adding FFA as transport)

Quoted 8 lines

The series can be fetched from [2]

--
Regards,
Sudeep

[1] https://developer.arm.com/documentation/den0077/latest
[2] git://git.kerniel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git v5.13/ffa

Tested OK with my OP-TEE driver patches on top of 755e78187c4e ("firmware: arm_ffa: Add support for MEM_* interfaces"), which is the latest on the v5.13/ffa branch above.

Cheers,
Jens

Quoted 68 lines

v5->v6:
- Dropped DT dependecy completely and use the discovery APIs for adding FFA partitions on the bus. They is some workaround added as v1.0 doesn't provide UUID as part of the discovery APIs which is used to match the devices and driver on FFA bus.
- Extended SMCCC v1.2 API to support full set of input and output registers.
- Couple of minor bug fixes found as part of testing

v4->v5:
- Fixed couple of comments in DT bindings
- Moved to use native version of RXTX_MAP call, fixed vm_id param to RXTX_UNMAP, dropped couple of unused confusingly named macros (can be added back with correct name when we need to use them)

v3->v4:
- Added support to allow partitions to set 32bit only mode
- Addressed all the comments from Jens Wiklander

v2->v3:
- Dropped hypervisor partitions and userspace support as it is no longer in the list of requirements
- Moved away from ioctl style interface for in-kernel users as there is no need to keep in sync with userspace anymore
- Some kerneldoc fixes as pointed out in earlier reviews

v1->v2:
- Moved userspace code to a separate unit, will move to separate module. Still working on minimizing initcall dependencies and exported functions to reuse some of the code.
- Fixed couple of minor issues pointed out
- Dropped ASYNC send message as I haven't been able to test

Sudeep Holla (6):
arm64: smccc: Add support for SMCCCv1.2 extended input/output registers
firmware: arm_ffa: Add initial FFA bus support for device enumeration
firmware: arm_ffa: Add initial Arm FFA driver support
firmware: arm_ffa: Add support for SMCCC as transport to FFA driver
firmware: arm_ffa: Setup in-kernel users of FFA partitions
firmware: arm_ffa: Add support for MEM_* interfaces

 MAINTAINERS                       |   7 +
 arch/arm64/kernel/asm-offsets.c   |   9 +
 arch/arm64/kernel/smccc-call.S    |  57 +++
 drivers/firmware/Kconfig          |   1 +
 drivers/firmware/Makefile         |   1 +
 drivers/firmware/arm_ffa/Kconfig  |  21 +
 drivers/firmware/arm_ffa/Makefile |   6 +
 drivers/firmware/arm_ffa/bus.c    | 210 +++++++++
 drivers/firmware/arm_ffa/common.h |  31 ++
 drivers/firmware/arm_ffa/driver.c | 719 ++++++++++++++++++++++++++++++
 drivers/firmware/arm_ffa/smccc.c  |  39 ++
 include/linux/arm-smccc.h         |  55 +++
 include/linux/arm_ffa.h           | 266 +++++++++++
 13 files changed, 1422 insertions(+)
 create mode 100644 drivers/firmware/arm_ffa/Kconfig
 create mode 100644 drivers/firmware/arm_ffa/Makefile
 create mode 100644 drivers/firmware/arm_ffa/bus.c
 create mode 100644 drivers/firmware/arm_ffa/common.h
 create mode 100644 drivers/firmware/arm_ffa/driver.c
 create mode 100644 drivers/firmware/arm_ffa/smccc.c
 create mode 100644 include/linux/arm_ffa.h

--
2.25.1

#12 lore raw
Quoted 23 lines · Jens Wiklander
Quoted 22 lines · Sudeep Holla

Hi all,

This is very basic implementation for in-kernel support for Arm FF-A specification.

Arm Firmware Framework for Armv8-A specification[1] describes a software architecture that provides mechanism to utilise the virtualization extension to isolate software images and describes interfaces that standardize communication between the various software images. This includes communication between images in the Secure and Normal world.

The main idea here is to create FFA device to establish any communication with a secure partition. This is currently tested with OPTEE(with changes to OPTEE driver adding FFA as transport)

The series can be fetched from [2]

--
Regards,
Sudeep

Quoted 9 lines
Quoted 2 lines

[1] https://developer.arm.com/documentation/den0077/latest
[2] git://git.kerniel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git v5.13/ffa

Tested OK with my OP-TEE driver patches on top of 755e78187c4e ("firmware: arm_ffa: Add support for MEM_* interfaces"), which is the latest on the v5.13/ffa branch above.

Thanks Jens for testing, much appreciated!

Signature · 2 lines
Regards,
Sudeep