Skip to content

Commit

Permalink
soc: qcom: subsys-pil-tz: use memcpy_toio() for pil_init_image_trusted()
Browse files Browse the repository at this point in the history
The new optimized memcmp doesn't work well on device memory, and when subsys tries to load any fw, we are met with:

[   11.111213] ueventd: firmware: loading 'cdsp.mdt' for '/devices/platform/soc/8300000.qcom,turing/firmware/cdsp.mdt'
[   11.113128] ueventd: loading /devices/platform/soc/8300000.qcom,turing/firmware/cdsp.mdt took 2ms
[   11.113170] subsys-pil-tz 8300000.qcom,turing: cdsp: loading from 0x0000000099100000 to 0x000000009a500000
[   11.117481] ueventd: firmware: loading 'adsp.mdt' for '/devices/platform/soc/17300000.qcom,lpass/firmware/adsp.mdt'
[   11.117518] Unable to handle kernel paging request at virtual address ffffff801f7c6d5c
[   11.117522] Mem abort info:
[   11.117525]   Exception class = DABT (current EL), IL = 32 bits
[   11.117527]   SET = 0, FnV = 0
[   11.117529]   EA = 0, S1PTW = 0
[   11.117530]   FSC = 33
[   11.117532] Data abort info:
[   11.117534]   ISV = 0, ISS = 0x00000061
[   11.117536]   CM = 0, WnR = 1
[   11.117539] swapper pgtable: 4k pages, 39-bit VAs, pgd = 000000003e4fd651
[   11.117541] [ffffff801f7c6d5c] *pgd=00000001f8883003, *pud=00000001f8883003, *pmd=00000001f30fe003, *pte=00680000fd475703
[   11.117547] Internal error: Oops: 96000061 [xiaomi-sm8250-devs#1] PREEMPT SMP
[   11.117551] Modules linked in:
[   11.117554] Process init (pid: 568, stack limit = 0x000000005be89f40)
[   11.117558] CPU: 4 PID: 568 Comm: init Tainted: G S      W       4.14.239-MOCHI xiaomi-sm8250-devs#1
[   11.117560] Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 VAYU (DT)
[   11.117562] task: 00000000e65c9d8d task.stack: 000000005be89f40
[   11.117570] pc : memcpy+0x188/0x2a0
[   11.117577] lr : pil_init_image_trusted+0x130/0x234
[   11.117579] sp : ffffff80229937c0 pstate : 80000145
[   11.117581] x29: ffffff80229937c0 x28: ffffffeaebf93a00
[   11.117584] x27: ffffff8599334000 x26: 0000000000000040
[   11.117586] x25: ffffff859a0aeaa0 x24: ffffff859a63a000
[   11.117589] x23: ffffffeaf557d880 x22: ffffff801f7c5000
[   11.117592] x21: 0000000000001d9c x20: ffffff801f65d000
[   11.117594] x19: ffffff859933cb08 x18: 0000007c2b138000
[   11.117597] x17: 0000007ebf1ef1e4 x16: ffffff8597c02274
[   11.117599] x15: ffffffffffffffff x14: ffffffffffffffff
[   11.117602] x13: ffffffffffffffff x12: ffffffffffffffff
[   11.117604] x11: ffffffffffffffff x10: ffffffffffffffff
[   11.117607] x9 : ffffffffffffffff x8 : ffffffffffffffff
[   11.117609] x7 : ffffffffffffffff x6 : ffffffffffffffff
[   11.117612] x5 : ffffff801f7c6d9c x4 : ffffff801f65ed9c
[   11.117614] x3 : ffffff801f7c6d40 x2 : ffffffffffffffcc
[   11.117617] x1 : ffffff801f65ed80 x0 : ffffff801f7c5000
[   11.117620]
[   11.117620] PC: 0xffffff8598c00e28:
[   11.117622] 0e28  a9022468 a9422428 a9032c6a a9432c2a a984346c a9c4342c f1010042 54fffee8
[   11.117628] 0e48  a97c3c8e a9011c66 a97d1c86 a9022468 a97e2488 a9032c6a a97f2c8a a904346c
[   11.117634] 0e68  a93c3cae a93d1ca6 a93e24a8 a93f2caa d65f03c0 d503201f a97f348c 92400cae
[   11.117639] 0e88  cb0e0084 cb0e0042 a97f1c86 a93f34ac a97e2488 a97d2c8a a9fc348c cb0e00a5
[   11.117645]
[   11.117645] LR: 0xffffff8597ef067c:
[   11.117647] 067c  97eeeccc f9400265 b4fffe65 52801803 910143e2 aa1503e1 910183e0 d2804004
[   11.117652] 069c  72a02803 d63f00a0 aa0003f6 17ffffe9 aa1403e1 aa1503e2 aa1603e0 9434418a
[   11.117658] 06bc  97ff9590 72001c1f b9404ae1 f9402be0 54000241 910133e4 910163e2 d2800085
[   11.117663] 06dc  d2800103 290b03e1 52800021 52800040 97ff9657 2a0003f3 f9413bf4 f9402bf7
[   11.117669]
[   11.117669] SP: 0xffffff8022993780:
[   11.117671] 3780  98c00e68 ffffff85 80000145 00000000 9a0aeaa0 ffffff85 00000040 00000000
[   11.117677] 37a0  ffffffff 0000007f 97ef0644 ffffff85 229937c0 ffffff80 98c00e68 ffffff85
[   11.117682] 37c0  22993ba0 ffffff80 97eeec4c ffffff85 f557d918 ffffffea 00000000 00000000
[   11.117688] 37e0  f6264460 ffffffea f6264400 ffffffea f55b9480 ffffffea 97b704d8 ffffff85
[   11.117693]
[   11.117695] Call trace:
[   11.117698]  memcpy+0x188/0x2a0
[   11.117701]  pil_boot+0x358/0x730
[   11.117704]  subsys_powerup+0x28/0x30
[   11.117709]  subsys_start+0x38/0x134
[   11.117711]  __subsystem_get+0xb0/0x11c
[   11.117713]  subsystem_get+0x10/0x18
[   11.117716]  cdsp_loader_do.isra.0+0xe4/0x1a8
[   11.117718]  cdsp_boot_store+0x8c/0x168
[   11.117722]  kobj_attr_store+0x14/0x24
[   11.117726]  sysfs_kf_write+0x34/0x44
[   11.117729]  kernfs_fop_write+0x118/0x184
[   11.117733]  __vfs_write+0x2c/0xd8
[   11.117735]  vfs_write+0x80/0xec
[   11.117738]  SyS_write+0x54/0xac
[   11.117741]  el0_svc_naked+0x34/0x38
[   11.117744] Code: a97e2488 a9032c6a a97f2c8a a904346c (a93c3cae)
[   11.117747] ---[ end trace fc45fc8b1fa34513 ]---

by looking at the link register we track it back to the function and use the alternative to fix it.

test: device boots with the new optimized string routines
  • Loading branch information
Jebaitedneko authored and NotZeetaa committed Nov 20, 2021
1 parent c31db42 commit ad46880
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/soc/qcom/subsys-pil-tz.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ static int pil_init_image_trusted(struct pil_desc *pil,
return -ENOMEM;
}

memcpy(mdata_buf, metadata, size);
memcpy_toio((void __iomem *)mdata_buf, metadata, size);

desc.args[0] = d->pas_id;
desc.args[1] = mdata_phys;
Expand Down

0 comments on commit ad46880

Please sign in to comment.