#Nyaux

1 messages · Page 16 of 1

wicked loom
#

and then idk

#

if it works, i'll track upstream and bump the commit whenever new commits come out

unkempt relic
#

will there be an OS to complement Hyper and uACPI?

#

call it Super

kind root
#

Yeah we'll work that out

kind root
#

Those were supposed to be part of that

wicked loom
unkempt relic
wicked loom
#

also idk if i should do protocol: hyper or ultra (or allow both)

#

minor details

kind root
#

We could make a limine->hyper Abi for providing a predefined config

unkempt relic
kind root
#

Lmao

wicked loom
#

as i mentioned above, i was thinking of just having hyper scan the efi vars for a predefined config

#

and Limine would construct the config and put it into an efivar on the fly based on the Limine config options

wicked loom
#

i do wonder though

kind root
#

So idk

#

You could just boot into hyper directly for hyper protocol

wicked loom
#

it would be nice to also pass the kernel and modules or whatever directly (as in, have Limine itself load them into memory)

#

so they can also be loaded off of ext4 or whatever else Limine supports, using Limine style paths

kind root
#

True

#

I thought u dropped support for those tho

unkempt relic
#

yeah

wicked loom
#

i readded it a while back

unkempt relic
#

i thought you quit ext

elder shoal
#

It was brought back but experimental™️

wicked loom
#

^

unkempt relic
#

zfs next in line

wicked loom
#

actually i only thought out how this would work for UEFI

#

not sure about BIOS lol

kind root
wicked loom
#

the puppy linux creator bitched enough to make me wanna add it back

kind root
wicked loom
#

then we could use the same method on both

kind root
#

True

molten grotto
#

I don't think efi vars are that great for potentially large temporary one-boot data anyway if its stored to some flash (unless there is a way to have non-persistent variables)

kind root
#

Anyways we'll work out the details but the idea overall sounds pretty interesting

unkempt relic
#

a missed opportunity with EFI's design in general:

#

amiga's rigid disk block allowed you to embed filesystem drivers with your partitions

#

no one would hate and everyone would love pluggable FS drivers for EFI

unkempt relic
#

a toast to object oriented design: you can install a DataType module for WebP into your Amiga running AmigaOS from the early 90s and basically all amiga programs that deal with graphics can instantly work with WebPs

kind root
#

Njce, too ahead of its time ig

steady flume
#

i was able to find a terminal emulator on an iphone i was gifted, unfortunately however that was a long time ago and i forgor 💀

with that, you might be able to set up sshd on your home computer then ssh in on your phone when you need/want to

#

don't forget flanterm :^)

surreal path
#

good mornin

#

to all

#

i still havent figured out the nasm crate yet

#

but im tryinggggg

thorn bramble
#

just use global_asm!

#

lol

surreal path
#

also on the plane will be home to Ireland in like 3-4 hours

steady flume
thorn bramble
#

yea its kinda ass

steady flume
#

oh lmfao

i never really used that iphone nor the app

#

¯_(ツ)_/¯

shut laurel
flat nymph
#

iOS is annoying for SSH because of Apple's background apps' limitations

finite summit
#

just remove the iOS part

#

done.

flat nymph
#

Android doesn't have those

#

(Although I think they might've also started doing that)

#

Like you could have an ssh session going for days

#

Whereas on iOS it would get closed if the app is running in background

marble surge
#

Though idk I've never used ish myself nor iPhone

flat nymph
#

You can just ssh into your machine at home

flat nymph
#

Or you can use darknets

#

(if you can't open ports)

marble surge
#

What's the issue at hand?

surreal path
#

hi okay

#

im back

#

from my trip

#

lets get to work on the IDT

surreal path
#

i think this is correct

plush hearth
#

Keep in mind that the error code only gets pushed for some exceptions

surreal path
#

cool

#

now i need to just make an array of function pointers that global or whatevs

#

or maybe

#

i can just store the interrupt number

#

and have a global function that dispatches the

#

crap towards which function

#

yea maybe that'd work

flat nymph
#

I have some GAS assembly macros in my OS which create an array of functions that push interrupt number

thorn bramble
#

they use assembler macros to generate isr stubs that set up an interrupt frame with a consistent layout so a generic interrupt handler can be invoked

#

exactly what you wanted to do

surreal path
thorn bramble
#

i wasn’t worried

#

good luck!

surreal path
#

having trouble getting a variable using gas syntax

#

or even using my macros

#
.extern function_handlers
.macro interrupterror num
.endm
.global stubs
stubs:
  .long interrupterror

this doesnt work i do not know why

#

keeps saying undefined symbol

finite summit
#

so define the symbol

surreal path
#

i did

#

in tudt i did

#

rust*

molten grotto
surreal path
#

But now I’m getting macro problems

#

Fun

frigid cliff
#

You don’t need and to do interrupts with rust, or really anything as long as it has inline asm and naked functions

#

I can’t remove the embed because I’m on mobile nooo

#

The x86-interrupt ABI is unstable, but with rust it can be helpful for this stuff

surreal path
#

where do u

#

pop everything out

#

in your inline asm

#

i do not see

#

nvm im blind

frigid cliff
#

It’s somewhere in x86_64/mod.rs but I’m kinda bad about dealing with registers so I’m not sure if I do 😅

surreal path
#

u have a function called syscall, what does sym mean? what are u trying to do in your syscall handler

#

what is a virtual pointer ive never seen something like that

#

(i come from C so beware)

frigid cliff
#

syscall is the function I pass into the 0x80 interrupt (it’s kinda garbage tho so it can be ignored if you want) sym passes a function to an asm block as a pointer iirc

molten grotto
surreal path
#

i see

frigid cliff
surreal path
#

oh i see

#

all about ur safety huh lol

frigid cliff
#

Yes, pretty much

surreal path
#

anyways can i borrow some of the inline asm

frigid cliff
#

Go ahead memingmeme

#

Technically it’s MIT but I’m not too worried about it really

surreal path
#

also what are you doing here

frigid cliff
#

Ah yes, that cluster fuck of a macro

#

I’m generally using it to give an error code to my exception handler (should be just above that), I should probably rework that so it calls panic or something but it’s a little bit of a messmemedown

#

Rdi is the register that rust uses for the first argument so when I push the number onto the stack, I’m taking the stack pointer which now points to that number and moving it into rdi since it now points to the interrupt number I passed to the macro and so the exception function knows what exception happened

surreal path
#

i see

#

smart

#

thank god for rust

frigid cliff
#

I think I stole it from Felix lol

surreal path
#

im sorry i dont do things the rust way 💀

#

i should maybe learn rust macros more

#

but anyways

#

Nyaux needs to be worked on

frigid cliff
#

It’s changed since I stole it but it’s pretty similar to their implementation

#

Macros are annoying, but you get used to them once you are eventually forced to use them because rust doesn’t have a stable way to pass variadic arguments to a function without a macro

molten grotto
#

rust macros are pretty nice in comparison to c's lol

surreal path
#

OH 100%

#

LOL

frigid cliff
#

Oh yes 100000%

surreal path
#

i would know

molten grotto
#

also that push_gprs function seems a bit weird, as like the compiler can save some stuff to the stack on the entry to there and then its supposed to restore it at the end but then you pushed some random stuff to there and told the compiler that you didn't use the stack

frigid cliff
#

Yeah, my handling of registers is kinda terrible and I knew that xd

molten grotto
#

and push_gprs might be called too late after the compiler already used some of the registers for something

surreal path
molten grotto
#

make the handler entry fn naked and then instead of push_gprs being a function either just inline the asm there manually or make it a macro

frigid cliff
surreal path
#

lovely that rust is complaining i cannot use registers

#

anymore

frigid cliff
#

Can I see the whole macro?

surreal path
#

yep

#
macro_rules! exception_function {
    ($code:expr, $handler:ident) => {
        #[inline(always)]
        #[naked]
        extern "C" fn $handler() {

            unsafe {
                core::arch::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",
                    "push {0:r}",
                    "mov rdi, rsp",
                    "call {1}",
                    "pop {0:r}",
                    "mov rsp, rdi",
                    "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",
                    in(reg) $code,
                    sym exception_handler,
                    options(noreturn)
                );
            };



            loop {
                
            }
        }
    };
}
frigid cliff
#

And what’s the error it says??

surreal path
#

only const and sym operands are supported in naked functions

frigid cliff
#

Oh yeah

surreal path
#

wait i solved it by using const

frigid cliff
#

Unsure of that works

#

I don’t really know how const works

surreal path
#

it wont let me u

#

se it

#

i enabled the feature

frigid cliff
surreal path
#

yep

frigid cliff
#

Hm

#

Can I see perchance?

surreal path
#

yep

surreal path
frigid cliff
#

Can you try putting it in lib.rs too?

surreal path
#

okay

#

solved it

frigid cliff
#

Yippee

#

I think lib.rs features are the ones with higher precedence even if you have a main.rs

shut laurel
surreal path
#

double fault sadly :c

frigid cliff
frigid cliff
steady flume
#

oh 💀

frigid cliff
#

not the rick roll link xd

steady flume
#

i mean, it's the perfect use case

surreal path
#

sorry no work today im kind of sick

#

too sick to work on nyaux atm

alpine mulch
#

get well soon man dw about it

surreal path
alpine mulch
#

Don't pressure yourself, that's the important part

#

Do only what you feel like doing if you feel like doing it

surreal path
#

general protection fault over here

surreal path
#

but i wanna work on it

surreal path
#

not when initing the idt

#

but when using it

#

manually interrupting the cpu

#

even tho

#

the IDTR

#

looks correct

#

this is very odd

#

it looks valid

#

further debugging doesnt show much

#

other then the fact that its general protection faults when an interrupt ever occurs

#

and the backtrace shows that its happening when an interrupt occurs

#

general protection error code is 0 so nothing segment related

#

not fun

#

size is 4096

#

which is expected, 16 bytes * 256 is 4096

#

more or less a single page

#

very odd

#

banging my head againist the wall trying to figure this out lol

desert haven
#

what does qemu think of your idt?

#

like what does it say in info registers

surreal path
desert haven
#

yeah thats fucked

#

also you limit is 1 byte higher than it should be

surreal path
#

thats not valid

kind root
desert haven
#

but the base address is totally wrong

surreal path
#

yea it is

#

wtf

desert haven
#

limit is the highest usable byte of the table (same goes for gdt)

surreal path
#

right

desert haven
#

so 0 -> 0xFFF is 0x1000 bytes

surreal path
#

right so i need to minus the size by one

#

still having something completely wrong

desert haven
#

did you fix the base address?

surreal path
#

the bass address looks correct in the IDTR

desert haven
#

what about in qemu?

surreal path
#

still completely stupid

desert haven
#

are you packing the idtr struct?

surreal path
#

no

#

#[repr(C)]
is all i do

desert haven
#

I dont know rust, but I imagine its inserting some padding after the limit field

#

ah yeah, it would be then

surreal path
#

adding packed solved nothing

#

nvm it did solve it

desert haven
#

oh lol

surreal path
#

thank you r4

#

😭

desert haven
#

np

#

😎

surreal path
#

😎

#

also ordered some kfc

#

😎 😎

#

everythings works nicely

#

even the saving of the registers

#

nice

#

now we have an IDT

#

whats nextttt uhhhh

#

uacpi integration now??? hmmm

desert haven
#

idt -> uacpi

#

a natural next step lol

#

do you have a timer?

surreal path
#

no

#

i have a heap allocator, pmm, vmm as well

#

i can allocate virtual addresses and shi

#

same implmentation from old nyaux

desert haven
#

very nice

#

imo I would suggest a timer, then scheduling and your sync primitives.

surreal path
#

right

#

i can get the lapic address from the msr

#

my reaction to that information

surreal path
#

got the lapic address

desert haven
#

Almost! You forgot to mask out some flag bits in the msr

median goblet
#

@desert haven out of curiosity

#

can kernel software simply assume the lapic lives at 0xfee00000

desert haven
#

I mean I wouldnt advise it, but I have have seen kernels that assert that and carry on assuming it to be true

median goblet
#

I see

desert haven
median goblet
surreal path
#

now is correct

alpine mulch
#

I would be a good boss

edgy pilot
shut laurel
#

bash any%

finite summit
#

for a second I thought he had bash

#

and I was gonna be like

#

"how tf does he have bash in < 2 weeks, and I've been at osdev for a year and still haven't ported mlibc once in 5 revisions of the kernel"

thorn bramble
#

i had a vfs and a few syscalls the first night of osdev in zig

#

safe to say it was shit lol

#

but was it quick? yeah

flat nymph
#

porting (m)libc is boring

finite summit
#

ik, as I have tried to once

flat nymph
#

(as in I'm rolling my own libc)

edgy pilot
surreal path
#

I’m too sick

#

😭😭

#

help me

surreal path
#

hi i saw u type fadanoid

#

hii

#

@kind root does uacpi have rust bindings i kinda need to use it

#

to get a bunch of tables

#

i need

finite summit
#

Unless you like pain

#

Then go on

surreal path
#

trying to get uacpi integeration

#

using the uacpi-rs bindings by @silk wind

#

few problems tho

silk wind
#

What problems do you get?
Also I took over the development after the previous owner stopped maintaining it and I haven't found time to rework it

surreal path
#

the trait asks for boxed

#

i dont have

#

box

#

for some reason alloc doesnt define it

#

even tho i have a global allocator

#

that works

finite summit
#

you could use C :^)

surreal path
#

and marked it with #[global_allocator]

surreal path
finite summit
#

never too late to rewrite

surreal path
#

3rd rewrite when memedown

molten grotto
#

extern crate alloc;

surreal path
#

oh

#

lmao

molten grotto
surreal path
#

now it works

silk wind
#

The rust analyzer in vsc doesn't give you the same level of help as rustc does

surreal path
#

i know

surreal path
#

is the address in rsdp request limine gives virtual or physical

surreal path
#

and im guessing uacpi expects a physical address so

#

i gotta unadd the hhdm offset from it

#

still page faultsss

#

:c

#

page faults here not matter what i do

#

:ccc

#

even tho i add the hhdm offset to it

edgy pilot
#

add or subtract

surreal path
#

add when using the map function

#

i give uacpi the physical rsdp

#

i let it call the kernel api map

#

which adds the hhdm offset to it

#

and returns it

edgy pilot
#

What's the page fault error code

surreal path
#

0

edgy pilot
#

the memory wasn't mapped then

#

debug your map function

surreal path
#

should be tho i went over the entire memory map and mapped everything

#

i dont think its my map function cause its the same implmentation from old nyaux

edgy pilot
#

bit 0 not being set means page isn't present

surreal path
#

there is something i dont do i do in old nyaux

#
for (uint64_t i = 0; i < 0x100000000; i += 0x1000)
    {
        map((uint64_t*)((uint64_t)kernel_pagemap.pml4 + hhdm_request.response->offset), (hhdm_request.response->offset + i), i, NYA_OS_VMM_PRESENT | NYA_OS_VMM_RW);
        hhdm_pages += 0x1000;
    }

this line

#

i dont understand why i do this

#

in old nyaux

edgy pilot
#

that seems to map first 4 gb to hhdm

surreal path
#

right

#

im guessing i need to do the same

edgy pilot
#

in your rust rewrite where do you map the memmap entries

surreal path
#

to map the hhdm

edgy pilot
#

no I mean in which file and line

surreal path
edgy pilot
#

try actually mapping in your uacpi map function

surreal path
#

okay

#

i cant

#

do so

edgy pilot
#

wdm?

surreal path
#

cause

#

listen im just gonna map the above 4gig of the hhdm i know that is the issue

edgy pilot
#

I'm confucius

kind root
surreal path
kind root
#

Cr2?

surreal path
#

right

#

yea weird

edgy pilot
surreal path
#

im gonna solve that

#

cause vmm_region_alloc gives memory

edgy pilot
#

just get a random one away from the ram and map it to there

surreal path
#

allocated and mapped contingous memory

edgy pilot
#

you can get top of the memory from memmap entries

kind root
#

Because memory below 1mb is not mapped

edgy pilot
surreal path
kind root
#

What does Info mem say

surreal path
#

okay sec

kind root
#

Yeah u don't map any of reserved memory

surreal path
#

right

#

okay it worked

kind root
#

What worked

surreal path
#

nvm

#

seems like uacpi over here is giving me a status error

#

out of memory

#

lovely

#

so im not gonna map the reversed regions then

#

cause it causes that

edgy pilot
#

how much ram are you giving to qemu

surreal path
#

2g

edgy pilot
#

you shouldn't run out of memory by mapping reserved regions

surreal path
#

i know

kind root
#

Fix it

surreal path
#

doesnt matter if i do the same thing

#
while i != 0x100000000
        {
            q.map(
                HDDM_OFFSET.get_response().unwrap().offset() + i,
                i,
                VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()
            ).unwrap();
            i += 0x1000;
            hhdm_pages += 0x1000;
        }
#

as in old nyaux

#

i have no idea whats going on ughh

finite summit
#

I think

#

maybe

#

lemme check

#

nvm it's phys

surreal path
#

okay i may take a break for an hour my brain hurts debugging this

#

maybe ill have an idea on why when i come back from the break

finite summit
#

No.

flat nymph
#

But like what else

finite summit
#

C

flat nymph
#

Ada?

finite summit
#

shhhh, you'll wake streaksu

flat nymph
#

C is obnoxious

finite summit
#

I hope you're being sarcastic rn

flat nymph
#

A language without templates is painful

finite summit
#

skill issue ngl

elder shoal
#

Just macro so hard you reinvent c++

flat nymph
#

Macros can turn into hell

#

Very quickly and very easily

finite summit
#

I've never had much problems with macros

flat nymph
#

Also no RAII

finite summit
#

skill issue

#

just free your memory

#

I rather use 22M of memory in my kernel, or leak that much

#

but who cares, they invented swap for a reason

flat nymph
#

It's not a skill issue, it's an old language

finite summit
#

it's a skill issue

flat nymph
#

My kernel doesn't count how much is used so I'm gonna assume it's very little ultrameme

finite summit
surreal path
#

fine ill go back to C and stop rewriting

#

ugh

flat nymph
flat nymph
surreal path
finite summit
#

rust is cancer

#

don't use rust

#

or associate yourself with it

#

I will be met with large backlash saying that

#

which is why I will have this thread muted for a day

surreal path
#

no im gonna take the existing project

#

and im gonna have both rust components and some componets written in C

#

and that decesion you must respect

#

wine about it like a baba memedown

#

or actually no

#

im gonna have it written in rust and im just gonna go fix my allocator bug

#

okay

#

thats it

#

i already made progress

#

im not stopping

#

@kind root do you know anything about when uacpi throws a out of memory status?

#

when you just init it

kind root
#

from anything that allocates

flat nymph
#

Idk, I'm almost finished with reading the Rust book, and the language just feels like C++ without exceptions and with fancier names for its features

surreal path
#

OHHHH

#

OHHHHHH

#

wait

#

its my slab allocator

#

so my slab allocator is returning 0?

#

hmm

kind root
#

u tell me

surreal path
#

wtf

edgy pilot
#

rewrite in c#

surreal path
#

NO

edgy pilot
#

yes

surreal path
#

im not returning 0?

kind root
#

i never said it was only from kernel_alloc

#

many other allocating api

surreal path
#

ill check dealloc then

kind root
#

what

#

why

surreal path
#

no

#

sorry

#

no

kind root
#

check e.g. mutex_alloc

surreal path
#

OHHHHH

#

thats why

#

what am i supposed to give it

#

for mutex alloc

kind root
#

idk?

#

return 1;

surreal path
#

okay

#

it worked!

#

literarly ONE Number

#

ONE FUCKING NUMBER

#

😭

#

well now that works its time to actually

#

create the namespace

#

init level mismatch?

#

what does that mean

#

huh???

#

does anyone know what that means orrr

#

i have no clue

#

what kind of error that it

kind root
#

incorrect order of initialization or api usage

surreal path
#

okay i used it the right way now

#

memory error

#

of course

#

wait wrong screenshot

#

this one

#

and i know vmm_region_alloc panics BEFORE it returns the NONE value so

#

this is something else

#

why is the current pagemap none

kind root
#

btw if u just need the tables u dont have to load the namespace

#

just uacpi_initialize is enough

surreal path
#

wrong image sorry

kind root
#

yeah thats the beginning of namespace_load

surreal path
#

why is my rip 0

#

tf

kind root
#

💀

surreal path
#

wait

#

second

#

im on a sleep tablet

finite summit
#

obos curse

surreal path
#

so hard to think

finite summit
#

so sleep

surreal path
#

i want to get this out of the way first thooo

finite summit
#
if (on_sleep_tablet)
    Sleep();```
finite summit
#

that were because I added schizophrenic code

kind root
#

never program before the daily dose of redbull

#

this has worked for me so far

finite summit
#

I don't think I've taken much caffiene in my life

surreal path
#

i never tried a redbull

elder shoal
#

enlightened: never program before a bottle of beer

surreal path
#

what does it taste like

kind root
surreal path
finite summit
#

infy you're a fucking genius

kind root
#

lol

finite summit
#

obos won't be cursed anymore

#

if I simply get a caffiene addiction!

surreal path
#

PAGE FAULT OF COURSE

#

page fault non present bit

#

now lets see the rip

#

also why tf is the rip at 0

#
/home/rayan/.cargo/git/checkouts/uacpi-rs-859d27ced179e937/4960769/uacpi-sys/vendor/source/interpreter.c:292 (discriminator 1)
[rayan@linux NyauxKT]$```
#

lovellllly

edgy pilot
#

nyauxmaster 5.0 name leaked

finite summit
#

I already knew it

surreal path
#

on this line

kind root
#

wdym his name is not nyauxmaster?

surreal path
finite summit
#

#introduce-yourself message

#

lies

surreal path
#

RAHHHHh

kind root
surreal path
#

that the memcpy this uacpi-rs

kind root
#

nah

#

it could be any memory related bug

#

also u can delete those, they arent used

surreal path
#

sooo its with my code or what

#

im so confused

surreal path
#

because if it couldnt allocate

#

i would get unwrap or result errors

kind root
#

it could be anything else

surreal path
#

because i do the rust error checking

surreal path
#

i have no idea how im gonna debug this

flat nymph
#

I start staring at the disassembled code in these situations

kind root
#

see which actual line it dies at

surreal path
#

only the non impl

#

CR2=ffff80010008203d

#

this is what cr2 looks like

#

does that look valid

finite summit
#

no

surreal path
#

what does that look like

finite summit
#

it's after the hhdm

#

but before the kernel

finite summit
surreal path
#

ummmm so why is it wanting that address

finite summit
#

if it's in uacpi

#

then you're providing it with that

surreal path
#

wha?

finite summit
#

make sure you don't go over the hhdm limit

#

when mapping physical pages

#

or well

#

putting phys. pages in the hhdm

#

or getting their address rather

surreal path
kind root
#

i doubt its anything super complex

#

just u doing a rarted thing somewhere

#

is your calloc ok?

surreal path
#

uhhhhh iwasnt asked to create a calloc

#

with the rust bindings

kind root
#

maybe the rust bindings are fucked somewhere

#

they're untested for hte most part

#

and also outdated

surreal path
#

unsafe fn alloc(&self, layout: core::alloc::Layout) -> *mut u8 {
MemoryManager.alloc(layout)
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: core::alloc::Layout) {
MemoryManager.dealloc(ptr, layout);
}

surreal path
#

so i dont know what to do then

kind root
#

inspect them

surreal path
#

#[no_mangle]
pub(crate) unsafe extern "C" fn uacpi_kernel_calloc(count: usize, size: usize) -> *mut c_void {
get_kernel_api()
.alloc(Layout::from_size_align(count * size, 8).unwrap())
.cast()
}
it does this

#

for calloc

kind root
#

no idea if that zeroes anything

surreal path
#

let me check the layout rust doc

#

nope

#

means jacksquat

kind root
#

zero it then lol

surreal path
#

okay lmao ill just zero all my memory then

kind root
#

tbh

#

debian linux has that config option on

#

absolutely any memory allocated anywhere is always zeroed

surreal path
#

thats actually really cool

#

oh for the big memory allocations

#

i forgot to memzero them

#

but no i do

#

it faults when it trys to vmm region allocate

#

nvm

#

now we are page faults

#

with an error code of 2

#

[rayan@linux NyauxKT]$ addr2line -e kernel/kernel ffffffff8004f75d --demangle
/rust/deps/compiler_builtins-0.1.121/src/mem/x86_64.rs:117
[rayan@linux NyauxKT]$

#

what???

#

why here

#

nvm

#

back to the same issue

#

@kind root is namespace init needed for getting tables

#

or no

#

cause this is clearly some weird issue with some old version of uacpi

#

im not wanting to debug

#

probs something that happened before

kind root
#

its ur skill issue pretty confident meme

kind root
#

only uacpi_initialize

kind root
#

oh wait

#

if its using old uacpi

#

it probably depends on those libc helpers that these bindings ship

#

those probably suck

#

as theyre untested

#

so idk

surreal path
#

yeaaaaaa seeee

#

i just need init anyway i need the hpet

kind root
#

just update uacpi lol

surreal path
#

im not making rust bindings for it

kind root
#

F

surreal path
#

i have an OS to work on to be fair

kind root
#

yeah thats why i mentioned earlier just forget about namespace for now

#

uacpi_initialize is enough

surreal path
#

yea

surreal path
#

apologies i havent dont any work

#

still sick

#

:c

surreal path
#

back to work

#

i think i shall use a different acpi aml parser

#

cause the rust bindings for uacpi are incomplete

silk wind
#

There is a rust aml parser but idk how feature complete it is

surreal path
#

ill use it for NOW

kind root
#

nonono

#

it doesnt support half the opcodes, its recursive, and other other half of opcodes are implemented incorrectly

#

u can try but i just wouldnt use any

haughty kite
#

basically its totally fucked

#

and you should just write your own

kind root
#

lol yes

#

thats toally easier than unfucking the current rust bindings meme

#

maybe there are acpica binding for rust

#

but probably not

flat nymph
#

Rewrite in C

finite summit
kind root
#

yeah idk man rust for nyaux wasnt a very good choice i think

flat nymph
#

Or have it as a userapace server (written in C)

kind root
#

yup

flat nymph
#

It basically just needs a bit of POSIX and mapping of physical memory

surreal path
#

ill use the shitty rust version

#

and then switch to the new uacpi rust bindings when thats ready

#

that sound good?

#

i need to get a move on with the project

#

i plan to make everything modular

#

so

#

i will be able to rewrite the acpi part of the kernel just fine

kind root
surreal path
#

yea lol

kind root
#

im simply warning you that the rust ACPI crate is not very good

surreal path
#

yea i saw its shit

kind root
#

i mean sure lol

#

lai doesnt do table parsing for u tho

surreal path
#

fucking hell what do i use

#

😭

kind root
#

lol

finite summit
surreal path
#

i cant do this bro notihing works it keeps page faulting

surreal path
#

debugging the memory manager

#

seems like theres an issue

#

with the slab allocator

#

:c

#

let obj_amount = (4096 - size_of::<slab_header>()) / size;
i feel as if this is wrong

#
for i in 1..obj_amount
            {
                let mut new = (start as u64 + (i as u64 * size as u64)) as *mut KTNode;
                println!("node: {:#?}", new);
                (*prev).next = Some(new);
                prev = new;
            }
            
            (*prev).next = None;

i cannot know whats causing some of the nodes to point to 0x1

#

i cant figure it out

#

😭

kind root
#

wtf is this formatting

finite summit
#

copy pasting from vscode is funky

surreal path
surreal path
#

😭

kind root
#

At least its not pointing to 0x2

finite summit
surreal path
#

@molten grotto i need your help im dying i cannot figure out the bug in my slab allocator code

kind root
#

Didn't you have one that was relatively good

surreal path
#

i did

#

its the same implmentation

kind root
#

What happened to it

#

Oh

surreal path
#

yea

#

rust version has bug

#

crazy

kind root
#

Maybe u fucked up because of rust semantics

surreal path
#

i dont think so i did everything correctly

#

i read the documentation

#

write_bytes does count * size of T

#

maybe theres something i dont know

kind root
#

I mean I dont see any other possibilities

surreal path
#

yea

thorn bramble
#

keep in mind alignment

#

tho idk what ur doing

surreal path
#

(please help memedown i havent slept)

surreal path
#

kill me

#

wtf

#

0x1????

#

like bro

#

help

#

😭

thorn bramble
#

holy fucking shit

#

i hope u find god

surreal path
thorn bramble
#

phys
slab allocator

#

????

surreal path
#

😭 ik not great at naming things

#

its both the pmm and slab allocator in one file

thorn bramble
#

this code

#

is giving me

#

multiple aneurysms

#

i can feel blood vessels popping in my brain

surreal path
#

ik but it should work

thorn bramble
#

idk

#

i cant read it lol

surreal path
#

😭

thorn bramble
#

all i see if

#

unwrap

#

unwrap

#

unwrap

surreal path
#

lol

thorn bramble
#

unsafe

surreal path
#

i know im writing like its C

thorn bramble
#

jesus man idk how you read this

#

no

#

you are writing it

#

then compiling

#

compiler tells you something

#

and you do the complete opposite

#

(probably)

#

idk how you actually come up with this code

surreal path
#

😭

thorn bramble
#

but comparing booleans to booleans is criminal

#

idk why people do it in ANY language

#

like a bool is already a bool

#

why compare it to another bool

#

'outer: while h.is_none() == false

#

like here

surreal path
#

i know

thorn bramble
#

while !h.is_none()

#

or just while h.is_some()

surreal path
#

yea ikik

thorn bramble
#

or even better!!!

#

while let Some(h) = h {}

#

rust has structured bindings and pattern matching!!!

#

you dont need to unwrap everything!!!

#

you can just do that Lol

#

but yeah this is hard to read sorry

#

im not too sure why stuff is borrken

surreal path
#

i understand

surreal path
thorn bramble
#

just log more

#

you will figure it out

surreal path
#

im trying too

flat nymph
#

i know im writing like its C

thorn bramble
#

not really because the c++ compiler does not give you actual tips on how to fix errors

#

while the rust compiler does :^)

#

at least for the easy stuff

flat nymph
#

clang does

thorn bramble
#

since when lol

flat nymph
#

I was surprised

thorn bramble
#

maybe VERY simple stuff like "oh you forgot a deref"

#

or "there is a similarly named type/function/whatever"

#

but other than that i just splurges out a million template instantiations and tells u to fuck yourself

flat nymph
#

"Can't find the variable. Did you mean this: X?"

#

Or something

#

It's better than GCC though

thorn bramble
#

at the cost of compile times, i guess

#

at least thats my experience with llvm in general

surreal path
#

i read the warnings

#

nothing helped

#

:c

flat nymph
#

Can you make a binding to proven C version?

surreal path
#

kill me

#

why is it some 0x0

#

i said

#

None

#

(*new).next = None;

#

its supposed to be none

#

wtf

#

@thorn bramble u know anything about this

flat nymph
surreal path
molten grotto
#

if new doesn't contain an object previously written to there then yes

surreal path
#

@molten grotto

#
for i in 1..obj_amount
            {
                let mut new = (start as u64 + (i as u64 * size as u64)) as *mut KTNode;
                new.write_bytes(0, 1);
                (*new).next = None;
                
                (*prev).next = Some(new);
                println!("info about this new node new: {:?} prev: {:?}", (*new), (*prev));
                
                let mut e = 0;
                for c in 0..800000
                {
                    e += 1;
                }
                
                prev = new;
            }
            
#

here

#

new.write_bytes(0,1);

#

^^^

molten grotto
#

yeah that should be fine then assuming that all zeros is a valid representation of KTNode

#

(which it most likely is)

surreal path
#

but why is it saying Some(0x0)?

#

????

#

do you know?

surreal path
#

im really stuck

#

😭

#

im banging my head againist ze wall

molten grotto
surreal path
#

nothings working qwinci 😭

flat nymph
#

Try a different compiler

surreal path
#

no

surreal path
#

tried setting up rust santizer didnt even help

#

wtf

#

no errors???

#

bro

#

yall know this shit?

#

@molten grotto do you know about rust santiziers? i did -Z santizer=kcfi

#

still no errors

molten grotto
#

that's for control flow integrity anyway, not for ub

surreal path
#

what does that mean

molten grotto
#

asan needs quite a bit of work to get working

surreal path
#

it would be very helpful to have

molten grotto
#

well you need a shadow space where those functions that it asks for mark specific regions of memory as accessible or poisoned

molten grotto
#

like I said its not the easiest thing ever to implement

surreal path
#

i guess im stuck for the time being with this issue of Some(0x0)

#

😃

molten grotto
#

if you push it I can take a look again

surreal path
#

okay second

surreal path
molten grotto
#

the problem is that the size of KTNode is 16 because Option must be able to hold both Some(nullptr) and None as separate values and your slab size is 8

#

so either make the min slab size 16 or use Option<NonNull<KTNode>> instead of Option<*mut KTNode>

#

(NonNull is just a wrapper type over a pointer that can't be nullptr so then Option<NonNull<T>> can have the same size as the pointer itself as null can represent None)

surreal path
#

oh right

#

im idiot

molten grotto
#

well it depends on how you want to do it

#

if you want KTNode to have a size of 8 then you either use the raw pointer without option checking for null instead of None or use Option<NonNull<T>>

surreal path
#

nonnull is of size 8 right?

#

@molten grotto ?

molten grotto
#

yes it has the same size as the pointer itself as its just a wrapper over a pointer

#

and Option<NonNull<T>> has the same size as a pointer too

surreal path
#

right

#

or you know what

#

ill just not have sizes of 8

#

it works now thanks qwinci!

surreal path
#

nvm @molten grotto having a page fault when using the acpi crate in here
/rustc/9c01301c52df5d2d7b6fe337707a74e011d68d6f/library/core/src/array/equality.rs:150

#

:c

molten grotto
surreal path
molten grotto
#

if you use the hhdm to access them then yes

#

also do note that they might not be page aligned

surreal path
#

it works now tho

molten grotto
surreal path
#

it works

#

sadly

#

the interrupt handler keeps showing rip at 0x0

#

i cannot figure it out

#

😔

#

hmmm

#

ill just use gdb and see

surreal path
#

or run an asm instruction

#

manually

molten grotto
#

idk

surreal path
#

yea somethings corrupting the stack

#

reading the disassmebly

#

something funking is happening

#
ffffffff80004140 <NyauxKT::idt::page_fault>:
                        push   %rax
                        push   %rbx
ffffffff80004142:       push   %rcx
ffffffff80004143:       push   %rdx
ffffffff80004144:       push   %rsi
ffffffff80004145:       push   %rdi
ffffffff80004146:       push   %rbp
ffffffff80004147:       push   %r8
ffffffff80004149:       push   %r9
ffffffff8000414b:       push   %r10
ffffffff8000414d:       push   %r11
ffffffff8000414f:       push   %r12
ffffffff80004151:       push   %r13
ffffffff80004153:       push   %r14
ffffffff80004155:       push   %r15
ffffffff80004157:       push   $0xe
ffffffff80004159:       mov    %rsp,%rdi
ffffffff8000415c:       call   ffffffff80003c70 <NyauxKT::idt::exception_handler>
ffffffff80004161:       add    $0x8,%rsp
ffffffff80004165:       mov    %rdi,%rsp
ffffffff80004168:       pop    %r15
ffffffff8000416a:       pop    %r14
ffffffff8000416c:       pop    %r13
ffffffff8000416e:       pop    %r12
ffffffff80004170:       pop    %r11
ffffffff80004172:       pop    %r10
ffffffff80004174:       pop    %r9
ffffffff80004176:       pop    %r8
ffffffff80004178:       pop    %rbp
ffffffff80004179:       pop    %rdi
ffffffff8000417a:       pop    %rsi
ffffffff8000417b:       pop    %rdx
ffffffff8000417c:       pop    %rcx
ffffffff8000417d:       pop    %rbx
ffffffff8000417e:       pop    %rax
ffffffff8000417f:       ud2
ffffffff80004181:       int3
ffffffff80004182:       int3
ffffffff80004183:       int3
ffffffff80004184:       int3
ffffffff80004185:       int3
ffffffff80004186:       int3
ffffffff80004187:       int3
ffffffff80004188:       int3
ffffffff80004189:       int3
ffffffff8000418a:       int3
ffffffff8000418b:       int3
ffffffff8000418c:       int3
ffffffff8000418d:       int3
ffffffff8000418e:       int3
ffffffff8000418f:       int3
#

wtf

surreal path
#

fuck i didnt push the rip

#

my bad

#

wait no

#

the sdm states

#

that the rip should be on the stack wtf

molten grotto
#

well I didn't add all the functions, mostly it just has eval and reboot/sleep functions

surreal path
#

but still

#

im trying to figure out my

#

interrupt handler

#

why its broken lol

#

why is rip 0x0

#

am i doing everything right?

#

like huh

molten grotto
#

where does it get to rip 0

surreal path
molten grotto
#

the page fault handler?

surreal path
#

i dont understasnd why rip is 0

#

running it in gdb it solves the problem

#

it works now?

#

wtf

molten grotto
#

how do you trigger the exception

#

and what specific interrupt number if with the int instruction

surreal path
#

asm!("int 0xe");

molten grotto
molten grotto
#

so then because int 0xe doesn't push it (because its not a cpu triggered pagefault) the registers aren't saved in the same places

#

try triggering a real pagefault

#

eg. with (8usize as *mut i32).write_volatile(0);

surreal path
#

it worked

#

i fixed it!!!!

#

lovely

molten grotto
#

well actually looks like you don't take the error code into account in your registers struct or the idt register pushing code at all, it would be between rax and rip if its there (and if its not then you likely want to push a dumb zero to that place)

kind root
molten grotto
#

like the event stuff, namespace node discovery stuff etc

kind root
#

Still better than the current impl I think?

#

Thanks for your work BTW

molten grotto
#

I mean yeah at least it compiles with the latest uacpi meme and has some basic eval stuff but to use that you'd have to know the path ofc

kind root
#

Nice

surreal path
#

working on the hpet

#

rn

#

just reading spec relaxing

#

getting the registers and all that

#

rahhhhh

#

WHYYYY IS IT NOT CAPABLE