#HazelOS (Formerly Noise-v2)
1 messages ยท Page 2 of 1
ok neat
though imStill considering ubuntu 25.10 or 26.04
since many projects expect ubuntu
That's upto you
Kubuntu
though whats the default fs used in rootfs?
Btrfs is the default
XFS for server
i usually dont use modified versions
for some reason
prob just me
id probably use xfs
that's default for server iirc
it should be like rhel where you can choose presets at installation right?
or configuration
There's an installer
yeah
theres also the fedora everything
i prob fine with feodra kde
ok thanks for the info
In the sections below, you can find Fedora Linux downloads that do not fit under any of the standard release categories.
ok im now no longer a kde fan
Welcome to the dark side
fedora is also neat
Pros: It uses GTK4
Cons: FreeDesktopOrg hates anyone messing with their design
the first time i see vmware compile and instakll successfully
Which gtk theme are you using?
now fonts
SF pro
we'll see
I meant SF pro
Yup. But it fits with the theme
Use 7z to unarchive it
It's around 2 unzips operations iirc
Decrease sensitivity if you are using extensions
Nothing that 7z can't unarchive
oh so now we know that dmg is just 7z
or at least
compressed using 7z
I think 7zip just supports dmg format
ok
but how do i even use the font?
โ SFProFonts ls
Distribution Resources SFProFonts.pkg
'[HFS+ Private Data]' 'SF Pro Fonts.pkg' '[TOC].xml'
Unarchive the package
i see
Then unarchive Payload~
lol
gone with sf pro rounded regular
also @simple locust is there animations effect on gnome?
like the magic land for example
it isnt as polished though
not bad
plus
final thing, is there en extension that let me spawn multiple instances of an app?
the reason why i used to hate gnome is because of this
and i think we have some issues with ptyxis using sf pro rounded regular to
Classic gnome
Have an official extension
But not integrate it in the DE
Or you can also use ctrl + enter
In overview
Try sf mono if you want to
Or use firacode or smth
just gonna use hybrid
sf pro rounded for everything
and for mono fonts
sf mono reg
for some reason, im im love with gnome (and fedora)
I'm rewriting VMA because it was held together by a chewing gum
B+ trees weren't worth it
Now, I'm back to using RB trees for VMA
Also, For the kernel architecture. I'm thinking about keeping Memory Management and Threads/Process creation in kernel space
๐
while delegating drivers to userspace
I see you've finally introduced yourself
yeah
and you are finnally back
and @violet wharf is gone
btw fedora is peak
what happened to him?
all of us get kicked out of the server
you prob got too
for no reason
and hes been inactive for a bit of time
yeah
11 days
He did say, he had exams after his vacation
Almost two weeks lmao
but that doesnt explain to why the server vanished
must be a lot of work
True
so mysterious lmao
currently cooking vfs
and later sched to prepare for r0c4 as well as the userspace jump
and also migrated to using acpica over uacpi
It was hell. My professors were dumping assignments after assignments
relatable ๐ฅ
I forgot that r0c4 was release version
So, I had to google it
And this came up in the AI overview
WHAT
so what did you think it is?
a kernel component or something
lol
Btw There's this honeybee in my room
The constant buzzing is giving me a headache
here with a mosquito
well if you search aerosync on its own
so its a trademark
@simple locust also im making yet another PoC kernel #1475806779676823674
Capability-based? Like Zircon?
exactly
I feel like chicken-egg problems chase me around all the time
Earlier it was with VMA pool allocations
Now, when I try to implement vm_object abstraction
I need a working slab allocator to get xarray's to work
But the slab allocator itself depends on the VMA
!??
It requests virtual pages from the vma before dividing them up
my slub allocator doesnt even use any of the vma, just the buddy system
vmalloc is a different thing
Then how does it request pages?
the buddy system?
static struct page *allocate_slab(kmem_cache_t *s, gfp_t flags, int node) {
struct folio *folio;
struct page *page;
void *start;
void *p;
if (node == -1)
node = this_node();
folio = alloc_pages_node(node, flags, s->order);
if (!folio)
return nullptr;
page = &folio->page;
start = page_address(page);
page->slab_cache = s;
page->objects = (unsigned short)((PAGE_SIZE << s->order) / s->size);
page->inuse = 0;
page->frozen = 0;
page->node = node;
SetPageSlab(page);
INIT_LIST_HEAD(&page->list);
/* Build freelist */
page->freelist = start;
for (int i = 0; i < (int)page->objects - 1; i++) {
p = (char *)start + i * s->size;
if (s->flags & SLAB_POISON)
poison_obj(s, p, POISON_FREE);
set_redzone(s, p);
set_freelist_next(p, s->offset, (char *)p + s->size);
}
/* Last object */
p = (char *)start + (page->objects - 1) * s->size;
if (s->flags & SLAB_POISON)
poison_obj(s, p, POISON_FREE);
set_redzone(s, p);
set_freelist_next(p, s->offset, nullptr);
return page;
}
So, Should I just bypass vmalloc and allocate pages directly from pmm?
yes
you are adding another layer of latency for no reason
Yeah, but kaslr :(
alrighty time to use hhdm mappins for heap
That also means that I can just remove obj pools from vma/vmm
Slab cache could support vma
My idea was to remove hhdm mappings
entirely
but that's no longer possible
just dont request them?
true
These are just a couple of page table entries, should be doable
Added VM Object abstraction :)
Added Transparent Huge Page Promotion
to pf_handler
Essentially, it merges 512 4KB VM Objects into a single 2MB VM object
I'll try to run the kernel on real hardware
Check #showing-off
As for fb, I was using a shadow buffer
Pmm initialization is too slow for RAM above 8 gigs
how slow is too slow
It takes around 5 seconds to map physical memory
Just the mapping operation
The cause:
if (!is_aligned(phys_end, args.page_size)) {
phys_end = align_up(phys_end, args.page_size);
}
These 3 lines caused the kernel to crash
Anyway I got to fix the pmm issue
This is with 12 gigs of RAM
Forgot that the kernel doesn't support smp rn
Double faulted :<
Let's see if I can reproduce this double fault on qemu
It can be reproduced on QEMU
Thinking about implementing greedy paradigm in PMM init
@inner glen wdyt?
Still a bit slow, but atleast its faster than the previous attempt
Finally managed to improve the performance, and reduce pmm's memory footprint
Without diving into multithreading, the only way to improve the performance is to explicitly ask the compiler to generate clz/ctz instructions instead of generic implementations
Forgot that pattern filling exists
uint64_t page_template = ((uint64_t)idx << 32) | ((uint64_t)PAGE_FLAG_USED << 24);
uint64_t* map_page = (uint64_t*)mem_sections[idx].map;
for (size_t p = 0; p < PAGES_PER_SECTION; ++p) {
map_page[p] = page_template;
}
also got the macos theme?
personally never tried
at most just lazy virtual allocation
@simple locust also for some interesting reason
while aerosync is kind of resource-inefficient
Yeah lol
it actually works just on 40M ram with bios and 130M with uefi across vmware, bochs, vbox and qemu
That's efficient lol
How are you initializing Buddy Metadata?
lemme check
whats your minimum amount?
256MB lol
plus, not to mention i have kaslr support, and its actually limines issue
not my kernel's issue
you can have the code here
main allocation method is alloc_pages_node(3)
there is some inefficientcies tho
especially build_all_zonelists
for reference
[7] [ 1.115385] [aerosync::core::numa] Range [100000000 - 180000000] -> Node 1
[6] [ 1.138870] [aerosync::mm::pm] Built zonelists for all nodes.
(it used to be 1xx+ ms)
sched_class refactor is likely working
Just a few more tests before pushing it
sched_classes are now modular, allowing the kernel to load/unload them at any moment
"minor changes"
The thread/process api rewrite is functionally complete
average osdev
The kernel is fine with 3 CPUs
But for some reason, adding an extra cpus causes this error
youre missing some locking
ig so
if you put proper locking on your kprintf() or whatever it is that outputs text youll at least be able to read the error
theres at least one ERROR and one WARN there, i think about VMM and PMM?
I'm using snprintf with a local stack
so, it likely isn't krpintf() bug
maybe there's some race condition with KLOG?
Atleast it managed to boot
Still there are some bugs and issues to rectify
But it kindof works
Tho, I still need to revise my RCU implementation T-T
those double frees look spicy
just enough to make things go wrong moment
It feels like I'm rolling a dice whenever I test my kernel
This was test 1
Subsequent runs:
my kernel still no have SMP support :(, (only preserve log integrity across cpus when panic)
The issue was with PCP cache in PMM
It was maintaining stale entries
I've removed PCP caches so that every allocation goes through the buddy allocator
looks good
though i see some artifacts?
That's just dust
ofc i can see it
well that makes total sense
0xffff80043d83b000 % 64 = 0
The address is 64-bit aligned
And xrstor still GPFs
At first I was confused then, I remembered that kernel_log uses spinlock in place
Usermode transition :)
RCU's gp_thread isn't executing
idk why
scheduler is clearly selecting that thread
but still
no sign
Do I even need RCU?
Why RCU?
What is RCU?
How is RCU?
Where is RCU?
I hate RCU
๐
Spinlocks and sequential locks my love โค๏ธ
Btw, development is a bit slow as my professors thought it was a good time to mix assignments + Viva :(
Also the fact that I'm trying to write a proposal for GSOC
I should prolly leave signal handling to userspace
IPC without ring buffer :)
Ignore the timing issue, Logger is reading time from TSC
Not a tsc issue
that's weird
maybe something to do with locking and multithreading?
Thinking about using uint64_t as handle_t. What could go wrong?
nvm
Too much work
Not as good as GDT INIT OK!
There's something wrong with registers
left side results in GPF
While the right one works properly
Status Update: Refactoring various subsystems for more stability and performance
most of my post-smp locks are now qspinlocks or queued rwlocks
RCU is still PITA
BTW managed to fix the timing issue
Threaded interrupts, Baby!
Alright here's my dumb idea: Kernel only handles the core part in scheduling (context switch, notifying that the thread has expired, etc.) while a userspace service manages the policy work.
For a microkernel, this seems reasonable ig
comparable to minix 3's userland scheduling
Well, that's a starting point
Thnx for the reference btw
i do something similar in my hypervisor, where the hypervisor handles context switching etc, and I have a 'root partition' (trusted vm) that assigns vcpus to scheduling frames, picks their criticality level, and timeslices, it is also responsible for raising/lowering a criticality filter on schedulers.
A lightweight separation kernel designed specifically for adaptability, real-time computing, and mixed-criticality workloads - MicroOperations/Twan
First test with Capabilities-based communication
this is a microkernel right?
Yeah, I'm slowly refactoring it from monolithic to micro
gonna be a big change
I forgot that kernel wasn't supposed to allocate on behalf of the user
Yeah, vspace is getting booted out completely
what design are you targeting?
And scheduling will be ported to userspace
sth like Zircon or seL4
A mix of L4, Zircon, Mach + My own design
very cool
also just pure microkernel right?
Like my IPC is a mix of L4, Zircon and Mach
Yeah
ah
Kernel will only provide essential services
It's likely that RB trees, Xarray, everything else will be ported to userspace
I wanted to build a microkernel from the beginning
But overtime, my focus shifted to adding more features to the kernel
and I ignored the fact that kernel wasn't supposed to define the policy
only mechanism
relatable
at least yours wasnt like xnu
the modules (kexts) control the kernel policy
Like, at one point, I managed to identify my mistake with sched_classes
But that was still too monolithic
Rn, my focus is on maturing my capabilities subsystem and slowly port stuff out of the kernel
And maybe initialize the root server
It's gonna be a big rewrite
Should've planned in advance
Time for a rewrite
I'm gonna push the current code and then switch to a new branch
I hate writing build scripts
For me, That's more difficult than getting the actual kernel running
whar?
Writing a microkernel is hard, I gave up on the rewrite
Now, I'll continue the project from its current state
With some architectural changes if needed
Inspired from Zircon, Inroducing Aegis-ID
Similar to Zircon's Kernel Object ID (KOID), Aegis generates unique, unpredictable 64-bit IDs for kernel objects without triggering any memory locks
Aegis splits the 64-bit integer into two fields
Bits 63-56 contains the type tag used to identify the object
Whereas the rest are Scrambled Payloads derived (4-round Feistel Scrambler) from a per-cpu counter which is backed by a global counter base
Just for future reference, the constants are borrowed from fmix32 of MurmurHash3 (creator: Austin Appleby)
To prevent Avalanche effect
Actually this scrambling part is fmix32
whar is this software ๐
also made #1487781250310734005 heard you give up Noise v2 because you were making too much c++ boilerplate
scc
Don't remind me of those dark days
Tbh the main problem isn't with libcpp or template but the functions that is inserted by the compiler
You need define a way to call global constructors, and destructors
And that way isn't standard, it changes with architecture or abi
standard lib issue can be solved but what embedded C++ needs is a common compiler-rt or libstdc++
Which can be easily compiled
Instead of trying several irons in the fire, figuring out a way to compile and then link that to the kernel executable
The biggest hurdle for me was libcpp-abi
That thing refused to compile
๐
GDT INIT.... OK!
great progress though did you change the font
i used to not like it
but now i do
Yup, I switched to Jetbrains Mono
using your hand rolled ttf converter?
Yup
familiar enough
For better demonstration:
Somehow my qsbr thread is clashing with RCU thread
QSBR in kernel?
It shouldn't be in the kernel?
If not then I'm gonna happily remove it
not too sure
but i dont see it quite often
This thing is causing issues, Idk how
Or why
Can't use a debugger because it doesn't work well with interrupts
dump_stacktrace() somehow caused GPF
a bit of research says it suitable for networking and userspace rcu
relatable enough
Alright time to remove this monstrosity
Networking is for the userspace to manage
just disable it and test
especially for a microkernel (ig)
RCU test succeeds if I disable QSBR
what about the other way around?
to test if qsbr is actually working
without RCU
or it works but breaks rcu?
Somehow thread_create() is causing issues lol
!?
then its a deeper
maybe a chain of problems ๐
I think it has something to do with the slab allocator
I'll investigate it later on
Problems inside problems
And the cycle continues...
actually implementing one for my library
Exposing as kmem_cache or a global slab allocator?
its just the core logic
and you can assign it to allocator wrappers
Oh
using concepts
compile time functions my beloved
Should I just port this to the userspace? because most of functions used here are already exposed as syscalls
int64_t sys_fork(struct syscall_regs* regs) {
uint64_t proc_cap, cnode_cap, vspace_cap;
int64_t err = sys_cap_clone(0, nullptr, regs, &proc_cap, &cnode_cap, &vspace_cap);
if (err < 0) return err;
thread_t* curr = smp_current_core()->curr_thread;
struct capability* cap = cap_lookup(curr->owner->root_cnode, proc_cap, RIGHT_READ);
process_t* child_proc =
(process_t*)atomic_load_explicit(&cap->object_ptr, memory_order_acquire);
uint64_t child_koid = child_proc->kobj.koid;
cap_close(curr->owner->root_cnode, cnode_cap);
cap_close(curr->owner->root_cnode, vspace_cap);
return (int64_t)child_koid;
}
fork() now uses Capabilities and related components instead of blindly copying from the parent
Spent approx 20 mins figuring out why rcu_data was causing a GPF
I forgot to memset rcu_data
:/
lmao, i spent 30 just to realized i need to memset the (font selection) cmdline buffer (which was also causing gpf)
I was doing it wrong
POSIX syscalls shouldn't be in the kernel
Kernel will only expose native syscalls and the POSIX translation will be handled by a dedicated Userspace service
(The Managarm way)
My approach to syscalls:
There are 4 main categories (as of now): Sched, memory, IPC, Capabilities
Each category can hold upto 0x99 syscalls
I'm trying to only expose syscalls that are absolutely needed and leaving most work to the userspace
Like in spawn_thread() doesn't allocate the user stack, that's on the caller to provide
Most creation syscalls would like return their own capabilities, which is the only way userspace can interact with the underlying subsystems
process and thread creation would be non-POSIX way, an empty environment will be created for a new process
Maybe I would also expose clone() to userspace for supporting fork() in POSIX translation layer
- 0xff
i also had a somewhat similar (maybe not) idea of syscalls, i implement the linux syscall table normally and use some special value when syscalling the kernel for it to switch to an extended syscall table
but aerosync wont be worked on anymore (at least until i cant use macos 26 anymore)
Why can't u use mac 26?
apple being apple and stop supporting macos 26 (completely)
macos 27 is probably gonna release lateer this year or next year
but as macos 26 is still recent
it would still get updates
the only major issue is the web browsers
not short tho (~5yrs if things go as planned)
Oh
aparently hurd is back https://www.phoronix.com/news/Gentoo-GNU-Hurd-Experimental @simple locust
Good news: process_create() and thread_spawn() syscalls are working
Bad news: Pagemap is brand new so, I need to figure out a way to map the program into it
Pure capabilities only process_create() and thread_spawn() syscalls
๐ญ
Thread/Process cloning
This call can optionally create a new process or have two processes share the same memory space
Technically, the demonstrated behavior is similar to fork()+execv()
Non-clone() Process creation and thread spawning
I still need to figure out a way to map elf on the run
But that'll prolly need a loader microserver
rn, I'm just hijacking process_create() to also map the test elf in its vspace
In future, I want the microserver to load and map the elf in the new process before thread_spawn() can create the thread
IPC test :)
Rn I'm only working on OS specific library so that it could be used in future userspace programs
thats what im doing (but in C++) 
Limine provides TSC frequency too, maybe I should Update my tsc function to read from that
HPET can now be a userspace driver
Most modern x86 cpus already have TSC and LAPIC
So, PIT and HPET can be moved to userspace
The cutoff could be Nehalem for Intel and family 10h for amd
Putting it around ~2008-ish
Update: Removed HPET and PIT, thank you Limine
what
oh really?
Yeah, I was just using them for calculating tsc frequency
But now that Limine supports tsc frequency requests, I can just fetch it straight from the bootloader
That's the plan anyway
HPET daemon, which can be used if any program requests it
MMIO can be handled via IOMMU
oh
plus i didnt know fedora rice can have close buttons on the left
It's a gnome feature, I think you need to install Gnome tweaks
oh cool
IPC Timers (Key 512 is a periodic timer with 500k ns interval, key 256 is a oneshot timer 2 sec delay)
Ticks count could be low because of snprintf() and write() overhead
Somehow TSC time is drifting...
With 50k ns interval (it's about 38080 ticks (~1904 ms))
Underhood it's just LAPIC in TSC deadline mode
Read-Copy-Write ๐
what ๐ฅ
RCW instead of RCU
Any interval below 40000 ns isn't registered by IPC :(
Time to implement timer overruns
Nvm, interrupt/syscall/<insert other random mechanism here> overhead takes about ~35us
I'm limited by hardware and physics 
Now, I need to add some compensation mechanism to the timer
Maybe this drift is also a result of that
Maybe IPC overhead too
accessing memory is slow
sched_cost = 1192 ns
hr timer = 40 ns
lr timer = 50 ns
Where's it wasting the rest ~33.1 us?
Definitely not the interrupt overhead
Because the LAPIC timer isn't periodic
I believe it has something to do with scheduler_tick or something
Because pprt_notify unblocks a thread, so the kernel needs to call scheduler_tick() before it could switch to userspace
Managed to bring the minimum time to 10000ns
This only effect periodic timers, interesting...
Wrote new syscall interface for Memory operations
I'm trying to make everything as explicit as possible
A syscall would only touch components that aren't explicitly exposed to the user
So, vspace_map() couldn't create its own vmo
And most operations still depend on the process's capabilities
is that a bad thing for a microkernel or?
No
It's part of system security
No process can call restricted operations
Spent last couple of days working on VMA and Paging
and exposing syscalls to userspace
Maybe pause and write documentation
as most of the syscalls are undocumented
cool
My main objective rn is to stabilize the kernel
And expose syscalls wherever it's necessary
After that I'll start with the root server, and subsequent servers
Also, I need to clean up locks as they're a mess rn
Maybe a common API for every lock, a lockguard most likely
Mainly for debugging
Btw, Exams suck
It sucks even more when you travel in 45C and an ongoing heatwave
Can't wait for Sunday
Almost rewrote my build configuration
Also wrote a interface for wpkru, just need to add a few flags and expose it as a syscall
I forgot wpkru is a not a privileged instruction and accidentally introduced a syscall for that too ๐
Rewriting my syscall interface
switch-cases are too slow
I could use arrays but that requires a unified interface for every syscall
Unless I trigger UB
would it be possible to mock syscall handler so it takes the same amount of arg as the most one?
UB
thats also ub?
And it breaks control flow integrity
right
I could in theory cast it to a function that takes 6 uint64_t and returns a uint64_t but that's UB and breaks kCFI
you have kcfi too?
in theory with c is mostly yes
I'll implement it sometime in the future
in theory with c is mostly yes
a sparc64 kernel targeting the sun4u
Then 10 days break before I've sem exams
After that, it's a relaxing 3 months break before the next semester starts
expected
This is what I want to do with my syscalls
typedef uint64_t (*syscall_handler_f)(struct interrupt_trapframe*);
quick and easy O(1) look up
btw sys_process_create?
yeah, creates a new and empty process
so a blank fork()? or brand new?
It only contains three capabilities: cnode, proc, and vspace
Brand new
clone() is as close as it gets to fork()
Even then there are some caveats
fair enough
so how do we populate it?
at first i thought it was NtCreateProcess lmao
spawn_process() creates and registers a capability in the parent process
The caller then can use that capability to configure the process
like setup the vspace, load executable, create a thread, etc.
Everything is explicit
I don't have a way to load an executable lol
youll eventually
not from disk but from cpio at least
for init
But yeah it's just fork() + execve() except it doesn't have to iterate VMOs or mark pagetables as CoW
Idk, I'll most likely just attach the root server as a module in limine
and have kernel launch directly into it
btw i now realize macos is not too good for osdev
Then the root server will handle initialization
have no idea what is that but sounds cool
Just loading a limine module as a thread
directly from the kernel
Implemented Message queueing. The kernel would wait for the receiver to acknowledge a message before data can be transferred to buffer (max capacity = 64KB)
I need to update my locks
Because:
- They're are non-blocking.
- The API is a mess
how much of a mess?
definitions are inconsistent
Quick Update: Rewriting the kernel (back to C++ baby!)
Main motivation: The architecture was a mess
I switched to capabilities all of a sudden
and that messed up a major portion of my codebase
PMM's policy was hard-coded in the kernel
VMM was a mess
It was better to rewrite it than attempt to fix it
I've also updated the build configuration
Added support for aarch64
Segregated different components, and after some quick experience with working on LLVM
I've started to appreciate writing documentation along with design notes
Rn my plan is to just write the mechanism in kernel space
Policy work will be handled by user-space
everything is a mess
port it to s390x 
I couldn't bother to write initialization code in assembly
Note to self: -mno-implicit-float over -mgeneral-regs-only, -mno-x87, -mno-80387
for c++ targets
I hate aarch64
Don't you love the moment when your code doesn't work the first
Then you spend hours debugging
With no solution
and suddenly at 2:58 pm, your original code magically works
space radiation vibes 
looking at this im actually thinking porting my latest project to C++
Could be actually
Use template and concept magic
Also, use this instead of explicitly disabling FPU
Clang has some weird quirks with fpu in x86_64-elf target
It would allow float, double, etc. But long double is banned for some reason
That caused my build to fail (because libstdc++ has long double targets)

thanks but actually im using it for s390x target, so lets see how this goes
one thing though
@simple locust for some reason, when i enabled ubsan (undefined and friends), s390x-ibm-linux-gnu-gcc doesnt get the job done that well
while clang does it like it should
Clang is more flexible than gcc
Might have something to do with that
Gcc can sometimes default to internal libubsan
For now, I'm just using Flanterm for logging
Because Limine doesn't map mmio in aarch64 :)
I'm not ready for aarch64
I can't get the right tooling setup rn
LLVM-libc can't be compiled because it adds SIMD instructions
and there's no way to disable it without breaking the build
There was a reason, I shifted to C from C++
And that was my habit of over-abstracting
So, Now I've a LogSink abstract class which is inherited by both Flanterm and Uart drivers which registers themselves to the LogManager which provides a static function that dispatches messages to each function.
Logger is a per-subsystem modular class, which formats messages via snprintf and then passes that message over to the LogManager
Btw, LogManager's messages are also configurable :)
I missed C++
Paging is up
heyy youre back
I hate to take a short break from working on the kernel because of sem exams
But That break did allow me to design the over-abstracted VMM
Also, PMM is just a bump allocator :)
And VMM doesn't necessarily need a PMM
in the kernel
Also, @inner glen should I map LIMINE_MEMMAP_RESERVED_MAPPED while mapping HHDM pages?
mapping HHDM pages?
Mapping all available RAM into kernel's HHDM
i know, but thats the bootloader jobs i think
I am replacing Limine's pagemap
so you are changing limime?
No. I am just initializing my own kernel pagemap
also i think its LIMINE_MEMMAP_RESERVED right?
There's a new memmap type
so basically remapping to your liking?
oh, looks like im outdated
havent updated the header for years
and havent touched x86 for a few months now
Yeah, just map the elf and ram to kernel space
Limine's on v12
WHAT
Also, Now I understand why Linux prefers static allocations
didnt know it was THAT fast
why though?
i think theres a flag that limits your stack usage
It's way easier and more deterministic
I was talking about storing data in kernel's BSS
or some other area
segment
it sure does
I'm pretty sure I've over-abstracted most of my components lol
do you heavily uses vmos?
VMOs are for user-space
I have a Bump allocator for Kernel's PMM
sounds like a trusted design
(and I'm pretty sure It'll be disabled in the coming commits)
Very trusted
Page fault when I access SMP request's response wtf
smp_logger.debug("smp_request = %p", boot::smp_request.response);
page faults?
Vector 14
I forgot to mark it as present in page table lol
I thought that every page was implicitly present
But I must've changed it
yes bruh ๐ i originally meant a "page fault, really?" ๐ญ
anyways
hows the os
got to any notable milestone
Limine for now
fair point
Not really. I was busy procrastinating
just my thought, you should make a generic layer that the kernel expect
and then just plug a loder into
I started playing Brawl Stars
like limine gives you hhdm and mb2 does not
Oh that
Makes sense
since we cant get everything loader to implement our protocol
I'll try to design a common interface
cool
yeah, though for example, hhdm
Yeah that game has evolved a lot lol
you should map it manually
or whatever your kenrel expect
not tied to how limine maps it
I believe HHDM for x86-64 is fixed
usually
LA57 and 4-lvl paging has different values for HHDM offset
but other than that it could be just a getter function
Maybe I'll have to implement AP startup code
That requires parsing MADT
I was hoping to remove that from the kernel
uacpi
remove what
APIC parsing
youre doing it manually?
But I'll have to deal with LAPIC
No
I just didn't want to include ACPI subcomponent in kernel
why?
microkernels dont do that
?
you mean your microkernel implementation
Yeah
I thought PCID management should be implemented in Userspace
Guess what? It's a bad design idea
Any malicious process can compromise it
isnt pcid for improved ctx switch performance or sth
Yeah but the PCID has to be assigned
By the kernel
@simple locust i just came back from my vacation
and talked with claude a bit about kernel designs
and it gave me capability-object, transactional, typestate-enforced, modular monolithic kernel
a mouthful name it is
but it somewhat make sense
i mean i could applied this to my kernel, since its a PoC and i dont really care about anything else
Capabilities give you what you can touch. Typestate gives you how you're allowed to touch it. Transactions give you when it's committed. They're orthogonal axes of the same resource management problem. A capability without typestate tells you "you can use this object" but not "you can use this object right now in this way". A transaction without typestate doesn't know which state rollback should restore to.
Untyped Capabilities?
Tho I wonder how would one counter forgery in a monolithic kernel
From what I've read about MADT MP Wakeup Mailbox, it is fairly straight forward:
- Fetch mailbox address from MADT table (Type 16)
- Find the physical address for higher-half wakeup stub (which loads CR3, and does the rest of the work)
- Store the target APIC ID
- Send Wakeup command
mailbox!?
MADT table type 16
It simplifies AP initialization
You don't need to jump from real mode -> protected mode -> long mode
oh
On second thought, I am going back to Limine only initialization
It's just way too complicated
no generic layer?
Nope
ig that would work, maybe im just a bit cautious about being stuck to one thing
for example i just realized if i switched to C++ modules ninja would be the only option for cmake
(theres vs22+ but who even use visual studio to build this stuff)
make supports it too iirc
Well there's nothing to support
no
and no plans either actually
neither the fancy FASTBuild nor Xcode
and despite its been since C++20 or so, Bazel just literally have "working" modules support
meson still experimental
oh
cmake probably best for cross platform, but not flawless ofc
and some how MSVC have best c++ modules support
well i think that the actual hassle is the STL modules
my kernel used modules from a-z, no problem
in fact it was great
BUT
STL modules are work in progress
c++ is still dumb asf, no where as good as rust use
Same with Libc++ (it doesn't support freestanding environment)
When Clang was designed for portability
good work llvm team
I don't want C++ to start having opinions tbh
sorry but C++ modules are still not flawless even though they are designed (supposedly) to fix #include issue
just a bit more
#include is great
right....
I hate summers
I just want to lay somewhere cold and be as unproductive as ever
Anyway, Wrote LAPIC subcomponent for the kernel
It took me a couple of weeks. But I think I've managed to make it as optimal as possible
Found some quirks in SDM but it was worth it
ayy youre back
fair point
I don't think I will be getting relief anytime soon
Monsoon is delayed, and the weather department is predicting 90% less rain due to El Nino
90% less ๐ฅ
Thinking about writing a code patcher for the kernel
code patcher?
Yeah, replace older instructions with newer and better instructions (if they're supported)
For example, Intel introduced rdgsbase instruction in 2012 and AMD introduced it in 2017. rdgsbase is faster than rdmsr
So, I want to replace those rdmsr instruction with rdgsbase if the CPU supports it
Same with serialize
isnt that just an if statement
In assembly?
I want to ensure the lowest latency possible
oh
in interrupt path
so it is still self modifying
sort of
or just be like microslop
or an annoying company that demands you have a good enough cpu
I'm demanding a CPU which was released after 2008
maybe
I want it to look something like this:
ALTERNATIVE( \
.L_manual_loop: \
movb (%rsi), %al ; \
movb %al, (%rdi) ; \
inc %rsi ; \
inc %rdi ; \
dec %rcx ; \
jnz .L_manual_loop , \
rep movsb , \
FEATURE_ERMS_MEMCPY \
)
@inner glen
rep movsb would be stored in a separate elf section
And the patcher could just jump in and patch it out at boot
It took me a while to design it
sounds very safe to me
oh wait
linux already done it
oh i understand why the macro is named ALTERNATIVE now
Yeah, this how live patching works kinda
It creates an alias for the physical address of that instruction page and applies changes directly to it
oh you are right
now maybe i will think about this
currently im just abusing [[unlikely]]
inline auto stckf() noexcept -> u64 {
u64 tod{0};
static bool checked{false};
static bool has_stckf{false};
if (!checked) {
u64 fac{0};
register u64 r0 __asm__("0") = 0;
register u64 r1 __asm__("1") = reinterpret_cast<u64>(&fac);
__asm__ volatile(
" .insn s,0xb2b00000,0(%[addr])\n"
:
: [addr] "a" (r1), "d" (r0)
: "cc", "memory"
);
has_stckf = (fac & (1ULL << (63U - 25U))) != 0;
checked = true;
}
if (has_stckf) [[likely]] {
__asm__ volatile("stckf %0" : "=Q" (tod) :: "cc", "memory");
} else {
__asm__ volatile("stck %0" : "=Q" (tod) :: "cc", "memory");
}
return tod;
}
for example this piece of code
and a hundred more
well, at least this one isnt called in hot paths
I would've used it if the code wasn't critical
A branch condition
ALT_BEGIN
movl $MSR_GS_BASE, %ecx
rdmsr
testl %edx, %edx
ALT_REPL 64
rdgsbaseq %rax
testq %rax, %rax
ALT_END
This one looks much cleaner
@inner glen what do u think?
Yeah it works
I figured that if those double-quotes are used for just putting instructions in the correct section
It would be better to just break it down into 3 different macros
than limit myself from using other macros in the code
you mean the linux one?
Ig Linux uses C-preprocessor macros
I don't remember tbh
I also updated my patcher to accurately calculate RIP relative addresses
And Kinda wrote a x86-64 decoder ;-;
๐ฅ
i thought your kernel is C?
Nah, I was back to C++
I'm designing it so delicately
for me it feels like a switch with fallthrough cases looks better
My first design of LAPIC used separate X2APIC and XAPIC transport structs as templates
It would've been too long
Like this is the smallest function in the decoder
so theres more?
Yeah
This functions only checks if the instruction is ModR/M
There's another which calculates its displacement
etc
please no reinvent qemu in kernel space
I'm not reinventing it
It was necessary for fixing up some instructions in Patcher
like RIP-relative addressing
Future proofing rn
fair point
Maybe I'll expand it to compiler generated code sometime in the future
Just for eliminating branching
I think my FRED subsystem is ready to be tested
Just need to figure out how to get intel's simulator to work with my build configuration
qemu supports fred?
ah simics
oh lmao this is the first time i compiled your os
the only issue is i use https
so please fix it if you can with the cpm thing @simple locust which is cool
your build configuration works like autoconf
and is not autoconf so much better
Thanks. I spent weeks working on it
vrey nice
Maybe I should replace the ssh links with https
yes, of course
its more versitile
or
you just fall back
On it ๐ซก
So, apparently KVM can reject MSR reads/writes
AMD's P-state MSR: 0xC0010064 is one such MSR which can be rejected by the hypervisor
just had that minutes ago from linux kernel log
I hadn't thought that I would've to also read Hypervisor CPUIDs but alas
dont hypervisors behave differently tho
Yeah
But they may provide useful data
like TSC clock rate
Tho I need to confirm if the rate matches with the one reported by Limine's TSC freq request
accelerate stuff
should trust limine imo
or just use them all
There's not guarantee that it won't be removed in the future