3311 Commits
Author SHA1 Message Date
4lDO2 50b19d1b1f Fix obvious opportunistic_context_locking typo. 2026-09-07 20:33:38 +02:00
Ibuki Omatsu 3c13c8c4c9 refactor: Reimplement fdtbl using radix trees 2026-09-07 17:33:11 +02:00
Valentin Lorentz 3380858a16 Remove redundant store to ALL_PERCPU_BLOCKS 2026-09-06 17:50:05 -06:00
Valentin Lorentz d3c1cb02cc Fix test build
Broken by f52b427cf5
2026-09-06 17:50:05 -06:00
4lDO2 d5bf54423f Avoid frame zeroing when followed by frame copy. 2026-09-06 23:25:34 +02:00
4lDO2 3a02e6b493 Allow simultaneous write of CQEs and read of SQEs. 2026-09-05 20:33:32 +02:00
4lDO2 0ebeab2b73 only save/restore avx regs when needed 2026-09-05 15:23:43 +02:00
Wildan M eb8bb26097 Make cargo unit test work 2026-09-05 07:22:43 -06:00
Wildan M f52b427cf5 Raise context work stealing to two 2026-09-05 07:22:43 -06:00
4lDO2 5c796a0ac6 Safe get-percpu wrapper and warnings fixes. 2026-09-05 07:16:38 -06:00
4lDO2 a2ee203ee5 Update Cargo.lock 2026-09-05 14:50:11 +02:00
MJ Pooladkhay 2a6c84a58f Fix panic caused by SRAT iterator over-reading 12 bytes past the table
Signed-off-by: MJ Pooladkhay <mj@pooladkhay.com>
2026-09-05 14:47:51 +02:00
4lDO2 1f7fd64078 redox_syscall 0.9.4 syscall-v0.9.4 2026-09-05 10:48:51 +02:00
4lDO2 7fc4dee572 Clobber xmm0-xmm15 in x86_64 syscall wrapper. 2026-09-04 22:20:43 +02:00
R Aadarsh eeb2db1f2e Remove /scheme/sys/numa, /scheme/sys/numa_dist and
`/scheme/sys/numa_dom`
2026-09-03 20:53:20 +05:30
4lDO2 f4d59db53e Add additional counter for syscall switches. 2026-09-02 13:16:09 +02:00
4lDO2 d2874a167d Avoid fetch_add for context switch count.
Together with the previous commit, this reduces base IPC latency by 1%.
2026-09-02 13:09:56 +02:00
4lDO2 9329213e38 Avoid stats fetch_add when exclusively incremented.
x.store(x.load() + 1) is valid if all other threads are strictly
read-only (and even then, for counters the damage would be much limited
anyway).
2026-09-02 12:55:38 +02:00
Akshit Gaur 9df1951af0 Remove unnecessary var in RunContextData 2026-09-01 17:49:50 +05:30
4lDO2 1712dff573 Allow privileged x86_64 userspace to access MSRs. 2026-09-01 12:04:25 +02:00
4lDO2 ce151969e0 Allow userspace to use RDPMC. 2026-09-01 12:04:25 +02:00
aarch 77fec3254f Fix APs not being able to steal from CPU 0 2026-09-01 11:47:39 +02:00
Jacob Lorentzon 9ce506cc4f Merge branch 'integrate_syscall' into 'master'
Merge redox_syscall into this repo

See merge request redox-os/kernel!689
2026-08-31 20:15:41 +02:00
4lDO2 51f7e7ef9d Silence a probable false positive from clippy. 2026-08-30 15:58:22 +02:00
4lDO2 b9995d57e3 remove redundant syscall/.gitlab-ci.yml 2026-08-30 15:35:14 +02:00
4lDO2 d658b6ae19 Update syscall documentation. 2026-08-30 15:21:46 +02:00
4lDO2 95b7352292 Fix rustfmt in syscall/ 2026-08-30 15:07:23 +02:00
4lDO2 04fcea3785 Use local syscall/ dir for dependency. 2026-08-30 14:58:25 +02:00
4lDO2 570cdeadb0 Add 'syscall/' from commit '4cc3baafdcbca65660d7ad4c52b7900e1fd32315'
git-subtree-dir: syscall
git-subtree-mainline: b6fa12412e
git-subtree-split: 4cc3baafdc
2026-08-30 14:55:56 +02:00
Wildan M 653f795f9b Partially Revert "Use map_linearly in many places"
This reverts commit dee230ffca.
2026-08-30 15:22:46 +07:00
4lDO2 b6fa12412e Avoid Arc::clone in context::current with Ref. 2026-08-30 10:14:43 +02:00
Wildan M 5f640551a6 Use AddrSpace::current instead of context::current 2026-08-30 06:27:04 +07:00
Wildan M c9f586157f Use less context clone on proc 2026-08-30 06:08:00 +07:00
4lDO2 49df9a1682 Avoid UserScheme munmap if no mem was borrowed. 2026-08-29 10:36:31 -06:00
Wildan M bd5dd01bbf Remove redox-path handling 2026-08-29 06:13:47 +07:00
4lDO2 2b38bf8a17 Allow disabling opportunistic context locking. 2026-08-28 14:54:56 +02:00
4lDO2 16b371f86e Store scheme reference directly in file desc. 2026-08-26 20:27:02 +02:00
R Aadarsh 4cb8fbbb89 Do not acquire locks when calculating index for deallocation 2026-08-26 14:18:14 +05:30
R Aadarsh acc290a3db Avoid acquiring spinlock on non-NUMA systems during deallocation 2026-08-26 14:03:33 +05:30
Wildan M 8e96a9db29 Fix WaitCondition inner_drop not being called 2026-08-24 22:15:37 +07:00
Luiz Fernando Becher de Araujo d632b62e9f AArch64: Adapt SMP trampoline to NUMA-aware frame allocator 2026-08-23 17:21:53 -03:00
Luiz Fernando Becher de Araujo 5e6d2d2430 Use i64::from for PSCI result conversion 2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo 0787855dce AArch64: Drain scheduler wakeups in wakeup IPIs
Commit bb03b896 (remove linear scan) moved cross-CPU scheduler
wakeups into a per-CPU ipi_context_wakeup_list. Its x86 wakeup handler
drains that list before completing the IPI, but the AArch64 handler
only completed the SGI.

As a result, a context assigned to another AArch64 CPU could remain
blocked indefinitely. Which process and CPU encountered the missing
wakeup varied between boots, producing stalls at unrelated points
during userspace startup.

Mirror the x86 contract by creating a CleanLockToken and draining
the current CPU wakeup queue before ending the SGI.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo f2b6b6b803 IRQ: Report pending interrupts from fevent
irq_trigger() notifies event queues when an interrupt arrives, but an
interrupt can occur after a driver opens the IRQ handle and before it
subscribes the descriptor to an event queue. In that window kreadoff()
reports data while fevent() reports no readiness, so the driver can
sleep with an unacknowledged interrupt.

Make fevent() use the same per-handle acknowledged count and global
interrupt count as kreadoff(). Report EVENT_READ when the requested
handle has a pending count, closing the subscription race without
changing the existing acknowledgement protocol.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo bfa553feec IRQ: Track and release the exact reserved interrupt
IRQ handles currently reconstruct their reservation when they are
closed. That assumes every handle stores an x86 IRQ number and applies
irq_to_vector(), but devicetree phandle handles already store a
virtual IRQ. Closing such a handle therefore releases the wrong
descriptor. The devicetree implementation also enables the interrupt
in both branches of set_reserved(), so a release cannot mask it.

Store the exact CPU and index when a reservation is acquired and use
that information when the handle is closed. Handles opened only for
stat or through unreserved legacy paths carry no reservation. Also
reject phandle IRQ mappings that cannot be represented by the scheme
counter table, and disable devicetree IRQs when their reservation is
released.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo abe686accb AArch64: Harden PSCI SMP setup and GICv2 routing
Select the ACPI timer GSIV that matches the timer being programmed,
derive the GICv2 CPU target mask instead of assuming interface zero,
and route SPIs exclusively to the BSP when that mapping is available.
Preserve firmware routing and disable SMP safely when no valid target
exists, remove blocking diagnostics from interrupt handlers, skip
unnecessary boot-resource and TCR validation on uniprocessor builds,
remove unused CPUECTLR helpers, and document the current GICv2-only
secondary boot limitation.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo 9d0de645a1 AArch64: Allow GICv2 initialization on uniprocessor systems
Treat a zero GICD_ITARGETSR target mask as valid during BSP
initialization because GICv2 target registers may be RAZ/WI on
uniprocessor implementations, while retaining fail-closed SMP
behavior by requiring a valid target mask before starting secondary
CPUs and after each AP initializes its local GIC interface.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo ac99077220 AArch64: Bring up PSCI secondary CPUs from ACPI
Initialize the PSCI conduit from the FADT ARM boot flags, discover
enabled CPUs and their MPIDRs from MADT GICC entries, and feed the
resulting topology into the existing physical trampoline boot path,
enabling SMP on UEFI/ACPI platforms while preserving single-CPU
operation.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo cd5bea13b0 AArch64: Add stall diagnostics for TLB shootdown and context-switch lock
Use the StallWatch helper added earlier to report a spin loop that has
run far longer than any legitimate SMP handshake should take -- the
TLB shootdown wait and the context-switch-lock acquisition -- with one
diagnostic naming which CPU and, for the shootdown case, how many
acknowledgements are outstanding. Purely diagnostic: the loop keeps
spinning exactly as before, this only makes a stuck wait visible
instead of looking like a silent hang.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00
Luiz Fernando Becher de Araujo 94ec5320a8 AArch64: Bring up PSCI secondary CPUs through a physical trampoline
Prepare, during BSP initialization, everything a secondary CPU needs:
a 16-page kernel stack, a PercpuBlock, and an args page for every
PSCI-enabled secondary in the discovered topology. Also prepare a
physical trampoline page, copied from a small hand-written assembly
routine, cleaned to PoC, instruction-cache synchronized, and identity
mapped through a dedicated TTBR0.

Each BootArgs contains the CPU identity, physical and virtual stack
tops, the virtual per-CPU address, the trampoline identity-map TTBR0,
the kernel TTBR1, the BSP's TCR/MAIR/SCTLR/VBAR/CPACR values, the
virtual Rust entry point, and an atomic state word.

Fail closed and leave the board running on one CPU if resources cannot
be reserved, if any secondary does not use PSCI, or if TCR_EL1 does
not make both TTBR0 and TTBR1 walks Inner Shareable. PTE.SH alone
cannot make page-table entries coherent between walkers, and this boot
path inherits TCR from the bootloader instead of reprogramming it
while the kernel is live.

start_secondaries() calls PSCI_CPU_ON for each slot with the physical
trampoline and BootArgs addresses. It observes the shared state word
advance through STARTING -> LOCAL_READY -> READY -> ONLINE and sends a
directed SGI after LOCAL_READY to exercise actual IPI delivery before
publishing the CPU. CPU startup and local interrupt self-tests are
bounded by two-second timeouts; failures stop further CPU activation
instead of exposing a partially initialized SMP topology.

The trampoline accepts PSCI entry at EL1 or EL2, normalizing EL2 to
EL1h when necessary. PSCI supplies the context address in x0 and
enters with stage-1 translation and caches disabled. The trampoline
loads the prepared translation registers, invalidates the local TLB,
enables the kernel translation regime, installs the stack, per-CPU
pointer, exception vector and FP configuration, and branches to the
virtual Rust entry point.

Cache initialization and coherency-domain management are deliberately
left to the PSCI implementation, as required by the PSCI contract.
The trampoline therefore does not probe CPUECTLR_EL1.SMPEN, inspect
cache geometry, or invalidate private cache levels.

secondary_start() validates the magic, MPIDR, logical ID, state and
per-CPU pointer before continuing. It installs the per-CPU block,
initializes the local GIC interface and timer, removes the temporary
identity map, and requires both a directed SGI and a local timer
interrupt before advancing from LOCAL_READY to READY.

CPU_COUNT is advanced only by publish_cpu(), whose compare_exchange
requires the published logical ID to equal the current CPU count.
Because secondaries are started in order, the visible CPU set remains
a contiguous prefix of logical IDs.

shootdown_tlb_ipi() skips the requesting CPU in its broadcast path.
Callers invalidate their local TLB directly, so sending an IPI back to
the requester would be redundant.

Signed-off-by: Luiz Fernando Becher de Araujo <luiz.becher.araujo@gmail.com>
2026-08-23 19:37:08 +00:00