Skip to content

Conversation

@lipengfei28
Copy link
Contributor

@lipengfei28 lipengfei28 commented Nov 25, 2025

Summary

X86_64:init bar in bios, In NuttX, PCI should not be enumerated again; it is only necessary to calculate the size of the BARs.
kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION failed

Impact

qemu-system-x86_64, PCI enumerate in bios, in nuttx,should use address in the bar regs,
it is only necessary to calculate the size of the BARs,

Testing

If there is not ths patch
the log:
qemu-system-x86_64 -cpu host -enable-kvm -m 2G -cdrom boot.iso -nographic -serial mon:stdio
-object memory-backend-file,id=shmmem-shmem2,mem-path=/dev/shm/my_shmem2,size=4194304,share=yes
-device ivshmem-plain,id=shmem2,memdev=shmmem-shmem2,addr=0xb
SeaBIOS (version 1.15.0-1)

iPXE (https://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+7FF8B350+7FECB350 CA00

Booting from Hard Disk...
Boot failed: could not read the boot disk

Booting from Floppy...
Boot failed: could not read the boot disk

Booting from DVD/CD...
pci_scan_bus: pci_scan_bus for bus 0
pci_scan_bus: class = 00000600, hdr_type = 00000000
pci_scan_bus: 00:00 [8086:1237]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000601, hdr_type = 00000080
pci_scan_bus: 00:08 [8086:7000]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000101, hdr_type = 00000000
pci_scan_bus: 00:09 [8086:7010]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4: mask64=fffffffe 16bytes
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000680, hdr_type = 00000000
pci_scan_bus: 00:0b [8086:7113]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000300, hdr_type = 00000000
pci_scan_bus: 00:10 [1234:1111]
pci_setup_device: pbar0: mask64=fffffff0 16777216bytes
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2: mask64=fffffff0 4096bytes
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000200, hdr_type = 00000000
pci_scan_bus: 00:18 [8086:100e]
pci_setup_device: pbar0: mask64=fffffff0 131072bytes
pci_setup_device: pbar1: mask64=fffffffe 64bytes
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000500, hdr_type = 00000000
pci_scan_bus: 00:58 [1af4:1110]
pci_setup_device: pbar0: mask64=fffffff0 256bytes
pci_setup_device: pbar1 set bad mask
qemu-system-x86_64: kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION failed, slot=4, start=0xfffffffffe000000, size=0x400000: Invalid argument
kvm_set_phys_mem: error registering slot: Invalid argument
[1] 616461 IOT instruction qemu-system-x86_64 -cpu host -enable-kvm -m 2G -cdrom boot.iso -nographic

Add this patch:
qemu_robot_robot qemu-system-x86_64 -cpu host -enable-kvm -m 2G -cdrom boot.iso -nographic -serial mon:stdio
-object memory-backend-file,id=shmmem-shmem2,mem-path=/dev/shm/my_shmem2,size=4194304,share=yes
-device ivshmem-plain,id=shmem2,memdev=shmmem-shmem2,addr=0xb
SeaBIOS (version 1.15.0-1)

iPXE (https://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+7FF8B350+7FECB350 CA00

Booting from Hard Disk...
Boot failed: could not read the boot disk

Booting from Floppy...
Boot failed: could not read the boot disk

Booting from DVD/CD...
pci_scan_bus: pci_scan_bus for bus 0
pci_scan_bus: class = 00000600, hdr_type = 00000000
pci_scan_bus: 00:00 [8086:1237]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000601, hdr_type = 00000080
pci_scan_bus: 00:08 [8086:7000]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000101, hdr_type = 00000000
pci_scan_bus: 00:09 [8086:7010]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4: mask64=fffffffe 16bytes
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000680, hdr_type = 00000000
pci_scan_bus: 00:0b [8086:7113]
pci_setup_device: pbar0 set bad mask
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000300, hdr_type = 00000000
pci_scan_bus: 00:10 [1234:1111]
pci_setup_device: pbar0: mask64=fffffff0 16777216bytes
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2: mask64=fffffff0 4096bytes
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000200, hdr_type = 00000000
pci_scan_bus: 00:18 [8086:100e]
pci_setup_device: pbar0: mask64=fffffff0 131072bytes
pci_setup_device: pbar1: mask64=fffffffe 64bytes
pci_setup_device: pbar2 set bad mask
pci_setup_device: pbar3 set bad mask
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
pci_scan_bus: class = 00000500, hdr_type = 00000000
pci_scan_bus: 00:58 [1af4:1110]
pci_setup_device: pbar0: mask64=fffffff0 256bytes
pci_setup_device: pbar1 set bad mask
pci_setup_device: pbar2: mask64=fffffffffffffff0 4194304bytes
pci_setup_device: pbar4 set bad mask
pci_setup_device: pbar5 set bad mask
acpi_dump: RSDT = 0x7ffe190c
acpi_dump: tp32 = 0x7ffe1930
acpi_dump: end32 = 0x7ffe1940
acpi_sdt_dump: ptr = 0x7ffe17c0 sig = FACP
acpi_sdt_dump: ptr = 0x7ffe1834 sig = APIC
acpi_sdt_dump: ptr = 0x7ffe18ac sig = HPET
acpi_sdt_dump: ptr = 0x7ffe18e4 sig = WAET
acpi_dump: Found MADT type 0 0x7ffe1860
acpi_dump: Found MADT type 1 0x7ffe1868
acpi_dump: Found MADT type 2 0x7ffe1874
acpi_dump: Found MADT type 2 0x7ffe187e
acpi_dump: Found MADT type 2 0x7ffe1888
acpi_dump: Found MADT type 2 0x7ffe1892
acpi_dump: Found MADT type 2 0x7ffe189c
acpi_dump: Found MADT type 4 0x7ffe18a6
acpi_dump: Found LAPIC for CPU 0 0x7ffe1860
acpi_dump: ACPI ID 0
acpi_dump: APIC ID 0
acpi_dump: flags 1
acpi_dump: Found IOAPIC 0x7ffe1868
x86_rng_initialize: Initializing RNG
ivshmem_probe: shmem addr=0xfe000000 size=4194304 reg=0xfebb1000
pci_register_uio_ivshmem_driver: Register ivshmem driver, id=0
e1000_probe: Enabled bus mastering
e1000_probe: Enabled memory resources
e1000_initialize: Failed to connect MSI -138
telnetd [0:255]

NuttShell (NSH) NuttX-12.3.0
nsh> ls
/:
dev/
proc/
nsh>
nsh> pwd
/
nsh>

@github-actions github-actions bot added Area: PCI Size: S The size of the change in this PR is small labels Nov 25, 2025
@jerpelea jerpelea changed the title pci:x86_64 calculate bar size,kvm_set_user_memory_region: KVM_SET_USE… drivers/pci: calculate bar size Nov 25, 2025
Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update commit title to
drivers/pci: x86_64 calculate bar size

Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update PR message to describe the change

X86_64:nit bar in bios, so in nuttx, the bar is setuped
kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION failed

Signed-off-by: lipengfei28 <[email protected]>
@lipengfei28
Copy link
Contributor Author

please update commit title to drivers/pci: x86_64 calculate bar size

done

Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update PR description.

@lipengfei28
Copy link
Contributor Author

Please update PR description.

done

@linguini1
Copy link
Contributor

done

It still does not adhere to the contribution guidelines. You must fill out all of the sections according to the template.

@lipengfei28
Copy link
Contributor Author

done

It still does not adhere to the contribution guidelines. You must fill out all of the sections according to the template.

done

@linguini1
Copy link
Contributor

done

Please read the contributing guidelines. The description is still insufficient.

First off, the description still contains the following template text:

PRs without testing information will not be accepted. We will request test logs.

This portion, ironically, asks for test logs. Letting us know what command you used to invoke QEMU is good step, but that is still not a test log. It is not sufficient "testing" to invoke QEMU and see that NuttX boots. You've made a functional change to the PCI driver. How are you testing that change specifically, in the driver? Are you invoking the driver?

It's also not clear from your description (at least to me) what the fix is. You mention:

X86_64:init bar in bios, In NuttX, PCI should not be enumerated again; it is only necessary to calculate the size of the BARs.
kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION failed

This doesn't really make sense to me. What is this error and under what conditions was it occurring before? How does your change fix that? Was NuttX failing to boot before this change? It is not well described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: PCI Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants