#Managarm and related projects
1 messages · Page 6 of 1
why stack exhaustion btw? Irqs should never exhaust the stack no matter how frequent they occur
yeah we could do that
BadgerOS does this regardless of architecture or SOC
It has one generic file for dealing with it and defers timer specifics to the timer's driver
hmm maybe not then
idk it jmp 0's at some point
or maybe not actually hmm
Stacks are hard to debug if you don't have any guards around them
Specifically that overflow guard; does Managarm use one?
uh
okay so i dont know why
but i think that 2^64-1 is not a valid value for cntp_cval_el0
that's just basically infinity far into the future right?
what my m1 treats it as, however
we could also mask the irq in the control reg
is infinitely far in the past
Could this be a problem?
also, i think the problem is that we try using both the physical and virtual timers
Is it not treated as unsigned?
afaicu we should only ever use the virtual one, otherwise we'll see jumps in the raw timestamp due to the host scheduling differences
Managarm does have guard pages on kernel stacks, yes
yes but apple
resetting cntp_cval_el0 to 0xFFF'FFFF'FFFF'FFFFULL works
or alternatively, only ever use the physical timer if we don't mind those jumps
but we need to always use one or the other if we want all timers to be in sync
If it causes an immediate irq while we expect it to cause an irq only in 300 years, that'd obviously explain the problem 
yeah it does
lol
the timer does work as normal though
currently it reads 10537447172497
Is there any reason you don't just disable the alarm in some way?
suspiciously close to my uptime
i thought writing all 1s would always work
but as i mentioned we can just mask the irq in the control reg
RISC-V does guarantee that for its equivalent but a quick skim of the ARM docs for this timer doesn't seem to say so
LMFAO
it does
but hear me out
its an apple
Like those apple USB extension cords that only fit their keyboards
lol
ffff...fffe also works
apple moment lmfao
oh wait is this the virtual timer??
hmm
i dont know and i dont care
its one of the two
the linux devs yearn for auto ```c
if (type == ARCH_TIMER_TYPE_CP15) {
typeof(clk->set_next_event) sne;
uh yes i think its virtual
wait
wtf
i need to more carefully test this before i get confused
ok nevermind
fff...ffe does not work
Cannot use kernel for 300 years of continuous uptime, literally unusable
i wonder what's the longest uptime you could get on linux before it croaks
Maybe it's not that it treats it as signed but that it ignores writes with reserved bits set?
If it implements less than 64 bits
IT WORKS
nice
pog
meanwhile, systemd getting closer and closer
what about mkdir foo && ls -la foo?

hmm i dont even know if its actually the issue
i now got this stack trace
which is not inspiring confidence
lmfao
lmao rip
oops lol
Have you considered double / triple fault handling? That helped me debug ISRs and trap handlers early on in BadgerOS.
address 456
yeah idk
nah, not just 32-bit in general, we need Managarm for 32-bit PowerPC 
cache stuff could be likely
does that work?
yes
amazing
this is the power of a good icache 
i would've imagined the page table caching would've been correct
i know icache management is borked
i have a patch lying around locally somewhere that i should clean up and push
face it
to flush icache when faulting in an executable page
Do we need a "it isn't cache\nit's never cache\nit was cache" T-shirt?

i mean your patch is flushing the tlb :^)
yeah
oh
lmao
i guess the m1 has negative tlb entries
wait wtf
where do you flush the tlb?
when reusing an asid
im just gonna go around and fix your tlb maintainance logic lol
this patch probably doesn't apply (and it's too heavy-handed since we only need to flush the icache, not all caches)
but i dug it up in my git stash
at entry 37 
lmao
what's wrong with it exactly?
missing?
hmm wait no
uh
okay i think the issue is that you are missing a reordering fence
yes
you must use DSB ISHST; ISB after updating page tables
okay that makes sense
yeah so i added thor::pageTableUpdateBarrier();
and now im spamming it out after every map
wtf
what is this code
void KernelVirtualAlloc::unmap(uintptr_t address, size_t length) {
assert((address % kPageSize) == 0);
assert((length % kPageSize) == 0);
// TODO: The slab_pool poisons memory before calling this.
// It would be better not to poison in the kernel's VMM code.
unpoisonKasanShadow(reinterpret_cast<void *>(address), length);
for(size_t offset = 0; offset < length; offset += kPageSize) {
PhysicalAddr physical = KernelPageSpace::global().unmapSingle4k(address + offset);
physicalAllocator->free(physical, kPageSize);
}
kernelMemoryUsage -= length;
// TODO: we could replace this closure by an appropriate async::detach_with_allocator call.
struct Closure final : ShootNode {
void complete() override {
frg::slab_allocator<CoreSlabPolicy, IrqSpinlock> coreAllocator(corePool.get());
KernelVirtualMemory::global().deallocate(reinterpret_cast<void *>(address), size);
Closure::~Closure();
asm volatile ("" : : : "memory");
frg::destruct(getCoreAllocator(), this);
}
};
static_assert(sizeof(Closure) <= kPageSize);
auto p = frg::construct<Closure>(getCoreAllocator());
p->address = address;
p->size = length;
if(KernelPageSpace::global().submitShootdown(p))
p->complete();
}
``` im sure im reading this wrong
but this seems like a kernel UaF
the kernel frees the backing page
and only then dispatches a TLB shootdown
that is uh
very incorrect
it doesnt have the same considderations as userspace code
yeah i realized now
u can Assume nobodys touching it by then
that lets u batch kernel virtual memory shootdowns a lot more aggressively and stuff
this is a kernel code path so its fine
as in you can literally just let it get completely full and never actually "free" any virtual pages
until its totally full
then you free everything that was freed previously and do a single shootdown ipi
and have basically eliminated kernel vm shootdowns
potential managarm improvement right there since it seems its doing a shootdown per virtual page.
let's see if the arm gods are happy
panics on thor: ECAM interrupt-maps with non-zero parent #address-cells are unsupported
yeah its the standard qemu interrupt swizzle i think
it's strange since this works in qemu-virt without kvm (and on an rpi4)
maybe the vgic stuff is messing with it
well you can submit shootdown nodes of N pages, and if a node says to shootdown over 64 pages (or was it 64k? idr) we just shootdown the whole asid instead (not in the kernel though, since there's no "flush all global pages" on arm for example afaics)
i suppose an improvement would be if a shootdown node could point to multiple ranges of pages at once
to avoid multiple ipis
No IRQ controller associated with /intc@8000000
uuuuuuh what
it's an arm,gic-v3
oh that might be a me issuee
korona changed how the dt stuff works a bit for interrupts when porting to riscv to make it less ass and i've said i'll port the arm side but haven't gotten around to it yet
does managarm have deadlock detection
surely you can flush all global pages on arm
that sounds like a major oversight
whole tlb works
well it works but that throws away more than we want
its not a big deal if the batching is as extreme as what i gave (allowing the entire dynamic kernel va space to get filled up before you actually free and do a single shootdown)
practically undetectable
true
that in itself could cause a latency spike though from how much "actual" freeing youd suddenly be doing so youd probably batch much less than that
but still it wouldnt be a big deal
we don't
:)
what about measures to avoid priority inversion
like priority ceiling or priority inheritance or random boosting
okay i think it got to userspace!
no graphics though
i'll give it like a 50% chance its my shitty interrupt code
afaict we don't implement anything to prevent it currently either, but we also don't really change thread priorities at the moment (except for the ps/2 and virtio-console boosting theirs since they need to respond more quickly)
ps/2 since the controller has a small buffer and we might miss data otherwise, virtio-console since it's used to dump kernel ring buffers for things like the kernel profiler or allocation tracing and we don't want to lose data
anyway i should stop procrastinating working on stuff i'm supposed to be doing
yeah idk it still doesnt work
Yeah priority inheritance is definitely a feature that we're missing in the kernel
and that we should implement sooner or later
i recommend doing it with turnstiles
theyre cool
yea that might be a good idea. One question that I still wanted to research is whether we can also do priority inheritance over IPC. Basically, let one process cooperatively donate its priority to another process
That would be useful for example if a high priority process (say, sound driver) needs to request something from a normal priority process (e.g., USB host controller driver). You probably don't want the USB hcd to always run at a high priority, but if it needs to process a request by the sound driver, it would make sense to boost its priority
that's pretty weird, did you figure out why we don't recognize the gic-v3 in this case?
the arm code never calls associateIrqController
that define is missing __ in the end
uhh
Managarm does handle double faults, that was not the problem in the stack trace posted earlier
now i'm confused how this ever worked (since i changed that line)
yeah that's a good question
maybe it was never tested properly
that's probably the case. if i fix this, then it boots for me
although for some reason Weston gives no output despite finding virtio-gpu? CC qookie. Might also be a problem on my side though since not all packages are up to date in my aarch64 build
I also had issues with weston last time I tried it on aarch64
okay
time to look at my buggy gic code some more
oh also
netserver crashes on arm
Legacy transports are unsupported on this architecture
hmm now that i think about it
this is really fucking weird
why am i not getting kmscon?
you can disable virtio-net in vm-util.py
its still kinda weird that it just hangs there forever
for some reason the virtio-net crash makes udevd hang for a minute or so
not sure why it doesn't just continue
ah okay
its trying to run weston now
which fails because i dont hate myself enough to build weston
okay
now thats back to working
the performance is still not great
so it works now on M1 kvm?
yes
that's nice
although its quite slow
dont know if its managarm, my m1 or qemu
or something else
how slow is quite slow? :^)
significantly worse than linux in muvm
It's expected that it's slower than Linux but if it's really slow, something else may contribute to this as well
should be way faster than x86 with tcg though, isn't it?
it is faster
it feels like more latency than n00byedge's vps which is 50ms of network latency
you mean when typing?
what's weird, latency on x86 is certainly way smaller than 50ms
what is time ls?
165ms
huh
sometimes 230-240
it's 10x faster for me on x86
i wonder if we're doing something that makes aarch64 kvm choke
by doing too many exits or so
i'll try profiling
apple_firestorm_pmu/cycles/P: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' nevermind
hmm i wonder if its the memory barriers i put in a bunch of places
they are required for correctness, though
Assertion failed: physical != PhysicalAddr(-1) && "OOM"
Assertion failed: physical != PhysicalAddr(-1) && "OOM"
In function fetchRange at ../../../src/managarm/kernel/thor/generic/memory-view.cpp:1799
In function fetchRange at ../../../src/managarm/kernel/thor/generic/memory-view.cpp:1799
``` oh and at some point this happens
that's not worrying or anything
i have 2 gigs assigned
this is a vmexit
that msr
about 18% of them
that can definitely be improved
i can actually probably do that in the evening
we use IPIs to ping remote CPUs when threads are resumed by we don't make a lot of effort to suppress them when they are not necessary
weirdly, if i run while true; do time ls; done then the times do seem to come down
before it all, uh, crashes
posix: Thread killed as the result of signal 2
ah thats just me ^C ing it
nvm
this is weird
uh. host-qemu doesn't build
meson complains about relative -Dprefix ../../../src/ports/qemu/meson.build:1:0: ERROR: prefix value '../../build/tools/host-qemu' must be an absolute path
huh
ig we never tried building host-qemu on a non-x86 machine
dunno why this specific error is a thing tho lol
xbstrap should make that an absolute path tho
idk why that is relative tbh
you mean automatically doing that when you block on a message from other process?
Automatically doing it is probably not possible but it would be nice to integrate it into the ipc syscall
such that it doesn't add any substantial overhead
funni idea for porting binary stuff: we could just implement something like prctl(PR_SET_SYSCALL_USER_DISPATCH, PR_SYS_DISPATCH_ON) and have an adapter interface?
why a prctl?
doesn't really make sense as an emulation control API though
if anything personality(2) is a better fit
or a sysdep, mlibc::sys_set_user_syscall_handler(address) which will make the kernel return to address whenever it gets a syscall
well it would be for running linux binaries on managarm where we can keep the dynamic linked stuff but need to catch syscall()
we could probably make our observer stuff catch syscalls
e
i dont understand why you would use a prctl for this
depends on what level we'd want to emulate the syscalls
i mean, doing it in process would make a lot of sense
personality(2) turns this into a pure kernel/posix-subsystem thing, while prctl defers to a userspace handler
you dont have to use a linux syscall anyway
try the mach "Emulator" mechanism
it's called "doing your own design instead of shoehoring extra functionality into linux apis where it does not make any sense"
ah
I'm not inventing anything here
ahhh
best username on gh btw
How would that be different from implementing syscall() as a giant switch in mlibc
Maybe i misunderstand the goal
Is the goal to run linux binaries without recompilation?
syscall() can be inlined into the caller code
honestly having a linux emulation layer inside of mlibc would be very cool
I am pretty sure that on glibc it can't
its just a normal variadic function not defined in a header
not everyone uses glibc
and sometimes people inline their own syscall instructions regardless
usually non-glibc binaries are the ones that also have source available
fair
but yeah ig its possible that there could be manually written syscall instructions
syscall might be a macro with inline assembly
nvidia my beloved
though with this kind of syscall emulation thing wouldn't it basically need a chroot (if you don't want to have a mlibc compat layer binary)?
with like all the X and whatever libraries + nvidia libs + the programs you want to run all compiled for linux
I haven't thought about it too much 
If you want to support linux binaries unmodified, just port kvm and use qemu-user or gvisor :^)
We have qemu, so just KVM is left 
pcie passthrough is a thing
you go implement that kthx
reverse virt-gpu 
nested virtio-gpu
If you add kvm, I'll add passthrough ;D
don't tempt me with a good time
I see a new target after systemd 
Oh Leo, you were doing network memes, maybe you can look at implementing loopback interfaces?
(And not for me mind you, systemd -> logind -> KDE and GNOME (once we fix G-O-I))
The KVM stuff? Probably make a device node for it and log whatever stuff gets done to it. Then hook that up
i had some stuff done locally but
oh well
the async stuff won
i don't understand how any of it works

i have been offered help btw, so it's totally a me issue
if leo doesn't get to it i might take a look at it another day
gvisor would be incredibly based
Pitust's vmexit stats prompted me to look at perf stat kvm on my x86 machine and I noticed that for <= Kaby Lake (= my host), KVM perf can be improved by a solid 40% by doing -cpu host,-umip 
this doesn't affect newer intel cpus though
the reason is that KVM devs apparently decided to emulate umip no matter if it's supported by the host or not
by trapping every table access including ltr
lol
which we do on task switch when the I/O permission bitmap changes
That might be a good one for me too
anyways I have 8 PRs in queue for review, I need to work on something that takes a while to empty that queue
Loopback????
I'll try to reduce the number of ping IPIs later today
that seems like a low hanging perf improvement
afterwards I'll probably either do imsic on RISC-V (as that might be less broken than plain aplic in qemu) or may better OOM handling
@carmine current may I also suggest fixing the load balancing PR?
yeah
Highly based
what is umip?
oh HOLY FUCK
user mode instruction prevention
disables sgdtr and stuff like that in user mode
oh also
managarm crashes if you try profiling on !x86
/*
* PMC[0-1] are the 48/64-bit fixed counters -- PMC0 is cycles and PMC1 is
* instructions (see arm64/monotonic.h).
*
* PMC2+ are currently handled by kpc.
*/
pmc0 is S3_2_c15_c0_0
(just making some notes around m1 profiling)
pmc doesn't seem to work inside qemu
also one thing which should be implemented for aarch64 is user access prevention
though its not really that difficult, just have to check for pan support and if its supported then use msr s0_0_c4_c1_4, xzr to enable it and msr s0_0_c4_c0_4, xzr to disable it (idk why there are no proper names for those msrs)
no hits in linux
maybe it uses the pstate to change it or whatever
yeah
I think I got these msrs from optee
also annoyingly
linux doesn't enable PMCs for guests
😦
damn, i dont even know if that is possible on m1
actually looks like the naming is a skill issue in llvm, on gnu as it works just fine with msr pan, 1 and msr pan, 0 (not that it really matters, you can still use the msrs using the unreadable binary encodings)
yeah i think apple PMCs are just unusable in kvm
that's sad
x86 PMCs work generally fine in KVM
it doesn't support all PMCs that native supports but that's expected
or maybe not
i do not know
i suspect this is at play
(xnu code)
so i suspect that PMC N for N in [0, 7], at EL1, is 1<<(16+N) in PMCR1_EL1
idea.
what if i write a kernel module to set it
security is boring
lol
0xffffffffffffffff sounds like a secure value for PMCR1_EL1
managarm m1 when
just enabling it is probably not enough, it also needs to be context switched by kvm
s3_1_c15_c1_0
otherwise you're also measuring the host
what context, context is boring
the host is cool too
:^)
i'll just kill firefox
or make sure my system is quiet for testing
hmm actually
that could mess with linux really badly
yeah maybe i won't do that
now that i think about it
or rather, enabling IRQs could
because that definitely needs saving/restoring
so yeah i wont
yeah true
if linux kernel code wasnt so crap, i'd consider implementing PMC support for linux
actually i think i also can't contribute to asahi now that i looked at the xnu code
isn't xnu open source?
yeah, under an apple-flavored GPL
just looking at code doesn't mean that a re-implementation violates copyright
soo how is it an issue if linux is also gpl
ah no i can read it
it's incompatible
if it did then people would have to take the same attitude to looking at more liberally licenced code too
but aiui its a real open source license
I'd say that as long as you literally don't copy code its going to be fine
none of the liberal licences permit the licence text to be expunged
so if applying the same principle, any time you read BSD or even MIT licenced code, you'd be having to reproduce the licence notice
yeah
how exactly
i do not know
obviously if you try to memorize the literal code and try to replicate it from memory etc the story is different
oh APSL is also free software
but reading the algorithm and re-implementing the idea is not a copyright violation
yeah
anyway it can totally count cycles and instructions
lets unshallow my copy of linux and try more aggressive grep
and yeah kvm doesnt expose them to VMs
are the PMCs apple specific? or architectural for aarch64?
apple specific
not passed to VMs without a special entitlement on macOS, not passed to VMs at all on linux afaict
hmm perf kvm record fails with apple_firestorm_pmu/cycles/Pu: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
wtf why don't they support overflow interrupts
they... do
i think the driver is just broken tbh
ig the next wide sweep I could do is this
for improving the request logging experience
so that a symlink request log might look like
result on e9
couldn't you implement logging more generically?
just send a copy of every request to dmalog
and then support bragi in wireshark :^)
Maybe you could also make it more general by using some kind of attribute syntax
cant we use something off the shelf?
<< req_log::Attr{"from", ViewPath{...}} <<
Might also make sense to not log directly to stdout
that way we could wire it up in such a way that you can get the log in a machine readable way and only for some processes etc
i'd just dump the data to dmalog
a new dmalog channel
and then have a machine analyzer on the host as the only way of reading it
ngl that's actually not that bad of an idea
anyways the nice thing about converting it to lambdas is that switching it over to something else becomes easier
@trim eagle thoughts?
Approved
I was more asking about the pitust idea
we'd need to make up a special format that encodes some data like PID and protocol (fs vs posix for instance), and then append the bragi message
ig we could also try to use virtio-console
I mean, I wouldn’t necessarily make it only machine readable. The e9 logs as is are valuable (even tho the information logged could be better). But for the really extensive logging dumping it to a file and wiresharking it sounds pretty good
yeah we can just make the output configurable so that you can get (maybe even configurable selective) e9 logging + a wiresharkable dump
might even be helpful for stuff like systemd
Yeah. That sounds good
so I think step one is doing what the screenshots above hint at, which is prettier request loggiing on e9
Yeah that would be nice
hmm if I try to .getPath() on the pathResult in the readlinkat request handling I get a treeLink() not implemented for this FsNode exception
again
pls gib
Unfortunately I can’t access that rn
NOOOOOOOOOOO
So gimme a sec while I think hard to get it
is it a fix to getPath?
ah
If you check pts.cpp, there’s a globalRootLink or something like that?
Make treeLink return that
That’s what I did with Korona
That works?
that could simply be another bragi msg in front of the request
bragi msgs are self delimited anyway
for example ostrace is basically just a stream of self delimited bragi msgs
you can also re-use ostrace for this purpose btw
ostrace already logs all posix requests and their running time here: https://github.com/managarm/managarm/blob/master/posix/subsystem/src/requests.cpp#L3726
but not yet their parameters
that'd be easy to adapt though
we fixed treeLink() in dennis's checkout in pts RootNode and in the procfs fd directory node
i grepped for all directory node implementations and that were the only ones where it was missing
what do I return for the procfs fd node treeLink?
Yeah uhhhhhh I have that locally but I forgot to commit it
So I don’t have access now as I only have my laptop
ok I think I have iit
basically the same that the root dir does
you create the Link, the somehow tell the directory node about the Link
hmm it's a bit more annoying as it gets directMknodeed
you could also check if it's possible to add the logic to directMknode
or some directMkdir
template<typename T>
requires requires (T t) { {t._treeLink} -> std::same_as<Link *&>; }
std::shared_ptr<Link> DirectoryNode::directMknode(std::string name, std::shared_ptr<T> node) {
assert(_entries.find(name) == _entries.end());
auto link = std::make_shared<Link>(shared_from_this(), name, std::move(node));
node->_treeLink = link.get();
_entries.insert(link);
return link;
}

Yeah that works
seems cleaner to have a directMkdir though instead of adding an overload that silently does something extra 
YOOOO LOAD BALANCING IS MERGED
ok it works now
I have a local patch to avoid self IPIs when resuming threads
that gives a nice perf boost, at least inside virtual machines
Now the most frequent vmexit reason is IO_INSTRUCTION
can perf tell me for which RIPs this occurs most often?
Highly based
okay now the vmexit stats look sane
Awesome! We might want to try glxgears and see what the FPS is now
Obviously but 200 FPS is pretty damn good
Highest I’ve ever gotten on my laptop was 120
If / when patches are posted I’ll try it on the laptop
Once before LB and this work and once after
I specifically tested this on linux
when you have a socketpair, and process A writes to one end and closes it, and process B attempts to read later, it will first successfully read the written data, and only on the next read get EAGAIN
Do you also get EAGAIN if the socket is blocking?
no, that just hangs
hmm maybe that check is unnecessary to begin with?
I'm not sure
the man pages aren't helping me with this tho
what the hell are yall speaking?
minecraft enchanting table?
ig the next bugfix I'd want to do today is the funni upower crash
Sounds good
I'm asking because the snippet that you posted doesn't check for nonblock
that's fine
however that made me notice that the check is not really correct there I think?
hmm I don't really get how the env gets corrupted
the bt for it is pretty interesting too
it seems to use gettext to print some message about a task getting cancalled
Gettext my beloved
Do not post off topic memes
please
e
you have machine readable logs, and then a program which concerts them to the stuff we have right now?
Going from machine readable to formatted is easy but the other direction is not
@trim eagle at the recommendation of korona I just correctly implemented unix socket stuff like DGRAM/STREAM and related memes
honestly that might just fix a few funnies all around
I like it a lot
I’ll rebase my Managarm tree for systemd on Monday (I expect VC chances to be decent)
about the comment proposing the intrusive list for keeping track of the sockets, that doesn't quite work tho, right?
we need a shared_ptr for servePassthrough and that in turn means we can't really append to the list without hassle
What's the issue?
We can pass a shared_ptr to servePassthrough and add a raw ptr to the intrusive list
how does an intrusive list handle a raw ptr
what would the issue with that be? if the object has a list hook then you can append that to a list just fine
afaict boost intrusive list doesn't work with ptrs?
not sure
the docs aren't helping tbf
from the docs looks like it takes in a reference in which case it would work
just use frg::intrusive
we should get rid of the boost dependency
But yes, boost intrusive takes references and it doesn't care whether that reference is produced by dereferencing a shared_ptr or a raw ptr etc
frg::intrusive just takes raw pointers
with the recent perf fixes in, I decided to run a basic test to see what performance increases we got. So I ran glxgears 5 times on a system without the load balancing and the IPI fixes for 35 seconds each run (glxgears reports FPS every 5 seconds) and did the same on current master. Averaged them together and had the following results
without load balancing and ipi fixes
run 1: avg over 35 seconds: 86.736 FPS
run 2: avg over 35 seconds: 98.062 FPS
run 3: avg over 35 seconds: 98.223 FPS
run 4: avg over 35 seconds: 101.097 FPS
run 5: avg over 35 seconds: 100.724 FPS
total avg: 96.968 FPS
with load balancing and ipi fixes
run 1: avg over 35 seconds: 102.791 FPS
run 2: avg over 35 seconds: 99.637 FPS
run 3: avg over 35 seconds: 114.354 FPS
run 4: avg over 35 seconds: 98.559 FPS
run 5: avg over 35 seconds: 114.580 FPS
total avg: 105.984 FPS
gain: 9 FPS give or take
nice
yeah
i considered doing only machine readable logs for shkwve actually
pitust, do you want to PR your M1 changes?
or post a patch such that we don't forget about them?
sure i'll do that
its all horrible and ugly
i'll try untangling it some more i think
the entire diff is https://paste.sr.ht/~pitust/4a8939d9a4279075da86de1d9a61f0a88bb65eec
but thats also the umask stuff
i'll split it up into commits in a sec
ah theres more in the managarm/managarm repo too
the bootstrap-managarm changes are https://github.com/managarm/bootstrap-managarm/pull/440
so circling back to the credentials memes, ig it's time to also make the helix stuff return std::array
and maybe to use a type for credentials
I was thinking of something like this
struct CredentialsView : std::span<const char, 16> {};
struct Credentials {
Credentials(char data[16]) : data_{
data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7],
data[8], data[9], data[10], data[11],
data[12], data[13], data[14], data[15],
} {
}
auto operator<=>(const Credentials &c) const {
return this->data_ <=> c.data_;
}
operator CredentialsView() {
return view();
}
CredentialsView view() {
return CredentialsView{data_};
}
private:
std::array<const char, 16> data_;
};
with the credentials + process changes
and I'm getting ~440 fps on glxgears
Did the uacpi score change
prob not
I did however work on some long-standing things we wanted to improve in posix
and korona did some performance-enhancing work
but that is scheduler-level or IPI stuff

2025, the year of the managarm desktop
Indeed
You bet
we can probably get another 50% perf by allocator and kernel data structure improvements 
but that requires a bit more work
squeezing every bit out of the kernel so we can put off optimizing the actual bottlenecks 
we've already seen and felt massive speedups in the past weeks ngl
One big improvement in userspace would be a dentry cache in libblockfs
holy shit
why libblockfs?
i think that's the wrong place
it's analogous to how BSD traditionally did namecaching prior to DragonFly BSD, and Linux also does it the DragonFly way
a much nicer approach is to handle caching in the VFS layer
let's start small
that is to say put it in libblockfs is like put it in the vnode layer, but since your vnodes are a protection boundary away from the posix server, you pay an even greater penalty
2025, the year in which managarm is actually reasonably fast maybe
I could seriously daily drive managarm if it wouldn't crash all the time
debug the crashes 
you miss out on things like the posix server being able to resolve a path into whatever your vnode equivalent is (some entity on the libblockfs side) without actually needing to contact another server
also you still dont have a web browser do you
I have everything I need: Ethernet (e1000), LTE (USB CDC MBIM), USB, webkitgtk for browsing, and a mail client
oh do you
webkitgtk
i thought it was broken
works for me
it's reasonably stable
so that's my position on where you should put name caching in managarm, ask me if you want to know more (i looked into name caching quite a bit), i trust i won't get the serenityos treatment for this
the crashes are stuff like timer overflow or posix commiting seppuku over what should be error returns
I'm always willing to learn about new approaches 😄
it was a facetious comment (mostly)
Well, libblockfs would have the advantage that the would be no need for cache invalidation in another process
If the vfs does the caching (which sits in the posix server) and something changes on the libblockfs side, we'd need to invalidate the cache somehow
what would change on the libblockfs side?
the advantage of caching in posix is that it also allows for a nice impl of mounts
the principle of a dfbsd/linux style namecache is that it is actually more than a cache, all changes affecting the namespace go through it, so incoherence of the namecache with respect to the filesystem should happen only with the likes of NFS or 9p
i don't think linux revalidates 9p, actually
it probably doesn't, it's 9p
yeah lol
i have no idea how NFS regains cache coherence but i do know that there is a generation number involved
and probably locks
I'm not sure caching stuff should be a higher priority than uncoupling libblockfs from ext2
it sort of assumes that
if you want correct but complicated client side then you use NFS which provides reservations speculatively that guarantee consistency for you, and has a protocol for revoking these, as well as a timestamp for revalidation
like downcasting to ext2 structs in some places
or you can just not
holy shit what
aaaaaanyway
yeah libblockfs is basically libext2fs right now :^)
namecaches should be first, most likely
but i don't think it's such a big deal actually since filesystem internals differ by quite a bit
so i expect the shared code to be small when we untangle it
because it affects how you architect the backing fs
honest to god libblockfs is the only eyesore in managarm code remaining tbh, maybe except for the use of boost
that touches on another area, namecache in posix server will work for both ibblockfs and for whatever will provide 9p/nfs to managarm
how does nfs actually achieve coherence?
not sure how we would even go about implementing 9p or nfs tbh
what about posix/subsystem/src/requests.cpp where every second if does not follow the clang-format file?

in posix it would be mounted as another extern_fs
caching in posix would certainly be faster, i agree
it's also a better approach, in general
it speculatively gives out delegations that act as reader or writer locks on directory contents
and in turn it also revokes them
so its basically just classic leases
i don't think it does anything to prevent the host changing things from under it, but they would disapprove of that anyway
there are a lot of horrible cases i have no idea what happens on linux or any other system, like someone mounting over /nfs/mount/subdirectory and some other client unlinks subdirectory
so how does it work if, say, one client opens foo/bar/baz and another client renames foo/bar to foo/bar2
you still have a handle to foo/bar/baz
the thing you get has the filesystem id
and inode
and a generation number that is random
oh and there is no signature over any of this by the way, because those are boring
oh and 0 is a valid generation for every file handle 
iirc with mount namespace linux gained the ability to rmdir directories that still have mount points
client one has the open file, that'll stay open, if they held a directory reservation on foo/bar that will be revoked prior to the rename being carried out (there are also time limits on how long a cached result stays valid for)
iirc that was done to avoid a DoS attack where you mount over a dir inside a mount namespace to prevent its deletion on the host
so that timeout deals with the case where a client doesn't acknowledge revocation of the reservation timeously
ah i see
actually if we want to revalidate cache entries, we could make that really fast by putting some "is still valid" flag into memory that's shared between the posix server and the fs server
wait does your OS have gnome???
We have ran some gnome applications yes
not (yet)
cool!!
@carmine current I'd like to report an OOM after running glxgears for like sub 4 minutes
from limine enter to OOM I note 4 minutes 20 seconds
while true; do ls; done also provokes an OOM
that's at least partially fixed by a PR by leo
were we accidentally retained a shared_ptr to a process in posix
glxgears needs investigation though, probably by adding memory consumption traces to ostrace
That would be good yeah
I think we're now pretty close to having everything needed to run systemd-udevd upstream once #1232 is merged, except for the bits that break ABI and the package itself
All the more reason for me to get going on the init portion so we can get both at the same time potentially
I'm currently taking a look at the linux __UAPI_DEF_* memes, the other ABI break stuff is ready
I'll try to get the abi-breaking changes ready for a PR ig
but
maybe I should combine this with the ABI checker that I worked on a while back
that pointed out some funnies, including the ones I fixed for udevd
I'm not sure how usable it is in its current state for ci tho
./src/mlibc/scripts/header-abi-compare.py ../glibc/sysroot/usr/local/include/ build/packages/mlibc-headers/usr/include --help
usage: header-abi-compare.py [-h] [-m] [-M] [-f] [-s] [-t] reference mlibc [file]
positional arguments:
reference reference headers
mlibc headers to be checked
file limit scope to this file
options:
-h, --help show this help message and exit
-m Search missing functions
-M Compare macro definitions
-f Check function signatures
-s Check structs
-t Dump tree (debug + extremely verbose)
ig I'll work on setting up a PR that addresses all (relevant) ABI differences spotted by this, including the stuff necessary for systemd-udevd
I gtg for now tho, so I'll continue tomorrow
I think the ABI checker might even be good for CI tho
but only if we maintain a configuration that blacklists some stuff for which we can safely diverge from our reference
I only tested this against glibc so far, it might be interesting to do this against musl and bionic as well ig
I don't think we should care about libc abi differences
(we should care about OS abi of course but we should not aim for glibc ABI compat)
and also, any changes in this regard should not block udevd progress
thing is that systemd hard-asserts some constants to have certain values
GRND_* comes to mind
GRND should match for Linux anyway
Considering we run the Linux abi we switch with it
basically anything that is passed to the kernel in linux needs to be a 1:1 match anyways
Yep
the rest, ig that depends on the individual thing
like
I don't think changing NSS_PASSLENGTH is necessary
but F_TEST and parters might be a consideration
flags passed to lockf that is
basically my aim is to try and resolve all outstanding ABI differences that we would want to address
the scripts is just a tool to generate the list of things to look at 
GRND_ is OS abi not libc ABI
My answer to "that we should address" is: those that are linux kernel ABI
but for udevd/systemd we should only address the subset needed to make systemd work
When will managarm have swap
Help me port systemd and we get oomd 
be the change you want to see
Real
Okay
Where is managarm's VMM code
Is it in some server thing
Actually no microkernel sounds unfun to write a VMM for
Or not unfun
But too much design to consider
Anyway what I'm saying is that I'd make a cluster fuck out of the VMM code
Address-space.cpp in Thor comes to mind
the code for memory objects is in memory-view.cpp
1k sloc is not that much for a proper vmm ;D
swap has not really been a top priority for us yet
Managarm can swap file backed memory just fine, it just can't swap anonymous memory
ah i think the reason PMCs dont work on m1
is because they are marked as "TODO" in the driver
:^)
You can check if the reduction of IPIs made it faster on the M1. This is now merged to master
I also want to do some more changes to reduce the number of cpu timer updates
More performance == more better. I like
Ok, the plan for today is to get bragi to autogenerate Wireshark dissectors
After that ig it's time to make the dumping code pretty and integrate it into all protocols
👍
Pog
bragi
wireshark
what did i miss
I'm dumping all managarm ipc, writing that into a pcap, and loading it up in Wireshark
Basedness
ok that is exceedingly based
Are you in VC today, leo?
yes, starting now
@trim eagle wireshark bragi dissector, but now autogenerated from bragi files
I do not handle tags and tails yet
it's good
I was a bit lost at times but mostly just skill issues
like I searched for a way to obtain the offset for a fixed message member
until I noticed (and korona pointed out) that I need to just add up all prev members
I'd like to revise my previous statement
I now get to implement varint parsing in lua 🤮
fun
tag-based messages now work
hmm what if we adapted ostrace to dump pcap over dmalog instead of the ostrace format on request?
that would be super nice as you could just Ctrl+R in wireshark while managarm runs
anyways now that bragi decoding seems like a mostly solved issue, time to clean that up and push it somewhere
I don't think that makes sense. But you could just launch the conversion program in parallel with qemu
super cool
now you just need to get a properly allocated pcap protocol id
Nah I'll just keep using USR0
I'll probably remove bragi from rootfs and name it a host tool
Yeah we should do that anyways
Yeah we should do that anyways
Yeah we should do that anyways
Yeah we should do that anyways
Yeah we should do that anyways
Yeah we should do that anyways
is this weston????
epic!!!!!!!
this os seems to be quite polished, how long y'all been working on it?
also dumb question but the github says "Linux API compatibility", what does that mean exactly? sorry for stupidity, I'm new to this stuff 😅
It is indeed
Managarm is 10 years old
oh, wow
Y'all gonna stick with that or go with something else? I recommend sway (I fucking love sway :3)
We implement Linux specific API’s like epoll, timerfd, netlink and the like. We aim for source code level compatibility (so just a recompile)
oh, cool!!!!!
We also have sway and kmscon so your wish has been granted
KDE soon™️ if I get it working
that's awesome!! I checked the github but couldn't find an iso or img anywhere, where could I find that? I'd love to try it out!
systemd 😭 why
Nightly image (no sway, but installable over the package manager) can be found on https://builds.managarm.org. the readme will list qemu launch flags (or see https://docs.managarm.org)
Cuz I need a target, systemd is regarded as damn near impossible, we need an init system, we already use eudev, I need logind and because we can
thank you!!
(The logind requirement is for KDE and GNOME)
oh, fair enough, I'm just a hater tbh 
I talk shit about systemd damn well knowing I'm too stupid to figure out anything else 
Imma join the discord server, if that's okay, this seems epic
Of course!
Your terminal should have logging that might be of interest
(Our git port is broken and does not exist in upstream, neofetch can be installed but fastfetch is better)
oh, already closed the window, sorry, will try again and see if it is recurring
oh, cool, thank you :3
(not saying that the git being broken is cool, I meant about the second half)
the sway version just refuses to run for me 
Sway is not installed by default
weston runs fine, besides the terminal issue 😅
You’ll need to install it first
oh, that would explain it then, lol
sorry, and thank you!!!
No worries
k, tried a few times and it happened again, this is what my terminal shows
completely frozen
Scroll up a bit?
oh, sorry, already reset the vm 😭
I do see a crash but the actual issue is higher up. I just see the memory dump, the crash message is a bit higher. Look for where that purple block starts
oh wait just realised
my terminal would still say it, unless i close
like right here?
wow, that was fast!!!
Thanks for this, I’ll PR in a fix in the next few days (real life do be busy)
np
Yeah we ran into this from a different path already
Awesome
so, might just be stupid but I installed sway and still getting a black screen when trying to boot from the sway option
Yeah sway seems to have died
dam
this is really cool btw!!!
aside from a few hiccups it's super smooth and def feels polished 🙂
@vestal sapphire idk if you have time but sway from ci is dead. Something about DRM dumb from what I can see?
also having networking, a gui, and even a package manager working is super impressive 🙂
Unfortunately the full browser kinda broke atm otherwise you’d have a browser that has been able to run the discord webapp too
oh, wow, awesome!!
not awesome that it broke, I mean awesome that its a full browser and can run discord!!
Noted
I'll take a look
Probably also time to bump it
I likely bumped it a week or two back. But I didn’t touch versions
I mean bumping version
ig I'll take a look in a sec if I don't forget
hmm did we bump wlroots btw
Idk tbh
tools:
- name: host-bragi
from_source: bragi
tools_required:
- host-python
revision: 1
install:
- args: ['python3', '-m', 'venv', '.']
workdir: '@PREFIX@'
- args: ['bin/pip', 'install', '-e', '@THIS_SOURCE_DIR@']
workdir: '@PREFIX@'
isolate_network: false
this works
let's goooo
oooooooooh it's probably libdrm
Well, same workflow as for all other pkgs, right? Just install them before using
Wouldn’t be surprised tbh
no it's kinda weird
apparently sysfs doesn't have a drm directory for the device any more????
ah it was a sysfs meme
during cleanup I removed one dir traversal that changed the parent dir of an object
but I didn't consider the side effect that it created the directory
hmm I'm not sure the was it worked before was any good lol
Fair lol
getting it right seems tricky tho, fuck
okay I remember why I changed the meme before
it was because systemd-udev didn't like it
and that's correct ngl
however I'm nbot sure how to set up the class subdirs for devices with the name
Yikes
works again
it has some ugly artifacting tho, and I have no clue why
the solution ain't pretty tho
Hm?
so if we have the gpu at /sys/devices/pci0000:0000/0000:02.0/, we should create a subdir for the drm class
which in turn should contain card0
We discussed that already didn't we?
The correct logic is: if a class device is added to a non-class device parent, there is a glue directory
with the name of the class
That's the logic that linux uses
If a class device is added to another class device (even in a different class), there is no glue directory
yeah but where should that logic go
I guess in whatever function we do the mkdir for the child's sysfs dir
ok flags decoding works
when distributed managarm server
considering that requests can transfer memory objects etc that's probably not happening 
distributed OSes are a meme anyway
just splice the socket fd representing the lane with a memfd :^)
infiniband?
or any other RDMA solution
when has that ever stopped people
infiniband doesn't support transparent rdma either
very nice
now with responses
Nice
#840 is some bragi cleanup, I'll probably clean up the dumping code and put it there too
only thing that I still want to do is to try to hook up protocols/fs to this
and fix the bragi header 128 size assumption there as well
pretty cool
ok, so the WIP PRs are up for prelim review
https://github.com/managarm/bragi/pull/7
https://github.com/managarm/managarm/pull/840
it also needs a bootstrap PR to have bragi be a host tool
okay I think I implemented the extract-ostrace policy memes now
Based

lfg
Is this wireshark analyzing the messages between processes from Managarm?
yep it's dumped IPC
nice
nice