klange changed the topic of #osdev to: Operating System Development || Don't ask to ask---just ask! || For 3+ LoC, use a pastebin (for example https://gist.github.com/) || Stats + Old logs: http://osdev-logs.qzx.com New Logs: https://libera.irclog.whitequark.org/osdev || Visit https://wiki.osdev.org and https://forum.osdev.org || Books: https://wiki.osdev.org/Books
Lucretia has joined #osdev
LjL has quit [Read error: Connection reset by peer]
LjL has joined #osdev
leon has quit [Ping timeout: 260 seconds]
chiselfuse has quit [Ping timeout: 260 seconds]
chiselfuse has joined #osdev
gog has quit [Quit: byee]
m5zs7k has quit [Read error: Connection reset by peer]
m5zs7k has joined #osdev
chiselfuse has quit [Ping timeout: 260 seconds]
chiselfuse has joined #osdev
leon has joined #osdev
_ngn has quit [Remote host closed the connection]
_ngn has joined #osdev
X-Scale has joined #osdev
voidah has joined #osdev
mavhq has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
mavhq has joined #osdev
leon has quit [Ping timeout: 244 seconds]
X-Scale has quit [Quit: Client closed]
heat has quit [Ping timeout: 252 seconds]
Arthuria has joined #osdev
spookline is now known as kline
bradd has quit [Ping timeout: 265 seconds]
leon has joined #osdev
bradd has joined #osdev
bradd has quit [Read error: Connection reset by peer]
bradd has joined #osdev
bradd has quit [Ping timeout: 260 seconds]
terrorjack4 has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack4 has joined #osdev
thinkpol has quit [Ping timeout: 260 seconds]
vdamewood has joined #osdev
Xyon has quit [Ping timeout: 252 seconds]
_ngn has quit [Remote host closed the connection]
_ngn has joined #osdev
thinkpol has joined #osdev
Xyon has joined #osdev
bradd has joined #osdev
vdamewood has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
eluks has quit [Remote host closed the connection]
eluks has joined #osdev
Gooberpatrol66 has joined #osdev
voidah has quit [Ping timeout: 252 seconds]
voidah has joined #osdev
Arthuria has quit [Ping timeout: 276 seconds]
nikolar has quit [Ping timeout: 252 seconds]
Ram-Z has quit [Ping timeout: 252 seconds]
sbalmos has quit [*.net *.split]
eck has quit [*.net *.split]
ZipCPU has quit [*.net *.split]
zenomat has quit [*.net *.split]
klys has quit [*.net *.split]
sham1 has quit [*.net *.split]
Enapiuz has quit [*.net *.split]
rselim has quit [*.net *.split]
acidx has quit [*.net *.split]
amj has quit [*.net *.split]
geist has quit [*.net *.split]
kkd has quit [*.net *.split]
JTL has quit [*.net *.split]
graphitemaster has quit [*.net *.split]
sebastiencs has quit [*.net *.split]
KitsuWhooa has quit [*.net *.split]
hl has quit [*.net *.split]
wgrant has quit [*.net *.split]
pax_73 has quit [*.net *.split]
Celelibi has quit [*.net *.split]
tjf has quit [*.net *.split]
Benjojo has quit [*.net *.split]
cultpony has quit [*.net *.split]
MrBonkers has quit [*.net *.split]
cheapie has quit [*.net *.split]
truebad0ur has quit [*.net *.split]
zid` has quit [*.net *.split]
mcrod has quit [*.net *.split]
SystemPrompt has quit [*.net *.split]
ChanServ has quit [*.net *.split]
_ngn has quit [*.net *.split]
chiselfuse has quit [*.net *.split]
gildasio has quit [*.net *.split]
foudfou has quit [*.net *.split]
Gooberpatrol66 has quit [*.net *.split]
LjL has quit [*.net *.split]
remexre has quit [*.net *.split]
j00ru has quit [*.net *.split]
clever has quit [*.net *.split]
antranigv has quit [*.net *.split]
Patater has quit [*.net *.split]
beto has quit [*.net *.split]
childlikempress has quit [*.net *.split]
m3a has quit [*.net *.split]
bencevans has quit [*.net *.split]
alec3660 has quit [*.net *.split]
melonai has quit [*.net *.split]
guideX has quit [*.net *.split]
the_oz has quit [*.net *.split]
theruran has quit [*.net *.split]
bliminse has quit [*.net *.split]
hanemile_ has quit [*.net *.split]
alice has quit [*.net *.split]
dormito has quit [*.net *.split]
PapaFrog has quit [*.net *.split]
dza has quit [*.net *.split]
asymptotically has quit [*.net *.split]
ursa-major has quit [*.net *.split]
thinkpol has quit [*.net *.split]
rb has quit [*.net *.split]
Starfoxxes has quit [*.net *.split]
dostoyevsky2 has quit [*.net *.split]
puck has quit [*.net *.split]
eau has quit [*.net *.split]
johnjaye has quit [*.net *.split]
gjn has quit [*.net *.split]
sm2n has quit [*.net *.split]
xtex has quit [*.net *.split]
jleightcap has quit [*.net *.split]
baraq has quit [*.net *.split]
lucyy has quit [*.net *.split]
whereiseveryone has quit [*.net *.split]
listentolist has quit [*.net *.split]
bombuzal has quit [*.net *.split]
solaare has quit [*.net *.split]
chibill has quit [*.net *.split]
ptrc has quit [*.net *.split]
SophiaNya has quit [*.net *.split]
brynet has quit [*.net *.split]
basil has quit [*.net *.split]
PublicWiFi has quit [*.net *.split]
manawyrm has quit [*.net *.split]
LittleFox has quit [*.net *.split]
phr3ak has quit [*.net *.split]
Leftas has quit [*.net *.split]
Griwes has quit [*.net *.split]
pounce has quit [*.net *.split]
ddevault has quit [*.net *.split]
pg12 has quit [*.net *.split]
JerryXiao has quit [*.net *.split]
nitrix has quit [*.net *.split]
TkTech has quit [*.net *.split]
randm has quit [*.net *.split]
cross has quit [*.net *.split]
jimbzy has quit [*.net *.split]
jbowen has quit [*.net *.split]
DragonMaus has quit [*.net *.split]
m5zs7k has quit [*.net *.split]
craigo has quit [*.net *.split]
sprocket has quit [*.net *.split]
Mutabah has quit [*.net *.split]
steelswords94 has quit [*.net *.split]
Stary has quit [*.net *.split]
CaptainIRS has quit [*.net *.split]
HeTo has quit [*.net *.split]
exark has quit [*.net *.split]
FireFly has quit [*.net *.split]
ad__ has quit [*.net *.split]
Irvise has quit [*.net *.split]
pabs3 has quit [*.net *.split]
citrons has quit [*.net *.split]
runxiyu has quit [*.net *.split]
arminweigl has quit [*.net *.split]
sly has quit [*.net *.split]
nshp has quit [*.net *.split]
particleflux has quit [*.net *.split]
kristinam has quit [*.net *.split]
fluix has quit [*.net *.split]
eschaton has quit [*.net *.split]
moire has quit [*.net *.split]
KaitoDaumoto has quit [*.net *.split]
ThinkT510 has quit [*.net *.split]
isabella has quit [*.net *.split]
nortti has quit [*.net *.split]
sauce has quit [*.net *.split]
ghostbusters2 has quit [*.net *.split]
raggi has quit [*.net *.split]
imyxh has quit [*.net *.split]
shan has quit [*.net *.split]
hbag has quit [*.net *.split]
valeriusN has quit [*.net *.split]
dinkelhacker has quit [*.net *.split]
colona has quit [*.net *.split]
kazinsal has quit [*.net *.split]
eluks has quit [*.net *.split]
kof673 has quit [*.net *.split]
Affliction has quit [*.net *.split]
lanodan has quit [*.net *.split]
air has quit [*.net *.split]
youcai has quit [*.net *.split]
FreeFull has quit [*.net *.split]
tomaw has quit [*.net *.split]
nur has quit [*.net *.split]
fedaykin has quit [*.net *.split]
\Test_User has quit [*.net *.split]
jistr has quit [*.net *.split]
Matt|home has quit [*.net *.split]
urandom_ has quit [*.net *.split]
cow321 has quit [*.net *.split]
ramenu has quit [*.net *.split]
frkzoid has quit [*.net *.split]
mahk has quit [*.net *.split]
vancz has quit [*.net *.split]
tanto has quit [*.net *.split]
HumanG33k has quit [*.net *.split]
mcfrdy has quit [*.net *.split]
n3t has quit [*.net *.split]
bradd has quit [*.net *.split]
Xyon has quit [*.net *.split]
mavhq has quit [*.net *.split]
andreas303 has quit [*.net *.split]
zhiayang has quit [*.net *.split]
nadja has quit [*.net *.split]
Terlisimo has quit [*.net *.split]
torresjrjr has quit [*.net *.split]
CompanionCube has quit [*.net *.split]
MiningMarsh has quit [*.net *.split]
fkrauthan has quit [*.net *.split]
Rubikoid has quit [*.net *.split]
jeaye has quit [*.net *.split]
sjs has quit [*.net *.split]
Bitweasil has quit [*.net *.split]
thaumavorio has quit [*.net *.split]
sskras has quit [*.net *.split]
remn has quit [*.net *.split]
cow has quit [*.net *.split]
bl4ckb0ne has quit [*.net *.split]
Ameisen_ has quit [*.net *.split]
nohit has quit [*.net *.split]
leon has quit [*.net *.split]
Lucretia has quit [*.net *.split]
getz has quit [*.net *.split]
asarandi has quit [*.net *.split]
pog has quit [*.net *.split]
dostoyevsky has quit [*.net *.split]
gmodena has quit [*.net *.split]
j`ey has quit [*.net *.split]
marshmallow has quit [*.net *.split]
Arsen has quit [*.net *.split]
LambdaComplex has quit [*.net *.split]
ornitorrincos has quit [*.net *.split]
voidah has quit [*.net *.split]
terrorjack4 has quit [*.net *.split]
lojik has quit [*.net *.split]
emntn has quit [*.net *.split]
bauen1 has quit [*.net *.split]
wereii has quit [*.net *.split]
gruetzkopf has quit [*.net *.split]
[Kalisto] has quit [*.net *.split]
teroshan has quit [*.net *.split]
dennisschagt has quit [*.net *.split]
larsjel has quit [*.net *.split]
bslsk05 has quit [*.net *.split]
DoubleJ has quit [*.net *.split]
energizer has quit [*.net *.split]
koolazer has quit [*.net *.split]
woky has quit [*.net *.split]
carrar has quit [*.net *.split]
night has quit [*.net *.split]
Brnocrist has quit [*.net *.split]
Bonstra has quit [*.net *.split]
nagitsu has quit [*.net *.split]
alexander has quit [*.net *.split]
rom4ik has quit [*.net *.split]
khimaros has quit [*.net *.split]
slow99 has quit [*.net *.split]
V has quit [*.net *.split]
SanchayanMaity has quit [*.net *.split]
deriamis has quit [*.net *.split]
XgF has quit [*.net *.split]
xelxebar has quit [*.net *.split]
qookie has quit [*.net *.split]
stux has quit [*.net *.split]
travisg has quit [*.net *.split]
vismie has quit [*.net *.split]
pitust has quit [*.net *.split]
noeontheend has quit [*.net *.split]
tommybomb has quit [*.net *.split]
exec64 has quit [*.net *.split]
patwid has quit [*.net *.split]
yuiyukihira has quit [*.net *.split]
tom5760 has quit [*.net *.split]
bleb has quit [*.net *.split]
stefanct has quit [*.net *.split]
Ermine has quit [*.net *.split]
Maja has quit [*.net *.split]
danlarkin has quit [*.net *.split]
Rajnhildacho has quit [*.net *.split]
kanzure has quit [*.net *.split]
klys has joined #osdev
sbalmos has joined #osdev
geist has joined #osdev
kkd has joined #osdev
amj has joined #osdev
acidx has joined #osdev
Enapiuz has joined #osdev
sham1 has joined #osdev
zenomat has joined #osdev
ZipCPU has joined #osdev
eck has joined #osdev
truebad0ur has joined #osdev
mcrod has joined #osdev
cheapie has joined #osdev
cultpony has joined #osdev
MrBonkers has joined #osdev
tjf has joined #osdev
Benjojo has joined #osdev
Celelibi has joined #osdev
pax_73 has joined #osdev
zid` has joined #osdev
wgrant has joined #osdev
hl has joined #osdev
KitsuWhooa has joined #osdev
rselim has joined #osdev
sebastiencs has joined #osdev
graphitemaster has joined #osdev
SystemPrompt has joined #osdev
Ram-Z has joined #osdev
woky_ has joined #osdev
carrar has joined #osdev
stux has joined #osdev
qookie has joined #osdev
j`ey has joined #osdev
ornitorrincos has joined #osdev
LambdaComplex has joined #osdev
Arsen has joined #osdev
gmodena has joined #osdev
nohit has joined #osdev
n3t has joined #osdev
marshmallow has joined #osdev
koolazer has joined #osdev
mcfrdy has joined #osdev
kazinsal has joined #osdev
Ameisen_ has joined #osdev
energizer has joined #osdev
dinkelhacker has joined #osdev
colona has joined #osdev
bl4ckb0ne has joined #osdev
xelxebar has joined #osdev
DoubleJ has joined #osdev
valeriusN has joined #osdev
cow has joined #osdev
raggi has joined #osdev
shan has joined #osdev
remn has joined #osdev
XgF has joined #osdev
bslsk05 has joined #osdev
ghostbusters2 has joined #osdev
kanzure has joined #osdev
fluix has joined #osdev
eschaton has joined #osdev
moire has joined #osdev
Affliction has joined #osdev
kristinam has joined #osdev
deriamis has joined #osdev
nshp has joined #osdev
travisg has joined #osdev
particleflux has joined #osdev
DragonMaus has joined #osdev
HumanG33k has joined #osdev
jbowen has joined #osdev
Rajnhildacho has joined #osdev
danlarkin has joined #osdev
SanchayanMaity has joined #osdev
dostoyevsky has joined #osdev
sauce has joined #osdev
V has joined #osdev
larsjel has joined #osdev
[Kalisto] has joined #osdev
teroshan has joined #osdev
gruetzkopf has joined #osdev
thaumavorio has joined #osdev
isabella has joined #osdev
cross has joined #osdev
slow99 has joined #osdev
Bonstra has joined #osdev
sly has joined #osdev
sjs has joined #osdev
imyxh has joined #osdev
SophiaNya has joined #osdev
ptrc has joined #osdev
randm has joined #osdev
asarandi has joined #osdev
Bitweasil has joined #osdev
arminweigl has joined #osdev
hbag has joined #osdev
khimaros has joined #osdev
alec3660 has joined #osdev
TkTech has joined #osdev
runxiyu has joined #osdev
bleb has joined #osdev
Ermine has joined #osdev
tanto has joined #osdev
vancz has joined #osdev
jimbzy has joined #osdev
sskras has joined #osdev
dennisschagt has joined #osdev
brynet has joined #osdev
basil has joined #osdev
PublicWiFi has joined #osdev
manawyrm has joined #osdev
LittleFox has joined #osdev
phr3ak has joined #osdev
nortti has joined #osdev
bencevans has joined #osdev
stefanct has joined #osdev
m3a has joined #osdev
nitrix has joined #osdev
citrons has joined #osdev
jeaye has joined #osdev
rom4ik has joined #osdev
alexander has joined #osdev
JerryXiao has joined #osdev
Rubikoid has joined #osdev
childlikempress has joined #osdev
chibill has joined #osdev
beto has joined #osdev
bombuzal has joined #osdev
listentolist has joined #osdev
whereiseveryone has joined #osdev
baraq has joined #osdev
lucyy has joined #osdev
gjn has joined #osdev
xtex has joined #osdev
jleightcap has joined #osdev
sm2n has joined #osdev
patwid has joined #osdev
yuiyukihira has joined #osdev
asymptotically has joined #osdev
vismie has joined #osdev
tom5760 has joined #osdev
pitust has joined #osdev
noeontheend has joined #osdev
tommybomb has joined #osdev
ursa-major has joined #osdev
pg12 has joined #osdev
exec64 has joined #osdev
nagitsu has joined #osdev
ddevault has joined #osdev
Brnocrist has joined #osdev
night has joined #osdev
pounce has joined #osdev
dza has joined #osdev
Griwes has joined #osdev
PapaFrog has joined #osdev
mahk has joined #osdev
johnjaye has joined #osdev
dormito has joined #osdev
eau has joined #osdev
frkzoid has joined #osdev
pabs3 has joined #osdev
ramenu has joined #osdev
urandom_ has joined #osdev
Patater has joined #osdev
Irvise has joined #osdev
ad__ has joined #osdev
puck has joined #osdev
alice has joined #osdev
Matt|home has joined #osdev
FireFly has joined #osdev
exark has joined #osdev
hanemile_ has joined #osdev
jistr has joined #osdev
cow321 has joined #osdev
bliminse has joined #osdev
\Test_User has joined #osdev
kof673 has joined #osdev
HeTo has joined #osdev
theruran has joined #osdev
antranigv has joined #osdev
pog has joined #osdev
fedaykin has joined #osdev
the_oz has joined #osdev
fkrauthan has joined #osdev
dostoyevsky2 has joined #osdev
wereii has joined #osdev
CaptainIRS has joined #osdev
MiningMarsh has joined #osdev
sortie has joined #osdev
bauen1 has joined #osdev
tomaw has joined #osdev
clever has joined #osdev
Stary has joined #osdev
guideX has joined #osdev
CompanionCube has joined #osdev
solaare has joined #osdev
torresjrjr has joined #osdev
Mutabah has joined #osdev
FreeFull has joined #osdev
nur has joined #osdev
youcai has joined #osdev
Terlisimo has joined #osdev
sprocket has joined #osdev
j00ru has joined #osdev
steelswords94 has joined #osdev
Maja has joined #osdev
nadja has joined #osdev
air has joined #osdev
remexre has joined #osdev
lanodan has joined #osdev
foudfou has joined #osdev
ThinkT510 has joined #osdev
zhiayang has joined #osdev
KaitoDaumoto has joined #osdev
andreas303 has joined #osdev
emntn has joined #osdev
Starfoxxes has joined #osdev
rb has joined #osdev
Leftas has joined #osdev
melonai has joined #osdev
m5zs7k has joined #osdev
getz has joined #osdev
craigo has joined #osdev
Lucretia has joined #osdev
_ngn has joined #osdev
mavhq has joined #osdev
thinkpol has joined #osdev
Xyon has joined #osdev
gildasio has joined #osdev
chiselfuse has joined #osdev
terrorjack4 has joined #osdev
LjL has joined #osdev
lojik has joined #osdev
leon has joined #osdev
eluks has joined #osdev
Gooberpatrol66 has joined #osdev
voidah has joined #osdev
ChanServ has joined #osdev
bradd has joined #osdev
pax_73 has quit [Ping timeout: 248 seconds]
pax_73 has joined #osdev
JTL has joined #osdev
pabs3 has quit [Read error: Connection reset by peer]
pabs3 has joined #osdev
hwpplayer1 has joined #osdev
hwpplayer1 has quit [Remote host closed the connection]
exark has quit [Quit: quit]
exark has joined #osdev
exark has quit [Remote host closed the connection]
goliath has joined #osdev
exark has joined #osdev
craigo has quit [Quit: Leaving]
muffin has joined #osdev
muffin has quit [Quit: Reconnecting]
muffin has joined #osdev
<muffin> I have 16 local APIC structures in my MADT, 14 of which are marked as unusable. I only have 2 cores. Interesting design
netbsduser has joined #osdev
<Mutabah> Probably the firmware supports up to 16 cores, and only fills in the ones it needs
heat has joined #osdev
<muffin> makes sense Mutabah
spare has joined #osdev
<heat> what hardware is this?
<heat> that reeks of vmware, vmware has the nastiest acpi tables like this
<muffin> It's an Intel Celeron N4500
<muffin> with the acpi cpuid flag
<heat> heh okay
<heat> running on bare metal?
<muffin> No virtualization - I read out the ACPI tables directly through the UEFI configuration table RSDP
<heat> hmm what field are you referring to as "unusable"? i went to check my own code but there's no such field in the MADT...
<muffin> well, in the ACPI spec 6.5, 5.2.12.2 Processor Local APIC Structure it says "If this bit
<muffin> is clear and the Online Capable bit is also clear, this proces-
<muffin> sor is unusable"
<muffin> refering to the Enabled bit
<heat> ah okay, thanks
<heat> i should fix this
_ngn has quit [Ping timeout: 260 seconds]
_ngn has joined #osdev
heat has quit [Remote host closed the connection]
heat has joined #osdev
heat has quit [Read error: Connection reset by peer]
heat has joined #osdev
heat has quit [Read error: Connection reset by peer]
heat has joined #osdev
Left_Turn has joined #osdev
GeDaMo has joined #osdev
rom4ik has quit [Quit: Ping timeout (120 seconds)]
rom4ik has joined #osdev
nikolar has joined #osdev
muffin has quit [Quit: leaving]
emntn has quit [Quit: WeeChat 4.4.2]
Artea has joined #osdev
EmanueleDavalli has joined #osdev
bauen1 has quit [Ping timeout: 244 seconds]
Left_Turn has quit [Ping timeout: 264 seconds]
<EmanueleDavalli> I managed to cross-compile binutils for my os, I'm happy
kline has quit [Quit: *.banana *.split]
kline has joined #osdev
Left_Turn has joined #osdev
Left_Turn has quit [Read error: Connection reset by peer]
mid-kid has joined #osdev
Left_Turn has joined #osdev
Left_Turn has quit [Remote host closed the connection]
<mid-kid> I want to run 32-bit code inside a 64-bit linux program, to be able to embed precompiled code inside of the program.
<mid-kid> Any tips on where I should look to do this? Does anyone have any examples?
<mid-kid> I don't need to be able to access 32-bit system calls, just jump from the 64-bit code to the 32-bit code, and call 64-bit functions from hooks I'll install in the 32-bit code.
<GeDaMo> I don't think you can call 32-bit code directly from 64-bit on x86, it might have to be a separate process
<sortie> mid-kid: Unless the Linux kernel has a syscall for switching a thread to 32-bit, that's not really possible. But see the x32 ABI which is a 32-bit subset of x86_64.
<sortie> mid-kid: Can you tell us more about your motivation? Why don't you just embed 64-bit code?
<mid-kid> I don't suppose x86_64 instructions are encoded the same as x86 instructions?
<sortie> They kinda are but not 1:1 and they don't quite mean the same thing
<mid-kid> yeah that doesn't work for me
<sortie> Very similar but different
<GeDaMo> Some 32-bit instructions have been repurposed
<sortie> You got some binary blobs you want ro run?
<mid-kid> I got binary blobs yeah
<sortie> If they don't need system calls, I'd say spawn a 32-bit child process to run the binary blobs and use IPC to do RPCs into them
<sortie> Can you tell us more about the nature of these binary blobs?
<mid-kid> This is the project: https://github.com/mid-kid/metroskrew/ I extract code from a windows exe, patch it, and execute it.
<bslsk05> ​mid-kid/metroskrew - Port of the proprietary Windows Metrowerks ARM compiler to Linux by relinking (0 forks/4 stargazers)
<mid-kid> Right now it runs as a 32-bit binary
<sortie> Aha. And Wine isn't good enough for you?
<mid-kid> But I was wondering if I could make it a 64-bit binary without too much fuss
<sortie> Because that is kinda what wine is
<mid-kid> WINE is slow as molasses
<mid-kid> especially for things like this (a compiler) that is expected to be called thousands of times in short succession
<sortie> Making it a 64-bit binary is basically making it a 32-bit binary and just running it under a 64-bit kernel
<sortie> Unless you replace large parts of it with your own code and only got a couple tiny blobs
<mid-kid> hmm
<mid-kid> I did hear from somewhere that it's possible to jump to 32-bit code by reconfiguring some things, as long as you don't need syscalls.
<mid-kid> But I fail to remember what they mentioned about it.
<sortie> From a kernel point of view, totally doable, you can do that with the GDT and special instructions. Basically some of the first things you learn in osdev. You have to be the kernel though.
<sortie> So for your purposes, the question is whether Linux has a system call that can do this. For all I know, it might. wine could be using it.
<mid-kid> Yeah that's the thing that spurred this on
<sortie> mid-kid: But are the blobs 99% of your process? Or have you written a lot of code around them?
<mid-kid> WINE is implementing a method of running 32-bit programs without needing 32-bit libraries and support
<mid-kid> And I'm not sure what it's doing to accomplish that
<mid-kid> Surely it has wrappers to cross the boundaries at a win32 API level but
<sortie> wine acts as the dynamic linker
<mid-kid> sortie: the wrappers are most of my process
<mid-kid> sorry the blobs are most of my process
<sortie> In that case, you don't get any benefits from 64-bit.
<mid-kid> what I'm seeking is supporting userspaces without 32-bit support like WSL1
<mid-kid> the processor supports 32-bit no matter what
<mid-kid> just userspaces are all over the place
<sortie> If you want to run a Linux 32-bit program on on any platform, qemu-i386 is handy: https://www.qemu.org/docs/master/user/main.html
<bslsk05> ​www.qemu.org: QEMU User space emulator — QEMU documentation
<sortie> It basically translates the program dynamically to your native instruction set
<mid-kid> not really an option when I'm seeking speed lol
<sortie> qemu is fast especially with kvm
<sortie> The qemu-user mode doesn't emulate an entire OS, it just translates one process
<mid-kid> the alternative to this would be dumping all the ASM and writing a static recompiler for a few key CPUs
<sortie> mid-kid: But if you want fast? You got a 32-bit Linux process. Just run it.
<sortie> It works on 64-bit Linux too. Try static linking if you can't rely on a runtime.
<mid-kid> not an option on WSL1
<mid-kid> niche platform but eh
<sortie> Well if you can't afford a Linux system then I don't know what to say :)
<mid-kid> lol
<mid-kid> it was also just curiosity
<mid-kid> since I know it's possible
<mid-kid> maybe I should ask the WINE devs
<sortie> In any case, this is kinda a bit outside the realm of osdev, although I do see how this is a project that kinda falls through the cracks of established communities
<sortie> Wine devs might definitely know more about cursed Windows and Linux stuff
<mid-kid> true, I'm just not aware of many low-level tinkering communities on the internet
zhiayang has quit [Quit: oof.]
<sortie> Totally. This is a fine place to ask. Just that, you know, most people here mostly spend time on their own osdev projects and might not know cursed corners of the Linux kernel :)
<mid-kid> seeking help with this project, involving a bunch of quirks of ELFs, binutils and linux/windows APIs, has been naught impossible in general :)
<mid-kid> thankfully I didn't end up needing a lot of it but if there's anyone that knows about CPU states and segments it's you guys
bauen1 has joined #osdev
<sortie> I'm afraid it's going to be a lot of getting fragmented information from here and there
<mid-kid> hehehe
<mid-kid> I'm like 90% there, porting this to other platforms may be a goal in the future but nowhere in the near future
<mid-kid> I just wondered if I could get away with a filthy 64-bit port for now
<mid-kid> anyways, thanks for entertaining my questions :)
<GeDaMo> Could you use something like qemu to do a one-off translation?
<mid-kid> I'm not sure what you mean?
zhiayang has joined #osdev
<GeDaMo> Translate from your 32-bit code to 64-bit code
<GeDaMo> Normally, qemu translates at run-time, I'm just wondering if it can do an ahead-of-time translation
<mid-kid> I don't think it can, but it's something I've been musing doing myself
<mid-kid> it's not a very rogue binary that pulls nasty tricks so I could make a bunch of assumptions
<mid-kid> problem is mostly I can't get away with just dumping and manually inspecting the asm once
<mid-kid> there's like 24 versions of this compiler I want to support
<mid-kid> and its assembler, and its linker
<mid-kid> currently I have a program that analyzes the PE data and looks for certain function signatures
<mid-kid> to automatically fix things up and patch some functions
<mid-kid> AOT translation would require correctly identifying all functions, references to rodata, and etc
<mid-kid> programs like radare2 and rizin do a decent but not perfect job at that, so I kind of doubt QEMU is equipped to tackle that problem.
<mid-kid> anyway, thanks again, and sorry for flooding the channel
edr has joined #osdev
Left_Turn has joined #osdev
raphaelsc has joined #osdev
PublicWiFi has quit [Quit: WeeChat 4.3.0]
heat has quit [Read error: Connection reset by peer]
heat has joined #osdev
<heat> mid-kid, you most definitely can run 32-bit code in a 64-bit program
<heat> i'm 99% sure you can just switch segment registers and it Just Users
<heat> Just Works
<heat> not just users obviously
voidah has quit [Ping timeout: 244 seconds]
<heat> basically keep a thunk in a 32-bit region, switch data segment registers (ds, ss, fs, gs, es) to a 32-bit segment, then long jump with a 32-bit compat segment
<heat> this is very likely to be what wine does
<mid-kid> aha!
<mid-kid> that tracks more closely to what I heard
<mid-kid> are there any examples of this on the osdev wiki? is this 32-bit compat segment documented anywhere in linux?
<mid-kid> (idk is a valid answer lol)
<bslsk05> ​elixir.bootlin.com: segment.h - arch/x86/include/asm/segment.h - Linux source code v6.11.6 - Bootlin
<heat> let me draft up some asm for you
<mid-kid> ooooh, that'd be super helpful
<mid-kid> ah, so the __USER32_CS is the segment I want to jump to
<mid-kid> I assume I'll need to make sure that the program is located in 32-bit addressable memory
McDonaldsWiFi has joined #osdev
<mid-kid> -fno-pie goes a great way towards that goal
<bslsk05> ​gist.github.com: switch32.S · GitHub
<mid-kid> oh, you can abuse lret instead of jmp cs:addr
<sortie> heat: That actually works in user-space?
<heat> 99% sure yeah
<heat> you just can't switch privilege rings
<GeDaMo> The best way to get an answer is to say something wrong on the Internet :P
<heat> basically you need that thunk in 32-bit space, plus your 32-bit code and data in 32-bit space (mmap MAP_32BIT in linux gets you there)
McDonaldsWiFi has quit [Client Quit]
<mid-kid> Neat, I'll draft up a way to build a binary that does this
<mid-kid> I want to see if this works in WSL1, in particular. I think that'd be neat.
<mid-kid> Thanks a lot!
<heat> you're welcome :)
<heat> hmm actually those two lret's may be problematic
<heat> switch them out to a ljmp if you can
<heat> because 1) PIE 2) pushl might overflow your relocations 3) textrels
<mid-kid> alright!
<zid`> mmm textrel
<zid`> tastey flightless bird
<bslsk05> ​www.shielder.com: Shielder - Hunting for <del>Un</del>authenticated n-days in Asus Routers
* Ermine has asus router and kinda scared
xenos1984 has quit [Read error: Connection reset by peer]
<Ermine> is kinda scared*
PublicWiFi has joined #osdev
<zid`> I honestly think the various libcs should harden around %n
<zid`> disable it by default somehow
<heat> they do
<zid`> oh?
<zid`> works fine for me with glibc
<heat> they do _harden_
<heat> they don't disable it by default
<zid`> right
<heat> actually macOS might? idk
<heat> or openbsd for the weirdos
<zid`> %n is almost always just used in attacks and not in actual software, tbh
EmanueleDavalli has quit [Quit: Leaving]
xenos1984 has joined #osdev
<heat> the beauty of glibc is that i can't find printf
<zid`> too enterprise for heat
<heat> i'm a fan of REAL CODE for REAL PROGRAMMERS
<heat> not this soyboy definefest
<zid`> I mean, I am too, but, there's often a sadge reason
<zid`> like having to support weird things like onyx
<zid`> or strange compilers like llvm
<zid`> or *shudder*, wide characters
<heat> nah this is just gnuware
<zid`> glibc is slightly too over-enginereed but probably not by that much once you get into it
<Ermine> everything becomes simpler once you get the idea
<heat> i wasn't understanding why a variable existed in a function, but wasn't assigned to, ever (readonly_format)
<heat> turns out they do this in a .c that is then #include'd into a function, twice!
<Ermine> gnu folks like doing this
<nikolar> what do you mean heat
<netbsduser> i like a lot of gnu things but they have elevated pissing on C to a high art
<heat> https://elixir.bootlin.com/glibc/glibc-2.40.9000/source/stdio-common/vfprintf-process-arg.c#L325 half of these identifiers aren't actually identifiers but macros
<Ermine> there's another lib by gnu, which does the same thing
<bslsk05> ​elixir.bootlin.com: vfprintf-process-arg.c - stdio-common/vfprintf-process-arg.c - Glibc source code glibc-2.40.9000 - Bootlin
<netbsduser> it's rotten
<netbsduser> i did some awful stuff in a similar vein when i was very new to c
<bslsk05> ​elixir.bootlin.com: vfprintf-internal.c - stdio-common/vfprintf-internal.c - Glibc source code glibc-2.40.9000 - Bootlin
<nikolar> > # define OTHER_CHAR_T wchar_t
<nikolar> kek
<netbsduser> then i realised slowly by exposure to real C code that you don't just go writing "c", you should study the bsd, solaris, or even the linux codebase to learn how you write real C
<Ermine> that's where musl wins actually
<zid`> I hate reading code so I didn't bother to study
<zid`> I just saw lots of garbage and avoided it :P
<Ermine> even with dns_parse and friends
<zid`> people asking for help and stuff
<nikolar> zid` loves write only code
<zid`> correct
<zid`> code is for *compilers* to read, not people
<zid`> If you don't like the code, delete it
<zid`> and write it again
<heat> in rust
<zid`> in rust you delete it and rewrite it all anyway, because you changed one variable's lifetime
<nikolar> kek
<netbsduser> long story short, if it isn't in kernel normal form or a cognate thereof also derived from kernighan and ritchie's own style, if the codebase doesn't know how to do generic intrusive lists with macros, it's not really C and you ought to avoid it
<zid`> fuck generic lists
<zid`> too enterprise
<nikolar> at least intrusive lists are almost trivial to do
<nikolar> even inc
<nikolar> *in c
<zid`> just throw a fucking struct n *next; in by hand ffs
emntn has joined #osdev
<zid`> send_msg or whatever it is in the linux api can also fuck off
<nikolar> lol
<zid`> "let's implement a very simple packet format using only 'clever' macros"
<nikolar> kek
jedesa has joined #osdev
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 265 seconds]
Left_Turn has joined #osdev
Turn_Left has quit [Ping timeout: 265 seconds]
youcai has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
X-Scale has joined #osdev
Gooberpatrol66 has quit [Quit: Konversation terminated!]
Gooberpatrol66 has joined #osdev
Left_Turn has quit [Remote host closed the connection]
Left_Turn has joined #osdev
goliath has quit [Quit: SIGSEGV]
heat has quit [Read error: Connection reset by peer]
heat has joined #osdev
Left_Turn has quit [Ping timeout: 252 seconds]
netbsduser has quit [Ping timeout: 255 seconds]
netbsduser has joined #osdev
EmanueleDavalli has joined #osdev
Left_Turn has joined #osdev
goliath has joined #osdev
raphaelsc has quit [Ping timeout: 252 seconds]
Turn_Left has joined #osdev
xenos1984 has quit [Ping timeout: 252 seconds]
xenos1984 has joined #osdev
Left_Turn has quit [Ping timeout: 252 seconds]
Left_Turn has joined #osdev
Turn_Left has quit [Ping timeout: 252 seconds]
gog has joined #osdev
bauen1 has quit [Ping timeout: 246 seconds]
Left_Turn has quit [Ping timeout: 272 seconds]
fedaykin has quit [Ping timeout: 276 seconds]
fedaykin has joined #osdev
fedaykin has quit [Read error: Connection reset by peer]
fedaykin has joined #osdev
xenos1984 has quit [Ping timeout: 272 seconds]
gog has quit [Quit: byee]
xenos1984 has joined #osdev
goliath has quit [Quit: SIGSEGV]
voidah has joined #osdev
hwpplayer1 has joined #osdev
X-Scale has quit [Ping timeout: 256 seconds]
mavhq has quit [Ping timeout: 260 seconds]
frkzoid has quit [Ping timeout: 276 seconds]
Fingel has joined #osdev
bauen1 has joined #osdev
Left_Turn has joined #osdev
hwpplayer1 has quit [Remote host closed the connection]
goliath has joined #osdev
LittleFox has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
LittleFox has joined #osdev
<bslsk05> ​gist.github.com: bits.s · GitHub
gog has joined #osdev
<mid-kid> This is what I got so far
<zid`> I've never seen anybody ship source as a batch file that compiles itself
<zid`> it makes sense, but I've just never seen it
<mid-kid> I want to eventually wrap this in C to make it easier to work with but
<mid-kid> I'm wondering why the `ljmp [1f]` code is segfaulting on me
<heat> define not working?
<zid`> because you're running 'long offset 1f' as code?
<mid-kid> heat: It segfaults at that `ljmp [1f]` instruction if you uncomment the section and comment the inmediate ljmp
<zid`> oh wait is that
<zid`> ljmp
<heat> what does dmesg say?
<mid-kid> it's assembled as `ff 2d xx xx xx xx` where xx is an absolute address (which is fine due to -no-pie)
<heat> ah you're testing this in WSL1? might not give you a decent dmesg
<heat> let me test locally
<bslsk05> ​github.com: wine/dlls/wow64cpu/cpu.c at master · wine-mirror/wine · GitHub
<mid-kid> WINE does the exact same thing
<mid-kid> so I wonder what I'm doing wrong
<mid-kid> <heat> ah you're testing this in WSL1? might not give you a decent dmesg <- nah I'm running native linux
<mid-kid> I'll test WSL1 later
<mid-kid> one sec I'll grab a dmesg
<heat> runs here?
<zid`> I keep forgetting ljmp exists and isn't just people talking about jmping in gas
<mid-kid> heat: did you comment the `jmp __USER_CS:2f` line?
<mid-kid> [208024.702287] traps: bits.s.elf[971] general protection fault ip:401150 sp:ddd063e8 error:0 in bits.s.elf[401000+1000]
<mid-kid> waaaait
<mid-kid> is this a CET thing
<heat> unlikely
<zid`> # ./midkid.s.elf
<zid`> main: 0x0000000000401126
<zid`> aaa: 261
<heat> i mean if it works without the [] i'm happy
<mid-kid> let me upload the exact segfaulting version
<heat> i don't immediately see why the indirect jump wouldn't work
<zid`> do I need to uncomment anything
<heat> wait, reload segment registers?
<heat> i did tell you to do that
<mid-kid> heat: Is that it, really?
<heat> maybe?
<zid`> # ./midkid.s
<zid`> main: 0x0000000000401126
<mid-kid> yeah it segfaulted now
<mid-kid> Oh I guess [1f] is a data reference, so a data segment being wrong would mess it up
<zid`> [1328864.050223] RIP: 0023:0x401154
<zid`> [1328864.050578] Code: 00 00 00 48 8d 35 f2 ff ff ff 31 c0 e8 f5 fe ff ff b8 0f 00 00 00 48 89 25 ca 2e 00 00 ff 2d 00 00 00 00 53 11 40 00 23 00 37 <ff> 2d 5a 11 40 00 60 11 40 00 33 00 48 8b 25 aa 2e 00 00 48 8d 3d
<mid-kid> hmm
<zid`> crashed on the ff 2d 5a 11 40 00
<mid-kid> yeah
<zid`> 401154: ff 2d 5a 11 40 00 jmp FWORD PTR [rip+0x40115a]
<heat> hmm, for one, might not be needed, data segments don't have bitness
<mid-kid> I've just been unable to find the __USER32_DS value
<mid-kid> so I figured they stayed the same
<heat> otoh i anecdotally needed to switch for my kernel code, apparently
<zid`> 0x401160 0x33
<zid`> where do these user32cs and usercs come from? hardcoded in linux's gdt?
<heat> yes
<mid-kid> yeah
<mid-kid> yep, loading the segment registers fixed it
<mid-kid> damn, ok
<heat> okay there you go :)
<mid-kid> updated gist
<mid-kid> thanks a lot!
<zid`> why does it crash though
<heat> you're welcome :)
<heat> yeah i wouldn't know honestly
<mid-kid> zid`: [1f] imples ds:[1f] I think?
<zid`> right but your ds should be valid to begin with
<mid-kid> let me gdb it
<heat> gdb won't tell you much
<heat> actually gdb will probably royally blow up
<zid`> you need the error code from the gpf
<mid-kid> nah gdb has no issue with it
<zid`> if it's set to a number, it means you loaded an invalid descriptor, otherwise you go down a fuckin huge list of reasons :P
<mid-kid> ds is 0 after the ljmp
<heat> error is 0
<heat> oh? okay then, that makes sense
<mid-kid> ss is set correctly
<zid`> oh, is linux doing the '0 selectors are weirdly valid' thing
<mid-kid> and es is cleared
<heat> no
<zid`> which then blows up on the *next* transition
<heat> i mean, maybe
<heat> idk
spare has left #osdev [#osdev]
<zid`> you can leave a bunch of selectors 0 when you iretq back to userspace
<heat> segment registers and their context switching is hard and annoying
<mid-kid> I think ds and es aren't used in 64-bit mode at all
<mid-kid> so linux doesn't set them
<mid-kid> they're not set in main: either
<zid`> and they don't explode unless you try to fuck with them.. like we're doing here
<zid`> ss can also be 0 I think, weirdly?
<mid-kid> yeah, setting ds as the first thing in main() works too
<zid`> nod, solved imo
<mid-kid> it's preserved across the switch
<mid-kid> thanks again
<heat> this is for all the haters that said it couldn't be done
<heat> it can be done, it is discussing, and you just did it
<heat> disgusting
<zid`> I never would have thought of it, but I guess it's just.. fine? lol
<zid`> how do the syscalls react?
<zid`> don't give a shit because they reload cs anyway?
<mid-kid> I wouldn't dare execute syscalls like this
<heat> gotta make legacy syscalls with their numbers i believe
<heat> but yeah obviously reloads cs
<heat> this is getting into a 32-bit compat mode process, manually
<zid`> you'd wanna use the old ones just to get low pointers
<zid`> but I mean, theoretically, if everything was mapped low enough.. could you use the proper ones? :D
<heat> hmm actually it seems that 32-bit syscall emulation is one thing you can't poke from userspace
<zid`> even through int 0x80?
<zid`> I have no idea how linux even knows whether you're a 32bit or 64bit process unless that's how, int 0x80 vs syscall
<heat> oh wait, you might just be able to, through int 0x80
<heat> or even 32-bit sysenter/syscall, which it seems you can differentiate
<zid`> oh can you size modrm it
<zid`> then it dispatches differently in the cpu
<zid`> and linux can TELL
<heat> wdym
<zid`> syscall vs .byte 0x67 syscall
<zid`> which then does something.. different? I've never done a 32bit syscall syscall
<heat> that's a funky idea but i don't think that's what they do
<zid`> my worry is just that half the backend isn't set up
<zid`> like, a 32bit process not having a bunch of MSRs filled out for 64bit syscall to work, but in reverse
Arthuria has joined #osdev
<kof673> re: batch files with source, when i was talking about pragma stuff a long time ago, doug16k said ms stuff used pragma, not sure if that was just command-line flags or what. not the same but...
<geist> i'd think linux would just store somewhere that its a 32 or 64
<geist> like in the current thread structure
freakazoid332 has joined #osdev
<heat> yeah but apparently not
<heat> okay it seems they always assume int 0x80 is 32-bit
<heat> you could totally do it by segment register though (if cs == USER32_CS, compat syscall)
<zid`> sounds slow
<zid`> for no benny feet
<zid`> does 32bit syscall exist
<zid`> ah no
<zid`> Compat/Leg Mode, Invalid
<zid`> sysenter is both though
<zid`> IA32_SYSENTER_EIP (MSR address 176H) — The value of this MSR is loaded into RIP (thus, this value references the first instruction of the selected operating procedure or routine). In protected mode, only bits 31:0 are loaded.
<gog> on AMD yes
<zid`> let's do 32bit sysenter and 64bit syscall
<zid`> and int 0x80 calls rand()
<heat> it works nicely in practice because no one ever did/was able to do sysenter/syscall directly
<heat> always through the vDSO, and in that case they can just make it int 0x80
<heat> in case they don't use the vdso, always int 0x80
<geist> i guess the question there is can you int 0x80 from 64bit. ie, does the IDT get changed when you switch modes?
<geist> if they do switch or otherwise disable it in 64bit mode then coming through int 0x80 is prooof enough that it came from 32bit
<heat> you can't
<heat> 0x80 is always compat
<geist> i forget the detail there how that's disabled (or is it just implicitly disabled in 64bit mode?)
<geist> been a whiel since i thought about those details
<geist> now i'll have to re-read sysenter vs syscall. alls i remember is sycall is the only one used in 64bit on most systems, and usually sysenter is used in 32bit. some of it is because of availability on different cpus due to intel vs amd and for the longest time neither implementing both fully
<geist> syscall is always implemented in 64bit because it was part of amd64 from the get go so intel was forced to implement it
<geist> and thus it is the defacto 64bit mechanism
<heat> yea
<geist> even if syscall wasn't 'their' design
<heat> iirc intel implements sysenter in 32-bit and 64-bit, syscall only in 64
<geist> yah, and eventually amd implemented both in 32bit but since only sysenter is really available there on all cpus, no one bothers implementing syscall in 32bit
<geist> since IIRC they're about the same speed
<geist> iirc sysenter was added in P3. i remember running benchmarks on it on my P3 back in the early 2000s and it was indeed much faster
<geist> or more to the point the int mechanism on that class of machine was hundreds of cycles
<geist> and syscall/sysenter does like 1/10th of the work
<heat> now we just need to benchmark FRED
<zid`> Can we benchmark FRED on a pentium 3 though
<zid`> they'll bundle it with some awful modern intel cpu sadl
<zid`> with 28 cores clocked at 1GHz
<zid`> and 4 pci-e lanes
<heat> 2 P cores and 48 E cores
<heat> when you touch avx512 is halves the frequency
Turn_Left has joined #osdev
<zid`> laptop only
<zid`> 20W part
<zid`> for some reason doesn't have xsave or avx2, but has 512
Left_Turn has quit [Ping timeout: 244 seconds]
GeDaMo has quit [Quit: 0wt 0f v0w3ls.]
<nikolar> Just wait for amd to do it properly
goliath has quit [Quit: SIGSEGV]
<zid`> what a world we live in
voidah has quit [Ping timeout: 255 seconds]
<nikolar> Indeed
<nikolar> Btw geist, apparently -mapxf was enough to get 3 address instructions
<nikolar> GCC 14.2
<geist> nikolar: oh yeah i forgot to follow up. fiddled around with godbolt and got it to generate some apx stuff
<nikolar> Yeah same heh
<geist> i never could get it to really use the upper registers, but i'm sure if i gave it a complicated enough algorithm it eventually would spill over
<geist> in general i was seeing it use apx to use 3 address stuff to replace a alu + mov instruction sequence
<geist> and not much morer than that
<geist> in both clang and gcc
karenw has joined #osdev
<karenw> So the x86 lapic LINT0/1 registers have a 'type' and a 'vector'. What happens if I put 'type=NMI' and 'vector!=0x2'?
<nikolar> Yeah, I imagine 16 registers is quite enough for a vast majority of code
<nikolar> At least simple stuff you're messing with
EmanueleDavalli has quit [Quit: Leaving]
<zid`> karenw: presumably, your nmis stop working, if that's what it's supposed to be
<karenw> zid`: Fair, but would it route NMIs to a different vector, or would they come in on vector 0x2 regardless, or would hilarity ensure?
<zid`> I think those vectors are actually prios?
<karenw> Ah, that makes sense, it would just use the priority class of the vector.
<karenw> And ignore the least significant nibble
<zid`> I'm not sure you actually *have* anything connected to lint1 though
<zid`> lint0 is the pic and lint1 is the nmi line, I think, on a PC mobo
<zid`> and the nmi line is like, hardware watchdog
<karenw> Yeah, that's what I understand from the intel MP spec.
<zid`> if your server mobo has one
<karenw> There could be x86 devices out there with different configs, but they wouldn't be a 'PC-compatible' at that point.
<gog> NEC PC-98 for example
<heat> why are you reading the intel mp spec?
<zid`> MPS is what covers the APIC
<zid`> The SDM just says "read the MPS"
<zid`> no idea if it's *useful* to do that, but it does say it :p
<zid`> acpi is a superset of mps I think?
<karenw> The MP spec covers how the I/O apic, lapic, legacy pics are all wired together.
<karenw> That's the only chapter I'm reading anyway
<zid`> once you've read all this, tell me how msi works kthx
<karenw> zid`: Not in the MP spec, it only goes up to PCI bus not PCIe
<zid`> Once you've read all of the things, tell me how msi works kthx
<karenw> Willdo lol.
<karenw> Interrupt handling is a giant rabbit hole. I should have just gone with "Turn the legacy pics back on and pretend I'm Windows 3.1"
<zid`> My PCI-E interrupts arrive over the INT# thing and magically work and that's all I care about, the rest is fucking voodoo that I will not be touching unless it's to upgrade it to MSI from some well written notes :P
<karenw> I still haven't even got lapic/ioapic working. I just want to see keyboard interrupts (hoping that doesn't mean setting up USB)
<zid`> legacy usb in bios enabled makes it show up as ps/2 data I think
<zid`> via fakery involving SMI/SMM, was my assumption, but I never checked
<gog> that's about right
<gog> iirc
<zid`> cpu catches usb interrupt inside smm handler, it re-posts it as fake ps/2 data and returns, was my guess
<zid`> until you disable usb legacy on the controller and deliver it to 'yourself' instead
jedesa has quit [Quit: jedesa]
mavhq has joined #osdev
<kof673> > NEC PC-98 yes, and there is djgpp for whatever dos that is, good gog
<gog> GOGDOS
<zid`> I'll stick to GLADOS
<zid`> At least she'll berate me while I die
<gog> and cake
<zid`> every man's dream
<zid`> cake and being berated by a woman
netbsduser has quit [Ping timeout: 255 seconds]
<karenw> Christ, more random config I haven't found documented anywhere. Should lapic interrupts be level or edge? Limine leaves LINT0/1 as level and the rest as edge.
<heat> interrupts should be whatever the ACPI tables tell you
<zid`> PCI is level
<karenw> I'll leave them as level then
<karenw> Until I bother to parse ACPI
<zid`> It just depends what's connected to it, I'd just assume that whoever wired it up in your firmware left it wired correctly, shrug
<zid`> it'll be good enough for the keyboard and network to work I'd assume
<zid`> because of uefi supporting both internally
<heat> you need to parse ACPI
<zid`> If it doesn't work, buy a new computer where it does work*
<heat> IRQs with the wrong polarity will fuck your shit up
<karenw> Does ACPI also tell me what vector I should use for each LVT register? Or is that something my OS picks?
<karenw> And if it's configured to ExtINT, the vector I pick just acts as the base vector? Urgh, confused myself again
<heat> i don't remember what none of that shit is
<zid`> lint0/lint1 are the two legacy 'interrupt' pins, everything else is the fancy modern ioapic stuff
<heat> as far as i know you can skip everything
<heat> except the real pins
<heat> and the spurious irq thing
<zid`> so either you ignore the apic and just use lint0 via the pic, or you go all in on the apic and tell everything to deliver to the ioapic
<zid`> and disable the pic
<zid`> hope that helps
<karenw> The lapic timer also is useful and architectural.
<karenw> Or ignore the lapic and use the PICs directly
<zid`> you then program the ioapic to send an interrupt to a certain core's lapic
<heat> oh LVT is the timer
<heat> okay yeah you can pick whatever you'd like
<karenw> But you can't do SMP without the I/O apic mode
<zid`> You only need to bump the wakeup interrupt though
<zid`> not actually *use* them
<heat> vectors are purely a CPU thing, ACPI won't tell you anything, you can lay vectors out as you'd like
<karenw> LVTT is the timer LVT.
<zid`> lapic configuration is the final step, for 'what do with interrupt?'
<zid`> vectoring, masking, etc
<zid`> acpi tables are mostly full of "this is what's sending what to the ioapic" and "this is what's connected to lint0 and lint1" and stuff, lapic is internal and cpu controlled, the rest is how wires are connected
<heat> btw ISA interrupts (pin <= 19 it seems) need to be active-high, edge triggered, fixed delivery
<zid`> and needs the tables
<heat> was just checking my code
<zid`> everything should be active high edge
<zid`> people who do level and low are monsters
<karenw> https://pastebin.com/5bnnmDGE That's my current config. I guess it's time to actually parse ACPI to learn how to configure the I/O APIC. Maybe it will also reveal some lapic stuff I haven't learned yet.
<bslsk05> ​pastebin.com: (qemu) info lapicdumping local APIC state for CPU 0 LVT0 0x00008730 activ - Pastebin.com
<karenw> I still don't know what half of those registers actually are.
<heat> would love to help but uhhhhhhhhh i last looked at a lot of those bits either 3 or 7 years ago
<zid`> I'd have to check qemu source
<zid`> cus lvtpc isn't anything
<karenw> I still don't understand what 'ExtINT' mode actually doex
<zid`> I think it's talking about legacy pic
<zid`> when it says that, but it's a guess, qemuism again I think
<karenw> zid`: I assume it's the "LVT Performance Monitoring register", but QEMU is using an acronym for "Performance *Counter*"
<zid`> ooh clever
<karenw> Since LVTERR/LVTTHMR map to the LVT Error and LVT Thermal Sensor so that's the only one that's left.
<karenw> Although intel says all three of those are non-archetectural so I'm ignoring them for now
<zid`> for keyboard all you need to do is set the ioapic to deliver ps/2 interrupts via the apic not the pic, and disable the pic
<zid`> and to deliver it to a core that you actually have onlined, ofc
<karenw> I should have the PIC disabled correctly.
<zid`> doesn't your paste say you have it mapped to interrupt 48
<zid`> I mean, that's probably also fine
<karenw> LINT0 is mapped to interrupt 48. But the PIC itself is offline.
<zid`> like, if it never sends anything, that's also disabled
<zid`> yea
<karenw> There's a config register somewhere to re-route interrupts directly to the I/O apic I need to check that's set (it probabally is) and then actually unmask the IO APIC
<zid`> and the acpi tells you what's connected to each 'external' pin on the ioapic, and the ioapic can then route it to a specific pic
<zid`> specific apic
<zid`> keyboard sends irq 2 -> ioapic routes -> core 0 as interrupt 7 appears
<zid`> or such
<karenw> But the legacy pics are mapped to interrupts 32-47, then all masked off.
<karenw> I probabally don't need to map them anywhere, but earlier getting interrupts from them was progress
<heat> don't need to map the legacy pics yah
<zid`> can qemu dump your ioapic
<zid`> info pic has some stuff right?
<heat> yeah it can
<zid`> apparently my qemu emulates an ioapic with 24 external pins, and they're all routed to cpu 0
<zid`> I don't know what's connected to any of those pins though, haven't read the tables :P
craigo has joined #osdev
<karenw> heat: There was a comment on the wiki that you can get spurious legacy pic interrupts even when using the lapic.
<karenw> But that's probabally one of those things on ancient hardware
<karenw> And I don't suppport things pre-x64
<zid`> I don't have any raw ass machines that aren't under a hypervisor
<zid`> to dump my actual acpi tables from
<zid`> annoying
gog has quit [Quit: byee]
<heat> you can get spurious pic interrupts yeah
<heat> but you can also get spurious interrupts in any case
<heat> that's something you _need_ to handle
gog has joined #osdev
<karenw> Yeah, but if they come directly from the PIC, they need to not be mapped to <0x20
<zid`> cosmic ray interrupts
<karenw> Otherwise hilarity ensues
<karenw> If anything comes in on the vectors allocated for the legacy pics I just kprint a message and then send the legacy pics EOIs if they need them.
<karenw> Same if anything comes in via LINT0
<karenw> Just a different message and a lapic EOI
<zid`> I think we should have just chained another 8 more PICs on
<karenw> Oh god no
<zid`> good idea karenw, 12 more pics.
voidah has joined #osdev
<karenw> zid`: Just have pic0 have 8 more pics linked to all of it's lines
<karenw> 64 interrupts should be enough for anybody, right
<zid`> maybe we can make a superpic
<zid`> that has 128 lines, and we just chain two, for 255 interrupts
<karenw> Hardwire them to identiy map to vectors 0-255
<karenw> Hope you don't end up with a device mapped to an exception with error codes
<heat> karenw, yes but you don't actually need to assign vectors to the PIC
<heat> like, it's nice to remap them over the IO APIC space or something, but you really don't need to assign them vectors
<karenw> How would I know it's a spurious interrupt though?
<heat> it's a spurious interrupt if no interrupt handler claims the IRQ
<karenw> So... I'd poll the lapic and iopic and find they report no interrupt has happened?
<heat> no
<heat> generally what happens is: you see what irq number you got (from the vector, by reading a irq chip register, or whatever). you look for installed handlers. then call them one by one. if anyone claims the interrupt, it's not spurious. if someone claims the interrupt, it's spurious
<heat> s/someone/no one/
<bslsk05> ​<heat*> generally what happens is: you see what irq number you got (from the vector, by reading a irq chip register, or whatever). you look for installed handlers. then call them one by one. if anyone claims the interrupt, it's not spurious. if no one claims the interrupt, it's spurious
<heat> you'll EOI anyway
<karenw> Huh. Okay. Well... right now all interrupts are spurious by that logic. Except vector 254 (lapic timer)
<heat> also generally PCI interrupts are level triggered
<heat> so you really need to "claim the IRQ" in the device drivers, or you'll keep getting the IRQ even after EOI'ing in the LAPIC or wahtever
<karenw> Also: that helps explain why my laptop (running linux, not my OS) reports "No handler registered for interrupt {1,2,3}.55"
<karenw> During boot
<karenw> I assume that's linux saying "There was an interrupt on vector 55 on the non-boot processors, but no handler claimed it"
<heat> right
<karenw> This laptop has a lot of nonesense during boot. Like spec-violating ACPI tables and some other stuff. It's super cursed.
<zid`> > laptop
<zid`> found your problem
<zid`> laptop motherboard people are always nuts
<zid`> probably because they redo the shape of them every 20 seconds
<zid`> rather than sticking to a form factor and slowly incrementing the design, with the occasional socket wiring update
emntn has quit [Quit: WeeChat 4.4.2]
<heat> spec-violating acpi tables? that's insanely common
<heat> IIRC all nvidia ACPI tables have a particular bug that ACPI interpreters just need to handle
<Ermine> hence acpica
craigo has quit [Quit: Leaving]
<Ermine> (conformant acpi tables would be a perk of coreboot imo)
<karenw> ACPI Warning: Time parameter 255 us > 100 us violating ACPI spec, please fix the firmware. (20240322/exsystem-141)
<karenw> 12 times every time I boot or resume from sleep
Turn_Left has quit [Read error: Connection reset by peer]
<Ermine> "please fix the firmware" --- like user can fix it
<karenw> Lmao, try updating this piece of crap HP bios without a windows install to do it from
<kof673> <smashes corvette> in frustration
<heat> oh that's useless
<heat> i was going through acpica lately due to our dear maintaining going AWOL
<heat> they changed that warning into a warn once or whatever
<Ermine> > HP