#Nyaux

1 messages ยท Page 22 of 1

rigid fable
#

in what regard? running Linux or as an architecture/device

finite summit
#

Idk

#

Just ignore that

rigid fable
#

Well Linux runs fine on the PS3. As today you need a jailbroken PS3, since on OFW the otherOS feature was removed. Apart from that you just need a bootloader like Petitboot and a PPC build of Linux. There is also a lot of progress in PS3 RSX (gpu) hardware acceleration

#

look for T2 SDE

thorn bramble
#

and the ps4 is a somewhat standard amd apu iirc

rigid fable
#

and as an architecture it is so complex that still today it is THE hardest arch to emulate

thorn bramble
#

minus the non standard platform

thorn bramble
#

i wonder if it's got acpi

rigid fable
#

well the PS4 OS is just BSD

#

idk that may mean something

thorn bramble
#

well, its not "just" a bsd

#

its gotta be heavily modified

#

to actually fit their needs

#

and to run on their weird hardware

#

but they've done it, people got linux to run on it too

#

its not that bad apparently

kind root
#

When you port if of course

molten grotto
#

one thing which I don't know is whether you can get a framebuffer without actually writing/porting an amd gpu driver on it

elder shoal
#

Just do it ez

kind root
#

I'm sure its not rocket science to get a fb

flat nymph
#

hyper for PPC when

kind root
#

You dont even use it KEKW

#

For hyper im mostly fixing bugs or adding tiny qol features, as it is mostly feature complete for my needs

#

But im not against accepting changes that others might want if there's a need

elder shoal
#

uBIOS for booting hyper oses without a bootloader when

flat nymph
#

Maybe I will go to 32 bits

#

(after I fix RISC-V)

tawdry mirage
#

like it responds to any slot number, and they ran out of functions so a whole bunch of stuff is shoved into one function

unkempt relic
#

amazing everyone went over to powerpcs for games consoles when the ps3/xb360/revolution came out now everyone is on amd64 (i think, i don't know what that one nintendo uses, the wiiu or whatever it was called)

tawdry mirage
#

the switch is just an nvidia tegra x1 soc

#

which is aarch64

#

the wiiu is ppc since it's a direct upgrade to the wii (and that is a direct upgrade to the gamecube)

#

iirc

unkempt relic
#

when the ps3 came out its architecture was supposed to be revolutionary (ibm "cell", 1 ppc core, 8 something-or-others) but that fell very flat

tawdry mirage
#

problem with revolutionary arches for consoles is that it's hard to port games and have them be properly optimized :^)

#

unless it's an exclusive ig

finite summit
kind root
#

okok not literally

rigid fable
#

oh and I am quite sure that the only reason this did not affect the xbox 360 is because it had directX and other stuff from Windows which made porting easier. (let's not talk about the memory pool division)

tawdry mirage
surreal path
#

hi all im back

#

what we talking about

#

lol

tawdry mirage
#

considering they require a bunch of setup before you run code on them

#

and it's compiled separately afaik so that's extra effort as well

rigid fable
#

yes

rigid fable
edgy pilot
rigid fable
#

you could run physics, sound, graphics (also with the RSX), AI, particles and so on each on one SPU

#

actually at the beginning Sony wanted to use two separate CELLs for the cpu and gpu, but for cost issues they ditched the idea and quickly tried to partner up with ATI and then NVidia

surreal path
#

okay so

#

what does an Elf loader need to do exactly

#

like im unsure how to implment this i forgot a ton of things about elf lol

edgy pilot
thorn bramble
#

you take an address space

#

you take an elf

#

you map it in the address space

surreal path
#

what is an auxval

edgy pilot
#
struct auxval
{
    uint64_t at_entry;
    uint64_t at_phdr;
    uint64_t at_phent;
    uint64_t at_phnum;
};
surreal path
#

wha

thorn bramble
#

bro you have done it

#

already

#

how do you forget that quick

surreal path
#

i cant remember bro

#

i have shitty memory

thorn bramble
#

3.4.1

surreal path
#

3.4.1 is talking about fpu state

edgy pilot
#

yeah I think that's way more useful link :D

#

than my shitty code

thorn bramble
#

dont stop 1 paragraph in

#

"Initial Stack and Register State"

#

yeah only talks about fpu state

#

sure.

surreal path
#

okay i see

thorn bramble
#

scroll a bit more down

#

figure 3.9

edgy pilot
surreal path
edgy pilot
#

any issues?

surreal path
#

no

edgy pilot
#

nice

surreal path
thorn bramble
#

yeah good

#

im glad you can still see

surreal path
#

and auxilary vectors kind of give

#

arugments to the interpreter itself

#

ish

#

am i understanding correctly

thorn bramble
#

interpreter*

#

or rather the program that's running

#

it just so happens that the program is an interpreter

surreal path
#

i see

#

what auxilary vectors do i need to give

thorn bramble
#

check mlibc source

#

that will tell you the bare minimum of what you need to provide

#

but generally linux and any other kernel that loads elf executables provides most if not all of these

surreal path
#

where in mlibc source

thorn bramble
#

on github?

surreal path
#

no i mean

#

which directory am i looking for

thorn bramble
#

oh where in

#

i read where is

#

idk use search

#

go look at the rtdl source

surreal path
#

so it needs these?

thorn bramble
#

the first 4 are definitely needed

#

rest is probably optional

surreal path
#

in what order

#

should i push the aux vectors

thorn bramble
#

doesnt matter

surreal path
#

doesnt care?

thorn bramble
#

they are

#

iterated over

#

and itg just checks

#

what it's got

surreal path
#

okay

thorn bramble
#

like it doesnt check the order

#

does it

#

ok sorry my bad

#

no it doesn't matter what order they are in

#

as long as they're all there

surreal path
#
#[repr(C, packed(8))]
struct Elf64EntryHeader {
    e_ident: [i8; 16],
    e_type: u16,
    e_machine: u16,
    e_version: u32,
    e_entry: u64,
    e_phoff: u64,
    e_shoff: u64,
    e_ehsize: u16,
    e_phentsize: u16,
    e_phnum: u16,
    e_shentsize: u16,
    e_shnum: u16,
    e_shstrndx: u16
}
#[repr(C, packed(8))]
struct Elf64ProgramHeader {
    p_type: u32,
    p_flags: u32,
    p_offset: u64,
    p_vaddr: u64,
    p_paddr: u64,
    p_filesz: u64,
    p_memsz: u64,
    p_align: u64
}

#[repr(C, packed(8))]
struct auxvec {
    a_type: i32,
    a_val: u32,
    a_ptr: u64,
    a_fnc: 
}
#

okay i have these structs going

#

what should a_fnc be

thorn bramble
#
typedef struct
{
    int a_type;
    union {
        long a_val;
        void *a_ptr;
        void (*a_fnc)();
    } a_un;
} auxv_t;```
#

its supposed to be a union

surreal path
#

how to do a union in rust lmao

thorn bramble
#

union

surreal path
#

seriously?

thorn bramble
#

go try it

surreal path
#
struct auxvec {
    a_type: i32,
    union w {
        
    }
}
#

it didnt work

thorn bramble
#

...

surreal path
#

๐Ÿ˜ญ

thorn bramble
#

thats why you should learn the

#

language

#

first.

#
#[repr(C)]
union AuxvUn {
  a_val: u32,
  a_ptr: usize,
  a_fnc: usize,
}
#[repr(C)]
struct Auxv {
  type_: i32,
  un: AuxvUn,
}```
edgy pilot
#

no anonymous unions?

surreal path
#

yea i figured it out

edgy pilot
#

<insert megamind>

thorn bramble
#

no ub?

#

oh wait...

#

he uses raw pointers everywhere!

#

you should see his code lol

surreal path
#

๐Ÿ˜ญ

edgy pilot
#

:D

surreal path
#

what should the load_elf_function take in as arugments

#

or whatever tf

edgy pilot
#

the elf file

surreal path
#

the path?

edgy pilot
#

whatever you prefer

surreal path
#

what else

edgy pilot
#

the path, your version of vnode

#

etc

surreal path
#

what is the etc

#

??

#

๐Ÿ˜ญ

edgy pilot
#

idk

surreal path
#

๐Ÿ’€

edgy pilot
#

just load the whole 50mb file in memory and pass a raw pointer

#

use a path

surreal path
#

i see in ur code u take in base

edgy pilot
#

address the elf is loaded at

surreal path
#

i see

edgy pilot
#

you should probably randomise that a bit

#

"for security reasons"

thorn bramble
#

just

#

let him load the elf first

#

he doesnt even know what aslr is

edgy pilot
#

yes

surreal path
#

aslr?

thorn bramble
#

what did i say

surreal path
#

lmao

thorn bramble
#

just load the darn elf

surreal path
#

okok

thorn bramble
#

dont owrry about anything else

kind root
#

inb4 stuck for a month

surreal path
#

๐Ÿ’€

#

nahhh

molten grotto
#

I wonder what if I wouldn't have helped diagnose all those issues lol

kind root
#

u know the answer

surreal path
#

๐Ÿ˜ญ

#

infy hates me i swear chat

kind root
#

nah

#

i want u to succeed

#

but it seems like u take the easy way out every time

surreal path
#

not anymore

thorn bramble
#

*mut vfs

edgy pilot
#

static mut

thorn bramble
#

unsafe

surreal path
#

OKAY but it works

#

and raw pointers are faster in rust

#

to be fair

thorn bramble
#

for now

#

what

#

did u just

kind root
#

yes after qwinci debugs it

thorn bramble
#

say?

surreal path
thorn bramble
#

it works until you compile with --release

edgy pilot
#

lmao

surreal path
#

whats gonna happen in --release

thorn bramble
#

take a guess

surreal path
#

actually im gonna try that rn

thorn bramble
#

the answer is nobody knows

#

because you just dropped

#

all the ownership

#

lifetimes

#

and pointer provenance info

#

so llvm can do all that it wants

surreal path
#

let me try

thorn bramble
#

in terms of optimizations

#

even if it breaks your program

surreal path
#

im gonna run it

#

youll see it WONT break

edgy pilot
#

the easy way here is -O0

#

or something equivalent

surreal path
#

oh

thorn bramble
#

nah its a shit way out

surreal path
#

it did

thorn bramble
#

lol

#

who would have guessed

edgy pilot
#

lmao

thorn bramble
#

that breaking all the safety features

#

would break something

#

not me

surreal path
#

am i gonna have to do a third kernel rewrite

edgy pilot
#

in lua

surreal path
#

no

thorn bramble
#

if you want it to be in rust, yes

#

lol

#

like im not even being mean at this point

#

its dogshit

surreal path
#

i guess we are doing a third kernel rewrite

thorn bramble
#

i wish i could put it nicely

#

but i cant

#

you just dont write rust like that

#

and expect it to work

surreal path
#

but I want you guys to make sure that ANY code i write is the proper "rust way"

edgy pilot
#

I would suggest to first learn the language you're going to write a kernel in

thorn bramble
#

why should i make sure ur writing it correctly lmao

surreal path
#

๐Ÿ˜ญ

#

okay i take that back

#

ill just

thorn bramble
#

also everyone already told you to not write code like that

surreal path
#

double check

thorn bramble
#

anywhere where you have to use a raw pointer in rust

#

you should double check

#

because you should never have to do that

#

almost never*

#

and if you do it should be only for the abstractions that provide safety

edgy pilot
#

you shouldn't use raw pointers
unless you are accessing some system resource or using a library that requires it

thorn bramble
#

not even that

#

you should have abstractions over that too

#

that interact properly with lifetimes and shit

surreal path
#

okay

#

i will

thorn bramble
#

rust uses all that info for optimizations

surreal path
#

properely

#

rewrite the kernel

#

okay

edgy pilot
#

starting now?

surreal path
#

yep

#

third nyaux rewrite

thorn bramble
#

like you really need to know

#

what you're doing

edgy pilot
#

do some userspace rust program first

#

write tetris

thorn bramble
#

to write a kernel in rust

kind root
#

how are u going to rewrite it if u technically dont know rust still

#

ur going to end up with the same stuff

surreal path
#

okay then

thorn bramble
#

basically yeah

surreal path
#

how do i learn rust

#

properly

#

lmao

thorn bramble
#

write rust code

edgy pilot
#

userspace projects

thorn bramble
tawdry mirage
#

RIIC++ :^)

thorn bramble
#

based qookie

elder shoal
#

do a microkernel, write it in asm, and write brainfuck servers :')

thorn bramble
#

but id rather not see him struggle with that

surreal path
#

okay so whats the perfect rust project

#

that will teach me

#

everything i need to know of rust

thorn bramble
#

there isnt one

tawdry mirage
#

a kernel halfmemeleft

edgy pilot
thorn bramble
#

rust is a complicated language, to learn all of what you need to know you need to really spend some time with it

surreal path
#

cause i HAVE spent time with it

#

but the problem is

thorn bramble
#

you have not

surreal path
#

i have

#

but

thorn bramble
#

you were translating C to rust

#

that isnt

surreal path
#

i have c habits

thorn bramble
#

what i was talking about

#

HABITS?

#

no that is NOT habits

surreal path
#

๐Ÿ˜ญ ๐Ÿ˜ญ

thorn bramble
#

you just translated C code to rust brother

#

you didnt even take into consideration what the language offers

surreal path
#

okay heres what ill do

#

ill read through the rust book today overnight

#

and work all night learning rust

#

ill come back to yall tomorrow

#

and we can rewrite nyaux

thorn bramble
#

i dont think thats a good idea

surreal path
#

why

thorn bramble
#

to do it

elder shoal
#

or have a good night of sleep

thorn bramble
#

and then go sleep

#

yeah do that lol

elder shoal
#

and slowly learn rust properly

thorn bramble
#

its gonna take you months

surreal path
#

but it will delay my work on nyaux

thorn bramble
#

to learn rust properly

surreal path
#

nooo

thorn bramble
#

to be able to write a good kernel

#

it took me like more than a year or so to actually figure out how rust works

#

but probably because im slow

surreal path
#

im much faster at learning languages

#

to be fair

thorn bramble
#

and i was just used to writing code

#

you need to get used to programming

#

idk

#

its like the same thing

surreal path
#

i think it could take me 1-2 days if i really spend all my weekend on it

thorn bramble
#

but it feels like its a completely different thing

#

lol this guy is not being serious

#

learn rust in 2 days ๐Ÿ˜ญ

surreal path
#

no sleeping

thorn bramble
#

ok im outta here

#

gn

surreal path
#

gn iretq

thorn bramble
#

lmk when ur being serious

#

and whether you still want to

surreal path
#

wdym

thorn bramble
#

continue this rust kernel thing

surreal path
thorn bramble
#

i mean obviously you arent serious if you think you can learn rust well enough in a couple days to be able to write a good kernel

thorn bramble
#

its not about how long

#

its not an amout of time

#

that makes you good at a language?

surreal path
#

but what do i do with nyaux while im fucking

#

learning rust properly

#

i cant just

#

stop working on it

#

like it'd be the third time id do that shit

thorn bramble
#

idk but you clearly cant keep working on it if you dont know the language

#

you are just going to end up writing the same shit code with bunch of raw pointers all around the place

#

because "oh i cant figure out how this shit works but it works with pointers so ill just do that!"

edgy pilot
#

rewrite it in c and using raw pointers won't matter :D

thorn bramble
#

like rust is not a good language if you want to work on the kernel

#

because you are writing rust, not writing a kernel

#

idk if you catch my drift

surreal path
#

okay how abt ill come back in a week, after non stop rust development. I know i cant fully learn a language in that length of time but maybe i could be able to start on the rewrite at least

idfk i really dont wanna be waiting fucking months, osdev is my passion

thorn bramble
#

why do you even want to use rust

surreal path
#

the features i guess

#

safety and shit

#

also enums are nice

thorn bramble
#

you can have tagged unions in c(++)

#

but yeah as i said

surreal path
#

thing is

#

i dont know c++

thorn bramble
#

you need to actually understand the language

#

to be able to make use of its safety features and shit

thorn bramble
surreal path
#

again just give me a week, i promise that when i come back ill at least be more competent at the language

#

maybe make a less shitty kernel

#

still shitty but less

edgy pilot
#

component?

thorn bramble
#

competent

#

ah

#

faster

surreal path
#

still

#

ill rewrite it again

#

and again

#

and again

tawdry mirage
surreal path
#

until it fucking is good

thorn bramble
tawdry mirage
thorn bramble
#

i liked that

surreal path
thorn bramble
#

i mean up to you what you do

#

but as i said maybe if you want to do osdev you should do it in a language you know relatively well

#

unless you are fine with "waiting"

surreal path
#

still

#

ill rewrite it again

#

and continue this cycle

#

until i know proper rust and write a good fucking kernel

thorn bramble
#

might take a while

surreal path
#

we'll see

thorn bramble
#

but as i said you do you

#

personally id just use a language im familiar with

surreal path
#

even i dont know 100% of C's features

thorn bramble
#

c has no features bro

#

its a dead simple language

#

you write code

#

it does what you type

#

literally

surreal path
#

look ill just see what i can do

#

im gonna go and fucking learn rust now

#

see yall later, ill update you guys on how thats going

thorn bramble
#

well gl to you then meme

surreal path
thorn bramble
#

i am going to sleep

surreal path
#

gn

#

im not sleeping ๐Ÿ˜Ž

thorn bramble
#

im gonna write my kernel in c++ tomorrow

surreal path
#

niceee

thorn bramble
#

ill update you guys on how thats going

#

(maybe)

surreal path
#

๐Ÿ˜ญ ๐Ÿ˜ญ

thorn bramble
#

maybe because it probably doesnt go anywhere knowing myself

#

;')

tawdry mirage
thorn bramble
#

i mean is there really that much ub in C

#

for the most part it just does what you want it to do

elder shoal
thorn bramble
#

thats why its such a good language

#

but i do love some RAII and templates

elder shoal
thorn bramble
#

thats why i am going to use c++

tawdry mirage
thorn bramble
#

damn signed integer overflow sounds funky

#

idk what strict aliasing even means so i dont have to worry about that one right? meme

tawdry mirage
#

unsigned is defined to wrap around but signed is ub

thorn bramble
#

as in ((int64_t)0x7fffffff)+1 is ub?

#

ffff more

#

or int32_t

tawdry mirage
#

yeah

thorn bramble
#

interesting

tawdry mirage
#

it's not technically guaranteed to wrap to the lowest value

#

so checks like if (a + 1 < a) just get optimized out for example

#

because since overflow is ub and can't never happen, +1 means it's always larger

thorn bramble
#

fun

#

good thing i always do checks like this by checking against the max value

#

i guess im somewhat aware of things like that, or maybe the code ends up being cleaner or easier to read that way idk

tawdry mirage
#

so much for people knowing c meme

thorn bramble
#

so what about this strict aliasing thing?

#

are you able to tldr that or is it a bit more complicated

#

is it with multiple pointers pointing to the same value or something

tawdry mirage
#

dereferencing a pointer that aliases a value of an incompatible type

thorn bramble
#

ah so like c uint64_t v = 1337; uint8_t x = ((uint8_t*)&v)[5];

tawdry mirage
#

well through char it's explicitly allowed meme

thorn bramble
#

lmao

tawdry mirage
#

but *(float*)&my_int

molten grotto
#

no if uint8_t is unsigned char/char

edgy pilot
#

oh good

tawdry mirage
thorn bramble
#

is the famous fast inverse sqrt snippet ub?

tawdry mirage
molten grotto
tawdry mirage
elder shoal
#

sweet sweet ub

tawdry mirage
#

you can disable strict aliasing in c with -fno-strict-aliasing

thorn bramble
#

nice, now i know why its so "fast"

thorn bramble
#

probably nothing significant

molten grotto
#

yeah

tawdry mirage
#

yeah it means some optimizations aren't possible

thorn bramble
#

so tldr instead of type punning actually tell the compiler about the types properly

tawdry mirage
thorn bramble
#

yeah the compiler optimizes out the write

#

that makes sense

tawdry mirage
#

not even that, the compiler assumes the value of x is unchanged because the write couldn't have aliased the struct

#

so it yeets the assert out

thorn bramble
#

yeah basically what i was getting at

#

oh wait

#

yeah that makes sense

#

i thought it would yeet the write and the assert

tawdry mirage
#

technically it could do that as well

thorn bramble
#

ah

#

so if you made the write volatile what would happen?

#

would it still yeet the assert?

tawdry mirage
#

it still could, but i have a hunch it might not?

#

but i'm not sure what compilers will do, but technically volatile doesn't mean "stop caring about strict aliasing"

thorn bramble
#

i see

#

yeah i meant in terms of strict aliasing, sorry

#

it would still be valid to assume that y.x is still 0

#

because that write could not have possibly affected the struct blah blah

unkempt relic
#

with a volatile load of y.x it wouldn't, with a volatile write through a float alias, that's another matter

thorn bramble
#

yeah i was just wondering what swapping out that float write for a volatile one would do

#

thats interesting though, ill definitely watch out for any aliasing i might or might not do in the future :')

#

thanks for breaking that down for me qookie

tawdry mirage
#

some aliasing is fine though

#

e.g. a pointer to struct T can be cast to a pointer to the type of it's first member

thorn bramble
#

right

#

but at that point just &x.y

tawdry mirage
#

well it's useful for approximating inheritance

thorn bramble
#

yueah i was about to say

#

it might be nice in case of like a shared header

#

can you do it the other way?

tawdry mirage
#

hmm

thorn bramble
#

int* -> struct { int x; }*

tawdry mirage
#

i want to say yes

thorn bramble
#

lol that syntax is wrong

#

but you get the point

unkempt relic
#

in practice you always turn off strict aliasing, but it's an interesting thought to consider trying to get away from it altogether

tawdry mirage
molten grotto
#

lol

unkempt relic
#

maybe turkish or syrian

thorn bramble
#

An object shall have its stored value accessed only by an lvalue expression that has one of the
following types:99)
โ€” a type compatible with the effective type of the object,
โ€” a qualified version of a type compatible with the effective type of the object,
โ€” a type that is the signed or unsigned type corresponding to the effective type of the object,
โ€” a type that is the signed or unsigned type corresponding to a qualified version of the effective
type of the object,
โ€” an aggregate or union type that includes one of the aforementioned types among its members
(including, recursively, a member of a subaggregate or contained union), or
โ€” a character type.

#

technically it should be valid to alias a struct pointer using a pointer of the type of any of its fields? or im just misunderstanding because im tired

#

yeah i might be misunderstanding, not sure what "object" refers to in this case

surreal path
#

progress so far: i learned a lot more about lifetimes and rusts safety system, im currently writing simple userspace programs with extensive use of rusts advanced features to understand the language well

#

i dont know the eta on when ill be able to start rewriting the kernel but lets just keep going and see how we go

thorn bramble
#

mate u dont need to rush

#

take it easy and learn it properly

#

dont take shortcuts in your little programs like you did with the kernel

surreal path
#

i wont

thorn bramble
#

nice, good luck

surreal path
#

thanks !

kind root
#

try writing a simple emulator

#

like for nes maybe

surreal path
#

great idea

#

ill do that once i finished the book qookie gave yesterday

#

turns out linked lists are very useful for learning rust as a language lmao

surreal path
#

update today

#

so after finishing the linked list booklet and after properly finishing the rust book i believe im ready to try another rewrite, ive already done well without using static mut and instead wrapping a static variable under a mutex making it "safe", im using lifetimes and generics and shit as well. i never cast a pointer from pointer -> address -> pointer anymore. and i am always compiling in release mode

#

i am experiencing a problem with my own rust flanterm bindings however

#
  = note: rust-lld: error: /home/Rayan/Desktop/NyauxKT/kernel/target/x86_64-unknown-none/debug/deps/libflanterm_bindings-63cfa04b5ca34f3f.rlib(47dd3966b7af1aa8-fb.o):(function flanterm_fb_init: .text.flanterm_fb_init+0x186e): relocation R_X86_64_32 out of range: 18446744071562110592 is not in [0, 4294967295]; references section '.rodata.builtin_font'
          >>> referenced by fb.c:1018 (backends/fb.c:1018)
#

i dont know if this is a problem with my bindings or

#

if this is a problem with flanterm on their end

finite summit
#

Use

#

C

surreal path
#

no >:)

finite summit
#

Do it

#

C is nice

#

coolo

#

easy

surreal path
#

no

finite summit
tawdry mirage
surreal path
surreal path
#

i cant disable pic

#

it wont let me

finite summit
#

use C, that's the solution

surreal path
#

no

tawdry mirage
#

why can't you disable pic?

finite summit
flat nymph
#

It's easier to learn Rust if you know C++ memedown

finite summit
#

it's easier to not learn rust

#

it's like a parasite that once in your brain, is fatal

surreal path
#

i got it working

tawdry mirage
#

nice

surreal path
#

i got the gdt and idt working too

#

in fact let me test that out

#

with a page fault lol

#

works well

#

no static mut

#

barely any unsafe

#

time for the PMM

surreal path
#

pmm done

wide nexus
#

it looks pretty good

thorn bramble
#

@surreal path is your code up on github?

edgy pilot
#

oh 3rd rewrite already?

#

good luck

#

I started mine and basically stopped

#

In a day

desert haven
#

howcome you stopped?

edgy pilot
#

no motivation

desert haven
#

fair enough

surreal path
#

after religious testing of the PMM in rust release mode, the PMM is fine and can remain unchanged mostly (other then the removal of static mut for static behind a mutex)

kind root
#

did u finish the nes emulator already Pogomega

surreal path
#

kinda got it working to a point where it could parse opcodes and execute them

#

i didnt implement mappers or the apu or anything tho

kind root
#

why do u just speedrun everything LULW

#

writing one thing u can be proud of is so much cooler than many shitty things

surreal path
#

im not into writing emulators that much to be fair memedown

kind root
#

i think its kinda cool when u just write a generic thing that executes opcodes and then all of a sudden u can run other peoples stuff on that code

#

but yeah i get it

surreal path
#

nyaux might become assert os

#

like managarm

#

i just learned i can use asserts OUTSIDE of tests in rust

#

i am so happy about this information

kind root
#

remember to use asserts only for state corruption detection, not invalid external data

thorn bramble
#

assert!(pmm_is_ok)

kind root
#

^

thorn bramble
#

not assert!(this_user_pointer_isnt_null)

surreal path
#

oh gotcha

kind root
#

or not assert(this_hw_register_returned_0)

thorn bramble
#

extrapolate this to the entire kernel, but yeah

#

that too

#

basically use asserts as sanity checks

surreal path
#

gotcha

#

i will now rewrite the VMM

thorn bramble
#

assert!(@surreal path pushed his code to github)

surreal path
#

the PMM has remained unchanged but the VMM is probs prone to a lot of bugs

surreal path
#

first

#

lmao

thorn bramble
#

oki

kind root
#

show emulator code

#

im expecting idiomatic rust

elder shoal
thorn bramble
#

oh yeah i kinda wanna see it

#

some constructive criticism coming right up

surreal path
#

managarm os

#

more like

#

assert_eq(managarm)

#

okay that sounded better in my head

#

๐Ÿ’€

hollow goblet
#

explain this atheists

surreal path
#

vmm status: nearly complete

#

page table manager part of it is done

#

im working on the region setup function

thorn bramble
#

put the code up on github !! ! ! !

#

also the 6502 emu too meme

#

i wanna see how you are doing

surreal path
#

ITS ONLINE

#

WE GOT THE VMM WORKING

thorn bramble
#

cool stuff

surreal path
#

wait 2 secs

#

yea look at it now

orchid dawn
thorn bramble
#

i am gaming

surreal path
kind root
#

what was the bug

surreal path
#

BIT

#

was set incorrectly

#

๐Ÿ˜ญ

kind root
#

did qwinci fix it

surreal path
#

no

kind root
#

qookie?

surreal path
#

i noticed it

#

and solved it

kind root
surreal path
#

YESSSS

thorn bramble
surreal path
molten grotto
#

nyaux nt compatibility when troll

surreal path
thorn bramble
#

better question

#

why is it nyauxkt

finite summit
thorn bramble
#

instead of nyauxrs

surreal path
#

๐Ÿ˜ญ

thorn bramble
#

if its written in rust

#

and not kotlin

#

jvm os when

surreal path
#

๐Ÿ˜ญ ๐Ÿ˜ญ

finite summit
#

so when nyuax working-set vmm

#

trust me, it's not that hard

surreal path
finite summit
#

set of pages required to be paged in for an application to run as efficiently as possible

#

in short

thorn bramble
#

in short, don't

#

lol

surreal path
#

๐Ÿ˜ญ

molten grotto
#

just don't support swap yea lol

surreal path
#

lol

thorn bramble
#

who swaps anyway

#

just buy more ram

#

and let programs oom instead

#

clearly the better choice

#

at least you dont risk swapping to death

elder shoal
#

Im not too far away from supporting swap in astral Id imagine, shouldnt be too different from a file backed page

finite summit
#

#1061407633745125397 message

finite summit
#

at least

#

maybe the swap in/out part can be implemented like that

#

but to know what you'd swap out, you'd probably want a working-set, and a page replacement algorithm (such as aging) to go with it

elder shoal
#

Ikik

#

I thought of doing that before

finite summit
#

but note that swap in/out doesn't always go to disk

#

it also uses standby/dirty

#

*it also can use

#

lemme find something

#

#1141057599584878645 message

surreal path
#

lets go

finite summit
#

we love nyaux's logs

#

IT FUCKING WORKED
Yippie

surreal path
#

Yippie :3

surreal path
#

MY UNMAP FUNCTION DOESNT WORK

#

WHY TF

edgy pilot
#

same as map but just clear the entry

#

and invlpg

surreal path
#
pub fn unmap(&self, va: usize) {
        let him = unsafe { Self::find_pte(self.rootpagetable as usize, va) };

        unsafe { him.write(0) };
        println!("{:#x}", unsafe { him.read() });
        unsafe {
            core::arch::asm!("invlpg [{x}]", x = in(reg) va, options(nostack, preserves_flags))
        };
    }
unsafe fn find_pte(mut pt: usize, va: usize) -> *mut usize {
        let mut shift = 48;
        for i in 0..4 {
            shift -= 9;
            let idx = (va >> shift) & 0x1ff;
            let ptab: *mut usize = virt(pt);

            if i == 3 {
                return ptab.add(idx);
            }
            let entry = ptab.add(idx);

            if entry.read() & VMMFlags::KTPRESENT.bits() == 0 {
                return entry;
            }

            pt = entry.read() & 0x000f_ffff_ffff_f000;
        }
        unreachable!()
    }
#

BUT IT DOESNT WORK

#

NO PAGE FAULT

edgy pilot
#

wdym doesn't work

surreal path
#

I CAN STILL WRITE TO THE ADDRESS

#

AFTER UNMAPPING

edgy pilot
#

write to cr3 again

surreal path
#

oh

surreal path
edgy pilot
#

that's just for testing

#

your unmap works

#

does this dereference? invlpg [{x}]

surreal path
#

yes

edgy pilot
#

it shouldn't

surreal path
#

oh

#

okay lets try

#
error: invalid operand for instruction
   --> src/mem/vmm/mod.rs:187:31
    |
187 |             core::arch::asm!("invlpg {x}", x = in(reg) va, options(nostack, preserves_flags))
    |                               ^
    |
note: instantiated into assembly here
   --> <inline asm>:2:2
    |
2   |     invlpg r14
    |     ^

edgy pilot
#

that might have been correct

surreal path
#

wdym

#

yea it was

edgy pilot
surreal path
#

yea

#

switching to it does nothing @edgy pilot

#

why always happens to me

edgy pilot
#

just don't worry about it

#

it's not like you need unmapping

#

for now

surreal path
#

i do

edgy pilot
#

and it does unmap

surreal path
#

it doesnt

edgy pilot
#

it just doesn't flush the tlb

surreal path
#

no i need to fix this

edgy pilot
#

bruh

surreal path
#

wait i have an idea

edgy pilot
#

what's your idea

surreal path
#

MORE PROBLEMS

#

LOVELY

#

2 BUGS NOW

#

WHATS NEXT GOD

edgy pilot
#

what was your idea

surreal path
kind root
#

nyaux dont get stuck for 10 seconds impossible challenge

surreal path
#

yea im actually losing it

kind root
#

how long until u give up

surreal path
#

NEVER

kind root
surreal path
#

ILL NEVER GIVE UP

#

๐Ÿ˜Ž

elder shoal
#

I cant say much because I was stuck for like hours all because I was calling the wrong gcc builtin (__get_cpuid instead of __get_cpuid_count)

thorn bramble
#

but he miraculously came back

kind root
#

that will save you hours

kind root
kind root
#

didnt he like solve tons of bugs for u

surreal path
#

uea

#

yea

elder shoal
#

qwinci can you fix ps/2 in astral real harwdwaire for me next pls pls plsss ๐Ÿฅบ๐Ÿฅบ๐Ÿฅบ๐Ÿฅบ๐Ÿฅบ

finite summit
#

Astral challenge: unfuck ps/2
challenge level, impossible

#

obos challenge: uncurse
challenge level: locked

surreal path
#

qwinci pwtty please ๐Ÿฅบ ๐Ÿฅบ ๐Ÿฅบ fix this dumb ah bug for me plss ๐Ÿฅบ

kind root
# finite summit obos challenge: uncurse challenge level: locked

obos challenge: run at least for 2ns before double faulting
challenge level: insanity

astral challenge: find one pc (other than mathewnd's hardware) where ps2 works
challenge level: cock torture

nyaux challenge: unmap a page
challenge level: months of debugging by qwinci

elder shoal
#

find three pcs where ps2 works*

#

it works on my laptop and desktop

#

but ONLY ON MY DESKTOP AND LAPTOP KEKW

kind root
#

corrected

elder shoal
#

soon I'm gonna be running webkitgtk with 128 cores before ps2 works

kind root
#

lmao

finite summit
#

I only panic

#

I usually only double fault

#

at max

kind root
#

corrected

thorn bramble
#

i got windows to double fault only once in my entire life

#

by accident that is

#

not very hard to do deliberately

#

so you should probably work on that meme

finite summit
#

I don't double fault often

#

only a couple times during the fireworks test because of a vmm bug

#

but other than that, I don't really crash that much

#

only hangs mainly

median goblet
#

the working set list is the list of virtual address that have valid PTEs

#

on x86(_64), a valid PTE is any PTE with the present bit (0) set

finite summit
unkempt relic
finite summit
finite summit
unkempt relic
finite summit
#

Ok good to know

median goblet
flat nymph
haughty kite
#

probably not

flat nymph
#

(I'm wanting/trying to implement it in my OS, but I'm stuck with locks)

thorn bramble
#

how did managarm get involved in this whole thing lol

#

no managarm doesn't have swap

magic kernel
flat nymph
#

So OBOS and soon NyauxKT >>> Managram?

thorn bramble
#

managarm works by allocating memory and praying there is enough physical memory to cover the allocations

#

quite literally meme

thorn bramble
haughty kite
#

you can call it an assert its okay

thorn bramble
#

it literally asserts if there is no free physical memory

elder shoal
flat nymph
haughty kite
thorn bramble
#

probably

#

idk

#

compile and test it yourself if you wanna know

flat nymph
#

I mean asserts are supposed to be removed when not debugging..?

haughty kite
#

asserts are forever

median goblet
thorn bramble
#

idk

#

i'm not a managarm developer lol

#

fwiw tho, iirc they use meson debugoptimized

#

so it's debug release :)

elder shoal
#

Managarm without asserts is like an angel without its wings

thorn bramble
#

TRUTH.

magic kernel
#

Itโ€™s even a draft PR (699)

#

But that just returns a nullptr and that then needs to be handled back up the stack, that part is still lacking. Iโ€™m pretty sure I left for summer vacation and I just drafted it in

surreal path
#

lol

#

anyways time to figure ut whats going on

surreal path
#

okay one part solved

#

the next bug

#

needs solving

#

unmap

#

DOESNT WORK

#

RAHHH

surreal path
#

lets go

#

only using rust references

#

no raw ptr

#

finally

#

no ub

thorn bramble
#

that doesn't mean you don't have UB in your code :)

#

just the parts using references don't have UB

#

creating a reference still might be UB

surreal path
#

THEN HOW DO U MAKE SOMETHING COMPLETELY NOT UB ๐Ÿ˜ญ

thorn bramble
#

know what you're doing

#

that's #1

surreal path
#

fair

hollow goblet
thorn bramble
#

yep

hollow goblet
#

and with strict provenance, integer -> pointer casts are UB which are kinda required for like PA->VA conversion

surreal path
#

and i will keep it disabled

hollow goblet
#

i believe MIRI runs stuff with strict provenance or something like that? I don't actually know much about provenance lol

#

even if it's not exactly strict provenance, MIRI will be REALLY MAD at creating pointers from integers

surreal path
#

who cares abt what miri thinks

hollow goblet
#

anyhow if you really wanna "prove" your code is UB-free, extract pieces of it to run in miri

surreal path
#

im just gonna use references everywhere anyway

hollow goblet
#

you can mess shit up with references too

surreal path
#

i know what im doing tho so

#

yea

hollow goblet
#

it's not easy to check if you're correct without the right tools

#

it would be really cool to do a unit test + miri setup of sorts

surreal path
#

slab allocator and pmm done in safe rust

#

should i take a break

#

for an hour

#

or vmm now

thorn bramble
#

slab isnt safe rust*

surreal path
thorn bramble
#

itโ€™s not

surreal path
thorn bramble
#

well it's fucking not!

surreal path
#

okay chill iretq ๐Ÿ˜ญ

thorn bramble
#

you still use raw pointers

surreal path
#

ONLY A FEW TIMES

thorn bramble
#

dereferencing them into references doesnt make it safe

#

lol

#

u took ur code

#

and everywhere u made it into references

#

that doesnt make it safe

#

its still the same inherently broken algorithm

surreal path
#

okay so how ELSE am i supposed too write it

surreal path
thorn bramble
#

ur creating pointers from thin air

surreal path
thorn bramble
#

i just did

surreal path
#

am i supposed to write it

#

then taking pointers from "thin air"

thorn bramble
#

definitely not like that

#

i dont know rust bro

#

but people do it differently

surreal path
#

bro ๐Ÿ’€

thorn bramble
#

without all this shit

surreal path
#

whatever man as long as the UB is reduced so it doesnt have weird ah bugs its fine

thorn bramble
#

you didnt reduce anything

#

you just asked rust to do borrow checking on raw pointers xd

surreal path
#

bro

#

whatever man

thorn bramble
#

yeah as i said yesterday

#

u did rewrite some parts to be more proper or whatever

#

few less parts to worry about i guess

hollow goblet
#

if you really want it to be 100% safe

surreal path
#

look i give up rust

hollow goblet
#

but you're doing kernel work, just assume it's gonna be fineโ„ข๏ธ

surreal path
#

like completely

#

im done

surreal path
#

use C

#

i just cant

hollow goblet
#

just don't get it optimized out

finite summit
#

finally, you have restored normal brain function

hollow goblet
#

and it's fine

hollow goblet
hollow goblet
#

rust my beloved

finite summit
#

boo

edgy pilot
#

learn

surreal path
#

its gonna take months

#

to learn c++

#

lmao

finite summit
surreal path
#

even if i already know C

hollow goblet
edgy pilot
finite summit
#

just do C

edgy pilot
#

yes im sure

finite summit
#

C is easier anyway, no vtables to worry about

hollow goblet
surreal path
finite summit
#

not all C++ features can be used from kernel mode easily

#

don't

hollow goblet
#

i don't get why so much hate on rust here

finite summit
#

you'll end up learning C++ then ending up being confused as to why some stuff don't work

#

or write C-like C++ code and get flamed

hollow goblet
edgy pilot
hollow goblet
#

i am most comfortable with rust

finite summit
#

still doesn't give you some runtime support

#

(a lot of)

#

also global constructors are wacky

hollow goblet
#

does C++ have an equivalent of panic=abort

finite summit
#

and to be avoided

edgy pilot
finite summit
#

in kernel mode

hollow goblet
edgy pilot
#

you can port llvm or gcc libs, it's not hard

#

I have done it before with both

#

a few years ago

hollow goblet
#

anyhow