Re: [patch] kvm: make cr3 loading more robust

Avi Kivity
2007-01-04T08:58:36Z

Ingo Molnar wrote:
> another small detail is that currently KVM_SET_MEMORY_REGION appears to
> be an add-only interface - it is not possible to 'unregister' RAM from a
> VM.
>

Well, the _interface_ supports removing, the implementation does not :)

Everything was written in mind to allow memory hotplug.

> That keeps things easy for now, but if it's ever implemented then the
> current cr3 of all vcpus of the VM needs to be validated against the
> reduced memory slot map. (besides migrating all existing mappings from
> the removed memory slot to other memory slots and redirecting all
> in-flight DMA transactions, etc., etc. Which all needs heavy guest-OS
> awareness as well.)
>

Actually I think it's quite easy:

- halt all vcpus
- wait for dma to complete
- mmu_free_roots()
- zap all page tables
- actually unplug memory
- mmu_alloc_roots()

The guest needs to cooperate, but it can do so using the native memory
hotlpug mechanisms (whatever they are). No guest modifications are needed.