From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: guest assigned device MMIO maps with WC: does this work correctly? Date: Wed, 20 Nov 2013 21:58:15 +0200 Message-ID: <20131120195815.GA11239@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: kvm@vger.kernel.org, gleb@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:13347 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754868Ab3KTTzG (ORCPT ); Wed, 20 Nov 2013 14:55:06 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAKJt6cd004481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Nov 2013 14:55:06 -0500 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: I see this in kvm: static u64 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) { u64 ret; /* For VT-d and EPT combination * 1. MMIO: always map as UC * 2. EPT with VT-d: * a. VT-d without snooping control feature: can't guarantee * the * result, try to trust guest. * b. VT-d with snooping control feature: snooping control * feature of * VT-d engine can guarantee the cache correctness. Just * set it * to WB to keep consistent with host. So the same as item * 3. * 3. EPT without VT-d: always map as WB and set IPAT=1 to keep * consistent with host MTRR */ if (is_mmio) ret = MTRR_TYPE_UNCACHABLE << VMX_EPT_MT_EPTE_SHIFT; ... } does this mean that even if guest maps BAR for an assigned device as write combined (or configures such using an MTRR), host will override this and use uncacheable in practice? I think there are some drivers that map MMIO as write-combined for performance (but don't have such hardware) so I'd like to figure out from code whether this will work correctly. -- MST