#OBOS (not vibecoded)

1 messages · Page 40 of 1

flint idol
#

it's making up trb address out of thin air

#

what the actual fuck

#

is it an iommu problem? is it a kernel krill issue? ahhhh

flint idol
#

500k download speed for managarm servers 🥀

#

im tryna see if managarm's xhci driver will work here

#

ok the speeds boosted

flint idol
#

well managarm works

#

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

i fucking hate reading C++ code

#

"ah yes let me have code implcitly call other code and make it hard to track what variables are defined where because FUCK YOU"

uncut narwhal
flint idol
#

lmao

#

reading c++, linux, or bsd source code drives me insane

#

bsd source being the least out of the three

lean glen
#

BSD source code is amazing

#

linux is much more unreadable imo

flint idol
#

I wrote like all of the x8664 thing in 2024

#

and had barely any idea how anything worked

#

so like now nothing works on a lot of real hw

#

because bah dumb reasons

knotty totem
flint idol
#

least unreadable

knotty totem
#

ah

honest citrus
#

no clue how the upstream maintainers do it without wanting to rip their hair out

flint idol
#

man I fuckin hate this city's transit

#

buses are always late

#

but the ONE day I am late, it is early

#

and dont forget the next bus is in 20 minutes

#

@dense vigil can u get the bus to hurry up pls

dense vigil
#

this should help

flint idol
#

ok thx

knotty totem
#

Girl what

#

Just no 😭

dense vigil
#

I didn’t think it was bad

knotty totem
#

I realize it's not technically nsfw but it's supposed to put the same image in your mind

dense vigil
#

That is not what comes to my mind right away but fair

#

I’m sorry

knotty totem
#

It's okay ❤️

#

I had my finger over that section of the gif (I'm on mobile) and legitimately thought it was just... that

dense vigil
flint idol
#

time to continue trying to fix xhci because damn me i guess

flint idol
#

why the fuck is the xhci controller putting the same trb on the event queue twice

#

ok better question is why is the xhci controller seeing the same trb twice

flint idol
#

im dumb

real pecan
#

lol

flint idol
#

i forgot to update the dequeue pointer when sending the address device for the 2nd time (after sending a command in between)

sterile sparrow
flint idol
#

xhci is cursed

#

does get descriptor request
device, nah take USB Transaction Error instead

#

is it possible that these usb2 ports are under control of ehci

flint idol
#

why do i have to get all the bad errors

dense vigil
#

Or managarm/BSD

flint idol
#

managarm works

#

perfectly fine

#

with passthrough enabled

#

tbh

#

i never got port reset to work on this hardware

#

when not doing passthrough

#

maybe that has something to do with something

flint idol
flint idol
#

today I am going to revise the entire xhci controller init sequence

flint idol
#

i fucking give up

#

git reset

#

(git stash)

dense vigil
flint idol
#

duahqjfufjwuaudgbf

#

my pc just rebooted randomly

flint idol
#

saw an orange light in the case

#

😭

#

cant go outside

#

too cold

#

cant fix bugs

blazing python
#

hard xhci reality

stark sigil
flint idol
#

same here in southern ontario

#

apparently in some places in ontario it's gonna reach -50

#

(not here thank god)

flint idol
#

yea

#

Dangerously cold air swept across parts of Ontario early Saturday morning, with wind chills nearing –40 degrees Celsius in northern areas.

#

yesterday my toe nearly froze off

#

i think

#

it still hurts

stark sigil
#

i had to shower in hot water after coming home from school

#

the weather is insane

#

i think i got a cold as well

flint idol
#

same

#

it's so cold the sun is out

stark sigil
#

its so cold the sun cant even be a deadly lazer anymore

flint idol
#

real

blazing python
flint idol
#

(how many of those ports work? don't ask me, i wouldnt know trl)

blazing python
flint idol
#

yes

blazing python
#

is this hard

flint idol
#

through hda

#

not if i use a portable audio driver some1 else made

blazing python
#

i want do audio stuff later for my kernel so

flint idol
#

still havent figured out how to fix choppiness 😔

#

#drivers message

blazing python
flint idol
#

my own™

#

im planning to eventually add downstream support for my audio server protocol to sdl and stuff

#

so shit that uses sdl for audio can work

blazing python
flint idol
#

im too lazy to port pulseaudio

#

and get an alsa implementation

flint idol
#

xhci isnt real omfg

#

sdfkjsdfksdo

#

there are 10 ports on the controller

#

on the root hub

#

ZERO RESET SUCCESSFULLY

#

FSDOKGJSDLKFMSDOKFDMSLFKSDMF

#

atp it has to be the ehci ctlr trolling me

flint idol
#

i tried disabling the ehci ctlrs before trying to init the xhci ctlrs

#

it did nothing

uncut narwhal
#

good luck with your usb hell

flint idol
#

This requirement means that Root Hub port may report a device is connected
(CCS and CSC = ‘1’) before the xHC is running (i.e. HCHalted (HCH) = ‘0’), and that
when software enables the xHC and HCHalted (HCH) transitions to ‘0’, PSCEG
shall be asserted for each port with a connected device, generating a respective
Port Status Change Event. In this case

#

what a fucking lie

#

rtfdg,l;fedmdksgl;gjmdsf

dense vigil
#

And he still has to goto school

flint idol
#

damn that's cold

dense vigil
#

This is America too iirc

flint idol
#

at least your friend isn't working on xhci

dense vigil
dense vigil
#

But like really fucking advanced shit I think

flint idol
dense vigil
flint idol
#

where like the entire country lives

#

i truthfully have no fucking idea what the problem is

#

i am literally about to give up

dense vigil
#

You know what I do in times like these?

#

I try random bullshit

#

Until it works

flint idol
#

what do you think ive been doing 😔

dense vigil
#

You gotta bull the shit even harder

weary hound
flint idol
weary hound
#
void switchUsbPortsToXhci(PciDevice *dev) {
    debugLogger() << "            Switching USB ports to XHCI!" << frg::endlog;
    auto io = dev->parentBus->io;

    auto usb3PortsAvail = io->readConfigWord(dev->parentBus, dev->slot, dev->function, 0xDC);
    io->writeConfigWord(dev->parentBus, dev->slot, dev->function, 0xD8, usb3PortsAvail);

    auto usb2PortsAvail = io->readConfigWord(dev->parentBus, dev->slot, dev->function, 0xD4);
    io->writeConfigWord(dev->parentBus, dev->slot, dev->function, 0xD0, usb2PortsAvail);
}
flint idol
#

let me try that

weary hound
#

on intel chipsets

#

with ehci

#

usb ports are muxed between xhci and ehci, and you can toggle it

flint idol
#

fak

#

it didnt work

#

😔

#
uint64_t usb3_ports_available = 0;
uint64_t usb2_ports_available = 0;
DrvS_ReadPCIRegister(dev->location, 0xdc, 4, &usb3_ports_available);
DrvS_WritePCIRegister(dev->location, 0xd8, 4, usb3_ports_available);

DrvS_ReadPCIRegister(dev->location, 0xd4, 4, &usb2_ports_available);
DrvS_WritePCIRegister(dev->location, 0xd0, 4, usb2_ports_available);
#

oh wait this needs to be done on an xhci controller

#

grepogijrd

#

it got further

#

kinda

#

some ports now report CCS

#

uh nvm

#

i dont have a dollar to my name

dense vigil
#

That’s fine

#

Just give your soul to this

flint idol
#

hm

dense vigil
flint idol
#

current connection status

dense vigil
#

That’s good I presume

flint idol
#

yes it means a shit is connected on the port

flint idol
torpid wigeon
flint idol
#

perhaps

weary hound
flint idol
#

no i did xhci controller passthrough

weary hound
#

ah

flint idol
#

now time to figure out why the driver hangs after port reset thinkong

flint idol
#

well it's a problem with either trb emplacing

#

or interrupt receiving

flint idol
#

could be both, even

flint idol
#

well all i know rn is that im not getting any goddamn irqs

flint idol
#

so now it decided it doesnt wanna work anymore

dense vigil
#

What if USB is actually implemented with quantum mechanics and the only way to be able to make a working driver is to be ordained by the gods and or to be in the proper super position at the time

flint idol
#

hm

#

that would check out

#

if only i had decided to commit in the past few days

dense vigil
#

You may need to do some head clips into a block to get your sub pixel correct

flint idol
#

then i would be able to diff between now and then

dense vigil
#

Like super Mario bros style

flint idol
#

so uh for some reason usb hotplugging stopped working everywhere

flint idol
flint idol
#

January 24th, 2026, at 1940: xhci has progressed a bit further, I am still going crazy from this

weary hound
flint idol
#

i told myself i would fix it

#

but im having problems with the first trb

#

also i have some new code

#

so let me push that

flint idol
weary hound
flint idol
#

i just pushed like 750 changes

weary hound
#

another thing is that checking USBSTS.EINT for interrupt pending is not correct if you use MSIs, because iirc the interrupter IP is automatically cleared after the write that triggers the MSI

flint idol
#

oh

weary hound
#

actually hm, EINT is RW1C so it's only ever set by the controller

#

still i wouldn't use it and just check the specific interrupter

#

in managarm we check ERDP.EHB since that has to be cleared by software after it's done processing stuff from the event ring

flint idol
#

ok ill try that

weary hound
flint idol
#

im gonna share them anyway whats the worst that could happen

weary hound
#

well the problem is that they're edge triggered

#

so you can lose them if multiple happen and you have them masked at the time

flint idol
#

i see

#

ill fix that in a second, rn the only driver i am running is the xhci driver so other devices shouldn't be a problem™

#

oh well time to open managarm code

#

because well ig damn me, i get interrupts with xhci passthrough on this hardware

#

(and i also get trb completion code 0x4 because usb has damned me)

weary hound
#

usb transaction error my beloved

#

managarm also gets it when trying to talk to stuff behind hubs

#

and i haven't figured out why yet

#

although i got some new equipment to try and debug it (cheap usb protocol analyzer from china based on an open source design), but i haven't had the time to do it yet

flint idol
#

gl

#

i think im gonna do some polling on the event ring to see if it's an interrupter problem or something else

dense vigil
#

I wonder if there is a good way to test MSI/X seperate from the USB controller

#

Like a QEMU device to write to an IO port and it gives you an MSIX

flint idol
#

AHCI

dense vigil
flint idol
#

anyway this xhci controller uses MSI

#

and it seems to not be an interrupter problem

#

ok so no matter what i set the cycle bit to

#

it doesnt recognize my trb

stark sigil
#

msi the company trl

flint idol
#

omg

#

i just want an irq

#

is that so much to ask for, xhci controller

#

are you really that lazy, xhci controller

#

sdflkgsndflksdnfs

stark sigil
#

i have to do all OHCI, EHCI and then XCHI at some point pain

dense vigil
#

Nobody needs usb 1.1 as the main controller

stark sigil
#

i do

dense vigil
#

Why

#

The MacBook

stark sigil
dense vigil
#

Fuuuuckkkkk

flint idol
stark sigil
#

oh no

dense vigil
#

What

#

Explain

#

Elaborate

#

Please

flint idol
#

ehci forces you to implement a UHCI or OHCI controller driver for support for older usb devices

#

XHCI handles USB1, USB2, and USB3 under the same thing

stark sigil
#

oh

#

i guess i do indeed need usb 1

flint idol
#

but intel wanted to be lazy with EHCI and decided "have the OHCI or UHCI controller do it"

flint idol
#

USB is insane, I tell you

dense vigil
#

Who the FUCK invented this

#

Who the FUCK did this so I can strangle them when they sleep

flint idol
#

dumbasses at intel and some other dumbasses at other companies

stark sigil
#

intel

#

idk

flint idol
#

i dont care if microsoft had anything to do with this or not

stark sigil
# stark sigil intel

Ajay V. Bhatt is an Indian-American computer architect who produced several widely used technologies, including USB (Universal Serial Bus), Platform Power Management architecture, and various other chipsets.
In January 2025, he was honored with the Padma Shri, India's fourth-highest civilian award, by the Government of India.

#

this idiot

flint idol
#

fuck micro$oft

flint idol
#

he probably didnt invent the EHCI/OHCI/UHCI interfaces

flint idol
#

my ears are bored

flint idol
#

IM NEVER GONNA DANCE AGAIN, GUILTY FEET HAV EGOT NO RHYTHM

#

THOUGH IT'S EASY TO PRETEND

#

I KNOW YOURE NO T A FOOL

stark sigil
flint idol
#

[January 24th, 2026, 20:56: I have started yelling song lyrics in OBOS thread, i have been driven to absolute insanity because of USB]

flint idol
dense vigil
stark sigil
#

i cant even find the specification for any of them

dense vigil
#

Honestly honestly

#

I should fucking mirror the USB specs on my site

flint idol
#

no the xhci spec was free

dense vigil
#

Copyright be damned

flint idol
stark sigil
flint idol
#

didnt check uhci or ohci

stark sigil
#

this is worse than openfirmware

dense vigil
flint idol
#

idk if the usb specs are pay walled

stark sigil
flint idol
#

but I couldnt find an official spec

flint idol
#

idk why i couldnt find the usb3 spec anywhere

dense vigil
stark sigil
#

is xhci usb3, ehci usb2, and ohci and uhci usb1?

dense vigil
#

Can you send them to me so I can mirror them nicely

#

If you can find all of them

#

Just so people can find them 🙏

flint idol
stark sigil
flint idol
flint idol
stark sigil
flint idol
#

as you would any other device

stark sigil
#

ok honestly i think i have to implement device trees even on x86

#

on powerpc it was practical but x86 is literally pain

flint idol
#

it's paywalled

#

i found it on libgen

flint idol
#

just like dont tell him

dense vigil
#

I don’t wana get like

flint idol
dense vigil
#

DMCAd tho

flint idol
#

fine ill do it myself

dense vigil
#

Then il do it too

#

And we take the fall together

flint idol
#

real

dense vigil
#

Honestly would the fellow even care?

flint idol
#

idk

#

ask him

#

he's active on the osdev forums

dense vigil
#

I’m not on there

#

Why don’t you ask

flint idol
#

helping clueless people like me with USB

flint idol
dense vigil
#

I cannot find UHCI

flint idol
dense vigil
flint idol
#

lets just uh ignore that

#

watch us get ToS banned because piracy is against discord rules

dense vigil
#

i mean somone here could prolly get written permission

#

for us

dense vigil
#

ehci atleast says this

flint idol
#

there isn't even an OHCI spec 🥀

dense vigil
#

sooooo

#

No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted herein, except that a license is hereby granted to copy and reproduce this specification for internal use only

#

this is "internal use" right

dense vigil
#

btw qookie how illegal is this PSP1G_pspTrollar

flint idol
#

1.1 i think

dense vigil
#

even if its for public good

weary hound
#

i mean aside from the ben lunt book this is all publicly available

#

(so perhaps stop sharing it)

flint idol
#

ill hide it on my server so no one can find it

#

hopefully like no one signs with ftp and finds it

#

because like that would be terrible

#

you know

dense vigil
#

this should be correct?

flint idol
#

lgtm

weary hound
# weary hound

for ohci there is even an open source implementation in spinalhdl :^)

#

if you want to design your own hardware with ohci

flint idol
#

nah ill just use aptitude it's smarter

dense vigil
#

Let me get my USB

#

To put them on my file server

#

Because I forget the login

#

And I CBA to change it

#

Because my desktop at home is logged in

flint idol
#

i hate the cold but i love the vibe of the cold

dense vigil
#

Gparted how fucking long does it take to format a USB ext4

flint idol
#

next time I have to wait for the bus in the cold im gonna listen to snowy from undertale ost

dense vigil
#

Why is my laptop overheating now PSP1G_pspTrollar

flint idol
dense vigil
#

This is just the normal spec books

#

Fat32 worked thank you

#

Unmounting it crashed plasma shell

flint idol
#

for tomorrow: play minecraft

#

for monday: study for math exam
for tuesday: do math exam, stress over math exam
for wednesday: play terraria
for thursday: enjoy my break after exam season
for friday: contemplate on my exam grades
for next Saturday: work on obos?

dense vigil
#

@flint idol I got them mirrors

flint idol
#

nice

dense vigil
flint idol
#

fucking hell

#

my pc isnt booting

#

well its only on the new kernel version

#

im gonna take a break from xhci

#

also after xhci i feel like adding evdev support to obos

#

would be le fun™, probably

flint idol
#

ok so im tryna get fvwm3 to work

#

but it's faulting tryna execute 0x11

#

in lile the actual fvwm3 executable

dense vigil
#

(But seriously take a break you need it lmao)

flint idol
#

lmao

#

but yes

#

I just got blinded by the sun reflecting off all this snow holy

#

this snow has gotta be like 3 feet deep

vale nymph
#

Arent u like from the middle east what

flint idol
vale nymph
#

Damn

uncut narwhal
#

yeah the canada explains why the snow is that deep lol

flint idol
#

it is stack corruption occurring as soon

#

as waitpid() in mlibc tries to return

flint idol
#

i think it's a bug in my signal implementation

#

yeah that checks out, it tries to return to 0x11, which is 17, which is SIGCHLD

#

um trying to fix it causes a triple fault lmfao

#

obos truly has the best code quality

#

which is probably a security vulnerability

#

because like anything can triple fault the kernel by passing an invalid ucontext

#

💀

#

it doesn't even set the ss/cs

dense vigil
#

Well I mean

#

It’s not really a SECURITY issue per say

#

Everyone data is safe

#

Nothing is sacked

#

Is more of a DoS attack

sterile sparrow
flint idol
#

fvwm3 works now

#

at least

sterile sparrow
flint idol
#

hf

#

was pretty portable imo

#

it also happens to be astral's WM

sterile sparrow
#

ye

dense vigil
blazing python
blazing python
flint idol
#

never tried it

#
[  LOG  ] thread 28: enter write_sync. blkCount=316, pipe->ptr=0, pipe->in_ptr=0, pipe->size=4096, pipe=ffff9000003c5808
[  LOG  ] thread 28: ret from write_sync. blkCount=316, pipe->ptr=316, pipe->in_ptr=0, pipe->size=4096, pipe=ffff9000003c5808
[  LOG  ] (thread 29, process 10) syscall Sys_ExecVE returned 0xb (OBOS_STATUS_NOT_FOUND)
[  LOG  ] (thread 28, process 9) syscall Sys_FdSeek returned 0x2f (OBOS_STATUS_SEEK_UNALLOWED)
[  LOG  ] thread 28: enter write_sync. blkCount=316, pipe->ptr=0, pipe->in_ptr=0, pipe->size=4096, pipe=ffff9000003c5808
[  LOG  ] thread 28: ret from write_sync. blkCount=316, pipe->ptr=316, pipe->in_ptr=0, pipe->size=4096, pipe=ffff9000003c5808```
#

wtf

#

there should be some read log

#

before the pointer goes back to zero

#

oh

#

the pipe is freed

#

fixed it

#

/bin/sh didn't exist

#

KVM Internal Error my beloved

#

ts consistent too

blazing python
flint idol
#

OH NO

#

I ACCIDENTALLY JUST SEARCH XCOCK

#

INSTEAD OF XCLOCK

sterile sparrow
#

acxcidentally

flint idol
sterile sparrow
#

xaccidentally

flint idol
#

i accidentally ported x

sterile sparrow
#

man i hate it when that happens

flint idol
#

xcock doesn't work nooo

#

it starts but doesnt show the time

#

😔

dense vigil
#

Maybe you don’t have thoes implemented?

#

Could have it return the time from the BIOS RTC

flint idol
dense vigil
#

Oh lmao

flint idol
#

it seems to get the time from clock 0x1 which i defined as the tsc/kernel time source

#

something does that, at least

flint idol
#

currently implementing PTYs

flint idol
#

so in theory, PTYs work

#

i just need the mlibc sysdeps

flint idol
#

TIL xterm's build system is insane

#

and xterm also just so happens to imagine new functions into existence

#

nvm

#

like congratz to the guy who wrote this

#

he managed to make a completely shit build system

#

what dumbass wrote this build system, seriously

#

bro what

#

config.log says it made a confdefs.h but not one is in sight

#

nvm that

knotty totem
#

find it then?

vale nymph
flint idol
#

it's not detecting any of the installed headers correctly

#

or well it's detecting them but it isn't going in the config.h file thing

flint idol
#

atp i might as well write my own makefile for this shit

vale nymph
flint idol
#

i got it to build using duct tape

#

ffs

#

it's trying to use bsd PTYs

#

oh it doesnt build anymore

#

wtf

flint idol
#

why does it think im compiling for goddamn BSD

#

what the fuck is wrong with this

#

ok i got it to build again

flint idol
#

whoever invented the ioctls that work on goddamn file descriptors

#

fuck you

#

IO control

#

not FD control

#

well i got one half of PTYs working

#

it can definitely output onto the PTY

#

but xterm isn't recognizing it got output

#

like, input works

#

but xterm is just completely heedless to the fact it got output it needs to print

#

(which is probably because my PTYs are wrong)

knotty totem
#

(from shortly after the xfree86 fork)

knotty totem
#

it shouldn't be hard

flint idol
#

NOOOOOO I JUST LOST ALL MY DEBUGGING PROGRESS

#

BECAUSE I FORGOT TO UNSET A BREAKPOINT FOR Arch_GotoUser

knotty totem
#

ok, unset it now and then continue

flint idol
#

no because it went to a different user thread

knotty totem
#

you'll go to the next point it would've breaked at

flint idol
#

and it's impossible for me to go back to the old one

#

because it's also a different process

#

ok i set a breakpoint on the last place i remember being at

#

note: charproc.c:6894

flint idol
#

also, "no job control in background" 🥀

flint idol
# flint idol

*only works without fvwm3 because i think xorg hates me

dense vigil
flint idol
#

what do i do

#

i should debug why it has no job control

#

hell is should debug how tf it's working

#

obos has absolutely no "changing controlling TTY" logic

#

this working should not be possible

#

except if like it's because on fork() nothing closes the stdio descriptors

vale nymph
#

if you cant vibecode x12 you are ngmi

flint idol
#

ok nvm it does work with fvwm3

#

i need to fix some bug with ps2

#

after using the mouse/keyboard long enough it kinda just starts having a stroke

#

to put it shrimply

#

also unfortunately doom does not work with X11

#

😔

#

it loads the WAD and all

#

but alas, it doesn't actually run

#

TODO: get SDL's X11 interface thing working

#

although that sounds like a problem for future me

#

im gonna stop doing osdev for the day

dense vigil
knotty totem
dense vigil
#

All I know is the creator is a biggot anti vaxor conspiracy person XD

flint idol
#

no clue why it gets EINVAL

flint idol
flint idol
#

yeah for dumb reasons

#

the xorg keyboard input driver

#

isn't working that well

flint idol
#
void pty_ref(void* tty) { OBOS_SharedPtrRef(&(((struct pty*)(((struct tty*)tty)->interface.userdata))->ptr)); }
void pty_deref(void* tty) { OBOS_SharedPtrUnref(&(((struct pty*)(((struct tty*)tty)->interface.userdata))->ptr)); }
flint idol
#

hey that's not fair why cant my fvwm3 look like that :(

flint idol
#

no way xbps-install is almost working

flint idol
#

🙏

sterile sparrow
#

faster than movistar internet

flint idol
#

for funsies im gonna set MSS (max segment size) to 0xffff

#

(so much for congestion and stuff)

flint idol
#

im tryna think of a way to increase IO performance

#

on the network stack

#

im thinking of one thing in particular and that is to eliminate as many allocations as possible

#

i was also thinking of delaying ACKs in the TCP implementation

#

reasons being:

#

a) sending packets takes time

#

b) it is better to send one big ACK as opposed to many different small ACKs

#

one thing i noticed in packet dumps is that obos is sending a bunch of small ACKs really slowly

#

i just removed a SINGLE assertion

#

and that boosted I/O perf 10-100 times more

#

still slow as shit

#

but

honest citrus
dense vigil
#

I plan to get nvme on there too soon

#

And any others that come up that people need

honest citrus
#

nice

dense vigil
#

LMK if there is any others you need me to mirror

flint idol
#

ok so my problem with TCP right now is that it is not seeing a lot of packets that come to it

#

causing a lot of retransmissions

dense vigil
#

More driver issues?

flint idol
flint idol
dense vigil
#

Or it’s getting them too slow and it’s getting retransmitted causing a snake effect

flint idol
#
#define RX_QUEUE_SIZE (4096)

ill just do this and see what happens trl

#

no clue if the device actually supports that

flint idol
#

ok i fixed the ACK bugs

#

and now imn getting reasonable download speeds

#

in the 100s of KiB/s

#

but the kernel dies halfway through

#

the download speeds were so fast for obos that it exposed a race condition

dense vigil
#

Your going beyond ‘97

flint idol
#

so i think i might've accidentally broke something

dense vigil
#

And put tons of emojis

flint idol
#

lol

dense vigil
#

Reading the entire file

flint idol
#

jeez i didnt think of that, thanks

dense vigil
#

No problem good chum

#

You’re doing a file transfer though right?

flint idol
#

yeah

dense vigil
#

And I presume DMA with the network card?

flint idol
#

pretty much

dense vigil
#

I wonder if you can have the ISR track the packets coming in and then compare that with the actual result

flint idol
#

so ur saying i should capture the packets for analyzing purposes

#

(wireshark)

#

nah the problem is the tcp implementation is overwriting the buffer

dense vigil
#

In the ISR just track minimal data and compare it with the result to make sure nothing is lost internally

dense vigil
#

Have you tried

flint idol
#

it receives data, it gets more, it overwrites it, or so it appears

dense vigil
#

Not doing that

flint idol
#

i always forgot how genius you are

flint idol
dense vigil
#

Yes yes thank you

dense vigil
#

But I am very lacking in sleep

#

And I just dealt with a ton of discord drama

flint idol
#

i can tell go to sleep man

dense vigil
#

And I need to unwind a little

#

I can share more in DMs

#

But holy shit 😭

#

How can you tell btw

flint idol
#

a slightly elevated level of sarcasm

dense vigil
#

Excellent deduction

#

I’m just waiting for dinner

#

Then I’m gonna sleep

flint idol
#

aight

dense vigil
#

Sorry if I am intruding btw

#

Hope you can get the networking card going well

flint idol
dense vigil
#

Thank you

flint idol
#

i need some funny sarcasm in my life

dense vigil
#

Dosnt everyone

flint idol
#

yes

flint idol
#
size_t nPushed = 0;
OBOS_ENSURE(be32_to_host(hdr->seq) >= con->state.rcv.nxt);
Net_TCPPushReceivedData(
    con, 
    segment_data, segment_length,
    be32_to_host(hdr->seq) - con->state.rcv.nxt,
    &nPushed);
if (con->state.rcv.furthest < con->state.rcv.nxt)
    con->state.rcv.furthest = con->state.rcv.nxt;
if ((be32_to_host(hdr->seq) + nPushed) > con->state.rcv.furthest)
    con->state.rcv.furthest = (be32_to_host(hdr->seq) + nPushed);
if (be32_to_host(hdr->seq) == con->state.rcv.nxt)
{
    con->state.ack_pending = true;
    OBOS_ASSERT(con->state.rcv.furthest >= con->state.rcv.nxt);
    con->state.rcv.nxt = con->state.rcv.furthest;
}
if (!con->ack_timer.handler && con->state.ack_pending)
{
    con->ack_timer.handler = ack_timer_handle;
    con->ack_timer.userdata = con;
    Core_TimerObjectInitialize(&con->ack_timer, TIMER_MODE_INTERVAL, 5*1000);
}
#

well this is the code

#

and apparently it causes the kernel to ACK more than it actually put in the buffer

flint idol
#

magnificent indeed

stark sigil
#

holy crap exotic if statements without { / }

#

are you doing ethernet now??

flint idol
#

im fixing bugs with tcp

#

and improving tcp performance

stark sigil
#

it was already there flobsh

flint idol
#

uh how do i verify the file's contents now

#

sha256

#

yeah that's not the same file 💀

#

the checksums are completely different

#

and ig because the kernel fucking hates me

#

i consistently get this crash

#

when running curl on http

dense vigil
#

Or CRLF or some other shit

flint idol
#

well it's reading a raw data file so id hope it's not CRLF

dense vigil
#

Try downloading a binary file that’s all 0xFF or somthing?

#

And then you can do a check in the hex editor

#

Unless you already did that

flint idol
#

it's getting data out of order

#

so receiving all 0xffs will not reveal anything

dense vigil
#

That’s how TCP works innit? You have to re order it back

flint idol
#

yeah and that's the bug

flint idol
#

somehow

dense vigil
#

Why don’t you put the data in order trol

flint idol
#

really should've thought of that smh

#

i have a better idea

#
while [ `sha256sum $out` != `cat sum` ]
do
  curl -Lo $out $url 
done```
dense vigil
flint idol
#

keep on redownloading the file until the checksum is right

dense vigil
#

Bogosort ahh algorithm

flint idol
dense vigil
#

Do packets not have an order ID?

flint idol
#

if the receiver got a mismatching checksum, the packet is retransmitted

#

so technically

#

it is

#

but it doesn't really work like that at all

#

i lied

#

the lion does not concern himself with data accuracy

flint idol
#

if only i knew how i could make this buffer work

#

i need the consumer of the buffer to be able to read from it like a stream

#

but i need the producer to be able to write to it at any arbitrary offset, with the user only being signaled when there is some complete data (i.e., data at offset zero has been written)

#

what if i used a bitmap to indicate which regions of the buffer have not been written and which haven't been read trl

#

so ig the data structure i am looking for is a: string

dense vigil
#

How does reading it like a stream work?

#

Why not just have a read and write pointer

flint idol
flint idol
#

so like if the buffer has bytes 15-20 received, then a read would block until offsets 0-15 are filled

dense vigil
flint idol
#

no

flint idol
dense vigil
#

Why not use a freelist of unwritten blocks or some shit

flint idol
#

seems pretty not right

#

idk ill figure it out im wording what i want terribly

#

maybe instead of writing stuff out of order

dense vigil
#

Do you know how many packets you get ahead of time?

flint idol
#

what i need to do is reorder segments so that they are in the right order, then process them in order

dense vigil
#

Why not make a sparse array you allocate lazily

flint idol
dense vigil
#

Damn trol

flint idol
#

all i know is that i will get at most rcv.wnd bytes ahead of time

#

but that says absolutely nothing

flint idol
dense vigil
#

What if when you get a block you sort them automatically and if it can’t be put in sorted put them in a linked list elsewhere or some other thing

#

And then as needed go through it and sort it and put onto the main set

flint idol
#

idk

#

maybe a bitmap of "received bytes" could the solution

#

once there are enough contiguous received bytes from the start of the buffer, signal the reader

#

but of course a bitmap might not be the best

dense vigil
#

Yeah I don’t think a bitmap is the best

flint idol
#

a list might work

#

a self-sorting, self-defragmenting list

dense vigil
#

Like an RB tree?

flint idol
#

no rb-trees are only self-balanced

#

also wouldn't fit this, i don't need O(log n) search

#

i need fast iteration, so a list is likely best suited

#

but at the same time, a list will need allocation, and allocation might not be the best idea in a critical part of the tcp stack (but that is probably a problem for later)

#
struct received_segment {
    intptr_t offset;
    size_t len;
    // list info
}```
#

when a received_segment is found with offset=0, it signals the reader, and the reader will read from offset to len of that segment

#

if i knew how much data im getting in advance this could be easier

#

like if i knew for a fact i would get receive_buffer.length bytes, then i could simply have the reader block until that many bytes have been written

#

but alas, i dont have that information

#

actually wait

#

i do have that information

#

not exactly

#

that information

#

but what ill do is keep my current approach

#

but only signal the buffer when the kernel sends an ACK to the data

#

because ik for a fact that the tcp implementation ACKs when it knows it's emplaced all data

#

and i did that

#

and the data is still completely wrong

flint idol
#

that's wrong

#

yeah it's probably in my best interest to have the packets be sorted in order of SEQuence, then processed in that order

#

which sounds pretty complicated for my brain rn

#

so im gonna sleep

#

TODO for tomorrow: process packets in the right goddamn order

#

maybe even TODO for tomrrow: implement TCP SACK (selective ACK)

dense vigil
#

You could say keep X blocks pre allocated so when new shit comes in they fill up first

dense vigil
#

Ahhh

#

Whoops sorry

flint idol
#

if i process packets in the right order to begin with this problem doesnt exist

flint idol
#

this networking shit is fun icl

dense vigil
#

What happens to out of order packets? I presume you keep those non processed elsewhere

flint idol
#

more amusing than xhci pain

flint idol
#

and process them once there are no more holes

flint idol
#

on my phone there is an audio file named weird.wav that was created at 1:30 am...

#

i do wonder what this could be

dense vigil
#

You should use miracle sort btw

dense vigil
#

And send it here

flint idol
vale nymph
#

where you randomize it and if it is not sorted, you destroy the universe

flint idol
vale nymph
#

by the theory of quantum immortality, it will be sorted

flint idol
dense vigil
vale nymph
#

yeah but I don't want to share it in fear of someone abusing the destruction of the universe for nefarious means

#

works pretty well, seeing as we are still here

flint idol
#

time to listen to 647 instupendo with the lights off starting at the ceiling

#

nvm i think ill get possessed if I do that

dense vigil
#

I wonder what would happen with an HTTP server

#

Like your OS hosting it

#

And seeings how scrambled it is

flint idol
#

because the problem is not on transmission but instead on reception

dense vigil
#

True

#

I mean then ship it

#

Who needs to receive data anyways

flint idol
#

true trl

dense vigil
#

Actually though

#

When you finish this

#

Host an HTTP(S) server for your kernel

#

On your kernel

#

And have it though NAT to catch most attacks on a buggy stock

#

Stack

#

And also use it for people to pen test your stack

flint idol
#

not a terrible idea

#

I could realistically host smth like that on my vps

dense vigil
flint idol
#

I was also thinking it might be possible to host a site on obos as long as I implement some sort of watchdog timer that resets the system if it detects a hang

dense vigil
#

With a VM you can heavily restrict the traffic and sniff it to make sure it’s not doing stupid ahh shit to be able to kill it

flint idol
#

its not like sshd would be any less capable on obos than it is linux

dense vigil
#

Not like a hetzner box is that expensive for a cheaper one?

blazing python
dense vigil
#

But I mean you never know on the Internet

flint idol
dense vigil
#

With people fucking hammering every ssh and http server to find vulns and shit

flint idol
blazing python
dense vigil
#

Well just don’t say I didn’t warn you if anything happens

flint idol
#

the kernel drops any packets that lied about their length

#

and worst case scenario if it overflows and crashes, the watchdog timer takes over and resets the kernel

dense vigil
#

I’m just saying take some precautions so you don’t have to fucking explain to your VPS provider if it got pwned lmfao

flint idol
#

yeah im not actually gonna do it anytime soon

dense vigil
flint idol
#

the ext2 driver is not very reliable

#

and i dont even have sshd ported

flint idol
#

ok

#

time to properly do out-of-order packet processing

dense vigil
#

And then if it’s lower than the max they can go into the proper spot

flint idol
#

I would need rcv.wnd amount of slots (0xffff)

#

for that to work

dense vigil
#

And that’s expensive

flint idol
#

indeed

flint idol
#

i think im gonna use an rb-tree

#

instead of a list

flint idol
#

uh so ive managed to make the receive speeds and accuracy bad

#

scraped that idea

#

instead i will go back to what i originally did

devout niche
#

i feel like an rb tree for the reassembly queue is not ideal

#

since the reassembly queue should not have many segments on it in most cases

flint idol
#

true...

#

im thinking that instead of having a reassembly queue, i will insert packets into the rx buffer as soon as they're available

#

send an ACK (and signal the rx buffer) everytime rcv.nxt is advanced

#

and ill have some specific conditions for advancing rcv.nxt

#

that i will explain once i know what they are

#

this will also probably aid me when/if i implement the SACK extension

dense vigil
#

Oberrow quick question

#

What’s your block layer interface

#

How does a file system ask for a block

#

Because I wana make sure I’m not missing anything obvious

flint idol
#

the ext2 driver (only existing file system driver) either uses the page cache

#

or submits an IRP

#

to the block device

dense vigil
#

So like it would get a pointer to the page cache entry or would it copy to a buffer?

flint idol
#

it would get a pointer to a page cache entry

#

and then do whatever it needed with the block

dense vigil
#

How do you deal with the page cache entry being invalidated while in use? Would the FS free it back after?

flint idol
#

The kernel is to shit itself if that happens.

#

but uh as long as it isn't on a standby list, the pagecache entry, it should be good

dense vigil
#

I think in my kernel I would probably have it lock the cache entry

flint idol
dense vigil
#

Like the pfndb may say BLOCK_CACHE_FREE
Or
BLOCK_CACHE_USED

flint idol
dense vigil
#

And it will only reclaim free ones

flint idol
dense vigil
#

I may do a seperate buddy allocator for the cached blocks to allocate from?

flint idol
#

in struct page

flint idol
#

just set that bit until the driver is done with the entry, it should be good™

dense vigil
#

How should one make the allocator linked list skip over blocks like that l?

#

It wouldn’t be much overhead though

flint idol
#

if (page->flags & PHYS_PAGE_LOCKED) continue;

dense vigil
#

Because it won’t need to lock it for long

flint idol
#

?

dense vigil
#

Yeah

flint idol
#

anway if u will excuse me i have a reassembly queue to fix

dense vigil
#

Good thing I pointed that out

flint idol
#

well im getting consistent download speeds and accuracy i believe

#

(that doesn't mean shit)

#

literally exactly 143 bytes a second

#

because for some reason the window isn't growing properly

sterile sparrow
#

hey not bad, you could use a BBS just fine meme

dense vigil
#

Rust only gets 142

flint idol
#

so to fix the whole "data isn't right" thing

#

im gonna double buffer this shit

#

you read that right

#

ill have the kernel intermediate receive buffer

#

that will be flushed to a user "ready buffer"

#

whenever the kernel sends an ACK

dense vigil
#

What does Linux do here hmmCat

#

Does it do similar

flint idol
#

something sane

flint idol
#

is it insane? yes

#

will it work? idk

devout niche
# flint idol im gonna double buffer this shit
/*
 * We manage rcv_wnd like this: it stays constant until we can't
 * putnext() any further data and have to queue it; then, we
 * reduce rcv_wnd by as much as we receive. this continues until
 * we are free to putnext() again, at which point we reopen the
 * window to its full extent.
 */
#

so i push the data up through STREAMS but if STREAMS says it can't take any more, then i queue it within the TCP driver

#

it seems to be a fine solution

flint idol
#

hm

devout niche
#

i found it interesting we both ended up with a 'double buffer' solution there

#

note the reopening to full extent

#

streams is full: data is queued up in the tcp driver in the meantime; streams doesn't allow messages to be sent up anymore until the streams queue reaches a low watermark; when that low watermark is reached, potentially a lot of data queued in tcp can go up at once, and then readers naturally coalesce their reads of this data

flint idol
#

the double-buffering solution gets me the right data

#

however it seems to fail to return the right amount of data in cases where the amount of data received in total is < rx window size

flint idol
#

yeah it's failing to push the full extent of data to userspace for some reason

#

huh it seems like it's not ACKing everything properly

flint idol
flint idol
#

im having fun running sudo ss -K dst 192.168.3.2 while sshing into the host from obos

stark sigil
#

sudo

flint idol
#

after I come back home today im gonna commit my working changes and implement selective ack

dense vigil
#

Btw how does OBOS handle MMAPing files from block devices?
I heard how managarm does it. Pretty complex but possibly manageable but I wonder how USB person does it

vale nymph
#

I would assume so seeing as it has a page cache

dense vigil
#

Page cache is gonna be hard. Wanting to see how others do it

#

It’s coming up soonerish on the list

flint idol
#

it refs the page in the pagecache

#

and then maps the physical address

#

possibly mapping as CoW if it is a private mapping

#

and possibly creating new entries if prefaulting is requested

#

if a pagecache entry does not exist and prefaulting is not requested then on fault, it is created and mapped

dense vigil
#

How do you handle invalidation of MMAPd files or other things so you can update the needed PTEs

flint idol
#

and this ID is also used to identify the page in the swap

dense vigil
#

I mean like if say multible processes have this mapped and you need to edit the pages to fault, how do you keep track of that and to clean them all up?

flint idol
#

I forgor let me check

dense vigil
#

Thank you

flint idol
#

uh iirc I always map pages that are swapped out with a swap allocation id so the kernel never has to keep track of what pages are using a virtual page

#

I also think that if a pagecache entry has mappedPageCount >0 the kernel will not invalidate it

#

(not same as refcount btw)

dense vigil
flint idol
#
                // TODO(oberrow): Reclamation of file cache pages.```
dense vigil
#

So then the kernel sees oh this is part of this to send it over here to nuke mappings

flint idol
#
// represents a swap allocation, as well as the physical page that it uses, if it was already read.
typedef struct swap_allocation
{
    LIST_NODE(swap_allocation_list, struct swap_allocation) node;
    uintptr_t id; // the key
    size_t refs;
    page* phys; // if !phys, this page must be read from swap.
    struct swap_device* provider;
} swap_allocation;
OBOS_NODISCARD swap_allocation* MmH_LookupSwapAllocation(uintptr_t id);
swap_allocation* MmH_AddSwapAllocation(uintptr_t id);
void MmH_RefSwapAllocation(swap_allocation* alloc);
void MmH_DerefSwapAllocation(swap_allocation* alloc);```
#

and then when the kernel swaps smth out, if there is already a swap allocation it will use that as the id otherwise it'll create a new one

dense vigil
#

So there currently isn’t a way to reclaim a MMAPd file from a process because it isn’t tracked?

#

Because many virtual address spaces could refer to such a page

dense vigil
#

Well when you or I do that

#

I’m ready for hell

flint idol
#

I also dont like the idea of keeping track of virtual pages in a physical mapping