klange changed the topic of #osdev to: Operating System Development || Don't ask to ask---just ask! || For 3+ LoC, use a pastebin (for example https://gist.github.com/) || Stats + Old logs: http://osdev-logs.qzx.com New Logs: https://libera.irclog.whitequark.org/osdev || Visit https://wiki.osdev.org and https://forum.osdev.org || Books: https://wiki.osdev.org/Books
<gog> -Oslow
<zid> -Ofast-but-not-too-fast-please
<nikolar> zid: isn't that just -O2
<karenw> Og: Fast but debuggable. O2: Fast. O3: Fscking Fast. Ofast/O3+ffast-math: Screw the rules, I want speed.
<karenw> Os: Being small *is* fast.
<zid> Os "We tried"
<nikolar> what does Og do different to O2
<zid> doesn't remove vars, mainly
<zid> gdb is pretty awful to use when everything says <value optimized out>
<Ermine> Os: we need to fit in 128K of space and ideally leave half of it free
<zid> Os: 135k is fine right?
<Ermine> or in case of router, 4M, but we're also using squashfs...
<karenw> Og is defined as "all optimizations that don't intefere with debugging"
<karenw> It's somewhere between -O0 (the default) and -O2, but is orthogonal to -O1
<zid> My favourite is -O3 but it goes insane and gets slower
<zid> because it tried to be clever and inline everything into everything
<zid> and blew away icache or something
<karenw> Gentoo advises against O3 for that reason
<karenw> Of course... >using gentoo unironically
<zid> O3 is fine 99.9% of the time
<zid> known buggy things get their clags overridden anyway
<heat> nikolar, Og is a nop in clang
<nikolar> yeah i thougth so
<heat> O0: glue smells funny haha
<kof673> -Ogentle-but-firm
Dead_Bush_Sanpa1 has joined #osdev
Dead_Bush_Sanpai has quit [Ping timeout: 260 seconds]
Dead_Bush_Sanpa1 is now known as Dead_Bush_Sanpai
Dead_Bush_Sanpa1 has joined #osdev
Dead_Bush_Sanpai has quit [Ping timeout: 244 seconds]
Dead_Bush_Sanpa1 is now known as Dead_Bush_Sanpai
frkzoid has quit [Read error: Connection reset by peer]
frkazoid333 has joined #osdev
msv has quit [Remote host closed the connection]
msv has joined #osdev
chiselfuse has quit [Ping timeout: 264 seconds]
chiselfuse has joined #osdev
hwpplayer1 has joined #osdev
zu0_ has joined #osdev
zu0_ has quit [Quit: 0]
zu0 has joined #osdev
qubasa has joined #osdev
theruran has quit [Quit: Connection closed for inactivity]
chiselfuse has quit [Ping timeout: 264 seconds]
chiselfuse has joined #osdev
hwpplayer1 has quit [Quit: I'll be back later]
gog has quit [Quit: byee]
karenw has quit [Ping timeout: 248 seconds]
terrorjack4 has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack45 has joined #osdev
edr has quit [Quit: Leaving]
craigo has quit [Ping timeout: 276 seconds]
EChelownED has joined #osdev
<EChelownED> hello all
runxiyu has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
runxiyu has joined #osdev
rayan has joined #osdev
<rayan> hi
<rayan> wakey wakey
<rayan> my context switching is dying
<rayan> :noo:
<EChelownED> centos EOL ?
<EChelownED> you make your own OS here?
<EChelownED> does anyone modify windows
heat has quit [Ping timeout: 245 seconds]
<rayan> bro
<rayan> lol
<Mutabah> EChelownED: Yes, this channel is for people writing their own OS
<Mutabah> which usually means kernel and userland shims (and sometimes full userlands, othertimes porting standard unix tools)
<rayan> mutabah
<rayan> why the actual hell
<EChelownED> cool
<zijjgfs> man making an OS is soo much work
<zijjgfs> too bad they dont have some kind of libOS
<rayan> does my scheduler refuse to work
<rayan> after i changed
<rayan> ONE
<rayan> LOC
<EChelownED> i want to obliterate my windows server 2019
<rayan> i debugged with gdb
<rayan> and the stack is somehow getting corrupted now?
<Mutabah> rayan: enter is not punctuation, please write full sentances
<EChelownED> i want to take back control of my PC
<rayan> okay sorry.
<Mutabah> Especially when pinging someone
<Mutabah> rayan: Crystal ball says that you got your SP wrong
<rayan> Basically, my kernel is getting its return address somehow corrupted and is no longer returning to the thread anymore.
<Mutabah> OR, you aren't saving/restoring state properly in an interrupt handler
<rayan> oh i do
<EChelownED> does anyone have a working OS yet
<zijjgfs> hey guys i used ChatGPT to write my own OS ;) aren't i clever? got it done in 1/10th the time. u all wish u were as productive as moi
<rayan> all my stubs have saving and restoring state yet
<rayan> are*
<zijjgfs> 1000% productivity boost with AI here
<rayan> why did i say yet, minus the yet as well
<Mutabah> EChelownED: Define working :) I got my previous project up to running an IRC client
<rayan> i dont know whats going on, gdb is leading me nowhere.
<zijjgfs> i got it so optimized that it only takes me 2 days 19 hours and 54 minutes to make an OS
<Mutabah> rayan: qemu? It has basic instruction tracing that may help
<rayan> qemu + gdb
<rayan> i put a bunch of printfs and well, nowhere either. all i know that it seems to get corrupted after leaving preemption
<rayan> note that I use -O2 and clang but what i do in schedd task is very basic
<Mutabah> double-check your stack by single-stepping through taht code?
<rayan> yes
<Mutabah> _instruciton_ single-stepping
<rayan> yes i have.
<bslsk05> ​www.qemu.org: Record/replay — QEMU documentation
<zijjgfs> right now my OS factory employs 200 illegal mexicans making OSes just the same way I did, but it's still not efficient enough, i'm thinking of replacing them w/ H1-B indians. they work somewhat harder and you know how they <3 tech
<EChelownED> how does the OS operate Mutabah
<zijjgfs> maybe in a couple years when AGI improves i can replace them with AI
<EChelownED> like is it a spin off of linux or what is it
<zijjgfs> and then i can use AI to prompt AI to make OSes even faster
<rayan> i will try qemu replay
<Mutabah> zijjgfs: Chill out dude
<zijjgfs> then i will DOMINATE the OS market and rule the world... muahahahaha
<rayan> the limine bootloader just dies
<zijjgfs> Mutabah: U prolly havent even made one single OS yet u joker
<rayan> when trying replay
<Mutabah> EChelownED: My previous one? It was nearly all custom code, just implemented a unix-like syscall interface - so porting most software was not too hard
<rayan> so thats a no go
<zijjgfs> I can pump them out a dozen at a time like hotcakes.
<rayan> maybe u'll find something i missed Mutabah? heres some source code: https://github.com/rayanmargham/NyauxKC/blob/master/kernel/src/sched/sched.c
<bslsk05> ​github.com: NyauxKC/kernel/src/sched/sched.c at master · rayanmargham/NyauxKC · GitHub
<rayan> you will find the stubs in isrstubs.asm
<rayan> check gdte.asm for the context switching
<EChelownED> why do you all make your own OS
<Mutabah> EChelownED: Fun :)
<zijjgfs> because some guy on reddit told me i couldnt do it. so i showed him!!!
<Mutabah> rayan: What line did you change to break things? That may have clues
<rayan> i just made a switch queue function
<zijjgfs> there's no way you're going to be able to tell with his commit messages
<Mutabah> Looking at gdte.asm (strange place for task switching code, shouldn't be related to gdt), it has hard-coded structure offsets
<zijjgfs> > ttttryueru
<Mutabah> with minimal comments
<rayan> yes i verified the offsets to be correct
<rayan> i think there may be UB going on
<zijjgfs> rayan you should learn about the pause instruction
<rayan> yea i know what a pause instruction is
<rayan> it is for the spinlock wait loop
<rayan> it hints to the processor to avoid memory order violations
<zijjgfs> there are other effects
<rayan> even then, that shouldnt effect the scheduler
<zijjgfs> i was looking at your second to last commit
<kof673> > some kind of libOS there was an oskit and other things but unmaintained, ancient, etc.
<rayan> i dont know whats going on to be fair
<kof673> that was somewhat the idea, let you get linux/bsd/whatever drivers "for free" and focus on whatever your real goal is
<zijjgfs> rayan why are you making an os then wth
<rayan> i had also verified everything on real hw
<zijjgfs> so why don't you bisect the breaking commit
<rayan> zijjgfs bro
<zijjgfs> kof i was obviously being facetious
<rayan> there is literarly no reason
<kof673> i sensed that, just saying :D
<rayan> a few locs can change how context switching works
<kof673> various projects did want "universal drivers" but not sure they ever get anywhere...
<rayan> i just changed the way i did my queue logic end of story
<zijjgfs> ndis?
<zijjgfs> lol
<zijjgfs> rayan then you know how solve the problem, why are you on irc
<rayan> bro, the queuing logic is not the problem
<Mutabah> rayan: Maybe your queue logic is wrong enough that it's corrupted the queue? And is now attempting to run a dead task?
<rayan> i check for NULL objects
<rayan> all memory is memsetted too
<rayan> Mutabah it shouldnt be happening like that to be fair
<Mutabah> rayan: The context switch code checks out... although, it would be better to pass `&old->kernel_stack_ptr` instead of `old` to it - so the assembly doesn't need to know offsets
<Mutabah> also, have that function handle changing CR3 - allows you to have kernel stacks in different address spaces
<rayan> it does
<rayan> its ur job to worry about that
<rayan> as a kernel
frytaped has joined #osdev
frytaped has quit [Remote host closed the connection]
<rayan> anyways Mutabah
<rayan> this is very weird
frytaped has joined #osdev
<Mutabah> My suggestion would be to print out the thread pointers, to check that they are consistent
<zijjgfs> rayan you shouldve used Python. then you could've just done 'import sched' and then bam
<rayan> zijjgfs please stop attempting to insult me
<zijjgfs> im just trying to help jeez
<rayan> thats not help
<Mutabah> Oh, and that copy-pasted code you have for pushing/popping those registers?
<rayan> yea what about that
<Mutabah> Those are the callee-save registers in the ABI.
<zijjgfs> in fact u have libos built into python, could just do 'import os' gg no re kthx
<Mutabah> zijjgfs: Please stop.
<zijjgfs> okay
<rayan> Mutabah what about them
<Mutabah> If you don't have anything productive to say, don't say anything
<zijjgfs> i thought we all act like clowns in clown world
<Mutabah> rayan: You have a comment implying that you don't know, thought I'd tell you why
<Mutabah> (also, https://github.com/thepowersgang/rust_os/blob/master/Kernel/Core/arch/amd64/start.asm#L408-L449 - here's my version of that same function, simple is best)
<bslsk05> ​github.com: rust_os/Kernel/Core/arch/amd64/start.asm at master · thepowersgang/rust_os · GitHub
<rayan> oh yes that makes sense
<zijjgfs> I just don't get why rayan can't figure this out on his own. like i said, could diagnose it by bisecting commits, using version control kinda what it was made for
<rayan> Mutabah that makes sense for the ABI yea
<rayan> zijjgfs already did
<Mutabah> zijjgfs: have you seen the size of the commit that probably broke things?
<zijjgfs> nope
<zijjgfs> well i guess there's a lesson
<Mutabah> rayan: Maybe also see if you can figure out why limine breaks with record+replay? That slightly surprises me (maybe it's a bug that is fixed in a newer qemu, if you have an older one currently)
<rayan> i cant change qemu versions
<rayan> sadlyh
<rayan> im using wsl
<Mutabah> compile it manually?
<rayan> would be too much time
<rayan> considering my CPU
<Mutabah> Iirc, it's a 30min-1hr compile on an ultrabook CPU
<rayan> no i mean
<rayan> my cpu is really really REALLY old
<rayan> either way, maybe you can try to compile it
<rayan> its quite simple, just run the make command
<rayan> all deps should be gotten for you
<Mutabah> I'm not going to debug this entirely for you
<rayan> that was not what i was suggesting but okay
<rayan> anyways Mutabah i will print the thread pointers
<rayan> old thread 0xffff800000006018, new thread 0xffff800000006018old thread 0xffff800000006018, new thread 0xffff800000006018
<rayan> all looks consisent Mutabah
<rayan> it is happening at context switch
<rayan> i verified that with gdb
<rayan> the ret is taking me to the schedd
<Mutabah> would there be any race if you switch to yourself?
<rayan> no as all cpus have their own queue
<rayan> and touch only THEIR queue
<rayan> the ret in the do_savekstackandloadkstack should take me to return_from_kernel_in_new_thread
<rayan> meaning the stack is probs getting corrupted somehow
<Mutabah> Oh, is this a newly created thread?
<rayan> yes
<Mutabah> let's look for that code too then
<rayan> check main.c
<rayan> check sched.c for create_kentry
<Mutabah> Hmmm.... so, there is a requirement that the stack be aligned to 16 bytes at a `call` instruction iirc
<rayan> it is though
<Mutabah> I don't think that holds with that newly created stack
<rayan> how do i make it 16 byte aligned then?
<Mutabah> `StackFrame` is 22 words, there's one for the ret address, then 6 saved registers
<Mutabah> Maybe that's causing corruption inside the `change_rsp0` function - check its disassembly
<rayan> 22 dwords*
<rayan> and hold on
<clever> rayan: whatever creates the initial stack, needs to decrement the stack by enough to make it aligned, which can be done with just an AND operation, clear those lower bits!
<Mutabah> add a dummy push to the start of `do_savekstackandloadkstack` ?
<clever> and anything that decrements the stack to make room for vars, needs to decrement it a bit extra
<Mutabah> By "words" I meant 64-bit native machine words, not 16-bit intel "words"
<clever> and of course, undo that when returning
<rayan> how much dummy pushes will i add
<rayan> just one Mutabah?
<clever> 22 x 64bit, is 176 bytes, or 11*16 bytes
<Mutabah> Just one, to make the push count odd (which, with the pushed RA in `call` would align the stack to an even qword count)
<clever> so 22 x 64bit, is already a multiple of 16 bytes
<rayan> okay
<rayan> hold on
<Mutabah> clever: 6 pushed registers plus the one RA leads to an unaligned stack at the `call change_rsp0` instruction
<clever> the key, is that 16 bytes, is 2 x 64bit, so if the number of 64bit words is even, its already a multiple of 16
<clever> Mutabah: ah, that wouldnt be 22 words long then, but something else, and if all of those are 64bit, thats 7, which isnt even
<rayan> that causes a fault
<rayan> 0xe
<rayan> unpresent page
<rayan> idt stub 54
<rayan> yea um
<rayan> yea thats what occurs i suppose
<rayan> nvm, put the push in the wrong place
<rayan> still
<rayan> thread doesnt execute still :(
<rayan> Mutabah and clever
Dead_Bush_Sanpai has quit [Ping timeout: 244 seconds]
<EChelownED> what are some other good servers
<EChelownED> this chat so far good one
<EChelownED> or channels
hwpplayer1 has joined #osdev
<Mutabah> rayan: Single-step and see where the bad value comes from?
<Mutabah> (oh hey, qemu build is complete)
<rayan> its stuck in send_eoi???
<rayan> it iretqs to send eoi
<rayan> all the time
<rayan> wtf
<rayan> ye athis is very weird
<rayan> what the hell why is it iretqing to send eoi ? Mutabah
<Mutabah> Not sure, when I see "EOI" I assuming it's sending the EOI message to the interrupt controller (which is an `out` instruction, not `iretq`)
<rayan> yes
<rayan> but iretq is returning to send eoi function
<rayan> which makes ZERO sense
<rayan> and its iretqing in the isr stub, not in the return from kernel in new thread
rayan has quit [Quit: Leaving]
<Mutabah> single-step, and check the state and value of RSP.
frytaped has quit [Quit: WeeChat 4.4.2]
frytaped has joined #osdev
frytaped has quit [Max SendQ exceeded]
frytaped has joined #osdev
frytaped has quit [Max SendQ exceeded]
frytaped has joined #osdev
frytaped has quit [Max SendQ exceeded]
frytaped has joined #osdev
frytaped has quit [Max SendQ exceeded]
frytaped has joined #osdev
frytaped has quit [Read error: Connection reset by peer]
Dead_Bush_Sanpai has joined #osdev
EChelownED has quit [Remote host closed the connection]
karenw has joined #osdev
frytaped has joined #osdev
frytaped has quit [Max SendQ exceeded]
frytaped has joined #osdev
GeDaMo has joined #osdev
goliath has joined #osdev
housemate has joined #osdev
hwpplayer1 has quit [Quit: I'll be back later]
goliath has quit [Quit: SIGSEGV]
housemate has quit [Quit: Nothing to see here. I wasn't there. I take IRC seriously.]
jedesa has joined #osdev
x64S has quit [Quit: Leaving]
msv has quit [Ping timeout: 260 seconds]
msv has joined #osdev
Left_Turn has joined #osdev
xal has quit [Quit: No Ping reply in 180 seconds.]
xal has joined #osdev
<cloudowind> happy new year people , Un used the term first time ive seen "climate breakdown " for 2025.. lets see how happy its going to be
hwpplayer1 has joined #osdev
\Test_User has quit [Quit: \Test_User]
\Test_User has joined #osdev
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 265 seconds]
edr has joined #osdev
mavhq has quit [Read error: Connection reset by peer]
mavhq has joined #osdev
mavhq has quit [Read error: Connection reset by peer]
craigo has joined #osdev
yakubin has joined #osdev
heat has joined #osdev
qookie has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
Arsen has quit [Quit: Quit.]
mavhq has joined #osdev
Arsen has joined #osdev
qookie has joined #osdev
theruran has joined #osdev
alexander_ is now known as alexander
frytaped has quit [Quit: WeeChat 4.4.2]
frytaped has joined #osdev
sidcha has joined #osdev
Left_Turn has joined #osdev
sidcha has quit [Client Quit]
sidcha has joined #osdev
Turn_Left has quit [Ping timeout: 244 seconds]
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 276 seconds]
hwpplayer1 has quit [Remote host closed the connection]
goliath has joined #osdev
vdamewood has joined #osdev
steelswords9436 has quit [Read error: Connection reset by peer]
steelswords9436 has joined #osdev
sidcha has quit [Quit: The Lounge - https://thelounge.chat]
sidcha has joined #osdev
housemate has joined #osdev
the_oz has quit [Remote host closed the connection]
the_oz has joined #osdev
karenw has quit [Remote host closed the connection]
karenw has joined #osdev
f_ has quit [Remote host closed the connection]
f_ has joined #osdev
frytaped has quit [Quit: WeeChat 4.4.2]
kpel has joined #osdev
Left_Turn has joined #osdev
housemate has quit [Quit: Nothing to see here. I wasn't there. I take IRC seriously.]
Turn_Left has quit [Ping timeout: 260 seconds]
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 246 seconds]
Left_Turn has joined #osdev
Turn_Left has quit [Ping timeout: 245 seconds]
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 246 seconds]
Left_Turn has joined #osdev
Left_Turn has quit [Remote host closed the connection]
Left_Turn has joined #osdev
Turn_Left has quit [Ping timeout: 264 seconds]
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 265 seconds]
GeDaMo has quit [Quit: 0wt 0f v0w3ls.]
vdamewood has quit [Quit: My Unrecognized Mac has gone to sleep. ZZZzzz…]
Lucretia has joined #osdev
cloudowind has quit [Ping timeout: 265 seconds]
Fingel has joined #osdev
cloudowind has joined #osdev
heat_ has joined #osdev
heat has quit [Ping timeout: 248 seconds]
goliath has quit [Quit: SIGSEGV]
heat_ has quit [Remote host closed the connection]
heat_ has joined #osdev
craigo has quit [Quit: Leaving]
heat_ has quit [Remote host closed the connection]
heat_ has joined #osdev
<nikolar> Happy new kerneling year
<sortie> Who's OS is already in 2025? Mine runs on UTC :3
<nikolar> *whose :P
Turn_Left has quit [Read error: Connection reset by peer]
<sbalmos> ktime: Core 2 in future compared to Core 0. Core 1 in past compared to Core 0. Reality determined to be nonlinear. System halted.
<sortie> UTC & Year of the Sortix in 60 seconds!