#Astral
1 messages · Page 14 of 1
and with copying buffers I mean like directly copying to the page cache etc etc etc
it also has the nicety of not having to keep track of how deep you are into the buffer anymore
a nice effect of this is that you can create say a list of
region 1 size 32
region 2 size 12
region 3 size 32
and read say 40 bytes from device a and then 40 bytes from device b
and it all gets copied and handled transparently by the iovec_iterator abstraction
and if you want to just pass a buffer and lenght and not worry about it, there are the socket_{write,read} and vfs_{write,read} helpers
I should probably rename the socket ones to send and recv to make them more in line with the socket ops
alright, thats done now
all I/O goes through the iovec interface and copies directly from user to where it needs to go
another step in the unshittification of astral
I'm trying to port some funny x11 program and damn I have never heard of this function before
sigvec sounds like a precursor to sigaction
also the build system is so horrid I literally am just calling the compiler myself because fuck that
i wonder why it doesn't use signal unconditionally, that's in standard c afaik
this program is old old old
What does it do
The program

dont ask me
Fish cant escape the tank ig
what's up with the main and datetime windows?
I think its the fvwm sidebar just not wanting to load lmao
well that's certainly... interesting
it puts it above all other windows, I guess as a type of screen saver
did a kill -10
screen locker
yeah I cant go back 
to unlock you walk to the sysadmin's office and ask him to send it sigusr1 again :^)
this is literally the whole recipe
name=xfishtank
revision=1
from_source=xfishtank
imagedeps="base-devel imake"
hostdeps="xgcc xbinutils libtool pkgconfig"
deps="base imlib2"
build() {
# the build system sucks, so we will directly call the compiler and ignore it!
cp -rp ${source_dir}/* .
gcc makeh.c -o makeh
./makeh fishmaps/?*.h > xfishy.h
x86_64-astral-gcc -Dlinux -I./fishmaps -lX11 -lImlib2 -lm xfish.c medcut.c -o xfishtank
}
package() {
mkdir -p ${dest_dir}/usr/bin/
cp -v xfishtank ${dest_dir}/usr/bin/xfishtank
}
it uses fucking imake so nope fuck off I will just do it myself
@prime juniper you should see if this runs on managorm
youre probably better off downloading it and building it inside managarm lmaooo
btw, you still have imake in the deps
even thought you bypass it
shit true
good thing debian has this pckg
Nah I don’t even start on this shit
alright
soon I will rewrite the scheduler
first, though, some cleanup
removing proc and thread from sched
thread and proc now have their own files
and a scheduler folder in sys
enough for today
🔥
cleanup is always nice
holy shit this is amazing
just remembered this discussion. wait what
like you can override a preexisting mapping with another?
yes or eg. a smaller range that is in the middle of an existing mapping
NGL that's kind of stupid
but i have no choice but to support it
if i want posix compatibility
first thing I will do will be make a cpu hierarchy
btw did you add the function to have a semaphore with a max count?
a very useful thing
after all it makes sense to aggressively work-steal between hyperthreads but less so between cores less shared
it doesn't always make sense to work steal within hyperthreads, as that impacts the single threaded performance heavily
not yet, I can add it in a bit
also tyrquake does work pretty decently now, the problem was that I unconditionally waited on the semaphore inside close for some reason
@carmine swallow pushed
do keep in mind I am using a new way of passing a buffer to drivers now
but switching from the old way to the new way should be as simple as switching out a function call
(and making sure you can take a fault)
does this mean that its not like huge delay now
the iovec iterator stuff? I already switched to it a moment ago
yes at least as far as I tested
also re the card dying inside windows, what was the exact sequence on how you got from astral to windows? because there are only really two things that I can immediately think of, either the card/codec ia not properly power cycled before windows tries to use it (which is needed because the astral driver doesn't properly stop the card on eg. a reboot) or maybe its the weird realtek quirk
yeah that
epicc
uhh I ^C the cat, tried to cat it again, astral gets stuck in the cat and then I reset
ah
i decided to build and explore astral
anything specific that you are proud of and I should check out?
Nothing really stands out too much tbh
Some parts are pretty solid, some need to be better
The ps2 driver 
ok here's my first issue
- building package: astral
/home/sanana/src/os/Astral/.jinx-cache/rbrt: mount() failure at line 309: Operation not permitted
What distro are you using
If you dont want to have to build it I have some precompiled binaries in my server
and it's a binary i think? that's no good for nix (I have nix-ld so it should be ok tho
rootless podman 
yeah podman could work too
port docker to astral
@tribal dust
I'm working on a podman jinx-like thing
I updated the image there yesterday
i'll try it
i'm working on nixstrap
wow so many alternatives
oh yeah that looked cool
idk how well it works on non-linux tho
my goal is to make it work anywhere podman runs
it should be OK for darwin other than nixpkgs issues
which I really couldn't fix
but often nixpkgs has darwin in badPlatforms because lack of maintainers
my main motivation is doing osdev on macOS
I tried like 5 different ways of getting jinx to run and it just wouldnt
main problem was FS issues
I was basically running jinx which runs its own container in a linux container in a linux vm
lmao
fakeroot fakechroot /usr/sbin/chroot 
my eventual goal for nixstrap is to eventually replace cppnix with something else, either something that really is not nix or a nix reimplementation that is non-unix friendly
but that is not today
today it runs everywhere nix runs
nixstrap shouldn't need much other than cppnix and libguestfs
yea i really can't think of anything that would really be needed other than stuff that disko requires (depends on what filesystems you want in the disk image) and libguestfs + cppnix
when I say nixstrap dependencies I mean required dependencies
for example the limine nixpkgs package does not build on darwin I think, so if you use the nixstrap limine module, then it wouldn't build
but you could definitely roll your own, nixstrap is modular
downloading mathewnd's astral build
What kind of software uses readv/writev? I assume chiefly network stuff?
I wonder if its emulatable with a series of read()/write()s for a temporary solution
Its expected to be atomic Im pretty sure
Network stuff prefers to use readmsg/recvmsg
Which uses an iovec
ah so that's a "no" unless you are the only reader/writer and can ensure that fact
Not even for that
but thats kinda fucked up
cause normal read() and write() dont have such atomicity themselves do they?
wrong reply
.
More so in, its treated like one big write/read
So say you writev to a pipe, as far as its below pipe_buf on the total size of the write all the iovs will be written atomically
Do keep in mind about this pipe write atomicity stuff, its not often implemented in hobby kernels
@tribal dust did it work
150 stars, nice
nice, L for uACPI tho
soon uacpi will surpass acpica I trust
Current state against ACPICA is:
- Way way better portability (drop-in cmake, meson, easy to tell which files to include, easily overridable platform layer)
- Way way better NT compatibility
- Way way better at using the stack (stuff that would recurse in ACPICA doesnt in uACPI)
- Way way better at handling bogus AML (no currently known fuzzer input that segfaults it unlike ACPICA, which dies if u blow on it wrong)
- Way way better CI and tests (complete lack thereof for ACPICA with half abandoned test suite)
- Lacks some minor convenience API
- Lacks thread safety in a lot of places
- Way less battle tested
- Lacks cool features like object cache, user-provided buffers for return values, a few other things here and there
A few of these im going to solve before 1.0
The rest maybe later
and well obviously ACPICA also provides a compiler, a disassembler and a debugger
which uacpi is not going to provide ever
not in linux
:^)
which point
oh like
- not in linux
yeah right
forgot that one
i can also say its a downside, since it has a lot of linux-specific (aka only in the linux source tree) patches, and no one knows how many of these are bugfixes that never made it to ACPICA upstream
thats the bad thing about being the bespoke linux acpi layer instead of trying to be a generic thing
write uacpi patches for linux 
well like i mentioned before, its not hard at all to make linux work with uacpi but it has 999999 places using ACPICA API
like most of that api maps 1 : 1 to uACPI but its still code that must be manually rewritten
so its almost impossible
aka would take months/years
I mean would something like that even be accepted
of course, as long as there's a demonstrable improvement in some area it would absolutely be accepted
which is technically possible but years of work and talking to upstream
and well, uACPI polish as well, which it lacks in some aforementioned areas at this point
Like ACPICA is on life support right now, nobody is working on it
one could dream that if it really becomes nescessary multiple people would work on it
it depends on whether you'd want to have your project imported mercilessly into the linux source tree never to make it out again
and hacked apart by randomers, and any changes you want to commit needing signed off
yeah they dont do submodules so it would end up being a bespoke linux layer as well
damn
drm used to be platform independent too and look what happened
yup
embraced, extended, extinguished
was gonna say
the closest possible thing is reactos, which had some interest as well
why is it that everyone loves EEE so much
it's a push but at least one of the BSDs may consider it
yeah probably
macos is out (do they use acpica anyway?), freebsd, dragonfly, net are possibilities, openbsd has their own acpi
I kinda want (doubt I ever will though) to try and port uACPI to linux and get it to boot (but without any drivers)
macos rolled their own acpi interpreter
that's fair enough for them
macos doesnt have anything anymore now
they also expect very specific aml with very specific objects so not like it matters
especially since they don't even need to deal with hardware quirks
they don't have to deal with countless aml insanities churned out by clowns
yeah was gonna say
considering the new apple silicon computers don't use acpi at all that might be completely out of the question sooner or later :^)
yeah they use the apple device tree thing
funnily enough on that
they synthesised a device tree on the i386 port in the past
especially since arm acpi is at not-so-good stage rn
good thing NT is pushing for it tho
so its not going away any time soon
i can't remember if ARM ServerReady Extreme System Environment! or whatever it's called mandates ACPI or just uefi
good
i think only the embedded one wants device trees
funny how this is the astral thread
and rest are either acpi-only or both
only embedded people that dont have the time nor expertise to write acpi
or any sort of firmware to run it ig
isn't an aml interpreter also really big
yeah true
so like acpi might be outta the question
probably
i wonder now whether riscv's version of ARM ServerReady Extreme System Environment!, which given riscv tradition is probably called "rvsbscbaippaktbnsdaiohsd", does mandate acpi itself, or even uefi
i mean you're already running linux anyway
most likely
lmao
the static lib I compile for uacpi is 2.5 mib
ACPI is the required mechanism for the hardware discovery and configuration. Server platforms are required to adhere to the RISC-V ACPI Platform Requirements Specification [21]. Platform firmware must support ACPI and the runtime OS environment must use ACPI for device discovery and configuration.
yes it does
cool
and my kernel binary is 2.7 mib
well if u do UACPI_HARDWARE_REDUCED or whatever its gonna be cut in half
fair
surprisingly it's not even an alphabet soup name
it's called "RISC-V OS-A Server Platform Specification"
and if the linker is any good it removes code symbols that aren't used (at least I think linkers do that?)
what does that even disable?
all registers and event management and shit like that
linkers usually deal with sections and not individual symbols
there is --gc-sections
but you need to compile with -ffunction-sections to have each function go into it's own section
I see
uhh so if u just have .text it wont clean up dead code?
yes
wtf
In my experience, if you have a static lib which you use no symbols from no code is included
yeah linkers gc objects that don't have any references to them
(they also can do that for shared libraries with --as-needed)
so which one is it
one or both or neither
or some combination of the above
💀
if you feed the linker foo.o but none of it's symbols are referenced in relocations from any other object file that object is just discarded
that could be an interesting project
i think it's worthy, a good stress test
One day I will finish my linker
By objects I thought you meant symbols
indeed
I wanna look into mlibc's dynamic linker and implement unimplemented relocations
that was a nightmare for me once, trying to figure out the best way to get objc categories defined within a static library to load
gotta love linkers
there is a way to do it in apple ld but i don't know about gnu ld
how goes your database anyway
slowly
and your orchestration tool
im only working on it half of the time
on hold until the db is done
so basically never
ur making a db?
it's semi working but i want to make it use the DB
Why it be deep-frying my executables
i would love to implement a database but i don't have the prerequisites yet
me neither, the difference is im just writing one anyway :^)
but the problem domain bears a suspicious resemblance to filesystems and their interaction in terms of caching with memory so it's not a million miles away from osdev
will it have sql like SELECT whatever FROM?
its a nosql so no
because it has to be webscale
(still doing raft)
Bruh this is the astral thread
same, one day i will make mine support multiple input files, and make it actually lay out phdrs instead of only generating sections :^)
all that means is that no
its just the same thing
but with a different syntax
i see
My goal was to leverage Rust's async and "fearless concurrency" to try and beat mold
But I gave up because rust lol
i was writing mine in scheme, for my 65816 project https://github.com/qookei/paaliaq/blob/master/toolchain/reloc.scm
Speaking of which I kinda wanna build a breadboard computer with that chip
I mean ideally I'd have a fricking 386 but that won't work on a breadboard
actually
rust async probably wouldnt help
you want rayon
How slow does it run lmao
Breadboards can do about up to 20mhz
And that's really pushing ot
Also newer CPUs aren't dip so you need a breakout board I think they're called
Yeah but dunno how that compares to mold's parallel library
i mean that's right around the speed the (cheaper) 386s and 486s run at anyway no?
I don't think mold would be that hard to beat tho
idk onetbb sounds really impressive
Mhm yeah I guess the slower i386s ran around 12mhz
can always use the embedded ones
Which ran as slow as you wanted
I mainly want a "modern" cpu because paging is just so nice
Yeah exactly
This reminded me to check ben eater's channel
I know it's not ben eater's project
thats on my watchlist
But anyway
when I finally had money to do breadboard computer stuff I wasnt too interested anymore (and when I tried I managed to hurt my fucking fingers wiring stuff up lmao)
I still have the z80 and stuff
Send them to me :^)
The breadboards
I should port obos to the i686 then make my own bread board i686 computer
If I ever do a breadboard computer I'd like to build some kind of macintosh thing but with a more modern cpu
Then print it on a pcb
Kinda worried about graphics and stuff
No idea how breadboard-able that is
I mean if ben eater made a breadboard gpu, what's stopping you
It was dead simple
Though
fuck it get an early amd64 processor
ascend
idk how hard itd be or if itd even be possible
That's shitty for real use
Ideally It'd be something like vga
or TIGA
Like the TMS34010
I think that's fairly breadboardable
You'd need to design a pcb
Continuing from the previous circuit that produced valid VGA sync signals, we'll build up a circuit step by step that can draw text characters on the screen.
Sounds promising
Wonder if I would be able to get seabios running
I'd just write my own
Probably not, my thing would be too obscure
simpler
Yeah
I already wrote half of one for my 5150 emulator :^)
Or make obos be the firmware 
firmware for something that old surely wouldnt be too hard
And if it's homebrewed it might be easier since you know what you need to init and where everything is
Yeah 5150 wasn't too hard, you just have to have a ton of bios calls
I'll write ASL for it 
You don't even need BIOS
wait
Just implement like 20, the ones needed to run limine
Then that's it
you can hardcode most of them too
Like e820
Or video modes
I can probably find an i386 chip on ebay for cheap
yea
I'd say 7-8 should be fine theoretically
because idk how to make a dynamic ram refresh thingy
I'd just use sram
expensive but easier to work with
*more expensive
mmio
You don't need a chip for that tho?
I mean
I don't think so
some sorta system
to do it
as in some and chips
to know whether to set the ram EN pin high
there's gotta be a way by mapping the address line pins or something
so you know how chips have the ENABLE pin
iirc they're used for stuff like this
yea
for example if bits 0xffff0000 are set, you'd set ROM.ENABLE to high (I think it's LOW to enable in a lot of cases, but whatever)
otherwise it could set RAM.ENABLE to hgih
or whatever the rom address was
I'd need to read the sdm for that
I'd add a uart
to it
what was the chip called
that had the ps/2 controller
and a bunch of other stuff
Intel 82091AA
unless that's too big
or I can't find it
but anyway
let's stop literring the astral thread
yeah you'd probs need a pic and pit too
Getting an OS to run on that would be an exercise in optimization
Yes.
so an Intel 8253/8254 and an intel 8259
(PIT/PIC)
along with the aic
(this)
and the i386
ram
rom
and other stuff
that I'm probably forgetting
indeed
that too
tbh sounds good
I don't wanna deal with video timing and shit
and dma
and whatnot
xbstrap with extra steps
the yaml is about to change a bit btw
json instead 
korona is cooking
phdml when
it's still yaml no? but now there are macros that can transform it
shhhhhhhh
yaml but easier
I mean already as-is, yaml is easier to type than json tbh
my problem is that I professionally hate maintaining shell scripts
I mean aren't your yaml files just shell scripts but in strings lol
it's mostly program invocations
Yeah that's what I meant
so not shell, but execve
jinx recipes are basically just invocations
maybe I should make a qemu target for this first
idk
I definitely will be getting a gdb stub though
yeah actually fair
I could probably just do -M none and add the components myself
also for the funnies I will be implementing debugcon in real hw
(port 0xe9)
*aip
id just do serial
problem with hardware is you need to do polling and stuff
you can't do 0xe9 with that
tru
I'll just not do anything
as in
not do debugcon
if I end up doing this
anyway, since this my project I'll move to the obos thread
this is 0x8 when running on linux but 0x10 when booting off astral
what the fuck?
magic
wait nvm I forgot that wsl does shit
I need to check what it returns on windows
this is a 4 core 8 thread cpu it makes no sense for the value there to be 0x10
bruh?
I'm probably reading something wrong wrt to the spec then
hmmm I think I am
its talking about the physical package
not the core
so the range for core is insde the range for the logical processor in the physical package
man I'm tired
finally
ok time to test on real hw
an then go to sleep and clean out this path tomorrow
Still doesnt work on my laptop
why wouldn't it?
as long as the kernel is Linux, of course
Maybe its the old ass version I use or something
oh definitely
yep
Epic
alright I got the cpuid outputs and played around and seems like I got it right now
just gotta implement it in the kernel and test if it will work
Quick google search tells me I have to use __get_cpuid_count instead of just __get_cpuid when using leaves that can have ecx set, oops!
pushed x86 topology detection stuff, still havent written the part which the scheduler will interface with though
also pushed a change idfk why I wasnt doing yet
on anonymous CoW with page refcount == 1, I just map the page now directly instead of copying it to a new page
really simple change, I really dont know why I didnt do it before
Oh cool, what are your plans for topology aware scheduling?
Something super simple and based on ule:
If it needs to be scheduled on a cpu, it goes there
Otherwise, it will triy to put it back on the cpu it has affinity on (such as the last one it was executed on), if it is not too overloaded
If that was not possible, it will walk back the topology trying to find a close cpu that can run it
Failing that, it will just find the least loaded cpu in the system and put the thread there
Also, I wonder how fucked up a CDE port would be 
hi
Hello nyauxmaster 5.0
hi mathew
@prime juniper mr portmaster mr portmaster between 0 and WHY what do you think it'd take to port cde 
Would be epic
what dat
Ngl but the fucks a CDE?
The Common Desktop Environment (CDE) is a desktop environment for Unix and OpenVMS, based on the Motif widget toolkit. It was part of the UNIX 98 Workstation Product Standard, and was for a long time the Unix desktop associated with commercial Unix workstations. It helped to influence early implementations of successor projects such as KDE and G...
Where sources
But considering it’s based on X11 and targeting Unix
I assume itd be horrifying because I had troubles getting it working on linux lmao
though once I rewrite the scheduler I can find out
Honestly might make my own cde-like DE if I ever get to that point
Something about old Unix guis...
i think its portable
OpenVMS is not unix
its vms
ngl id kill for astral with kde
in minecraft
Why is it depending on libtirpc for the Linux backend? My usual path is say you’re Linux, disable Pam and go
Aight time to revive the KDE on Managarm project (tbf systemd on managarm is part of that cuz logind session memes)
that would be huge
ikr
I have the entire stack ported (at least to a basic plasma desktop iirc)
But I’m running into startup memes
Related to sessions and shit
No no I did that with elogind
I should also see if I can see wtf is causing fvwm to fuck up the side bar
ah
still all of shit like dbus, sessions, etc very very borign and complex af
Yeah it’s a thing
yeah thats very cool
Tho who knows what happens once we do users properly
Access control might be a bitch
astral is very far from kde at least because it has basically 0 drm or anything like that
Yeah that’s gonna be some patches and that still doesn’t eliminate the session stuff
But yes 
i will fix that at some point ™️
uGPU.........
stuck in uacpi scope creep forever
i want to finish it properly before working on other stuff
so that its an actual production ready library
by then I (hopefully) will have fleshed out astral's driver interface more
I was going to do that but I got sidetracked by something arguably more important
(which is making the scheduler actually good)
both are important tbh
true
uni break is over but that just gives me something to scribble and think about when slacking off in class
yeah some time to read about algorithms and stuff instead of coding stuff directly
you can provide a drm interface for a plain fb
idk if linux does tho
efifb maybe?
yeah ofc, thats what managarm does
its still kind of tons of code
yeah drm is pain
its definitely grown over the years too
I will do it
I will do the unthinkable
I will finally do it
invariant tsc for timekeeping 
hpet too slow
especially since I need a fast and reliable and nonshit time source for the ULE interactivity metric
and also qemu is faster this way
after around what year is invariant TSC guaranteed to be a thing?
not 2013
ah well doesnt matter, I'll still have the hpet as a fall back
so if it doesnt have invariant tsc tough luck, buy a better computer next time and bear with the slowless for now
Another thing I will also do is rwlocks
port ideas: neko (maybe oneko) and minesweeper
minesweeper and xneko
Already ported
Now port libremines
Do it
(Audio optional)
omg :3
I like the penguin doing faces on ace-of-penguins minesweeper
Been there done that (never tried that minesweeper tho, I ported that for solitaire lol)
It is funny
http://tasvideos.org/6699S.html
An Ubuntu 18.04.1 distribution with Linux kernel 5.3.0-26-generic with keyboard and mouse support and a US default keyboard layout was used to run libTAS v1.3.5 running a compiled release version of PCem v15_235273a emulating a Pentium OverDrive MMX 200 in a Socket 7 Shuttle HOT-557 mainboard with a S3 ViRGE/DX g...
lol I did *something* that increased fps in glxgears by 10
scheduler
I havent even began to rewrite it 😭
does wsl2 not pass the invariant tsc to the linux vm bruh
Broke the clock reporting?
I didnt change much other than making it more precise so meh
dont think it was that
might be more related to me changing something about cow I think but probably now
I think after my vmm rewrite I will finally get to implement swap in the astral kernel
this time I don't plan on doing anything cursed
so hopefully in a day or two
yeah its just straight up not reported by cpuid
going insane
-cpu host?
Oh like wsl2 itself is not invariant tsc?
yea
Ah
tsc: Marking TSC unstable due to running on Hyper-V
hyper-v is known to have fucked up tsc
whether it will behave properly if you actually have an invariant tsc on the host i don't know
I do all this programming on this laptop and I cant install linux because eventually someone else uses it and she has stuff here aaaaaaaagh
I do have invariant tsc on my host cpu
maybe it will just work under hyper-v then
I should find a way to tell linux that its okay then
or just straight up patch the kernel 
as in hyper-v would have to deliberately fuck things up in order to make it so that the tsc were "unstable"
funny thing, apparently there are some bioses whose SMIs fucked with the tsc in an attempt to make it appear as the SMI never ran!!
absolutely unbelievable
funnily enough it seems like its just straight up disabled by it in the cpu
so cpuid 0x80000007 returns 0 in the edx bit 8
virtualbox with hyper-v does report an invariant tsc
so it is a config specific to wsl
czapek@raptor-wsl:~$ dmesg | grep -i tsc
[ 0.000000] clocksource: hyperv_clocksource_tsc_page: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000001] tsc: Detected 3417.599 MHz processor
[ 0.006855] TSC deadline timer available
[ 0.040487] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x31433fb2e38, max_idle_ns: 440795229393 ns
[ 0.134735] clocksource: Switched to clocksource tsc-early
[ 1.310970] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x31433fb2e38, max_idle_ns: 440795229393 ns
[ 1.313251] clocksource: Switched to clocksource tsc
czapek@raptor-wsl:~$ cat /proc/cpuinfo | grep -i tsc
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize ibt flush_l1d arch_capabilities```
interesting
i assume "tsc deadline timer available" means ive got invariant tsc?
this is wsl2 too
🤔
invariant tscp is nonstop_tsc iirc
which you do have
what wsl2 ver are you running on
idk, how do i check? lmao
debian
o
WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.4169
I'm on wsl 2.2.4.0
couold it maybe be that?
i would send it over but thats weird so i wont lol
compiling it is fairly easy but it takes time
czapek@DESKTOP-EPBQ7CO:czapek$ type .\.wslconfig
[wsl2]
kernel=C:\\Users\\czapek\\wsl\\vmlinuz
networkingMode=mirrored
firewall=false
[experimental]
sparseVhd=true```
thats how you enable a custom kernel
.wslconfig in user directory
@robust geyser does dmesg have hyperv_clocksource_tsc_page for you
czapek@raptor-wsl:~$ dmesg | grep -i hyperv_clocksource_tsc_page
[ 0.000000] clocksource: hyperv_clocksource_tsc_page: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns```
Starting with Windows Server 2022 Hyper-V, Hyper-V uses hardware support for TSC frequency scaling to enable live migration of VMs across Hyper-V hosts where the TSC frequency may be different. When a Linux guest detects that this Hyper-V functionality is available, it prefers to use Linux’s standard TSC-based clocksource. Otherwise, it uses the clocksource for the Hyper-V synthetic system clock implemented via the shared page (identified as “hyperv_clocksource_tsc_page”).
could it be that my windows is too old for this to be enabled
its been installed since like 2021
no
2022
early 2022
I think
or
my cpu doesnt support tsc scaling or w/e
well
considering I dont plan on doing live migration cant I just disable it complaining??
aghhh
my winver
yeah its the same
its probs the scaling thing
idk
but its a hyper-v issue since it reports it as being unavailable in the cpuid bit
but only in wsl
in virtual box it reports it correctly
which wtf?
hyperv vbox?
yeah
I have no idea atp
what kernel do you have?
5.15.153 on wsl
czapek@raptor-wsl:~$ uname -a
Linux raptor-wsl 6.1.21.2-microsoft-standard-WSL2+ #1 SMP Tue Mar 19 10:13:35 CET 2024 x86_64 GNU/Linux
ohhh
wsl.exe is lying
gonna install the debian one and see if that does anything? I doubt it
nope
try updating the kernel
either aka.ms/wsl2kernel
and download the update package
or try compiling one yourself
yep
dont forget to checkout the right branch
there are some instructions somewhere how to compile the kernel
yeah I found them
good luck 
or rather... have a good time
takes like 3-4 minutes on my machine, fortunately
i gotta update it
i estimate around 25 minutes on your computer
complete guess
dont forget to -j`nproc`
or -j$(nproc), whichever you prefer
linux-msft-wsl-6.6.36.6 
im building this shit !!!!
@robust geyser you were off by a bit
i am still building
idk why i need like 90% of these drivers
but whatever
you do you msft
gpu drivers on wsl!!! yeah i need that for sure...
inb4 they allow passthrough to wsl
crying
[ 0.000000] Linux version 6.6.36.6-microsoft-standard-WSL2+ (czapek@raptor-wsl) (gcc (Debian 14.2.0-4) 14.2.0, GNU ld (GNU Binutils for Debian) 2.43.1) #1 SMP PREEMPT_DYNAMIC Fri Sep 27 02:54:33 CEST 2024
czapek@raptor-wsl:~$ dmesg | grep -i tsc
[ 0.000000] clocksource: hyperv_clocksource_tsc_page: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000000] tsc: Detected 3417.599 MHz processor
[ 0.006792] TSC deadline timer available
[ 0.038356] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x31433fb2e38, max_idle_ns: 440795229393 ns
[ 0.087189] clocksource: Switched to clocksource tsc-early
[ 1.125985] tsc: Refined TSC clocksource calibration: 3417.599 MHz
[ 1.126299] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x31433fb2e38, max_idle_ns: 440795229393 ns
[ 1.129983] clocksource: Switched to clocksource tsc```
¯_(ツ)_/¯
just change the linux kernel
ig it really is a hyperv meme or smth
but slow
right
I mean the only reason I was even going to implement the tsc was for faster timekeeping
I could try to botch something together
since scheduler needs that
fuck it
kvmclock time

ah fuck it I think I should just try to dual boot linux in this thing
what will I be arsed more to do
kvmclock or install linux
linux
install debian
for one specific reason
passing through my ethernet card for when I want to develop a driver for it
join me, myself, and I using debian
I was probably gonna install artix but then again I dont have time to juggle university work osdev and babysitting a linux distro
czapek@raptor-wsl:~/sources/zig-kernel$ dmesg | grep -i kvm
czapek@raptor-wsl:~/sources/zig-kernel$ echo $?
1```
cool, broken kernel
back to 6.1.whatever i guess
arch is better
I'm an arch user, and tbh, I don't really have that many problems with it
most of the time it just works
same here
but when I started, it was a lot of work
it just depends on how you set it up
what is "hardware assert support" and why does managarm not have it implemented yet?

@prime juniper pls fix
have you perhaps looked into the Virtually Contiguous PFNDB™️?
windows is not helping and not letting me resize the partition enough grrrr
real windoze moenmt
I have thought of implementing it yeah
just putting everything in a huge region and praying theres one big enough isnt exactly good
yeah, no
i was trying to implement it today but i've hit a few roadblocks and i wanted to see how other people solved my issues
or if those are exlucisve to me being slow 
but if you haven't worked on it (yet) then no worries
not yet
originally I was going to have each usable region keep track of its own pfns until vmm init
so like at the start of each regions the struct pages for each page would be allocated
yep thats what i did in my old kernel
but iterating over memory regions to find the page you want isnt ideal
it should just be pfndb[pfn>>4]
which is why then you make it virtually contigous later
but thats like double the work
ugh its annoying me that i cant find a better solution even though i know there is one and its not that fucking hard
tomorrow i’ll give your idea a try
even though it pains me i have to implement two memory managers just to throw one away immediately 💀
I think you would still need to take care of a few things
I mean like
necessary evil or something
have it at the start of each range and then just map it later on and have a function pointer or w/e
i cant have them be mapped contiguous after that
because there might be gaps between thrm after all
youd probably still need some calculation for it to put it in the right place in the page
page structs for a given region might not fill up an entire page
or like, idk how to word that
but i hope you know what i mean
i turned wifi on and discord teleported me to the first message in this thread, nice
I might actually think of how to solve this tomorrow while bored at work if I remember
its too late and me tired
to think
i can throw my idea in here tomorrow
sure
i just have a small issue that im not sure how to fix
maybe you’ll have an idea
sleep now tho, gn
gn
i hate hyperv
worst VM software to ever grace mankind
not only can it not run old operating systems good
but it RUINS the performance of my OTHER vm software
it's also why I use wsl1 all the time and never wsl2
i think it might make my computer slower too but that last one may be just placebo
Yep will do. Managarm must assert!
boron has a functional virtually sparse page frame database
you can look there for inspiration
it doesn't have support for a buddy allocator or allocations bigger than a page of physically contiguous memory but I haven't needed that feature yet
I have it implemented if you want to take a look, nothing too fancy to look at.
ah I was not the first to respond 😆
https://github.com/DeanoBurrito/northport/blob/kernel-rewrite/kernel/arch/x86_64/Hat.cpp#L206-L213 where it happens, EarlyPmAlloc is implemented here https://github.com/DeanoBurrito/northport/blob/kernel-rewrite/kernel/interfaces/loader/Limine.cpp#L331, its just a bump allocator from the memory map.
HatInit() is one of the first things run when the kernel starts (theres some hooks for setting up any no-alloc log outputs, global ctors and an arch-layer hook for setting up interrupt handling stuff).
it could definitely be more efficient with not mapping holes in the memory map and using 2M pages where applicable, but i'll get there
You need to enable KVM not as a module because wsl with custom kernels does not load them
I've had the same problem and enabling KVM not as a module fixed it
These solutions are interesting but I was thinking of making something that doesnt depend on some separate early mapping code idk
Maybe it is faster to just have some separate paging code that takes out of the memory map than using a function pointer or an if else later on
Probably
Func ptr is indirection and fucks up compiler inlining and if else is a branch
yeah that sounds unpleasant, especially when its only needed for a short period of time
you could always have it call into another TU and then patch in a jmp over the early code after its not longer needed
could be fun 😅
I need to focus on the scheduler rewrite I need to focus on one thing otherwise I will never get anything done
So I will look into it soon
haha understandable
Wait what's whole convo about? PFNDBs?
My biggest trouble atm is deciding how I am going to proceed wrt the tsc, since hyperv hates me but I cant really afford to read the hpet on every wake up and interruptible sleep (at least not on fast machines)
Yeah
I mean if windows allows me to shrink the partition over 9 gbs itd be easy but nope cant let you install linux nuh uh
my pmm alloc function returns a uintptr_t
which is the physical address
and struct page allocation is done later
if needed
then there is a separate vmm allocator which is kinda special in that it uses the pmm+hhdm to allocate memory
then the vmm might later allocate a struct page for that physical page and emplace it into an rb tree
trust me I'll push that code soon 
ideally, you should return a struct page* when allocating memory
and accept that when freeing
i mean not that it matters if your pfndb is virtually contiguous, but if it isn’t then finding the page struct using the physical address isn’t O(1), but getting the ohysical address from a page struct is
You should have functions to directly manipulate any page table
Separate from VAD lists and stuff like that
basically what i was trying to do, but 2MiB pages are giving me a headache
thats why I put a TODO 
i am trying to calculate how much memory i need for the PFNDB, then take the biggest memory entry and steal that much memory from it and leave the rest for 4KiB pages (page tables)
but the biggest memory entry can be misaligned, so if i align up i lose a bunch of 4KiB pages
I do yeah thats the arch_mmu_* functions
But they dont have an erly pmm alloc or anything
how do you feel about steeling one of the mmap entries from another type? if you dont care about reserved entries, repurpose it for a usable one that has the misaligned part of the entry you want to use.
its not particularly elegant
i just thought of an idea
ah we should probably stop distracting mathewnd at some point too
what if instead of stealing a part from the start of the memory entry
i just yoink it from the end
lol
you could still waste pages
Idm if its useful discussion and not people just fighting over meaningless shit
i will use whats before that for 4KiB pages
so i dont waste the pages before that in the memory entry
and whats after i can account for too, because i know where the 2mib “region” starts and how big it is
I believe that huge pages are nothing more than a slight optimization which can be focused on later
I wouldn't focus on them at the beginning
I agree
i dont really want to allocate hundreds of megabytes using 4KiB pages
it seems slooooow
nop
but I also get wanting to have it done right at the beginning
you don't allocate hundreds of megabytes
for a 32GiB memmap you do 
It's about 4 MB for the PFNDB on a system with 16 GiB
you dont get that too often but yeah
Wait nvm no
i dont want it to be slow on a system like that
nop
also 2MB and 1GB pages wont even solve your speed problem
i will implement it in a bit when i get up
I do have helpers for that
well, they will barely
less memory to allocate and map will definitely improve boot speeds
Just allocate enough for each range at the start of it and map that appropriately?
250 allocations vs 100k allocations
Not 100% efficient but works
i guess thats true too
you can do that if you are hellbent on using huge pages
why
why not return the page number?
it should
but page*->pfn was free
ideally it should be a simple Pfndb[Pfn]
if its virtually contiguous then you might as well have an easy association of pfn->page
also the pfn can easily be converted to a PTE with a single bitshift, there isn't a level of indirection
PFN to PTE? interesting
how do you do that?
i know NT has a bunch of bullshit mappings but i don’t know how they work
I think he meant like, how its expected to be in the PTE? Like pfn << 12
i guess
Maybe just check if regions are aligned to 2mb and if so use 2mb for those
Or if they're not and they're like 2mb + 8192 then I'm sure you can figure out a way to do 2mb page + 2 4k pages
?
the PFN is the physical address of the corresponding page shifted right by 12
you just shift it left by the PFN's position in the PTE
set the relevant bits such as P
boom
i thought you meant something else
were you thinking of VPN to PTE address?
that one is obvious
NT does use recursive mapping which allows a direct conversion
yeah i believe NT has some mechanisms for that
but im not sure how that works
ah that makes sense
you can set one of the top level PTEs to the same pfn as the top level itself
that's basically how it's done.
and it'll be a virtually sparse but linear mapping of all of the page table levels in memory
i have yet to implement this in boron myself
how did I get Linux running while using less memory than that
like it was using <40mb on a 8gb system
Out of how much exactly
40mb/8gb
just post dmesg | grep e820
Idk
I don't even have that laptop anymore
I don't think so atleast
perhaps it just doesn't account the page structs
interesting
I need to see if that cpuid bit is set on wsl
if so I can try just patching the kernel
writing to that msr say in linux early boot and praying it actually works
if it does I will actually scream lol
Whats the current command to build miminal astral from scratch?
make DISTROTYPE=minimal?
update jinx to latest tbh

