#EvalynOS

1 messages · Page 4 of 1

viral bison
#

their id is always 0

hazy saddle
#

yeah ima fix that

viral bison
#

anyway, if you are using single core, i have added a function to get the current thread in those patches

#

if you wanna apply them

hazy saddle
#

btw @viral bison my int 0x69 syscalls are my non POSIX ones

#

that im gonna axe eventualy

viral bison
#

k

hazy saddle
#

yoooo

viral bison
#

gg

hazy saddle
#

Now I gotta port a libc

viral bison
#

mlibc

hazy saddle
#

It looks scary pwease

viral bison
#

it's not

hazy saddle
#

So how do I do it

viral bison
#

there is a guide

#

#curated-resources

hazy saddle
#

Before I push I’m gonna make a Mandelbrot program and a generic k thread for making user programs and a function

#

And then we can have some fun

#

My kernel is free from the curses

#

I meaaannnn

#

I kind of load an elf

viral bison
#

lol

hazy saddle
#

I did read that mlibc will mainline ports for other kernels

#

I doubt mine is going in there tho

viral bison
#

idk, maybe

hazy saddle
#

they still synced for some reason @viral bison

viral bison
#

lol idk

hazy saddle
#

and and

#

the first one waits for the ither to catch up

viral bison
#

that's strange

hazy saddle
#

its as if some varribles are being shared??

#

but they properly move places

viral bison
#

did you apply my patches?

hazy saddle
#

Let me try those

#

apply to a fresh tree right

viral bison
#

yes

hazy saddle
#

@viral bison your patchset does the same

viral bison
#

hmm

hazy saddle
#

leme give you my patch set with the debuggable bad apple

viral bison
#

oh i think i know

#

the app is resetting the PIT cycles

hazy saddle
#

OHHH RIGHT

viral bison
#

you should not do that

hazy saddle
viral bison
#

btw, keep editing my patches

hazy saddle
viral bison
#

those have some more fixes

hazy saddle
#

ooo like what else?

viral bison
#

the vmm share pages fix

#

and a ctx switch one

#

tho i forgot to change this back to this

#

and remove the *--stack for the pagemap pasisng under it

hazy saddle
#

IT WORKS

viral bison
#

perfect

hazy saddle
#

redoing the bad apple for int match and not needing to touch the PIT

viral bison
#

you could still get the PIT ticks

hazy saddle
#

Oh I meant as in reprogramming it

viral bison
#

and convert the base freq to the amount of ticks needed

hazy saddle
#

It can still read it

#

I wana say thank you so much for the help @viral bison

viral bison
#

np

hazy saddle
#

@viral bison I have a really stupid idea but I wana add a kernel level compositor

viral bison
#

huuh

#

don't do that XD

hazy saddle
#

Not a full WM though 😭

#

But like being able to slice off bits of the frame buffer

#

And manage virtual ones

viral bison
#

make a graphic thread

hazy saddle
#

I can do that in userspace tho

#

And il setup my shared memory system

#

@viral bison wana know a fun fact about the bad apple demo I have

viral bison
#

?

hazy saddle
#

I made it

#

Before I had a VMM

#

Or a PMM

viral bison
#

oooof

hazy saddle
#

And before any userspace

#

And when I was making my own bootloader

#

FUCK THAT SHIT BTW

#

ALL HAIL LIMINE

viral bison
#

XD

#

i might make my own BL too later on

#

when i have my own graphics lib

#

so i can make it very good looking

hazy saddle
#

Oh btw wana know somthing really hacky I did

#

I was trying to get somthing to run on an embedded Linux device

#

But it only runs things as root

#

And my app says no no no

viral bison
#

XD

hazy saddle
#

Soooo

#

I made a shim .so file you preload

#

And it lies to it and it will tell it it’s UID 1000

#

And GID 1000

#

And that lets it run

#

XD

viral bison
#

XD

hazy saddle
#

That’s the other thing I need to put in my public domain repo

#

Because fuck this shit it’s ass

#

I don’t want credit

#

I don’t need it

#

Just take it and go

#

Oh I need to get the insane rant I made when I gave up that project

#

I made a timeline

#

From my shit memory but yeah a

#

@viral bison

#

If you open a project and seee this

#

What are you doing

viral bison
#

wtf is that

hazy saddle
#

Me going insane

viral bison
#

yeah, i can see XD

hazy saddle
#

I spent 3 sleepless days working on that project

viral bison
#

maybe you should sleep more often

hazy saddle
#

I should

#

It’s 5am rn tho

viral bison
#

i'm 6h ahead if you, lol

hazy saddle
#

A lot of my kernel was made at 2am with the power of two entire two liters of Dr Pepper in my veins

#

This is how I code

viral bison
#

i'm immune to caffeine

#

so that doesn't work for me

#

or well, caffeine makes me even more sleepier

hazy saddle
#

But yeah I try and get shit done

#

And that’s why my commits are somtimes a little large

#

I do tons of manual fuzzing on my code

viral bison
#

i make small commits, i have the fear of my SSD killing itself again

hazy saddle
#

This is a real commit I did btw

viral bison
#

280k LINES IN 47 FILES???

hazy saddle
#

I code a lot

#

(This is when I added bad apple and refactored a shit ton)

#

(When I did this commit I also did a limine conversion)

#

(And an entire project refactor from a single file)

#

(It was massive)

viral bison
#

oof

hazy saddle
#

Wait shit @viral bison

#

I don’t have a USB to validate this on real hardware

#

Mine dispersed

viral bison
#

lol

#

i have one

#

where is the iso?

hazy saddle
#

Let me merge my bad apple into your patch set and then I will generate a new patch

hazy saddle
#

You take a USB and make a fat32 gpt partition

#

And mark it as esp and boot

#

And put the proper files on it plainly

#

And it boots

viral bison
#

k

hazy saddle
#

It’s honestly pretty neat?

viral bison
#

i prefer an iso

#

so i can use it with my ventoy usb

#

tho i still have like 4 or 5 more usbs

hazy saddle
hazy saddle
#

i dunno how to package it right ngl

#

i hope my changes diddnt fuck up the timing too bad on the bad apple

viral bison
#

which files do i have to copy?

#

these?

#

@hazy saddle

#

ok, i booted in

#

i'm in the terminal

hazy saddle
hazy saddle
#

Can bad apple properly run twice

#

Or 3 times

viral bison
hazy saddle
#

Let’s see how far it can go before exploding

viral bison
#

time to test

#

no sound

hazy saddle
#

It works through PC speaker

#

Your laptop may not have one?

viral bison
#

i have integrated speakers

#

btw, the 2 bad apples are overwriting themselves

#

lol

hazy saddle
#

Huh

#

They should not be hmmCat

viral bison
hazy saddle
#

all i did was exit qemu to discord

viral bison
#

they are not overwriting in qemu

#

but it is failing a bit after

#

while on the laptop it's still going

hazy saddle
#

in my qemu it keeps going

viral bison
#

didn't it fail there?

hazy saddle
#

thast was with user input

#

i get this happening if i run credits

viral bison
#

oh wait

hazy saddle
#

and then spam enter

viral bison
#

my laptop is using the one with my patches only

hazy saddle
#

your patches only should overlap

#

my patches make it not overlap

viral bison
#

i only ran make all

#

and copied the elf in the main dir

#

not the bin dir

#

it pagefaulted on rodata

#

wtf

viral bison
#

XD

hazy saddle
viral bison
#

idk

hazy saddle
#

FUCKKKKK

viral bison
#

they are still overwriting on my laptop, wtf

hazy saddle
#

Even with my patches?

viral bison
#

ye

hazy saddle
#

Check the code did it apply right

viral bison
#

yes, if i run it via qemu it works

hazy saddle
#

WTF

viral bison
#

oh wait what

hazy saddle
hazy saddle
viral bison
#

it gets a thread id -1

#

or wait no

#

thread id 0 is the shell

hazy saddle
#

Yes

#

@viral bison hmmCat

#

I am clueless on the issue

viral bison
#

idk

hazy saddle
#

Does your patch set still change the TSS?

#

Rather the RSP0

#

Welp @viral bison back in stasis the project goes?

#

Or maybe @devout path can save us

neon drum
#

Have you fixed the BAD APPLE fault?

hazy saddle
#

It can run twice

#

But it has some random issues

neon drum
#

Twice 😭

hazy saddle
hazy saddle
#

But it randomly crashes from certain inputs

hazy saddle
#

And there are issues between real hardware and VM

neon drum
#

Hmm

#

Aight bye

#

My brain is fucked

hazy saddle
hazy saddle
#

Will you be back later perhaps

neon drum
#

Idk

hazy saddle
#

Mood

viral bison
hazy saddle
#

What happens if you DONT do that

#

As a wild idea

rancid viper
#

what is the status anyway

viral bison
#

We fixed the original bug

#

Now there is another

hazy saddle
#

But we got new ones

viral bison
#

It tries to execute code from ro data

hazy saddle
#

99 little bugs in the code, 99 little bugs. Take one down, patch it around 117 little bugs in the code.

rancid viper
#

well if you want to update a branch I could take a look

hazy saddle
#

This is how I do development as I don’t like “bad” code on the repo

rancid viper
#

bugfix is bad?

hazy saddle
#

Well there are other bugs

rancid viper
rancid viper
hazy saddle
rancid viper
#

either way its ur repo

rancid viper
#

ill fix it somehow

hazy saddle
#

It is on my system

rancid viper
#

I use nix

hazy saddle
#

I should edit that script to support more than one distro

rancid viper
#

you could pull the binaries from github

hazy saddle
#

Even for EDK2 OVMF?

rancid viper
#

or codeberg now I suppose

rancid viper
#

not ur job to provide ovmf imo

hazy saddle
#

But it might not always been in the past specified by my script

rancid viper
#

where do u even use the binary

#

I cant find it

#

found it

viral bison
#

at least, it got all the files it needed

#

and worked

rancid viper
#

you probably have limine installed

viral bison
#

oh, maybe that

hazy saddle
#

The path limine is put in gets loaded automatically by OVMF

rancid viper
#

no I mean

#

I fixed it

#

for me

hazy saddle
#

Huh neat

rancid viper
#

so how do I reproduce this issue

viral bison
#

run badapple 2 times

#

and let them play

rancid viper
#

I ran it three times

#

they have now played for a couple minutes

viral bison
#

show

rancid viper
#

?

viral bison
#

wtf

#

which patches are you using?

rancid viper
#

the ones evalyn told me to use

viral bison
#

patches2.patch?

rancid viper
#

yes

viral bison
#

strange, it's going fine for me too rn

#

nope

#

it nuked itself

#

the framebuffer had enough

rancid viper
#

works fine for me

viral bison
rancid viper
#

are u guys running under kvm

viral bison
#

this is after a few mins

viral bison
#

if you do make run it starts under kvm

rancid viper
#

well

#

idk I cant reproduce the bug

viral bison
#

it seems to fail randomly every time

#

it kept going for a bit

#

again

rancid viper
#

well

viral bison
#

and then the framebuffer got nuked

#

and now i got a GPF

#

wth

#

on the pit interrupt

hazy saddle
#

That’s also part of it

viral bison
#

i didn't have to do it

hazy saddle
#

Run the CREDITS command and spam enter also caused it for me

viral bison
#

why that attribute?

rancid viper
#

uh

#

dont do that

viral bison
#

something is nuking the stack

#

and i think the pit has something to do with it

hazy saddle
hazy saddle
#

And it should still deal with the stack right

viral bison
#

i meant the interrupt one

hazy saddle
#

Maybe it’s about time I do interupts in assembly isn’t it

viral bison
#

yes

hazy saddle
#

Good thing I have a good reference I can steal from since I’m working on a wiki with some friends as a side project and it has some about that

hazy saddle
#

I wana see what it’s doing to the stack

#

I’m in bed right now crying eating whip cream btw

#

So might take a bit to get up

viral bison
#

go to sleep

#

it's better for now

hazy saddle
#

Whipped cream lmao

hazy saddle
#

I’m work on this in the afternoon when I wakeup

#

And then hopefully we should be okay

#

@viral bison alright so plan
When I wake up I’m going to get assembly based interupts working properly and then if this fixes the bug things should be able to be properly cleaned up and pushed

#

I’m gonna order some USBs

#

Wait second wind is hitting

viral bison
hazy saddle
#

i got an extra 30 minutes of energy

viral bison
#

lol

hazy saddle
#

@viral bison would this be correct?

extern dispatch_interupt

%macro ISR 1
global do_isr%1
do_isr%1:
    cli
    push 0
    push %1
    jmp dispatch_interupt_asm
%endmacro

%macro ISR_ERR 1
global do_isr%1
do_isr%1:
    cli
    push %1
    jmp dispatch_interupt_asm
%endmacro

dispatch_interupt_asm:
    push rax
    push rbx
    push rcx
    push rdx
    push rsi
    push rdi
    push rbp
    push r8
    push r9
    push r10
    push r11
    push r12
    push r13
    push r14
    push r15

    mov rdi, rsp
    call dispatch_interupt

    pop r15
    pop r14
    pop r13
    pop r12
    pop r11
    pop r10
    pop r9
    pop r8
    pop rbp
    pop rdi
    pop rsi
    pop rdx
    pop rcx
    pop rbx
    pop rax

    add rsp, 16
    iretq

; Exceptions
ISR_ERR 0x08     ; DF
ISR_ERR 0x0D     ; GPF
ISR_ERR 0x0E     ; PF

; Hardware
ISR     0x20     ; PIT
ISR     0x21     ; PS/2
ISR     0x24     ; Serial #1 & #3

; Spurious Interupts
ISR     0x27     ; Spurious PIC1
ISR     0x2F     ; Spurious PIC2

; System Call
ISR 0x69         ; Non POSIX System Calls
viral bison
#

it's incomplete

hazy saddle
#

what am i missing?

viral bison
#

basically all of the interrupts

hazy saddle
#

i am aware

#

im matching pairty with my C code

#

WHICH

viral bison
#

yeah well

hazy saddle
#

is fine because

viral bison
#

that won't work

hazy saddle
#

it should be fine right?

viral bison
#

pagefault won't trigger

hazy saddle
#

wym

viral bison
#

bc it's an exception

#

you can't change its interrupt

hazy saddle
#

i know?

viral bison
#

then why you set it to 0x69

hazy saddle
#

thats not 0x69??

#

ISR_ERR 0x0E ; PF

#

thats page faults

viral bison
#

oh wait

#

i did not see it

hazy saddle
viral bison
#

btw, syscall is not called like that in x64

hazy saddle
#

ehhh mmLol whom cares

viral bison
#

interrupts were the very old method

#

now there is the syscall instruction

hazy saddle
#

ik its the old method but i dunno how to make that work right

viral bison
#

you need to set some MSRs

#

to use the syscall instruction

hazy saddle
#

i know but the docs were confusing for them

viral bison
#

we talked about them a while ago in #osdev-misc-0

#

bc i did not uderstand those docs too

hazy saddle
#

discord isnt wanting to bring up the message right 😭

viral bison
#

search for my messages

hazy saddle
#

leme finish this up first tho

#

oh also bonus part of this @viral bison is interupt driven panics will give me wayyy more accurate reg dumps

viral bison
#

ye

hazy saddle
#

gonna have to rework a good bit of shi rn but its gonna be good

hazy saddle
#

wow and my adhd meds were taken on time

#

i think i got this

#

il keep this one in C rn because its a taken function and should be OKAY @viral bison

viral bison
#

i think asm is better

#

tho why the leave instruction?

hazy saddle
#

il convert later™

hazy saddle
#

this shit is so unstable i dont wana touch it with a 10ft pole

viral bison
#

XD

#

this is my syscall handler

hazy saddle
#

that looks super close to my ISR hander code hmmCat

viral bison
#

bc it basically is

hazy saddle
#

yeah lmfao

viral bison
#

i wanna get all the regs

hazy saddle
viral bison
#

so i can support syscalls from multiple oses

hazy saddle
#

ooo smart

#

my friend had the reverse idea

#

if an app attempted a sys call from another os

#

it would know the process was compimised

#

so it would lock it down and lie to the process to make it suffer heh

viral bison
#

XD

hazy saddle
#

eg malloc would return invalid kernel pointers or other shit

viral bison
#

my future plan is to support windows app as good as possible

hazy saddle
#

ala reactOS?

viral bison
#

similar, yeah

hazy saddle
#

you gonna have an entire UI framwork in the kernel mmLol

viral bison
#

i wanna try to make my os run apps from windows, macos, linux

#

and my own os's apps

hazy saddle
#

what about my os heh

#

once i get better systemcalls

viral bison
#

can be added

hazy saddle
viral bison
#

i think i'll use modules for that

hazy saddle
#

would be neat if you could have a hint system call maybe?

#

so if apps are aware of it they can tell you what layer to use

#

and i could compile my crt0 to emit that

viral bison
#

well, my os will try to look at the header to know which os the app was made for

hazy saddle
#

ahhh

#

but i have no headers mmLol

#

/s

viral bison
#

you'll need to make elfs

#

(they are not that complicated to load)

hazy saddle
#

[clang] (-Wincompatible-pointer-types) Incompatible pointer types passing 'struct interrupt_frame *' to parameter of type 'struct interrupt_frame *' huh

viral bison
#

wtf

hazy saddle
#
src/kernel/interupts/gp_fault.h:4:33: warning: ‘struct interrupt_frame’ declared inside parameter list will not be visible outside of this definition or declaration
    4 | extern void gp_fault_isr(struct interrupt_frame* frame);
      |                                 ^~~~~~~~~~~~~~~
src/kernel/interupts/interupts.c: In function ‘dispatch_interupt’:
src/kernel/interupts/interupts.c:10:26: error: passing argument 1 of ‘gp_fault_isr’ from incompatible pointer type [-Wincompatible-pointer-types]
   10 |             gp_fault_isr(frame);
      |                          ^~~~~
      |                          |
      |                          struct interrupt_frame *
src/kernel/interupts/gp_fault.h:4:50: note: expected ‘struct interrupt_frame *’ but argument is of type ‘struct interrupt_frame *’
    4 | extern void gp_fault_isr(struct interrupt_frame* frame);
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
#
 ✘ evalyn@EvalynPC  ~/Documents/Programming/C/evalynOS   master ±  grep -Rnw . -e "struct interrupt_frame"
./src/kernel/interupts/gp_fault.h:4:extern void gp_fault_isr(struct interrupt_frame* frame);
./src/kernel/interupts/page_fault.h:5:extern void page_fault_isr(struct interrupt_frame*);
./src/kernel/interupts/interupts.c:4:void dispatch_interupt (struct interrupt_frame *frame) {
./src/kernel/interupts/double_fault.c:4:void double_fault_isr(struct interrupt_frame* frame) {
./src/kernel/interupts/interupts.h:30:struct interrupt_frame {
./src/kernel/interupts/interupts.h:37:extern void dispatch_interupt (struct interrupt_frame *frame);
./src/kernel/interupts/generic.c:4:void generic_isr(struct interrupt_frame* frame) {
./src/kernel/interupts/page_fault.c:4:void page_fault_isr(struct interrupt_frame* frame) {
./src/kernel/interupts/generic.h:3:extern void generic_isr(struct interrupt_frame* frame);
./src/kernel/interupts/double_fault.h:3:extern void double_fault_isr(struct interrupt_frame* frame);
./src/kernel/interupts/gp_fault.c:4:void gp_fault_isr(struct interrupt_frame* frame) {
./src/kernel/utils/panic.c:139:void panic(char* message, struct interrupt_frame* frame) {
./src/kernel/utils/panic.h:8:void panic(char* message, struct interrupt_frame* frame);
viral bison
#

maybe a missing include?

hazy saddle
#

no?

#

WTF

severe marlin
#

Just gonna step in bc I noticed, but gp_fault.h also needs to include whatever header the struct is defined in

hazy saddle
#

wait why isnt it

#

huh

severe marlin
#

That's where the first warning is coming from at least

hazy saddle
#

ty

#

how did that end up like that

hazy saddle
#

its CISC right mmLol

viral bison
#

idk

hazy saddle
#

i ❤️ switch/case statments

viral bison
#

oooooof

hazy saddle
#

its fine lmao

viral bison
#

this is an easier way

hazy saddle
#

btw is my kernel code organized well

#

i dont have arch spesifc ISR folders because they are all x86 spesific

viral bison
#

it should be good

hazy saddle
#

well shit

#

This is with assembly based interupts btw

viral bison
#

well, time to find the issue

hazy saddle
#

Want the patch file?

viral bison
#

not rn

#

trying to finish implementing syscalls

#

and running the first userspace app

hazy saddle
#

ooo nice

#

oooooo

#

Hey atleast working on this helps with your stuff too heh

viral bison
#

XD

hazy saddle
#

@viral bison what should i throw breakpoints on in GDB btw

#

ima try and debug

viral bison
#

idk really

#

try to breakpoint the badapple code

#

near to where it errors

hazy saddle
#

im gonna breakpoint the exception handlers and then i can see the stack trace maybe

#

it crashes if i type too much on the keyboard

viral bison
#

don't you already print it?

viral bison
#

just play bad apple 1 time

hazy saddle
#

its some kind of interupt

viral bison
#

and after a bit the framebuffer is nuked

hazy saddle
#

and my stacktrace failed to generate

#
#0  panic (message=<optimized out>, frame=<optimized out>) at src/kernel/utils/panic.c:409
#1  0xffffffff8000c0df in dispatch_interupt_asm ()
#2  0x0000000000000008 in ?? ()
#3  0x0000000000000206 in ?? ()
#4  0xffff810000030950 in ?? ()
#5  0x0000000000000000 in ?? ()
viral bison
#

yeah well, if the stack gets nuked

hazy saddle
#

yeah entire thing gets nuked

#

usureaboutthat bump alloc pool is in here somwhere

#

prolly junk tho

#

@viral bison ERROR : 00000000 00000000 00000000 00001011
this aparently means its a segment related error coming from an external thing from the IDT at index 0b1

#

for the GPF error

viral bison
#

oh

hazy saddle
#

let me try and repro the PF one

devout path
#

wat hi

hazy saddle
#

hello

#

we got more than one user app running

#

but other bugs

devout path
#

wat help do u guys need

hazy saddle
#

debugging

devout path
#

lemme back tread

devout path
hazy saddle
#

ooo fun we got one of these

#

the panic panic

viral bison
#

yeah i got a few of those

hazy saddle
#

serial manages to keep the logs properly tho

devout path
hazy saddle
#

well kinda

viral bison
#

no

#

the stack is getting nuked

hazy saddle
#

that dosnt happen on qemu but it will on rea; hwardware right

devout path
#

oke ima take my time and read

hazy saddle
devout path
hazy saddle
#

your also gonna want the most recent patch file?

#

is this a fucking reserved bit being set FLAGS : 00000000 00000001 00000000 00000010

devout path
#

can ya'll summarize the problem for me huhu

#

im like

#

brain dedge rn

hazy saddle
#

when running userspace apps

#

the kernel can shit its pants

#

and either PF or GPF

devout path
#

what the sigma?

#

randomly?

hazy saddle
#

randomly

devout path
#

HUH

hazy saddle
#

yes

devout path
#

what's the stack trace

hazy saddle
#

fucked

devout path
hazy saddle
#

yup

viral bison
#

not really random

#

i kept getting the same pagefault

#

but it was at a sub 0x1000 addr

hazy saddle
#

but it can also somtimes GPF

devout path
#

okay that's at least great

viral bison
#

ye

#

that too

#

it can be GPF or pagefault

devout path
#

wat patch are ya'll runnin on

hazy saddle
viral bison
#

patches2.patch

devout path
#

the github? then patches2.patch?

hazy saddle
#

i have a patches3.patch i need to generate

hazy saddle
#

do git diffs have untracked files?

viral bison
#

no

devout path
#

no

hazy saddle
#

how do i make it do that then

viral bison
#

add the files

hazy saddle
devout path
#

can ya'll send a

#

nvm

hazy saddle
#

this is getting a lil big heh

devout path
#

heh-

#

thanks

#

wat

hazy saddle
#

hm?

devout path
#

do i really need bootx64.efi on my /usr/share

#

when i did make run it said that

#

oh wait

#

im actually kinda dumb rn

devout path
#

;-; my ovmf name is different form here

#

i've been manually changing some stuff XD

#

wat

#

i can't seem to make this pf

#

i'll be back in like 30 mins to see what's happenin here

#

@hazy saddle

#

this must have to do with how the pages work ngl

hazy saddle
#

hm?

devout path
hazy saddle
#

yeah yeah ofc

#

i have a spot for that actualy

devout path
#

im jus wildly guessin here but it must've been somethin that had to do with the corelation of the page entry table and the userspace

hazy saddle
#

part of the stack trace code has checks for the kind of fault it is

devout path
#

yep

hazy saddle
#

hey @devout path atleast my kernel is less buggy than minecraft bedrock heh

devout path
#

TRUE

#

XDDDDDDDDDDDD

hazy saddle
#

Honestly me you and diamond could probably remake bedrock in a few weeks and have something better heh

#

Honestly that could be a fun group project after our kernels are in a decent shape

devout path
#

to be honest, we could LMAO

hazy saddle
#

Make a from scratch vulkan game engine?

#

Mine is in 2d and I need to learn a lot more vulkan to fix the thing heh

devout path
#

YEAH

#

that would be awesome ngl

hazy saddle
#

I did a c++ project with hot reloadable modules even

#

Could use some of that tech with it

#

It is LGPLv3 but it’s my own code so heh I can do whatever I want with it

devout path
#

daangg

hazy saddle
#

There is only one bug that I found with it too

#

If you delete a module

#

And then reload it gets unlosded

#

But if you put it back

#

And then reload to attempt to get it back

#

It will crash

#

But heh that’s not HORRIBLE

#

And if the system dosnt need to be fully dynamic it will reduce issues

#

Or cross threads

#

Because I also had a thread pool

devout path
hazy saddle
devout path
#

i wrote debug and my guess WASN'T CORRECT LMAO

#

hmmmmmmmmmmmmmmmmmm

devout path
#

i thought it would be that the pages are being assigned as user space

viral bison
devout path
#

then i realized even after changing the vmm.c a bit

#

cuz i thought

viral bison
#

vulkan is pain tho

devout path
#

I THOUGHT it was faulty

hazy saddle
hazy saddle
devout path
#

XDD

hazy saddle
#

Could even have threads for generating optimized geometry too?

#

So that’s offloaded

devout path
#

apparently..

#

have anyone tried

#

patch3 in real hardware?

hazy saddle
#

My USB stick is gone

#

Missing

devout path
#

wanna know what's funny?

#

it's working perfectly

#

LMAO

viral bison
hazy saddle
#

HUH

devout path
#

HAHAHAHAHAHAH

#

PATCH 2 SEEMS TO HAVE SOMETHING

hazy saddle
#

QEMU or KVM bug?

devout path
#

SOMETHING THAT I DON'T KNOW LMAO

hazy saddle
#

let me try TCG?

devout path
#

i did every thing i had to do for analysis

#

and im 80% sure it's all fine

#

i thought it was the vmm.c being a lil bitch

#

i skimmed it and foudn some questionable stuff

#

but when i put it in debug it had same result

hazy saddle
#

it crashes even faster on TCG

devout path
#

even if it was coded like that

#

HUH

#

IT'S CRASHING FOR U?

hazy saddle
devout path
#

dude intel is built diff i guess LMAO

hazy saddle
#

in QEMU and TCG or KVM

devout path
#

im runnin on KVM rn

#

IM SO CONFUSED XD

#

wait..

#

i have a different bootx64 efi

#

nah most likely not because of that no?\

#

what in the actual fuck is this LMAO

hazy saddle
viral bison
#

i can't build it

hazy saddle
#

it should be limines?

devout path
#

i downloaded recent limine's binaries

hazy saddle
devout path
#

cuz i don't hav eit in usr/share

devout path
viral bison
devout path
#

can ya'll try this simple fix

hazy saddle
#

im on latest

devout path
viral bison
#

i applied patches3

devout path
#

wat da

#

patches 3 worked for me

viral bison
#

do i have to apply patches.patch too?

devout path
#

no i don't think so ;-;

hazy saddle
#

apply it to fresh

devout path
#

i only applied it to a new instance

viral bison
#

i stashed the old ones

devout path
viral bison
#

so it was clean

devout path
#

change | to &

hazy saddle
devout path
#

now it did a double PANIC HUH

#

ok im gonna stop guessing and actually check this out

#

@hazy saddle

#
#include <stdint.h>

#include <interupts/interupts.h>
#include <utils/panic.h>

#define PF_PRESENT (1 << 0)     // Page is not present
#define PF_WRITE (1 << 1)       // Fault was a write
#define PF_USER (1 << 2)        // Fault from user mode
#define PF_RESERVED (1 << 3)    // Reserved bit was set
#define PF_FETCH (1 << 4)       // Instruction fetch fault

__attribute__((interrupt))
void page_fault_isr(struct interrupt_frame* frame, uint64_t error) {
    // my head hurts
    uint64_t faulting_addr;
    asm volatile("mov %%cr2, %0" : "=r"(faulting_addr));
 
     int present = (error & PF_PRESENT) ? 1 : 0;
    int write = (error & PF_WRITE) ? 1 : 0;
    int user = (error & PF_USER) ? 1 : 0;
    int reserved = (error & PF_RESERVED) ? 1 : 0;
    int fetch = (error & PF_FETCH) ? 1 : 0;
    volatile uint64_t pf_addr = faulting_addr;
    volatile int pf_flags = error;
    volatile int pf_present = present;
    volatile int pf_write = write;
    volatile int pf_user = user;
    volatile int pf_reserved = reserved;
    volatile int pf_fetch = fetch;
    
    (void)pf_addr;
    (void)pf_flags;
    (void)pf_present;
    (void)pf_write;
    (void)pf_user;
    (void)pf_reserved;
    (void)pf_fetch;
    
    panic("Page Fault", 0x0E, frame, error, PANIC_FLAGS_FRAME | PANIC_FLAGS_ERROR | PANIC_FLAGS_VECTOR);
}

#

can u add this to ur page_fault.c

#

just check if i messed something up LMAO

hazy saddle
#

void page_fault_isr(struct interrupt_frame* frame, uint64_t error) {
huh

#

it dosnt take in an error anymore

#

and it shouldnt be attribute((interrupt))??

#

did you not get the assembly intterupts code?

devout path
#

wat

#

huh

hazy saddle
#

did your patch apply right?

devout path
#

#include <stdint.h>

#include <interupts/interupts.h>
#include <utils/panic.h>

attribute((interrupt))
void page_fault_isr(struct interrupt_frame* frame, uint64_t error) {
panic("Page Fault", 0x0E, frame, error, PANIC_FLAGS_FRAME | PANIC_FLAGS_ERROR | PANIC_FLAGS_VECTOR);
}

#

wasn't this the code earlier

hazy saddle
#

that code got goned reduced to atoms

devout path
#

o h

#

w e l p back to le drawing board

hazy saddle
#

it should be like this

#include <interupts/interupts.h>
#include <utils/panic.h>

void page_fault_isr(struct interrupt_frame* frame) {
    panic("Page Fault", frame);
}
devout path
#

heh nope ;-;

#

wait gimme a second

hazy saddle
#

i got a whole

extern dispatch_interupt

%macro ISR 1
global isr%1
isr%1:
    cli
    push 0
    push %1
    jmp dispatch_interupt_asm
%endmacro

%macro ISR_ERR 1
global isr%1
isr%1:
    cli
    push %1
    jmp dispatch_interupt_asm
%endmacro

dispatch_interupt_asm:
    push rax
    push rbx
    push rcx
    push rdx
    push rsi
    push rdi
    push rbp
    push r8
    push r9
    push r10
    push r11
    push r12
    push r13
    push r14
    push r15

    mov rdi, rsp
    call dispatch_interupt

    pop r15
    pop r14
    pop r13
    pop r12
    pop r11
    pop r10
    pop r9
    pop r8
    pop rbp
    pop rdi
    pop rsi
    pop rdx
    pop rcx
    pop rbx
    pop rax

    add rsp, 16
    iretq

; Exceptions
ISR_ERR 0x08           ; DF
ISR_ERR 0x0D           ; GPF
ISR_ERR 0x0E           ; PF

; Hardware
ISR     0x20           ; PIT
ISR     0x21           ; PS/2
ISR     0x24           ; Serial #1 & #3

; Spurious Interupts
ISR     0x27           ; Spurious PIC1
ISR     0x2F           ; Spurious PIC2

; System Call
ISR     0x69           ; Non POSIX System Calls

; Others
ISR     0x16           ; Reserved (Used as placeholder for generic)
devout path
#

lemme rm -rf real quick

#

oopsie

#

anyways lemme make sure my patch actually applied first

hazy saddle
devout path
#

XD

#

oops

#

heh...............................................................

#

welp

#

back to the drawing board

devout path
#

i tried everythin

#

i'll get back on this tmr

#

i need sleep xd it's like almost 12

hazy saddle
devout path
#

@hazy saddle

#

@hazy saddle

#

@hazy saddle

#

heh i ain't sleeping apparently

hazy saddle
#

oh shit what

devout path
#

YEP SAME REACTION

#

I ADDED SOME DEBUG XD

#

i ran that then it did that

#

yk what's funny i added an infinite loop but uuh it just went to that

hazy saddle
#

how tf did it fail to load the bin file

devout path
#

0 damn clue

#

honestly i have no clue

#

oh wait

#

i think

#

nvm

#

nahi have no clue honestly

hazy saddle
#

can you change the retuen values of the VFS layers?

#

see which one fails

#

make these -2

devout path
#

gime a sec

hazy saddle
#

@devout path is bad apple running atleast once if at all?

devout path
#

n o p e

hazy saddle
#

It works for me???

devout path
#

huh

#

wdym

#

like it runs?

#

it returns fs_read is the problem with me

hazy saddle
#

Bad Apple runs

#

Is the initramfs building right?

#

Ok ok

#

There is an issue with my builds

#

If the bad apple compile fails

#

It fails silently

#

Cd into the folder and run the script manually

devout path
#

i mean it does run but it pf's

devout path
hazy saddle
#

Yes you

#

If the fs call is failing

#

Check the tar file?

devout path
#

oke wait

#

o h

#

@hazy saddle

#

y e a

#

@hazy saddle bad apple is indeed missing

hazy saddle
#

Try running the script manually

#

For the bad apple build

devout path
#

wat's the script

#

is it compile user apps

hazy saddle
#

The one under src/user/badapple

#

You need to cd there too

devout path
#

i kinda get it now

#

i don't have clang

#

ah yes i completely forgot

#

im not on my fedora

#

im on ubuntu

#

my bad my bad

#

thanks for pointin that out

hazy saddle
#

Isn’t the main kernel also compiled with clang

devout path
#

w a i t.

#

yeah i just realized

#

huh

hazy saddle
#

Huh

devout path
#

now this is even more confusing LMAO

#

cuz i don't have clang on the os that i am using rn

#

philippine servers are absolute garbage

#

oh damn i built with gcc

#

fuckin

#

holy

#

BALLS

hazy saddle
devout path
#

LMAO

#

I BUILT WITH GCC

hazy saddle
#

GCC works but aparently it’s shit now lmao

#

So I’m using clang

devout path
#

okay it's running

devout path
#

fuck that ngl

hazy saddle
#

I don’t use one

#

I probably should

#

But ehhhh

devout path
#

XD

hazy saddle
#

How does cross compiler work on clang

devout path
#

oh idk i think clang already has one

#

u don't have to build it like how u did with gcc

#

im not entirely sure i always used gcc XD

rancid viper
#

clang is a cross-compiler

#

by nature

#

it uses llvm as its backend so

devout path
rancid viper
#

to be clear it wont have a target for your kernel by default obviously

#

so u still have to do that if thats what is being discussed

devout path
#

jimmir@jimmir-workstation:~/debugevalynOS$ addr2line -e ./kernel.elf 0xffffffff8000fa9f
??:?
jimmir@jimmir-workstation:~/debugevalynOS$

rancid viper
devout path
#

this ain't useful at all lmao

hazy saddle
devout path
#

XD

#

LMAOOOOOOOOO

hazy saddle
#

XD

rancid viper
#

did not make that very clear

hazy saddle
rancid viper
#

needs to be compiled

obtuse loom
#

gcc needs to be rebuilt

hazy saddle
#

Is there a good way of distributing that for people? Or do I make people spend like an hour comping clang yaaar

obtuse loom
#

clang can often do it with a few command line flags

#

what do you want to target

rancid viper
#

their own kernel

obtuse loom
#

oh okay then you can just use clang

#

no rebuild needed

hazy saddle
#

Yeah and I already use clang with a ton of command line arguments so it should already be fine

obtuse loom
obtuse loom
#

as long as the flags are right then yes

hazy saddle
#

I used to use native GCC with the same arguments and it worked mmLol

obtuse loom
#

lucky 😂😂

devout path
#

w a t

hazy saddle
#

The flags were like

devout path
#

heh

hazy saddle
#

Everything

#

Every flag

#

Oh you should see my first build script I had for this kernel before it got serious

rancid viper
#

oh so targeting freestanding

hazy saddle
#

Actualy @devout path take a look at that and the bad apple build script

#

I wonder if you can see how similar they are

devout path
#

what did u do before u even messed this up

hazy saddle
#

Now there are two

#

Is it even running properly for you now?

#

Compiling etc

devout path
#

yes i can run badapple

hazy saddle
#

Run it again

#

And then run credits a bunch of times until it decides to crash

devout path
#

yep i got a gpf

#

that's why i did addr2line earlier

#

then it returned a whopping ?:??

#

very insightful

hazy saddle
#

This shits fucked

devout path
#

truly

#

im skimming files rn

#

what the fuck

obtuse loom
devout path
#

the moment i go out of qemu it pf's

#

yeah

hazy saddle
hazy saddle
#

Like on purpose pain

devout path
#

heh

hazy saddle
#

I said I am going to use the floating point registers pain

#

And then I used them

#

And it worked

devout path
hazy saddle
#

Quite queer

devout path
#

AYO

#

UWOAH

#

IT'S BEEN 5 MINS

#

NO CRASH

#

@hazy saddle

hazy saddle
#

It’s random innit?

#

Try smashing the keyboard a bit

devout path
#

heh.......................................................................................................................................

#

it is not crashing

#

i think i found it

obtuse loom
hazy saddle
hazy saddle
obtuse loom
#

is it true random? 👀

devout path
#

idk if ur going to judge my fix but uuh

#

it works LMAO

#

badapple sounds like deathcore to me now

#

dang

hazy saddle
hazy saddle
devout path
#

well

#

i made the context switch save evry registr

#

and then

#

i made it so that

#

the initial thread matches to the first switch and returns to actual code instead of whatever the fuck mlao

#

so yeah it's been 15 mins

#

no crash XD

hazy saddle
viral bison
#

that's strange

devout path
#

i m e a n : )

devout path
#

it w o r k s : )

#

well...

#

take a look for urself

hazy saddle
#

But isn’t that how preemption is done?

#

Don’t you have to save all registers

devout path
#
global thread_switch
global switch_to_user

section .text

thread_switch:
    pushfq
    push rax
    push rbx
    push rcx
    push rdx
    push rsi
    push rdi
    push rbp
    push r8
    push r9
    push r10
    push r11
    push r12
    push r13
    push r14
    push r15

    mov [rdi], rsp
    mov rsp, rsi

    pop r15
    pop r14
    pop r13
    pop r12
    pop r11
    pop r10
    pop r9
    pop r8
    pop rbp
    pop rdi
    pop rsi
    pop rdx
    pop rcx
    pop rbx
    pop rax
    popfq
    ret

USER_STACK_TOP equ 0x0000000080000000

switch_to_user:
    mov ax, 0x30 | 3
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax

    push 0x30 | 3
    mov rax, USER_STACK_TOP
    push rax
    push 0x200
    push 0x28 | 3
    push 0x4000
    iretq

viral bison
#

i don't save all the regs and it works

devout path
#
#include "stddef.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include <scheduler/scheduler.h>
#include <scheduler/switch.h>
#include <filesystem/filesystem.h>
#include <memory/vmm.h>
#include <memory/pmm.h>
#include <drivers/x86_64/ports.h>
#include <drivers/x86_64/gdt.h>
#include <utils/panic.h>

uint64_t STACK_SIZE = 65536;

void task_quit() {
    while (1) {

    }
}

struct thread_node* threads = NULL;
int next_thread_id = 0;

void create_thread(void (*entry_point)(void*), pagemap_t *pagemap) {
    bool had_threads = (threads != NULL);

    struct thread* new_thread = malloc(sizeof(struct thread));
    memset(new_thread, 0, sizeof(struct thread));

    new_thread->stack = malloc(STACK_SIZE);
    memset(new_thread->stack, 0, STACK_SIZE);
    new_thread->stack_top = (void *)(((uintptr_t)new_thread->stack + STACK_SIZE) & ~0xFULL);

    new_thread->is_user_task = 0;
    new_thread->threadId = next_thread_id;
    next_thread_id++;

    if (pagemap != NULL) {
        new_thread->pagemap = pagemap;
    } else {
        new_thread->pagemap = kernel_pagemap;
    }

    uint64_t *stack = (uint64_t *)new_thread->stack_top;

    if (entry_point == NULL) {
        entry_point = task_quit;
    }
    *--stack = (uint64_t)task_quit;

    // heh mlao
    *--stack = (uint64_t)entry_point; 
    *--stack = 0x202;                

    *--stack = 0; // rax
    *--stack = 0; // rbx
    *--stack = 0; // rcx
    *--stack = 0; // rdx
    *--stack = 0; // rsi
    *--stack = 0; // rdi
    *--stack = 0; // rbp
    *--stack = 0; // r8
    *--stack = 0; // r9
    *--stack = 0; // r10
    *--stack = 0; // r11
    *--stack = 0; // r12
    *--stack = 0; // r13
    *--stack = 0; // r14
    *--stack = 0; // r15





#

don't judge

devout path
viral bison
#

why task quit too

devout path
#

i'll leave u guys to figure that out

#

im brain fried

#

it's working ; )

devout path
# devout path ``` #include "stddef.h" #include <stdint.h> #include <stdlib.h> #include <string...
    new_thread->rsp = (uint64_t)stack;

    struct thread_node* new_node = malloc(sizeof(struct thread_node));
    new_node->thread = new_thread;

    if (!had_threads) {
        new_node->next_thread = new_node;
        threads = new_node;
    } else {
        new_node->next_thread = threads->next_thread;
        threads->next_thread = new_node;
    }

    shouldSchedule = 1;
}

void schedule() {
    outb(0x20, 0x20);

    asm volatile("cli");

    struct thread *previous_thread = threads->thread;
    threads = threads->next_thread;
    struct thread *current_thread = threads->thread;

    vmm_switch_to(current_thread->pagemap);

    tss.rsp0 = (uint64_t)current_thread->stack_top;

    thread_switch(&previous_thread->rsp, current_thread->rsp);
}

struct thread *get_current_thread() {
    return threads->thread;
}



#

this the extention to the scheduler.c

#

im actually brain cooked rn

#

im gonna look at a window and refresh

#

brb

hazy saddle
devout path
#

im back

viral bison
#

the problem is that the user registers are saved on the stack

devout path
#

so the code earlier only set a partial register set and had a stack layout that d i d n t m at ch ;-;

hazy saddle
viral bison
#

so changing there should not have any effect

devout path
#

heh : )

viral bison
#

for some reason

devout path
#

my brain fried for dis : )

#

im gonna look at window more

hazy saddle
#

what is 202 here *--stack = 0x202;

devout path
#

basically this bug now fixed pls do try

viral bison
hazy saddle
#

but what flags

viral bison
#

rflags

#

for the kernel

hazy saddle
#

but it changed

#

@devout path

devout path
#

0x202 is the initial rflags correct

#

HUH

#

WHY IS IT WORKING FOR ME

viral bison
#

it prob wasn't the regs

devout path
#

did u remove the

viral bison
#

as i said

devout path
#

remove the thing

#

the

#

no

#

it is the regs

#

u have to remove one thing

#

the

#

sti

#

fuck

#

what was it again

#

bro i didn't take notes

#

wait

hazy saddle
#

wait wairt

devout path
hazy saddle
#

i got it

devout path
#

idk just compare

viral bison
#

but the user registers are not touched in the ctx switch

devout path
#

oke nice

devout path
#

i mean

hazy saddle
#

i had a fuckup

devout path
#

been running for a while now so

#

do i give patch file?

hazy saddle
#

i got it i think

devout path
#

oh

hazy saddle
#

its not crashing

devout path
#

heh

#

: )