#Managarm and related projects
1 messages · Page 7 of 1
Ok can to work today ig
With the way I’m feeling atm, can join in. Systemd here we go?
state: 
jk
waiting 🙏
Current ETA like 15:30? idk train just stopped on the tracks lol
Cancel that: the fucking train just broke down @nocturne tide @serene portal
@safe glen

lol
Literally
train
They just announced shits fucked and the driver is checking what can be done
Worst case a different train has to push / pull us to Breda and we change there
Train moment
Lol
Come on just go we’re wasting valuable systemd porting time
LMAO
Last time this train died it took 5 FUCKING HOURS
Please send emergency 12 gauge shells to my forehead
We ballin we’re moving
holy shit big
I did do some looking into MATE. Their file browser seems to want gvfs according to gentoo and that’s meh. Might skip that for now. No big issues identified so far
holy shit French people man i swear

Probably stolen from Germany
ETA 20-25 minutes
I literally can't go a week without experiencing or hearing of one of our trains fucking up bruh
I did not know you are Dutch too
Based
GEKOLONISEERD
Why are so many people here dutch
yes
no biggie
okay I think the bragi stuff is mostly done
I have a few unhandled cases (that just get ignored) but I don't care enough to implement them
unhandled tail member uint8[] mask
unhandled type <class 'bragi.tokens.Struct'>
unhandled tag member Rect[] drm_clips
unhandled tail member uint32[] fds
unhandled tag member Rect[] drm_clips
unhandled type <class 'bragi.tokens.Struct'>
unhandled tail member Ifconf[] ifconf
unhandled tail member uint32[] values
i wonder how hard it would be to make wireshark be able to intercept bragi comms inside of managarm
just expose it over a special socket or something
ok I think the only missing codegen feature for the wireshark dissector is handling structs
after I implement that ig I can PR in that stuff
Based
Mental note to self: make build environment that runs without containers or all that jazz and do the funny
What?
I have a segfault during build (of course it’s gobject-introspection related) and that allegedly dumps core but in cbuildrt that’s not happening / not possible to exfiltrate. See if I can repro it without containerization and gdb that bitch
This would unblock gnome-calculator, gtk4 and friends
You can probably just hack the build system to launch gdb inside cbuildrt
I haven’t found out why and this has been nagging me for literal months now
Fuck the fine grained approach I’m bringing the sledgehammer this time
Gobject-introspection will bow to me and do as I wish
Doesn't it make sense to focus on systemd first? 
Yes, it does, but maybe I can let the shit that I need build in the background
More specifically, I can let it build while I go to sleep tonight lol
Then debug tomorrow / later
I have a working bragi wireshark codegen on my bragi fork on the wireshark branch
@trim eagle if you want to take a look
the bootstrap PR with support for it is already up
I'll need to clean up my managarm and mlibc work
I have not added support for bragi struct yet tho
Nice work
ok, the bragi PR is ready for review
it seems to work fine for dissecting my dumps
next up, mlibc
ok, only managarm remaining now I hope
neat
may i recommend adding helpers that make the code slightly less impossible to read though
which code?
the bragi stuff
when working with any sort of code generation anything, its usually advisable to add a helper type which automatically prepends the indent and appends the newline every time you add stuff
ah yeah I wanted to do that and forgor 
fair point
ig I'll do functions like this
I wonder if we could use virtio sockets to allow for more granular control over which ostrace events are emitted
or virtio-console ig
How would a different transport help with that?
basically we could activate certain ostrace events depending on what virtio-sockets are available for instance
and discard the others
obv running ostrace selectively improves performance when booting with ostrace
btw, in the PR I made sure all the ostrace stuff is dumped lazily so there is no measurable runtime cost to the PR when booting without ostrace
imo we should just have a way to filter out certain events
at the kernel command line maybe
do the config by injecting an ACPI table :^)
smbios table since qemu has an argument to do that :^)
although without a patch we apply (that we should upstream) it forgets to copy the null terminator 
they also have one for acpi tables
what about real hardware
will y'all be able to listen to bragi over serial or something in real hardware?
I'm not quite decided on how to do that yet
I was considering just dumping it over UDP or serial but wiring that up is not entirely trivial
because microkernel 
i don't think dumping it over udp is particularly hard
I mean we'd need to have a way to have netserver advertise an ostrace thingy
I updated the bragi PR with improved codegen (readability)
we could just put something like ostrace-udp=10.0.0.123 into the command line
and then have a userspace utility that reads the ring buffer and that dumps to netserver
wouldn’t reading the ring buffer and sending it over network generate additional logs
yeah but we could exclude those 
Journald dump kmsg moment
cool
bruh
my thonkpad's UEFI impl requires TFTP extension support on the server??????????//
inb4 doesn't check what dhcp says and assumes the dhcp server is the tftp server
at least the tftp server is short (< 100 SLOC of python)
despite paying attention to being correct to the spec and preventing path traversal attacks
okay I got the PXE and NVMe-oF boot working on my laptop pretty ez
all it took was writing the tftp server, everything else worked
I am now battling sysfs code currently
it seems like the devpath resolving or sysfs structure is borked?
not sure
btw leo is there anything I should review?
yeah because all the wireshark PRs need to be merged in sync
that was a measure to prevent one of them being merged by accident
830, 833 are also open
also mlibc #1190
yeah so about the devpath resolving
it is supposed to be round-trip going from the protocol -> text -> protocol, however on my thonkpad it is not
it also ignores the friggin options to not use short notation
alright so we can't really rely on the devpath2text protocol, so time to just roll our own ig
it wasn't that hard tbf
AAAAAAAAAAAAAAAAAAAAAAAAAAAA I HATE EDK2
it always reports PNP0A03 for every PCI root, no matter if it actually is
given that there are no further requirements on _UID being correct, I think we're cooked

I think the only sanity-preserving solution is to obtain the segment number of the PCI root and go with that
so basically we should just store the PCI and PCIe roots as the same devpath node and replace the _UID with segment number so that PciRoot(0) just means whatever root handles segment 0
edk2 is being kinda insane here ngl
also the impl is probably not up to spec 
okay getting the segment number is a bit ugly, as I have to get the PCI root protocol for the device path, but whatever
what are you trying to do
see #osdev-misc-0 too
but
I have a UEFI device path that I convert to text and pass to managarm for setting up the correct NIC
interesting
thing is, when trying to follow that device path I noticed that despite the machine having PCIe roots (PNP0A08), UEFI's device path always reports PNP0A03
so, how do I deal with that
I thought to basically just do gBS->LocateDevicePath(&PciRootIoProtocol, device_path) to get the segment num as I'll assume the device path's reported _UID is borked
does PciRoot(0) mean _UID of 0?
yes, that is supposed to mean HID=PNP0A03 _UID=0
however, even a PNP0A08 with _UID=0 is commonly reported as PciRoot(0)
_UID should be unique for all pci roots, no matter the HID no?
which is turbo annoying for the managarm side as I access them via the HID
that was not my reading of the spec
is there even a PcieRoot?
yes
well
u can just work around this behavior by checking if there are device paths with PcieRoot or something
nah so the thing is that I need to uniquely identify which controller to pick
and the PciRoot _UID is useless to me as it kinda doesn't actually mean anything on real impls
like I actually cannot resolve that to an actual ACPI device
it could be either PNP0A08 or PNP0A03 and I have no way of knowing
so my thought was to resolve this on the UEFI side, where I just slightly
modify the PCI root device paths: I can just replace the reported _UID with the segment number and be done
I don't see a way to get _BBN in UEFI tho
I still think just matching MAC addresses is good enough
the problem with that is that you probably need to initialize NICs just to then notice that MAC address collisions are suprisingly common
I have the devpath trickery implemented now tho, I can disklessly boot as far as into netserver now
not sure what's wrong there now tho
what I'll probably also do is carve out some memory early in UEFI for setting up an early bootAlloc
We should probably get rid of all uefi pool allocations in favor of this
Yes, but you want to init the NICs anyway
There's no point in running with NICs disabled
I'm thinking that wanting to blacklist some devices on boot might be useful esp for getting hw to boot
hence why I'm reluctant to just init everything
hmmm I'm now getting an assert in the NVMe driver??????
bruh
the ability to deny driver loading on boot might indeed be useful
yeah for instance my NVMe on my laptop is giving me weird asserts, so I had to comment out the NVMe PCI probing which would be nice to avoid
anyways I might just open a PR for the tftp serving stuff I wired up in vm-util
so basically what I do for diskless boot of my laptop is having the NVMe-oF controller running (configure using nvmetcli) and then I can just do vm-util.py tftp, which sets up a tftp directory and starts serving that
we could possibly also integrate NVMe-oF controller configuration by writing to configfs into that to have a full no-worries diskless boot setup done by vm-util
Using assert() to check for hw behavior is broken
Yea we should use configfs, not nvmetcli
As nvmetcli was quite broken when i checked it out a few weeks ago
pretty bad idea
nah it wasn't even that
the assert is that the slot number is in range, which it isn't for some godforsaken reason
so it seems like a logic bug somewhere
still no further progress with diskless boot on the thonkpad
what's the blocker?
something about NVMe-oF not being able to connect to the controller idk
however while debugging stuff I wrote some nice vm-util.py additions, guess I'll pr them in
basically I have a vm-util.py tftp command that sets up a tftp root and runs a tftp server without the braindamage required for "regular" tftp servers
and I also wrote a vm-util.py wol <mac> that just yeets a WoL packet
turns out fedora's packaged wol pkgs are borked? idk they don't work
ig for wol it might be nice to have it read a config file at CWD to allow for aliases
hmm I wonder if I can make UEFI use the window size option to make tftp downloads quicker
you probably can't make it very fast no matter what you do as the protocol is garbage
the http boot should be better but I have no idea what its supported by, at least my laptop didn't support it
ok so apparently I can use the window size option when using the (M)TFTP protocol itself
however, that is not possible with the protocol you get from the PXE protocol
I mean what we could also do is to just ship a NVMe-oF DXE and use that instead of TFTP for loading everything after limine
or a HTTP boot DXE
alternatively, ig we could also just spin up a new TFTP protocol instance using the data about the server we obtain from PXE
that would allow us to set the window size option
we'd probably still need the PXE TFTP proto impl as a fallback as the proper MTFTP protocols might not be available I'd think
I don't think this is worth optimizing with custom solutions
NVMe-oF would have the added benefit on not relying on kernel cmdline for passing parameters, as it installs an ACPI table 
the downside being that there's no NVMe-oF DXE implementation that I'm aware of
also technically I think it requires UEFI 2.10 because the device path type was reserved before but that's probably just minor details
maybe optimizing this with the "normal" TFTP protocol is worth it rn tho
it's just an alternative codepath to download a file
On non-UEFI platforms, workarounds like this also won't work
on non-UEFI platforms you wouldn't run eir-uefi 
checkmate
Even on uefi platforms, we probably want to stick to something that works out of the box on real hw
without installing/loading custom DXEs etc
yeah you can do the proper TFTP protocol with window size without custom DXEs
it's very very likely present if you do PXE boot, and if not we can just fall back to the slow PXE->Mtftp() variant
How does the window size work?
the window size determines how many data blocks are sent until an ACK is expected
so instead of ACKing every data packet you can cut out the ping-pong for 63/64 packets with window size of 64 for instance
The "Trivial File Transfer Protocol" (RFC 1350) is a simple, lockstep, file transfer protocol that allows a client to get or put a file onto a remote host. One of its primary uses is in the early stages of nodes booting from a Local Area Network (LAN). TFTP has been used for this application because it is very simple to implement. The employment...
ah I figured out the the wol stuff didn't work
apparently that was due to the fact that something got confused about which of my (many) interfaces to use
so my solution to bind the socket to a specific interface circumvented that accudentally
(I currently have 3 NICs + 2 wg connections active)
oh and wifi
That can only really happen if you specify the wrong broadcast IP, can't it?
Say, you have two interfaces 10.1.0.5 and 10.2.0.27, then you should send to 10.1.0.255 to target the first interface
(Assuming /24 subnets)
thing is, for WoL, you are supposed to send it to INADDR_BROADCAST
I don't think wol cares about the IP inside the ip header
it doesn't but I'm not sure whether it would get switched if the machine has been down for longer?
not sure how WoL works on a NIC level
WoL probably just greps for the magic packet as that format is static
yeah
For the magic packet + correct mac address
If the switch forgot the mac address, it'll broadcast across all links
ok update on the diskless boot thing
it seems like it gets stuck trying to set up a NVMe-oF connection
it tries to send ARP requests, never gets a reply, and the TCP sending fails with that
I also don't see the arp requests in wireshark which is weird
the NIC works fine when booting from disk, and I see it receiving packets with diskless booting
thus I'd conclude the NIC driver is at least not completely broken
(the machine has a i219-V, which is served by our freebsd-e1000 driver)
I'm really not sure what's going on
afaict the network parameters supplied from UEFI are correct, too
this exact setup work in qemu, too
ah I think I can replicate it with a tap device
Sounds weird indeed
it works in qemu with a tap device
but it does not on real hw
hmm maybe we don't reset the NIC properly on init? I can't think on any real reason except for memes like that
yeah that's not unlikely
you can try a PCI level reset
but that needs a new hw protocol request
i'll probably check the driver on freebsd or somthing similar first
maybe I'm just missing something there
Maybe we overwrite the uefi implementation's ring buffers etc with garbage and the device goes into an error state
Or the uefi firmware disables the device in some way
Do we enable bus mastering on that device?
Did that yield any progress?
I tried shutting down the PXE protocol but that didn't help
it's still failing to send ARP requests
i can only imagine that the problem is that the card somehow doesn't work correctly after being driven by the firmware
Did you try the PCI reset?
not yet
How does managarm deal with events/software bus? (iiuic)
can you make that question more specific?
I'm not really sure what you mean by "events/software bus"
I want to have some sort of system for device (resource) discovery, where different servers can publish devices and so on
Like a disk driver can publish disks, the blockd server can publish partitions, the init server can publish handles for filesystem drivers, and so on
I think Linux has dbus
But managarm also had some sort of system for this? I want to know how people typically do it
Or some sort of event bus
we have mbus
you can inspect that on a managarm system by running lsmbus
if you want to dump it to e9, run lsmbus > /dev/helout
for the source, look for mbus
Linux uses sysfs for this purpose, dbus is a userspace mechanism
Managarm uses mbus which unifies enumeration and monitoring (for hotplug)
mbus is essentially a table of objects that you can (1) enumerate and (2) watch for changes
But I think VFS is too inconvenient for this
And I think what I could even potentially do is some sort of broadcast system
kobject/udev netlink 
The way monitoring works for mbus is that each object has a sequence number that is updated on object creation and on object property change and you can ask mbus for all objects where the sequence number is larger than X

where "updated" means that a global counter is incremented and then written to the object's sequence number
This scheme is stateless on the server side so listeners cannot perform denial-of-service attacks against the mbus server
What do you mean by stateless in this context?
The server doesn't have to keep per-client state
Yeah, but how do you make sure the clients don't invent bogus sequence numbers?
if the seq number you send is above anything mbus knows about you just get an empty response
In contrast, sysfs (or rather, netlink kevent) on linux is not stateless and only privileged clients are allowed to subscribe to events
That's because the linux kernel queues an unbounded number of kevent notifications on netlink sockets that are subscribed to kernel events
the problem with sysfs is that it's user(space)-facing thing
And iiuc the kernel is using some internal API for publishing things on it?
I mean it's just a representation of stuff that drivers publish
mbus is a server you talk to over ipc
you send a request to publish a new object, and get a management ipc handle, on which you send ipc requests to feed other clients that bind to the object with handles
usually those handles are for object-specific ipc streams
e.g. usb device mbus nodes give you an ipc stream you can send usb requests over, etc
the only special kernel support is that it has a supercall that gives you the handle to the ipc lane to talk to mbus over
but how do clients request the objects?
the client prepares property filters (each object has a set of properties attached to it), then in a loop starting with seq=0 you send an enumerate request with the seq and filter, get a set of results back, and if the result was paginated you send another request at the seq indicated by the response
that gets you the ids and properties of the objects you queried, then you can bind to the object by id to get a handle to whatever the object is serving
but if the server is stateless, where are the properties stored?
Right now the kernel talks to the userspace mbus server. Ideally, this dependency would be reversed, but it's not a big issue for now. If we ever want to get rid of this dependency, we could add something like nested mbus support where the userspace mbus server subscribes to objects provided by a kernel-based mbus server
the server is stateless for client requests, it still stores the actual object state
I've been talking about Linux here
yes
So basically, mbus is a server which lets you publish a bunch of things, and then everyone can just request/read them, based on a bunch of filters?
This seems simple and effective...
(why am I talking like an LLM?)
yes
(I just need to think how to deal with the async part of it all)
I think I'm gonna implement something like this then as well
if you like udev try looking at solaris' devfsadmd
on solaris devices are presented in /devices (the devicefs) in the same hierarchy as they occupy in the device tree gotten from openfirmware (or a fake one on x86) after it's been decorated by driver loading and attachment
thats neat
devfsadm in turn then creates links in /dev based on this + configuration files
behind every linux idea is a prior and better implementation of it in solaris or some other unix
let me insert "good" between "every" and "linux"
plan9 has no shortage of bad ideas though 
But it was designed at a time where its ideas made more sense
here's how Gemini thinks mbus fits into Managarm 
mbus is a fundamental component for enabling dynamic interactions within Managarm:
Drivers: Bus drivers utilize mbus to register devices they manage. This allows other system components to discover and utilize these devices without hardcoded configurations.
System Servers: System servers, like the POSIX server, rely on mbus to discover and locate other services they depend on. This promotes modularity and allows for flexible system configurations.
Applications: While applications may not directly interact with mbus for discovery in typical scenarios, the services and devices they utilize are made available through mbus, indirectly relying on it for system functionality.
the description wouldn't actually be too bad if it didn't add a lot of stupid fluff ("This promotes modularity and allows for flexible system configurations." / "enabling dynamic interactions within Managarm")
i wonder if gemini was taught on managarm code
all coding capable AIs have been made to at least skim thru most github code for the most common languages, usually sorted by stars
which is why they suck at Ironclad, because for the longest time, Ironclad wasnt on github
i think by now it can also use google search results, so part of the info may come from there
i think they can do that already
the real question is: how long until they can write our docs? 
yes it can
but this feature is incompatible with enabling web search 
the results are mixed
it does manage to summarize the talk slides but the explanation is not very detailed
like, the Solution: Leveraging Events and IPC section only states half of the solution and not the entire thing
actually, if I copy/paste the chat in this channel from yesterday, it manages to give a decent technical overview of how mbus works:
https://docs.google.com/document/d/e/2PACX-1vQelx_CweiD5frtAj4pV3UHn4FHjrJOB7-KOgyUCwMsYrlq_wAhcXr-jFSEAhqRYnBwvfjZqm4ZMwVS/pub
somebody fine tune an LLM to generate handbook pages from a discord bot 
Clients discover objects by sending enumerate requests to the mbus server over IPC. These requests include property filters, allowing clients to specify criteria for the objects they are interested in. Enumeration is sequence-number based for efficient monitoring. Clients start with a sequence number of 0 and send an enumerate request along with their filters. The server responds with a set of objects matching the filter and having a sequence number greater than the provided sequence number. If the response is paginated (i.e., not all matching objects are returned in one response), the response indicates a sequence number for the next request to continue enumeration. If a client sends a sequence number higher than anything mbus knows about, it receives an empty response.
^ in particular, this part is a pretty good and correct summary of what qookie and I wrote
seriously considering writing this now
because scaleway has a (atm because beta free) very cheap LLM api
this would probably be actually useful
not sure how much effort it is, never messed with LLM APIs
i mean i normally quite strongly dislike LLMs
but this sounds interesting
its also more fun than listening to this lecture
discord api is likely more annoying
LLM written docs suck ass
just write them as you develop, much easier and much more accurate
yes but quickly making this bot sounds fun and something i can do within this uni day of lectures of super boring stuff
also i kinda want to see how it would summarize other things too
sumarizing code into docs? I can tell you how it will do that now, horribly
we were talking about summarizing discord chats into docs, not code
madre de dios bendito
if you give it code as input it probably indeed sucks hard
im gonna be honest, of all things, I am not sure discord chats are an improvement
but by all means, try it out
I am willing to swallow my preconceptions
I doubt I will
get deepseek-r1 running locally with ollama and feed the AI a file with the chats
its gonna be the easiest way to do this
no need to bother with discord API
just download the chats with a bot
@carmine current discord bot account created 
i guess you could feed the entire messages ever written on the managarm discord into it and then add a /command to ask it for info about a specific topic
i can add the bot and make an experimental channel if you want to
i was just gonna make it a "summarize the last x messages" or "summarize from here" thing
would be nice!
send a link
asking for a specific topic is most likely more useful
or we can just have both i guess
sent
one is easier to implement as a "see if it actually works" thing 
anyway 30 min uni break 
@carmine current about the post-install step
I'm not sure that's a great idea, as that would run it every boot which takes a solid 7-10 seconds on my (beefy) machine
not on package install/update?
yeah that'd be super annoying ngl
given that the hwdb doesn't really change I would want to have it run more than exactly once
but maybe if systemd will fix this anyway we can merge it as-is
systemd has a unit file that only gets triggered if the hwdb does not exist
alright
which btw is why this line is a thing https://github.com/managarm/bootstrap-managarm/blob/95390ff72cf6f8bfab1b1db0c38a7e342f7a460e/scripts/update-image.py#L459
also, a SEA OF GREEN
hm?
it makes sure that the hwdb does not get nuked by a make-image which would regnerate it on the next boot
also has the advantage that the xbbs nighly image already has it pregenerated 
ah unforunate
we'd need proper shutdown if we want to run w/o -snapshot 
systemd support will help with that
looks fine
Do you just store everything in mbus in a map, keyed by sequence ID, or am I missing something?
yes
Isn't it kinda expensive?
not really?
what exactly?
the map is object id -> object
Like if you have a lot of drivers requesting with a bunch of filters, it's a lot of processing for every new object
although ig sequence id -> object is also a std::map of sorts, although we explicitly use the frigg intrusive rb_tree
The sequence id is not the problem
Like idk how to explain it, but this doesn't feel scalable
each filter needs to processed once for each update
there's no way around that, really
we could build additional indexes to skip some filters but that's just an optimization
its a pretty classic DB problem
What I'm thinking is making my thing a tree
which is another way of saying "there's a shitload of research into making this kind of thing scale well"
So not everything has to be processed
So I shouldn't care until (if ever) this becomes a problem?
of course lol
that should be the default
I don't think a tree fundamentally saves any processing here
A tree is equivalent to an additional index that indexes a "parent" property
thats not actually true btw
But like the processing could be subdivided
you can rank properties by how much they get used
Hm?
like for example if you publish an object with properties (p1: v1, p2: v2)
instead of looking at every filter
you can try looking only at filters which constrain p2 to the correct value

this works especially well if you structure your properties more cleverly than just a flat dictionary
But what I'm thinking about is that for example, this system can be used for devices discovery, and for some other events
The device discovery thing can have a lot of listeners, but new devices rarely appear, but the frequently changing stuff would be in a different domain and would not run a lot of filters
but impl wise this is hard to do
that's true, but this is essentially what i mean by "you can add more indexes"
yeah pretty much
you can solve it easily enough
VFS-like thing basically
you have to select one of the properties you are matching on as a "primary" property
and then you have a map of <hash of primary property, list of listeners>

then you just hash each property and wake up every listener matching it
and if you choose the primary property well you will get woken up only when it might be necessary for you to do shit
Ok, and that doesn't require changing the interface if I decide to implement that later
yeah
And you allow duplicate names?
yes but names are informational only and not used in filters
that's interesting
if you require names to be globally unique you need some policy to decide which server can register which name
otherwise one server can do a denial of service attack against another server
ok so I've only looked at the man page so far but implementing fdinfo doesn't even seem to be that hard?
that may just be the next thing I tackle after getting ironclad NVMe done
Based
Leo doing insane work in every dept
Maybe we can trick him into mountinfo too????
And with that info exposed, /proc/self/mounts is more of the same (mountinfo exposes more iirc)
Then /etc/mtab becomes a thing (that’s nowadays a symlink to /proc/self/mounts)
says local ACPI man
mountinfo sounds trivial, i can do that as well
it's just a list of mount points, isn't it?
or wait, i may be mistaking it for /proc/mounts
ah but yeah it's basically the same thing
so a few things about that
we need to assign mount IDs to mounts and same for major, minor numbers
wiring stat to show st_dev for regular files should be easy after that
Yeah idk how that would work
Well actually in managarm it would work fine because it has acpi in kernel mode
all of /proc/mounts, /proc/[pid]/mounts and /proc/[pid]/mountinfo are similar
mount IDs are trivial to allocate
and we have major / minor numbers, we just don't store the device that backs a mount point
but we can easily add that without major changes
yeah
it would probably be pretty similar to a monolithic kernel
tell all drivers that we're going to suspend
give them a few seconds to react
if they don't react, either wait or kill them (depending on the importance of the device)
Yeah
If it was in userspace tho
How would resume work?
Since that happens in real mode
And everything dies and resets as in every device state
Do you guys ever get complaints about managarm not being an actual microkernel because of all these things being in kernel mode
Or because of the POSIX server being extremely monolithic
not really
managarm is FAKE
also, other than ACPI there's nothing in kernel mode that could be moved to user mode
scheduler?
(while keeping the same design)
gic code, maybe
yes obviously moving things from one mode to another mode changes the design
I would imagine people would complain about the POSIX server quite a bit
never encountered that
Interesting
i mean in a major way. for example, moving ACPI wouldn't change any syscalls
ah yeah
the POSIX server is kinda monolithic, that's true. but that's due to the nature of POSIX
some parts could be moved out
but the POSIX server is still much smaller than a monolithic kernel
Maybe I will implement it in pmOS
it doesn't talk to devices, it doesn't implement persistent file systems or networking etc
I see
That would be cool
the attack surface of the posix server is much smaller than the attack surface of a monolithic kernel
you could also reimplement the posix server in almost 100% safe rust if you really wanted to
;D
or Ada ;D
Ew you guys have enough already with C++
scheduler is inside the kernel but that's also true for a lot of other microkernels
for example, it's also true for seL4
isn't seL4 basically useless anyway
no, why?
seL4 is used in production
The new apple modem runs cL4
it had a DARPA grant to implement a secure system, go figure what it may be used for 
memory leaks don't matter on rockets
powered by assertos™️ missile
It uses garbage collector
qualcomm chips run l4
It collects all the memory and even some area around it :^)
too
actually it specifically mentions "unmanned air and ground vehicles"
l4 is arguably used for drones yeah
I say arguably because those drones run like 3 OSes
And they have not made it into general use afaik
They are like networked air decoys iirc
It's neat
imo drones are not neat things
These ones are unarmed
then it's fun
They are just deployed by fighters and are meant to imitate planes
So air defense is confused
lol imagine drone running managarm and assert fail
It just crashes on a school killing countless innocent children like every machine of war
Assert makes it default to factory settings
hi
a managarm drone would likely assert way before flying over a school
I honestly dont know how I would react if Ironclad was used in like a weapon to kill people
I know that if time goes on and I keep the ball rolling, thats just a thing that comes in the field at a certain point, these companies try a lot of stuff just to pad budgets
but idk man
if not your os, it would be some other os
that point works until your code is used to blow up children you know
yeahhhhhhh
it would be unfounded, historically many had even more than managarm does
Leo is doing some work on /proc/mounts rn
^
Yooooo. Based
Progress on mounts ngl
@vestal sapphire do you also have a list of mountable FS types? Cuz if yes we can export that over procfs too (managarm#593 and potentially managarm#594)
not yet
I'll prob impl a bunch of stuff tho so it might just get very easy to do
If it is, then please do so. Otherwise I don’t believe it’s actively blocking anything so don’t worry
ok we ball
Balling
nice
But aren’t we missing /dev/pts?
It’s a thing in on Linux. Devpts. Idk if we implement it as a separate FS tho
Yikes
ah no wait
I don't recursively handle children mountpoints
ah I need to traverse multiple mount points now, damn
Oof
did you implement multiple mount point traversal?
btw something that we also shouldn't forget about is reviving the rust build
not yet
do we have a utility for that already?
I might just be too stupid to use ViewPath ngl
No
but ViewPath::getPath already does mountpoint traversal?
yes
when going down in the fs hierarchy you need to check the child mount points to see if you enter a different mount
when you go up via .. you need to check against the MountView's origin to check if you enter the parent mount
But the latter is already done by getPath
okay so why does ViewPath.getPath assert on having no owner
I just don't understand the logic of it
okay I guess the problem is that I don't know what mount the link returned by getAnchor() is?
yeah I guess changing the anchor to be a ViewPath works
getAnchor always returns a link in the parent mount
nice
yoooooooooooo
this code very fast
oh yeah
Since it should show /dev/sda2 or something like that
/dev/sda1/
Based
now mountinfo is next
and after that, fdinfo
that should allow us to drop some systemd patches
we can't run mount with the changes, yet
then it's broken..?
why is it appending a slash if it's not a directory lmao
Mount might use mountinfo
I tried to fix it once and ... it wasn't pretty
you are right according to strace
Also, try a symlink from /proc/self/mounts (yes that’s a thing) to /etc/mtab
time for mountinfo
It’s supposed to exist for historical purposes
I already have /proc/self/mounts lol
Good
But /etc/mtab symlink?
Some tools still look for that. LFS makes it in chapter 7
They should just work lol
Maybe mount falls back to it lol
That’s why
And because it’s supposed to exist but I can add that myself later anyway
okay let's see if mountinfo just works™️
Be advised systemd (and I think technically libmount) wants to poll that file
good enough ig
yeah they're reasonable afaict
Nice
ig I should wire up stat to report the major:minor numbers as well
that's up to each fs
tmpfs stats should be fixed in general
Also the c/a/mtime
And perms / uid / gid
Should be pretty trivial
Just a few additional integers to store
why tho?
it doesn't do it when I strace mount
it does on managarm tho
I'm confused by the fact that it doesn't do it on linux
I'll look into the source later today ig
It might take some fallback path in managarm because we don't implement newer interfaces to discover mounts (?)
Maybe it polls a different proc file instead on linux
No clue why, I just seem to remember it being the case
You Might want to look into drain_libmount_events iirc
Today I'll have time to rework the fifo implementation
Based
Nice
maybe I should bump uACPI today
I assume no meaningful changes to the sysdeps are needed?
or consumers of the API
being up to date and easier bumping in the future
yeah
alright
you could also bump rust
actually, is there anything important that i should do?
regarding systemd requirements etc
xhci fixes, kde port, gnome port 
I don't really know, that's dennis' realm
2 and 3 are blocked on systemd / logind and 3 is blocked on goi being cringe
there was one semi important bug fix, but nothing huge
"SOCK_DGRAM" is too vague. what SOCK_DGRAM features are we missing?
In general test if it’s conforming to spec and review the open PR for it
imho we also shouldn't invest time into elogind
No we get that for “free” with systemd proper
at least not until systemd works
Yes please
I’ll test all of the things whenever time permits
I fear that won’t be until Wednesday tho
However, Wednesday and thursday should be full days to work on Managarm (after I write 3 not so long reports that I need to hand off ASAP)
alright, compiling the test suite and adding some DGRAM tests makes sense
afterwards, I can probably rewrite the CoW implementation
Sounds good
ok the fdinfo stuff is a bit funni for the case on anonymous inodes
inspecting linux gives me nonsense
Bruh momento
Based
ok PR updated, you should be able to just apply it
the mlibc side is easy, just add
statxbuf->stx_mnt_id = resp.mount_id();
to sys_statx
Sounds good
okay I think a problem we will run into with IOMMU is the fact that we need to exclude regions that are marked reserved in the memory map from being mapped through it
so ig first order of business is doing that
managarm iommu support? wtf did i miss
leo is bored again apparently
then port xorg
xorg is obsolete tech in maintenance only mode
Wayland gang
btw @nocturne tide do you want to PR the KVM changes?
they probably need some minor changes before merging
but nothing crazy
in the guest or from the host?
on the host
it needs to be done before the ioctl which maps a memory region
right after this
just a little loop from 0 to mem_size writing zeroes every 4096 bytes
but as you said, this won't be needed when ept/npt code gets converted to use cursor or whatever
so it's a little workaround for now
imho it still makes sense to PR the changes in
at least if you have some time to fix the comment that'll be posted during review
since that'll make testing much easier
maybe i can also do the conversion to the cursor
yeah i guess it can be a draft pr since i don't really feel like it's anywhere near ready for upstream
i'll try to rebase it today and draft a pr
code doesn't need to be perfect to be committed
@vestal sapphire btw did you make any progress on iommu yesterday after i left?
nah I was mostly just reading
i'll probably look into converting the EPT code to the cursor this evening
i expect that the iommu pt code will be pretty similar
Timing update, leaving the GF for home now, so after dinner and my administrative work I guess systemd is on the menu again
i'm available at 7pm
Sounds good, hopefully I’m done writing the reports by then
getting it upstream will ensure that it doesn't bitrot though etc
ah i guess you're not wrong
Currently cycling but I'll be available until 19:20
Has anyone tested Managarm on the HiFive Unmatched?
And: Does it use the Limine boot protocol?
no, but i would be interested to see the result
I'll volunteer to test that, then.
I don't expect it to work out of the box though
Assuming the ISO fits in <=32MB
My largest SDcard
I might be able to get it on the SATA HDD in there but that'd take way longer because I'd have to temp. transfer that to my main PC, copy it on, and transfer it back.
huh
you mean GB?
i hope you mean GB lol
who the fuck has 32MB SD cards
yeah i'm confused as well
lmao i was gonna ask whats ur smallest SD card
if 32MB is ur largest
😭
but yeha that makes sense
alright, that makes more sense 😄
the problem is that we don't have automatically built images for riscv yet
but i can send you and image
I'd appreciate that
does limine work on the unmatched?
Assuming U-boot is configured properly, yes
I know how to do that for the unmatched
- U-boot SPL (with OpenSBI) in a partition.
- U-boot proper in the second
- EFI partition
- Anything else
so i can just send you an image that has limine installed as BOOT/BOOTRISCV64.EFI on the ESP, right?
yes
but
Send me the root FS and ESP separately
Because the first two partitions require specific formatting
ok
Progress: systemd-journald yields output now
RV64 image when? :P
If you wait too long I'm going to bed
Hm, I'm still working on a different thing rn, so maybe I'll send it tomorrow instead
ok
So journald output to kmsg (aka e9) works
which allows us to see the messages of all services which is nice
journald itself is hanging in a busy loop though, so that needs to be fixed
it gets POLLHUP on some socket. for some reason it doesn't close the socket nor does it stop polling it. hence, the next poll immediately returns and it keeps looping.
I think it might expect an error from some other syscall (e.g., write()) that we don't return correctly (comments in the code in systemd indicate that they rely on error returns from other functions to notice that the socket is truly closed by the remote)
kmscon dies due to seat-related issues (unclear why it's behaving differently when systemd runs vs. when it does not run)
still nice progress
It would probably be good to write unit tests for our unix socket implementation, in particular checking:
- if the local/remote sockaddrs after connect etc are correct
- to check if disconnecting behaves correctly (disconnecting DGRAM sockets should not do anything, writing to disconnected stream sockets should error out, poll should return the correct flags after disconnect, the handling of disconnect but not yet empty socket buffers needs to be correct.)
- checking if multiple DGRAM sockets sending to the same DGRAM socket work correctly (I think the current code manages the "connected" state incorrectly for DGRAM -- DGRAM should simply not use the state)
yes, definitely
There are also a few other issues (iirc mount fails due to getopt / we could try if weston works) but imho we should focus on journald
systemd without journald is not viable as we won't be able to see log messages during boot if journald is not present
@trim eagle imho it would also be a good idea to clean up the systemd patches such they can be merged
then it's much easier to play around with it locally
Merged you say. Yeah I don’t see that happening soon as it’s still riddled with debug prints and I’m not comfortable merging stuff that doesn’t work
What I will do, is update my patches to remove some of the no longer needed prints (journald main loop) and to use fdinfo and mountinfo and see if that fixes something
I'm not saying that we should merge + enable it
but cleaning up the patches such that the patches can be merged would be good
Ofc we don't enable it until it works
this probably amounts to splitting the patches into two parts: stuff that is reasonable and can be merged + debugging prints on top that won't be merged
but for example it would be great if i could just build systemd-utils on master and get to an already working journald
After I update my patches it should just be pull my bootstrap branch and sock DGRAM and settimeofday fix and go
nice. it would still be good to split the patches into "can basically be already applied because it makes sense" + "whacky stuff that we probably want to remove"
Img? :3
That's the first thing I'll do today when i get to my PC ;D
:D
Waiting for hwdb update on qemu RISC-V is not fun 
systemd itself is probably mostly slow due to logs
It’s not helping no
https://drive.google.com/file/d/1UdYxA3VM0WNKGgaklVFcWxnWDcj_lNEH/view?usp=sharing
^ Uploaded a RISC-V image to gdrive
this is a gpt image with ESP + root partition
I guess the easiest way to extract the partitions is by using losetup -Pf image, then copying the partition out of /dev/loop0p1 / /dev/loop0p2 ?
or one could just copy out the files
Cool, I'll try that tomorrow. It's a bit late for me rn
btw I think the assumption that we need to copy out all structs to not invoke UB is incorrect
like in the case of DMAR structs, I have some memory that is previously untouched
I have a void pointer to it, and I construct a frg span of uint8_t to it
if I then reinterpret_cast a section of it to the struct type that is not violating struct aliasing and not violating alignment requirements if the struct has the proper alignment specified
While that is true in general, there is no guarantee that DMAR is properly aligned
looking at my own machines, there is none where DMAR is misaligned but there is one where RSDP is misaligned, for example
seems that the alignment is not even consistent among multiple AMI firmwares 
one machine that i have as page aligned ACPI tables
the others have 8 byte alignment
DMAR structs should be packed tho
if you have packed structs and you're careful you can get away without memcpy
but packed itself is questionable
packed generates single byte loads on some archs 
yeah but that's correct then
right, but memcpy + non-packed would be more efficient
it's better to copy it out of unaligned memory once
depends on what you want to trade, time or memory 
personally, I'd avoid packed
it's an unfortunate attribute that conflates packing with external alignment
it did to me just as you said on riscv builds
but adding the aligned attribute lets you provide the external alignment you want and that corrected the code generation
rust did not offer that privilege. anyway, it's not as much of a loss to go without packed if you're in C++
good to know that an alignment attribute fixes it
rust for its part has not got this
their equivalent of packed reduces external alignment to 1 unconditionally and is incompatible with the attribute that increases external alignment

Based
current state is:
- I can set up the IOMMU, including knowing which PCI devices go through it
- I deny all DMA requests
- I can log faults
ig next step is having a hw proto request to allow passthrough of DMA requests
Nice

can you set up passthrough on a per-device level? or do you need to construct PTs that contain all RAM?
I can just set a bit per device (per function even) to just do pt
if the IOMMU supports that
can you support SMMUs?
at least on a theoretical level
(or DART/SART on apple real hw)
probably yes, I haven't looked at them yet tho
(keep in mind that DART/SART have fixed 16k page sizes)
anything that's emulated by qemu is probably going to be done first tho
virtio-iommu is kinda unnecessary tho
qemu supports emulating both VT-d and the AMD equivalent
we already need 2 anyways
I'm setting this up to be a generic interface specifically to also support SMMU down the line, should be good enough
arm SMMUs work a bit differently, AFAIU they have a finite number of "stream IDs" that you can use to associate devices and PTs
but idk the details
but that's also the case on x86
ah maybe not
you can have multiple iommus and there's a device <-> iommu mapping in the DRAT
ah yeah
okay
ah yeah and there is the other more different iommu used basically only for nvme i think
or maybe other things too nvm
okay I can kinda boot with the IOMMU in passthrough mode
virtio-block is being weird about it
does it fault?
no it just waits for half a minute
yep

very nice
nukes shouldn't use Intel IOMMUs?
uh, this is very hard to read
yea discors compression
can you find a frame that's somewhat readable and upload that as an uncompressed picture?
@vestal sapphire something for you to fix just dropped ^ 


actually maybe i can also fix that
context: i have 4 m.2 nvmes in my system and 1 via usb c
doesn't seem nvme related
Hmmm, i'm a bit confused
but i can take a look at this in the evening
seems that the MSI allocation succeeds but the installMsi request still somehow errors out
what's strange is that we don't see this message: https://github.com/managarm/managarm/blob/master/kernel/thor/system/pci/pci_discover.cpp#L394
and afaict we should get to the auto descError = co_await PushDescriptorSender{conversation, IrqDescriptor{object}}; on this code path
which should cause the client side to succeed
Marvin if you have some time you could add extra logs to the thor code path that i linked above to check if we fail somewhere or if we get to the PushDescriptorSender
the vid doesn't play for me lmfao
doesn't play either
lmao
ah vlc works 
plays for me but the compression makes it useless
i wonder what packages i'm missing to make this video play in firefox
libavdecode 
i mean it must be some specific codec since other videos play
hmm could it be that the NVMe just supports a single MSI vector but we try to use two?
it's h264 avc
The video also doesn't play for me with the official discord .deb, i had to download it

