From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.111596.1669616767470620388 for ; Sun, 27 Nov 2022 22:26:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YDxA5Eb/; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669616766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jGt3wrKWRdNRpZjc/wUHqssEVh9C2B5opvo5/SXbTs0=; b=YDxA5Eb/EqumQY9Wn136o/JFr2ii42DkZM7FCj3myQrBwpttqHu2zNkRj7Tg8OGInD9OLx crYbXF5JYhekBUISESjMQcFx8h21jDpkr8sGT8B+jjRwj51LrUyU/3u5WF0+7aw8D0r5yx RB+lOvpQmBH1HMzDcfE7JZ/xcdfdaUM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-J5zAwucENkKR1OISikw3uA-1; Mon, 28 Nov 2022 01:26:03 -0500 X-MC-Unique: J5zAwucENkKR1OISikw3uA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0261F3814585; Mon, 28 Nov 2022 06:26:03 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2EA2C40C2087; Mon, 28 Nov 2022 06:26:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D87C31800080; Mon, 28 Nov 2022 07:25:58 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Gerd Hoffmann , Pawel Polawski , Ard Biesheuvel , Jordan Justen , Jiewen Yao Subject: [PATCH 1/1] OvmfPkg/PciHotPlugInitDxe: fix io window size Date: Mon, 28 Nov 2022 07:25:58 +0100 Message-Id: <20221128062558.173307-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Smallest IO window size for PCI bridges is 0x1000. Add a check and fixup the Exponent of needed. Avoids broken resource assignments like this: [ ... ] PciBus: Resource Map for Root Bridge PciRoot(0x0) Type = Io16; Base = 0x6000; Length = 0x7000; Alignment = 0xFFF [ ... ] Base = 0xC000; Length = 0x200; Alignment = 0xFFF; Owner = PPB [00|02|00:**] Base = 0xC200; Length = 0x40; Alignment = 0x3F; Owner = PCI [00|1F|03:20] Base = 0xC240; Length = 0x20; Alignment = 0x1F; Owner = PCI [00|1F|02:20] [ ... ] ... which the linux kernel fixes up later: [ 0.644657] pci 0000:00:1f.3: BAR 4: assigned [io 0x1000-0x103f] [ 0.646833] pci 0000:00:1f.2: BAR 4: assigned [io 0x1040-0x105f] With the patch applied: { ... ] PciBus: Resource Map for Root Bridge PciRoot(0x0) Type = Io16; Base = 0x6000; Length = 0x8000; Alignment = 0xFFF [ ... ] Base = 0xC000; Length = 0x1000; Alignment = 0xFFF; Owner = PPB [00|02|00:**] Base = 0xD000; Length = 0x40; Alignment = 0x3F; Owner = PCI [00|1F|03:20] Base = 0xD040; Length = 0x20; Alignment = 0x1F; Owner = PCI [00|1F|02:20] [ ... ] Signed-off-by: Gerd Hoffmann --- OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c index 3f9c84cf2b54..6c8bbc3b199d 100644 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c +++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c @@ -117,6 +117,10 @@ SetIoPadding ( IN UINTN SizeExponent ) { + if (SizeExponent < 12) { + SizeExponent = 12; + } + Descriptor->ResType = ACPI_ADDRESS_SPACE_TYPE_IO; Descriptor->AddrLen = LShiftU64 (1, SizeExponent); Descriptor->AddrRangeMax = Descriptor->AddrLen - 1; -- 2.38.1