On Sat, Jun 16, 2018 at 01:17:57PM +0200, Almudena Garcia wrote: > Finally, we got to write a test function to get the apic_id, and It feels > to run correctly. > Now, we're trying to implement another function, to transform the apic_id > in the kernel cpuid. > > I attach the current test function to get apic_id with its test file
One other thing. No sane operating system uses the cpuid instruction each time they need to identify the current processor, because of its cost (it's a fully serializing instruction). Instead, they make the fs or gs segment register refer to a per-processor area in memory, where the ID of the current processor can be found, among other things. See the cpu_id() function at [1] for a reasonably simple (but not naive) implementation. -- Richard Braun [1] https://git.sceen.net/rbraun/x15.git/tree/arch/x86/machine/cpu.h?id=7615ab33c6d9e0b858aa3f183095a83f7a1d0620#n471