kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Jan Kiszka" <jan.kiszka@siemens.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Joel Schopp <joel.schopp@amd.com>
Subject: Re: [RFC][PATCH] KVM: SVM: Sync g_pat with guest-written PAT value
Date: Tue, 21 Apr 2015 14:11:02 +0200	[thread overview]
Message-ID: <55363E56.1020100@redhat.com> (raw)
In-Reply-To: <55354871.5030208@siemens.com>



On 20/04/2015 20:41, Jan Kiszka wrote:
> If the guest pushes data for DMA into RAM, it may assume that it lands
> there directly, without the need for explicit flushes, because it has
> caching disabled - no?

Yes, but Intel IOMMUs can have snooping control and in this case you can
just set memory to WB.

On Intel, KVM trusts the guest's PAT if the IOMMU is in use, and you do
not have an Intel IOMMU with snooping control.  In this case
kvm_arch_has_noncoherent_dma(vcpu->kvm) returns true.

The same should work for AMD, so you can set the gPAT:

- to the guest's value if kvm_arch_has_noncoherent_dma(vcpu->kvm), and
then you return cachemode2protval(kvm_get_guest_memory_type(...)) from
svm_get_mt_mask to layer the guest MTRRs on top of the guest PAT.

- otherwise, to all WB (0x0606060606060606), and then you can return
either 0 or _PAGE_NOCACHE from svm_get_mt_mask to achieve either UC (for
MMIO regions) or WB (for everything else).

To sum up you have:

               IOMMU?                      no IOMMU?
guest PAT      obeyed                      ignored (all WB)
guest MTRR     obeyed (svm_get_mt_mask)    ignored (UC if MMIO, else WB)
host PAT       always ignored              always ignored
host MTRR      always obeyed               always obeyed

I think that kvm_arch_has_noncoherent_dma() can be resampled, and gPAT
updated, in wbinvd_interception.

Paolo

  parent reply	other threads:[~2015-04-21 12:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13  5:16 KVM: How does is PAT emulation supposed to work? Jan Kiszka
2015-04-13  6:58 ` [RFC][PATCH] KVM: SVM: Sync g_pat with guest-written PAT value Jan Kiszka
2015-04-17 16:59   ` Radim Krčmář
2015-04-20 16:14   ` Radim Krčmář
2015-04-20 17:16     ` Radim Krčmář
2015-04-20 17:21       ` Jan Kiszka
2015-04-20 17:33         ` Radim Krčmář
2015-04-20 17:37           ` Jan Kiszka
2015-04-20 17:45             ` Jan Kiszka
2015-04-20 18:33               ` Radim Krčmář
2015-04-20 18:41                 ` Jan Kiszka
2015-04-21 12:10                   ` Radim Krčmář
2015-04-21 12:11                   ` Paolo Bonzini [this message]
2015-04-20 17:22       ` Radim Krčmář
2015-04-20 17:25     ` [PATCH v2] " Jan Kiszka
2015-04-20 17:35       ` Radim Krčmář
2015-04-21 11:09       ` Paolo Bonzini
2015-04-21 11:25         ` Jan Kiszka
2015-04-21 11:32           ` Paolo Bonzini
2015-04-21 11:56             ` Jan Kiszka
2015-04-21 12:12               ` Paolo Bonzini
2015-04-21 12:21         ` Radim Krčmář
2015-05-24 15:28           ` Jan Kiszka
2016-02-09 19:25             ` Jan Kiszka
2015-04-17 16:43 ` KVM: How does is PAT emulation supposed to work? Radim Krčmář
2015-04-17 17:12   ` Jan Kiszka
2015-04-17 20:28     ` Radim Krčmář

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=55363E56.1020100@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=joel.schopp@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    /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).