18 Jan, 2021
40 commits
-
Get the trusty irq state before use or "is->gicv3_workaround" will
always be false.Test: Boots on imx8mq.
Signed-off-by: Ji Luo
Change-Id: I986d331cae61c4a4152e5f6e389cf9d7d7fa998c -
Remove trusty log buffer from Trusty OS memlog service to prevent
Trusty OS keeping write into old buffer if Linux kernel reboot without
resetting Trusty OS.Change-Id: I6cff4008a9e3b51661f1357086922c19939f0169
Signed-off-by: Haoran.Wang -
memfds are not available for use in modules. Switch to dma_buf based
interface instead.Bug: 117221195
Change-Id: I4665ce58ea26606ab696bcb8b82b144574770bc1
Signed-off-by: Matthew Maurer -
Below commit makes the IPIs are handled as normal interrupts,
set_smp_ipi_range() are added to be called by the arch code
to register IPIs:
commit 8d2909c0ac02bf4658ae9e6c36824d12ea704618
Author: Marc Zyngier
Date: Sat Apr 25 15:03:47 2020 +0100FROMGIT: arm64: Allow IPIs to be handled as normal interrupts
Array ipi_desc[] are added to hold the ipi descriptors which
should be requested by the arch code. Trusty will use the
interrupts located at custom range (8 ~ 15) and thus is out
of the default range (0~7).This commit enlarge the default range to cover the custom
IPIs to fix below smp panic:
[ 1.996641] Unable to handle kernel read from unreadable memory at virtual address 0000000000000078
[ 2.005687] Mem abort info:
[ 2.008482] ESR = 0x96000004
[ 2.011539] EC = 0x25: DABT (current EL), IL = 32 bits
[ 2.016852] SET = 0, FnV = 0
[ 2.019907] EA = 0, S1PTW = 0
[ 2.023049] Data abort info:
[ 2.025931] ISV = 0, ISS = 0x00000004
[ 2.029769] CM = 0, WnR = 0
[ 2.032739] [0000000000000078] user address but active_mm is swapper
[ 2.039096] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[ 2.044671] Modules linked in:
[ 2.047738] CPU: 0 PID: 12 Comm: cpuhp/0 Tainted: G W 5.10.1-04680-gaff554cd24bd-dirty #7
[ 2.057217] Hardware name: NXP i.MX8MQ EVK (DT)
[ 2.061752] pstate: 20400085 (nzCv daIf +PAN -UAO -TCO BTYPE=--)
[ 2.067768] pc : __ipi_send_mask+0x1c/0x120
[ 2.071958] lr : custom_ipi_enable+0x100/0x130
[ 2.076401] sp : ffff8000122d3c30
[ 2.079717] x29: ffff8000122d3c30 x28: ffff0000bd950a60
[ 2.085037] x27: ffff000006106e48 x26: ffff0000061b0000
[ 2.090356] x25: ffff800011e75000 x24: 0000000000000001
[ 2.095676] x23: fffffdffbff6d928 x22: 000000000000000f
[ 2.100997] x21: 0000000000000051 x20: ffff800011557ae8
[ 2.106316] x19: 000000000000000f x18: ffff00000611f848
[ 2.111635] x17: 0000000000000000 x16: 0000000000000001
[ 2.116954] x15: 0000000000000010 x14: 0000000000000000
[ 2.122272] x13: 0000000000000004 x12: 0000000000000011
[ 2.127590] x11: 0000000000000000 x10: ffff800011557ac8
[ 2.132908] x9 : ffff800011557ac8 x8 : ffff800011ea9dc8
[ 2.138229] x7 : ffff800011ad5ce1 x6 : 0000000000000003
[ 2.143550] x5 : 000000000000fc2e x4 : ffff0000bd950a88
[ 2.148870] x3 : 0000000000000003 x2 : 0000000000000000
[ 2.154191] x1 : ffff800011557ae8 x0 : 0000000000000000
[ 2.159510] Call trace:
[ 2.161963] __ipi_send_mask+0x1c/0x120
[ 2.165801] custom_ipi_enable+0x100/0x130
[ 2.169903] irq_percpu_enable+0x34/0x78
[ 2.173830] enable_percpu_irq+0xa0/0xe4
[ 2.177759] trusty_irq_cpu_up+0x90/0xf4
[ 2.181685] cpuhp_invoke_callback+0x17c/0x734
[ 2.186135] cpuhp_thread_fun+0x138/0x188
[ 2.190148] smpboot_thread_fn+0x204/0x30c
[ 2.194249] kthread+0x140/0x324
[ 2.197482] ret_from_fork+0x10/0x30Test: Boots with trusty.
Signed-off-by: Ji Luo
Change-Id: I246d7f9ab30f3c759d66ec5a58e56b70ee68c3dc -
Some SoC need the workaround for GICv3 to pass Trusty OS stress test.
So add it back.If need this workaround, then add "use-gicv3-workaround" in the dts
node.Change-Id: Icf4b27f7709b8237d9425ba3e2de3c8adda09aeb
Signed-off-by: Haoran.WangConflicts:
drivers/trusty/trusty-irq.c
drivers/trusty/trusty.cChange-Id: Ic45862f69e010616e33c410b24efcd0181d31517
-
Use trusty-log driver to output the Trusty OS
log into Linux end.
Also added the TIPC call in trusty-log system
to disable the UART output on Trusty OS end
when Linux ready.Change-Id: I695c6360938f3e2f199739f9655d8bc71071be61
Signed-off-by: Haoran.Wang -
Fix build break after porting trusty drivers from kernel
5.4 to kernel 5.10.Test: Builds.
Signed-off-by: Ji Luo
Change-Id: Ic25d075c7948f76f7da659b3b62ce2b6671cbe03 -
Consistently use the MIT license for headers that are also duplicated in
Trusty (and sometimes in TF-A too). This is the license in the other
copies, and unlike GPL-2.0 it's compatible with both Linux and Trusty.For trusty-log.h, also add the copyright statement that is in the other
copy, as the MIT license requires a copyright statement.Also remove the unnecessary include of in arm_ffa.h.
Finally, also add reminders to keep the headers in sync.
Change-Id: Id0349d605013a941d2c54d9a372991b300d8feea
Signed-off-by: Eric Biggers -
While 'uint' and 'ulong' are defined in , in Linux kernel
code they're used far less often than 'unsigned int' and 'unsigned
long'. So replace these types with the standard ones.In the process, remove some unnecessary casts to these types:
- Don't cast to uint to print u32 or smaller with %u. It's not needed.
- Don't cast to uint to print size_t; instead just use %zu.
Change-Id: I53e405f9f40d8e935f1f68e0549125859ab78ca5
Signed-off-by: Eric Biggers -
Linux kernel code conventionally uses u8, u16, u32, etc. instead of the
stdint-style uint8_t, uint16_t, uint32_t, etc. So replace the
stdint-style types with the Linux-style types.Don't make this change in arm_ffa.h or trusty-log.h, since there is a
copy of these headers in non-Linux code, and there is a desire to keep
the copies the same.Change-Id: I0a0239cbda9a32b004581e80e5d4420cee7ee429
Signed-off-by: Eric Biggers -
All user-selectable kconfig options need to have help text.
Change-Id: I9b8a9caccecec0425d52cb5c9195ec0767437345
Signed-off-by: Eric Biggers -
Reject service names longer than 256 bytes (including terminating null)
rather than silently truncate them.Otherwise it may be impossible to increase the maximum supported length
in the future because userspace could start relying on the truncation.Change-Id: I681a3cf4ae07afa81ecd7cea315ef6e40f0e42d2
Signed-off-by: Eric Biggers -
In recent kernels, implementations of file_operations::poll() are
supposed to return __poll_t and use the EPOLL* constants, not POLL*.This fixes the following 'sparse' warning:
drivers/trusty/trusty-ipc.c:1564:27: warning: incorrect type in initializer (different base types)
drivers/trusty/trusty-ipc.c:1564:27: expected restricted __poll_t ( *poll )( ... )
drivers/trusty/trusty-ipc.c:1564:27: got unsigned int ( * )( ... )Also, on some architectures the EPOLL* constants are different from the
POLL* ones; see upstream commit a9a08845e9ac ("vfs: do bulk POLL* ->
EPOLL* replacement").Change-Id: Ie014a57a0b1405b7f69cb4936a2962fea084c78c
Signed-off-by: Eric Biggers -
checkpatch warns about BUG_ON() because it is discouraged these days.
Instead, whenever possible the problem should be recovered from instead
(e.g. by returning an error code).Change-Id: I21aff5e0349666c5de6ec003f1979b30d6ca0a75
Signed-off-by: Eric Biggers -
Drivers are supposed to use dev_*() instead of pr_*(), since
the former includes the device in the message.Change-Id: Ie5b72669659fc4a1a5990fcde889a1fee493b9a1
Signed-off-by: Eric Biggers -
Developers can use ftrace if they want function entry logging.
Change-Id: Ie6336aabe0643339c738315c489c6b0e446882e8
Signed-off-by: Eric Biggers -
Setting device_driver::dev_groups is the recommended way to register
device attributes.Change-Id: Ie85ed32b9a5def858792e69afce2a2cb6d193c5a
Signed-off-by: Eric Biggers -
Setting device_driver::dev_groups is the recommended way to register
device attributes.Note: this changes the behavior slightly, as we now register the
trusty_version attribute even if requesting the version from Trusty
failed. The file will show "unknown" in that case. (Don't return an
error instead, since returning an error when reading a sysfs attribute
would be unusual.)Change-Id: Idc2fe1bd50e428735e0e2ba7e5e9aee4b93474f0
Signed-off-by: Eric Biggers -
trusty_fast_call64() isn't used, so maybe it should just be removed.
But for any of the Trusty driver modules besides trusty-core to start
using it, it needs to be exported, analogous to trusty_fast_call32().Change-Id: Id25aa4e8545753b2ccb8c7bb595d563bb7d8e9b3
Signed-off-by: Eric Biggers -
Currently TRUSTY_IRQ and TRUSTY_LOG are forced on whenever TRUSTY is,
which defeats the point of them being separate options.Make them deselectable so that the user can disable these modules if
they aren't needed.Change-Id: I6e5199bea203918dcb967f257e2797b105b03ca4
Signed-off-by: Eric Biggers -
trusty-virtio is meant to act as a bus, and trusty-ipc as a device on
that bus. However, trusty-virtio is not completely generic yet and
relies on trusty-ipc.ko being loaded first.Bug: 140053385
Bug: 168322325
Change-Id: I9a0244de23019c393b34eb62de8de970449a8d6b
Signed-off-by: Tri Vo -
Check if virtqueue was created before touching it. Otherwise, if
trusty-virtio.ko is loaded before trusty-ipc.ko, kernel panics with the
following trace:[ 1.550733] CPU: 1 PID: 7 Comm: kworker/u8:0 Not tainted 5.4.46-00188-g939619581245-dirty #10
[ 1.552811] Hardware name: linux,dummy-virt (DT)
[ 1.555320] Workqueue: trusty-check-wq check_all_vqs
[ 1.555996] pstate: 20400005 (nzCv daif +PAN -UAO)
[ 1.557575] pc : vring_interrupt+0x10/0xd4
[ 1.558004] lr : check_all_vqs+0x48/0x70
...
[ 1.567712] Call trace:
[ 1.567901] vring_interrupt+0x10/0xd4
[ 1.568086] check_all_vqs+0x48/0x70
[ 1.568420] process_one_work+0x270/0x474
[ 1.568439] worker_thread+0x288/0x4e4
[ 1.568453] kthread+0x114/0x124
[ 1.568480] ret_from_fork+0x10/0x18
[ 1.569764] Code: f800865e a9be7bfd f9000bf3 910003fd (3940e029)
[ 1.570468] ---[ end trace 2fde04f3a63b631d ]---
[ 1.571115] Kernel panic - not syncing: Fatal exception
[ 1.571768] SMP: stopping secondary CPUs
[ 1.572542] Kernel Offset: disabled
[ 1.573217] CPU features: 0x000000Bug: 168322325
Change-Id: Idc88aca6fb8b1f9f5b0a6a538e9ccd77b153b2fe
Signed-off-by: Tri Vo -
Change-Id: I176f1f744bbadb404485337c48f27b302b59e1d9
Signed-off-by: Eric Biggers -
Static and global data that is never modified should be const.
Change-Id: I9bb498bdec02d0c67de02f755223e8059f0ce3d3
Signed-off-by: Eric Biggers -
- Make tipc_compat_ioctl() call tipc_ioctl(), to avoid code duplication
as more ioctls get added. This follows the way that .compat_ioctl()
is typically implemented in drivers; e.g. see ext4_compat_ioctl().- Fix error code for "unrecognized ioctl".
- Remove user-triggable warning and error messages, or downgrade them to
debug level. Kernel convention is to be quiet; userspace can handle
failures the way it wants to.- Remove check for _IOC_TYPE() which is redundant because only specific
ioctl numbers are handled.- Move compat ioctl definition to internal file, as it doesn't belong in
the UAPI header.Change-Id: Ic69db9dbeef823f415cc4be05faf0386e638696f
Signed-off-by: Eric Biggers -
Fix the following warning:
drivers/trusty/trusty-ipc.c: In function ‘dn_share_fd’:
drivers/trusty/trusty-ipc.c:1154:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
1154 | dev_dbg(dev, "shmem_getpage(%d) failed: %d\n", pg_idx,Change-Id: I1fc45d877239ba7ead42b876db794dc14e57ebc1
Signed-off-by: Eric Biggers -
min_t() is preferred over explicit casts.
Change-Id: Ic66f25f765d99cb008088e8bfcb13a251a3092ce
Signed-off-by: Eric Biggers -
Drivers should be quiet unless there is something important to log.
Change-Id: I669f07a08f0bbbd6c307e4057edccb7ec7d3ef0e
Signed-off-by: Eric Biggers -
register_platform_driver() and module_platform_driver() already handle
setting device_driver::owner to THIS_MODULE.Change-Id: I16054be6c0e68b1fd201f5cfa5276fd579b4b16c
Signed-off-by: Eric Biggers -
Linux kernel code uses traditional include guards, not '#pragma once'.
Change-Id: Ia865e58b1d08a2e8df96854933f500b504341794
Signed-off-by: Eric Biggers -
Add 'static' to functions and data that are only used in the same file.
Change-Id: I755816cc242b347e3f09ed0b261b425aa04829ab
Signed-off-by: Eric Biggers -
Makefiles and Kconfig files should have an SPDX line too.
Change-Id: I644d4fb8dd7383ec5c36b310a11bb42a93960581
Signed-off-by: Eric Biggers -
Avoid having to use 'depends on TRUSTY' in every option.
Change-Id: Ic4e0e8d636af44d1a0360b9f7616bb3ecd8ccb26
Signed-off-by: Eric Biggers -
There's no need for these kconfig symbols since CONFIG_ARM and
CONFIG_ARM64 can just be used directly instead.Change-Id: Ie2416a4a76bd190faeb101e02171f94ae3f42255
Signed-off-by: Eric Biggers -
'n' is already the default when no default is explicitly specified.
Change-Id: Ia55333edaf48718f8c8b318c2776ec4eafd1d267
Signed-off-by: Eric Biggers -
The trusty driver currently only builds for the ARM and ARM64
architectures. Add the missing dependency to the kconfig symbol.Change-Id: If78b260032b23761bcc9f7d147342a307f95da82
Signed-off-by: Eric Biggers -
* Adds ability to send memfds over a tipc channel
Missing:
* COMPAT support for 32-bit ioctls
* Receiving shared memoryBug: 117221195
Test: tipc-test -t send-fd
Change-Id: I1bb6c9f1c2ce8ab3e73de3666916a89f872909c9
Signed-off-by: Matthew Maurer -
Previously, these were just replicated in userspace by exact number.
Export them explicitly through uapi rather than manually keeping them in
sync.Bug: 117221195
Signed-off-by: Matthew Maurer
Change-Id: I77bb8d4fcc919bed23eb7a02489a867b06870a27 -
Follow the recommended kernel coding style.
See https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arraysTest: trusty/vendor/google/aosp/scripts/build.py qemu-generic-arm64-test-debug
Change-Id: I435731f8148a9efad57dbe70327f8395ab9c99c4
Signed-off-by: Eric Biggers -
Follow the recommended kernel coding style.
See https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-argumentsTest: trusty/vendor/google/aosp/scripts/build.py qemu-generic-arm64-test-debug
Change-Id: Ife4b4f887ec3b3334af15d5f21535727fbf41e98
Signed-off-by: Eric Biggers