2019-05-15 11:59:30

by Christophe Leroy

[permalink] [raw]
Subject: Can scatterlist elements cross page boundary ?

Hi,

I had understood that scatterlists where lists of buffers, each buffer
being enclosed within a single memory PAGE. Isn't that right ?

As far as I understand, dma_map_sg() expects each entry to be DMA mapable.

But at the time being, I'm getting the following errors on the Talitos
algorithmes:

[ 2.382845] alg: aead: authenc-hmac-sha1-cbc-aes-talitos encryption
test failed (wrong result) on test vector 0, cfg="misaligned splits
crossing pages, inplace"

[ 2.430178] alg: aead: authenc-hmac-sha1-cbc-aes-talitos encryption
test failed (wrong result) on test vector 1, cfg="misaligned splits
crossing pages, inplace"

[ 2.509270] alg: aead: authenc-hmac-sha256-cbc-aes-talitos encryption
test failed (wrong result) on test vector 0, cfg="uneven misaligned
splits, may sleep"

When comparing the expected and actual results, I see (respectively for
the 3 fails above tests) :

[ 2.362271] 00000000: e3 53 77 9c 10 79 ae b8 27 08 94 2d be 77 18 1a
[ 2.368529] 00000010: 1b 13 cb af 89 5e e1
[ 2.372429] 00000000: e3 53 77 9c 10 79 ae b8 27 08 94 2d be 77 18 1a
[ 2.378924] 00000010: fe fe fe fe fe fe fe

[ 2.398908] 00000000: d2 96 cd 94 c2 cc cf 8a 3a 86 30 28 b5 e1 dc 0a
[ 2.405185] 00000010: 75 86 60 2d 25 3c ff f9 1b 82 66 be a6 d6 1a b1
[ 2.411407] 00000020: ad 9b 4c
[ 2.414427] 00000000: d2 96 cd 94 c2 cc cf 8a 3a 86 30 28 b5 e1 dc 0a
[ 2.420926] 00000010: 75 86 60 2d 25 3c ff f9 1b 82 66 be a6 d6 1a b1
[ 2.427287] 00000020: fe fe fe

[ 2.491701] 00000000: e3 53 77 9c 10 79 ae b8 27 08 94 2d be 77 18 1a
[ 2.498125] 00000010: cc
[ 2.500403] 00000000: e3 53 77 9c 10 79 ae b8 27 08 94 2d be 77 18 1a
[ 2.507012] 00000010: fe


Looking at the test manager, I understand that it builds scatterlists
with buffers that are using 2 pages. Am I correct ?

Then how do we expect the driver to behave ?

Thanks
Christophe


2019-05-15 12:10:12

by Pascal Van Leeuwen

[permalink] [raw]
Subject: RE: Can scatterlist elements cross page boundary ?

Hi Christophe,

I ran into a similar issue with the Inside Secure driver.

If I understood correctly, scatter buffers do not need to be enclosed in a single page as long as the scatter buffer as a whole is contiguous in memory. So it can be multiple pages, but then they have to be back-to-back in physical/device memory.

The latter should be guaranteed by the kernel allocator.

Regards,

Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines, Inside Secure

Tel. : +31 (0)73 65 81 900

http://www.insidesecure.com


2019-05-15 14:09:11

by Herbert Xu

[permalink] [raw]
Subject: Re: Can scatterlist elements cross page boundary ?

On Wed, May 15, 2019 at 12:08:45PM +0000, Pascal Van Leeuwen wrote:
> Hi Christophe,
>
> I ran into a similar issue with the Inside Secure driver.
>
> If I understood correctly, scatter buffers do not need to be enclosed in a single page as long as the scatter buffer as a whole is contiguous in memory. So it can be multiple pages, but then they have to be back-to-back in physical/device memory.
>
> The latter should be guaranteed by the kernel allocator.

Yes this is correct.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt