Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Igor Mammedov

On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
---
  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));

Shouldn't we print it to the console too?

I'm not sure if it's possible to print at this stage, but I'll try and
re-post if it works.




+hlt();
+}
  yield();
+}
  }

  // Restore memory.
--
1.7.7.6


--
Gleb.


--
-
 Igor

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Gleb Natapov
On Mon, Mar 12, 2012 at 10:52:18AM +0100, Igor Mammedov wrote:
 On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
 ---
   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));
 Shouldn't we print it to the console too?
 I'm not sure if it's possible to print at this stage, but I'll try and
 re-post if it works.
 
If it is not possible currently may be we should move smp detection to
later stage. Or do not hlt here and report error later. The easier for a
user to see this error the easier it is for us to debug user's problems.

 
 +hlt();
 +}
   yield();
 +}
   }
 
   // Restore memory.
 --
 1.7.7.6
 
 --
  Gleb.
 
 -- 
 -
  Igor

--
Gleb.

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


[SeaBIOS] Re : Re : [Qemu-devel] Regression: more 0.12 regression (SeaBIOS related?)

2012-03-12 Thread Alain Ribière
On Wed, Mar 07, 2012 at 06:31:31AM -0800, Alain Ribière wrote:

  I ran qemu 1.0.1 and the latest SeaBIOS (from the git) with the following 
  options :
  qemu-system-i386 -L git/bios -fda disk.img -no-fd-bootchk -boot a -m 16
  
  Here is the log :
  https://docs.google.com/open?id=0B7mz0vq6Rpb7UE1ibjJDcEhTRWlNV050QnMyMWwtZw
  
  Here is the floppy disk image I used :
  
  https://docs.google.com/open?id=0B7mz0vq6Rpb7bHpYaEt2SnVUUi1KaWE3a3lBQUJpQQ
  
  
  The floppy disk is simply a C-DOS 720 Ko floppy created by format
  a: /s. So it's quite empty.
  
  Qemu doesn't crash or freeze. But I can just type a single character
  and the nothing else. But the system is still running (there is a
  clock at the bottom right of the screen).
 
 I tracked this down.  Looks like the image takes over the PS2 irq and
 keyboard handling, but then occasionally calls into the BIOS.  When it
 does call the BIOS irq handler (manually), it expects the irq handler
 to enable the keyboard.  Weird.
 
 Anyway, the patch below fixes it for me.
 
 -Kevin

Great ! It works for me too.

Thanks a lot,

Alain
___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Igor Mammedov

On 03/12/2012 11:14 AM, Gleb Natapov wrote:

On Mon, Mar 12, 2012 at 10:52:18AM +0100, Igor Mammedov wrote:

On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
---
  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));

Shouldn't we print it to the console too?

I'm not sure if it's possible to print at this stage, but I'll try and
re-post if it works.


If it is not possible currently may be we should move smp detection to
later stage. Or do not hlt here and report error later. The easier for a
user to see this error the easier it is for us to debug user's problems.


It looks safe to move vga_setup() right after pci_setup() in post().
However I can't tell what structures various option roms might access so
I'm not completely sure if it right thing to do.

Does something like this look good to you?
(kvm guest boots without any issue and error prints as well if condition is met)

diff --git a/src/post.c b/src/post.c
index 43523dd..9358b49 100644
--- a/src/post.c
+++ b/src/post.c
@@ -208,6 +208,9 @@ post(void)
 pci_setup();
 smm_init();

+// Run vga option rom
+vga_setup();
+
 // Initialize internal tables
 boot_setup();
 drive_setup();
@@ -227,9 +230,6 @@ post(void)
 mouse_setup();
 init_bios_tables();

-// Run vga option rom
-vga_setup();
-
 // Do hardware initialization (if running synchronously)
 if (!CONFIG_THREADS || !CONFIG_THREAD_OPTIONROMS) {
 init_hw();
diff --git a/src/smp.c b/src/smp.c
index 42184a4..b11cb95 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -138,8 +138,9 @@ smp_probe(void)

 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,
+printf(ERROR: Expected %d cpu(s) but %d cpus started.\n,
 cmos_smp_count + 1, readl(CountCPUs));
+printf(Machine halted.\n);
 hlt();
 }
 yield();



--
-
 Igor

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Gleb Natapov
On Mon, Mar 12, 2012 at 02:09:02PM +0100, Igor Mammedov wrote:
 On 03/12/2012 11:14 AM, Gleb Natapov wrote:
 On Mon, Mar 12, 2012 at 10:52:18AM +0100, Igor Mammedov wrote:
 On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
 ---
   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));
 Shouldn't we print it to the console too?
 I'm not sure if it's possible to print at this stage, but I'll try and
 re-post if it works.
 
 If it is not possible currently may be we should move smp detection to
 later stage. Or do not hlt here and report error later. The easier for a
 user to see this error the easier it is for us to debug user's problems.
 
 It looks safe to move vga_setup() right after pci_setup() in post().
 However I can't tell what structures various option roms might access so
 I'm not completely sure if it right thing to do.
 
Well you move it above Setup interfaces that option roms may need
comment, so we can be sure it is not safe :)

I think moving smp detection to later stage should be safer. But now I am
not even sure we should halt at all. May be warn the user and continue
booting with cmos_smp_count = CountCPUs?

 Does something like this look good to you?
 (kvm guest boots without any issue and error prints as well if condition is 
 met)
 
 diff --git a/src/post.c b/src/post.c
 index 43523dd..9358b49 100644
 --- a/src/post.c
 +++ b/src/post.c
 @@ -208,6 +208,9 @@ post(void)
  pci_setup();
  smm_init();
 
 +// Run vga option rom
 +vga_setup();
 +
  // Initialize internal tables
  boot_setup();
  drive_setup();
 @@ -227,9 +230,6 @@ post(void)
  mouse_setup();
  init_bios_tables();
 
 -// Run vga option rom
 -vga_setup();
 -
  // Do hardware initialization (if running synchronously)
  if (!CONFIG_THREADS || !CONFIG_THREAD_OPTIONROMS) {
  init_hw();
 diff --git a/src/smp.c b/src/smp.c
 index 42184a4..b11cb95 100644
 --- a/src/smp.c
 +++ b/src/smp.c
 @@ -138,8 +138,9 @@ smp_probe(void)
 
  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,
 +printf(ERROR: Expected %d cpu(s) but %d cpus started.\n,
  cmos_smp_count + 1, readl(CountCPUs));
 +printf(Machine halted.\n);
  hlt();
  }
  yield();
 
 
 
 -- 
 -
  Igor

--
Gleb.

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Igor Mammedov

On 03/12/2012 02:27 PM, Gleb Natapov wrote:

On Mon, Mar 12, 2012 at 02:09:02PM +0100, Igor Mammedov wrote:

On 03/12/2012 11:14 AM, Gleb Natapov wrote:

On Mon, Mar 12, 2012 at 10:52:18AM +0100, Igor Mammedov wrote:

On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
---
  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 + 1readl(CountCPUs)) {
+dprintf(1, BUG: Expected %d cpu(s) but %d cpus started\n,
+cmos_smp_count + 1, readl(CountCPUs));

Shouldn't we print it to the console too?

I'm not sure if it's possible to print at this stage, but I'll try and
re-post if it works.


If it is not possible currently may be we should move smp detection to
later stage. Or do not hlt here and report error later. The easier for a
user to see this error the easier it is for us to debug user's problems.


It looks safe to move vga_setup() right after pci_setup() in post().
However I can't tell what structures various option roms might access so
I'm not completely sure if it right thing to do.


Well you move it above Setup interfaces that option roms may need
comment, so we can be sure it is not safe :)

Yep, sorry my bad.



I think moving smp detection to later stage should be safer. But now I am

we can't move it past init_bios_tables() and this function is is under comment
// Setup interfaces that option roms may need so I'm not sure we can move
vga_setup before it.


not even sure we should halt at all. May be warn the user and continue


We need to stop because otherwise user won't event notice that there was
an error and only later may notice not expected cpus count in OS. BIOSes
usually stop in case of error and you have to override this behavior in
settings (something like this: boot if keyboard is not present).

Perhaps we could safely clamp CountCPUs to 1 + alter smp_ap_boot_code()
to stop counting in case of error and continue to boot till we will be able
to print error message and stop after that.
Yep, error message is nice to have but I'm not sure if this one case is
worth of inventing deferred print infrastructure. Support personnel might
just enable logging from debug port if BIOS is suspected (it is easy to
spot, we hang right on boot). That's what they have to do now in case of
any BIOS related problems.


booting with cmos_smp_count = CountCPUs?


I guess is was this way some time ago 31bfad632b0ca and with large cpu counts
it wasn't reliable to wait XX ms while all cpus initialize, that why 
cmos_smp_count
was introduced and bios waits on exact count.

The halt condition is meant for buggy emulators so if we get more cpus then
expected it is safer to just stop then experience inexplicable bugs later
(I can imagine having mp, smbios and acpi tables built with different CountCPUs,
and maybe there is other dependencies).



--
Gleb.


--
-
 Igor

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Gleb Natapov
On Mon, Mar 12, 2012 at 05:04:48PM +0100, Igor Mammedov wrote:
 On 03/12/2012 02:27 PM, Gleb Natapov wrote:
 On Mon, Mar 12, 2012 at 02:09:02PM +0100, Igor Mammedov wrote:
 On 03/12/2012 11:14 AM, Gleb Natapov wrote:
 On Mon, Mar 12, 2012 at 10:52:18AM +0100, Igor Mammedov wrote:
 On 03/11/2012 11:36 AM, Gleb Natapov 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 Mammedovimamm...@redhat.com
 ---
   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 + 1readl(CountCPUs)) {
 +dprintf(1, BUG: Expected %d cpu(s) but %d cpus 
 started\n,
 +cmos_smp_count + 1, readl(CountCPUs));
 Shouldn't we print it to the console too?
 I'm not sure if it's possible to print at this stage, but I'll try and
 re-post if it works.
 
 If it is not possible currently may be we should move smp detection to
 later stage. Or do not hlt here and report error later. The easier for a
 user to see this error the easier it is for us to debug user's problems.
 
 It looks safe to move vga_setup() right after pci_setup() in post().
 However I can't tell what structures various option roms might access so
 I'm not completely sure if it right thing to do.
 
 Well you move it above Setup interfaces that option roms may need
 comment, so we can be sure it is not safe :)
 Yep, sorry my bad.
 
 
 I think moving smp detection to later stage should be safer. But now I am
 we can't move it past init_bios_tables() and this function is is under comment
 // Setup interfaces that option roms may need so I'm not sure we can move
 vga_setup before it.
 
I think init_bios_tables() is not required for option rom to work. Not
sure though. Kevin?

 not even sure we should halt at all. May be warn the user and continue
 
 We need to stop because otherwise user won't event notice that there was
 an error and only later may notice not expected cpus count in OS. BIOSes
 usually stop in case of error and you have to override this behavior in
 settings (something like this: boot if keyboard is not present).
 
 Perhaps we could safely clamp CountCPUs to 1 + alter smp_ap_boot_code()
 to stop counting in case of error and continue to boot till we will be able
 to print error message and stop after that.
 Yep, error message is nice to have but I'm not sure if this one case is
 worth of inventing deferred print infrastructure. Support personnel might
 just enable logging from debug port if BIOS is suspected (it is easy to
 spot, we hang right on boot). That's what they have to do now in case of
 any BIOS related problems.
 
Since this error should not really happen IRL I agree we should not spend to
much time on new infrastructure.

 booting with cmos_smp_count = CountCPUs?
 
 I guess is was this way some time ago 31bfad632b0ca and with large cpu counts
 it wasn't reliable to wait XX ms while all cpus initialize, that why 
 cmos_smp_count
 was introduced and bios waits on exact count.
 
 The halt condition is meant for buggy emulators so if we get more cpus then
 expected it is safer to just stop then experience inexplicable bugs later
 (I can imagine having mp, smbios and acpi tables built with different 
 CountCPUs,
 and maybe there is other dependencies).
 
 
 --
  Gleb.
 
 -- 
 -
  Igor

--
Gleb.

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [Qemu-devel] [PULL] Update seabios to 1.6.3.2

2012-03-12 Thread Anthony Liguori

On 03/12/2012 09:48 AM, Andreas Färber wrote:

Hi Gerd,

Am 12.03.2012 14:08, schrieb Gerd Hoffmann:

New seabios release on the 1.6.3 stable branch -- lets update.
Also add a Makefile + script to simplify seabios updating.


That version was released yesterday and I don't see any PATCHes yet...
Care to share your build script first before you send a PULL?
You also forgot to mention where to pull from. ;)

No objection to updating though.


I happen to be looking to do this myself, but upon running SeaBIOS through some 
testing, I ran into:


/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel 
bin/vmlinuz-3.0 -initrd .tmp-3349/initramfs-3349.img.gz -append console=ttyS0 
seed=38721 -drive file=.tmp-3349/disk-3349.img,if=none,snapshot=on,id=hd0 
-device virtio-balloon-pci,addr=03.0 -device virtio-blk-pci,addr=04.0,drive=hd0 
-nographic -nodefconfig -m 1G -no-reboot -no-hpet -device virtio-serial -chardev 
socket,path=.tmp-3349/channel-3349.sock,id=channel0,server,nowait -device 
virtserialport,chardev=channel0,name=org.libguestfs.channel.0 -nodefaults 
-serial stdio -enable-kvm -pidfile .tmp-3349/pidfile-3349.pid -qmp 
unix:.tmp-3349/qmpsock-3349.sock,server,nowait

KVM internal error. Suberror: 1
emulation failure
EAX=aa55 EBX= ECX= EDX=
ESI= EDI= EBP= ESP=6f50
EIP=003c EFL=00010202 [---] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =   9300
CS =c300 000c3000  9b00
SS =   9300
DS =   9300
FS =   9300
GS =   9300
LDT=   8200
TR =   8b00
GDT= 000fd3a8 0037
IDT=  03ff
CR0=0010 CR2= CR3= CR4=
DR0= DR1= DR2= 
DR3=
DR6=0ff0 DR7=0400
EFER=
Code=00 00 7c 02 81 02 00 00 00 00 00 00 00 00 3c 00 00 00 00 00 8c c8 8e d8 
fa fc e9 91 00 b8 16 00 ba 10 05 ef ba 11 05 ec 66 c1 e0 08 ec 66 c1 e0 08 ec

^Cqemu: terminating on signal 2

How extensively did you test the new seabios changes and are you able to 
recreate?

My GCC is:

gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

Regards,

Anthony Liguori



Andreas


Gerd Hoffmann (2):
   Add seabios build scripts to roms/
   Update seabios to 1.6.3.2

  pc-bios/bios.bin  |  Bin 131072 -  131072 bytes
  roms/Makefile |   10 ++
  roms/config.seabios   |1 +
  roms/configure-seabios.sh |5 +
  roms/seabios  |2 +-
  5 files changed, 17 insertions(+), 1 deletions(-)
  create mode 100644 roms/Makefile
  create mode 100644 roms/config.seabios
  create mode 100755 roms/configure-seabios.sh





___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 3/3] Take in account hot(un)plugged cpus on reboot

2012-03-12 Thread Igor Mammedov

On 03/11/2012 11:58 AM, Gleb Natapov wrote:

On Sat, Mar 10, 2012 at 12:47:28PM +0100, Igor Mammedov wrote:

Initial count of active cpus is communicated to bios from qemu via
CMOS_BIOS_SMP_COUNT io port. However if cpus are hotplugged after
boot and then guest is rebooted without taking down qemu then
bios might be stuck at smp_probe
while (cmos_smp_count + 1 != readl(CountCPUs))
   yield();
where cmos_smp_count + 1 will be less that CountCPUs due to
additional hotplugged cpus.

One way to fix bug is to take in account hotplugged cpus and count
online cpus in cpu status bitmap that qemu provides at 0xaf00 and
bios uses for ACPI cpu hotplug in acpi-dsdt.dsl.

Alternative ways to fix issue was disscussed on following thread:
   http://www.seabios.org/pipermail/seabios/2011-August/002147.html
without any conclusion

Rationale why counting cpus in cpu_sts bitmap at 0xaf00 might be
better that updating CMOS_BIOS_SMP_COUNT in qemu.
   feeble one: we are already relying on cpu_sts at 0xaf00 for ACPI
cpu hotplug machinery and it seems that there is no standard
way to pass this info (so we are now using board extension).
   2nd: another possible use for cpu_sts bitmap is when cpus are able
to be (hot)plugged in nonconsecutive order, MADT + CPON
package should be build taking in account info about which
cpus are (un)plugged.

v2 changes:
   - access cpu_sts only if qemu advertise its support
   - unconditionally use acpi_cpu_online_count if available to cover
 unplug case as well


Why not update cmos in qemu during cpu hot plug instead?

In mail thread mentioned above it was proposed to do so but it didn't
get any response:


On 2011-08-03 12:07, Vasilis Liaskovitis wrote:
An alternative to this patch would be to update the smp_cpus variable in 
qemu-kvm and
do a cmos update to 0x5f from the cpu-hotplug code. Access to the rtc_state 
(cmos device)
would be required in hw/acpi_piix4.c.  This way no change to Seabios would be 
required.



Sure it' possible to do this in qemu but essentially it will duplicate
count of cpus in cpu_sts. And if we are going to have some day ability
to plug/unplug individual cpus then we need to have access to cpu_sts
map to build correct mp/smbios/acpi tables. So why not to use
cpu_sts for counting cpus if available and leave CMOS_BIOS_SMP_COUNT
for compatibility reason. And later when (un)plugging specific cpus
will be ready we could use the same map for correct initialization of
various BIOS tables.

I've wrote this patch because of in perspective cpu_sts map can be used
not only for counting cpus, otherwise I'd just try the way of 'cmos
update to 0x5f from the cpu-hotplug code' as the simplest way.




Signed-off-by: Igor Mammedovimamm...@redhat.com
---
  src/smp.c |   23 +++
  1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/smp.c b/src/smp.c
index 9933ac6..835b766 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -17,6 +17,9 @@

  #define APIC_ENABLED 0x0100

+#define ACPI_CPU_STATUS_MAP 0xaf00
+#define ACPI_CPU_STATUS_MAP_SZ 32
+
  struct { u32 ecx, eax, edx; } smp_mtrr[32] VAR16VISIBLE;
  u32 smp_mtrr_count VAR16VISIBLE;

@@ -115,6 +118,26 @@ smp_probe(void)
  msleep(10);
  } else {
  u8 cmos_smp_count = inb_cmos(CMOS_BIOS_SMP_COUNT);
+dprintf(1, Powered-on with %d cpu(s)\n, cmos_smp_count + 1);
+
+if (qemu_cfg_have_acpi_cpus_map()) {

It's possible to encode version of map format, in fw_cfg value returned
from qemu. So that in future if map format is changed then we'll be able
to fallback to cmos_smp_count and use newer version when supported by BIOS.


+u8 i = 0, acpi_cpu_online_count = 0;
+/* count plugged in cpus in acpi PRST bitmap */
+while (i  ACPI_CPU_STATUS_MAP_SZ) {
+u8 j = 0, status = inb(ACPI_CPU_STATUS_MAP + (i++));
+while (j  8)
+if ((status  j++)  1)
+++acpi_cpu_online_count;
+}
+
+dprintf(1, Counted %d present cpu(s) in ACPI cpus status map\n,
+acpi_cpu_online_count);
+/* if cpu(s) were hot(un)plugged then on reboot
+ * we should wait for an actual cpus number, so use
+ * acpi_cpu_online_count instead of cmos_smp_count */
+cmos_smp_count = acpi_cpu_online_count - 1;
+}
+
  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,
--
1.7.7.6


--
Gleb.


--
-
 Igor

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 08/19] usb: Push 'struct usbdevice_s' usage through to pipe allocation.

2012-03-12 Thread Dave Frodin
I had to do some whitespace cleanup in order for patch 08/19 to apply cleanly. 
I don't have
much experience in applying patches so there might be something I'm missing.

Here are the changes I had to do...

Subject: [PATCH] Whitespace cleanup, replace two tabs with spaces

---
 src/usb-msc.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/usb-msc.c b/src/usb-msc.c
index e143401..62152d8 100644
--- a/src/usb-msc.c
+++ b/src/usb-msc.c
@@ -132,8 +132,8 @@ usb_msc_init(struct usb_pipe *pipe
 
 // Verify right kind of device
 if ((iface-bInterfaceSubClass != US_SC_SCSI 
-iface-bInterfaceSubClass != US_SC_ATAPI_8070 
-iface-bInterfaceSubClass != US_SC_ATAPI_8020)
+iface-bInterfaceSubClass != US_SC_ATAPI_8070 
+iface-bInterfaceSubClass != US_SC_ATAPI_8020)
 || iface-bInterfaceProtocol != US_PR_BULK) {
 dprintf(1, Unsupported MSC USB device (subclass=%02x proto=%02x)\n
 , iface-bInterfaceSubClass, iface-bInterfaceProtocol);
-- 
1.7.9

dave

- Original Message -
 From: Kevin O'Connor ke...@koconnor.net
 To: seabios@seabios.org
 Sent: Saturday, March 10, 2012 7:44:46 PM
 Subject: [SeaBIOS] [PATCH 08/19] usb: Push 'struct usbdevice_s' usage through 
 to pipe allocation.
 
 Pass the usbdevice_s info to device configuration and allocation
 code.
 
 Signed-off-by: Kevin O'Connor ke...@koconnor.net
 ---
  src/usb-hid.c |   28 +++-
  src/usb-hid.h |6 ++
  src/usb-hub.c |8 
  src/usb-hub.h |4 ++--
  src/usb-msc.c |   15 ---
  src/usb-msc.h |6 ++
  src/usb.c |   35 +++
  src/usb.h |   13 +++--
  8 files changed, 59 insertions(+), 56 deletions(-)
 
 diff --git a/src/usb-hid.c b/src/usb-hid.c
 index 168b7fa..21363c3 100644
 --- a/src/usb-hid.c
 +++ b/src/usb-hid.c
 @@ -49,7 +49,8 @@ set_idle(struct usb_pipe *pipe, int ms)
  #define KEYREPEATMS 33
  
  static int
 -usb_kbd_init(struct usb_pipe *pipe, struct usb_endpoint_descriptor
 *epdesc)
 +usb_kbd_init(struct usbdevice_s *usbdev
 + , struct usb_endpoint_descriptor *epdesc)
  {
  if (! CONFIG_USB_KEYBOARD)
  return -1;
 @@ -61,15 +62,15 @@ usb_kbd_init(struct usb_pipe *pipe, struct
 usb_endpoint_descriptor *epdesc)
  return -1;
  
  // Enable boot protocol.
 -int ret = set_protocol(pipe, 0);
 +int ret = set_protocol(usbdev-defpipe, 0);
  if (ret)
  return -1;
  // Periodically send reports to enable key repeat.
 -ret = set_idle(pipe, KEYREPEATMS);
 +ret = set_idle(usbdev-defpipe, KEYREPEATMS);
  if (ret)
  return -1;
  
 -keyboard_pipe = alloc_intr_pipe(pipe, epdesc);
 +keyboard_pipe = alloc_intr_pipe(usbdev, epdesc);
  if (!keyboard_pipe)
  return -1;
  
 @@ -78,7 +79,8 @@ usb_kbd_init(struct usb_pipe *pipe, struct
 usb_endpoint_descriptor *epdesc)
  }
  
  static int
 -usb_mouse_init(struct usb_pipe *pipe, struct usb_endpoint_descriptor
 *epdesc)
 +usb_mouse_init(struct usbdevice_s *usbdev
 +   , struct usb_endpoint_descriptor *epdesc)
  {
  if (! CONFIG_USB_MOUSE)
  return -1;
 @@ -90,11 +92,11 @@ usb_mouse_init(struct usb_pipe *pipe, struct
 usb_endpoint_descriptor *epdesc)
  return -1;
  
  // Enable boot protocol.
 -int ret = set_protocol(pipe, 0);
 +int ret = set_protocol(usbdev-defpipe, 0);
  if (ret)
  return -1;
  
 -mouse_pipe = alloc_intr_pipe(pipe, epdesc);
 +mouse_pipe = alloc_intr_pipe(usbdev, epdesc);
  if (!mouse_pipe)
  return -1;
  
 @@ -104,29 +106,29 @@ usb_mouse_init(struct usb_pipe *pipe, struct
 usb_endpoint_descriptor *epdesc)
  
  // Initialize a found USB HID device (if applicable).
  int
 -usb_hid_init(struct usb_pipe *pipe
 - , struct usb_interface_descriptor *iface, int imax)
 +usb_hid_init(struct usbdevice_s *usbdev)
  {
  if (! CONFIG_USB_KEYBOARD || ! CONFIG_USB_MOUSE)
  return -1;
 -dprintf(2, usb_hid_init %p\n, pipe);
 +dprintf(2, usb_hid_init %p\n, usbdev-defpipe);
  
 +struct usb_interface_descriptor *iface = usbdev-iface;
  if (iface-bInterfaceSubClass != USB_INTERFACE_SUBCLASS_BOOT)
  // Doesn't support boot protocol.
  return -1;
  
  // Find intr in endpoint.
  struct usb_endpoint_descriptor *epdesc = findEndPointDesc(
 -iface, imax, USB_ENDPOINT_XFER_INT, USB_DIR_IN);
 +usbdev, USB_ENDPOINT_XFER_INT, USB_DIR_IN);
  if (!epdesc) {
  dprintf(1, No usb hid intr in?\n);
  return -1;
  }
  
  if (iface-bInterfaceProtocol ==
  USB_INTERFACE_PROTOCOL_KEYBOARD)
 -return usb_kbd_init(pipe, epdesc);
 +return usb_kbd_init(usbdev, epdesc);
  if (iface-bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE)
 -return usb_mouse_init(pipe, epdesc);
 +return usb_mouse_init(usbdev, epdesc);
  return -1;
  }
 

Re: [SeaBIOS] [PATCH 08/19] usb: Push 'struct usbdevice_s' usage through to pipe allocation.

2012-03-12 Thread Kevin O'Connor
On Mon, Mar 12, 2012 at 11:30:36AM -0600, Dave Frodin wrote:
 I had to do some whitespace cleanup in order for patch 08/19 to apply 
 cleanly. I don't have
 much experience in applying patches so there might be something I'm missing.
 
 Here are the changes I had to do...
 
 Subject: [PATCH] Whitespace cleanup, replace two tabs with spaces

I guess a mailer somewhere converted the tabs to spaces.  I'll remove
the tabs from the code though (seabios uses spaces only).

-Kevin

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [Qemu-devel] [PULL] Update seabios to 1.6.3.2

2012-03-12 Thread Kevin O'Connor
On Mon, Mar 12, 2012 at 11:25:07AM -0500, Anthony Liguori wrote:
 On 03/12/2012 09:48 AM, Andreas Färber wrote:
 Hi Gerd,
 
 Am 12.03.2012 14:08, schrieb Gerd Hoffmann:
 New seabios release on the 1.6.3 stable branch -- lets update.
 Also add a Makefile + script to simplify seabios updating.
 
 That version was released yesterday and I don't see any PATCHes yet...
 Care to share your build script first before you send a PULL?
 You also forgot to mention where to pull from. ;)
 
 No objection to updating though.
 
 I happen to be looking to do this myself, but upon running SeaBIOS
 through some testing, I ran into:
 
 /home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel
[...]
 How extensively did you test the new seabios changes and are you able to 
 recreate?

There's only two lines of code changes in this release (beyond build
related changes (8 lines)).  I don't think it's seabios.

-Kevin


--- a/src/boot.c
+++ b/src/boot.c
@@ -326,7 +326,7 @@ boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
 void
 boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
 {
-bootentry_add(IPL_TYPE_BCV, defPrio(prio, DEFAULT_PRIO)
+bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
   , SEGOFF(seg, ip).segoff
   , desc ? MAKE_FLATPTR(seg, desc) : Legacy option rom);
 }
diff --git a/src/pmm.c b/src/pmm.c
index 82a0b1d..c649fd8 100644
--- a/src/pmm.c
+++ b/src/pmm.c
@@ -214,7 +214,8 @@ malloc_fixupreloc(void)
 int i;
 for (i=0; iARRAY_SIZE(Zones); i++) {
 struct zone_s *zone = Zones[i];
-zone-info-pprev = zone-info;
+if (zone-info)
+zone-info-pprev = zone-info;
 }
 
 // Add space free'd during relocation in f-segment to ZoneFSeg

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Kevin O'Connor
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 imamm...@redhat.com
 ---
  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.)

-Kevin

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 2/3] Allow bios to detect if qemu has cpus status map for acpi hotplug.

2012-03-12 Thread Kevin O'Connor
On Sat, Mar 10, 2012 at 12:47:27PM +0100, Igor Mammedov wrote:
 
 Signed-off-by: Igor Mammedov imamm...@redhat.com
 ---
  src/paravirt.c |   12 
  src/paravirt.h |2 ++
  2 files changed, 14 insertions(+), 0 deletions(-)
 
 diff --git a/src/paravirt.c b/src/paravirt.c
 index 9cf77de..c2bd0a8 100644
 --- a/src/paravirt.c
 +++ b/src/paravirt.c
 @@ -305,6 +305,18 @@ u16 qemu_cfg_get_max_cpus(void)
  return cnt;
  }
  
 +u16 qemu_cfg_have_acpi_cpus_map(void)
 +{
 +u16 cnt;
 +
 +if (!qemu_cfg_present)
 +return 0;
 +
 +qemu_cfg_read_entry(cnt, QEMU_CFG_HAVE_ACPI_CPUS_MAP, sizeof(cnt));
 +
 +return cnt;
 +}

Please use the file interface for passing new variables into
seabios.  This enables the seabios code to look something like:

romfile_loadint(etc/have_acpi_map, 0);

with no need to write per-file handlers.

-Kevin

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 1/3] Halt if number of started cpus are more then expected

2012-03-12 Thread Peter Stuge
Igor Mammedov wrote:
 not even sure we should halt at all. May be warn the user and continue

 BIOSes usually stop in case of error

That doesn't mean that it's a good idea.


//Peter

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios


Re: [SeaBIOS] [PATCH 3/3] Take in account hot(un)plugged cpus on reboot

2012-03-12 Thread Kevin O'Connor
On Sat, Mar 10, 2012 at 12:47:28PM +0100, Igor Mammedov wrote:
 Initial count of active cpus is communicated to bios from qemu via
 CMOS_BIOS_SMP_COUNT io port. However if cpus are hotplugged after
 boot and then guest is rebooted without taking down qemu then
 bios might be stuck at smp_probe
[...]
 --- a/src/smp.c
 +++ b/src/smp.c
 @@ -17,6 +17,9 @@
  
  #define APIC_ENABLED 0x0100
  
 +#define ACPI_CPU_STATUS_MAP 0xaf00
 +#define ACPI_CPU_STATUS_MAP_SZ 32
 +
  struct { u32 ecx, eax, edx; } smp_mtrr[32] VAR16VISIBLE;
  u32 smp_mtrr_count VAR16VISIBLE;
  
 @@ -115,6 +118,26 @@ smp_probe(void)
  msleep(10);
  } else {
  u8 cmos_smp_count = inb_cmos(CMOS_BIOS_SMP_COUNT);
 +dprintf(1, Powered-on with %d cpu(s)\n, cmos_smp_count + 1);
 +
 +if (qemu_cfg_have_acpi_cpus_map()) {
[...]

Please don't clutter up smp.c with this.  The code should look
something like:

  int total_cpus = getCPUcount();
  while (readl(CountCPUs)  total_cpus)
  yield();

The getCPUcount() can be buried in paravirt.c, acpi.c, or where ever
it makes sense.

BTW, why do we have to call qemu_cfg_have_acpi_cpus_map?  Can't this
just be inferred if the data at inb(0xaf00) is all zeros?

-Kevin

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios