Revert "swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single"
authorJason Liu <jason.hui.liu@nxp.com>
Tue, 8 Jun 2021 09:43:46 +0000 (17:43 +0800)
committerJason Liu <jason.hui.liu@nxp.com>
Tue, 8 Jun 2021 12:25:38 +0000 (20:25 +0800)
commit1de9639b1a87417fde25efa9fa08c8c39a6a5d9f
tree3a583d83d7bd3df4cf0f33462432cc5e125e207e
parent51433f05002274ee09632f293a6972c86dc03194
Revert "swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single"

This reverts commit 85a5a6875ca93dc4efbf20df942ba41d27a917e3.

The tlb_addr might not be aligned with tlb bucket size when call
swiotlb_tbl_sync_single, which will result in data corruption.
The issue was seen when do the tcrypt test: modprobe tcrypt mode=211 sec=1
The call stack as the followings: the tlb_addr might be: 0x00000000c280f9c0
for example, in one of the test:
testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aes-caam) decryption

[   64.985483] Hardware name: NXP i.MX8MPlus EVK board (DT)
[   64.990793] Call trace:
[   64.993245]  dump_backtrace+0x0/0x1a0
[   64.996909]  show_stack+0x18/0x70
[   65.000226]  dump_stack+0xd0/0x128
[   65.003629]  swiotlb_tbl_sync_single+0x16c/0x1bc
[   65.008248]  dma_sync_single_for_device+0xf4/0x12c
[   65.013054]  rfc4106_setkey+0x68/0x9c [caam_jr]
[   65.017586]  crypto_aead_setkey+0x2c/0x60
[   65.021600]  test_aead_speed.constprop.0+0x264/0x660 [tcrypt]
[   65.027346]  do_test+0x37fc/0x5c48 [tcrypt]
[   65.031531]  tcrypt_mod_init+0x58/0x1000 [tcrypt]
[   65.036235]  do_one_initcall+0x54/0x1c0
[   65.040071]  do_init_module+0x54/0x250
[   65.043819]  load_module+0x6d0/0x78c
[   65.047395]  __do_sys_finit_module+0xb8/0x100
[   65.051752]  __arm64_sys_finit_module+0x24/0x30
[   65.056283]  el0_svc_common.constprop.0+0x78/0x1a0
[   65.061073]  do_el0_svc+0x24/0x90
[   65.064389]  el0_svc+0x14/0x20
[   65.067444]  el0_sync_handler+0x1a4/0x1b0
[   65.071453]  el0_sync+0x178/0x180

The fix was to adjust orig_addr by adding the offset back by revert the patch.

Fixes:85a5a6875ca9("swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single)
Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
Cc: Horia Geanta <horia.geanta@nxp.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
kernel/dma/swiotlb.c