From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm <kvm@vger.kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Carsten Otte <cotte@de.ibm.com>
Subject: Re: [PATCH 1/6] kvm-s390: Fix memory slot versus run
Date: Tue, 12 May 2009 15:33:23 +0200 [thread overview]
Message-ID: <4A097AA3.8000007@linux.vnet.ibm.com> (raw)
In-Reply-To: <4A095EEA.60902@redhat.com>
Avi Kivity wrote:
> Christian Ehrhardt wrote:
>> Avi Kivity wrote:
>>> Christian Ehrhardt wrote:
>>>>
>>>> The bad thing on vcpu->request in that case is that I don't want
>>>> the async behaviour of vcpu->requests in that case, I want the
>>>> memory slot updated in all vcpu's when the ioctl is returning.
>>>
>>> You mean, the hardware can access the vcpu control block even when
>>> the vcpu is not running?
>> No, hardware only uses it with a running vcpu, but I realised my own
>> fault while changing the code to vcpu->request style.
>> For s390 I need to update the KVM->arch and *all*
>> vcpu->arch->sie_block... data synchronously.
>
> Out of interest, can you explain why?
Sure I'll try to give an example.
a) The whole guest has "one" memory slot representing all it's memory.
Therefore some important values like guest_origin and guest_memsize (one
slot so it's just addr+size) are kept at VM level in kvm->arch.
b) We fortunately have cool hardware support for "nearly everything"(tm)
:-) In this case for example we set in vcpu->arch.sie_block the values
for origin and size translated into a "limit" to get memory management
virtualization support.
c) we have other code e.g. all our copy_from/to_guest stuff that uses
the kvm->arch values
If we would allow e.g. updates of a memslot (or as the patch supposes to
harden the set_memory_region code against inconsiderate code changes in
other sections) it might happen that we set the kvm->arch information
but the vcpu->arch->sie_block stuff not until next reentry. Now
concurrently the running vcpu could cause some kind of fault that
involves a copy_from/to_guest. That way we could end up with potentially
invalid handling of that fault (fault handling and running guest would
use different userspace adresses until it is synced on next vcpu
reentry) - it's theoretical I know, but it might cause some issues that
would be hard to find.
On the other hand for the long term I wanted to note that all our
copy_from/to_guest functions is per vcpu, so when we some day implement
updateable memslots, multiple memslots or even just fill "free time"(tm)
and streamline our code we could redesign that origin/size storage. This
could be done multiple ways, either just store it per vcpu or with a
lock for the kvm->arch level variables - both ways and maybe more could
then use the vcpu->request based approach, but unfortunately it's
neither part of that patch nor of the current effort to do that.
The really good thing is, because of our discussion about that I now
have a really detailed idea how I can improve that code aside from this
bugfix patch (lets hope not too far in the future).
>> That makes the "per vcpu resync on next entry" approach not feasible.
>>
>> On the other hand I realized at the same moment that the livelock
>> should be no issue for us, because as I mentioned:
>> a) only one memslot
>> b) a vcpu can't run without memslot
>> So I don't even need to kick out vcpu's, they just should not be
>> running.
>> Until we ever support multiple slots, or updates of the existing
>> single slot this should be ok, so is the bugfix patch this should be.
>> To avoid a theoretical deadlock in case other code is changing
>> (badly) it should be fair to aquire the lock with mutex_trylock and
>> return -EINVAL if we did not get all locks.
>
> OK.
>
>
--
Grüsse / regards,
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization
next prev parent reply other threads:[~2009-05-12 13:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-05 14:39 [PATCH 0/6] kvm-s390: collection of kvm-s390 fixes ehrhardt
2009-05-05 14:39 ` [PATCH 1/6] kvm-s390: Fix memory slot versus run ehrhardt
2009-05-06 12:01 ` Avi Kivity
2009-05-11 13:00 ` Christian Ehrhardt
2009-05-11 13:15 ` Avi Kivity
2009-05-11 13:46 ` Christian Ehrhardt
2009-05-11 14:02 ` Avi Kivity
2009-05-11 14:42 ` Christian Ehrhardt
2009-05-11 15:01 ` Avi Kivity
2009-05-12 9:15 ` Christian Ehrhardt
2009-05-12 11:35 ` Avi Kivity
2009-05-12 13:33 ` Christian Ehrhardt [this message]
2009-05-17 22:31 ` Avi Kivity
2009-05-20 12:05 ` Christian Ehrhardt
2009-05-05 14:39 ` [PATCH 2/6] kvm-s390: use hrtimer for clock wakeup from idle ehrhardt
2009-05-06 12:10 ` Avi Kivity
2009-05-06 12:36 ` Christian Borntraeger
2009-05-07 10:19 ` Avi Kivity
2009-05-07 10:34 ` Christian Borntraeger
2009-05-20 15:48 ` Hollis Blanchard
2009-05-05 14:39 ` [PATCH 3/6] kvm-s390: optimize float int lock: spin_lock_bh --> spin_lock ehrhardt
2009-05-05 14:39 ` [PATCH 4/6] kvm-s390: Unlink vcpu on destroy ehrhardt
2009-05-06 12:11 ` Avi Kivity
2009-05-11 13:00 ` Christian Ehrhardt
2009-05-05 14:39 ` [PATCH 5/6] kvm-s390: Sanity check on validity intercept ehrhardt
2009-05-05 14:39 ` [PATCH 6/6] kvm-s390: Verify memory in kvm run ehrhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A097AA3.8000007@linux.vnet.ibm.com \
--to=ehrhardt@linux.vnet.ibm.com \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.