IRC channel logs

2020-04-26.log

back to list of logs

<damo22>hey almuhs
<almuhs>hi
<damo22>acpica works
<damo22> http://paste.debian.net/plain/1142935
<terminatrix>yeah, i told her this morning lol
<damo22>?
<terminatrix>yup damo22 she told me you was working on the acpica a couple of days ago
<terminatrix>then this morning i read you when you wrote it was working :P
<terminatrix>you were*
<terminatrix>on the other side, i've not been able to run the system on vbox >.<, and i'm still installing it on qemu (it goes painstakingly slow)
<damo22>terminatrix: try -M q35,accel=kvm
<damo22>in qemu with kvm option it runs super fast
<terminatrix>damo22, im on w10 >.< so i got no support for hyperv
<damo22>oh
<damo22>why is a person interested in hurd running windows?
<terminatrix>i would have to create a native partition on my desk and install lnx to run qemu properly
<terminatrix>damo22 lol, so simplistic!
<almuhs>excuse me, I was afk
<almuhs>damo22: It's great!! Has you got found APIC tables then?
<damo22>have a look at the dump
<damo22>it initialised all the tables
<damo22>there is a function now called acpi_init() and you can put anything you need in there
<damo22>it currently just loads all the tables
<damo22>and populates internal structures
<damo22>you could store the lapic address in a global stored in acpi_init.c
<damo22>or a mapped version of it
<damo22>i could probably clean up the code by moving the "os layer" stuff to a new file
<damo22>im going to get a coffee
<damo22>brb
***Server sets mode: +nt
***Server sets mode: +nt
<almuhs>WOW
<damo22>:D
<damo22> https://www.youtube.com/watch?v=FCKjoI4CTxk
<almuhs>LOL
<almuhs>if this works, the next step is to parse the APIC table to find Local APIC, IOAPIC, and the common reference to Local APIC
<damo22>i think theres a function for that
<damo22>i need to dig up the api docs
<almuhs>AcpiGetTable(), if I remember well
<damo22>i think it already called all that
<damo22>its stored in initial_tables variable
<almuhs> https://acpica.org/sites/acpica/files/acpica-reference_18.pdf
<almuhs>is lapic stored in initial tables?
<almuhs>I'm cloning your repo
<damo22>im not sure
<damo22>i only called acpi_initialize_tables
<damo22>i think i need to call a few other things before and after
<damo22>git checkout debian-acpica
<almuhs>yes, I did It
<almuhs>It's strange. The functions described in acpica-reference, doesn't appears in your acpica code
<almuhs>mmm... maybe these appears, but with other naming
<almuhs>the docs describe this function
<almuhs>ACPI_STATUS
<almuhs>AcpiGetTable (
<almuhs>char
<almuhs>UINT32
<almuhs>ACPI_TABLE_HEADER
<almuhs>*Signature,
<almuhs>Instance,
<almuhs>**Table)
<almuhs>but in the code, this appears as acpi_get_table(char *signature ...
<damo22>yeah i used the linuxized version
<damo22>it looks nicer than camelcase
<damo22>its the same code just renamed
<almuhs>yes, now I understand
<terminatrix>i don't like much the camelcase convention either
<almuhs>yes, It's strange
<damo22>i have a new patch
<terminatrix>and remembers me constantly of java and the like>.<
<almuhs>in your repository? or have you sent a new patch to upstream gnumach?
<damo22>i need to implement 3 more stubs hang on
<damo22>then i will push to mine
<almuhs>I have to find how to compile acpica code in linux
<almuhs>to test how to get APIC table, and how to parse It
<almuhs>the acpica really is compiled and installed, but I need to learn how to use It. At first, what library I have to include in my C snippet
<damo22>there is a way to compile it in userspace
<damo22>i dont know exactly but you have to create a lib
<damo22>my code now page faults
<damo22>trying to follow the init instructions in the spec
<almuhs>be sure that you're calling the function after paging is configured. In other case, you will have addressing problems
<damo22>+ acpi_initialize_subsystem ();
<damo22>+ acpi_initialize_tables (initial_tables, ACPI_MAX_TABLES, 0);
<damo22>+ acpi_load_tables ();
<damo22>+ acpi_enable_subsystem (ACPI_FULL_INITIALIZATION);
<damo22>+ acpi_initialize_objects (ACPI_FULL_INITIALIZATION);
<damo22>i call it after linux_init(
<damo22>in model_dep.c
<almuhs>machine_init()
<almuhs>ok, then this is called just after start the system
<almuhs>setup_main() -> machine_init() -> acpi_init()
<almuhs>i386at_init() -> setup_main() -> machine_init() -> acpi_init()
<almuhs>** c_boot_entry() -> setup_main() -> machine_init() -> acpi_init()
<almuhs>and c_boot_entry() is called in the first routine, boothdr.S
<almuhs>but, anyway, with this sequence, acpi_init() is called after all the memory was configured
<almuhs>in the last function which is called before boot the rest of the system
<damo22>ah it tried to create a semaphore
<damo22>and failed
<almuhs>yours?
<damo22>yes
<almuhs>It's a complex task
<almuhs>youpi recommended me many time ago to do a "big lock" if there are not any fragile resource
<damo22>acpica implements a big lock
<damo22>but you have to provide semaphore handlers
<almuhs>then It's enough
<damo22>but i currently set them to noop
<almuhs>richard recommended me to implement atomic operations
<almuhs>but the most simple approach is using locks
<damo22>i will make my code hang if there is a problem
<damo22>then push
<damo22>then you can read the log
<almuhs>ok
<damo22>pushed
<almuhs>ok, I'm checking the changes
<almuhs>I hate "goto" instruction
<almuhs>I prefer separate this code in a new function (maybe a static function, to avoid expose It outside)
<damo22>sure, its not final
<damo22>its a dirty hack to make it work
<almuhs>ok
<damo22>because its late where you are i had to code it fast
<almuhs>ok, thanks
<damo22>it hangs for me at #2
<almuhs>acpi initialization
<almuhs>maybe can be necessary to reserve a memory page
<damo22>i think its calling acpi_os_create_semaphore
<damo22>and i return AE_NO_MEMORY
<damo22>because i dont know how to create one
<almuhs>this? status = acpi_ut_mutex_initialize();
<damo22>it says where
<damo22>in the log
<almuhs>where is the log?
<damo22>i'll boot it and paste
<damo22>cant create semaphore
<damo22>ACPI Error: AE_NO_MEMORY, During Global Mutex creation (20200326/utxfinit-67)
<damo22>OUCH! where = 2
<almuhs>ok
<almuhs>yes, It the call what I said
<almuhs>status = acpi_ut_mutex_initialize();
<damo22>ok
<damo22>"cant create semaphore" is in acpi_init.c
<damo22>i wrote it
<almuhs>I remember read anything about mutex in Mach, but I don't remember exactly where
<almuhs>yes, but I watch utxfinit-67. This is the file and line
<damo22>linux/ has semaphores
<damo22>i could use the linux functions
<almuhs>but I don't know if It possible to call linux code from gnumach directly
<damo22>it already has linux/ embedded
<almuhs>yes, but linux has Its own libraries
<almuhs>and sometimes these can be in conflict with gnumach libraries
<almuhs>in special, glibc-like libraries
<damo22>i already used it for vremap
<almuhs>then you will try It
<almuhs>but I'm not sure about the linux semaphore can runs well in gnumach, outside of linux code
<damo22>hmm
<damo22>what is a semaphore in the context of this?
<damo22>is it related to threading?
<almuhs>a semaphore is a structure which controls the access to the same memory resource, setting a turn for each thread which wants to access it
<damo22>ohh
<almuhs> https://en.wikipedia.org/wiki/Semaphore_(programming)
<damo22>does gnumach itself have semaphores?
<almuhs>I think not, but I remember something similar
<youpi>in gnumach you'd rather use a simple lock
<damo22>youpi: !
<almuhs>the semaphore implementation can be easy, but not trivial. It's necessary to control samelock
<almuhs>(I don't remember the name exactly, but in concurrency techniques, It's possible that in some situations, all threads are block, waiting to another
<almuhs>deadlock
<terminatrix>yeah, it sounds like you have some sort of intelligent algorythm overseeing the whole sceneario
<almuhs>there are many pseudocodes to implement a software semaphore, avoiding deadlocks
<terminatrix>have to have*
<damo22>youpi: did you see my ACPICA stuff?
<almuhs>youpi possibly are sleeping now. He is french
<almuhs>and now is 2:55 AM
<damo22>oh
<almuhs>by this reason, I told you yesterday that ask your question via maillist
<damo22>yes i did send in a mail
<almuhs>then you have to wait, or reply your own mail being more explicit
<almuhs>oh, I've just saw that youpi replied you 2 hours ago
<damo22>/dev/klog
<almuhs>yes
<damo22>i solved that problem by adding infinite for loop when it fails
<damo22>so i can see errors
<damo22>i will try to allocate a simple lock
<almuhs>gnumach has Its own implementations of simple lock
<damo22>yeah but it needs to have a name
<almuhs>in sched_prim.c there are some examples, If I remembers well
<damo22>acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_semaphore * handle)
<almuhs>what says the docs about this function?
<damo22>whats the difference between a spinlock and a semaphore
<damo22>#define acpi_spinlock simple_lock_t
<almuhs> https://stackoverflow.com/questions/195853/spinlock-versus-semaphore
<almuhs>this phrase is very descriptive: "A semaphore has a counter and will allow itself being acquired by one or several threads, depending on what value you post to it, and (in some implementations) depending on what its maximum allowable value is."
<almuhs>this is the counter in your function
<almuhs>a more practical explaination: https://unix.stackexchange.com/questions/5214/what-is-the-difference-between-spin-locks-and-semaphores
<damo22>ok a spinlock is a semaphore with max value=1
<almuhs>yes
<youpi>also, a spinlock spins
<youpi>a mutex is a semaphore with max value
<youpi>a spinlock is a mutex that spins instead of sleeping
<youpi>(when having to wait for it to be ready)
<almuhs>a spinlock is a waiting loop, is not?
<damo22>do i need to implement semaphores in gnumach?
<damo22>because simple_lock doesnt seem to be enough
<youpi>does acpi really use semaphores as semaphores, and not just as locks ?
<youpi>almuhs: it's a busy-waiting loop yes
<youpi>i.E. keep retrying, instead of going to sleep
<almuhs>the function prototype use a semaphore
<almuhs><damo22> acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_semaphore * handle)
<youpi>yes but that doesn't mean it is actually used with max_units > 1
<almuhs>we can find the calls to this function
<damo22>status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
<damo22>theres a couple of those
<almuhs>status = acpi_os_create_semaphore(1, 0, &main_thread_gate);
<almuhs>status = acpi_os_create_semaphore(1, 1, &thread_complete_gate)
<damo22>most of them are 1
<damo22>but some arent
<almuhs>or combinations with 0 and 1
<damo22>if you create a semaphore with 1, 1 doesnt that mean you can use a simple lock, and just lock it
<youpi>to get inspiration for a semaphore implementation, you can see linux/dev/kernel/sched.c 's __down and __up
<youpi>(1): not exactly indeed, but most often that's meant to be a lock, and thus simplelock is fine
<youpi>but yeah, if there are real uses of real semaphores, then see sched.c
<damo22>do we have spinlocks?
<almuhs>I have academical notes about semaphores, but I don't know if this can be useful to this purpose
<damo22>i could just do a simple lock and do a while loop?
<damo22>i'll try to hack it and assume max_units == 1
<youpi>simple_lock *is* a spinlock
<youpi>don't assume, assert
<damo22>ok
<almuhs>but if max_units == 1, then this could crash with NCPUS > 2, is not?
<youpi>max_units is completely unrelated to ncpus
<almuhs>if NCPUS > 2, and more than two tries to access to same resource, this could crash
<almuhs>is not?
<youpi>??
<youpi>simple_lock does protect against any number of accessors
<youpi>and max_unit in the semaphore definition is *not* the number of accessors
<almuhs>ok, It's true
<youpi>it's the number of tokens in the semaphore
<almuhs>the wait queue size?
<youpi>no
<damo22>linux/src/include/asm-i386/semaphore.h
<youpi>the number of tokens, really
<damo22>we have this already
<youpi>yes but that's awfully linux-glue-specific
<damo22>ok
<youpi>and what you need is not only the fast-path of the inline
<youpi>but the slow path that I mentioned above
<youpi>the __down / __up versions
<damo22>this is getting over my head
<youpi>(token = resource count)
<youpi>what? slow/fast path?
<damo22>yeah
<almuhs>oh, now I understand
<youpi>fast path is to handle the common case when it's available
<youpi>no need to wait
<youpi>just increment count
<youpi>you can do that in assembly
<youpi>but thats hairy
<youpi>and if it's actually not available, you have to go the slow path
<youpi>which actually sleeps
<damo22>ok
*youpi powerdown
<damo22>i will try to code this as a simple lock for now and assert if max_units > 1
<damo22>gnite
<almuhs>if you needs, It's not difficult to find academical notes about semaphores, mutex... etc
<almuhs>with this you can learn a theorical concept
<almuhs>this comment in wikipedia page seems important:
<almuhs>"If the implementation does not ensure atomicity of the increment, decrement and comparison operations, then there is a risk of increments or decrements being forgotten, or of the semaphore value becoming negative. Atomicity may be achieved by using a machine instruction that is able to read, modify and write the semaphore in a single operation"
<almuhs> https://en.wikipedia.org/wiki/Semaphore_(programming)#Semantics_and_implementation
<almuhs> https://see.stanford.edu/materials/icsppcs107/23-Concurrency-Examples.pdf
<damo22>i coded it as simple locks but it crashes on kmem_cache_alloc
<damo22>maybe you should go to sleep
<almuhs>yes, It's so late
<almuhs>read the docs that I sent here
<almuhs>if you can find academical notes, or books about concurrency, you can understand better these concepts
<damo22>its parsing the AML but getting stuck
<damo22>does anyone know how kalloc / kfree is supposed to work
<damo22>how are you supposed to free memory if you dont know the size
<damo22>the linux/ memory allocator stores the kmallocs in a list
<damo22>how does gnumach do it
<damo22>youpi: when i vfree an address mapped with vremap it crashes
<damo22>i have no idea how to map physical addresses to virtual addresses and then free them
<damo22> http://paste.debian.net/plain/1143067/
<damo22>this is gnumach log with verbose acpi
<damo22>looks like the size=0 of the AML i wonder if that caused it to cras
<damo22>h
<damo22>i think the DSDT on qemu is empty
<damo22>ha!
<damo22> http://paste.debian.net/plain/1143073 \o/
<damo22>youpi: braunr thinks we should not put acpica into the kernel, just put a minimal APIC table parser in there instead, but i think there is stuff in DSDT that needs to be parsed from AML and executed to complete the init of the board before the first timer interrupt
<youpi>it'd be better not to put all interpreter stuff in there yes