Commit Graph

34670 Commits

Author SHA1 Message Date
Sebastian Huber
f06dd3e176 build: Optional __RTEMS_MAJOR__ via command line
Update #4548.
2021-11-16 07:46:45 +01:00
Sebastian Huber
a0650f5f32 build: Support command line specified options
Update #4548.
2021-11-16 07:46:16 +01:00
Sebastian Huber
9551f340d0 Revert "optvermaj.yml: Allow __RTEMS_MAJOR__ to be overridden so RTEMS 7 tools can be tested"
This reverts commit d1bbfbea5f.
2021-11-15 11:14:12 +01:00
Sebastian Huber
ccbcfb679d rtems: Add new clock manager directives
Update #4527.
2021-11-15 11:14:12 +01:00
Sebastian Huber
1b5db7926b rtems: Simplify rtems_semaphore_set_priority()
Do not write to the object referenced by old_priority in error paths.
This is in line with other directives.
2021-11-15 11:14:12 +01:00
Sebastian Huber
ee57a7f1a1 score: Fix _CORE_ceiling_mutex_Set_priority()
We have to use a second thread queue context to acquire and release the
thread wait lock.

Close #4356.
2021-11-15 09:53:17 +01:00
Sebastian Huber
16b50ac63c score: Always check if a prio ceiling is defined
Priority ceiling semaphores (in contrast to MrsP semaphores) have only
one priority ceiling which is defined for the home scheduler of the task
which created the semaphore.  Always check during a semaphore seize that
the home scheduler of the calling task is equal to this scheduler.

This avoids a scheduler mismatch if the semphore is acquired after the
calling thread blocked on the semaphore.
2021-11-15 09:53:17 +01:00
Sebastian Huber
7a591d0cd4 score: Fix thread pinning assertions 2021-11-15 09:53:17 +01:00
Sebastian Huber
ffb8833dd2 score: Add _Timecounter_Set_NTP_update_second()
Allow the installation of an NTP update second handler which may be used by an
NTP service.

Update #2348.
2021-11-15 08:56:54 +01:00
Sebastian Huber
b936ce5a8c score: Optimize timehand updates for non-SMP
In uniprocessor configurations, the timehand updates are done with
interrupts disabled.  So, it is impossible to observe a generation
number of zero.
2021-11-15 08:56:54 +01:00
Sebastian Huber
52c53a5914 score: Port large time delta support to RTEMS 2021-11-15 08:56:54 +01:00
Sebastian Huber
b88d9cb3e1 score: Initialize timehand generation to UINT_MAX
This leads to a timehand generation overflow right at the system start
and helps to get code coverage in test programs.
2021-11-15 08:56:54 +01:00
Mark Johnston
c3a68059d8 timecounter: Load the currently selected tc once in tc_windup()
Reported by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32729
2021-11-15 08:56:54 +01:00
Sebastian Huber
346755874b kern_tc.c: Scaling/large delta recalculation
This change is a slight performance optimization for systems with a slow
64-bit division.

The th->th_scale and th->th_large_delta values only depend on the
timecounter frequency and the th->th_adjustment. The timecounter
frequency of a timehand only changes when a new timecounter is activated
for the timehand. The th->th_adjustment is only changed by the NTP
second update. The NTP second update is not done for every call of
tc_windup().

Move the code block to recalculate the scaling factor and
the large delta of a timehand to the new helper function
recalculate_scaling_factor_and_large_delta().

Call recalculate_scaling_factor_and_large_delta() when a new timecounter
is activated and a NTP second update occurred.

MFC after:	1 week
2021-11-15 08:56:54 +01:00
Mark Johnston
ea389aaadd timecounter: Lock the timecounter list
Timecounter registration is dynamic, i.e., there is no requirement that
timecounters must be registered during single-threaded boot.  Loadable
drivers may in principle register timecounters (which can be switched to
automatically).  Timecounters cannot be unregistered, though this could
be implemented.

Registered timecounters belong to a global linked list.  Add a mutex to
synchronize insertions and the traversals done by (mpsafe) sysctl
handlers.  No functional change intended.

Reviewed by:	imp, kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32511
2021-11-15 08:56:54 +01:00
Mark Johnston
66d4077c98 timecounter: Let kern.timecounter.stepwarnings be set as a tunable
MFC after:	1 week
2021-11-15 08:56:54 +01:00
Ed Maste
d84e3b6ed7 Remove "All Rights Reserved" from
FreeBSD Foundation sys/ copyrights

These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-11-15 08:56:54 +01:00
Warner Losh
87d7a6e54b kern: clarify boot time
In FreeBSD, the current time is computed from uptime + boottime. Uptime
is a continuous, smooth function that's monotonically increasing. To
effect changes to the current time, boottime is adjusted.  boottime is
mutable and shouldn't be cached against future need. Document the
current implementation, with the caveat that we may stop stepping
boottime on resume in the future and will step uptime instead (noted in
the commit message, but not in the code).

Sponsored by:		Netflix
Reviewed by:		phk, rpokala
Differential Revision:	https://reviews.freebsd.org/D30116
2021-11-15 08:56:54 +01:00
Konstantin Belousov
8d5fc57e65 Make kern.timecounter.hardware tunable
Noted and reviewed by:	kevans
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D29122
2021-11-15 08:56:54 +01:00
Konstantin Belousov
570e58e4fe Add ddb 'show timecounter' command.
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-15 08:56:54 +01:00
Robert Watson
4b384f318c Changes that improve DTrace FBT reliability
on freebsd/arm64:

- Implement a dtrace_getnanouptime(), matching the existing
  dtrace_getnanotime(), to avoid DTrace calling out to a potentially
  instrumentable function.

  (These should probably both be under KDTRACE_HOOKS.  Also, it's not clear
  to me that they are correct implementations for the DTrace thread time
  functions they are used in .. fixes for another commit.)

- Don't allow FBT to instrument functions involved in EL1 exception handling
  that are involved in FBT trap processing: handle_el1h_sync() and
  do_el1h_sync().

- Don't allow FBT to instrument DDB and KDB functions, as that makes it
  rather harder to debug FBT problems.

Prior to these changes, use of FBT on FreeBSD/arm64 rapidly led to kernel
panics due to recursion in DTrace.

Reliable FBT on FreeBSD/arm64 is reliant on another change from @andrew to
have the aarch64 instrumentor more carefully check that instructions it
replaces are against the stack pointer, which can otherwise lead to memory
corruption.  That change remains under review.

MFC after:	2 weeks
Reviewed by:	andrew, kp, markj (earlier version), jrtc27 (earlier version)
Differential revision:	https://reviews.freebsd.org/D27766
2021-11-15 08:56:54 +01:00
Konstantin Belousov
18e6686d10 Remove double-calls to tc_get_timecount()
to warm timecounters.

It seems that second call does not add any useful state change for all
implemented timecounters.

Discussed with:	bde
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2021-11-15 08:56:54 +01:00
Pawel Biernacki
df77572247 Mark more nodes as CTLFLAG_MPSAFE
or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2021-11-15 08:56:54 +01:00
Konstantin Belousov
9fcf785d81 Consolidate read code for timecounters
and fix possible overflow in bintime()/binuptime().

The algorithm to read the consistent snapshot of current timehand is
repeated in each accessor, including the details proper rollup
detection and synchronization with the writer.  In fact there are only
two different kind of readers: one for bintime()/binuptime() which has
to do the in-place calculation, and another kind which fetches some
member from struct timehand.

Extract the logic into type-checked macros, GETTHBINTIME() for bintime
calculation, and GETTHMEMBER() for safe read of a structure' member.
This way, the synchronization is only written in bintime_off() and
getthmember().

In bintime_off(), use overflow-safe calculation of th_scale *
delta(timecounter).  In tc_windup, pre-calculate the min delta value
which overflows and require slow algorithm, into the new timehands
th_large_delta member.

This part with overflow fix was written by Bruce Evans.

Reported by:	Mark Millard <marklmi@yahoo.com> (the overflow issue)
Tested by:	pho
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	3 weeks
2021-11-15 08:56:54 +01:00
Mateusz Guzik
ae5b0b29cf Remove duplicated empty lines from kern/*.c
No functional changes.
2021-11-15 08:56:54 +01:00
Konstantin Belousov
b825e213c3 Initialize timehands linkage much earlier.
Reported and tested by:	trasz
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-15 08:56:53 +01:00
Konstantin Belousov
71b71d6ad2 Make timehands count selectable at boottime.
Tested by:	O'Connor, Daniel <darius@dons.net.au>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D21563

This patch was modified by Sebastian Huber
<sebastian.huber@embedded-brains.de> to adjust it for RTEMS.  See
comment in the patch.
2021-11-15 08:56:53 +01:00
Olivier Houchard
045ed584fe Instead of using an incomplete list of platforms
that uses 64bits time_t in 32bits mode, special case amd64, as i386 is
the only arch that still uses 32bits time_t.
2021-11-15 08:56:53 +01:00
Andrew Turner
468568ff18 Create a new macro for static DPCPU data.
On arm64 (and possible other architectures) we are unable to use static
DPCPU data in kernel modules. This is because the compiler will generate
PC-relative accesses, however the runtime-linker expects to be able to
relocate these.

In preparation to fix this create two macros depending on if the data is
global or static.

Reviewed by:	bz, emaste, markj
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D16140
2021-11-15 08:56:53 +01:00
Mateusz Guzik
6a2363f7b7 tc: bcopy -> memcpy 2021-11-15 08:56:53 +01:00
Brooks Davis
4d6837da2d Move most of the contents of opt_compat.h
to opt_global.h.

opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
2021-11-15 08:56:53 +01:00
Sebastian Huber
c830bc643a score: Remove FreeBSD identifier 2021-11-15 08:56:53 +01:00
Konstantin Belousov
118208b1f1 Use atomic_load(9) to read ppsinfo sequence numbers.
In this case volatile qualifiers enusre that a compiler does not
optimize the accesses out.

Reviewed by:	alc, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D13534
2021-11-15 08:56:53 +01:00
Pedro F. Giffuni
bd0fdf4e50 SPDX: use the Beerware identifier. 2021-11-15 08:56:53 +01:00
Sebastian Huber
69aaf58745 libtest: Improve the interrupt test timing
If no state change occurred during the test action, then assume a late
interrupt.
2021-11-15 08:56:53 +01:00
Sebastian Huber
240a1f79b1 score: Introduce CPU budget operations
This patch set replaces the CPU budget algorithm enumeration with a set of CPU
budget operations which implement a particular CPU budget algorithm.  This
helps to hide the CPU budget algorithm implementation details from the general
thread handling.  The CPU budget callouts are turned into CPU budget
operations.  This slightly reduces the size of the thread control block.

All schedulers used the default scheduler tick implementation.  The tick
scheduler operation is removed and the CPU budget operations are directly used
in _Watchdog_Tick() if the executing thread uses a CPU budget algorithm.  This
is performance improvement for all threads which do not use a CPU budget
algorithm (default behaviour).
2021-11-15 08:56:53 +01:00
Sebastian Huber
6cef3f16b6 score: Do not shadow parameter 2021-11-15 08:56:53 +01:00
Joel Sherrill
d1bbfbea5f optvermaj.yml: Allow __RTEMS_MAJOR__ to be overridden so RTEMS 7 tools can be tested 2021-11-12 10:02:51 -06:00
Kinsey Moore
ef207e9ed5 bsps/aarch64: Restore interrupt nesting
Fixing the debug mask flag broke nested interrupts. This restores that
functionality.
2021-11-10 10:51:40 -06:00
zack leung
19c101281a libtests/calloc.c: Fix reported memory leak
This fix came from Code Inspector, flagged by one of the analysis that
was done.

This test code is compiled only but better to address the issues so
future static analysis reports will not include it.
2021-11-03 08:39:12 -05:00
Kinsey Moore
a857a225d0 cpukit/aarch64: Add libdebugger support
This adds support for libdebugger under AArch64 using software
breakpoints and the single-step execution mode present in all AArch64
CPUs.
2021-11-01 08:39:00 -05:00
Kinsey Moore
750bde8c78 bsps/aarch64: Mask debug events from startup
Debug events should be masked at least until after the first context
switch and should usually be masked until a debugger is attached for
application debugging.
2021-11-01 08:39:00 -05:00
Kinsey Moore
2d27725838 bsps/aarch64: Set interrupt level correctly
The existing code is functional but inccorrect and blindly modifies the
other masking bits. It is important to preserve those other bits since
they control masking of important system events.
2021-11-01 08:39:00 -05:00
Kinsey Moore
55a93ae3b4 bsps/aarch64: Add missing MMU map recursion check
Certain input parameters for MMU mapping operations could cause an
infinite recursion if block end boundaries didn't align to 4k. This
ensures that recursion descent does not exceed 2 levels and instead
rounds up to the nearest 4k block if necessary.
2021-11-01 08:39:00 -05:00
Kinsey Moore
2055e42362 aarch64: Break out MMU definitions
This moves the AArch64 MMU memory type definitions into cpukit for use
by libdebugger since remapping of memory is required to insert software
breakpoints.
2021-11-01 08:39:00 -05:00
Kinsey Moore
37684cfdc9 cpukit/aarch64: Use correct debug register names
The N used in the breakpoint and watchpoint register names is intended
to be an integer between 0 and 15 (inclusive) and will not compile when
used as is. This adds the accessors necessary to access all of these
breakpoint and watchpoint registers.
2021-11-01 08:38:59 -05:00
Kinsey Moore
102261043a cpukit/libdebugger: Use uintptr_t for pointers
Use uintptr_t instead of DB_UINT when the variable in question describes
a pointer.
2021-11-01 08:38:59 -05:00
Kinsey Moore
a678d1a99c cpukit: Compare the function result
Compare the function result instead of the function pointer for non-SMP
builds.
2021-11-01 08:38:59 -05:00
Kinsey Moore
c5986a5520 testsuite: Add machine exception signal map test
Add a test to verify that mapping of machine exceptions to POSIX signals
operates properly when the application requests it.
2021-10-29 12:40:56 -05:00
Kinsey Moore
4812a8b572 cpukit: Add signal mapping support
This adds a confdef option allowing an application to request mapping
machine exceptions to POSIX signals. This is required for some languages
such as Ada.
2021-10-29 12:40:56 -05:00