On 03/13/2012 12:51 AM, Kevin O'Connor wrote:
On Sat, Mar 10, 2012 at 12:47:26PM +0100, Igor Mammedov wrote:
Reduce amount of consumed cpu time (i.e. don't spin forever) if
number of started cpus are more then expected. And print a bug
message into debug port.

Signed-off-by: Igor Mammedov<[email protected]>
---
  src/smp.c |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/smp.c b/src/smp.c
index 8c077a1..9933ac6 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -115,8 +115,14 @@ smp_probe(void)
          msleep(10);
      } else {
          u8 cmos_smp_count = inb_cmos(CMOS_BIOS_SMP_COUNT);
-        while (cmos_smp_count + 1 != readl(&CountCPUs))
+        while (cmos_smp_count + 1 != readl(&CountCPUs)) {
+            if (cmos_smp_count + 1<  readl(&CountCPUs)) {
+                dprintf(1, "BUG: Expected %d cpu(s) but %d cpus started\n",
+                        cmos_smp_count + 1, readl(&CountCPUs));
+                hlt();
+            }
              yield();
+        }

I suggest just changing the "while !=" to a "while<".  The chance of
detecting the error is pretty slim anyway.  (Under normal
circumstances, the processor is spinning on the count - the chance of
two other processors getting in to increment before the first
processor sees a change is pretty small.)

Then with buggy emulators (i.e. actual started number of cpus > cmos_smp_count 
+ 1),
it is possible that we could continue to boot while CountCPUs is still 
increasing.
And as result we could build mp/acpi/smbios tables with different count.
It's safer to stop then deal with consequences later.

This patch is only for purpose of increasing stability of host, i.e. do not
consume needlessly cpu and affect other VMs if bug creeps in used emulator.


-Kevin

--
-----
 Igor

_______________________________________________
SeaBIOS mailing list
[email protected]
http://www.seabios.org/mailman/listinfo/seabios

Reply via email to