Re: [PATCH/RFC 2/2] s390 virtualization interface.

Carsten Otte
2007-04-27T15:45:40Z

Anthony Liguori wrote:
> Can you provide a high-level description of how this virtualization
> mechanism works?
Very well. First of all, userspace allocates regular memory via
malloc() or mmap()s a file. The user address space will equals the
virtual machines address space, user space can define an address
offset where the virtual machine starts and can define a maximum size
of the virtual machine. Both is set in each of the SIE control blocks.
Userspace uses open/read/close to read a kernel image into its proper
location.

Next, userspace launches a set of pthreads. Each pthread corresponds
with a virtual CPU, and each pthread calls the sys_s390host_add_cpu
system call.
Now the first CPU enters sys_sie to start interpretive execution via
sys_s3900host_sie. The CPU will run the virtual cpu context for a
while and exit again with an intercept code that indicates the reason
for the exit. Now userspace deals with that, and enters
sys_s390host_sie again. Later on, all other CPUs get started via an
interprocessor signal SIGP. Userspace will also receive this as SIE
intercept. Now all pthreads representing the different virtual CPUs
will enter the virtual machine context simultaneously.
Interprocessor signals (need_resched and such) are handled by the
hardware as long as the sender and receiver are both in virtual
context. Otherwise, userspace will get control again.

In the end, when the machine is halted (or panics), all CPUs will
return with an intercept code indicating that execution has ended for
this CPU. Userspace will now call sys_s390host_remove_cpu to free
things up, then userspace will exit().

> How does MMU virtualization work?
s390 does have hardware support for memory management for virutalized
environments. The first patch of this series introduces an extension
to the page table entry, that tracks dirty/reference bits for host and
virtual machine seperately. For the guest, our CPU does transparently
merge the real dirty and reference bits stored in a storage key and in
the page table entry extension. The virutal machine can set up its
own page tables inside the box and use dynamic address translation.
This does not require intervention by the host, except that it needs
to do its part of dirty and reference tracking in the extended page
table entry explicitly.

cheers,
Carsten