From: Christoffer Dall <christoffer.dall@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
Claudio Fontana <claudio.fontana@huawei.com>,
Jan Kiszka <jan.kiszka@web.de>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
arm-mail-list <linux-arm-kernel@lists.infradead.org>,
kvm-devel <kvm@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH] KVM: arm/arm64: Don't let userspace update CNTVOFF once guest is running
Date: Thu, 9 Jul 2015 18:06:31 +0200 [thread overview]
Message-ID: <20150709160631.GA25650@cbox> (raw)
In-Reply-To: <CAFEAcA81LRcRu1r+H-6T_yT-AQ4XLAzX1osAWZYNPEDHSTiAQg@mail.gmail.com>
On Thu, Jul 09, 2015 at 03:26:20PM +0100, Peter Maydell wrote:
> On 9 July 2015 at 15:17, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> > On Thu, Jul 09, 2015 at 02:24:06PM +0200, Christoffer Dall wrote:
> > So I ran this through GDB, and this happens when the guest probes the
> > virtio devices, specifically the backtrace tells me that
> >
> > virtio_current_cpu_endian () at /root/src/qemu/hw/virtio/virtio.c:594
> > => cc->virtio_is_big_endian
> > -> arm_cpu_is_big_endian
> > -> cpu_synchronize_state
> > -> kvm_cpu_synchronize_state
> >
> > which causes cpu->kvm_vcpu_dirty = true, which causes the run-loop to
> > write the CNTVOFF on a per-vcpu basis without stopping anything, as far
> > as I can tell.
>
> Ah, I was wondering if it was going to turn out to be this,
> but I hadn't figured out why it was going to cause us to do
> a write-back of state rather than just a read.
>
> > So yeah, I guess the only required fix here is to fix QEMU in some way
> > as to not fiddle with the timer registers in this way, and then I
> > honestly don't know if we should try to fix legacy userspace in the
> > kernel, but based on the feedback from Jan, I suppose not.
>
> arm_cpu_is_big_endian() doesn't actually want to write
> back any state -- all it's interested in is reading.
> So we really ought not to need to write anything back there.
> kvm-all.c's sync functions don't seem to provide a "sync
> kernel state to userspace but I promise I'm not going to
> dirty it" function though. I guess we could add one.
>
> (Overall it's kind of fragile even if we can avoid this
> specific case where we're writing back the counter state,
> though -- we should probably think about the sync level
> stuff as well.)
Sounds to me like we should add the sync level stuff first, as it should
catch all callers, and afterwards consider adding the sync-one-way
optimization.
-Christoffer
next prev parent reply other threads:[~2015-07-09 16:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 14:54 [RFC PATCH] KVM: arm/arm64: Don't let userspace update CNTVOFF once guest is running Marc Zyngier
2015-06-25 8:04 ` Christoffer Dall
2015-06-25 8:48 ` Marc Zyngier
2015-06-25 8:59 ` Claudio Fontana
2015-06-25 9:10 ` Peter Maydell
2015-06-25 9:25 ` Claudio Fontana
2015-06-26 4:49 ` Jan Kiszka
2015-06-29 17:20 ` Claudio Fontana
2015-06-29 17:37 ` Peter Maydell
2015-07-08 15:56 ` Marc Zyngier
2015-07-08 16:06 ` Peter Maydell
2015-07-08 16:37 ` Marc Zyngier
2015-07-08 19:13 ` Peter Maydell
2015-07-09 10:22 ` Christoffer Dall
2015-07-09 10:38 ` Peter Maydell
2015-07-09 12:05 ` Christoffer Dall
2015-07-09 12:07 ` Peter Maydell
2015-07-09 12:24 ` Christoffer Dall
2015-07-09 14:17 ` Christoffer Dall
2015-07-09 14:26 ` Peter Maydell
2015-07-09 16:06 ` Christoffer Dall [this message]
2015-07-09 10:40 ` Jan Kiszka
2015-07-09 12:08 ` Christoffer Dall
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=20150709160631.GA25650@cbox \
--to=christoffer.dall@linaro.org \
--cc=claudio.fontana@huawei.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).