rust/bindings/bindings_helper.h | 1 + rust/helpers.c | 14 + rust/kernel/lib.rs | 1 + rust/kernel/scatterlist.rs | 549 ++++++++++++++++++++++++++++++++ 4 files changed, 565 insertions(+) create mode 100644 rust/kernel/scatterlist.rs
Hi All! This is a version of scatterlist abstractions for Rust drivers. Scatterlist is used for efficient management of memory buffers, which is essential for many kernel-level operations such as Direct Memory Access (DMA) transfers and crypto APIs. This patch should be a good start to introduce the crypto APIs for Rust drivers and to develop cipher algorithms in Rust later. Changelog: ---------- v2 -> v3: - Use `addr_of!` to avoid creating a reference to uninit memory. - Mark `ScatterList::as_ref` and `ScatterList::as_mut` as unsafe. - Revise some typos and check with `scripts/checkpatch.pl --codespell`. - Add `# Errors` doc comment to some methods of `SgTable`. v1 -> v2: - Split the old patch into smaller parts. - Remove the selftest module, and place those use cases in the doc. - Repair some invalid hyperlinks in the doc. - Put some `cfgs` inside functions to avoid boilerplate. ==================== Qingsong Chen (3): rust: kernel: add ScatterList abstraction rust: kernel: implement iterators for ScatterList rust: kernel: add SgTable abstraction rust/bindings/bindings_helper.h | 1 + rust/helpers.c | 14 + rust/kernel/lib.rs | 1 + rust/kernel/scatterlist.rs | 549 ++++++++++++++++++++++++++++++++ 4 files changed, 565 insertions(+) create mode 100644 rust/kernel/scatterlist.rs -- 2.40.1
On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: > Hi All! > > This is a version of scatterlist abstractions for Rust drivers. > > Scatterlist is used for efficient management of memory buffers, which is > essential for many kernel-level operations such as Direct Memory Access > (DMA) transfers and crypto APIs. > > This patch should be a good start to introduce the crypto APIs for Rust > drivers and to develop cipher algorithms in Rust later. I thought we were getting rid of the scatter list api for the crypto drivers, so this shouldn't be needed going forward, right? Why not just use the direct apis instead? And what crypto protocols are needed to be done in rust that we are currently missing in the C versions? thanks, greg k-h
On Sat, Jun 10, 2023 at 05:33:47PM +0200, Greg KH wrote: > On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: > > Hi All! > > > > This is a version of scatterlist abstractions for Rust drivers. > > > > Scatterlist is used for efficient management of memory buffers, which is > > essential for many kernel-level operations such as Direct Memory Access > > (DMA) transfers and crypto APIs. > > > > This patch should be a good start to introduce the crypto APIs for Rust > > drivers and to develop cipher algorithms in Rust later. > > I thought we were getting rid of the scatter list api for the crypto > drivers, so this shouldn't be needed going forward, right? Why not just > use the direct apis instead? See https://lore.kernel.org/r/ZH2hgrV6po9dkxi+@gondor.apana.org.au for the details of that (sorry I forgot the link first time...) greg k-h
On 6/10/23 11:35 PM, Greg KH wrote: > On Sat, Jun 10, 2023 at 05:33:47PM +0200, Greg KH wrote: >> On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: >>> Hi All! >>> >>> This is a version of scatterlist abstractions for Rust drivers. >>> >>> Scatterlist is used for efficient management of memory buffers, which is >>> essential for many kernel-level operations such as Direct Memory Access >>> (DMA) transfers and crypto APIs. >>> >>> This patch should be a good start to introduce the crypto APIs for Rust >>> drivers and to develop cipher algorithms in Rust later. >> >> I thought we were getting rid of the scatter list api for the crypto >> drivers, so this shouldn't be needed going forward, right? Why not just >> use the direct apis instead? > > See https://lore.kernel.org/r/ZH2hgrV6po9dkxi+@gondor.apana.org.au for > the details of that (sorry I forgot the link first time...) Thanks for the information. I agree that turning simple buffers into sg-bufs is not a good idea. If I were implementing a new cipher algorithm, I would definitely follow the `struct cipher_alg`, which takes simple `u8 *` pointer as parameter. However, if we'd like to utilize some existing ciphers, such as aead, we still need scatterlists to construct an `aead_request` for further operations, util changes are made to the underlying interface. Qingsong Chen
On Mon, Jun 12, 2023 at 11:49:51AM +0800, Qingsong Chen wrote: > On 6/10/23 11:35 PM, Greg KH wrote: > > On Sat, Jun 10, 2023 at 05:33:47PM +0200, Greg KH wrote: > > > On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: > > > > Hi All! > > > > > > > > This is a version of scatterlist abstractions for Rust drivers. > > > > > > > > Scatterlist is used for efficient management of memory buffers, which is > > > > essential for many kernel-level operations such as Direct Memory Access > > > > (DMA) transfers and crypto APIs. > > > > > > > > This patch should be a good start to introduce the crypto APIs for Rust > > > > drivers and to develop cipher algorithms in Rust later. > > > > > > I thought we were getting rid of the scatter list api for the crypto > > > drivers, so this shouldn't be needed going forward, right? Why not just > > > use the direct apis instead? > > > > See https://lore.kernel.org/r/ZH2hgrV6po9dkxi+@gondor.apana.org.au for > > the details of that (sorry I forgot the link first time...) > > Thanks for the information. I agree that turning simple buffers into > sg-bufs is not a good idea. If I were implementing a new cipher > algorithm, I would definitely follow the `struct cipher_alg`, which > takes simple `u8 *` pointer as parameter. However, if we'd like to > utilize some existing ciphers, such as aead, we still need scatterlists > to construct an `aead_request` for further operations, util changes are > made to the underlying interface. Why not make the changes to the C code first, and get those changes merged, making this patch series not needed at all? thanks, greg k-h
On 6/12/23 1:38 PM, Greg KH wrote: > On Mon, Jun 12, 2023 at 11:49:51AM +0800, Qingsong Chen wrote: >> On 6/10/23 11:35 PM, Greg KH wrote: >>> On Sat, Jun 10, 2023 at 05:33:47PM +0200, Greg KH wrote: >>>> On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: >>>>> Hi All! >>>>> >>>>> This is a version of scatterlist abstractions for Rust drivers. >>>>> >>>>> Scatterlist is used for efficient management of memory buffers, which is >>>>> essential for many kernel-level operations such as Direct Memory Access >>>>> (DMA) transfers and crypto APIs. >>>>> >>>>> This patch should be a good start to introduce the crypto APIs for Rust >>>>> drivers and to develop cipher algorithms in Rust later. >>>> >>>> I thought we were getting rid of the scatter list api for the crypto >>>> drivers, so this shouldn't be needed going forward, right? Why not just >>>> use the direct apis instead? >>> >>> See https://lore.kernel.org/r/ZH2hgrV6po9dkxi+@gondor.apana.org.au for >>> the details of that (sorry I forgot the link first time...) >> >> Thanks for the information. I agree that turning simple buffers into >> sg-bufs is not a good idea. If I were implementing a new cipher >> algorithm, I would definitely follow the `struct cipher_alg`, which >> takes simple `u8 *` pointer as parameter. However, if we'd like to >> utilize some existing ciphers, such as aead, we still need scatterlists >> to construct an `aead_request` for further operations, util changes are >> made to the underlying interface. > > Why not make the changes to the C code first, and get those changes > merged, making this patch series not needed at all? > Yes, you're right. I believe Herbert would work on that. And I would stop this patch series. Thanks. Qingsong Chen
On Mon, Jun 12, 2023 at 03:03:14PM +0800, Qingsong Chen wrote: > On 6/12/23 1:38 PM, Greg KH wrote: > > On Mon, Jun 12, 2023 at 11:49:51AM +0800, Qingsong Chen wrote: > > > On 6/10/23 11:35 PM, Greg KH wrote: > > > > On Sat, Jun 10, 2023 at 05:33:47PM +0200, Greg KH wrote: > > > > > On Sat, Jun 10, 2023 at 06:49:06PM +0800, Qingsong Chen wrote: > > > > > > Hi All! > > > > > > > > > > > > This is a version of scatterlist abstractions for Rust drivers. > > > > > > > > > > > > Scatterlist is used for efficient management of memory buffers, which is > > > > > > essential for many kernel-level operations such as Direct Memory Access > > > > > > (DMA) transfers and crypto APIs. > > > > > > > > > > > > This patch should be a good start to introduce the crypto APIs for Rust > > > > > > drivers and to develop cipher algorithms in Rust later. > > > > > > > > > > I thought we were getting rid of the scatter list api for the crypto > > > > > drivers, so this shouldn't be needed going forward, right? Why not just > > > > > use the direct apis instead? > > > > > > > > See https://lore.kernel.org/r/ZH2hgrV6po9dkxi+@gondor.apana.org.au for > > > > the details of that (sorry I forgot the link first time...) > > > > > > Thanks for the information. I agree that turning simple buffers into > > > sg-bufs is not a good idea. If I were implementing a new cipher > > > algorithm, I would definitely follow the `struct cipher_alg`, which > > > takes simple `u8 *` pointer as parameter. However, if we'd like to > > > utilize some existing ciphers, such as aead, we still need scatterlists > > > to construct an `aead_request` for further operations, util changes are > > > made to the underlying interface. > > > > Why not make the changes to the C code first, and get those changes > > merged, making this patch series not needed at all? > > > > Yes, you're right. I believe Herbert would work on that. And I would > stop this patch series. Thanks. No, I mean you work on that now. There's no reason you should wait for Herbert, or any one else, submit the patch series this week to that subsystem that does the conversion and see how it goes! thanks, greg k-h
© 2016 - 2026 Red Hat, Inc.