summaryrefslogtreecommitdiff
path: root/sys/arch
AgeCommit message (Collapse)Author
2 dayskernel/amd64: cpu: Add detection of invariant TSCIan Moffett
This commit introduces the 'CPU_FEAT_TSCINV' feature bit to indicate whether or not the CPU supports an invariant TSC. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: conf: Add CPU_UMIP config optionIan Moffett
This commit adds the CPU_UMIP kconf(9) option to allow the user to configure whether or not the kernel should enable the CR4.UMIP bit. It is recommended to keep this to "yes" as user applications should not be able to execute the SGDT, SIDT, SLDT, SMSW or STR instructions at all for security reasons. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: Ensure CR4.UMIP is set by defaultIan Moffett
To prevent user programs from performing any operations related to system memory structures (such as the GDT, TSS, etc), we will always set CR4.UMIP if possible to improve the security of Hyra. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: tsc: Bail if the TSC isn't supportedIan Moffett
Some older CPUs may not even support the TSC so it would be a good idea to check before we start assuming its existence. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: conf: Add boolean USER_TSC optionIan Moffett
Introduce the USER_TSC kernel config option to control whether or not the 'rdtsc' instruction should be accessible in a user context. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel/amd64: cpu: Report CPU vendor typeIan Moffett
This commit introduces a vendor field within the 'cpu_info' structure. This allows kernel code to detect the CPU vendor by comparing it with the CPU_VENDOR_* defines that have also been added. Signed-off-by: Ian Moffett <ian@osmora.org>
2 dayskernel: proc: Improve handling of 'nswitch'Ian Moffett
- Extend 'nswitch' to 64-bits as it increments fast - Ensure writes to 'nswitch' are atomic Signed-off-by: Ian Moffett <ian@osmora.org>
3 dayskernel/amd64: Add basic timestamp counter supportIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
4 dayskernel: timer: Add flags field + TIMER_MONOTONICIan Moffett
Sometimes we may rely on a specific kind of timer. While we are able to grab scheduler specific timers, general purpose timers, etc. One might need to for example, check whether their general purpose timer timer is monotonic or not. Signed-off-by: Ian Moffett <ian@osmora.org>
5 dayskernel/amd64: Introduce flexible IPI managementIan Moffett
This commit greatly improves the handling of how inter-processor interrupts are allocated and managed. Previously Hyra used handlers at fixed interrupt vectors for IPIs, however, that is very rigid and not very scalable at all. With the new IPI framework, one may allocate IPIs by calling 'md_ipi_alloc()' and initializing the handler field. To send an IPI to a specific processor, one can use cpu_ipi_send() and pass the specific CPU structure as well as the IPI identifier. Signed-off-by: Ian Moffett <ian@osmora.org>
8 dayskernel: sysctl: Report 'hw.*' variablesIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
9 dayskernel/amd64: Limit frame depth in backtraceIan Moffett
A backtrace usually occurs during critcal system events like panics. When the system in a error state, we cannot trust the correctness of the stack. This commit aims to improve checks done in a731d4e by adding a max frame depth that limits how many frames can be walked. Signed-off-by: Ian Moffett <ian@osmora.org>
9 dayskernel/amd64: Add better checks on 'rbp' and 'rip'Ian Moffett
Improve handling within the stacktrace logic used during system panics and critical events. - Perform checks on 'rbp' *before* logging - Ensure RBP is 8-byte aligned Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-25kernel/amd64: Keep track of which cores are onlineIan Moffett
Give each core a bit that indicates whether the core is online or halted. We also provide a cpu_halt() which marks the core as offline. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-19kernel: kconf: Seperate shared options to sys/confIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-17kernel/amd64: mp: Pin one idle thread to each coreIan Moffett
Each core on the CPU gets one idle thread so that it is always up to something. To ensure these threads are not bouncing wildly between cores and are always ready for their respective processor to take when they have no threads to grab. We must call proc_pin() on each for every processor. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-17kernel/amd64: Set up seperate syscall stackIan Moffett
It is a good idea to have a completely different stack during syscalls. This commit implements a TSS IST entry for syscalls. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-16kernel: accnt: Keep track of per-cpu statsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-16kernel: Sort out switch MI/MD switch logicIan Moffett
Certain operations dealing with context switches are better off being implemented as machine dependent routines which allows us to be flexible with what we can do, as well as the extra benefit of requiring less workarounds to keep things MI. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Track interrupt countIan Moffett
Keep track of how many times an interrupt fires, this can be used for interrupt statistics later on. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Get CPU family + modelIan Moffett
The CPU family ID and model number are sometimes useful in order to detect the presence of certain CPU features as well as detecting CPU specific quirks. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: cpu_check_feat() -> cpu_get_info()Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Add I8042_POLL kconf(9) optionIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel/amd64: Return NULL if IA32_GS_BASE is unsetIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel: Avoid using kprintf() during panicIan Moffett
Avoid using kprintf() during a system panic event as it relies on internal locking that may hang the system preventing diagnostics from being logged Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-13kernel: Make panic screen configurableIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-11kernel/amd64: i8042: Decode ESCAPE keyIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: Add support for coredumpsIan Moffett
To make debugging userland program crashes easier, this commit introduces coredumps that store the last known process state into a temporary /tmp/core.X file (where X is the PID of the faulting process). Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: conf: Add CPU_SMEP optionIan Moffett
Allow the user to configure if SMEP would be enabled for their build of the Hyra AMD64 port Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: cpu: Support SMEPIan Moffett
Some CPUs support Supervisor Memory Execution Protection that prevent ring 3 code from being executed in a ring 0 context. Enable this on CPUs that support it. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-05kernel/amd64: Add 'feat' field in cpu_infoIan Moffett
Keep track of per-cpu features by using a 'feat' field which contains the results of various CPUIDs. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-03kernel: driver: Assign names to all driversIan Moffett
Assign a name to each driver through the DRIVER_EXPORT() or DRIVER_DEFER() macros. This can be used for blacklisting driver startups. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-07-03kernel/aarch64: Add 'board_info' structureIan Moffett
Introduce a 'board_info' structure as well as an md_get_board() routine to get information about the host Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-29kernel/amd64: trap: Wrap regdump into a panic()Ian Moffett
- Rename regdump() to trap_fatal() - Use panic() rather than kprintf() Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-29kernel/amd64: trap: Restore IPL during user trapsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-27kernel/amd64: mp: Give each core an idle threadIan Moffett
Having the same amount of idle threads per core allow the CPU to always have a thread assigned to one of its cores even when there are currently no other threads for it to take. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: Deprecate reboot keyIan Moffett
Remove logic to reboot machine by simply pressing a key. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: mc1468xx: Implement date settingIan Moffett
Implement logic to update the date returned by the MC1468XX/RTC chip. This can be used to later implement some sort of time synchronization protocol or manual setting of the date. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: mc1468xx: Add 2000 to the yearIan Moffett
The year register of the RTC does not keep track of the century so default to 2000 until we figure out the non-standard century register. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: i8042: Use DMI for quirk checkingIan Moffett
On certain embedded controllers (ECs) like the EC present on the Thinkpad T420s, writes to the i8042 controller configuration byte are not very liked by the EC internal logic and thus result in them asserting an NMI as a certain host bus error. To workaround this, Hyra falls back to polling on these specific devices. Previously, Hyra did not have DMI/SMBIOS capabilities and therefore had to rely on assuming *all* Lenovo devices were "hostile". As of now since we are capable grabbing the product version from DMI, we can target specific devices like the T420s and this commit provides that logic. This commit additionally implements logic to enable interrupts on PS/2 port 0 (aka the keyboard). Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: Throw away any pre-kernel huge pagesIan Moffett
Before the Hyra kernel starts up, the Limine bootloader creates a mapping of the first 4 GiB of memory (identity mapped for base revisions of zero and mapped to the HDDM on higher base revisions). However, it usually will create a huge mapping over this which would be problematic during remaps of device MMIO base addresses as they typically reside at the 4 GiB region of RAM and as of this commit, huge pages are not a supported feature of the Hyra AMD64 pmap layer. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-25kernel/amd64: Only use USER_DS in md_td_kick()Ian Moffett
The function md_td_kick() is only used for user threads and there is no need reference any kernel segments. Furthermore, the previous code would introduce a bug where rpl would always be 0. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-23kernel: conf: Default to console fg of #B57614Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-22kernel/amd64: Only print SIMD logs on BSP initIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-22kernel/amd64: Add SIMD (SSE + AVX) supportIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-21kernel/amd64: mc1468xx: Add year, month and dayIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-20kernel/amd64: intr: Add driver specific intr dataIan Moffett
Allow the intr_hand structure to carry driver specific and interrupt related data so that it can be passed to an interrupt handler when it is invoked. Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-20kernel/amd64: intr: Ensure intr_hand.name has '\0'Ian Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-19kernel/aarch64: pmap: Handle PROT_EXEC prot flagIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
2025-06-19kernel/aarch64: Implement vas and map/unmap stubsIan Moffett
- Implement pmap_map() - Implement pmap_unmap() - Implement pmap_read_vas() - Implement pmap_switch_vas() Signed-off-by: Ian Moffett <ian@osmora.org>