IRC channel logs

2019-10-30.log

back to list of logs

<damo22>hey AlmuHS
<AlmuHS>hey
<damo22>nice work with smp
<damo22>ive been looking into ioapic
<damo22> http://paste.debian.net/plain/1111966 <--- i wrote this
<AlmuHS>has you read Richard x15 code? https://github.com/richardbraun/x15/blob/26e07e720a1f08f0ce237ce0258fa38b49c47c0d/arch/x86/machine/lapic.c#L293
<AlmuHS>I also need to initialize lapic LVT
<AlmuHS>I enumerated the apic_id of each processor, but I need to initialize the another lapic registers
<damo22>yes
<AlmuHS>but I don't know how do It exactly
<damo22>read my doc
<AlmuHS>ok
<damo22>it doesnt have all the detail required but there is some setup we need to do so that legacy PIC doesn't conflict
<AlmuHS>ok, It seems well
<AlmuHS>you can read chapter 10 in Intel Manuals, to get more info about APIC
<damo22> https://wiki.osdev.org/APIC
<AlmuHS>yes, but this is very simple
<AlmuHS>read this https://software.intel.com/sites/default/files/managed/a4/60/325384-sdm-vol-3abcd.pdf
<AlmuHS>chapter 10
<AlmuHS>you can also read the MP Spec, but is older than the manual https://pdos.csail.mit.edu/6.828/2011/readings/ia32/MPspec.pdf
<AlmuHS>btw, other problem with Mach is that, the most modern cpu which have registered in its code is Pentium Pro
<AlmuHS>see this https://github.com/AlmuHS/GNUMach_SMP/blob/wip/i386/i386/mp_desc.c#L327-L347
<AlmuHS>damo22
<damo22>ok
<damo22>we cannot rely on MP tables
<damo22>they are not supported anymore
<AlmuHS>MP Tables is deprecated
<damo22>yes
<AlmuHS>I'm using ACPI tables
<damo22>good
<AlmuHS>the table which stores the APIC data is MADT
<damo22>mach supporting pentium pro is not a bad thing
<damo22>it means it will theoretically work on any x86
<AlmuHS>but could be necessary to detect more modern models
<AlmuHS>pentium 4, by example
<damo22>we can forget about the extended apic setups
<AlmuHS>no, I can't
<AlmuHS>my implementation is xAPIC based
<damo22>xAPIC is ok
<AlmuHS>because original APIC don't works in Pentium 4 or later
<damo22>x2APIC is too complex i think
<AlmuHS>x2APIC is 64 bit based
<AlmuHS>so, at now I can't use this
<damo22>i mean, there is a mode of apic that uses logical clusters of NUMA nodes
<damo22>we can avoid that
<AlmuHS>but could be interesting detect if the cpu use x2APIC and, in this case, enable xAPIC compatibility mode
<AlmuHS>the latest Core iX models use x2APIC
<AlmuHS>x2APIC has a legacy xAPIC mode, but It is not enabled by default (and I have not implemented It)
<damo22>ok
<AlmuHS>in my Final Degree Thesis I explain all about this. But this is wrotten in spanish
<damo22>no worries
<AlmuHS>if you understand spanish, I can share the link
<AlmuHS> http://uhu.es/etsi/repositorioTFGM/ Select "Grado en Ingeniería Informática" and "2019", and you can find It in the list
<damo22>why dont we use Fixed mode for all interrupts in the IO APIC
<damo22>and route them to actual interrupt vectors
<AlmuHS>It's possible
<damo22>its not that hard
<AlmuHS>but I don't understand APIC very well, so I avoided It
<AlmuHS>if you want implement this, I can say you where is the structures in my code
<damo22>sure
<AlmuHS>wait a moment
<damo22>ive been reading some gnumach code
<damo22>spl.S etc
<AlmuHS>my apic structures is here: https://github.com/AlmuHS/GNUMach_SMP/blob/wip/imps/apic.h
<AlmuHS>I recovered It from old Mach 4 headers, and updated It with latest lapic table
<damo22>there is an ugly hack in gnumach that enables interrupts when setting the IPL
<damo22>to allow linux drivers to call cli/sti
<AlmuHS>and the apic enumeration from acpi tables is here: https://github.com/AlmuHS/GNUMach_SMP/blob/wip/i386/i386at/acpi_rsdp.c
<damo22>ok thanks
<AlmuHS> https://github.com/AlmuHS/GNUMach_SMP/blob/wip/i386/i386at/acpi_rsdp.h
<AlmuHS>I have to rename some functions, btw
<AlmuHS>the name is not clear about its purpuse
<AlmuHS>*purpose
<AlmuHS>the cpu enabling and configuration is here: https://github.com/AlmuHS/GNUMach_SMP/blob/wip/i386/i386/mp_desc.c
<AlmuHS>and here is the assembly snippet to jump to protected mode: https://github.com/AlmuHS/GNUMach_SMP/blob/wip/i386/i386/cpuboot.S
<AlmuHS>in the README I explain a bit about the implementation, although is a bit outdated
<AlmuHS> https://github.com/AlmuHS/GNUMach_SMP/blob/wip/README.md
<damo22>doesnt the bootloader start in protected mode?
<AlmuHS>nope
<damo22>you're basically switching back to flat 16 bit mode and starting from scratch
<AlmuHS>I explain
<AlmuHS>when the computer starts, it initialize some apic structures. But, after this, the BIOS select a cpu (called BSP), and start It. And the another are set as standby
<AlmuHS>to start the another cpus (called AP), It's needed to send an IPI (a special type of IRQ): the startup IPI
<damo22>yes
<youpi>on x86 the boot loader starts in real mode indeed. but grub loads the kernel in protected mode
<AlmuHS>but, when the cpu receive the IPI, It wake up in real mode
<youpi>uh
<youpi>what a legacy thing :/
<damo22>oh darn
<AlmuHS>but the kernel starts, at first, with only the BSP cpu
<AlmuHS>if the kernel wants to use another processors, It has to wake up them using startup IPI
<AlmuHS>and these processor (the AP processors) starts in real mode, as I said
<damo22>"(22:58:58) AlmuHS: but, when the cpu receive the IPI, It wake up in real mode" This explains all
<AlmuHS>the BSP continue in protected mode, there isn't problem with this
<AlmuHS>the kernel starts only with BSP
<AlmuHS>and, during the kernel boot, I need to start the another processor (AP processors)
<damo22>yep
<AlmuHS>when I send startup IPI to APs, the APs wake up in real mode
<damo22>i get it now
<AlmuHS>the BSP continues in protected mode, no problem with this
<damo22>why is your idt_descr empty
<AlmuHS>I set It later, with idt_init() call
<AlmuHS>in cpu_setup()
<AlmuHS>mp_desc.c
<damo22>.word 3*8+7 allocates space for the IDT?
<AlmuHS>what line?
<damo22>21
<AlmuHS>nope, It is part of gdt descriptor
<damo22>where is the idt?
<AlmuHS>is empty in this snippet
<AlmuHS>line 14 to 15
<AlmuHS>*16
<damo22>yes, but you need space for it
<damo22>?
<AlmuHS>I assumed that idt_init() do It
<AlmuHS>I load an empty IDT in line 78 in cpuboot.S
<damo22>how much space do you need for an IDT?
<AlmuHS>I don't know exactly
<AlmuHS>see idt.c file
<AlmuHS>i386/i386/idt.c
<AlmuHS>this is not mine, is from gnumach
<damo22>ohhh you load an empty one
<AlmuHS>yes, I said It before
<damo22>and then allocate it again later
<AlmuHS>yes
<damo22>ok
<AlmuHS>youpi: can you check my latest Hurd patch? I sent It two days ago
<damo22> https://github.com/AlmuHS/GNUMach_SMP/blob/6216e74dd0d961915edee69098f6e8d27a4ba896/i386/i386/idt_inittab.S#L96
<youpi>AlmuHS: I assumed you were working on the last_pocessor field detection
<AlmuHS>youpi: I sent the patch after you latest email
<AlmuHS>just after, in fact
<youpi>"latest" is not precise enough :)
<AlmuHS>wait, I search It
<youpi>Date: Tue, 29 Oct 2019 00:05:09 +0100
<youpi>that's what I have
<youpi> the code seems correct to me, but lacking autoconf check for the field
<AlmuHS>oh, I didn't know about I have to do It
<AlmuHS>reply about how a to do It (a lightly idea at least), in which file
<AlmuHS>damo22: thanks. I didn't found this table before
<youpi>I thought we had discussed about it on irc
<AlmuHS>in my historial I don't find It
<youpi>add to configure.ac a call to AC_CHECK_MEMBER to check for the struct member
<AlmuHS>oh, really
<youpi>that'll define a macro you can use in #ifdef/#else/#endif in the code
<AlmuHS>ok, then I'll check It later
<AlmuHS>damo22: do you understand my smp work?
<damo22>some of it yes
<AlmuHS>if you speak spanish, you can read my final degree thesis, that I linked It before
<damo22>unfortunately my spanish is not that good
<AlmuHS>then you can read the implementation chapter in README.md
<AlmuHS>is a bit outdated, but includes all the basic
<AlmuHS>and you can read the original draft, in https://gitlab.com/snippets/1756024
<damo22>i know about ACPI a little alreadyt
<AlmuHS>in my draft I link to ACPI specification
<damo22>i wrote acpi translator for hurd
<damo22>you can access the tables raw in /servers/acpi/tables
<AlmuHS>yes, but I never wrote a translator, and a friend wrote me the acpi_rsdp.c function (I only fixed and improve It)
<AlmuHS>so I prefered use this
<damo22>yeah sure, you need it in gnumach anyway
<damo22>to enumerate the APIC tables
<AlmuHS>yes
<AlmuHS>my laptop battery I'm mostly empty now, I have to shutdown in a moments
<damo22>ok
<damo22>i gtg to sleep
<AlmuHS>ok, good night
<damo22>:)
<damo22>use ctags and grep more AlmuHS
<damo22>;)
<deavmi>test
***deavmi_ is now known as deavmiHurd
<deavmiHurd>Anyone running i3 on Debian Hurd here?
***deavmi_ is now known as deavmiHurdLaptop
<AlmuHS>youpi: is this check correct? http://dpaste.com/0T2CA9Z
***Emulatorman_ is now known as Emulatorman
<youpi>AlmuHS: better use AC_CHECK_MEMBERS, which already does the AC_DEFINE on success
<AlmuHS>oh, ok
<AlmuHS>I never used It, I'm learning now at first time
<AlmuHS>youpi: and now?
<AlmuHS> http://dpaste.com/3YJDKGG
<youpi>I believe you still need the #include ?
<youpi>(see in config.log for the details of what is happening)
<AlmuHS>ok
<AlmuHS>youpi: config.log https://pastebin.com/HSMPEdRf
<youpi>AlmuHS: see, it doesn't know the structure, the include is indeed missing in the test file
<AlmuHS>It's true. what is the syntax to add include in AC_CHECK_MEMBERS ?
<AlmuHS>I don't find any example which add include
<youpi>you need to read the info manual of autoconf to know that
<youpi>that's the proper documentation
<youpi>looking for examples on the web has limits
<youpi> https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Generic-Structures.html
<jrtc27> https://codesearch.debian.net/search?q=AC_CHECK_MEMBERS
<jrtc27>first hit:
<jrtc27>util-linux_2.34-0.1/configure.ac
<jrtc27>])
<jrtc27>AC_CHECK_MEMBERS([struct termios.c_line],,,
<jrtc27> [[#include <termios.h>]])
<youpi>yes, but again, looking at the proper doc is usually better to make sure how things are supposed to be
<AlmuHS>yes, but I didn't understand the docs
<youpi>examples are good, sure, but proper documentation should *also* be used
<AlmuHS>I'm very noob
<youpi>sure, I don't mean the documentation is enough
<youpi>but don't only use examples
<jrtc27>yeah, you really want both together
<AlmuHS>yes
<jrtc27>anyway, codesearch.debian.net is a lifesaver for finding examples of pretty much anything
<AlmuHS>ok, I'll take notes
<AlmuHS> https://pastebin.com/M90ExX06
<AlmuHS>check now