Commit Graph

2766 Commits

Author SHA1 Message Date
vasilito 155d01b11e kernel(x86_64): make /scheme/sys/msr MSR access #GP-safe
The MSR R/W scheme lets root request an arbitrary wrmsr/rdmsr on any CPU
(used by cpufreqd/thermald). A bad MSR number or reserved-bit value raises
#GP; on the raw wrmsr/rdmsr that is a kernel-mode fault that panics the
whole machine at exit_this_context (unreachable!) — i.e. root userspace can
crash the kernel. Observed on KVM: cpufreqd writing a legacy P-state MSR
(#GP in the msr IPI handler) halted the boot right before the console/login.

Add wrmsr_safe/rdmsr_safe (arch/x86_64): the faulting instruction sits in a
__wrmsr_safe_start/end (resp. rdmsr) region, and the #GP handler recognises a
fault inside those bounds and returns an error via recover_and_efault — the
same fault-recovery mechanism already used for usercopy page faults. The MSR
scheme (local path) and the cross-CPU msr IPI handler now use these and
surface EIO to the caller (IPI failures propagated via a new MsrMailbox
faulted flag) instead of panicking. 32-bit x86 keeps the raw path (untested).
2026-07-16 12:11:34 +09:00
vasilito 887552f251 remove temporary openat/openat_into/write kernel diagnostics 2026-07-15 21:38:38 +09:00
vasilito 22de233c1a diag(kernel): log non-ENOENT openat + openat_into failures 2026-07-15 19:16:55 +09:00
vasilito b5a7bf5581 fix(kernel): FileTableVerb::Resize no-op + ProcUptime soft-float
Two fixes on the clean base (all boot-investigation diagnostics removed):

1. ProcScheme::kcall now accepts FileTableVerb::Resize on filetable
   handles as a no-op instead of returning EBADF. After the upstream
   'move fd allocation into userspace' relibc refactor, FILETABLE
   pre-syncs its size via a Resize call before growing; the kernel
   already grows posix_fdtbl on insert. Returning EBADF broke add_posix
   once a process's fd table grew (notably the bootstrap process manager
   proxying child thread ops), making the child's regs/env dup fail and
   its ld.so panic, crashing initfs daemons (randd) at boot.

2. ProcUptime uses integer arithmetic instead of f64 (the kernel is
   built with +soft-float; f64 in format!() breaks the build).
2026-07-15 15:27:55 +09:00
vasilito 2086faecb0 rb: reapply Red Bear patches on upstream 00cfa2d2 2026-07-12 16:55:28 +03:00
R Aadarsh 00cfa2d225 Add support for querying dom-node map 2026-07-11 08:33:17 +05:30
MJ Pooladkhay 985bc2623f Fix a race in get_round_robin_index. 2026-07-10 18:13:36 -06:00
R Aadarsh bb06db93ce Add support for querying numa info from userspace 2026-07-10 15:46:02 +05:30
R Aadarsh fbfe439451 Fix riscv and x86 compilation failure 2026-07-09 19:26:01 +05:30
R Aadarsh bfbbec47a9 Create seperate free lists for each NUMA memory regions 2026-07-08 21:33:02 +05:30
R Aadarsh 621a0f4be9 * Split free areas at NUMA memory boundaries
* Fix incorrect name usage in ACPI ARM parsing code
2026-07-08 21:32:37 +05:30
Akshit Gaur 38642377f3 Separate timers 2026-07-07 06:43:41 -06:00
4lDO2 c83b38eb70 Remove obsolete TODO, run rustfmt. 2026-07-06 19:30:05 +02:00
R Aadarsh 4d5d36d44e Extract code that is common to both x86 and ARM to srat::init 2026-07-05 20:16:00 +05:30
R Aadarsh 35340a80c4 * Add ACPI-NUMA parsing code for ARM
* Fix bug in the x86 code that caused incorrect cpu-node mapping

* Remove the usage of page mappers. Instead use the already existing
  linear mapping
2026-07-05 15:01:48 +05:30
R Aadarsh cb88ed59a2 Parse ACPI tables for NUMA information without allocating from the heap 2026-07-03 20:19:46 +05:30
Wildan M 372cd19b6f Remove irq from handles on close 2026-07-02 08:41:11 +07:00
R Aadarsh aa7e7d2f44 Fix the bug in RxsdtIter that caused u32 pointers to be used regardless of ACPI table kind 2026-07-01 10:36:07 -06:00
R Aadarsh a03c545f3c Fix build failure for ARM 2026-07-01 10:36:07 -06:00
R Aadarsh a2a3df33c6 Split acpi::init to perform two stage initialisation 2026-07-01 10:36:07 -06:00
Ibuki Omatsu 6c3d5d28c6 refactor: Move fd allocation logic into userspace 2026-07-01 08:02:47 -06:00
R Aadarsh 8171dc616b Fix panic due to using uninitialised NUMA_NODES 2026-06-21 14:30:07 +05:30
R Aadarsh 2ad76496c4 * Store addresses as pointers
* Remove lots of unsafe code by initialising in the closure passed to
  `call_once`

* Remove `NUMBER_OF_DOMAINS` as size can always be inferred from the
  hashmap's len
2026-06-21 14:03:49 +05:30
R Aadarsh 4106dcbbfa Gate behind a feature flag 2026-06-21 14:03:49 +05:30
R Aadarsh 969c905d8e Account for the case when distance information is not available 2026-06-21 14:03:49 +05:30
R Aadarsh 9ecc75029c * Correctly put cpus and memories for adoption
* Test on x86_64 (works)
2026-06-21 14:03:49 +05:30
R Aadarsh 16c59588b0 * Fix endianness
* Remove ITS affinity and numa
2026-06-21 14:03:49 +05:30
R Aadarsh ee2a61088e * Parse SLIT for distance information
* Order by distance, reorganise domains into nodes
2026-06-21 14:03:49 +05:30
R Aadarsh 63d1171ffb Initial commit 2026-06-21 14:03:49 +05:30
Wildan M 002fff546d Clear cloexec flag on Dup2 2026-06-20 06:35:01 +07:00
Wildan M ed31b800c4 Revert "Use weak context for Proc" 2026-06-19 17:36:41 +07:00
Wildan M 622a4fb3cd Solve context leak when switching 2026-06-19 17:33:46 +07:00
Wildan M 101f090ef9 Fmt 2026-06-19 16:50:14 +07:00
Akshit Gaur b93260ed2d Migrating run_queue to BTreeMap 2026-06-18 10:39:33 +05:30
4lDO2 56947e1a0f Revert drop of kstack in exit_this_context. 2026-06-04 13:37:57 +02:00
4lDO2 bd6d9acd3c Compile on other arches. 2026-06-03 19:06:12 +02:00
4lDO2 c27568e1fe profiling: allow walking across syscall boundaries 2026-06-03 19:01:35 +02:00
4lDO2 42613ddc06 WIP: simultaneous NMI-based user+kernel profiling. 2026-06-03 19:01:35 +02:00
R Aadarsh f8bc19747a Make necessary changes to the kernel in order for relibc to support posix_spawn and posix_spawnp
* `syscall::sendfd`, now, when called with a `ContextHandle::FileTable` adds the fd to the filetable removing it from the calling process's filetable

* Files can now be added to, removed from another process, and can be duplicated using `ProcScheme::kcall`

* Files of another process with the flag O_CLOEXEC can now be closed by using `kcall`
2026-06-03 15:29:02 +05:30
4lDO2 8011f3f648 Simplify acpi scheme. 2026-06-02 16:23:08 +02:00
4lDO2 6fc2d32497 Remove redundant methods from KernelScheme. 2026-06-02 11:24:37 +02:00
4lDO2 da3d235af5 remove syscall debug for removed syscalls 2026-06-02 11:24:37 +02:00
4lDO2 3e210ff169 Remove 5 obsolete syscalls. 2026-06-02 11:24:37 +02:00
Wildan M 8701e8165b Fix compilation for aarch64 after rust update 2026-05-31 06:55:02 +07:00
4lDO2 cee451af38 Use ArrayVec for kcall fd nums, 8% better perf! 2026-05-31 20:24:57 +02:00
Wildan M 973ac667e3 Use syscall time helper functions 2026-05-30 12:29:38 +07:00
Wildan M a47b3a8d57 Add timeout for events 2026-05-30 13:44:31 -06:00
Wildan M ec1395b554 Wrap unmap loop with handle_notify_files 2026-05-30 08:40:49 -06:00
Akshit Gaur 58283f63fe EEVDF 2026-05-30 08:39:48 -06:00
Ibuki Omatsu e847768f2b feat: Implement multiple fds variant for call and std_fs_call 2026-05-29 13:07:36 +02:00