Skip to contentSkip to conversation

phys_page_find() returning &sections[PHYS_SECTION_UNASSIGNED]

Qemu-devel Programmingkid 3 participants 5 messages Dec 24, 2015

lore
Share & tools
lore
#0 lore raw

I'm having problems with the pci_dma_read() function. When using a Mac OS X guest, the data that this function returns is all zeros. After doing a lot of instruction tracing, I tracked the problem to a function called phys_page_find(). It always returns &sections[PHYS_SECTION_UNASSIGNED]. What I would like to know is what is an unassigned section? How is memory suppose to be assigned?

The pci_dma_read() function call I'm tracking takes place in rtl8139.c in case anyone would like to know.

#1 lore raw
Quoted 6 lines · Programmingkid

I'm having problems with the pci_dma_read() function. When using a Mac OS X guest, the data that this function returns is all zeros. After doing a lot of instruction tracing, I tracked the problem to a function called phys_page_find(). It always returns &sections[PHYS_SECTION_UNASSIGNED]. What I would like to know is what is an unassigned section? How is memory suppose to be assigned?

Unassigned here is an area of the physical address space which has nothing in it (no RAM, no device, just nothing). Depending on the guest CPU architecture, accessing this might cause a bus fault or might just return a dummy value. (It looks like it's the latter for your case.)

One way to get this is if the guest mis-programs the PCI DMA so that it tries to do DMA from a wrong address. Or maybe the PCI host controller emulation isn't right and we're not using the right DMA address. Or there's some RAM or something that the guest expects to be present in the machine but which is not implemented by us.

You need to find out why we're trying to DMA to/from this bogus address, I think.

thanks
-- PMM

#2 lore raw
Quoted 21 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I'm having problems with the pci_dma_read() function. When using a Mac OS X guest, the data that this function returns is all zeros. After doing a lot of instruction tracing, I tracked the problem to a function called phys_page_find(). It always returns &sections[PHYS_SECTION_UNASSIGNED]. What I would like to know is what is an unassigned section? How is memory suppose to be assigned?

Unassigned here is an area of the physical address space which has nothing in it (no RAM, no device, just nothing). Depending on the guest CPU architecture, accessing this might cause a bus fault or might just return a dummy value. (It looks like it's the latter for your case.)

One way to get this is if the guest mis-programs the PCI DMA so that it tries to do DMA from a wrong address. Or maybe the PCI host controller emulation isn't right and we're not using the right DMA address. Or there's some RAM or something that the guest expects to be present in the machine but which is not implemented by us.

Quoted 2 lines

You need to find out why we're trying to DMA to/from this bogus address, I think.

Mac OS X has to give the RTL8139 network interface card an address to a memory buffer. It is used to send packets to the network interface card from the guest. How the address is allocated in Mac OS X seems simple enough. This address is a physical address and not a virtual address, so that seems good. One address that is used is 0x13d9000. I think that would be around the 19 MB area. It should be ok for the rtl8139 to access because it is in the "system" memory region.

#3 lore raw
Quoted 22 lines · Programmingkid
Quoted 21 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I'm having problems with the pci_dma_read() function. When using a Mac OS X guest, the data that this function returns is all zeros. After doing a lot of instruction tracing, I tracked the problem to a function called phys_page_find(). It always returns &sections[PHYS_SECTION_UNASSIGNED]. What I would like to know is what is an unassigned section? How is memory suppose to be assigned?

Unassigned here is an area of the physical address space which has nothing in it (no RAM, no device, just nothing). Depending on the guest CPU architecture, accessing this might cause a bus fault or might just return a dummy value. (It looks like it's the latter for your case.)

One way to get this is if the guest mis-programs the PCI DMA so that it tries to do DMA from a wrong address. Or maybe the PCI host controller emulation isn't right and we're not using the right DMA address. Or there's some RAM or something that the guest expects to be present in the machine but which is not implemented by us.

Quoted 4 lines
Quoted 2 lines

You need to find out why we're trying to DMA to/from this bogus address, I think.

Mac OS X has to give the RTL8139 network interface card an address to a memory buffer. It is used to send packets to the network interface card from the guest. How the address is allocated in Mac OS X seems simple enough. This address is a physical address and not a virtual address, so that seems good. One address that is used is 0x13d9000. I think that would be around the 19 MB area. It should be ok for the rtl8139 to access because it is in the "system" memory region.

Not sure this is relevant here but previously I've found a patch was necessary to OpenBIOS for me to make DMA work with RTL8139 otherwise sending data was not working correctly. Here's the patch in case it could help or give you an idea:

http://www.openfirmware.info/pipermail/openbios/2014-June/008363.html

But it could be your problem is different and the patch is not relevant.

Regards,
BALATON Zoltan

#4 lore raw
Quoted 28 lines · BALATON Zoltan
Quoted 22 lines · Programmingkid
Quoted 21 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I'm having problems with the pci_dma_read() function. When using a Mac OS X guest, the data that this function returns is all zeros. After doing a lot of instruction tracing, I tracked the problem to a function called phys_page_find(). It always returns &sections[PHYS_SECTION_UNASSIGNED]. What I would like to know is what is an unassigned section? How is memory suppose to be assigned?

Unassigned here is an area of the physical address space which has nothing in it (no RAM, no device, just nothing). Depending on the guest CPU architecture, accessing this might cause a bus fault or might just return a dummy value. (It looks like it's the latter for your case.)

One way to get this is if the guest mis-programs the PCI DMA so that it tries to do DMA from a wrong address. Or maybe the PCI host controller emulation isn't right and we're not using the right DMA address. Or there's some RAM or something that the guest expects to be present in the machine but which is not implemented by us.

Quoted 4 lines
Quoted 2 lines

You need to find out why we're trying to DMA to/from this bogus address, I think.

Mac OS X has to give the RTL8139 network interface card an address to a memory buffer. It is used to send packets to the network interface card from the guest. How the address is allocated in Mac OS X seems simple enough. This address is a physical address and not a virtual address, so that seems good. One address that is used is 0x13d9000. I think that would be around the 19 MB area. It should be ok for the rtl8139 to access because it is in the "system" memory region.

Quoted 8 lines

Not sure this is relevant here but previously I've found a patch was necessary to OpenBIOS for me to make DMA work with RTL8139 otherwise sending data was not working correctly. Here's the patch in case it could help or give you an idea:

http://www.openfirmware.info/pipermail/openbios/2014-June/008363.html

But it could be your problem is different and the patch is not relevant.

Regards,
BALATON Zoltan

Thank you very much for the help. It looks like the Mac OS X driver already sets the bus mastering bit.