#Nyaux

1 messages ยท Page 17 of 1

surreal path
#

spec says

#

13th bit

#

Size:
โ€ข This bit is a 0 to indicate that the main counter is 32 bits wide (and
cannot operate in 64-bit mode).
โ€ข This bit is a 1 to indicate that the main counter is 64 bits wide (although

kind root
#

Rust crate skill issue

surreal path
#

fine ill use the new

#

NEW

#

uacpi rs

#

bindings

kind root
#

I doubt it is btw

#

Probably your bug

surreal path
kind root
#

I mean idk how u get that field

surreal path
#

    fn init_lapic(&mut self, e: &mut ACPIMANAGER) {
        let addr = rdmsr(0x1b);
        self.lapic_addr = addr & 0xfffff000;
        println!("addr of lapic for cpu: {:#x}", self.lapic_addr);
        
        unsafe {
            core::arch::asm!(
                "mov rax, {0}",
                "mov cr8, rax",
                const 0,
                out("rax") _,
            );
            
            
            let q =  HpetInfo::new(&e.0).unwrap();
            let mut it = (q.base_address + HDDM_OFFSET.get_response().unwrap().offset() as usize) as u64;
            if it & (1 << 13) != 0
            {
                println!("Capable");
               
            }
            else {
                println!("nope");
                println!("{:#b}", it);
            }
        };
    }
#

bro

#

the config register

#

is at offset 0

kind root
#

Wtf is APICMANAGER

surreal path
#

lets not talk about that

tawdry mirage
#

the acpi manager

surreal path
#

๐Ÿ˜ญ

#

i dont understand why the hpet is 32 bit

kind root
#

I mean idk what it has at index 0

finite summit
#

duh

finite summit
kind root
#

Id love to see that

surreal path
#

COUNT_SIZE_CAP

#

is what im looking for

#

to be 1

#

which it isnt???

kind root
#

Yes

surreal path
#

thats not supposed to happen

#

it means the hpet is 32 bit

#

and qemu has a 64 bit hpet

#

so wtf

#

000-007h General Capabilities and ID Register

kind root
#

Like I said

#

You're probably reading random address

#

Idk how u get it

surreal path
#

using the acpi crate

#

which gives me the address to the hpet

#

and there is data there

kind root
#

Maybe the way you're using the crate is wrong

surreal path
#

i read the documentation

kind root
#

Is the signature correct at least

#

Print it out

surreal path
#

kk

#

bro come on

#

they want me to use hpetinfo

#

not

#

the actual fucking table

#

wt

#

wtf

#

rust devs omg

kind root
#

Like I said

#

This crate is brain damaged

surreal path
#

signature: HPET

#

it is indeed the hpet

kind root
#

Yeah no idea

tawdry mirage
#

what address do you get for the hpet itself

surreal path
#

sec

#

this one @tawdry mirage

#

physical address of course

molten grotto
#

that's correct at least

surreal path
#

yea

#

so wtf

#

ill push the changes so you can also take a look

#

pushed

#

please someone hlep

#

๐Ÿ˜ญ

surreal path
#

:(

surreal path
#

@molten grotto can i at least use your uacpi rs thing if you can implment scanning tables for me pretty please

#

cause currently you cannot scan tables

#

im kinda desperate

molten grotto
surreal path
#

im a fucking idiot

kind root
#

yes

#

lmao

surreal path
#

yep

#

buts its okay

#

we learn through this

#

we all started as idiots

#

lets be honest

#

@kind root we learn through this

#

andddd a page fault

#

guessing cause mmio isnt mapped in the hhdm right qwinci?

kind root
#

yes

surreal path
#

how do i map it

kind root
#

I dont actually know

#

It should be under 4g

surreal path
molten grotto
surreal path
molten grotto
#

it looks like the memory map doesn't contain all the regions so if you want to map everything just find the highest address in there

flat nymph
kind root
#

On qemu

surreal path
#

what the memory maps look like

#

@molten grotto for some reason it didnt map?

molten grotto
#

yes because its likely not contained within the memory map

surreal path
#

so how do i map it

molten grotto
#

either you get the highest base + length from the memory map and then map that much to the hhdm or alternatively you map the devices separately

flat nymph
#

Doesn't uACPI request memory maps?

surreal path
#

this isnt uacpi

#

and uacpi bindings dont work well

#

(for the moment)

molten grotto
surreal path
#

how to map the devices separately

elder shoal
surreal path
molten grotto
#

you just map them before the first time you access them to somewhere

flat nymph
#

I have vmem in my kernel for everything

kind root
molten grotto
surreal path
#

simple

#

done

elder shoal
#

still should map it tbh just to be sure

surreal path
#

it works now yayyyy

#

QWINCI I WILL MAKE YOU A SHRINE IN MY OS

#

REAL

#

FOR THE HELP YOU HAVE PROVIDED ME

#

YOU ARE SO KIND

#

OMG

#

enabled the hpet

#

๐Ÿ˜Ž

#

now i need to figure out calibration math

#

uhhhhh

#

fuck

molten grotto
#

at least there is the speed readable from the registers which is nice

#

just that its in femtoseconds or whatever

surreal path
#

it works

#

i slept for 1 second with the hpet

surreal path
#

i feel like this is wrong

#

guys is this wrong

#

or is this accurate

#

im unsure

#

stupid fucking timer

#

// unmasked, periodic, interrupt 34
// (1 << 17) sets to periodic
// read sdm for more info
self.write_lapic_register(0x320, 34 | (0 << 16) | (1 << 17));

#

i literarly

#

wrote to it

#

bro

#

BRO

#

DUMB AH

#

FUCKING

#

LAPIC

#

I HATE THIS LAPIC AH

#

RAHHH

#
// 0x100 enables the interrupt, 33 is the interrupt number for a surprious interrupt
                self.write_lapic_register(0xf0, 0x100 | 33);
                // divide by 4
                self.write_lapic_register(0x3e0, 1);
                // one shot timer, unmasked on interrupt 34
                // 1 << 16 masks the timer
                self.write_lapic_register(0x320, 34 | (1 << 16));
                // calibrate the lapic, set the inital count
                self.write_lapic_register(0x380, 0xffffffff);
                self.ksleep(10);
                let mut lapic_ticks_per_10ms = self.read_lapic_register(0x390);
                lapic_ticks_per_10ms = 0xffffffff - lapic_ticks_per_10ms;
                println!("lapic ticks per 10 ms {}", lapic_ticks_per_10ms);
                self.write_lapic_register(0x380, lapic_ticks_per_10ms);
                // unmasked, periodic, interrupt 34
                // (1 << 17) sets to periodic
                // read sdm for more info
                self.write_lapic_register(0x320, 34 | (0 << 16) | (1 << 17));
#

this is literarly all i fucking do

#

and yet

#

it doesnt work

#

IT DOESNT WRITE TO THE REGISTERS WHY TF

desert haven
#

what does write_lapic_register look like?

surreal path
#

me when rust doesnt listen to me for the billionth time

thorn bramble
#

where volatile

surreal path
#

using volatile doesnt solve it

#

ITS STILL NOT WRITING TO THE REGISTERS RAHHHHH

kind root
#

Related about rust on Linux

surreal path
#

lmao but seriously

#

its not writing to the registers

kind root
#

No idea

surreal path
#

๐Ÿ˜”

tardy hull
#

Meow meow meow :3

surreal path
#

btw qwinci are you still working on those uacpi-rs bindings, if so could you put scanning for tables on top of the priority list. this acpi crate is really fucking weird and i dont want to keep using it

#

i really want to use uacpi

#

but the lack of functionality of the bindings atm stops me from using it

surreal path
#

still cannot find the source of the issue atm*

#

im unsure why

#

i will step through the lapic init function and see

#

debugging more

thorn bramble
#

i wonder if you can trace (l)apic

#

-trace apic_mem*

#

that will print all memory accesses to any apic in the system

surreal path
#

at all

#

apic_mem_readl 0xf0 = 0x000000ff
apic_mem_writel 0xf0 = 0x000001ff
apic_mem_writel 0x350 = 0x00008700
apic_mem_writel 0x360 = 0x00008400
apic_mem_writel 0x300 = 0x000c4500
apic_mem_writel 0x300 = 0x000c4610
apic_mem_readl 0x30 = 0x00050014
these only show up with limine boot

#

not when in the kernel

thorn bramble
#

well then u did something wrong

#

lol

#

whats your "lapic base"

#

sorry lapic_addr

#

print that bitch

surreal path
#

thats the virtual address of the lapic base

#

in the hhdm

#

i manually mapped it

thorn bramble
#

it looks ok

surreal path
#
let addr = rdmsr(0x1b);
        
        self.lapic_addr = (addr & 0xfffff000) + HDDM_OFFSET.get_response().unwrap().offset();
#

what i do

thorn bramble
#

assuming hhdm offset is 0xffff800000000000

surreal path
#

yea

#
unsafe {cur_pagemap.as_mut().unwrap().map(self.lapic_addr, addr & 0xffff000, VMMFlags::KTWRITEALLOWED.bits() | VMMFlags::KTPRESENT.bits()).unwrap()};
#

this is how i manually map it

thorn bramble
#

0xffff000

#

...

#

...

#

...

#

!#RTEFWGDSRIJKOMPGRSWIOJKMGHRWSEFIJOKM+MKHGBRw

surreal path
#

BRO

#

ONE F

#

still didnt solve it tho even after readding the one f

#

still not writing ๐Ÿ˜ญ

thorn bramble
#

why are you mapping it manually

#

even

#

lol

surreal path
#

cause

thorn bramble
#

just map first 4GB

surreal path
#

its not in the memory map

thorn bramble
#
  • any additional usable entries
#

above 4GB

#

literally what limine does for you already

#

so just follow that

#

its good

surreal path
#

how do i do that even

thorn bramble
#

you... map all the memory from 0...4GB

surreal path
#

okay sce

thorn bramble
#

and then you loop over your memory map

#

and if any usable entries are above 4GB

#

you map them too

surreal path
#

4gib or 4gb

thorn bramble
#

in the hhdm

#

1024*1024*1024*1024*4

#

wait i think i might be dumb

#

yeah 1 1024 too many

#

basically 0x100000000

desert haven
#

its just 3

surreal path
#

okay

#

lets divide that by 4096 so i go over each page

#

0x100000

#

okay

thorn bramble
#

for addr in (0..0x100000000).step_by(PAGE_SIZE) { /* ... */ }

#

np

surreal path
#

lmao

thorn bramble
#

bro was about to whip out the let mut i = 0; while i < 0x100000000 { ... }

#

if you wanted to you could probably use 2MB/1GB pages so mapping it all isnt dogshit slow

#

but first get that working

surreal path
#
for i in (0..0x100000000).step_by(4096)
        {
            q.map(
                HDDM_OFFSET.get_response().unwrap().offset() + i as u64,
                i as u64,
                VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits()
            ).unwrap()
            hhdm_pages += 1;
        }
surreal path
#

lol

#

STILL

#

no write

thorn bramble
#

well something is Properly Fucked

surreal path
#

yep

#

as usual

#

codes on github anyway rust hates me

kind root
#

Nyaux try not to get stuck on random shit every day impossible challenge

surreal path
#

god just hates me

#

to be fair

molten grotto
surreal path
#

WHY WONT IT WRITE TO THE LAPIC

#

RAHHHHH

flat nymph
#

Don't you need to do writes as 32 bit ints? (May be not)

molten grotto
surreal path
flat nymph
surreal path
molten grotto
#

no

flat nymph
#

It's the same as with hpet

surreal path
#

wait no

molten grotto
#

it would be *mut u32

surreal path
#

nvm

#

thanks qwinci again

#

it works!!!

molten grotto
# surreal path thank you

now its there, it might be slightly inconvenient to use because of the re-exported tables and whatever but I don't want to spend the whole day writing nice accessor functions for the fields within the tables

surreal path
#

LOL

#

01a2

#

lmao

#

loooool

#

yea i dont know rust macros

#

help

#

i cannot figure out this

#
macro_rules! exception_function_no_error {
    ($code:expr, $handler:ident, $meow:tt) => {
        
        #[naked]
        extern "C" fn $handler() {

            unsafe {
                core::arch::asm!(
                    "push 0x0",
                    "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}",
                    "mov rdi, rsp",
                    "call {1}",
                    "add rsp, 8",
                    "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",
                    "iretq",
                    const $code,
                    sym $meow,
                    options(noreturn)
                );
            };



            
        }
    };
}
#

im trying to take in

#

the function

#

and get the symbol

#

but it doesnt work

#

:c

molten grotto
surreal path
#

e=01a2

#

?????

#

wtf

#

i dont know whats going on

#

help why isnt it working

molten grotto
#

debugger

surreal path
#

right

kind root
#

And thanks for your work btw

molten grotto
#

as in re-export bindgen generated tables

kind root
#

Ah

surreal path
molten grotto
# kind root Ah

though ig you could also just add uacpi-sys to your project along with uacpi rs so then you could use them directly from there (the enum names and whatever are annoying though because they are very long, I re-created some of them as constants but not all)

#

because it prefixes the c enum value name with the enum name itself so its eg. acpi_madt_entry_type_ACPI_MADT_ENTRY_TYPE_LAPIC

surreal path
#

i cant breakpoint at the idt stub for some reason

molten grotto
#

did you try to breakpoint at the function by name

molten grotto
#

now that I searched for that apparently there is a bindgen option to disable that lol

molten grotto
surreal path
#

keeps saying its not defined

molten grotto
#

add #[no_mangle] to the handler

surreal path
#

right

surreal path
#

rahhh

#
File src/idt/mod.rs:
269:    fn NyauxKT::idt::InterruptManager::start_idt();
196:    fn NyauxKT::idt::div_error();
139:    fn NyauxKT::idt::double_fault();
139:    fn NyauxKT::idt::general_protection_fault();
117:    fn NyauxKT::idt::idt_set_gate(u8, usize);
196:    fn NyauxKT::idt::invalid_opcode();
139:    fn NyauxKT::idt::page_fault();
101:    static fn NyauxKT::idt::exception_handler(u64);

@molten grotto look at this

#

wtf

#

it isnt

#

in the symbols at all...

#

nyaux try not have something go wrong for billionth time moment

kind root
#

Nyaux when gdt loaded letsgo

surreal path
#

lol

#

still

#

why is it

#

gpding

surreal path
#

:(

#

still cant figure it out

#

i think i know the issue

#

rust is omitting

#

the stub

#

for it

#

how do i stop that

#

:(

wide nexus
surreal path
wide nexus
molten grotto
surreal path
molten grotto
#

or maybe marking it as pub would solve it

surreal path
#

im pushing everything to github if u wanna take a look at the code

#

done

molten grotto
surreal path
molten grotto
#

also in your exception stub ```x86asm
push {0}
mov rdi, rsp
call {1}
add rsp, 8
mov rsp, rdi

molten grotto
#

the function that you call is allowed to use it for whatever

#

and there is no reason to move anything into rsp anyway

surreal path
#

right

#

okay i fixed

#

sending a lapic eoi does general protection fault?

molten grotto
#

ah yeah I forgot that too, you pass a physical address there

surreal path
#

i fixed that but

#
#[no_mangle]
pub extern "C" fn scheduler(registers: u64)
{
    let got_registers = unsafe {*(registers as *mut Registers_Exception)};
    println!("tick");
    let mut addr = rdmsr(0x1b);
    addr = addr & 0xfffff000;
    addr = addr + HDDM_OFFSET.get_response().unwrap().offset();
    CPU::send_lapic_eoi(addr);
}

#

this is all i do

molten grotto
#

you don't ever discard the error code you push to the stack in the stub either

#

you do have a lot of bugs lol

surreal path
#

i do

#

add rsp, 8

#

oh wait

#

NVM

#

SORRY ๐Ÿ˜ญ

molten grotto
#

you discard the number but you don't discard the error at the end before iretq

#

the other stub likely has the same problem, you need to take it into account even when its pushed by the cpu

surreal path
#

okay i solved it

#

but

#

it only ticks once

#

:(

#

righg

#

cause i call it manually

#

but

#

why isnt the lapic firing the vector

#

i unmasked it?

#

bro???

#

its unmasked

molten grotto
#

I'd bet you aren't installing the handler for the same vector

surreal path
#

no its 34

molten grotto
#

because you are using 34 as the vector for the lapic and maybe you install 0x34

surreal path
#

no interrupt still

#

pushed on github

#

sti instruction does nothing

molten grotto
#

because your hcf disables them

surreal path
#

IT WORKS

#

OMG THANKS QWINCI AGAIN

#

THANKS FOR HELPING ME FIND THESE BUGS UGHHHH

kind root
#

istg naux is written by qwinci at this point

surreal path
#

i know

#

bro is doing gods work

#

we now have lapic

#

๐Ÿฅณ

kind root
surreal path
#

vfs maybe next

#

or tarfs

#

hmm

molten grotto
#

you can implement vfs on top of tar

#

not that its the greatest idea ever but like its an option

cinder plinth
#

tarfs nooo

#

(that's not a thing)

surreal path
#

octal file name

#

remember that

kind root
#

size

molten grotto
#

I actually do vfs ops on top of the literal tar file without unpacking it into anything better

surreal path
cinder plinth
#

I guess that reduces boot time?

#

but then file access is slower

molten grotto
#

yeah and finding files

surreal path
#

okay time to learn about vnodes again and implment vfs for nyaux once again!!!!

elder shoal
#

ext2 backed by ram meme

surreal path
molten grotto
#

wouldn't probably be a terrible idea tbh

surreal path
#

right wheres that sun paper on vfs

surreal path
#

thank you

molten grotto
#

wait the one that I posted was the vmem one KEKW

surreal path
#

it was the slab

#

๐Ÿ˜ญ

#

i think i can do vnodes with traits

#

rust traits

#

the operations at least

#

every directory/file has a vnode right

#

yea i see

molten grotto
#

every open file/directory, they aren't something that's always there for all files

molten grotto
#

it would take a ton of memory if all files on the disk would have an in-memory vnode at all times

#

the way that I understood that they work (and how I have implemented them) is that each vnode has a lookup function that can be used to create a vnode for the next component of the path on-demand

molten grotto
#
VNode* root = root_vfs.get_root_node();
VNode* usr = root.lookup("usr");
VNode* bin = usr.lookup("bin");
VNode* bash = bin.lookup("bash");
surreal path
#

and what would the lookup function look like

green elbow
#

depends on the mounted filesystem

surreal path
#

lets sayyyy tmpfs

#

i just wanna get a grasping of the concept

green elbow
#

tmpfs is completely in RAM

surreal path
#

i knwo

green elbow
#

so you'd have some data structure of dirs/files

#

a tree + hashmap would work fine

surreal path
#

im looking at my old code

#

would ptr_to_vnode be an Option<*VNode>

#

if its None you create the VNODE based on the information?

#

or smthin

green elbow
#

ptr_to_vnode would still be a pointer no?

surreal path
#

But encased in an option type

green elbow
#

yeah no but i mean it should still be a pointer

#

an option stores it by value though

surreal path
#

oh

cinder plinth
surreal path
#

no u can store the pointer by value

#

*mut VNODE works

green elbow
surreal path
#

Option<*mut VNODE>

cinder plinth
#

maybe I should do that

#

would speed up lookups

molten grotto
#

also you likely want to allow multiple vnodes to reference the same in disk (or in ram) file/directory so the actual file/directory entry shouldn't care about what vnodes are pointing to it

green elbow
#

yeah i imagine you have faster lookups that way

#

idk how you do it now

cinder plinth
#

rn I do a linear search

green elbow
#

yh

unkempt relic
cinder plinth
#

which is not that bad, but I guess it could be bad for large directories

surreal path
#

okay how would a lookup function work

#

say

#

i had

#

a directory

#

lets call it usr

#

and i called .lookup

#

on it

#

what would that look like

green elbow
#

think about what your vnode actually stores

#

it'll become clear how to construct it as well

unkempt relic
surreal path
cinder plinth
#

yeah

green elbow
#

right

surreal path
#

its just a abstraction over the overlying fs

cinder plinth
#

keep an opaque pointer to some fs-specific structure

green elbow
#

right

unkempt relic
#

or i should say (hopefully) the directory entry with that name (or none)

cinder plinth
#

nvm

#

have vnode ops

#

that FSes implement

finite summit
#

unless I'm mistaken?

surreal path
#

what if a vnode doesnt exist

molten grotto
cinder plinth
surreal path
#

create it?

green elbow
unkempt relic
surreal path
#

using the information of the fs node right?

green elbow
#

so it's all in ram

surreal path
#

yea pretty much

#

as vnode is just an abstraction

green elbow
unkempt relic
surreal path
#

its really just an abstraction yea i get you

green elbow
#

you're not creating anything

surreal path
#

wdym?

#

i thought you cannot keep vnodes in ram all the time

#

cause of perfomance issues

green elbow
#

yeah but the point is you're not creating data

#

it's merely an accessor to data

finite summit
#

oopsie

cinder plinth
#

ideally you put as many files in ram as possible

unkempt relic
cinder plinth
#

this is why on macOS when you have 16gb of ram you have like 8gb ram usage idle, but on a 8gb system you don't

molten grotto
cinder plinth
#

I guess you could also have a hashmap per directory

#

tho idk how good that is space-wise

surreal path
#

there will be a vnode in ram that the tmpfs node points to

#

i think thats fine

green elbow
unkempt relic
surreal path
#

thats how the paper says it tho

#

so im gonna follow the paper

#

i dont think it has ram issues

cinder plinth
#

a namecache is always good to have no matter what

#

also sounds simple enough to implement

surreal path
#

afterall the vnode structure is lit a few bytes

#

๐Ÿ’€

#

@molten grotto please dont treat your vnodes like open files

elder shoal
surreal path
#

as the paper does it

#

cause it makes me feel all scientific

#

๐Ÿ˜Ž

unkempt relic
surreal path
#

ur right on that

molten grotto
surreal path
#

a few kb

unkempt relic
#

in the solaris tmpfs it does implement a tmpfs tmpnode as a struct containing a vnode, like what astarl does

surreal path
#

think abt it

molten grotto
surreal path
#

i will do that then

cinder plinth
#

my tmpnodes have a pointer to a vnode and vnodes have an opaque pointer to fs-specific data

#

(in this case a tmpnode)

surreal path
#

ill just have the tmpfs node store the vnode

unkempt relic
#

actually never mind, at some point it became a pointer, but it's not a great deal of different

surreal path
#

yep

#

^

cinder plinth
#

yeah that's what I do

surreal path
#

nyaux is getting a vfs boys

#

after like a week of shanggains

#

nyaux is finally getting the vfs

#

๐Ÿ˜Ž

molten grotto
#

actually maybe there is at least one benefit, eg. if you write to a file that could have multiple vnodes referencing the inode then the inode would have to have an in-file structure having eg. a lock to synchronize the writes

#

so then you would basically end up having an unique in-memory structure per inode anyway just that the vnode ops would be in the layer above using more space being duplicated for each open file

elder shoal
surreal path
#

heres what i thought of

#

ill have the vnode ops be a function pointer

#

that when defined for tmpfs

#

there will be a closure

#

that calls the tmpfs op

#

right

unkempt relic
#

or rather i can't immediately think of a lifetime issue

cinder plinth
#

but multiple ops tho

surreal path
elder shoal
cinder plinth
#

that you can have as traits btw

#

I use a virtual class for those

surreal path
cinder plinth
#

well yeah

#

they share common prototypes

surreal path
#

so i can just have it as a trait

#

vnode operations

#

that i can impl for a tmpfs node or smthin?

#

how do i store flags for a vnode

molten grotto
surreal path
#
trait VNodeOPS
{
fn blahblah() -> i32;
}
struct vnode
{
ops: Box<dyn VNodeOPS>
}
#

somethin like this

cinder plinth
#

yea

surreal path
#

yea

haughty kite
haughty kite
#

brackets were not meant to be put on their own line

#

it makes some sense in K&R C

surreal path
#

eeee

#

meow

#

okay i ran cargo fmt on the kernel

#

happy @haughty kite ?

haughty kite
#

yes

surreal path
#

star the repo then memedown

surreal path
#

okay so

#

with the vfs

#

do i need a get next component function

#

or smthin?

#

i feel the urge to add a NT subsystem

#

to the kernel

#

that would be cool

kind root
#

indeed it would

#

but are u confident u can pull that off

surreal path
#

just

#

lets focus on getting bash running

#

with proper ps2 drivers and whatever

#

rn lets focus on the vfs

surreal path
cinder plinth
surreal path
#

@molten grotto THANK YOU FOR THE NEW UACPI RS BINDGIGSSSS

#

OMG

#

YOOO

molten grotto
surreal path
#

rn

#

ill let you know how they work

molten grotto
#

also for the functions that take in &CStr (like table_find_by_signature) you can use literals of the form c""

#

though the signatures for the common tables like hpet are also exported as constants

molten grotto
#

what is the code where it fails

surreal path
#

i know my allocator isnt the problem

#

gives the address just fine

#

same with my vmm region allocator

#

memory is mapped and all no page fault occured

#

why is mr uacpi thinkings its out of memory

molten grotto
#

hmm

#

do you have the log level as trace?

#

or debug

#

because that could provide some info

surreal path
#

my slab allocator was requested ONE time for memory

#

to which it gave

#

thats all that happened

molten grotto
#

that's weird

surreal path
#

and that wasnt nessorilary for uacpi

#

that was for the kernel

#

Arc::new()

#

the kernel api

#

that worked fine

#

i checked

#

an arc object was created

#

so theres smthin funky goin on

molten grotto
#

can you push it to eg. a new branch or something? because I'd like to check, though I suspect that its not a problem with the bindings but its not impossible because I didn't test them

surreal path
#

done

molten grotto
#

ah right, 0 is an invalid value for uacpi::Handle

#

Ill add an assert to make sure that new() isn't passed that and then a separate function to create an invalid handle

#

but in any case you shouldn't return invalid handle from any of the kernel api functions that return handle in a success case

surreal path
#

so close

#

SO CLOSE

#

RAHHHH

#

here

#

its page faulting

#

@kind root memory hell :>

kind root
#

oberrow curse

surreal path
#

as usual :>

#

its the nyaux and oberrow curse

molten grotto
#

I pushed a check for the handle case, now it will fail with an assert if you try to do that

surreal path
#

nice

#

but page fault

#

HELP

kind root
#

perhaps ur reusing some memory twice

#

or freeing random stuff

surreal path
#

CR3=000000007ff39000

kind root
#

thats cr3

#

u need cr2

surreal path
#

oh

molten grotto
#

it looks like its a null deref

surreal path
#

CR2=0000000000000000

#

yeppers

#

null deref

#

alright

kind root
#

did u memset a random memory range

#

lol

surreal path
#

no???

#

๐Ÿ˜ญ

kind root
#

idk

green elbow
#

wasn't rust memory safe?? meme meme meme meme meme meme meme meme meme meme meme meme meme meme meme meme meme

surreal path
#
for i in 0..amou {
                        let mut e = PMM.alloc().unwrap();
                        e = (e as u64 + HDDM_OFFSET.get_response().unwrap().offset()) as *mut u8;
                        e.write_bytes(0, 4096 / 8);
                        e = (e as u64 - HDDM_OFFSET.get_response().unwrap().offset()) as *mut u8;
                        self.map((*new_guy).base + (i * 0x1000) as u64, e as u64, flags)
                            .unwrap();
                    }

only time i memset

kind root
surreal path
#

๐Ÿ˜Ž

#

okay @molten grotto the address i return SEEMS to be valid

#

for the region vmm

kind root
#

wtf is that alignment

#

3db?

surreal path
kind root
#

why are ur heap allocations 1-byte aligned

surreal path
#

no idea

thorn bramble
#

lmfao wtf

#

??????????

surreal path
#

๐Ÿ˜ญ

#

still cannot find the null deref

thorn bramble
#

safe rust btw

surreal path
#

very

thorn bramble
#

need to make my own rust kernel

surreal path
#

why rust oh why

#

you make my life hell

molten grotto
#

its also partially a skill issue

surreal path
#

๐Ÿ˜ 

thorn bramble
#

it is a giant skill issue

#

rust would make ur life easy

#

but u just refuse to write rust

molten grotto
#

well some parts are annoying

thorn bramble
#

ur code is literally like if it was made by one of those C to rust transpilers

kind root
#

maybe figure out why your virtual address is byte aligned and physical is page aligned

#

how did u even map it like that

molten grotto
#

but in general if you don't spam unsafe everywhere and do things a bit more ideomatically then its at least a lot better

surreal path
thorn bramble
#

rust enforces alignment so

#

it very well might cause problems

kind root
#

well it is if u assume that [virtual, virtual+4095] is valid

thorn bramble
#

its not C where you can dereference any pointer as long as the CPU is happy

kind root
#

because its not in your case

thorn bramble
#

in rust unaligned pointers are UB, no matter if you dereference them or not

#

at least iirc

surreal path
#

right

molten grotto
thorn bramble
#

oh, then i might be wrong, you CAN have unaligned pointer, just can't dereference them

#

that makes sense

#

can't create an unaligned reference

molten grotto
#

yeah that would be ub

thorn bramble
#

my bad on misinformation then

thorn bramble
#

this shit

#

i swear this looks like your code except for the libc:: types

surreal path
#

๐Ÿ’€

#

idk how im even getting byte aligned addresses wtf

thorn bramble
#

read ur code

#

and figure it out

#

print stuff

surreal path
#

both the hhdm and kernel region are 4096 byte aligned tho

#

yea they are aligned wtf

#

what the actual fuckers

cinder plinth
#

Ah Geert already did the joke

thorn bramble
#

im not geert

thorn bramble
#

oh damn

#

i said that right after the message too

#

my bad

haughty kite
#

*(int*)(((void*)x)+2) can be UB

#

especially with strict aliasing

thorn bramble
#

ok well but rust actually checks ub at runtime by default

haughty kite
#

true

elder shoal
#

Boring, real programming needs to have a luck factor

finite summit
surreal path
#

i fixed the alignement issue

#

we got as far as here

#

yea wtf is that address @kind root ๐Ÿ˜ญ

#

0xffff80007d685028

#

thats an issue with the slab allocator chat?

#

alignement issue AGIAN

#

this time with the slab?

#

am ii correcgt

#

wait no

#

wtf is going on

#

๐Ÿ˜ญ

#

????

#

CR2=0000000000000005

#

????

#

sorry

#

wha

molten grotto
#

again null deref from the looks of it

surreal path
molten grotto
#

some heap corruption ig

surreal path
molten grotto
#

it probably doesn't really help with this kind of issue

surreal path
molten grotto
#

what address

surreal path
#

prev address

#

i will print every address returned to see if its an issue with the allocator

#

sec

surreal path
#

some new info

#

object already exists?

#

wha

molten grotto
#

that can be normal but I am not sure if it should happen on qemu

surreal path
#

does the returned address look valid @molten grotto ?

#

the last thing my slab allocator returns

molten grotto
#

yes it looks valid

surreal path
#

okay

#

so not the slab issue

#

maybe vmm?

surreal path
surreal path
kind root
#

Either youre mapping incorrectly

#

Or youre corrupting the heap

surreal path
#

bru

molten grotto
#

just one guess, have you made sure that the minimum size that you pass to slab_header::init is 40?

#

because if its any less than that you are going to be corrupting the slab nodes themself

surreal path
#

nooo

#

๐Ÿ’€

molten grotto
#

I think you already had a bug like that

surreal path
#

to fix it

#

not 40

molten grotto
#

I am not sure if you had that many fields in the slab header back then tho, likely not

surreal path
#

struct slab_header {
size: usize,
next_slab: Option<*mut slab_header>,
freelist: Option<*mut KTNode>,
}

#

3 fields

#

8 + 8 + 8

#

24 bytes

#

...

#

yea

molten grotto
#

oh wait its KTNode that's used as the freelist node, nvm

surreal path
#

yes but slab header

molten grotto
#

well KTNode 16 because of the option

#

but yeah if you already made sure that the min size is 16 then that's not a problem

surreal path
molten grotto
#

ig you could just make your alloc return whole separate pages for all sizes under page size to test whether its an issue with the slab stuff

#

(and adjust dealloc appropriately or just don't do anything there)

surreal path
#

its the slab

surreal path
#

ITS THE SLAB QWINCI

#

ITS THE FUCKING SLAB

#

KAKZMKCLXM MVNKLDKG:POSF@{lpDO'K,;OLMX.,JKN CAVKD\SLJ;GOP[]aof#D

#

S

#

@molten grotto I AM IN MISERY

#

also page fault here lol

#

@kind root what does it mean !!!!!

#

wtf is a gpe block

#

your the uacpi guy

kind root
#

litearlly doesnt matter

#

fix the heap corruption

surreal path
#

i fix the other issue

#

cause it seems to me

#

theres 2 issues

#

with my allocator?

#

am i correct?

elder shoal
#

Oberrow curse strikes again

surreal path
#

RAHHHHHHHHHH

#

ko[] m,. l;k'cp[pd';,mc. ./l';#c'dl,./m ,/@:c#

#

d[sa];cl',./m โ€ขc./@~:

#

s[]D[#'M./B, ,/'#S

#

]

#

#L';VKL;L'#

#

XW

kind root
surreal path
#

in my VMM region allocator???

kind root
#

its uninstalling a gpe block because of some fatal init error

molten grotto
#

unsupported gas access size 255

#

yeah that's not a correct size

surreal path
#

huh

#

wtf

kind root
#

aka your mapping function is borked

surreal path
#

the vmm region alloc function right?

kind root
#

i mean idk what u call it

surreal path
#

thats what i call it

#

okay 2 memory corruption issues

#

amazing

molten grotto
#

also do you make sure that the alloc size doesn't exceed a page now that you are returning straight up pages for each allocation?

#

idk how much allocations like that uacpi makes if any but that could be a possible issue

surreal path
#

if layout.size < 4096

#

do one page

#

thats it

#

all i did

molten grotto
#

ah

surreal path
#
if layout.size < 4096:
  return one_singular_page()
molten grotto
#

and do you zero the memory in that page?

surreal path
#

shit

molten grotto
#

try doing that first as its also used for the uacpi calloc function

surreal path
#

CR2=0000000000000009

surreal path
#

still getting that issue

molten grotto
#

then its something different ig

surreal path
#

region thing

#

@molten grotto

#

does the vmm region base look valid

#

i feel like theres something wrong

#

block=0xffff80007daac00c

#

@kind root

kind root
#

and

surreal path
#

okay sec

#

ill inventigate further

surreal path
#

gentlemen

#

do these vmm regions look valid

#

do they look aligned

#

yea or nah

orchid dawn
#

from a glance they all look aligned

surreal path
#

i even wrote some tests

#

they all pass

#

@orchid dawn could u check it out

#

im desperate

orchid dawn
#

im at school lmfao

#

I have no idea

surreal path
#

when u come home maybe

orchid dawn
#

I still have like 20 other things I'm working on lol

#

even if I didn't, I likely would also have no idea

surreal path
#

๐Ÿ˜”

#

its not the deallocation

#

i checked

#

i cant figure this out ๐Ÿ˜ญ ๐Ÿ˜ญ

#

back to oberrow hell

surreal path
#

COME ON BRAIN THINk

#

WHAT THE FUCK IS WRONG WITH ME UGHHHH WHY CANT I FIGURE THIS STUPID

#

FUCKING ERROR

#

UNSUPPORTED GAS

#

SIZE

#

UR MOM

#

UGH

#

so annoying

#

@kind root my brain is dying

kind root
#

all this means is

#

whatever mapping u returned for FADT

#

is likely bogus

#

how does your map fn look like

surreal path
#

how big is the FADT table

surreal path
kind root
#

nono

#

for uacpi

surreal path
#

okay sec

#
unsafe fn map(&self, phys: uacpi::PhysAddr, len: usize) -> *mut core::ffi::c_void {
        (phys.as_u64() + HDDM_OFFSET.get_response().unwrap().offset()) as *mut _
    }
kind root
#

taht should work unless your hhdm is mapped incorrectly ig

surreal path
#

whichhh it isnt

#

cause i copy the above 4gb

#
for i in (0..0x100000000 as u64).step_by(4096) {
            q.map(
                HDDM_OFFSET.get_response().unwrap().offset() + i as u64,
                i as u64,
                VMMFlags::KTPRESENT.bits() | VMMFlags::KTWRITEALLOWED.bits(),
            )
            .unwrap();
            hhdm_pages += 1;
        }
kind root
#

i mean idk, something related to memory is bugged

surreal path
#

yea and i have no fucking idea how im gonna debug this

kind root
#

well u can just printf

surreal path
#

literarly what i did

kind root
#

also put a breakpoint in gdb