Skip to content

Commit

Permalink
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/herbert/crypto-2.6

Pull crypto updates from Herbert Xu:
 "API:
   - Fix out-of-sync IVs in self-test for IPsec AEAD algorithms

  Algorithms:
   - Use formally verified implementation of x86/curve25519

  Drivers:
   - Enhance hwrng support in caam

   - Use crypto_engine for skcipher/aead/rsa/hash in caam

   - Add Xilinx AES driver

   - Add uacce driver

   - Register zip engine to uacce in hisilicon

   - Add support for OCTEON TX CPT engine in marvell"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (162 commits)
  crypto: af_alg - bool type cosmetics
  crypto: arm[64]/poly1305 - add artifact to .gitignore files
  crypto: caam - limit single JD RNG output to maximum of 16 bytes
  crypto: caam - enable prediction resistance in HRWNG
  bus: fsl-mc: add api to retrieve mc version
  crypto: caam - invalidate entropy register during RNG initialization
  crypto: caam - check if RNG job failed
  crypto: caam - simplify RNG implementation
  crypto: caam - drop global context pointer and init_done
  crypto: caam - use struct hwrng's .init for initialization
  crypto: caam - allocate RNG instantiation descriptor with GFP_DMA
  crypto: ccree - remove duplicated include from cc_aead.c
  crypto: chelsio - remove set but not used variable 'adap'
  crypto: marvell - enable OcteonTX cpt options for build
  crypto: marvell - add the Virtual Function driver for CPT
  crypto: marvell - add support for OCTEON TX CPT engine
  crypto: marvell - create common Kconfig and Makefile for Marvell
  crypto: arm/neon - memzero_explicit aes-cbc key
  crypto: bcm - Use scnprintf() for avoiding potential buffer overflow
  crypto: atmel-i2c - Fix wakeup fail
  ...
  • Loading branch information
torvalds committed Apr 1, 2020
2 parents 890f0b0 + fcb90d5 commit 72f3542
Show file tree
Hide file tree
Showing 152 changed files with 13,777 additions and 5,297 deletions.
39 changes: 39 additions & 0 deletions Documentation/ABI/testing/sysfs-driver-uacce
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
What: /sys/class/uacce/<dev_name>/api
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Api of the device
Can be any string and up to userspace to parse.
Application use the api to match the correct driver

What: /sys/class/uacce/<dev_name>/flags
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Attributes of the device, see UACCE_DEV_xxx flag defined in uacce.h

What: /sys/class/uacce/<dev_name>/available_instances
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Available instances left of the device
Return -ENODEV if uacce_ops get_available_instances is not provided

What: /sys/class/uacce/<dev_name>/algorithms
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Algorithms supported by this accelerator, separated by new line.
Can be any string and up to userspace to parse.

What: /sys/class/uacce/<dev_name>/region_mmio_size
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Size (bytes) of mmio region queue file

What: /sys/class/uacce/<dev_name>/region_dus_size
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Size (bytes) of dus region queue file
37 changes: 37 additions & 0 deletions Documentation/devicetree/bindings/crypto/xlnx,zynqmp-aes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/crypto/xlnx,zynqmp-aes.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Xilinx ZynqMP AES-GCM Hardware Accelerator Device Tree Bindings

maintainers:
- Kalyani Akula <[email protected]>
- Michal Simek <[email protected]>

description: |
The ZynqMP AES-GCM hardened cryptographic accelerator is used to
encrypt or decrypt the data with provided key and initialization vector.
properties:
compatible:
const: xlnx,zynqmp-aes

required:
- compatible

additionalProperties: false

examples:
- |
firmware {
zynqmp_firmware: zynqmp-firmware {
compatible = "xlnx,zynqmp-firmware";
method = "smc";
xlnx_aes: zynqmp-aes {
compatible = "xlnx,zynqmp-aes";
};
};
};
...
176 changes: 176 additions & 0 deletions Documentation/misc-devices/uacce.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
.. SPDX-License-Identifier: GPL-2.0
Introduction of Uacce
---------------------

Uacce (Unified/User-space-access-intended Accelerator Framework) targets to
provide Shared Virtual Addressing (SVA) between accelerators and processes.
So accelerator can access any data structure of the main cpu.
This differs from the data sharing between cpu and io device, which share
only data content rather than address.
Because of the unified address, hardware and user space of process can
share the same virtual address in the communication.
Uacce takes the hardware accelerator as a heterogeneous processor, while
IOMMU share the same CPU page tables and as a result the same translation
from va to pa.

::

__________________________ __________________________
| | | |
| User application (CPU) | | Hardware Accelerator |
|__________________________| |__________________________|

| |
| va | va
V V
__________ __________
| | | |
| MMU | | IOMMU |
|__________| |__________|
| |
| |
V pa V pa
_______________________________________
| |
| Memory |
|_______________________________________|



Architecture
------------

Uacce is the kernel module, taking charge of iommu and address sharing.
The user drivers and libraries are called WarpDrive.

The uacce device, built around the IOMMU SVA API, can access multiple
address spaces, including the one without PASID.

A virtual concept, queue, is used for the communication. It provides a
FIFO-like interface. And it maintains a unified address space between the
application and all involved hardware.

::

___________________ ________________
| | user API | |
| WarpDrive library | ------------> | user driver |
|___________________| |________________|
| |
| |
| queue fd |
| |
| |
v |
___________________ _________ |
| | | | | mmap memory
| Other framework | | uacce | | r/w interface
| crypto/nic/others | |_________| |
|___________________| |
| | |
| register | register |
| | |
| | |
| _________________ __________ |
| | | | | |
------------- | Device Driver | | IOMMU | |
|_________________| |__________| |
| |
| V
| ___________________
| | |
-------------------------- | Device(Hardware) |
|___________________|


How does it work
----------------

Uacce uses mmap and IOMMU to play the trick.

Uacce creates a chrdev for every device registered to it. New queue is
created when user application open the chrdev. The file descriptor is used
as the user handle of the queue.
The accelerator device present itself as an Uacce object, which exports as
a chrdev to the user space. The user application communicates with the
hardware by ioctl (as control path) or share memory (as data path).

The control path to the hardware is via file operation, while data path is
via mmap space of the queue fd.

The queue file address space:

::

/**
* enum uacce_qfrt: qfrt type
* @UACCE_QFRT_MMIO: device mmio region
* @UACCE_QFRT_DUS: device user share region
*/
enum uacce_qfrt {
UACCE_QFRT_MMIO = 0,
UACCE_QFRT_DUS = 1,
};

All regions are optional and differ from device type to type.
Each region can be mmapped only once, otherwise -EEXIST returns.

The device mmio region is mapped to the hardware mmio space. It is generally
used for doorbell or other notification to the hardware. It is not fast enough
as data channel.

The device user share region is used for share data buffer between user process
and device.


The Uacce register API
----------------------

The register API is defined in uacce.h.

::

struct uacce_interface {
char name[UACCE_MAX_NAME_SIZE];
unsigned int flags;
const struct uacce_ops *ops;
};

According to the IOMMU capability, uacce_interface flags can be:

::

/**
* UACCE Device flags:
* UACCE_DEV_SVA: Shared Virtual Addresses
* Support PASID
* Support device page faults (PCI PRI or SMMU Stall)
*/
#define UACCE_DEV_SVA BIT(0)

struct uacce_device *uacce_alloc(struct device *parent,
struct uacce_interface *interface);
int uacce_register(struct uacce_device *uacce);
void uacce_remove(struct uacce_device *uacce);

uacce_register results can be:

a. If uacce module is not compiled, ERR_PTR(-ENODEV)

b. Succeed with the desired flags

c. Succeed with the negotiated flags, for example

uacce_interface.flags = UACCE_DEV_SVA but uacce->flags = ~UACCE_DEV_SVA

So user driver need check return value as well as the negotiated uacce->flags.


The user driver
---------------

The queue file mmap space will need a user driver to wrap the communication
protocol. Uacce provides some attributes in sysfs for the user driver to
match the right accelerator accordingly.
More details in Documentation/ABI/testing/sysfs-driver-uacce.
17 changes: 16 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4577,7 +4577,9 @@ S: Supported
F: drivers/scsi/cxgbi/cxgb3i

CXGB4 CRYPTO DRIVER (chcr)
M: Atul Gupta <[email protected]>
M: Ayush Sawal <[email protected]>
M: Vinay Kumar Yadav <[email protected]>
M: Rohit Maheshwari <[email protected]>
L: [email protected]
W: http://www.chelsio.com
S: Supported
Expand Down Expand Up @@ -10066,6 +10068,7 @@ F: Documentation/devicetree/bindings/phy/phy-mvebu-utmi.txt
MARVELL CRYPTO DRIVER
M: Boris Brezillon <[email protected]>
M: Arnaud Ebalard <[email protected]>
M: Srujana Challa <[email protected]>
F: drivers/crypto/marvell/
S: Maintained
L: [email protected]
Expand Down Expand Up @@ -17139,6 +17142,18 @@ W: http://linuxtv.org
S: Maintained
F: drivers/media/pci/tw686x/

UACCE ACCELERATOR FRAMEWORK
M: Zhangfei Gao <[email protected]>
M: Zhou Wang <[email protected]>
L: [email protected]
L: [email protected]
S: Maintained
F: Documentation/ABI/testing/sysfs-driver-uacce
F: Documentation/misc-devices/uacce.rst
F: drivers/misc/uacce/
F: include/linux/uacce.h
F: include/uapi/misc/uacce/

UBI FILE SYSTEM (UBIFS)
M: Richard Weinberger <[email protected]>
L: [email protected]
Expand Down
1 change: 1 addition & 0 deletions arch/arm/crypto/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
aesbs-core.S
sha256-core.S
sha512-core.S
poly1305-core.S
1 change: 1 addition & 0 deletions arch/arm/crypto/aes-neonbs-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static int aesbs_cbc_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
kernel_neon_begin();
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
kernel_neon_end();
memzero_explicit(&rk, sizeof(rk));

return crypto_cipher_setkey(ctx->enc_tfm, in_key, key_len);
}
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/crypto/ghash-ce-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <linux/linkage.h>
#include <asm/assembler.h>

.arch armv8-a
.fpu crypto-neon-fp-armv8

SHASH .req q0
T1 .req q1
XL .req q2
Expand Down Expand Up @@ -88,8 +91,6 @@
T3_H .req d17

.text
.arch armv8-a
.fpu crypto-neon-fp-armv8

.macro __pmull_p64, rd, rn, rm, b1, b2, b3, b4
vmull.p64 \rd, \rn, \rm
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/crypto/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sha256-core.S
sha512-core.S
poly1305-core.S
1 change: 1 addition & 0 deletions arch/arm64/crypto/aes-neonbs-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static int aesbs_cbc_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
kernel_neon_begin();
aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
kernel_neon_end();
memzero_explicit(&rk, sizeof(rk));

return 0;
}
Expand Down
20 changes: 20 additions & 0 deletions arch/arm64/crypto/sha1-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,32 @@ static int sha1_ce_final(struct shash_desc *desc, u8 *out)
return sha1_base_finish(desc, out);
}

static int sha1_ce_export(struct shash_desc *desc, void *out)
{
struct sha1_ce_state *sctx = shash_desc_ctx(desc);

memcpy(out, &sctx->sst, sizeof(struct sha1_state));
return 0;
}

static int sha1_ce_import(struct shash_desc *desc, const void *in)
{
struct sha1_ce_state *sctx = shash_desc_ctx(desc);

memcpy(&sctx->sst, in, sizeof(struct sha1_state));
sctx->finalize = 0;
return 0;
}

static struct shash_alg alg = {
.init = sha1_base_init,
.update = sha1_ce_update,
.final = sha1_ce_final,
.finup = sha1_ce_finup,
.import = sha1_ce_import,
.export = sha1_ce_export,
.descsize = sizeof(struct sha1_ce_state),
.statesize = sizeof(struct sha1_state),
.digestsize = SHA1_DIGEST_SIZE,
.base = {
.cra_name = "sha1",
Expand Down
Loading

0 comments on commit 72f3542

Please sign in to comment.