qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Andrew Jones" <drjones@redhat.com>,
	"Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
	"Marc Zyngier" <marc.zyngier@arm.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Jérémy Fanguède" <j.fanguede@virtualopensystems.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"Christoffer Dall" <christoffer.dall@linaro.org>,
	"Mario Smarduch" <m.smarduch@samsung.com>
Subject: Re: [Qemu-devel] [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED
Date: Thu, 14 May 2015 16:19:23 +0200	[thread overview]
Message-ID: <5554AEEB.6040401@redhat.com> (raw)
In-Reply-To: <20150514154327-mutt-send-email-mst@redhat.com>

On 05/14/15 15:48, Michael S. Tsirkin wrote:
> On Thu, May 14, 2015 at 03:32:10PM +0200, Laszlo Ersek wrote:
>> On 05/14/15 15:00, Andrew Jones wrote:
>>> On Thu, May 14, 2015 at 01:38:11PM +0100, Peter Maydell wrote:
>>>> On 14 May 2015 at 13:28, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>>> Well, PCI BARs are generally MMIO resources, and hence should not be cached.
>>>>>
>>>>> As an optimization, OS drivers can mark them as cacheable or
>>>>> write-combining or something like that, but in general it's a safe
>>>>> default to leave them uncached---one would think.
>>>>
>>>> Isn't this handled by the OS mapping them in the 'prefetchable'
>>>> MMIO window rather than the 'non-prefetchable' one? (QEMU's
>>>> generic-PCIe device doesn't yet support the prefetchable window.)
>>>
>>> I was thinking (with my limited PCI knowledge) the same thing, and
>>> was planning on experimenting with that.
>>
>> This could be supported in UEFI as well, with the following steps:
>> - the DTB that QEMU provides UEFI with should advertise such a
>>   prefetchable window.
>> - The driver in UEFI that parses the DTB should understand that DTB
>>   node (well, record type), and store the appropriate base & size into
>>   some new dynamic PCDs (= basically, firmware wide global variables;
>>   PCD = platform configuration database)
>> - The entry point of the host bridge driver would call
>>   gDS->AddMemorySpace() twice, separately for the two different windows,
>>   with their appropriate caching attributes.
>> - The host bridge driver needs to be extended so that TypePMem32
>>   requests are not rejected (like now); they should be handled
>>   similarly to TypeMem32. Except, the gDS->AllocateMemorySpace() call
>>   should allocate from the prefetchable range (determined by the new
>>   PCDs above).
>> - QEMU's emulated devices should then expose their BARs as prefetchable
>>   (so that the above branch would be taken in the host bridge driver).
>>
>> (Of course, if QEMU intends to emulate PCI devices somewhat
>> realistically, then QEMU should claim "non-prefetchable" for BARs that
>> would not be prefetchable on physical hardware either, and then the
>> hypervisor should accommodate the firmware's UC mapping and say "hey I
>> know better, we're virtual in fact", and override the attribute (-> use
>> WB instead of UC). With which we'd be back to square one...)
>>
>> Thanks
>> Laszlo
> 
> Prefetcheable is unrelated to BAR caching or drivers, it's a way to tell
> host bridges they can do limited tweaks to downstream transactions in a
> specific range.
> 
> Really non-prefetcheable BARs are mostly those where read has
> side-effects, which is best avoided. this does not mean it's ok to
> reorder transactions or cache them.

I believe I understood that (although certainly not in the depth that
you do), because when the idea had come up first (ie. equating cacheable
with prefetchable, or at least "repurposing" the latter for the former)
I had tried to read up on prefetchable (just on the web; no time for
reading the PCI spec. ... I peeked now, it also mentions "write merging"
for bridges.) The way I perceived it, the idea was to give the guest a
hint about caching with the prefetchable bit / DTB entry. Sorry if I was
mistaken.

Thanks
Laszlo

  reply	other threads:[~2015-05-14 14:19 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 11:31 [Qemu-devel] [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Andrew Jones
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 1/3] arm/arm64: pageattr: add set_memory_nc Andrew Jones
2015-05-14 11:05   ` Christoffer Dall
2015-05-14 13:46     ` Andrew Jones
2015-05-15 14:51       ` Christoffer Dall
2015-05-18 15:53       ` Catalin Marinas
2015-05-19 10:03         ` Andrew Jones
2015-05-19 11:18           ` Catalin Marinas
2015-05-19 11:38             ` Andrew Jones
2015-05-20 10:01             ` Christoffer Dall
2015-05-20 11:24               ` Catalin Marinas
2015-05-23  1:08         ` Mario Smarduch
2015-05-25 17:11           ` Andrew Jones
2015-05-27  1:08             ` Mario Smarduch
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 2/3] KVM: promote KVM_MEMSLOT_INCOHERENT to uapi Andrew Jones
2015-05-14 10:12   ` Paolo Bonzini
2015-05-14 10:34   ` Christoffer Dall
2015-05-13 11:31 ` [Qemu-devel] [RFC/RFT PATCH v2 3/3] arm/arm64: KVM: implement 'uncached' mem coherency Andrew Jones
2015-05-14 10:55   ` Christoffer Dall
2015-05-14 13:32     ` Andrew Jones
2015-05-15 15:02       ` Christoffer Dall
2015-05-15 17:04         ` Andrew Jones
2015-05-15 20:16           ` Jérémy Fanguède
2015-05-21  2:29           ` Mario Smarduch
2015-05-21 16:50             ` Andrew Jones
2015-05-14 10:30 ` [Qemu-devel] [RFC/RFT PATCH v2 0/3] KVM: Introduce KVM_MEM_UNCACHED Christoffer Dall
2015-05-14 11:09   ` Laszlo Ersek
2015-05-14 11:29     ` Christoffer Dall
2015-05-14 11:31       ` Paolo Bonzini
2015-05-14 11:36         ` Christoffer Dall
2015-05-14 11:38           ` Paolo Bonzini
2015-05-14 12:00             ` Christoffer Dall
2015-05-14 12:08               ` Paolo Bonzini
2015-05-14 12:24                 ` Christoffer Dall
2015-05-14 12:28                   ` Paolo Bonzini
2015-05-14 12:34                     ` Christoffer Dall
2015-05-14 13:01                       ` Laszlo Ersek
2015-05-14 12:38                     ` Peter Maydell
2015-05-14 13:00                       ` Andrew Jones
2015-05-14 13:32                         ` Laszlo Ersek
2015-05-14 13:48                           ` Michael S. Tsirkin
2015-05-14 14:19                             ` Laszlo Ersek [this message]
2015-05-14 14:41                               ` Michael S. Tsirkin
2015-05-15  9:00                                 ` Ard Biesheuvel
2015-05-14 10:31 ` Andrew Jones
2015-05-14 10:37   ` Peter Maydell
2015-05-14 13:03     ` Andrew Jones
2015-05-14 13:11       ` Peter Maydell
2015-05-14 13:33         ` Laszlo Ersek
2015-05-14 13:36         ` Andrew Jones
2015-05-15 15:09           ` 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=5554AEEB.6040401@redhat.com \
    --to=lersek@redhat.com \
    --cc=agraf@suse.de \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=j.fanguede@virtualopensystems.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=m.smarduch@samsung.com \
    --cc=marc.zyngier@arm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).