Skip to contentSkip to conversation

crypto: qce - Replace with stub driver

PATCH NAK Eric Biggers 5 participants 21 messages Jul 31 – Aug 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qce - Replace with stub driver

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the CPU-based crypto (even actually using far more CPU cycles than the CPU-based crypto, due to the massive driver overhead), don't provide any security benefits over the CPU-based crypto, and have various other issues. They're also unrelated to the Inline Crypto Engine which works far better and is what is actually being used these days.

Due to the major performance problems people experienced when accidentally using this driver, the algorithms were already demoted to below the priority of ARMv8 CE in the crypto API several years ago. Regardless of priority, these algorithms also aren't compatible with the most common uses of in-kernel crypto; for example, they don't support dm-crypt because they allocate memory, and they don't support IPsec since they take a mutex which isn't compatible with softirq context.

It's time to move on and just drop this obsolete functionality entirely.

However, the driver does serve one purpose which is to bind to the devicetree node and allow the interconnects to scale down (though even that part is broken, as it holds static interconnect bandwidth votes).

Thus, clear out the crypto functionality, leaving just a stub driver that drops the interconnection bandwidth votes to zero.

Tested on the SM8650 HDK.

---
 drivers/crypto/Kconfig        | 117 +----
 drivers/crypto/qce/Makefile   |   7 -
 drivers/crypto/qce/aead.c     | 787 ----------------------------------
 drivers/crypto/qce/aead.h     |  56 ---
 drivers/crypto/qce/cipher.h   |  56 ---
 drivers/crypto/qce/common.c   | 564 ------------------------
 drivers/crypto/qce/common.h   |  94 ----
 drivers/crypto/qce/core.c     | 271 ------------
 drivers/crypto/qce/core.h     |  64 ---
 drivers/crypto/qce/dma.c      | 135 ------
 drivers/crypto/qce/dma.h      |  47 --
 drivers/crypto/qce/qcrypto.c  |  43 ++
 drivers/crypto/qce/regs-v5.h  | 322 --------------
 drivers/crypto/qce/sha.c      | 498 ---------------------
 drivers/crypto/qce/sha.h      |  71 ---
 drivers/crypto/qce/skcipher.c | 434 -------------------
 16 files changed, 50 insertions(+), 3516 deletions(-)
 delete mode 100644 drivers/crypto/qce/aead.c
 delete mode 100644 drivers/crypto/qce/aead.h
 delete mode 100644 drivers/crypto/qce/cipher.h
 delete mode 100644 drivers/crypto/qce/common.c
 delete mode 100644 drivers/crypto/qce/common.h
 delete mode 100644 drivers/crypto/qce/core.c
 delete mode 100644 drivers/crypto/qce/core.h
 delete mode 100644 drivers/crypto/qce/dma.c
 delete mode 100644 drivers/crypto/qce/dma.h
 create mode 100644 drivers/crypto/qce/qcrypto.c
 delete mode 100644 drivers/crypto/qce/regs-v5.h
 delete mode 100644 drivers/crypto/qce/sha.c
 delete mode 100644 drivers/crypto/qce/sha.h
 delete mode 100644 drivers/crypto/qce/skcipher.c
drivers/crypto/Kconfig +7 -110
index 0189dfdcbbe1..03113ad3467c 100644
@@ -527,119 +527,16 @@ source "drivers/crypto/marvell/Kconfig"
 source "drivers/crypto/intel/Kconfig"
 
 config CRYPTO_DEV_QCE
-	tristate "Qualcomm crypto engine accelerator"
-	depends on (BROKEN && ARCH_QCOM) || COMPILE_TEST
+	tristate "Qualcomm crypto engine"
+	depends on ARCH_QCOM || COMPILE_TEST
 	depends on HAS_IOMEM
 	help
-	  This driver supports Qualcomm crypto engine accelerator
-	  hardware. To compile this driver as a module, choose M here. The
-	  module will be called qcrypto.
-
-	  This driver does not have exclusive access to the
-	  hardware, causing races with the secure world.  It
-	  is also slower than the CPU.
+	  This driver provides a stub for the Qualcomm crypto engine. It exists
+	  only to bind to the devicetree node and allow interconnects to scale
+	  down, saving power. It doesn't expose any cryptographic functionality.
 
-config CRYPTO_DEV_QCE_SKCIPHER
-	bool
-	depends on CRYPTO_DEV_QCE
-	select CRYPTO_AES
-	select CRYPTO_LIB_DES
-	select CRYPTO_ECB
-	select CRYPTO_CBC
-	select CRYPTO_XTS
-	select CRYPTO_CTR
-	select CRYPTO_SKCIPHER
-
-config CRYPTO_DEV_QCE_SHA
-	bool
-	depends on CRYPTO_DEV_QCE
-	select CRYPTO_SHA1
-	select CRYPTO_SHA256
-
-config CRYPTO_DEV_QCE_AEAD
-	bool
-	depends on CRYPTO_DEV_QCE
-	select CRYPTO_AUTHENC
-	select CRYPTO_LIB_DES
-
-choice
-	prompt "Algorithms enabled for QCE acceleration"
-	default CRYPTO_DEV_QCE_ENABLE_ALL
-	depends on CRYPTO_DEV_QCE
-	help
-	  This option allows to choose whether to build support for all algorithms
-	  (default), hashes-only, or skciphers-only.
-
-	  The QCE engine does not appear to scale as well as the CPU to handle
-	  multiple crypto requests.  While the ipq40xx chips have 4-core CPUs, the
-	  QCE handles only 2 requests in parallel.
-
-	  Ipsec throughput seems to improve when disabling either family of
-	  algorithms, sharing the load with the CPU.  Enabling skciphers-only
-	  appears to work best.
-
-	config CRYPTO_DEV_QCE_ENABLE_ALL
-		bool "All supported algorithms"
-		select CRYPTO_DEV_QCE_SKCIPHER
-		select CRYPTO_DEV_QCE_SHA
-		select CRYPTO_DEV_QCE_AEAD
-		help
-		  Enable all supported algorithms:
-			- AES (CBC, CTR, ECB, XTS)
-			- 3DES (CBC, ECB)
-			- DES (CBC, ECB)
-			- SHA1, HMAC-SHA1
-			- SHA256, HMAC-SHA256
-
-	config CRYPTO_DEV_QCE_ENABLE_SKCIPHER
-		bool "Symmetric-key ciphers only"
-		select CRYPTO_DEV_QCE_SKCIPHER
-		help
-		  Enable symmetric-key ciphers only:
-			- AES (CBC, CTR, ECB, XTS)
-			- 3DES (ECB, CBC)
-			- DES (ECB, CBC)
-
-	config CRYPTO_DEV_QCE_ENABLE_SHA
-		bool "Hash/HMAC only"
-		select CRYPTO_DEV_QCE_SHA
-		help
-		  Enable hashes/HMAC algorithms only:
-			- SHA1, HMAC-SHA1
-			- SHA256, HMAC-SHA256
-
-	config CRYPTO_DEV_QCE_ENABLE_AEAD
-		bool "AEAD algorithms only"
-		select CRYPTO_DEV_QCE_AEAD
-		help
-		  Enable AEAD algorithms only:
-			- authenc()
-			- ccm(aes)
-			- rfc4309(ccm(aes))
-endchoice
-
-config CRYPTO_DEV_QCE_SW_MAX_LEN
-	int "Default maximum request size to use software for AES"
-	depends on CRYPTO_DEV_QCE && CRYPTO_DEV_QCE_SKCIPHER
-	default 512
-	help
-	  This sets the default maximum request size to perform AES requests
-	  using software instead of the crypto engine.  It can be changed by
-	  setting the aes_sw_max_len parameter.
-
-	  Small blocks are processed faster in software than hardware.
-	  Considering the 256-bit ciphers, software is 2-3 times faster than
-	  qce at 256-bytes, 30% faster at 512, and about even at 768-bytes.
-	  With 128-bit keys, the break-even point would be around 1024-bytes.
-
-	  The default is set a little lower, to 512 bytes, to balance the
-	  cost in CPU usage.  The minimum recommended setting is 16-bytes
-	  (1 AES block), since AES-GCM will fail if you set it lower.
-	  Setting this to zero will send all requests to the hardware.
-
-	  Note that 192-bit keys are not supported by the hardware and are
-	  always processed by the software fallback, and all DES requests
-	  are done by the hardware.
+	  To compile this driver as a module, choose M here. The
+	  module will be called qcrypto.
 
 config CRYPTO_DEV_IMGTEC_HASH
 	tristate "Imagination Technologies hardware hash accelerator"
drivers/crypto/qce/Makefile +0 -7
index 2cf8984e1b85..c1606b34f9ca 100644
@@ -1,9 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CRYPTO_DEV_QCE) += qcrypto.o
-qcrypto-objs := core.o \
-		common.o \
-		dma.o
-
-qcrypto-$(CONFIG_CRYPTO_DEV_QCE_SHA) += sha.o
-qcrypto-$(CONFIG_CRYPTO_DEV_QCE_SKCIPHER) += skcipher.o
-qcrypto-$(CONFIG_CRYPTO_DEV_QCE_AEAD) += aead.o
drivers/crypto/qce/aead.c deleted +0 -787

787 lines not on this page · raw message

drivers/crypto/qce/aead.h deleted +0 -56

56 lines not on this page · raw message

drivers/crypto/qce/cipher.h deleted +0 -56

56 lines not on this page · raw message

drivers/crypto/qce/common.c deleted +0 -564

564 lines not on this page · raw message

drivers/crypto/qce/common.h deleted +0 -94

94 lines not on this page · raw message

drivers/crypto/qce/core.c deleted +0 -271

271 lines not on this page · raw message

drivers/crypto/qce/core.h deleted +0 -64

64 lines not on this page · raw message

drivers/crypto/qce/dma.c deleted +0 -135

135 lines not on this page · raw message

drivers/crypto/qce/dma.h deleted +0 -47

47 lines not on this page · raw message

drivers/crypto/qce/qcrypto.c new file +43 -0

43 lines not on this page · raw message

drivers/crypto/qce/regs-v5.h deleted +0 -322

322 lines not on this page · raw message

drivers/crypto/qce/sha.c deleted +0 -498

426 lines not on this page · raw message

drivers/crypto/qce/sha.h deleted +0 -71

71 lines not on this page · raw message

drivers/crypto/qce/skcipher.c deleted +0 -434

434 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

base-commit: a264cb967dbdbf9544c4de80e2f7188214b93f77

Signature · 1 line
2.55.0

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 22 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the CPU-based crypto (even actually using far more CPU cycles than the CPU-based crypto, due to the massive driver overhead), don't provide any security benefits over the CPU-based crypto, and have various other issues. They're also unrelated to the Inline Crypto Engine which works far better and is what is actually being used these days.

Due to the major performance problems people experienced when accidentally using this driver, the algorithms were already demoted to below the priority of ARMv8 CE in the crypto API several years ago. Regardless of priority, these algorithms also aren't compatible with the most common uses of in-kernel crypto; for example, they don't support dm-crypt because they allocate memory, and they don't support IPsec since they take a mutex which isn't compatible with softirq context.

It's time to move on and just drop this obsolete functionality entirely.

However, the driver does serve one purpose which is to bind to the devicetree node and allow the interconnects to scale down (though even that part is broken, as it holds static interconnect bandwidth votes).

Quoted 6 lines

Thus, clear out the crypto functionality, leaving just a stub driver that drops the interconnection bandwidth votes to zero.

Tested on the SM8650 HDK.

Some thoughts:

1. Should this be put under a different subdirectory? This is now a power management driver, not a crypto driver. IMO it should just fall under ARCH_QCOM, without a separate Kconfig entry (or at least a "default y" one).

2. Should it be re-added to the defconfigs? Most distros will want to turn it on, as it saves power and is minuscule.

3. Will this the smallest driver in the whole kernel?

Quoted 47 lines
---
 drivers/crypto/Kconfig        | 117 +----
 drivers/crypto/qce/Makefile   |   7 -
 drivers/crypto/qce/aead.c     | 787 ----------------------------------
 drivers/crypto/qce/aead.h     |  56 ---
 drivers/crypto/qce/cipher.h   |  56 ---
 drivers/crypto/qce/common.c   | 564 ------------------------
 drivers/crypto/qce/common.h   |  94 ----
 drivers/crypto/qce/core.c     | 271 ------------
 drivers/crypto/qce/core.h     |  64 ---
 drivers/crypto/qce/dma.c      | 135 ------
 drivers/crypto/qce/dma.h      |  47 --
 drivers/crypto/qce/qcrypto.c  |  43 ++
 drivers/crypto/qce/regs-v5.h  | 322 --------------
 drivers/crypto/qce/sha.c      | 498 ---------------------
 drivers/crypto/qce/sha.h      |  71 ---
 drivers/crypto/qce/skcipher.c | 434 -------------------
 16 files changed, 50 insertions(+), 3516 deletions(-)
 delete mode 100644 drivers/crypto/qce/aead.c
 delete mode 100644 drivers/crypto/qce/aead.h
 delete mode 100644 drivers/crypto/qce/cipher.h
 delete mode 100644 drivers/crypto/qce/common.c
 delete mode 100644 drivers/crypto/qce/common.h
 delete mode 100644 drivers/crypto/qce/core.c
 delete mode 100644 drivers/crypto/qce/core.h
 delete mode 100644 drivers/crypto/qce/dma.c
 delete mode 100644 drivers/crypto/qce/dma.h
 create mode 100644 drivers/crypto/qce/qcrypto.c
 delete mode 100644 drivers/crypto/qce/regs-v5.h
 delete mode 100644 drivers/crypto/qce/sha.c
 delete mode 100644 drivers/crypto/qce/sha.h
 delete mode 100644 drivers/crypto/qce/skcipher.c
drivers/crypto/Kconfig +2 -2
index 0189dfdcbbe1..03113ad3467c 100644
@@ -527,119 +527,16 @@ source "drivers/crypto/marvell/Kconfig"
 source "drivers/crypto/intel/Kconfig"
 
 config CRYPTO_DEV_QCE
-	tristate "Qualcomm crypto engine accelerator"
-	depends on (BROKEN && ARCH_QCOM) || COMPILE_TEST
+	tristate "Qualcomm crypto engine"
+	depends on ARCH_QCOM || COMPILE_TEST
 	depends on HAS_IOMEM
 	help

drivers/crypto/Kconfig source "drivers/crypto/marvell/Kconfig" · line 536

Quoted 10 lines
drivers/crypto/Kconfig +3 -7
-	  This driver supports Qualcomm crypto engine accelerator
-	  hardware. To compile this driver as a module, choose M here. The
-	  module will be called qcrypto.
-
-	  This driver does not have exclusive access to the
-	  hardware, causing races with the secure world.  It
-	  is also slower than the CPU.
+	  This driver provides a stub for the Qualcomm crypto engine. It exists
+	  only to bind to the devicetree node and allow interconnects to scale
+	  down, saving power. It doesn't expose any cryptographic functionality.

Should this mention why the cryptographic functionality available in the hardware has been proven unsuitable for use?

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
maintainer Nacked-by on v1 1/1 NAK
#2 lore raw
In reply to Eric Biggers
Quoted 22 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the CPU-based crypto (even actually using far more CPU cycles than the CPU-based crypto, due to the massive driver overhead), don't provide any security benefits over the CPU-based crypto, and have various other issues. They're also unrelated to the Inline Crypto Engine which works far better and is what is actually being used these days.

Due to the major performance problems people experienced when accidentally using this driver, the algorithms were already demoted to below the priority of ARMv8 CE in the crypto API several years ago. Regardless of priority, these algorithms also aren't compatible with the most common uses of in-kernel crypto; for example, they don't support dm-crypt because they allocate memory, and they don't support IPsec since they take a mutex which isn't compatible with softirq context.

It's time to move on and just drop this obsolete functionality entirely.

However, the driver does serve one purpose which is to bind to the devicetree node and allow the interconnects to scale down (though even that part is broken, as it holds static interconnect bandwidth votes).

Quoted 7 lines

Thus, clear out the crypto functionality, leaving just a stub driver that drops the interconnection bandwidth votes to zero.

Tested on the SM8650 HDK.

---

I'll be on vacation for most of August so my lack of responses won't mean I no longer care, only that I'm disconnected. Let me just leave this here for completness:

I don't understand why the push to fast track the removal of this driver now, when there's clearly an effort to get it fixed from the vendor itself. I've also never seen a driver for an IP on a supported platform being removed from mainline linux.

Thanks,
Bartosz

Nacked-by on v1 1/1 NAK
#3 lore raw
In reply to Eric Biggers
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

NAK

[1] https://lore.kernel.org/all/20260728152241.GA4281@quark/
[2] https://lore.kernel.org/all/[email protected]/

Quoted 14 lines

CPU-based crypto (even actually using far more CPU cycles than the CPU-based crypto, due to the massive driver overhead), don't provide any security benefits over the CPU-based crypto, and have various other issues. They're also unrelated to the Inline Crypto Engine which works far better and is what is actually being used these days.

Due to the major performance problems people experienced when accidentally using this driver, the algorithms were already demoted to below the priority of ARMv8 CE in the crypto API several years ago. Regardless of priority, these algorithms also aren't compatible with the most common uses of in-kernel crypto; for example, they don't support dm-crypt because they allocate memory, and they don't support IPsec since they take a mutex which isn't compatible with softirq context.

Quoted 1 line

It's time to move on and just drop this obsolete functionality entirely.

Best regards,
Krzysztof

#4 lore raw
Quoted 6 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Note that the crypto maintainer has already accepted a patch from another developer to mark this driver as BROKEN.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

"The community" is more than the hardware vendor.

I think the results of independent testing of this driver are incredibly clear. The pending fixes do not fix the performance either, but actually make it worse.

I have been asking for the inclusion of this driver to be justified for many years. As far as I've ever been able to tell it's just a "checkbox feature", which isn't something that really belongs upstream.

I care about the technical merit of the kernel's cryptographic algorithm implementations.

- Eric

#5 lore raw
In reply to Krzysztof Kozlowski
Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Quoted 8 lines

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

A stub driver needs to be added for power management reasons. It turns out that if there is no driver, power consumption is very high.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

I trust that Bartosz can fix the driver with enough work. However, even if the QCE driver had never had a single bug, it would still not be worth using. Its performance is so poor that one should always use CPU-based crypto instead. In the default configuration, that is in fact what happens.

The QCE's algorithm implementations only provide a way people can misconfigure their systems and ruin their performance. There are debug options that also severely harm performance, but they have legitimate uses during development. The current QCE driver doesn't.

I have no problem with a driver for the QCE that does something actually useful. While there are disagreements about whether restricted media processing is a feature or an anti-feature, my view is that it is better for it to be implemented upstream than in an out-of-tree driver. However, the driver as it currently exists does not implement this.

I expect that such a driver would not use the crypto API at all. Instead, I suspect it would use dmabufs for source and destination buffers and integrate with the secure world firmware in some way. That means that the driver doesn't belong under drivers/crypto.

These are the reasons I submitted a patch to mark the driver as BROKEN, which Herbert Xu has since accepted.

Quoted 26 lines

NAK

[1] https://lore.kernel.org/all/20260728152241.GA4281@quark/
[2] https://lore.kernel.org/all/[email protected]/

Quoted 14 lines

CPU-based crypto (even actually using far more CPU cycles than the CPU-based crypto, due to the massive driver overhead), don't provide any security benefits over the CPU-based crypto, and have various other issues. They're also unrelated to the Inline Crypto Engine which works far better and is what is actually being used these days.

Due to the major performance problems people experienced when accidentally using this driver, the algorithms were already demoted to below the priority of ARMv8 CE in the crypto API several years ago. Regardless of priority, these algorithms also aren't compatible with the most common uses of in-kernel crypto; for example, they don't support dm-crypt because they allocate memory, and they don't support IPsec since they take a mutex which isn't compatible with softirq context.

Quoted 1 line

It's time to move on and just drop this obsolete functionality entirely.

Best regards,
Krzysztof

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#6 lore raw
Quoted 40 lines · Demi Marie Obenour
Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Quoted 8 lines

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

A stub driver needs to be added for power management reasons. It turns out that if there is no driver, power consumption is very high.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

I trust that Bartosz can fix the driver with enough work. However, even if the QCE driver had never had a single bug, it would still not be worth using. Its performance is so poor that one should always use CPU-based crypto instead. In the default configuration, that is in fact what happens.

The QCE's algorithm implementations only provide a way people can misconfigure their systems and ruin their performance. There are debug options that also severely harm performance, but they have legitimate uses during development. The current QCE driver doesn't.

I have no problem with a driver for the QCE that does something actually useful. While there are disagreements about whether restricted media processing is a feature or an anti-feature, my view is that it is better for it to be implemented upstream than in an out-of-tree driver. However, the driver as it currently exists does not implement this.

Quoted 7 lines

I expect that such a driver would not use the crypto API at all. Instead, I suspect it would use dmabufs for source and destination buffers and integrate with the secure world firmware in some way. That means that the driver doesn't belong under drivers/crypto.

These are the reasons I submitted a patch to mark the driver as BROKEN, which Herbert Xu has since accepted.

And Bartosz and other people committed to work on this by improving, fixing and in the long term providing you with the actual important user of this. All this was already said.

And then after having all these discussions Eric sends AGAIN patch to remove the driver. How many times this will have to be discussed the same way? If we now reach agreement the driver stays, next month again there will be a patch to remove it? And then one more month again?

The driver is marked as BROKEN, thus absolutely NO ONE is affected by any issues the driver has.

It's some personal vendetta to keep coming after that - unimportant now
- driver.

Best regards,
Krzysztof

#7 lore raw
Quoted 58 lines · Krzysztof Kozlowski
Quoted 40 lines · Demi Marie Obenour
Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Quoted 8 lines

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

A stub driver needs to be added for power management reasons. It turns out that if there is no driver, power consumption is very high.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

I trust that Bartosz can fix the driver with enough work. However, even if the QCE driver had never had a single bug, it would still not be worth using. Its performance is so poor that one should always use CPU-based crypto instead. In the default configuration, that is in fact what happens.

The QCE's algorithm implementations only provide a way people can misconfigure their systems and ruin their performance. There are debug options that also severely harm performance, but they have legitimate uses during development. The current QCE driver doesn't.

I have no problem with a driver for the QCE that does something actually useful. While there are disagreements about whether restricted media processing is a feature or an anti-feature, my view is that it is better for it to be implemented upstream than in an out-of-tree driver. However, the driver as it currently exists does not implement this.

Quoted 7 lines

I expect that such a driver would not use the crypto API at all. Instead, I suspect it would use dmabufs for source and destination buffers and integrate with the secure world firmware in some way. That means that the driver doesn't belong under drivers/crypto.

These are the reasons I submitted a patch to mark the driver as BROKEN, which Herbert Xu has since accepted.

And Bartosz and other people committed to work on this by improving, fixing and in the long term providing you with the actual important user of this. All this was already said.

And then after having all these discussions Eric sends AGAIN patch to remove the driver. How many times this will have to be discussed the same way? If we now reach agreement the driver stays, next month again there will be a patch to remove it? And then one more month again?

Quoted 5 lines

The driver is marked as BROKEN, thus absolutely NO ONE is affected by any issues the driver has.

It's some personal vendetta to keep coming after that - unimportant now
- driver.

Well, there was also feedback that BROKEN drivers should not stay in the tree and instead just be removed. So I was considering that feedback too, as well as the results of additional testing and review of this driver, including evidence that the driver performs even worse than thought and is actually getting even worse; the performance seems irredeemable. As for proposing the stub driver, that is addressing the power management issue that was mentioned on the other thread.

Anyway, it sounds like you support it being BROKEN. Okay, but again, as Greg mentioned
(https://lore.kernel.org/linux-crypto/2026071312-uncover-refining-8cac@gregkh/)
it is awkward to have BROKEN stuff in the tree since it cannot even be built. I'm not sure we can have it both ways!

- Eric

#8 lore raw
Quoted 73 lines · Eric Biggers
Quoted 58 lines · Krzysztof Kozlowski
Quoted 40 lines · Demi Marie Obenour
Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Quoted 8 lines

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

A stub driver needs to be added for power management reasons. It turns out that if there is no driver, power consumption is very high.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

I trust that Bartosz can fix the driver with enough work. However, even if the QCE driver had never had a single bug, it would still not be worth using. Its performance is so poor that one should always use CPU-based crypto instead. In the default configuration, that is in fact what happens.

The QCE's algorithm implementations only provide a way people can misconfigure their systems and ruin their performance. There are debug options that also severely harm performance, but they have legitimate uses during development. The current QCE driver doesn't.

I have no problem with a driver for the QCE that does something actually useful. While there are disagreements about whether restricted media processing is a feature or an anti-feature, my view is that it is better for it to be implemented upstream than in an out-of-tree driver. However, the driver as it currently exists does not implement this.

Quoted 7 lines

I expect that such a driver would not use the crypto API at all. Instead, I suspect it would use dmabufs for source and destination buffers and integrate with the secure world firmware in some way. That means that the driver doesn't belong under drivers/crypto.

These are the reasons I submitted a patch to mark the driver as BROKEN, which Herbert Xu has since accepted.

And Bartosz and other people committed to work on this by improving, fixing and in the long term providing you with the actual important user of this. All this was already said.

And then after having all these discussions Eric sends AGAIN patch to remove the driver. How many times this will have to be discussed the same way? If we now reach agreement the driver stays, next month again there will be a patch to remove it? And then one more month again?

Quoted 5 lines

The driver is marked as BROKEN, thus absolutely NO ONE is affected by any issues the driver has.

It's some personal vendetta to keep coming after that - unimportant now
- driver.

Well, there was also feedback that BROKEN drivers should not stay in the tree and instead just be removed. So I was considering that feedback too, as well as the results of additional testing and review of this driver, including evidence that the driver performs even worse than thought and is actually getting even worse; the performance seems irredeemable. As for proposing the stub driver, that is addressing the power management issue that was mentioned on the other thread.

Quoted 5 lines

Anyway, it sounds like you support it being BROKEN. Okay, but again, as Greg mentioned
(https://lore.kernel.org/linux-crypto/2026071312-uncover-refining-8cac@gregkh/)
it is awkward to have BROKEN stuff in the tree since it cannot even be built. I'm not sure we can have it both ways!

Which was I think pointed already a few times that it will not stay BROKEN but will get fixed and get proper useful use cases.

Best regards,
Krzysztof

#9 lore raw
Quoted 74 lines · Krzysztof Kozlowski
Quoted 73 lines · Eric Biggers
Quoted 58 lines · Krzysztof Kozlowski
Quoted 40 lines · Demi Marie Obenour
Quoted 7 lines · Krzysztof Kozlowski
Quoted 2 lines · Eric Biggers

None of the algorithms the QCE driver registers with the crypto API are even close to being useful. They're massively outperformed by the

The amount of patches you send towards removal of QCE is really stunning. Or rather worrying. This is like third approach or so.

Quoted 8 lines

Your previous approaches received valid feedback, including even fixes and committment of new maintainer.

But you even complained that it does receive fixes! [1]

We removed the driver temporarily from typical configurations, so no one will be affected, by whatever is found now and not yet fixed. Still not enough! For you this was reason to remove the driver (AGAIN!) [2]

A stub driver needs to be added for power management reasons. It turns out that if there is no driver, power consumption is very high.

Quoted 2 lines

This is beyond comprehension and very unpleasant, because you actively work against the community with this approach.

I trust that Bartosz can fix the driver with enough work. However, even if the QCE driver had never had a single bug, it would still not be worth using. Its performance is so poor that one should always use CPU-based crypto instead. In the default configuration, that is in fact what happens.

The QCE's algorithm implementations only provide a way people can misconfigure their systems and ruin their performance. There are debug options that also severely harm performance, but they have legitimate uses during development. The current QCE driver doesn't.

I have no problem with a driver for the QCE that does something actually useful. While there are disagreements about whether restricted media processing is a feature or an anti-feature, my view is that it is better for it to be implemented upstream than in an out-of-tree driver. However, the driver as it currently exists does not implement this.

Quoted 7 lines

I expect that such a driver would not use the crypto API at all. Instead, I suspect it would use dmabufs for source and destination buffers and integrate with the secure world firmware in some way. That means that the driver doesn't belong under drivers/crypto.

These are the reasons I submitted a patch to mark the driver as BROKEN, which Herbert Xu has since accepted.

And Bartosz and other people committed to work on this by improving, fixing and in the long term providing you with the actual important user of this. All this was already said.

And then after having all these discussions Eric sends AGAIN patch to remove the driver. How many times this will have to be discussed the same way? If we now reach agreement the driver stays, next month again there will be a patch to remove it? And then one more month again?

Quoted 5 lines

The driver is marked as BROKEN, thus absolutely NO ONE is affected by any issues the driver has.

It's some personal vendetta to keep coming after that - unimportant now
- driver.

Well, there was also feedback that BROKEN drivers should not stay in the tree and instead just be removed. So I was considering that feedback too, as well as the results of additional testing and review of this driver, including evidence that the driver performs even worse than thought and is actually getting even worse; the performance seems irredeemable. As for proposing the stub driver, that is addressing the power management issue that was mentioned on the other thread.

Quoted 8 lines
Quoted 5 lines

Anyway, it sounds like you support it being BROKEN. Okay, but again, as Greg mentioned
(https://lore.kernel.org/linux-crypto/2026071312-uncover-refining-8cac@gregkh/)
it is awkward to have BROKEN stuff in the tree since it cannot even be built. I'm not sure we can have it both ways!

Which was I think pointed already a few times that it will not stay BROKEN but will get fixed and get proper useful use cases.

Well, that again brings us back to the core issue which is the actual current functionality of the driver, which is to register crypto_ahash, crypto_skcipher, and crypto_aead algorithms with the crypto API.

It isn't useful functionality, but rather just a footgun that allows users to misconfigure their systems, an issue I've seen happen multiple times. CPU-based implementations of *every one* of those algorithms already exist. On a typical SoC that has this hardware, the CPU-based implementations are ~50x faster as shown in tests. Pending patches make the difference even greater at ~100x. And the CPU-based implementations actually use significantly less CPU time, as well. There seems to be no path forward for significantly fixing this issue, either.

Then, if these algorithms are removed, the rest of the code in the driver (besides setting the interconnect bandwidth) becomes unused. The policy in the kernel for dead code is that it should be removed. So that is why it makes sense to drop that code as well, but really the core issue is the crypto algorithm registrations, not the supporting code per se.

An alternative we could consider is dropping the cra_priority further, to further decrease the chance that these algorithms are used. But I feel it's hard to justify why they're there at all, if the rationale for keeping them is "we made sure that no one can actually use them, so they can't be causing problems anymore"...

- Eric

#10 lore raw
Quoted 4 lines · Eric Biggers

Well, that again brings us back to the core issue which is the actual current functionality of the driver, which is to register crypto_ahash, crypto_skcipher, and crypto_aead algorithms with the crypto API.

Quoted 9 lines

It isn't useful functionality, but rather just a footgun that allows users to misconfigure their systems, an issue I've seen happen multiple times. CPU-based implementations of *every one* of those algorithms already exist. On a typical SoC that has this hardware, the CPU-based implementations are ~50x faster as shown in tests. Pending patches make the difference even greater at ~100x. And the CPU-based implementations actually use significantly less CPU time, as well. There seems to be no path forward for significantly fixing this issue, either.

You've repeated your point about performance several times. Nobody ever said you're wrong. Performance is not the only reason for choosing one provider over another.

Quoted 6 lines

An alternative we could consider is dropping the cra_priority further, to further decrease the chance that these algorithms are used. But I feel it's hard to justify why they're there at all, if the rationale for keeping them is "we made sure that no one can actually use them, so they can't be causing problems anymore"...

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

As I've said before: we don't just drop maintained drivers from linux.

Herbert: it's been a while, would you mind chiming in and deciding one way or the other, as Greg seems to have deferred to your judgement?

Thanks,
Bartosz

#11 lore raw
Quoted 16 lines · Bartosz Golaszewski
Quoted 4 lines · Eric Biggers

Well, that again brings us back to the core issue which is the actual current functionality of the driver, which is to register crypto_ahash, crypto_skcipher, and crypto_aead algorithms with the crypto API.

Quoted 9 lines

It isn't useful functionality, but rather just a footgun that allows users to misconfigure their systems, an issue I've seen happen multiple times. CPU-based implementations of *every one* of those algorithms already exist. On a typical SoC that has this hardware, the CPU-based implementations are ~50x faster as shown in tests. Pending patches make the difference even greater at ~100x. And the CPU-based implementations actually use significantly less CPU time, as well. There seems to be no path forward for significantly fixing this issue, either.

Quoted 3 lines

You've repeated your point about performance several times. Nobody ever said you're wrong. Performance is not the only reason for choosing one provider over another.

That isn't a very practical viewpoint for the in-kernel crypto use cases, where performance tends to be critical and users will do a lot to get even a few percent improvement, let alone 10000%! But as Demi and I have explained, even if the performance aspect is ignored the driver still isn't worth it, for multiple other reasons.

Also, you did give saving CPU cycles as a reason earlier
(https://lore.kernel.org/linux-crypto/CAMRc=Me55rUmjjR+ZzdWd2ss9JJMZzJch0zKd4GqONBjCzFMYQ@mail.gmail.com/).
That's one of the reasons I actually tested it and responded to that. It sounds like you've now walked back your claim. So great, we seem to be on the same page regarding that point now.

Quoted 7 lines
Quoted 6 lines

An alternative we could consider is dropping the cra_priority further, to further decrease the chance that these algorithms are used. But I feel it's hard to justify why they're there at all, if the rationale for keeping them is "we made sure that no one can actually use them, so they can't be causing problems anymore"...

Quoted 5 lines

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

As I've said before: we don't just drop maintained drivers from linux.

We definitely do if the drivers are not useful or appropriate for inclusion in the kernel, though the policy varies by subsystem. Even just last month an entire filesystem got dropped despite someone wanting to maintain it.

- Eric

#12 lore raw
Quoted 6 lines · Eric Biggers
Quoted 4 lines · Bartosz Golaszewski

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

Quoted 7 lines
Quoted 1 line

As I've said before: we don't just drop maintained drivers from linux.

We definitely do if the drivers are not useful or appropriate for inclusion in the kernel, though the policy varies by subsystem. Even just last month an entire filesystem got dropped despite someone wanting to maintain it.

I suppose you're talking about EFS? A thing that can't even be tested on real hardware? This is a much more extreme case. Here you have several people representing the vendor saying they want to keep and maintain it. I'm fine having my own tree and sending PRs to Herbert if he agrees and you are of course entirely free to disregard any patches targetting it.

Thanks,
Bartosz

#13 lore raw
Quoted 15 lines · Bartosz Golaszewski
Quoted 6 lines · Eric Biggers
Quoted 4 lines · Bartosz Golaszewski

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

Quoted 7 lines
Quoted 1 line

As I've said before: we don't just drop maintained drivers from linux.

We definitely do if the drivers are not useful or appropriate for inclusion in the kernel, though the policy varies by subsystem. Even just last month an entire filesystem got dropped despite someone wanting to maintain it.

Quoted 5 lines

I suppose you're talking about EFS? A thing that can't even be tested on real hardware? This is a much more extreme case. Here you have several people representing the vendor saying they want to keep and maintain it. I'm fine having my own tree and sending PRs to Herbert if he agrees and you are of course entirely free to disregard any patches targetting it.

Would you be okay with one of these options?

1. Make the stub driver as the default, with
the real driver guarded by an off-by-default Kconfig option.

2. Keep the driver as is (with the power management issue fixed), but don't register any algorithm implementations with the crypto API.

3. Only register algorithm implementations with the crypto API if a non-default Kconfig option is selected.

4. Only register algorithm implementations with the crypto API if a non-default module parameter is selected.

5. Move the driver out of drivers/crypto, delete the algorithm registrations, and then add support for restricted media content decryption later.

The last option would be my preferred one.

Also, if Qualcomm has customers who use the QCE via the crypto API, is Qualcomm aware of _why_ they made that choice? From Eric's and my perspective, that seems like a very strange decision, unless there are factors that Eric and I are not aware of.

Finally, would you be willing to have a group call to discuss this at some point? That might be a more suitable venue for this kind of discussion, and could potentially lead to a conclusion faster. Also, while at least I couldn't sign any NDAs, there might be information that you could discuss there that you cannot post to a public mailing list.

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#14 lore raw
Quoted 33 lines · Demi Marie Obenour
Quoted 15 lines · Bartosz Golaszewski
Quoted 6 lines · Eric Biggers
Quoted 4 lines · Bartosz Golaszewski

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

Quoted 7 lines
Quoted 1 line

As I've said before: we don't just drop maintained drivers from linux.

We definitely do if the drivers are not useful or appropriate for inclusion in the kernel, though the policy varies by subsystem. Even just last month an entire filesystem got dropped despite someone wanting to maintain it.

Quoted 5 lines

I suppose you're talking about EFS? A thing that can't even be tested on real hardware? This is a much more extreme case. Here you have several people representing the vendor saying they want to keep and maintain it. I'm fine having my own tree and sending PRs to Herbert if he agrees and you are of course entirely free to disregard any patches targetting it.

Would you be okay with one of these options?

1. Make the stub driver as the default, with
the real driver guarded by an off-by-default Kconfig option.

2. Keep the driver as is (with the power management issue fixed), but don't register any algorithm implementations with the crypto API.

3. Only register algorithm implementations with the crypto API if a non-default Kconfig option is selected.

Quoted 9 lines

4. Only register algorithm implementations with the crypto API if a non-default module parameter is selected.

5. Move the driver out of drivers/crypto, delete the algorithm registrations, and then add support for restricted media content decryption later.

The last option would be my preferred one.

I actually have a slightly different spin on the stub driver. I'd like to keep the driver future-proof and avoid all kinds of needless churn when we do get to the secure dma bufs and restricted media playback (and we will get there eventually :) ).

Can we make the QCE into an MFD driver with the core binding to the DT node and handling the interconnect bandwidth, while the part handling crypto algorithms becomes its cell and is moved into a separate module? This one can be disabled in defconfig by default and I don't even mind it being guarded with CONFIG_EXPERT. The core module would remain in arm64 defconfig.

With that: any future extensions providing support for more functionalities of this IP can simply be implemented as more MFD cells while we can also keep chipping away at the existing code and use it for testing the BAM pipe locking.

Quoted 5 lines

Also, if Qualcomm has customers who use the QCE via the crypto API, is Qualcomm aware of _why_ they made that choice? From Eric's and my perspective, that seems like a very strange decision, unless there are factors that Eric and I are not aware of.

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

Quoted 5 lines

Finally, would you be willing to have a group call to discuss this at some point? That might be a more suitable venue for this kind of discussion, and could potentially lead to a conclusion faster. Also, while at least I couldn't sign any NDAs, there might be information that you could discuss there that you cannot post to a public mailing list.

Sure, I'm fine to have a call. If you think about coming to Linux Plumbers this year, I'll be there all week and it's a good place for such a discussion too.

FYI I've only been online for a couple days this week and I'm going offline again until the end of August with the exception of August 26th when I'll be able to chime in again. Any call would too have to happen in September at the earliest.

Thanks,
Bartosz

#15 lore raw
Quoted 56 lines · Bartosz Golaszewski
Quoted 33 lines · Demi Marie Obenour
Quoted 15 lines · Bartosz Golaszewski
Quoted 6 lines · Eric Biggers
Quoted 4 lines · Bartosz Golaszewski

No, the rationale has never been this. FWIW it can be that it's used for testing of the crypto module on a supported platform and that is already enough of a reason to keep it upstream.

Quoted 7 lines
Quoted 1 line

As I've said before: we don't just drop maintained drivers from linux.

We definitely do if the drivers are not useful or appropriate for inclusion in the kernel, though the policy varies by subsystem. Even just last month an entire filesystem got dropped despite someone wanting to maintain it.

Quoted 5 lines

I suppose you're talking about EFS? A thing that can't even be tested on real hardware? This is a much more extreme case. Here you have several people representing the vendor saying they want to keep and maintain it. I'm fine having my own tree and sending PRs to Herbert if he agrees and you are of course entirely free to disregard any patches targetting it.

Would you be okay with one of these options?

1. Make the stub driver as the default, with
the real driver guarded by an off-by-default Kconfig option.

2. Keep the driver as is (with the power management issue fixed), but don't register any algorithm implementations with the crypto API.

3. Only register algorithm implementations with the crypto API if a non-default Kconfig option is selected.

Quoted 9 lines

4. Only register algorithm implementations with the crypto API if a non-default module parameter is selected.

5. Move the driver out of drivers/crypto, delete the algorithm registrations, and then add support for restricted media content decryption later.

The last option would be my preferred one.

I actually have a slightly different spin on the stub driver. I'd like to keep the driver future-proof and avoid all kinds of needless churn when we do get to the secure dma bufs and restricted media playback (and we will get there eventually :) ).

Can we make the QCE into an MFD driver with the core binding to the DT node and handling the interconnect bandwidth, while the part handling crypto algorithms becomes its cell and is moved into a separate module? This one can be disabled in defconfig by default and I don't even mind it being guarded with CONFIG_EXPERT. The core module would remain in arm64 defconfig.

Quoted 3 lines

With that: any future extensions providing support for more functionalities of this IP can simply be implemented as more MFD cells while we can also keep chipping away at the existing code and use it for testing the BAM pipe locking.

I'm not familiar with MFD drivers, but this sounds like the best of both worlds. The driver stays upstream, but anyone who doesn't explicitly need it can ignore it.

Quoted 9 lines
Quoted 5 lines

Also, if Qualcomm has customers who use the QCE via the crypto API, is Qualcomm aware of _why_ they made that choice? From Eric's and my perspective, that seems like a very strange decision, unless there are factors that Eric and I are not aware of.

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

That sounds like the kind of thing that would cause someone to use a worse implementation of cryptographic algorithms 🙂.

For what it is worth, many common uses of kernel cryptography can't use the QCE. This notably applies to the CSPRNG (/dev/urandom etc), storage encryption, and AF_ALG. Therefore, I expect that anyone who needs FIPS 140 compliance with Linux needs to ensure that the software crypto is certified, as that's what actually gets used in most cases.

Quoted 6 lines
Quoted 5 lines

Finally, would you be willing to have a group call to discuss this at some point? That might be a more suitable venue for this kind of discussion, and could potentially lead to a conclusion faster. Also, while at least I couldn't sign any NDAs, there might be information that you could discuss there that you cannot post to a public mailing list.

Quoted 7 lines

Sure, I'm fine to have a call. If you think about coming to Linux Plumbers this year, I'll be there all week and it's a good place for such a discussion too.

FYI I've only been online for a couple days this week and I'm going offline again until the end of August with the exception of August 26th when I'll be able to chime in again. Any call would too have to happen in September at the earliest.

That's fine.

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#16 lore raw
Quoted 4 lines · Demi Marie Obenour
Quoted 3 lines

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

Quoted 8 lines

That sounds like the kind of thing that would cause someone to use a worse implementation of cryptographic algorithms 🙂.

For what it is worth, many common uses of kernel cryptography can't use the QCE. This notably applies to the CSPRNG (/dev/urandom etc), storage encryption, and AF_ALG. Therefore, I expect that anyone who needs FIPS 140 compliance with Linux needs to ensure that the software crypto is certified, as that's what actually gets used in most cases.

Well there's that, and also the Inline Crypto Engine (which is actually being used and is unrelated to QCE) has its own FIPS certification.

Which upstream kernel feature, if any, is QCE being used with? I have asked this multiple times and still not gotten an answer.

Does the perceived value perhaps come merely from "offering" FIPS certified cryptography on the system -- then not actually using it in practice? That can maybe be understandable in some cases, but it's also not really something that belongs upstream where actual technical merit is expected. Also, could ICE be enough to check that checkbox?

- Eric

#17 lore raw
Quoted 14 lines · Eric Biggers
Quoted 4 lines · Demi Marie Obenour
Quoted 3 lines

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

Quoted 8 lines

That sounds like the kind of thing that would cause someone to use a worse implementation of cryptographic algorithms 🙂.

For what it is worth, many common uses of kernel cryptography can't use the QCE. This notably applies to the CSPRNG (/dev/urandom etc), storage encryption, and AF_ALG. Therefore, I expect that anyone who needs FIPS 140 compliance with Linux needs to ensure that the software crypto is certified, as that's what actually gets used in most cases.

Quoted 5 lines

Well there's that, and also the Inline Crypto Engine (which is actually being used and is unrelated to QCE) has its own FIPS certification.

Which upstream kernel feature, if any, is QCE being used with? I have asked this multiple times and still not gotten an answer.

Historically AF_ALG has been used to access FIPS-certified crypto from userspace, but that no longer can be used with QCE. Most kernel features reject CRYPTO_ALG_ASYNC, CRYPTO_ALG_ALLOCATES_MEMORY, or both. If I exclude tests and fallback paths of other drivers, that leaves crypto/asymmetric_keys/public_key.c (hashing), BPF, MACsec, OpenVPN data channel offload, ecryptfs, Ceph, SMB, IPsec, mac802154, TIPC, TLS, and crypto/kpp.c. AF_ALG only allows offload drivers for cbc(paes), which QCE doesn't implement. QCE is broken with IPsec and probably some other networking protocols, as it would wind up taking a mutex in softirq context.

Is there anything on that list that you don't plan to convert to the crypto library?

Quoted 5 lines

Does the perceived value perhaps come merely from "offering" FIPS certified cryptography on the system -- then not actually using it in practice? That can maybe be understandable in some cases, but it's also not really something that belongs upstream where actual technical merit is expected. Also, could ICE be enough to check that checkbox?

I agree with all of these points.

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#18 lore raw
Quoted 20 lines · Demi Marie Obenour
Quoted 14 lines · Eric Biggers
Quoted 4 lines · Demi Marie Obenour
Quoted 3 lines

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

Quoted 8 lines

That sounds like the kind of thing that would cause someone to use a worse implementation of cryptographic algorithms 🙂.

For what it is worth, many common uses of kernel cryptography can't use the QCE. This notably applies to the CSPRNG (/dev/urandom etc), storage encryption, and AF_ALG. Therefore, I expect that anyone who needs FIPS 140 compliance with Linux needs to ensure that the software crypto is certified, as that's what actually gets used in most cases.

Quoted 5 lines

Well there's that, and also the Inline Crypto Engine (which is actually being used and is unrelated to QCE) has its own FIPS certification.

Which upstream kernel feature, if any, is QCE being used with? I have asked this multiple times and still not gotten an answer.

Quoted 10 lines

Historically AF_ALG has been used to access FIPS-certified crypto from userspace, but that no longer can be used with QCE. Most kernel features reject CRYPTO_ALG_ASYNC, CRYPTO_ALG_ALLOCATES_MEMORY, or both. If I exclude tests and fallback paths of other drivers, that leaves crypto/asymmetric_keys/public_key.c (hashing), BPF, MACsec, OpenVPN data channel offload, ecryptfs, Ceph, SMB, IPsec, mac802154, TIPC, TLS, and crypto/kpp.c. AF_ALG only allows offload drivers for cbc(paes), which QCE doesn't implement. QCE is broken with IPsec and probably some other networking protocols, as it would wind up taking a mutex in softirq context.

It's a far more narrow list than even that. asymmetric_keys uses the shash API, so it cannot use QCE. BPF crypto uses the lskcipher API, so it cannot use QCE. MACsec uses AES-GCM which QCE driver doesn't have. OpenVPN uses AES-GCM or ChaCha20Poly1305, neither of which the QCE driver has. The non-legacy Ceph protocol uses AES-GCM, which again the QCE driver doesn't have. IPsec does decryption in softirq context, which the QCE driver doesn't support. QCE driver does not implement kpp algorithms. SMB, TIPC, TLS, all usually use AES-GCM as well. Until just a couple months ago ksmbd crashed if passed an async algorithm, which proves it was never used with QCE. There is really not much left, maybe ecryptfs AES-CBC file contents encryption? But even for that the cra_priority makes it not actually used.

But we are going into the weeds here with trying to theorize some way the code could theoretically be reached. It seems it's really just not. Or at least if there is a use it is not upstream and/or is not actually the appropriate code to be using.

- Eric

#19 lore raw
Quoted 45 lines · Eric Biggers
Quoted 20 lines · Demi Marie Obenour
Quoted 14 lines · Eric Biggers
Quoted 4 lines · Demi Marie Obenour
Quoted 3 lines

SM8650 with the QCE is FIPS 140-2 certified and apparently this makes a difference. Don't ask me if that makes sense, I don't claim to understand the legal aspects of it.

Quoted 8 lines

That sounds like the kind of thing that would cause someone to use a worse implementation of cryptographic algorithms 🙂.

For what it is worth, many common uses of kernel cryptography can't use the QCE. This notably applies to the CSPRNG (/dev/urandom etc), storage encryption, and AF_ALG. Therefore, I expect that anyone who needs FIPS 140 compliance with Linux needs to ensure that the software crypto is certified, as that's what actually gets used in most cases.

Quoted 5 lines

Well there's that, and also the Inline Crypto Engine (which is actually being used and is unrelated to QCE) has its own FIPS certification.

Which upstream kernel feature, if any, is QCE being used with? I have asked this multiple times and still not gotten an answer.

Quoted 10 lines

Historically AF_ALG has been used to access FIPS-certified crypto from userspace, but that no longer can be used with QCE. Most kernel features reject CRYPTO_ALG_ASYNC, CRYPTO_ALG_ALLOCATES_MEMORY, or both. If I exclude tests and fallback paths of other drivers, that leaves crypto/asymmetric_keys/public_key.c (hashing), BPF, MACsec, OpenVPN data channel offload, ecryptfs, Ceph, SMB, IPsec, mac802154, TIPC, TLS, and crypto/kpp.c. AF_ALG only allows offload drivers for cbc(paes), which QCE doesn't implement. QCE is broken with IPsec and probably some other networking protocols, as it would wind up taking a mutex in softirq context.

It's a far more narrow list than even that. asymmetric_keys uses the shash API, so it cannot use QCE. BPF crypto uses the lskcipher API, so it cannot use QCE. MACsec uses AES-GCM which QCE driver doesn't have. OpenVPN uses AES-GCM or ChaCha20Poly1305, neither of which the QCE driver has. The non-legacy Ceph protocol uses AES-GCM, which again the QCE driver doesn't have. IPsec does decryption in softirq context, which the QCE driver doesn't support. QCE driver does not implement kpp algorithms. SMB, TIPC, TLS, all usually use AES-GCM as well. Until just a couple months ago ksmbd crashed if passed an async algorithm, which proves it was never used with QCE. There is really not much left, maybe ecryptfs AES-CBC file contents encryption? But even for that the cra_priority makes it not actually used.

Quoted 4 lines

But we are going into the weeds here with trying to theorize some way the code could theoretically be reached. It seems it's really just not. Or at least if there is a use it is not upstream and/or is not actually the appropriate code to be using.

At this point I think it is quite clear that the following algorithms provided by QCE are unusable no matter what userspace does:

- SHA256
- HMAC-SHA256
- AES-XTS
- authenc(hmac(sha256),cbc(aes))

Those should all be deleted as unreachable or unused code. There are also a lot of algorithms in other drivers that can also be removed.

If the driver was actually used, I _suspect_ it was by requesting it explicitly via AF_ALG. AF_ALG won't let you do that anymore, though. The other possibilities I can think of are messing with priorities via NETLINK_CRYPTO or somehow not building any software implementations with a higher cra_priority than QCE.

Splitting the driver up would be much better than the current status quo, though.

Signature · 2 lines
Sincerely,
Demi Marie Obenour (she/her/hers)
#20 lore raw
In reply to Eric Biggers

Hello,

Quoted 6 lines · Eric Biggers
drivers/crypto/qce/qcrypto.c new file +0 -0
new file mode 100644
index 000000000000..d526902b3060

drivers/crypto/qce/qcrypto.c line 10

Quoted 10 lines
drivers/crypto/qce/qcrypto.c new file +10 -0
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
+ */
+
+#include <linux/device.h>
+#include <linux/interconnect.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>

<linux/platform_device.h> already makes sure that of_device_id is available, so don't include <linux/mod_devicetable.h> which will go away soon.

Also I wonder why/if you need <linux/device.h> here.

drivers/crypto/qce/qcrypto.c line 24

Quoted 13 lines
drivers/crypto/qce/qcrypto.c new file +13 -0
+static int qce_crypto_probe(struct platform_device *pdev)
+{
+	struct icc_path *mem_path;
+
+	mem_path = devm_of_icc_get(&pdev->dev, "memory");
+	if (IS_ERR(mem_path))
+		return PTR_ERR(mem_path);
+
+	return icc_set_bw(mem_path, 0, 0);
+}
+
+static const struct of_device_id qce_crypto_of_match[] = {
+	{ .compatible = "qcom,crypto-v5.1", },

No , before a closing } please

drivers/crypto/qce/qcrypto.c line 27

Quoted 3 lines
drivers/crypto/qce/qcrypto.c new file +3 -0
+	{ .compatible = "qcom,crypto-v5.4", },
+	{ .compatible = "qcom,qce", },
+	{}

A single space between { and } is the most usual form, please stick to that.

Quoted 6 lines
drivers/crypto/qce/qcrypto.c new file +6 -0
+};
+MODULE_DEVICE_TABLE(of, qce_crypto_of_match);
+
+static struct platform_driver qce_crypto_driver = {
+	.probe = qce_crypto_probe,
+	.driver = {

drivers/crypto/qce/qcrypto.c line 43

Quoted 10 lines
drivers/crypto/qce/qcrypto.c new file +10 -0
+		.name = KBUILD_MODNAME,
+		.of_match_table = qce_crypto_of_match,
+	},
+};
+module_platform_driver(qce_crypto_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Qualcomm crypto engine stub driver");
+MODULE_ALIAS("platform:" KBUILD_MODNAME);
+MODULE_AUTHOR("The Linux Foundation");

Best regards
Uwe