OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 9:20 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Need information about multiple-processor management in Bios
PostPosted: Sun May 27, 2018 10:21 am 
Offline

Joined: Sun May 27, 2018 9:58 am
Posts: 2
Location: Siberia
Hi! Could anyone explain me a method that bios use for disable selected logical processor?
I didn't found any information about it.


Top
 Profile  
 
 Post subject: Re: Need information about multiple-processor management in
PostPosted: Mon May 28, 2018 12:12 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

XBear wrote:
Hi! Could anyone explain me a method that bios use for disable selected logical processor?
I didn't found any information about it.


In general...

To stop a logical CPU; you'd disable and then flush caches; then disable IRQs with CLI; and then you'd either do HLT or MONITOR then MWAIT. This (almost) puts the CPU into a "do nothing forever" state where the only things that can wake it from this state is an INIT IPI (the first part of the "INIT, SIPI, SIPI" startup sequence), an SMI, an NMI or a machine check exception. Of course you'd also make sure machine check exceptions are disabled so they won't happen, and (at least for BIOS) would mask SMI and NMI sources so they won't happen either. Also, hopefully the BIOS would put the CPU into its "lowest power consumption" state before stopping the CPU (or when stopping the CPU if MONITOR/MWAIT was used); so that it consumes the least power to do nothing.

Depending on why the BIOS was stopping a CPU (e.g. if the CPU was faulty, or "disabled" because hyper-threading was turned off), it might also not mention the CPU in ACPI tables (and MultiProcessor tables) so that operating systems don't know the CPU exists and won't try to re-start the CPU. This is one of the reasons why an operating system should never broadcast the "INIT, SIPI, SIPI" sequence to all CPUs (it might start faulty CPUs that should not be started or used).

Note that there might or might not be CPU specific/model specific things and/or motherboard specific things on top of this. For a random theoretical example (which doesn't really exist in practice because almost no real hardware has ever supported it); if a system supports "hot-plug CPUs" (and if the entire chip is being disabled and not just one of its logical CPU or on of its cores) then the motherboard would probably have some way to (electrically) disconnect the CPU so that it can be removed safely.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Need information about multiple-processor management in
PostPosted: Mon May 28, 2018 9:57 am 
Offline

Joined: Sun May 27, 2018 9:58 am
Posts: 2
Location: Siberia
Thank you for your answer.But I still have some doubt..
If I understood you right, there is only one real exist way to disable logical cpu. I mean disable interrupts, caches and make hlt loop.
As you say it is still possible to wake up halted processor by INIT SIPI SIPI.During my research I disabled logical cpu in bios and after sending broadcast INIT SIPI I had not got answer.

Brendan wrote:
Note that there might or might not be CPU specific/model specific things and/or motherboard specific things on top of this.


Where can I found information about it? In my case (Intel X99 chipset), there is no mentions about management cpu cores in official datasheet.


Top
 Profile  
 
 Post subject: Re: Need information about multiple-processor management in
PostPosted: Mon May 28, 2018 1:17 pm 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
Brendan wrote:
To stop a logical CPU; you'd disable and then flush caches [...]

Why would you disable the cache? To prevent cache coherency errors when you re-online the CPU after write-back pages changed to write-combining in the meantime? That is basically the only reason that I see why you would want to do that?

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
 Post subject: Re: Need information about multiple-processor management in
PostPosted: Mon May 28, 2018 3:24 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

XBear wrote:
Brendan wrote:
Note that there might or might not be CPU specific/model specific things and/or motherboard specific things on top of this.


Where can I found information about it? In my case (Intel X99 chipset), there is no mentions about management cpu cores in official datasheet.


I think that for most Intel CPUs (including things like the memory controller, etc. in recent Intel chips) there's a corresponding "BIOS Writer's Guide" that contains information that isn't available to the general public (where you need to be a company and may need to be some kind of partner/affiliate and probably need to sign an NDA just to look at these documents).

Korona wrote:
Brendan wrote:
To stop a logical CPU; you'd disable and then flush caches [...]

Why would you disable the cache? To prevent cache coherency errors when you re-online the CPU after write-back pages changed to write-combining in the meantime? That is basically the only reason that I see why you would want to do that?


If/when you modify MTRRs you're supposed to follow a special sequence to make sure MTRRs are the same on "all" CPUs (and if you don't you can break cache coherency and risk data corruption). What Intel doesn't clearly say is that you can cheat - if a CPU's caches are disabled (and any/all of its cache's contents flushed), then its MTRRs are irrelevant and you don't need to make sure its MTTRs are the same as the "still enabled" CPUs' MTRRs (but if the CPU is re-enabled you would have to update its MTRRs before enabling its caches).

Note that for some cases (e.g. faulty CPUs, especially if its cache is faulty, and if you're taking a CPU offline in preparation for physical removal) this would be a necessity; but for other cases (e.g. just taking a CPU offline for a little while to save power) you might consider it optional (as long as you bring the CPU back online if/when MTTRs are changed).


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Need information about multiple-processor management in
PostPosted: Tue May 29, 2018 2:16 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
Hi,

the OP's message is ambiguous. Could mean that he wants to know what the BIOS does if you disable a core in the setup program. In that case, the simplest thing to do is not start it.

After a reset all CPU cores in the system (even across packages) will determine a bootstrap processor (BSP). The protocol is supposed to guarentee exactly one BSP. Which they could do by just always using CPU number 0 as BSP, but I suppose you might want to be able to disable that. The BSP will then start like the 8086 did so long ago, while all the other processors, called Application Processors (APs) will hang themselves into a state where they are only receptive to INIT IPIs (or, in case of at least some systems supported by coreboot, start anyway and get stopped in a CLI-HLT loop). From that point on, only one CPU runs in the system.

The only evidence that a starting OS has of other APs existence is the MADT (or on older systems, the MP table). And the BIOS can just not mention a given CPU.

That is also why you should never send INIT IPIs in delivery mode "to every LAPIC except me", because you might wake up a disabled core that way. And it might have been disabled for a reason.

Ciao,
Markus

_________________
Carpe diem!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 158 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group