Skip to contentSkip to conversation

BIOS regression since v2.3.0 (misaligned longword i/o to address 0xffff)

Qemu-devel Stefan Weil 3 participants 7 messages Jul 26, 2015 – Jul 27, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

since commit 21f5826a04d38e19488f917e1eef22751490c769 "seabios: update to 1.8.0 release" there is a misaligned i/o access caused by the PC BIOS.

QEMU's PC emulation (qemu-system-i386, qemu-system-x86_64) with enabled trace backend reports the misaligned i/o access when running the BIOS code:

Misaligned i/o to address 0x0000ffff with size 4 for memory region io

("to address 0x0000ffff" was added by my debug code)

This issue was reported by users of QEMU for Windows, but it is not Windows specific.

Regards
Stefan

#1 lore raw

Am 26.07.2015 um 21:32 schrieb Stefan Weil:

Quoted 12 lines

Hi,

since commit 21f5826a04d38e19488f917e1eef22751490c769 "seabios: update to 1.8.0 release" there is a misaligned i/o access caused by the PC BIOS.

QEMU's PC emulation (qemu-system-i386, qemu-system-x86_64) with enabled trace backend reports the misaligned i/o access when running the BIOS code:

Misaligned i/o to address 0x0000ffff with size 4 for memory region io

Quoted 7 lines

("to address 0x0000ffff" was added by my debug code)

This issue was reported by users of QEMU for Windows, but it is not Windows specific.

Regards
Stefan

Sorry, I did not notice that the code which reports misaligned access is not part of the official QEMU code.

Here is the patch for memory.c which adds it:

@@ -1073,6 +1119,9 @@ bool memory_region_access_valid(MemoryRegion *mr,

     int access_size, i;

     if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
+        fprintf(stderr, "Misaligned i/o to address %08" HWADDR_PRIx
+                        " with size %u for memory region %s\n",
+                addr, size, mr->name);
         return false;
     }

Is the misaligned i/o access done by the BIOS code a feature or a bug?

Regards
Stefan

#2 lore raw

Am 27.07.2015 um 07:49 schrieb Stefan Weil:

Quoted 39 lines

Am 26.07.2015 um 21:32 schrieb Stefan Weil:

Quoted 12 lines

Hi,

since commit 21f5826a04d38e19488f917e1eef22751490c769 "seabios: update to 1.8.0 release" there is a misaligned i/o access caused by the PC BIOS.

QEMU's PC emulation (qemu-system-i386, qemu-system-x86_64) with enabled trace backend reports the misaligned i/o access when running the BIOS code:

Misaligned i/o to address 0x0000ffff with size 4 for memory region io

Quoted 7 lines

("to address 0x0000ffff" was added by my debug code)

This issue was reported by users of QEMU for Windows, but it is not Windows specific.

Regards
Stefan

Sorry, I did not notice that the code which reports misaligned access is not part of the official QEMU code.

Here is the patch for memory.c which adds it:

(quoted diff) +3 -0
@@ -1073,6 +1119,9 @@ bool memory_region_access_valid(MemoryRegion *mr,
     int access_size, i;
 
     if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
+        fprintf(stderr, "Misaligned i/o to address %08" HWADDR_PRIx
+                        " with size %u for memory region %s\n",
+                addr, size, mr->name);
         return false;
     }
 

Is the misaligned i/o access done by the BIOS code a feature or a bug?

Quoted 3 lines

Regards
Stefan

The change (regression?) was caused by this commit (which obviously did not intend to change generated code):

40d03128531e06b35a3836f9346790003692540e is the first bad commit commit 40d03128531e06b35a3836f9346790003692540e

Author: Paolo Bonzini <[email protected]>
Date:   Thu May 15 13:22:26 2014 +0200

piix: add and use dev-piix.h

Move all definitions for PIIX registers to a single header file, like there is one already for Q35, and make the naming more consistent.

:040000 040000 72d3a611f87106916d58e30fa1d615659fa711f6 5bfd5601430bc5263ac0a6f8a15a131f3bc8678e M src

#3 lore raw

Am 27.07.2015 um 08:24 schrieb Stefan Weil:

Quoted 38 lines

Am 27.07.2015 um 07:49 schrieb Stefan Weil:

Quoted 37 lines

Am 26.07.2015 um 21:32 schrieb Stefan Weil:

Quoted 12 lines

Hi,

since commit 21f5826a04d38e19488f917e1eef22751490c769 "seabios: update to 1.8.0 release" there is a misaligned i/o access caused by the PC BIOS.

QEMU's PC emulation (qemu-system-i386, qemu-system-x86_64) with enabled trace backend reports the misaligned i/o access when running the BIOS code:

Misaligned i/o to address 0x0000ffff with size 4 for memory region io

Quoted 7 lines

("to address 0x0000ffff" was added by my debug code)

This issue was reported by users of QEMU for Windows, but it is not Windows specific.

Regards
Stefan

Sorry, I did not notice that the code which reports misaligned access is not part of the official QEMU code.

Here is the patch for memory.c which adds it:

(quoted diff) +3 -0
@@ -1073,6 +1119,9 @@ bool memory_region_access_valid(MemoryRegion *mr,
     int access_size, i;
 
     if (!mr->ops->valid.unaligned && (addr & (size - 1))) {
+        fprintf(stderr, "Misaligned i/o to address %08" HWADDR_PRIx
+                        " with size %u for memory region %s\n",
+                addr, size, mr->name);
         return false;
     }
 
Quoted 4 lines
Quoted 4 lines

Is the misaligned i/o access done by the BIOS code a feature or a bug?

Regards
Stefan

Please ignore my last e-mail. This one is the commit reported by git bisect for seabios:

457ba42878bd9f704e5a6c1c7bc7fcced686fe4e is the first bad commit commit 457ba42878bd9f704e5a6c1c7bc7fcced686fe4e

Author: Paolo Bonzini <[email protected]>
Date:   Thu May 15 13:22:28 2014 +0200

smm: complete SMM setup

SMI generation requires two bits to be set in PIIX4, one for APMC interrupts specifically and a general one.

For Q35 it is the same, plus it is a good thing to lock SMIs after enabling them.

:040000 040000 5bfd5601430bc5263ac0a6f8a15a131f3bc8678e 5e0901b1c5ae4c79ed4c34c8bd27e7daf9006086 M src

#4 lore raw
Quoted 9 lines · Stefan Weil

commit 457ba42878bd9f704e5a6c1c7bc7fcced686fe4e

Author: Paolo Bonzini <[email protected]>
Date:   Thu May 15 13:22:28 2014 +0200

smm: complete SMM setup

SMI generation requires two bits to be set in PIIX4, one for APMC interrupts specifically and a general one.

Quoted 8 lines

For Q35 it is the same, plus it is a good thing to lock SMIs after enabling them.

:040000 040000 5bfd5601430bc5263ac0a6f8a15a131f3bc8678e
5e0901b1c5ae4c79ed4c34c8bd27e7daf9006086 M src

Is this enough to fix it?

src/fw/smm.c +1 -1
@@ -184,7 +184,7 @@ static void piix4_apmc_smm_setup(int isabdf, int i440_bdf)
 
     /* enable SMI generation */
     value = inl(acpi_pm_base + PIIX_PMIO_GLBCTL);
-    outl(acpi_pm_base + PIIX_PMIO_GLBCTL, value | PIIX_PMIO_GLBCTL_SMI_EN);
+    outl(value | PIIX_PMIO_GLBCTL_SMI_EN, acpi_pm_base + PIIX_PMIO_GLBCTL);
 
     smm_relocate_and_restore();
 

Paolo

author Reviewed-by
#5 lore raw

Am 27.07.2015 um 10:46 schrieb Paolo Bonzini:

Quoted 31 lines · Stefan Weil
Quoted 9 lines

commit 457ba42878bd9f704e5a6c1c7bc7fcced686fe4e

Author: Paolo Bonzini <[email protected]>
Date:   Thu May 15 13:22:28 2014 +0200

smm: complete SMM setup

SMI generation requires two bits to be set in PIIX4, one for APMC interrupts specifically and a general one.

Quoted 7 lines

For Q35 it is the same, plus it is a good thing to lock SMIs after enabling them.

:040000 040000 5bfd5601430bc5263ac0a6f8a15a131f3bc8678e
5e0901b1c5ae4c79ed4c34c8bd27e7daf9006086 M src

Is this enough to fix it?

src/fw/smm.c +1 -1
@@ -184,7 +184,7 @@ static void piix4_apmc_smm_setup(int isabdf, int i440_bdf)
 
     /* enable SMI generation */
     value = inl(acpi_pm_base + PIIX_PMIO_GLBCTL);
-    outl(acpi_pm_base + PIIX_PMIO_GLBCTL, value | PIIX_PMIO_GLBCTL_SMI_EN);
+    outl(value | PIIX_PMIO_GLBCTL_SMI_EN, acpi_pm_base + PIIX_PMIO_GLBCTL);
 
     smm_relocate_and_restore();
 
Quoted 1 line

Paolo

Yes, and the new code also looks much better for an outl function call. :-) You may add

Stefan

#6 lore raw

Am 27.07.2015 um 11:32 schrieb Stefan Weil:

Quoted 38 lines

Am 27.07.2015 um 10:46 schrieb Paolo Bonzini:

Quoted 31 lines · Stefan Weil
Quoted 9 lines

commit 457ba42878bd9f704e5a6c1c7bc7fcced686fe4e

Author: Paolo Bonzini <[email protected]>
Date:   Thu May 15 13:22:28 2014 +0200

smm: complete SMM setup

SMI generation requires two bits to be set in PIIX4, one for APMC interrupts specifically and a general one.

Quoted 7 lines

For Q35 it is the same, plus it is a good thing to lock SMIs after enabling them.

:040000 040000 5bfd5601430bc5263ac0a6f8a15a131f3bc8678e
5e0901b1c5ae4c79ed4c34c8bd27e7daf9006086 M src

Is this enough to fix it?

src/fw/smm.c +1 -1
@@ -184,7 +184,7 @@ static void piix4_apmc_smm_setup(int isabdf, int i440_bdf)
 
     /* enable SMI generation */
     value = inl(acpi_pm_base + PIIX_PMIO_GLBCTL);
-    outl(acpi_pm_base + PIIX_PMIO_GLBCTL, value | PIIX_PMIO_GLBCTL_SMI_EN);
+    outl(value | PIIX_PMIO_GLBCTL_SMI_EN, acpi_pm_base + PIIX_PMIO_GLBCTL);
 
     smm_relocate_and_restore();
 
Quoted 1 line

Paolo

Yes, and the new code also looks much better for an outl function call. :-) You may add

Quoted 3 lines

Stefan

When I look at src/hw/megasas.c, I see three more outl function calls with wrong argument order. CC'ing Hannes therefore.

Stefan