#OBOS (not vibecoded)

1 messages · Page 25 of 1

white mulch
#

why wouldn't it speed it up lol

flint idol
#

although it speeds up by so much

white mulch
#

without optimizations there are a lot of redundant memory accesses for an example

flint idol
#

unlike any other time I've used optimizations

weak kestrel
#

and performance difference becomes more apparent

flint idol
#

well LTO is being a pain\

#

it's removing my ubsan symbols

#

I'll move ubsan/kasan/stack checker to a separate lib

weak kestrel
flint idol
#

undefined reference

flint idol
weak kestrel
#

weird

#

works fine for me

#

ubsan is for debug mode anyway
and you don't use lto with debug mode cool_meme

flint idol
#

and if there is a kernel module in debug mode

#

being used on a release kernel

#

it doesn't find ubsan

#

so it starts crying

flint idol
#

the linker is rearted

#

ok

#

I define the symbol OBOS_InitrdBinary

#

export it

#

reference it in 5 different places

#

WHERE THE FUCK

#

is my symbol

#

looks like it needed to be volatile

#

fuck binutils

#

fuck LTO

#
OBOS_EXPORT const void *hashmap_get(struct hashmap *map, const void *item);```
#

makes the visibility of

#

hashmap_get

#

'default'

#
[ DEBUG ] Could not resolve symbol 'hashmap_get' (symbol is hidden) referenced within a driver.```
white mulch
#

what if you add -Wl,--export-dynamic?

flint idol
#

that fixes that

#

now I just need to fix the nullptr access in the COM driver

#

bruh

#

inlining is ruining me stack traces

white mulch
#

implement dwarf cfi interpreter meme

flint idol
#

ok wtf is up with LTO

#

how is it making

#

Symbol->name become nullptr

#

JUST HOW

#

yeah goodbye LTO

flint idol
#

time to stop rotting away behind my phone scrolling

#

and instead

#

rot away behind my computer

#

writing the new PCI interface

#

and actually

#

I will be using early table-access

#

in uacpi

#

don't ask how cpu_local.h somehow ends up including pci.h

real pecan
#

Wtf

flint idol
#

well it includes cpu_local_arch.h

#

which includes arch/x86_64/gdbstub/connection.h

#

which includes driver_interface/header.h

flint idol
flint idol
#

for the struct pci_hid

#

I'm also going to be refactoring the driver interface init

flint idol
#

fun fact: the obos master branch still doesn't have dirty/standby lists

#

I need to merge userspace-work soon....

#

while I am on the topic of the vmm

#

I think I want to merge struct working_set_node and struct page

#

someway

#

because there might be a bug related to that

#

(I haven't observed the bug yet, since it has to do with shared pages between two vmm contexts)

#

basically, the amount of working sets a page is in is stored in the working set node

#

but each time a page is put into a working-set

#

a new one is made

#

potentially causing fnuy stuff to happen
such as:

  • a page being removed from a working-set (therefore being paged out), while it's still in another process' working-set
#

the way to solve that is really simple

#

put a working_set_node in the struct page

#

like a pointer to it

#

I just realized that locking virtual pages really just means "locking it into the working-set"

#

so pseudocode for that would be:

lock(&pages->ctx)
prefault(pages)
foreach page in pages:
  working_set_node n = insert_page_into_workingset(&pages->ctx->ws, page)
  n->locked = true
unlock(&pages->ctx)```
#

and the opposite would be the same, but without the prefaulting, and instead of inserting the page into the working-set, it gets the page's ws entry, then sets n->locked = false

#

I wonder how prefault will work

#

I could just call Mm_HandlePageFault for each page in there

#

Mm_HandlePageFault(ctx, page->virt, page->present ? PF_EC_PRESENT : 0);

flint idol
#

in like a week

#

I'm off on vacation

#

so no osdev there

#

I'm sure yall will miss me

#

I'll bring my laptop :^)

real pecan
#

u cant osdev from laptop?

flint idol
#

huh

#

what prevents me from osdeving on a laptop?

real pecan
#

it was a legit question

#

since u said no osdev

flint idol
#

well idk if I'll be bringing my laptop

#

if I can

#

(I don't think my family would be fine with me bringing my laptop on a 2-week vacation)

#

((just to do the exact thing I do everyday))

real pecan
#

two weeks is enough to get extremely bored at a vacation

flint idol
#

last couple days are doing the pilgrimage in makkah, saudi arabia

#

anyway

#

we'll see

flint idol
#

can someone pin this?

white mulch
flint idol
#

thanks

thick jolt
flint idol
#

lmao

dire belfry
#
♫ 137 little bugs in the code ♫
♫ 137 little bugs ♫
♫ take one down, patch it around ♫
♫ 93,428,471,930,587,234,682,318,095,723,456,932,108,653,294,867,394,583,495,715,902,847,523,905,
rapid pulsar
#

♫ 20,730,897,752,653,674,714,720,723,427,459,000,889,249,915,529,600,981,530,433,365,335,188,589,206,775,527,139,229,601,995,115,836,043,535,786,629,580,792,144,773,078,426,776,834,268,298,332,187,236,818,042,380,226,849,443,884,860,369,688,406,406,660,118,018,751,041,554,543,095,806,670,784,324,017,067,690,408,791,078,125,463,951,378,030,499,174,512,211,021,762,053,899,146,321,811,754,326,676,200,848,317,668,615,746,032,791,477,810,189,370,765,796,872,015,454,208,726,535,891,065,392,365,497,780,680,934,294,765,890,614,462,433,230,434,642,019,850,210,194,574,941,837,149,904,506,668,092,623,531,566,731,463,976,957,855,738,022,148,581,771,099,684,223,664,263,637,368,004,862,059,648,627,935,705,330,725,186,314,285,961,032,283,586,277,966,145,966,280,929,918,887,266,909,890,820,024,385,375,444,923,126,652,775,589,102,263,540,978,186,901,034,212,346,494,403,140,899,551,856,996,521,257,241,285,133,877,814,522,994,967,358,822,224,685,926,377,660,467,871,022,924,275,654,082,181,950,373,765,807,211,473,562,917,453,950,351,601 little bugs in the code ♫

flint idol
#

they're only little bugs

#

WIP

#

my bf interpreter is cursed

dire belfry
flint idol
#

better

#

although it isn't perfect

#

the interpreter

#

it kinda works

#

and it also can run a bf interpreter written in bf in it

lean glen
#

Why the fuck are you making a brainfuck interpreter

thick jolt
#

😎

rapid pulsar
flint idol
#

didn't feel like osdev

rapid pulsar
#

oh that's a lot faster than the one I linked

flint idol
#

I ran the wrong command

rapid pulsar
#
$ time echo '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.!' | ./kuroko bf.krk "$(cat bf.bf)"
Hello World!

real    0m0.362s
user    0m0.354s
sys    0m0.011s

lol

thick jolt
flint idol
#

back to osdev lesgo

torpid wigeon
#

lesgo

flint idol
#

been a couple months

#

still barely any userspace

vale nymph
#

just say soon™️ and then never do it

thick jolt
#

im unsure

#

how to impl this

flint idol
thick jolt
#

i still dont understand what im looking at

#

like at all

flint idol
#

u have functions

#

called __asan_load1

#

to 8

#

but only powers of two

thick jolt
#

to 8?

#

what

flint idol
#

__asan_load1
then that last number is all the powers of two up to and including 8

thick jolt
#

what

flint idol
#

bru

white mulch
#

__asan_load1, __asan_load2, __asan_load4, __asan_load8

thick jolt
#

oh

#

ok

flint idol
#

and then the same thing, but with the word store instead of load

thick jolt
#

ok

flint idol
#

then in that, you call some other function, which I call asan_verify

#

which verifies the memory isn't poisoned

#

and I explain what "poison" is in the messages here

#

and in the case that the memory is poisoned

#

you panic

#

you can poison just about anything

#

freed memory, out-of-bounds memory

#

non zeroed memory

thick jolt
#

i think im just gonna take a break from osdev for a week i dont feel motivated anymore. i feel like every piece of code i write is utter shit so i would probs also screw up the kasan impl as well

#

to be honest

flint idol
#

ok

#

cya

thick jolt
#

bro is saying ok cya

#

look fine ill impl kasan

#

but ur gonna see how shit

#

it will be

#

look

#

ill probs

#

triple fault or some shit

flint idol
#

you probably will if you forget to mark the asan helper functions as __attribute__((no_sanitize("address")))

#

you'd stack overflow if you forget to do that

torpid wigeon
#

rule 1 of osdev

#

don't expect to write linux 2, but don't let your code reflect that

flint idol
#
OSDev.wiki

Rule of osdev #1469: never assume memory is zero'd - moondeck
Rule of osdev #1468: never assume indices are sequential - mniip
Rule of osdev #1470: don't divide when you can shift - glauxosdever
Rule of osdev #fbf89521-21f1-4a52-b5cb-a0bf0f761bb4: probably avoid collisions with globally unique identifiers - sortie
Rule of osdev #1985: Never try ...

white mulch
#

I tried asan once but idk how do you actually make it work because you have to have initialized enough stuff to make it work in the first place

flint idol
#

wut

torpid wigeon
#

just don't write bad code

thick jolt
#

okay i did this now what

#

who is even

white mulch
# flint idol wut

well like you have to have an allocator for an example to be able to use asan so you'd have to mark all functions needed to bring that up with no sanitize address

thick jolt
#

calling these functions

#

idfk

flint idol
#

the compiler

#

generates them for each memory access

weak kestrel
#

don't you need a prekernel

#

with clang at least

flint idol
#

huh

thick jolt
#

okay and what do i need to do in __asan_load_n?

white mulch
flint idol
#

it calls asan_verify

#

or well

#

it calls something

#

that verifies the memory is unpoisoned

thick jolt
#

what am i supposed to put posion values in the memory or smthin

#

what

#

im lost now

thick jolt
flint idol
#

no

thick jolt
#

where

flint idol
#

you have a region after your slab

#

or in your slab

#

which you memset to the poison

thick jolt
#

this wont verify my vmm region tho

flint idol
#

y

thick jolt
#

because

weak kestrel
flint idol
thick jolt
#

thats virtually memory mapped memory, and like

#

idfk

#

im lost

weak kestrel
thick jolt
flint idol
#

if you wanted to poison globals

thick jolt
#

but then

#

uacpi will get garbage

#

data

weak kestrel
flint idol
#

no it won't?????

thick jolt
#

why

white mulch
# weak kestrel with clang at least

you can make clang emit out of line function calls everywhere so then you could probably skip the asan checks before you have initialized everything

flint idol
thick jolt
#

because uacpi expects

#

zero'd memory

flint idol
#

no it doesn't

thick jolt
#

in one of its

#

calloc

#

functions

#

and if i posion the memory

flint idol
#

IT'S AFTER THE ALLOCATED REGION

#

oops caps lock\

thick jolt
#

so like

[page]posion value

#

like

#

after the page

flint idol
#

it's like

#

no

#

it's after an allocated piece of memory

#

what I do is in my allocator

#

if kasan is enabled

#

I add like 256 bytes I think

#

to the size

thick jolt
#

what

flint idol
#

before allocating anything

#

and then after allocation

#

I do memset(addr+size-256, poison, 256);

thick jolt
#

what why 256

flint idol
#

nice number

thick jolt
#

what if that goes over that page

flint idol
#

then it corrupts memory over that page

#

:)

thick jolt
#

wow

#

so u cant use 256

#

cause like

#

yea

flint idol
#

no

thick jolt
#

because what if

#

ur on the last allocated region in the slab

#

ur just gonna

#

overwrite another page

#

fun

flint idol
#

then just

thick jolt
#

memory corruption

flint idol
#

what

#

this is what I meant

thick jolt
#

oh

thick jolt
#

so you add 256 bytes to the slab

#

size

flint idol
#

no

thick jolt
#

oh

flint idol
#

that's the malloc function

thick jolt
#

what

flint idol
#

it adds 256 to the size parameter

thick jolt
#

now ur just making me more confused

#

what

#

what size function

flint idol
#

use that thing you have in your head

#

wassit called

#

brain

#

and think of what I could've meant

#

when I said "size function"

thick jolt
#

size parameter

#

so like

#

in this calculation

#

u remove -256 bytes

#

giving the page 256 more bytes

flint idol
#

no I don't

thick jolt
#

oh

flint idol
#

for one I don't use a slab allocator

thick jolt
#

oh but for a slab allocator would u do this

#

yes or no

flint idol
#

probs not

thick jolt
#

oh

flint idol
#

what I mean is

#

you would add 256 to amount

#

at the beginning of the function

#

(if kasan is enabled)

thick jolt
#

oh

#

so if ksan

#

malloc(amount + 256)

#

?

flint idol
#

yea

thick jolt
#

ok

#

how do i check if ksan is enabled

flint idol
#

ifdef __SANITIZE_ADDRESS__

thick jolt
#

ok

#

like this?

flint idol
#

yeah

#

but

#

after you allocate the memory

#

memset(him + amount, poison, 256)

thick jolt
#

ok can my posion be whatever i want?

flint idol
#

sure

#

as long as it's not:

thick jolt
#

ok

flint idol
#

zero

#

and it must be consistent with what your asan impl. expects

thick jolt
#

whats next

#

and yes i removed the duplicate ifdef

flint idol
#

go to asan_verify

weak kestrel
thick jolt
#

im confused looking at this

thick jolt
weak kestrel
#

OBOS_AsanPoisonValues

flint idol
thick jolt
#

ok

thick jolt
flint idol
#

size is the size of the access

thick jolt
#

and what is this function

flint idol
#

it checks if it's accessing a poisoned region

#

and if so panics

thick jolt
#

do i have to impl it

flint idol
#

yes?

thick jolt
#

ok

flint idol
#

you can rename it

#

read the comments of my implementation

#

but not the actual code

thick jolt
#

yea i dont know what this bitmask is checking for

#

shhifting at by 47

#

and inverting it

flint idol
#

checking if the memory is canonical

thick jolt
#

and oring it with

#

ok ill just copy that if statement

#

:)

#

what is memcmp_b whats the difference between memcmp and memcmp_b

flint idol
#

memcmp_b checks the memory against an integer

#

as opposed to another memory block

thick jolt
#

is there a impl of this function i can yoink

flint idol
#

make it urself

thick jolt
#

is memcmp_b doing#

#

if (address + size) == value:
return 1
else
return 0

#

?

flint idol
#

no????

thick jolt
#

oh

flint idol
#

it returns a bool for one

#

if the memory is equal

#

to val

#

return true

#

else return false

thick jolt
#

okay so bool instead of number

#

okay

#

but the if statement is correct yers?

flint idol
#

not at all

thick jolt
#

oh

#

fun when im always stupid and never understand things

flint idol
#

I wonder who's been cloning obos thinkong

thick jolt
#

me

#

i cloned it

#

like a bit

#

ago

flint idol
#

november 2nd?

thick jolt
#

yea

flint idol
#

someone cloned it

thick jolt
flint idol
#

take memcmp

#

instead of if (blk1[i] == blk2[i]
do if (blk[i] == val)

thick jolt
#

and what is i

#

size?

flint idol
#

look at memcmp

thick jolt
#

yea im looking at memcmp

#

what about it

#

oh

#

so u loop over

#

if (p1[i] == val

#

do whatever

#

okay

flint idol
#

incorrect

thick jolt
#

oh

flint idol
#

think about that if statement

#

it should be if p1[i] != val

#

return false

thick jolt
#

okay

#

solved

#

tf is short circuit#

#

what is this

#

ltt

#

linus tech tips

flint idol
#

that's why I said read the comments

#

and not the code for that function

thick jolt
#

yea im reading

#

your checking if the ptr

#

16 bytes before is posioned

#

if one of the sides is posioned

#

yk

weak kestrel
#

who wants to implement asan in my kernel halfmemeright

thick jolt
#

@flint idol why at + size

#

oh wait

#

nvm

#

sorry

flint idol
#

it's all good

thick jolt
#

is this correct oberrow

#

@flint idol ?

#

actually wait no is this correct

flint idol
thick jolt
flint idol
#

btw

#

this is wrong

thick jolt
#

oh

#

fun

flint idol
#

you index into nyaux_poison

#

when you check if it's poisoned

thick jolt
#

mhm

flint idol
#

but you don't index into nyaux_poison when you poison the memory

#

you had used some other value

#

which I stated before

thick jolt
#

what

#

????

#

i dont understand

#

what does it mean when u say "when checking if its posioned but not when posioned you had used some other value"

#

like

#

i dont understand what you meant

thick jolt
#

but i remembered

#

to do this

#

so

#

its right

#

😎

flint idol
#

0x1a is for non-zeroed memory

thick jolt
#

okay

#

okay i did this

#

now what

flint idol
thick jolt
#

but i didnt impl __asan_load_n

#

or whatever

#

what am i supposed to do

flint idol
flint idol
thick jolt
flint idol
#

and?

thick jolt
#

why do i need to define __asan_load1

flint idol
#

because

thick jolt
#

etc

flint idol
#

that's what the compiler expects

thick jolt
#

okay

#

ill just

#

manually make the functions

#

wait

#

what is OBOS_EXPORT

flint idol
#

dw about it

thick jolt
#

ok

#

functions done now what

#

am i done

flint idol
#

add -fsanitize=kernel-address

#

to your CC_FLAGS

#

and also asan_store doesn't take a size paramter

#

and also, asan_verify needs kasan disabled

thick jolt
thick jolt
flint idol
#

ok

#

maybe to the linker too

thick jolt
#

now it wants

flint idol
#

idk

thick jolt
#

no abourt

#

abort

flint idol
#

just add _noabort

#

to the end

#

of all those functions

thick jolt
#

okay

flint idol
#

__asan_load1 becomes __asan_load1_noabort

#

etc

#

btw, no underscore

#

between the number

#

and load/store

#

so instead of __asan_load_1

#

you do __asan_load1

thick jolt
#

now it wants load16????

flint idol
thick jolt
#

now its talking about load_n?

flint idol
#

instead of __asan_load_n

#

do __asan_loadN_noabort

thick jolt
#

nvm i did that

#

compiles

flint idol
#

wooo

#

now does it run?

thick jolt
#

triple fault

#

called it

flint idol
#

make sure you

#

disable kasan on all kasan functions

thick jolt
#

16th line

thick jolt
#

cr2 is

#

ffff800006672ff8

#

then from 0xe

#

it 0xd's

#

then 0x8

#

then 0xd

flint idol
#

you know how I check if I cross a page boundary

thick jolt
#

yea

flint idol
#

do that

#

you're probably accessing far too memory

thick jolt
#

how do i check that

flint idol
#

math

thick jolt
#

#define OBOS_CROSSES_PAGE_BOUNDARY(base, size) (round_down_to_page(base) == round_down_to_page((uintptr_t)(base) + (size)))

#

mine

#

now

#

:)

torpid wigeon
#

rob him if his code

flint idol
#

I use MIT license for a reason

flint idol
# thick jolt #define OBOS_CROSSES_PAGE_BOUNDARY(base, size) (round_down_to_page(base) == roun...

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

thick jolt
#

okay and what do i do if i did cross a page boundary

flint idol
#

go to the next comparison

thick jolt
#

and what if thats false or true

#

what happens

#

?

#

???

rapid pulsar
#

?????????

thick jolt
#

like

#

if i cross a page boundary and either check passes

#

do i panic saying a page boundary was crossed or what

#

is that what i do?

#

i dont know if that is correct so im asking to verify if thats correct or not

thick jolt
#

what do i do then

flint idol
#

go to the next comparison

thick jolt
#

i said either

#

so both page boundary checks

flint idol
#

return;

thick jolt
#

just return?

#

isnt it a bad thing if u cross a page boundary

#

anyways i did the checks

#

still the same triple fault

#

still at memcmp_b

torpid wigeon
#

who the hell uses 2 space indents unironically

thick jolt
#

im having vscode format it

#

not my fault

#

but anyways i dont know whats going on

#

im going sleep

#

tmrw we figure this out

#

changes are on git

torpid wigeon
#

get a .clang-format

thick jolt
#

no thanks

#

goodnight

flint idol
#
static obos_status writeback_bar(pci_device* device, pci_bar* bar)
{
    obos_status status = OBOS_STATUS_SUCCESS;
    switch (bar->type) {
        case PCI_BAR32:
            status = DrvS_WritePCIRegister(device->location, 0x10+bar->idx*4, 0x4, bar->phys & 0xffffffff);
            break;
        case PCI_BAR64:
            status = DrvS_WritePCIRegister(device->location, 0x10+bar->idx*4, 0x4, bar->phys & 0xffffffff);
            status = DrvS_WritePCIRegister(device->location, 0x10+bar->idx*4+4, 0x4, bar->phys >> 32);
            break;
        case PCI_BARIO:
            status = DrvS_WritePCIRegister(device->location, 0x10+bar->idx*4, 4, bar->phys & 0xffffffff);
            break;
        default:
            return OBOS_STATUS_INVALID_ARGUMENT;
    }
    return status;
}```
thick jolt
#

niceeeeee

#

oh wait shit

#

i should be asleep

#

😭

#

my dad gonna kill me

flint idol
#

go to sleep.

thick jolt
#

okiiii

#

goodnight for real this time

flint idol
#

gn\

flint idol
#

other than the fact that I need to essentially rewrite the pci part of pnp

#

and the ahci driver doesn't compile

#

a large part of the new pci interface is implemented

#

well not large part

#

but a part

#

writing pci resources

#

and capabilities

#

now of course I don't initialize any buses yet

#

so it's useless

#

now my head hurts so I'm going to sleep early

#

but tomorrow I will probably continue on this

flint idol
#

when I'm done my new pci interface, the ahci driver will have support for multiple ahci controllers

#

hopefully

#

how would I name the drives though? sd1a

#

for ahci controller 1, drive a

#

sd2a
for ahci controller 2, drive a

short mortar
flint idol
#

No

white mulch
#

btw uHDA now has the locking stuff, fixed path configuration (as the old one was broken on real hw) and some doc on the concepts if you want to try it with your kernel (it would be good to have some other kernels to see if the kernel api is good enough though it may change with the possible unified api and also would be good to see if it works in general on different real hardware cards)

real pecan
#

also oberrow has some old hw so would be interesting to test

white mulch
#

one thing I am slightly worried about is cards that have broken stream position reporting meme though I don't think its that hard to fix as there is an other mechanism to get it too so you'd just switch to that if the position didn't change at all between irqs

flint idol
#

I can't wait to use my new panic screen

#

when I merge userspace-work with master

sharp pike
#

i5-4590T

flint idol
#

My computer is from 2013

sharp pike
#

which one?

torpid wigeon
flint idol
torpid wigeon
#

just say not present idk

flint idol
#

that wastes two bytes of memory

#

so no

torpid wigeon
#

printing out your long git hash wastes memory too

flint idol
torpid wigeon
#

(not mentioning the ascii art)

flint idol
#

ascii art just looks good

#

so I obviously need that

vale nymph
#

Oopsie! The cpu did a fucky wucky!!!!

flint idol
torpid wigeon
#

i'm writing a qr code generator for the drm panic handler

flint idol
#

(I may or may not have thought about doing that once)

vale nymph
torpid wigeon
#

i'll make it like uACPI

#

independent from everything else, just plug and play

flint idol
#

does it just not crash

vale nymph
#

Cpu1 watched cpu0 crash and decided to retire

flint idol
#

ah

#

sometimes I'm scared of what auto-merge can do

#

like when git merge decides it thinks it knows how to fix a merge conflict

#

uh oh
why is the current obos branch so much slower than master

vale nymph
#

Did you forget -O0

flint idol
#

they're both on -O2

#

I have a feeling it's my slowfat driver

torpid wigeon
#

fat + slow

flint idol
#

because like

#

my fat driver is slow af

#

I'm just going to blame it on uacpi

lean glen
#

tho

flint idol
#

true

#

I did also make the log level higher on userspace-work

#

and the speed seems matched

#

and it uses 9M less memory

flint idol
#

since I'm going to the UAE I might be able to test obos on some relatives devices (with consent first, of course)

#

cc @real pecan

#

apparently obos doesn't like CPUs reporting as AuthenticAMD

vale nymph
#

Have you never tested with tcg? IIRC tcg returns AuthenticAMD

flint idol
#

but never with -cpu qemu64

#

or rather, no -cpu argument

#

it literally just triple faults on initializing the page tables

#

maybe I'm missing some sorta check

#

huh?

#

it triple faults in stb sprintf

#

__builtin_popcount crashes

#

probably due to #UD

#

yup

flint idol
#

and it works

#

since __builtin_popcount calls a libgcc function

#

I just added a config option to obos

#

to configure the value passed to march

#

OBOS_X86-64_VERSION

#

v1 is x86-64
v2 is x86-64-v2
v3 is x86_64-v2
v4 is x86_64-v4

torpid wigeon
#

is it feasible to have opcode emulation for ud exceptions

#

or is that unusable

flint idol
#

sounds delusional

#

might as well do it

flint idol
#

I'm gonna see if obos works on qemu on my phone

#

I got termius installed

#

*termux

#

And will be cloning obos

#

Oh wait

#

I have no obos iso

#

Oh cool termux uses apt

#

Cannot link executable cmake

#

Libcrypto not found

#

And apt file

#

Doesn't work

haughty abyss
#

loool

inland radish
flint idol
inland radish
#

ah, I must have been testing on qemu-system-i386 only

flint idol
#

Ok

thick jolt
#

obos is now my os muhahaha

#

ill make a commit today obos will be ported to mlibc! yes muhahahahaha and it will run bash !!!

#

muheheheh

flint idol
#

Just got me hands on an esp32

#

As soon as I come back and am done writing the new pci interface

#

I will port obos

#

To xtensa

#

Or really after userspace-work is merged

short mortar
#

Some ESP32s have RISC-V cores...

torpid wigeon
#

like this one :P

flint idol
torpid wigeon
#

obos riscv port based

short mortar
#

I have some ESP32-C3s (I think) spread around home doing IoT stuff

#

I'm wondering how much can be implemented with their MMUs...

flint idol
#

Just realized obos uses waaaay too much memory

#

At least for esp32

#

This model specifically seems to have 4.5M total

#

And obos uses 10M memory

#

*virtual memory

#

And a lot more physical

#

memory

#

Although a couple MB of physical memory is framebuffer

#

Related

#

And my physical memory count doesn't even include any VMM structures (including PTs)

#

I'll just make it start swapping memory aggressively

thick jolt
real pecan
thick jolt
#

😱

flint idol
thick jolt
#

and ur gonna

#

nyaobos

#

no

#

nyabos

real pecan
flint idol
#

I wonder if esp32 has acpi

torpid wigeon
#

no

short mortar
#

It also kinda doesn't have proper virtual memory

flint idol
short mortar
#

It's a microcontroller

#

They don't have niceties of big computers

flint idol
#

Yeah but what makes it non proper

short mortar
#

I don't remember how it works, but it is very limited

flint idol
#

I'll just figure that out on the wag

#

*way

short mortar
#

Like you can only have 32 or so memory regions and it's meant for memory protection, not to have virtual memory

#

And only select ESP32s have user mode

flint idol
#

Challenge accepted

#

And user mode isn't really needed

short mortar
#

Which ESP32 did you get?

flint idol
#

On the chip

short mortar
#

I think it's ESP32S

#

Which has Xtensa cores

flint idol
#

This is it closer up

dire belfry
flint idol
#

Bruh

short mortar
#

Division Error

flint idol
torpid wigeon
#

(tried to execute sse)

flint idol
#

General protection fault (loaded 0x58 to cs when gdtr.limit was 0x38)

#

Because int 0x3 is for SIGTRAP

torpid wigeon
#

because it's privileged 🤓

flint idol
#

Used in debuggers

#

And other interrupts shouldn't be called manually otherwise it can cause cpu funniness

#

Btw that is only for interrupts through the int instruction

#

For example the page fault exception handler expects an error code

#

If it's not there it probably crashes

#

(It is not pushed when you do the int instruction to invoke int 0x14)

#

Type attribute in the idt entry

#

idtEntry.typeAttributes = DEFAULT_TYPE_ATTRIBUTE | (canUsermodeCall ? TYPE_ATTRIBUTE_USER_MODE : 0);

#

Debug trap

torpid wigeon
#

@flint idol ```c
typedef struct ATTR(packed)
{
u16 base_0_15;
u16 selector;
#if CONFIG_bits >= 64
Bits ist:2;
Bits reserved:6;
#else
bits reserved:8;
#endif
u8 type;
u16 base_16_31;
#if CONFIG_bits >= 64
u32 base_32_63;
u32 reserved2;
#endif
} IdtDesc;

which bit would that be here
torpid wigeon
#

yea

flint idol
#

That's it

torpid wigeon
#

which bit

flint idol
#

The entire thing

#

Bte

#

*btw

#

Don't use bitfields here

torpid wigeon
#

why

flint idol
#

Because that's a general rule for structs like th8s

#

*this

#

Compiler can do wacky stuff to it

torpid wigeon
#

how

flint idol
#

Search bitfield using discord search thing

#

Has been explained too many times

white mulch
#

well for idt it doesn't really matter unless you enable something that generates that irq in the middle when you are modifying the entry but in general its a good idea to avoid yeah

flint idol
torpid wigeon
#

lol i might have made a huge meme then :)))

flint idol
#

Gl

torpid wigeon
#

the code is so clean though 😢

flint idol
#

Sorry

white mulch
#

you can make pretty clean abstraction that's like bitfields but with structs (at least in c++, idk about c but I can't think it would be too bad there either)

torpid wigeon
#

yea example pls

flint idol
#

Bitfields are fine if you use them for internal structs

#

Or smth

#

That aren't from any sorta spec

torpid wigeon
#

why isn't that an enum

white mulch
#
namespace op_regs {
   constexpr BitRegister<u32> USBCMD {0x0};
}

namespace usbcmd {
    constexpr BitField<u32, bool> RS {0, 1};
    constexpr BitField<u32, bool> HCRST {1, 1};
}

void test() {
    IoSpace space {0xsomeaddressofxhci};

    auto cmd = op_space.load(op_regs::USBCMD);
    cmd &= ~usbcmd::RS;
    op_space.store(op_regs::USBCMD, cmd);
    cmd |= usbcmd::HCRST(true);
    op_space.store(op_regs::USBCMD, cmd);
}
``` this is basically what I do in my kernel and I borrowed the idea from managarm, basically the BitRegister contains the offset of the register within the space and then the space's load method just does a load from that offset returning a BitValue you can get those individual bitfields out of (or set them)
flint idol
torpid wigeon
#

but why not do this

flint idol
torpid wigeon
#

what is it used for

flint idol
#

The virtual alloc thing has its own flags

torpid wigeon
#

so you would use it like prot.present = true; prot.user = true;

flint idol
#

Yes

torpid wigeon
#

instead of prot = present | user;

flint idol
torpid wigeon
#

meh, i won't criticize that, imo the latter is cleaner

flint idol
#

Btw my vmm is made to be platform independent

torpid wigeon
#

so is mine

#

:3

flint idol
#

So I don't write anything like it's about to go in a pte

torpid wigeon
#

i don't either

flint idol
#

Lies

torpid wigeon
#

see line 305

flint idol
#

_x86

#

lvl=4

#

Seems pretty x86 to me

#

Unless vm map is different for each arch

torpid wigeon
#

it is

#

that's just the impl

flint idol
#

So it's not cross platform?

torpid wigeon
#

wdym

flint idol
#

If it's different for each arch it's not really cross platform

torpid wigeon
#

the header/usage is, the implementation is obviously architecture dependent

flint idol
#

Sorry what the hell is acquire_force

torpid wigeon
#

how the hell would that work otherwise

flint idol
torpid wigeon
#

i do care

flint idol
torpid wigeon
#

spin_acquire can fail

flint idol
real pecan
flint idol
#

And the fallible one is try_acquire

torpid wigeon
#

ig spin_try_acquire is a better name

#

yea

white mulch
flint idol
torpid wigeon
#

😔

white mulch
#

I don't think they are repeating that kind of code for each arch? it was just the code to map one page

#

and that obviously needs to be arch dependent

flint idol
#

It only has some helpers for mapping a page

#

And query page info

torpid wigeon
#

this is my map interface, nothing arch dependent here

flint idol
torpid wigeon
#

yea but how can that possibly be arch independent

white mulch
#

vm_map maps one page tho so the impl has to be arch dependent

#

though the desc is kinda undescriptive lol

flint idol
torpid wigeon
white mulch
#

maybe you should rename it to something like vm_map_page

torpid wigeon
#

but what else would i be mapping

flint idol
white mulch
#

or a bigger region

torpid wigeon
#

hm

#

i don't have that at all lol

flint idol
#

Skill issue

torpid wigeon
#

yep

#

btw if you mean the mmap syscall impl that is actually arch independent

#

probably the worst code you'll see today

#

but it does its thing

real pecan
#

doesnt this leak half of these mappings

#

or like depending on where it OOMs

torpid wigeon
#

yes it does

#

it also doesn't unmap the addresses

real pecan
#

isnt that kinda

#

not good

flint idol
#

lol

torpid wigeon
#

yes

#

that's what i was talking about in #polls

#

this shit is completely broken because i didn't know wtf i was doing

real pecan
#

lol

torpid wigeon
#

like

#

check out my genius isatty impl

flint idol
real pecan
#

if it works it works

torpid wigeon
flint idol
vale nymph
torpid wigeon
#

who needs pipes

#

shared memory + doorbell meme

real pecan
vale nymph
lean glen
#

always return true

torpid wigeon
#
#define } __builtin_trap(); }
short mortar
flint idol
#

Microkernel skill issue

short mortar
#

I'm thinking of reworking it and moving it to the kernel (instead of relying on IPC)

#

(also because of the deadlock issues related to scheduler priorities)

flint idol
#

Microkernel skill issue

shy forge
#

Imagine ever reporting no memory

#

Post made by the dynamic paging gang

short mortar
#

post made by managram assertos

flint idol
real pecan
flint idol
#

I have ahci

#

Nvme is planned™️

#

Pci interface rewrite

#

Of course I'm on vacation so I'm not working on it now

#

Lmao

#

I'm gonna support PCIe

#

Currently the pci interface is very shit™️

short mortar
#

What's the difference?

#

Besides ECAM

flint idol
#

Except MSI is guaranteed to be supported

#

On the software side ofc

short mortar
#

I don't support MSI (yet)

flint idol
#

Hw side there is more difference s

#

A way to get interrupts

short mortar
#

Message Signaled Interrupts

#

Basically a "better" way to do them

flint idol
#

I support MSI and MSI-X

short mortar
#

Except that it doesn't work on RISC-V

flint idol
#

And legacy irqs

#

Through int pin

#

It's paid

#

Just use osdev wiki, should be good enough

short mortar
#

I don't have it

flint idol
#

I do have a spec that explains the relationship between pci and acpi

short mortar
#

I found parts of it on a random website with hw (homework) solutions stuff

#

And seen enough of it to implement ACPI

flint idol
#

I have the osdev wiki page

short mortar
#

Wdym

flint idol
#

Did you buy it or sum?

white mulch
#

you can also find them literally everywhere lol, even on intel's site

white mulch
#

just google "pci specification pdf" for yourself, ofc its likely not intended to be public and its some old spec (iirc like 2.0)

flint idol
#

this cat says hi

short mortar
white mulch
short mortar
#

PCI Firmware*

white mulch
short mortar
#

Huh

real pecan
#

there was a gh repo where someone leaked all of the most recent pcie and pci specs

#

probably down now tho

white mulch
short mortar
#

I've just found 2021 verison

white mulch
# white mulch

though its not terribly useful imo, the acpi spec already contains most of the stuff iirc

short mortar
#

It said "refer to PCI spec"

#

I think

thick jolt
white mulch
thick jolt
white mulch
#

2k for a little pdf

weak kestrel
#

I think drafts are free

flint idol
#

Hi guys

#

Kbye

weak kestrel
#

kthxbye

vale nymph
flint idol
#

Wassup

#

Kbyenow

weak kestrel
flint idol
#

someone forked obos

#

Have no idea who

#

Well I know the github account

#

Yes yes definitely

#

100%

#

Is ur os not on github?

#

Then why isn't it on that github account

#

That's the account that forked obos

#

Oh yeah it is

#

I saw yeah

#

Btw master is missing many features from userspace-work

limber wave
#

wait i did

#

sorry

flint idol
#

Np

#

It doesn't really mean anything

limber wave
#

wait

#

actualy

#

how do i try it out

#

without making it my default

flint idol
#

clone userspace-work

#

And build instructions are in readme

limber wave
#

ah alr imma download it