Skip to content

Commit 0b05339

Browse files
Igor Mammedovmstsirkin
authored andcommitted
pci: acpi: Windows 'PCI Label Id' bug workaround
Current versions of Windows call _DSM(func=7) regardless of whether it is supported or not. It leads to NICs having bogus 'PCI Label Id = 0', where none should be set at all. Also presence of 'PCI Label Id' triggers another Windows bug on localized versions that leads to hangs. The later bug is fixed in latest updates for 'Windows Server' but not in consumer versions of Windows (and there is no plans to fix it as far as I'm aware). Given it's easy, implement Microsoft suggested workaround (return invalid Package) so that affected Windows versions could boot on QEMU. This would effectvely remove bogus 'PCI Label Id's on NICs, but MS teem confirmed that flipping 'PCI Label Id' should not change 'Network Connection' ennumeration, so it should be safe for QEMU to change _DSM without any compat code. Smoke tested with WinXP and WS2022 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/774 Signed-off-by: Igor Mammedov <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 1ad3264 commit 0b05339

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

hw/i386/acpi-build.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ static Aml *aml_pci_pdsm(void)
654654
Aml *acpi_index = aml_local(2);
655655
Aml *zero = aml_int(0);
656656
Aml *one = aml_int(1);
657+
Aml *not_supp = aml_int(0xFFFFFFFF);
657658
Aml *func = aml_arg(2);
658659
Aml *params = aml_arg(4);
659660
Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
@@ -678,7 +679,7 @@ static Aml *aml_pci_pdsm(void)
678679
*/
679680
ifctx1 = aml_if(aml_lnot(
680681
aml_or(aml_equal(acpi_index, zero),
681-
aml_equal(acpi_index, aml_int(0xFFFFFFFF)), NULL)
682+
aml_equal(acpi_index, not_supp), NULL)
682683
));
683684
{
684685
/* have supported functions */
@@ -704,18 +705,30 @@ static Aml *aml_pci_pdsm(void)
704705
{
705706
Aml *pkg = aml_package(2);
706707

707-
aml_append(pkg, zero);
708-
/*
709-
* optional, if not impl. should return null string
710-
*/
711-
aml_append(pkg, aml_string("%s", ""));
712-
aml_append(ifctx, aml_store(pkg, ret));
713-
714708
aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
709+
aml_append(ifctx, aml_store(pkg, ret));
715710
/*
716-
* update acpi-index to actual value
711+
* Windows calls func=7 without checking if it's available,
712+
* as workaround Microsoft has suggested to return invalid for func7
713+
* Package, so return 2 elements package but only initialize elements
714+
* when acpi_index is supported and leave them uninitialized, which
715+
* leads elements to being Uninitialized ObjectType and should trip
716+
* Windows into discarding result as an unexpected and prevent setting
717+
* bogus 'PCI Label' on the device.
717718
*/
718-
aml_append(ifctx, aml_store(acpi_index, aml_index(ret, zero)));
719+
ifctx1 = aml_if(aml_lnot(aml_lor(
720+
aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
721+
)));
722+
{
723+
aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
724+
/*
725+
* optional, if not impl. should return null string
726+
*/
727+
aml_append(ifctx1, aml_store(aml_string("%s", ""),
728+
aml_index(ret, one)));
729+
}
730+
aml_append(ifctx, ifctx1);
731+
719732
aml_append(ifctx, aml_return(ret));
720733
}
721734

0 commit comments

Comments
 (0)