From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: KVM: How does is PAT emulation supposed to work? Date: Fri, 17 Apr 2015 18:43:14 +0200 Message-ID: <20150417164310.GA3419@potion.brq.redhat.com> References: <552B5128.4010909@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58797 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932703AbbDQQnW (ORCPT ); Fri, 17 Apr 2015 12:43:22 -0400 Content-Disposition: inline In-Reply-To: <552B5128.4010909@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: 2015-04-13 07:16+0200, Jan Kiszka: > Hi all, > > while digging into the PAT topic for Jailhouse, I also wondered how KVM > deals with it. And I'm still not getting it complete - or there is a bug: > > KVM intercepts all guest writes to the PAT MSR and instead keeps the > guest value in vcpu->arch.pat. But, besides returning that value back on > read accesses, arch.pat has no other purpose. > > On Intel, we only seem to have proper emulation - through hardware - > when VMX supports PAT switching (see vmx_set_msr). On AMD, the situation > is even worse as the g_pat save field is not updated at all on PAT > writes. That seems to be a low hanging fruit to bring svm on the same > support level as vmx. > > Or am I missing something? I don't think so, it looks buggy ... we could switch PAT manually, if it isn't accelerated by hardware. > PS: If someone has a good idea for a simple test case on machines > without IOMMU (like my current boxes), thus without a chance to use > device pass-through to stress guest PAT settings, I would be all ears. Not a good one: KVM sets VMX_EPT_IPAT_BIT for RAM unless kvm_arch_has_noncoherent_dma(). You can comment the line in vmx_get_mt_mask(), or call kvm_arch_register_noncoherent_dma(), for guest PAT to work on normal memory.