From: "huaminxu3 via groups.io" <huaminxu3=gmail.com@groups.io>
To: devel@edk2.groups.io
Subject: [edk2-devel] The different I/O ports space distribution in Ovmf and seaBIOS , can I change the default I/O space in Ovmf?
Date: Mon, 20 Jan 2025 01:45:30 -0800 [thread overview]
Message-ID: <eLPV.1737366330295113697.sknQ@groups.io> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 3051 bytes --]
In OVMF PCI I/O space address distribution , according to the OvmfPkg/Library/PlatformInitLib/Platform.c
VOID
EFIAPI
PlatformMemMapInitialization (
IN OUT EFI_HOB_PLATFORM_INFO * PlatformInfoHob
)
{
UINT64 PciIoBase ;
UINT64 PciIoSize ;
UINT64 PciExBarBase ;
UINT32 PciBase ;
UINT32 PciSize ;
PciIoBase = 0xC000 ;
PciIoSize = 0x4000 ;
The PciIoBase and PciIoSize determine the I/O address space spare for PCI devices. In Ovmf, the two variables are fixed. The PciIoBase = 0xC000 and the PciIoSize = 0x4000 , which means the I/O space for PCI devices is 0x4000. In some circumstances, for example, when I attach many devices to the virtual machine , the 0x4000 is not enough. When I attach 8 PCI bridges and 100 netcards and 100 virtio disks, many devices are unusable. The I/O address of these devices become all 1, just as the following picture shows:
I compared the ovmf with seaBIOS and found that the virtual machine using seaBIOS can work properly. I looked into the I/O space distribution implement of seaBIOS and found that in qemu\roms\seabios\src\fw\pciinit.c, it says :
/*
* QEMU I/O address space usage:
* 0000 - 0fff legacy isa, pci config, pci root bus, ...
* 1000 - 9fff free
* a000 - afff hotplug (cpu, pci via acpi, i440fx/piix only)
* b000 - bfff power management (PORT_ACPI_PM_BASE)
* [ qemu 1.4+ implements pci config registers
* properly so guests can place the registers
* where they want, on older versions its fixed ]
* c000 - ffff free, traditionally used for pci io
*/
It seems that the 0x1000-0x9fff space can be used for PCI I/O space. In the seaBIOS, it calculates the total I/O space usage by PCI devices, if the total usage exceeds 0x4000, it use 0x1000-0x9fff for PCI I/O space, otherwise it uses 0xC000-0xFFFF:
struct pci_region * r_io = & bus -> r [ PCI_REGION_TYPE_IO ];
u64 sum = pci_region_sum ( r_io );
if ( sum < 0x4000 ) {
/* traditional region is big enougth, use it */
r_io -> base = 0xc000 ;
} else if ( sum < pci_io_low_end - 0x1000 ) {
/* use the larger region at 0x1000 */
r_io -> base = 0x1000 ;
} else {
/* not enouth io address space -> error out */
return - 1 ;
}
Due to the different implement of OVMF and seaBIOS, the OVMF can not know how much PCI I/O space all the devices use. So I am wondering that is it proper to change the default PCI I/O space to 0x1000-0x9FFF to fit more devices (for example , 100 netcards and 100 virtio disks). In that case, the PciIoBase =0x1000 and PciIoSize = 0x9000.
I am hoping that I can get a reply. Thank for you help.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121027): https://edk2.groups.io/g/devel/message/121027
Mute This Topic: https://groups.io/mt/110712298/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #1.2: Type: text/html, Size: 10939 bytes --]
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 150527 bytes --]
reply other threads:[~2025-01-20 10:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eLPV.1737366330295113697.sknQ@groups.io \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox