Re: PCI device passthrough / memory mapping issue

2010-03-24 Thread Avi Kivity

On 03/19/2010 12:46 AM, Fede wrote:

I'm currently working to enable vga passthrough in kvm.
   



assigned_dev_iomem_map: e_phys=1000 r_virt=0x7fa64af0e000 type=0
len=0200 region_num=3
kvm_register_phys_mem:580 memory: gpa: 1000, size: 200, uaddr:
7fa64af0e000, slot: 7,flags: 0
create_userspace_phys_mem: File exists
assigned_dev_iomem_map: Error: create new mapping failed


This worked a month ago. But after some git updates there's a problem.

When the real device regions are mapped from real virtual memory to
guest physical addresses in kvm, it overlaps region 3 with the guest
physical memory assigned to kernel space (0x1000 to 0x1020)

I've been trying to look for the answer to this question: Why is gpa
0x1000 chosen and not any other free memory space?
   


The BIOS generally assigns addresses, then the OS updates them if it 
wants to.  Is the crash before or after the OS has started loading?


If before, suggest you add some printfs to seabios to explain its decisions.


It seems that this addresses are being chosen here (for example, for region 3):
assigned_dev_pci_read_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_write_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_read_config: (4.0): address=001c val=0xfe00 len=4
   


The above sequence is how the bios determines the BAR size. (0x200 
in this case).



assigned_dev_pci_write_config: (4.0): address=001c val=0x len=4
   


Now it clears the mess from the previous step.


assigned_dev_pci_read_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_write_config: (4.0): address=001c val=0x1000 len=4
   


Here it assigns a new address.  It's clearly wrong.  A log in seabios 
will explain this.



What does this mean? Why PCI BARs are being written and read?



Why the
values that are written differs from the ones that are read after?
   


BARs are not RAM cells.  the least significant address bits are 
hardwired to zero, that's how the BIOS detects the BAR size (and 
required alignment).



The last write is the gpa that is used.

Is this a bug? I can't find the source of this gpa addresses. I need
to change them.
   


Looks like a bug in seabios.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PCI device passthrough / memory mapping issue

2010-03-18 Thread Fede
I'm currently working to enable vga passthrough in kvm.

This is a current git qemu-kvm run with some debug printings:


slash...@fidel ~/kvm/vms $ qemu-system-x86_64 -hda i386ubuntu904.img
-boot c -m 1024 -net nic -net user,hostfwd=tcp::-:22 -pcidevice
host=01:00.0
vm_register_phys_mem:580 memory: gpa: 0, size: a, uaddr:
7fa65f077000, slot: 0, flags: 0
kvm_register_phys_mem:580 memory: gpa: 10, size: 3ff0, uaddr:
7fa65f177000, slot: 1, flags: 0
kvm_register_phys_mem:580 memory: gpa: e, size: 2, uaddr:
7fa6a2fc, slot: 2, flags: 0
kvm_register_phys_mem:580 memory: gpa: c, size: 2, uaddr:
7fa6a2f7d000, slot: 3, flags: 0
kvm_register_phys_mem:580 memory: gpa: fffe, size: 2, uaddr:
7fa6a2fc, slot: 4, flags: 0
device: 01:00.0: driver=pci-assign host=01:00.0
get_real_device: region 0 size 16777216 start 0xe200 type 512 resource_fd 13
get_real_device: region 1 size 268435456 start 0xd000 type 4608
resource_fd 14
get_real_device: region 3 size 33554432 start 0xe000 type 512 resource_fd 15
get_real_device: region 5 size 128 start 0xe000 type 256 resource_fd 0
get_real_device: region 6 size 524288 start 0xe300 type 4608 resource_fd 0
assigned_dev_register_regions: MAP PHYSICAL MEMORY e_physbase=0xe200
assigned_dev_register_regions: NON_PCI_ROM_SLOT virt_base=0x7fa65cf0e000
assigned_dev_register_regions: MAP PHYSICAL MEMORY e_physbase=0xd000
assigned_dev_register_regions: NON_PCI_ROM_SLOT virt_base=0x7fa64cf0e000
assigned_dev_register_regions: MAP PHYSICAL MEMORY e_physbase=0xe000
assigned_dev_register_regions: NON_PCI_ROM_SLOT virt_base=0x7fa64af0e000
assigned_dev_register_regions: MAP PHYSICAL MEMORY e_physbase=0xe300
assigned_dev_register_regions: PCI_ROM_SLOT virt_base=0x7fa64ae8e000
assigned_dev_pci_read_config: (4.0): address= val=0x10de len=2
assigned_dev_pci_read_config: (4.0): address=000e val=0x len=1
assigned_dev_pci_read_config: (4.0): address= val=0x10de len=2
assigned_dev_pci_read_config: (4.0): address=0002 val=0x0622 len=2
assigned_dev_pci_read_config: (4.0): address=000e val=0x len=1
kvm_register_phys_mem:580 memory: gpa: f000, size: 100, uaddr:
7fa65e075000, slot: 5, flags: 0
kvm_dirty_pages_log_enable_slot:293 start f000 len 100
kvm_dirty_pages_log_change:266 slot 5 start f000 len 100 flags 1
assigned_dev_pci_read_config: (4.0): address= val=0x10de len=2
assigned_dev_pci_read_config: (4.0): address=000e val=0x len=1
assigned_dev_pci_read_config: (4.0): address=000a val=0x0300 len=2
assigned_dev_pci_read_config: (4.0): address= val=0x10de len=2
assigned_dev_pci_read_config: (4.0): address=0002 val=0x0622 len=2
assigned_dev_pci_read_config: (4.0): address=0010 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0010 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0010 val=0xff00 len=4
assigned_dev_pci_write_config: (4.0): address=0010 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0010 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0010 val=0xf300 len=4
assigned_dev_pci_read_config: (4.0): address=0014 val=0x0008 len=4
assigned_dev_pci_write_config: (4.0): address=0014 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0014 val=0xf008 len=4
assigned_dev_pci_write_config: (4.0): address=0014 val=0x0008 len=4
assigned_dev_pci_read_config: (4.0): address=0014 val=0x0008 len=4
assigned_dev_pci_write_config: (4.0): address=0014 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0018 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0018 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0018 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0018 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_write_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_read_config: (4.0): address=001c val=0xfe00 len=4
assigned_dev_pci_write_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_read_config: (4.0): address=001c val=0x len=4
assigned_dev_pci_write_config: (4.0): address=001c val=0x1000 len=4
assigned_dev_pci_read_config: (4.0): address=0020 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0020 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0020 val=0x len=4
assigned_dev_pci_write_config: (4.0): address=0020 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0024 val=0x0001 len=4
assigned_dev_pci_write_config: (4.0): address=0024 val=0x len=4
assigned_dev_pci_read_config: (4.0): address=0024 val=0xff81 len=4
assigned_dev_pci_write_config: (4.0): address=0024 val=0x0001 len=4
assigned_dev_pci_read_config: (4.0): address=0024 val=0x0001 len=4
assigned_dev_pci_write_config: (4.0):