qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [PATCHv2 10/12] tap: add vhost/vhostfd options


From: Anthony Liguori
Subject: Re: [Qemu-devel] Re: [PATCHv2 10/12] tap: add vhost/vhostfd options
Date: Tue, 02 Mar 2010 12:13:58 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0

On 03/02/2010 12:00 PM, Marcelo Tosatti wrote:
- it always returns a transient mapping
- it may (transparently) bounce
- it may fail to bounce, caller must deal

The new function I'm proposing has the following semantics:
What exactly are the purposes of the new function?

We need an API that can be used to obtain a persistent mapping of a given guest physical address. We don't have that today. We can potentially change cpu_physical_memory_map() to also accommodate this use case but that's a second step.

- it always returns a persistent mapping
For hotplug? What exactly you mean persistent?

Hotplug cannot happen as long as a persistent mapping exists for an address within that region. This is okay. You cannot have an active device driver DMA'ing to a DIMM and then hot unplug it. The guest is responsible for making sure this doesn't happen.

- it never bounces
- it will only fail if the mapping isn't ram

A caller can use the new function to implement an optimization to
force the device to only work with real ram.
To bypass the address translation in exec.c?

No, the ultimate goal is to convert virtio ring accesses from:

static inline uint32_t vring_desc_len(target_phys_addr_t desc_pa, int i)
{
    target_phys_addr_t pa;
    pa = desc_pa + sizeof(VRingDesc) * i + offsetof(VRingDesc, len);
    return ldl_phys(pa);
}

len = vring_desc_len(vring.desc_pa, i)

To:

len = ldl_w(vring->desc[i].len);

When host == arch, ldl_w is a nop. Otherwise, it's just a byte swap. ldl_phys() today turns into cpu_physical_memory_read() which is very slow.

To support this, we must enforce that when a guest passes us a physical address, we can safely obtain a persistent mapping to it. This is true for any ram address. It's not true for MMIO memory. We have no way to do this with cpu_physical_memory_map().

   IOW, this is something we can use in virtio, but very little else.
cpu_physical_memory_map can be used in more circumstances.
Does not make much sense to me. The qdev<->  memory map mapping seems
more important. Following your security enhancement drive, you can for
example check whether the region can actually be mapped by the device
and deny otherwise, or do whatever host-side memory protection tricks
you'd like.

It's two independent things. Part of what makes virtio so complicated to convert to proper bus accessors is it's use of ldl_phys/stl_phys/etc. No other device use those functions. If we reduce virtio to just use a map() function, it simplifies the bus accessor conversion.

And "cpu_ram_map" seems like the memory is accessed through cpu context,
while it is really always device context.

Yes, but that's a separate effort. In fact, see http://wiki.qemu.org/Features/RamAPI vs. http://wiki.qemu.org/Features/PCIMemoryAPI

Regards,

Anthony Liguori




reply via email to

[Prev in Thread] Current Thread [Next in Thread]