hw/acpi: add an assertion check for non-null return from acpi_get_i386_pci_host
PATCH v3 1/1 hw/acpi: add an assertion check for non-null return from acpi_get_i386_pci_host
All existing code using acpi_get_i386_pci_host() checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.
--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)
changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.
hw/acpi/pcihp.c +8 -0
@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }
@@ -136,6 +142,8 @@ static void acpi_pcihp_disable_root_bus(void)return ; } +assert (host); + bus =PCI_HOST_BRIDGE (host)->bus;if (bus) {/* setting the hotplug handler to NULL makes the bus non-hotpluggable */
hw/i386/acpi-build.c +6 -9
@@ -321,9 +321,7 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64) pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return ; - } +assert (pci_host); range_set_bounds1(hole, object_property_get_uint(pci_host,
@@ -1769,9 +1767,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, pci_host =acpi_get_i386_pci_host (); -if (pci_host) { - bus =PCI_HOST_BRIDGE (pci_host)->bus; - } +assert (pci_host); + + bus =PCI_HOST_BRIDGE (pci_host)->bus;if (bus) {Aml *scope =aml_scope ("PCI0" );
@@ -2389,9 +2387,8 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)QObject *o; pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return false; - } + +assert (pci_host); o =object_property_get_qobject (pci_host,PCIE_HOST_MCFG_BASE ,NULL );if (!o) {
Signature · 1 line
2.25.1
Quoted 5 lines · Ani Sinha
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.
add "on i386"?
Quoted 1 line
Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
This that seems inappropriate, this is not a bugfix.
Quoted 2 lines
Signed-off-by Ani Sinha <[email protected]>
Frankly I don't see this as a useful cleanup.
assert is generally a last resort thing.
Quoted 15 lines
--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0
hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 122
Quoted 7 lines
hw/acpi/pcihp.c +4
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need
why call out i386 here? well because currently host is only non-null for q35 and i440fx which are both i386. all the above is not a given and we won't remember to update the comment if we change it. Generally graceful failure is the default or should be.
Quoted 56 lines
hw/acpi/pcihp.c +4
-0+* to ignore null values for host here. +*/ return ; }@@ -136,6 +142,8 @@ static void acpi_pcihp_disable_root_bus(void)return ; } +assert (host); + bus =PCI_HOST_BRIDGE (host)->bus;if (bus) {/* setting the hotplug handler to NULL makes the bus non-hotpluggable */ hw/i386/acpi-build.c +6
-9@@ -321,9 +321,7 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64) pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return ; - } +assert (pci_host); range_set_bounds1(hole, object_property_get_uint(pci_host,@@ -1769,9 +1767,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, pci_host =acpi_get_i386_pci_host (); -if (pci_host) { - bus =PCI_HOST_BRIDGE (pci_host)->bus; - } +assert (pci_host); + + bus =PCI_HOST_BRIDGE (pci_host)->bus;if (bus) {Aml *scope =aml_scope ("PCI0" );@@ -2389,9 +2387,8 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)QObject *o; pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return false; - } + +assert (pci_host); o =object_property_get_qobject (pci_host,PCIE_HOST_MCFG_BASE ,NULL );if (!o) {Signature · 1 line
2.25.1
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Ani Sinha
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.add "on i386"?
Quoted 1 line
Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
Quoted 9 lines
This that seems inappropriate, this is not a bugfix.
Quoted 2 lines
Signed-off-by Ani Sinha <[email protected]>Frankly I don't see this as a useful cleanup.
assert is generally a last resort thing.
Igor pushed in the direction of assertion. Otherwise, see my v2.
Quoted 17 lines
Quoted 17 lines
--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;
Quoted 11 lines
hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 122
Quoted 5 lines
hw/acpi/pcihp.c +4
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need why call out i386 here? well because currently host is only non-null for q35 and i440fx which are both i386. all the above is not a given and we won't remember to update the comment if we change it. Generally graceful failure is the default or should be.
Hmm. there is much debate to be had about graceful and unfraceful failures :-) Some might say ungraceful failures helps to catch issues earlier before the state is messed up.
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Ani Sinha
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.
Quoted 6 lines
add "on i386"?
Quoted 1 line
Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")This that seems inappropriate, this is not a bugfix.
Forgot to answer this. I started this patch because I saw a gap that was introduced with the above patch. In acpi_pcihp_disable_root_bus(), Julia's code did not check for null return value from acpi_get_i386_pci_host(). See v2. Hence, I added the fixes tag. Then Igor suggested that I assert instead and I also thought perhaps assertion is a better idea. Hence v3. I am not conflicted after reading your argument. We should assert only when a certain invariant is always respected. Otherwise we should not assert. If you think acpi_get_i386_pci_host() can be called from non-i386 path as well, maybe v2 approach is better.
Quoted 18 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Ani Sinha
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Quoted 6 lines
add "on i386"?
Quoted 1 line
Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")This that seems inappropriate, this is not a bugfix.
Quoted 9 lines
Forgot to answer this. I started this patch because I saw a gap that was introduced with the above patch. In
acpi_pcihp_disable_root_bus(), Julia's code did not check for null return value fromacpi_get_i386_pci_host(). See v2. Hence, I added the fixes tag. Then Igor suggested that I assert instead and I also thought perhaps assertion is a better idea. Hence v3. I am not conflicted after reading your argument. We should assert only when a certain invariant is always respected. Otherwise we should not assert. If you thinkacpi_get_i386_pci_host()can be called from non-i386 path as well, maybe v2 approach is better.
Also I should point out that at this moment, only ich9 and piix4 end up calling acpi_pcihp_disable_root_bus(). Hence, we are ok either way for now. In the future, if other archs end of calling this function, then the question is, do we gracefully fail by simply returning in case of null host bridge or do we assert? In its current form, it will ungracefully crash somewhere.
ping ...
Quoted 40 lines · Ani Sinha
Quoted 18 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Ani Sinha
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Quoted 6 lines
add "on i386"?
Quoted 1 line
Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")This that seems inappropriate, this is not a bugfix.
Quoted 9 lines
Forgot to answer this. I started this patch because I saw a gap that was introduced with the above patch. In
acpi_pcihp_disable_root_bus(), Julia's code did not check for null return value fromacpi_get_i386_pci_host(). See v2. Hence, I added the fixes tag. Then Igor suggested that I assert instead and I also thought perhaps assertion is a better idea. Hence v3. I am not conflicted after reading your argument. We should assert only when a certain invariant is always respected. Otherwise we should not assert. If you thinkacpi_get_i386_pci_host()can be called from non-i386 path as well, maybe v2 approach is better.Also I should point out that at this moment, only ich9 and piix4 end up calling
acpi_pcihp_disable_root_bus(). Hence, we are ok either way for now. In the future, if other archs end of calling this function, then the question is, do we gracefully fail by simply returning in case of null host bridge or do we assert? In its current form, it will ungracefully crash somewhere.
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;
hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }
I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make acpi_pcihp_reset() stub and replace pcihp.c with stub (perhaps use acpi-x86-stub.c) when building for MIPS.
then a bunch of asserts/ifs won't be necessary, just one in acpi_get_i386_pci_host() will be sufficient.
Quoted 49 lines
hw/acpi/pcihp.c +2
-0@@ -136,6 +142,8 @@ static void acpi_pcihp_disable_root_bus(void)return ; } +assert (host); + bus =PCI_HOST_BRIDGE (host)->bus;if (bus) {/* setting the hotplug handler to NULL makes the bus non-hotpluggable */ hw/i386/acpi-build.c +6
-9@@ -321,9 +321,7 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64) pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return ; - } +assert (pci_host); range_set_bounds1(hole, object_property_get_uint(pci_host,@@ -1769,9 +1767,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, pci_host =acpi_get_i386_pci_host (); -if (pci_host) { - bus =PCI_HOST_BRIDGE (pci_host)->bus; - } +assert (pci_host); + + bus =PCI_HOST_BRIDGE (pci_host)->bus;if (bus) {Aml *scope =aml_scope ("PCI0" );@@ -2389,9 +2387,8 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)QObject *o; pci_host =acpi_get_i386_pci_host (); -if (!pci_host) { -return false; - } + +assert (pci_host); o =object_property_get_qobject (pci_host,PCIE_HOST_MCFG_BASE ,NULL );if (!o) {
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.
Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.
OK this is a good idea.
I can see that mips-softmmu-config-devices.h has CONFIG_ACPI_X86 turned on for mips. This does not seem right.
The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=y
So after
-CONFIG_ACPI_X86=y
-CONFIG_PIIX4=y
(the second one is needed because after removing first one we get:
/usr/bin/ld: libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'
This is because in hw/acpi/meson.build, piix4.c is conditional on CONFIG_ACPI_X86. )
/usr/bin/ld: libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld: libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
How to handle this?
Quoted 85 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'
Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.html
which means mips malta will continue to use the x86 specific functions like acpi_pcihp_reset(). Creating a stub for this with acpi-x86-stub.c will result in a double symbol definition because CONFIG_PC is off for mips.
Quoted 94 lines · Ani Sinha
Quoted 85 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.html
Quoted 5 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.
Also to be noted that there is a stub for acpi_get_i386_pci_host() which simply returns NULL. This activates when CONFIG_PC is disabled. It is this stub that gets called for mips and hence the check for non-null host is needed in acpi_set_pci_info() function.
Quoted 5 lines · Ani Sinha
Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.
Frankly this is generating more discussion that it's worth imho. IMHO these tweaks will bring little benefit.
Igor do you feel differently?
Signature · 1 line
MST
Quoted 10 lines · On Thu, 5 Aug 2021 18:13:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Ani Sinha
Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.Frankly this is generating more discussion that it's worth imho. IMHO these tweaks will bring little benefit.
Igor do you feel differently?
replacing 'ifs' with assert is a bit cleaner, but if we are cleaning it up we should clean up it properly without leaving unnecessary code around.
That's why I suggested to separate x86 specific parts from piix4. Philippe (CCed) even have reported issues ACPI parts were causing on MIPS machines, so if someone is willing to untangle the mess it might be worth the shot.
Quoted 102 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 94 lines · Ani Sinha
Quoted 85 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.htmlQuoted 5 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.
Quoted 4 lines
Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.
that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
Quoted 105 lines · Igor Mammedov
Quoted 102 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 99 lines · Ani Sinha
Quoted 85 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.htmlwhich means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.
Quoted 8 lines
Quoted 4 lines
Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
So malta mips does not need ACPI hotplug? In that case, maybe we should not make pcihp.c dependent on CONFIG_ACPI_X86. Ideas welcome.
Quoted 87 lines · Ani Sinha
Quoted 86 lines · Igor Mammedov
Quoted 84 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 83 lines · Ani Sinha
Quoted 82 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
PIIX, PIIX3 and PIIX4 are generic chipsets, not X86-specific.
QEMU's PIIX3 is a Frankenstein to support virtualization to a chipset not designed for it.
If you look at it, the X86 machine use a PIIX3 but the PIIX3 doesn't even provide an ACPI function. It appeared in the PIIX4. The kludge is to instanciate the PIIX4.acpi from the PIIX3 and X86 ppl are happy with it, but it makes it ugly for the other architectures.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.html
What do you mean "by design"? The Malta uses a PIIX4 chipset for its southbridge indeed.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.
Quoted 7 lines
Quoted 4 lines
that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
So malta mips does not need ACPI hotplug? In that case, maybe we should not make
pcihp.cdependent onCONFIG_ACPI_X86. Ideas welcome.
Linux on Malta does use the ACPI features from the PIIX4.
Please dig in the archives, Igor / myself already argued enough about this topic 2 years ago. The consensus was "yes, it is badly implemented, but it works and we don't have time to get it cleaner, pc machine is way more used than the malta one, so let not break the pc machines."
See:
https://www.mail-archive.com/[email protected]/msg613194.html
https://www.mail-archive.com/[email protected]/msg690435.html
https://www.mail-archive.com/[email protected]/msg725504.html
Quoted 130 lines · Philippe Mathieu-Daudé
Quoted 87 lines · Ani Sinha
Quoted 86 lines · Igor Mammedov
Quoted 84 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 83 lines · Ani Sinha
Quoted 82 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
PIIX, PIIX3 and PIIX4 are generic chipsets, not X86-specific.
QEMU's PIIX3 is a Frankenstein to support virtualization to a chipset not designed for it.
If you look at it, the X86 machine use a PIIX3 but the PIIX3 doesn't even provide an ACPI function. It appeared in the PIIX4. The kludge is to instanciate the PIIX4.acpi from the PIIX3 and X86 ppl are happy with it, but it makes it ugly for the other architectures.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.htmlWhat do you mean "by design"? The Malta uses a PIIX4 chipset for its southbridge indeed.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.Quoted 7 lines
Quoted 4 lines
that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
So malta mips does not need ACPI hotplug? In that case, maybe we should not make
pcihp.cdependent onCONFIG_ACPI_X86. Ideas welcome.Linux on Malta does use the ACPI features from the PIIX4.
Please dig in the archives, Igor / myself already argued enough about this topic 2 years ago. The consensus was "yes, it is badly implemented, but it works and we don't have time to get it cleaner, pc machine is way more used than the malta one, so let not break the pc machines."
Quoted 4 lines
See:
https://www.mail-archive.com/[email protected]/msg613194.html
https://www.mail-archive.com/[email protected]/msg690435.html
https://www.mail-archive.com/[email protected]/msg725504.html
Also:
https://gitlab.com/qemu-project/qemu/-/issues/193
https://gitlab.com/qemu-project/qemu/-/issues/221
Quoted 131 lines · Philippe Mathieu-Daudé
Quoted 130 lines · Philippe Mathieu-Daudé
Quoted 87 lines · Ani Sinha
Quoted 86 lines · Igor Mammedov
Quoted 84 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 83 lines · Ani Sinha
Quoted 82 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
PIIX, PIIX3 and PIIX4 are generic chipsets, not X86-specific.
QEMU's PIIX3 is a Frankenstein to support virtualization to a chipset not designed for it.
If you look at it, the X86 machine use a PIIX3 but the PIIX3 doesn't even provide an ACPI function. It appeared in the PIIX4. The kludge is to instanciate the PIIX4.acpi from the PIIX3 and X86 ppl are happy with it, but it makes it ugly for the other architectures.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.htmlWhat do you mean "by design"? The Malta uses a PIIX4 chipset for its southbridge indeed.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.Quoted 7 lines
Quoted 4 lines
that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
So malta mips does not need ACPI hotplug? In that case, maybe we should not make
pcihp.cdependent onCONFIG_ACPI_X86. Ideas welcome.Linux on Malta does use the ACPI features from the PIIX4.
Please dig in the archives, Igor / myself already argued enough about this topic 2 years ago. The consensus was "yes, it is badly implemented, but it works and we don't have time to get it cleaner, pc machine is way more used than the malta one, so let not break the pc machines."
Quoted 8 lines
Quoted 4 lines
See:
https://www.mail-archive.com/[email protected]/msg613194.html
https://www.mail-archive.com/[email protected]/msg690435.html
https://www.mail-archive.com/[email protected]/msg725504.htmlAlso:
https://gitlab.com/qemu-project/qemu/-/issues/193
https://gitlab.com/qemu-project/qemu/-/issues/221
Thanks Phil for the contexts. I will go through them. For now, should we simply go with my v2 then?
Quoted 99 lines · Philippe Mathieu-Daudé
Quoted 87 lines · Ani Sinha
Quoted 86 lines · Igor Mammedov
Quoted 84 lines · On Thu, 5 Aug 2021 19:42:35 +0530 (IST) Ani Sinha <[email protected]> wrote:
Quoted 83 lines · Ani Sinha
Quoted 82 lines · Ani Sinha
Quoted 45 lines · Igor Mammedov
Quoted 25 lines · On Mon, 26 Jul 2021 22:27:43 +0530 Ani Sinha <[email protected]> wrote:
All existing code using
acpi_get_i386_pci_host()checks for a non-null return value from this function call. Instead of returning early when the value returned is NULL, assert instead. Since there are only two possible host buses for i386 - q35 and i440fx, a null value return from the function does not make sense in most cases and is likely an error situation.Fixes c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")Signed-off-by Ani Sinha <[email protected]>--- hw/acpi/pcihp.c | 8 ++++++++ hw/i386/acpi-build.c | 15 ++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-)changelog:
v1: initial patch
v2: removed comment addition - that can be sent as a separate patch.
v3: added assertion for null host values for all cases except one.hw/acpi/pcihp.c +0
-0@@ -116,6 +116,12 @@ static void acpi_set_pci_info(void) bsel_is_set = true;hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 126
Quoted 10 lines
hw/acpi/pcihp.c +6
-0if (!host) { +/* +* This function can be eventually called from +* qemu_devices_reset() -> acpi_pcihp_reset() even +* for architectures other than i386. Hence, we need +* to ignore null values for host here. +*/ return ; }I suspect it's a MIPS target that call this code unnecessarily. It would be better to get rid of this condition altogether. Frr that I can suggest to make
acpi_pcihp_reset()stub and replacepcihp.cwith stub (perhaps useacpi-x86-stub.c) when building for MIPS.Quoted 3 lines
then a bunch of asserts/ifs won't be necessary, just one in
acpi_get_i386_pci_host()will be sufficient.OK this is a good idea.
I can see thatmips-softmmu-config-devices.hhasCONFIG_ACPI_X86turned on for mips. This does not seem right.The issue here is:
$ grep -R CONFIG_ACPI_X86 * devices/mips-softmmu/common.mak:CONFIG_ACPI_X86=ySo after
(quoted diff) +0
-2-CONFIG_ACPI_X86=y -CONFIG_PIIX4=y(the second one is needed because after removing first one we get:
/usr/bin/ld:libcommon.fa.p/hw_isa_piix4.c.o: in function `piix4_create':/home/anisinha/workspace/qemu/build/../hw/isa/piix4.c:269: undefined reference to `piix4_pm_init'This is because in hw/acpi/meson.build,
piix4.cis conditional onCONFIG_ACPI_X86. )
/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_gt64xxx_pci.c.o: in function `gt64120_pci_set_irq':/home/anisinha/workspace/qemu/build/../hw/mips/gt64xxx_pci.c:1020:
undefined reference to `piix4_dev'/usr/bin/ld:libqemu-mips-softmmu.fa.p/hw_mips_malta.c.o: in function `mips_malta_init':/home/anisinha/workspace/qemu/build/../hw/mips/malta.c:1404: undefined reference to `piix4_create'Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So should mips be doing piix stuff anyway? Is Piix4 etc not x86 specific?
PIIX, PIIX3 and PIIX4 are generic chipsets, not X86-specific.
QEMU's PIIX3 is a Frankenstein to support virtualization to a chipset not designed for it.
If you look at it, the X86 machine use a PIIX3 but the PIIX3 doesn't even provide an ACPI function. It appeared in the PIIX4. The kludge is to instanciate the PIIX4.acpi from the PIIX3 and X86 ppl are happy with it, but it makes it ugly for the other architectures.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Apparently this is by design:
https://qemu.readthedocs.io/en/stable/system/target-mips.htmlWhat do you mean "by design"? The Malta uses a PIIX4 chipset for its southbridge indeed.
I meant it was intentional and not by accident.
Quoted 26 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
which means mips malta will continue to use the x86 specific functions like
acpi_pcihp_reset(). Creating a stub for this withacpi-x86-stub.cwill result in a double symbol definition becauseCONFIG_PCis off for mips.Also to be noted that there is a stub for
acpi_get_i386_pci_host()which simply returns NULL. This activates whenCONFIG_PCis disabled. It is this stub that gets called for mips and hence the check for non-null host is needed inacpi_set_pci_info()function.Quoted 7 lines
Quoted 4 lines
that were half measures to deal around code that shouldn't be called, now with pcihp being used by both pc and q35 we don't have reason to keep around null checks modulo mips calling code that shouldn't be called there to begin with.
So malta mips does not need ACPI hotplug? In that case, maybe we should not make
pcihp.cdependent onCONFIG_ACPI_X86. Ideas welcome.Linux on Malta does use the ACPI features from the PIIX4.
Please dig in the archives, Igor / myself already argued enough about this topic 2 years ago. The consensus was "yes, it is badly implemented, but it works and we don't have time to get it cleaner, pc machine is way more used than the malta one, so let not break the pc machines."
Quoted 4 lines
See:
https://www.mail-archive.com/[email protected]/msg613194.html
https://www.mail-archive.com/[email protected]/msg690435.html
https://www.mail-archive.com/[email protected]/msg725504.html
Ok I see what you were trying to do. I wanted to stub out the cpu and memory hotplug bits for non x86 from piix4_acpi_system_hot_add_init(). Howwver, sadly, arm uses memory hotplug for its GED device:
cff51ac978c4fa0b3d0de0fd ("hw/arm/virt: Enable device memory cold/hot plug with ACPI boot")
This makes things messy and complicated.
Anyways, I am trying something and will send out a patch if I am successful.