Commit Graph

35309 Commits

Author SHA1 Message Date
Kinsey Moore
22015c0251 cpukit/aarch64: Remove _CPU_ISR_install_vector
This function was never actually used and is dead code.
2022-07-05 15:35:56 -05:00
Gabriel Moyano
eefaf0687c sppps01: Add test case for early returns of pps_event()
Update #2349.
2022-07-05 15:17:15 +02:00
Sebastian Huber
03e4d1e931 score: Add _CPU_Use_thread_local_storage()
At some point during system initialization, the idle threads are created.
Afterwards, the boot processor basically executes within the context of an idle
thread with thread dispatching disabled.  On some architectures, the
thread-local storage area of the associated thread must be set in dedicated
processor registers.  Add the new CPU port function to do this:

void _CPU_Use_thread_local_storage( const Context_Control *context )

Close #4672.
2022-07-04 08:30:42 +02:00
Sebastian Huber
9dd4bd3963 libtests/crypt01: Avoid stack overflows
The SHA512 functions may use huge amounts of stack space if compiled without
optimization.
2022-07-04 08:30:42 +02:00
Sebastian Huber
da8b234261 samples/minimum: Prevent a stack overflow
Prevent a stack overflow if RTEMS_COVERAGE is enabled.
2022-07-04 08:30:40 +02:00
Sebastian Huber
5c13a96f36 build: Add RTEMS_GCOV_COVERAGE option
Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
7452f67dd9 gcov: Add wrapper to dump the gcov info
Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
4f87edbb75 gcov: Add functions to dump the gcov information
Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
2bc233fe58 gcov: Add fork(), etc. gcov wrappers
The compiler wraps fork(), etc. system calls if coverage generation is enabled.
These functions must be provided by the system.  For RTEMS, they just return an
error status.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
a13047ca0e build: Allow separate optimization flags
Allow separate optimization flags for the BSP, cpukit, and tests.  For example,
the BSP and cpukit may be built without optimization if coverage
instrumentation is enabled, however, the tests may still use optimization.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
a0aaa394b6 build: Fix optimization flags definition order
OPTIMIZATION_FLAGS must be defined before /build/bsp/bspopts is processed.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
42da08dd9d build: Add cppflags, cflags, cxxflags to groups
Propagate the group defined cppflags, cflags, and cxxflags from parent groups
to child items through the build item context.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
0bb7b84698 build: Improve value substitution
The waf build system uses lists for tool flags.  The build items may use
variable substitution.  Add the ability to use the variable substitution in
lists.  For example:

MORE_FLAGS = ['-more', '-flags']

flags:
- -some-flag
- ${MORE_FLAGS}

Before this change, the ${MORE_FLAGS} was substituted to "-more -flags".  This
would be passed by waf as a single command line argument to the tool.

After this change, the ${MORE_FLAGS} list extends the flags list:

flags = ['-some-flag', '-more', '-flags']

This list extension is performed if a list element consists of exactly one
variable.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
4aeebaee5b build: Fix identifier pattern
Allow upper case characters in identifiers.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
281f39a600 build: Move BSP_INCLUDES split
The goal is to let the build items define as much as possible.
2022-07-04 08:29:52 +02:00
Sebastian Huber
857fb17db1 build: Add more flags to BuildItemContext
Add cppflags, cflags, and cxxflags to BuildItemContext.  This allows to
propagate the flags from parent items to child items.

Update #4670.
2022-07-04 08:29:52 +02:00
Sebastian Huber
d07d6498c6 samples/cdtest: Test exceptions during system init
Update #4668.
Update #4672.
2022-07-04 08:09:48 +02:00
Sebastian Huber
c15842d99d bsps/xilinx-zynq: Init debug console only once
Initialize the debug console only once during early system initialization.
2022-07-01 06:50:16 +02:00
Sebastian Huber
00f39770ca bsp/lpc32xx: Optimize Ethernet transmit
The updated Ethernet interface driver in libbsd profits from more
transmit descriptors since it no longer uses transmit done interrupts.
2022-06-27 09:25:10 +02:00
Sebastian Huber
050eaa92ef bsp/stm32h7: Exclude some tests 2022-06-24 13:19:57 +02:00
Sebastian Huber
fea5ed5e7d bsp/rtl22xx: Exclude exit03 2022-06-24 13:15:00 +02:00
Sebastian Huber
58b31af20b tstsmallmem: Exclude exit03 and tftpfs 2022-06-24 13:15:00 +02:00
Sebastian Huber
39c09b3b3d riscv: Include missing header file 2022-06-24 13:15:00 +02:00
Sebastian Huber
ba56e23999 score: Account for <sys/bitset.h> API changes
Update #4667.
2022-06-23 10:29:31 +02:00
Sebastian Huber
a76988c881 score: Remove unused _Processor_mask_Nand()
Update #4667.
2022-06-23 10:29:31 +02:00
Sebastian Huber
89e910f1aa spcpuset01: Account for <sys/cpuset.h> API changes
Update #4667.
2022-06-23 10:29:19 +02:00
Sebastian Huber
5dffbc424e score: Make SMP only code explicit
Conditional expressions with inline functions are not optimized away if
optimization is disabled.  Avoid such expressions to prevent dead
branches.  It helps also during code review to immediately see if a loop
is used or not.
2022-06-23 10:28:49 +02:00
Sebastian Huber
94df3a7a6d kern_tc.c: Provide a weak hardpps() implementation
The real implementation of hardpps() is defined in kern_ntptime.c.  Use it only
if the NTP support is needed by the application.

Update #2349.
2022-06-23 09:47:48 +02:00
Sebastian Huber
cd50bea678 score: Use right clock for threadq timeouts
Use CLOCK_REALTIME and CLOCK_MONOTONIC for relative thread queue timeouts
instead of CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE.  This fixes an
issue with clock_nanosleep() in combination with clock_gettime().

Close #4669.
2022-06-23 09:20:11 +02:00
Sebastian Huber
085f3637aa TFTPFS: Fix test configuration for FP targets
The test uses snprintf().

Update #4666.
2022-06-21 16:11:37 +02:00
Sebastian Huber
e38d4f79fa TFTPFS: Reduce test configuration
Update #4666.
2022-06-21 16:11:37 +02:00
Frank Kühndel
3e2b4ec857 TFTPFS: Add tests
Update #4666.
2022-06-21 09:32:16 +02:00
Frank Kühndel
679e7f109a TFTPFS: Implement block and window size options
The original file cpukit/libfs/src/ftpfs/tftpDriver.c
is split into two:

tftpfs.c     - This file contains the code from tftpDriver.c
               related to file system operations such as mount(),
               open(), read(), and so on.

tftpDriver.c - In the original file remains only the code related
               to networking.  This code implements the Trivial
               File Transfer Protocol (TFTP).

Moreover, the code is extended to support

  * RFC 2347 TFTP Option Extension
  * RFC 2348 TFTP Blocksize Option
  * RFC 7440 TFTP Windowsize Option

Update #4666.
2022-06-21 09:32:11 +02:00
Frank Kühndel
c044f0502a TFTPFS: Cleanup: Remove spaces at lines ends
Update #4666.
2022-06-21 09:32:04 +02:00
Chris Johns
6b2c5b5da1 testsuite: Fix gcc 12 warnings 2022-06-21 10:21:13 +10:00
Sebastian Huber
775314d57f jffs2: Update baseline version to Linux v5.9 2022-06-20 13:25:32 +02:00
Gustavo A. R. Silva
413a00db20 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2022-06-20 13:25:32 +02:00
Zhe Li
998ec9f545 jffs2: fix jffs2 mounting failure
Thanks for the advice mentioned in the email.
This is my v3 patch for this problem.

Mounting jffs2 on nand flash will get message "failed: I/O error"
with the steps listed below.
1.umount jffs2
2.erase nand flash
3.mount jffs2 on it (this mounting operation will be successful)
4.do chown or chmod to the mount point directory
5.umount jffs2
6.mount jffs2 on nand flash
After step 6, we will get message "mount ... failed: I/O error".

Typical image of this problem is like:
Empty space found from 0x00000000 to 0x008a0000
Inode node at xx, totlen 0x00000044, #ino 1, version 1, isize 0...

The reason for this mounting failure is that at the end of function
jffs2_scan_medium(), jffs2 will check the used_size and some info
of nr_blocks.If conditions are met, it will return -EIO.

The detail is that, in the steps listed above, step 4 will write
jffs2_raw_inode into flash without jffs2_raw_dirent, which will
cause that there are some jffs2_raw_inode but no jffs2_raw_dirent
on flash. This will meet the condition at the end of function
jffs2_scan_medium() and return -EIO if we umount jffs2 and mount it
again.

We notice that jffs2 add the value of c->unchecked_size if we find
an inode node while mounting. And jffs2 will never add the value of
c->unchecked_size in other situations. So this patch add one more
condition about c->unchecked_size of the judgement to fix this problem.

Signed-off-by: Zhe Li <lizhe67@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Kees Cook
e839daff5b treewide: Remove uninitialized_var() usage
Using uninitialized_var() is dangerous as it papers over real bugs[1]
(or can in the future), and suppresses unrelated compiler warnings
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
either simply initialize the variable or make compiler changes.

In preparation for removing[2] the[3] macro[4], remove all remaining
needless uses with the following script:

git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
	xargs perl -pi -e \
		's/\buninitialized_var\(([^\)]+)\)/\1/g;
		 s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
pathological white-space.

No outstanding warnings were found building allmodconfig with GCC 9.3.0
for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
alpha, and m68k.

[1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
[2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
[3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
[4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

Reviewed-by: Leon Romanovsky <leonro@mellanox.com> # drivers/infiniband and mlx4/mlx5
Acked-by: Jason Gunthorpe <jgg@mellanox.com> # IB
Acked-by: Kalle Valo <kvalo@codeaurora.org> # wireless drivers
Reviewed-by: Chao Yu <yuchao0@huawei.com> # erofs
Signed-off-by: Kees Cook <keescook@chromium.org>
2022-06-20 13:25:32 +02:00
Gustavo A. R. Silva
109815a82e jffs2: Replace zero-length array with flexible-array
There is a regular need in the kernel to provide a way to declare having a
dynamically sized set of trailing elements in a structure. Kernel code should
always use “flexible array members”[1] for these cases. The older style of
one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://github.com/KSPP/linux/issues/21

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2022-06-20 13:25:32 +02:00
Joel Stanley
44cd706c96 Revert "jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()"
This reverts commit f2538f999345405f7d2e1194c0c8efa4e11f7b3a. The patch
stopped JFFS2 from being able to mount an existing filesystem with the
following errors:

 jffs2: error: (77) jffs2_build_inode_fragtree: Add node to tree failed -22
 jffs2: error: (77) jffs2_do_read_inode_internal: Failed to build final fragtree for inode #5377: error -22

Fixes: f2538f999345 ("jffs2: Fix possible null-pointer dereferences...")
Cc: stable@vger.kernel.org
Suggested-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Wenwen Wang
e1a5720264 jffs2: Fix memory leak in jffs2_scan_eraseblock() error path
In jffs2_scan_eraseblock(), 'sumptr' is allocated through kmalloc() if
'sumlen' is larger than 'buf_size'. However, it is not deallocated in the
following execution if jffs2_fill_scan_buf() fails, leading to a memory
leak bug. To fix this issue, free 'sumptr' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Christoph Hellwig
cdac3ca64a jffs2: Remove jffs2_gc_fetch_page and jffs2_gc_release_page
Merge these two helpers into the only callers to get rid of some
amazingly bad calling conventions.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Jia-Ju Bai
9d9bfe5948 jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()
In jffs2_add_frag_to_fragtree(), there is an if statement on line 223 to
check whether "this" is NULL:
    if (this)

When "this" is NULL, it is used at several places, such as on line 249:
    if (this->node)
and on line 260:
    if (newfrag->ofs > this->ofs)

Thus possible null-pointer dereferences may occur.

To fix these bugs, -EINVAL is returned when "this" is NULL.

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Masahiro Yamada
b33c3d4b67 jffs2: Remove C++ style comments from uapi header
Linux kernel tolerates C++ style comments these days. Actually, the
SPDX License tags for .c files start with //.

On the other hand, uapi headers are written in more strict C, where
the C++ comment style is forbidden.

I simply dropped these lines instead of fixing the comment style.

This code has been always commented out since it was added around
Linux 2.4.9 (i.e. commented out for more than 17 years).

'Maybe later...' will never happen.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Al Viro
22e83b00f5 jffs2: fix use-after-free on symlink traversal
free the symlink body after the same RCU delay we have for freeing the
struct inode itself, so that traversal during RCU pathwalk wouldn't step
into freed memory.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2022-06-20 13:25:32 +02:00
Matthew Wilcox
55529cf3d0 Convert jffs2 acl to struct_size
Need to tell the compiler that the acl entries follow the acl header.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
2022-06-20 13:25:32 +02:00
Sebastian Huber
f44ecd0ea9 jffs2: Use RTEMS_CONTAINER_OF 2022-06-20 13:25:32 +02:00
Chris Johns
e70384d3f4 aarch64/gicv3: Remove accesses to secure registers
RTEMS runs at EL1 and the removed register accesses are for
EL3 or the TF-A. This change aligns our driver with the Linux
and FreeBSD ones.
2022-06-16 10:21:46 +10:00
Chris Johns
4f6c90f40d bsps/versal: Support a 64bit RAM base
Set the constraint to be 64bits to allow the complete address range.
2022-06-16 10:21:46 +10:00