From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v6 00/15] Nested EPT Date: Sun, 04 Aug 2013 18:42:09 +0200 Message-ID: <51FE8461.3080402@web.de> References: <1375366117-9014-1-git-send-email-gleb@redhat.com> <51FE1DD9.80904@web.de> <20130804093205.GJ6042@redhat.com> <20130804095355.GK6042@redhat.com> <20130804134435.GR6042@redhat.com> <51FE6FCF.6000109@web.de> <51FA88A2-ED4D-4FB7-AE12-59F88F2956C5@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bwP6JXDigRv0i2FBDdn8CgrTPfEUqKaBI" Cc: Gleb Natapov , kvm@vger.kernel.org, Xiao Guangrong , Jun Nakajima , Yang Zhang , pbonzini@redhat.com To: Xiao Guangrong Return-path: Received: from mout.web.de ([212.227.17.11]:55379 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753552Ab3HDQmR (ORCPT ); Sun, 4 Aug 2013 12:42:17 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MWS3S-1UYbWP1wEs-00XYHx for ; Sun, 04 Aug 2013 18:42:16 +0200 In-Reply-To: <51FA88A2-ED4D-4FB7-AE12-59F88F2956C5@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bwP6JXDigRv0i2FBDdn8CgrTPfEUqKaBI Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-08-04 18:15, Xiao Guangrong wrote: >=20 > On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: >=20 >> On 2013-08-04 15:44, Gleb Natapov wrote: >>> On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: >>>> On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: >>>>> On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: >>>>>> On 2013-08-01 16:08, Gleb Natapov wrote: >>>>>>> Another day -- another version of the nested EPT patches. In this= version >>>>>>> included fix for need_remote_flush() with shadowed ept, set bits = 6:8 >>>>>>> of exit_qualification during ept_violation, update_permission_bit= mask() >>>>>>> made to work with shadowed ept pages and other small adjustment a= ccording >>>>>>> to review comments. >>>>>> >>>>>> Was just testing it here and ran into a bug: I've L2 accessing the= HPET >>>>>> MMIO region that my L1 passed through from L0 (where it is suppose= d to >>>>>> be emulated in this setup). This used to work with an older postin= g of >>>>> Not sure I understand your setup. L0 emulates HPET, L1 passes it th= rough >>>>> to L2 (mmaps it and creates kvm slot that points to it) and when L2= >>>>> accessed it it locks up? >>>>> >>>>>> Jun, but now it locks up (infinite loop over L2's MMIO access, no = L2->L1 >>>>>> transition). Any ideas where to look for debugging this? >>>>>> >>>>> Can you do an ftrace -e kvm -e kvmmmu? Unit test will also be helpf= ul :) >>>>> >>>> I did an MMIO access from nested guest in the vmx unit test (which i= s >>>> naturally passed through to L0 since L1 is so simple) and I can see = that >>>> the access hits L0. >>>> >>> But then unit test not yet uses nested EPT :) >> >> Indeed, that's what I was about to notice as well. EPT test cases are = on >> Arthur's list, but I suggested to start easier with some MSR switches >> (just to let him run into KVM's PAT bugs ;) ). >> >> Anyway, here are the traces: >> >> qemu-system-x86-11521 [000] 4724.170191: kvm_entry: vcpu 0= >> qemu-system-x86-11521 [000] 4724.170192: kvm_exit: reason= EPT_VIOLATION rip 0xffffffff8102ab70 info 181 0 >> qemu-system-x86-11521 [000] 4724.170192: kvm_page_fault: addres= s 1901978 error_code 181 >> qemu-system-x86-11521 [000] 4724.170193: kvm_mmu_pagetable_walk: addr= 1901978 pferr 0=20 >> qemu-system-x86-11521 [000] 4724.170193: kvm_mmu_paging_element: pte = 3c04c007 level 4 >> qemu-system-x86-11521 [000] 4724.170193: kvm_mmu_paging_element: pte = 3c04d007 level 3 >> qemu-system-x86-11521 [000] 4724.170193: kvm_mmu_paging_element: pte = 3c05a007 level 2 >> qemu-system-x86-11521 [000] 4724.170193: kvm_mmu_paging_element: pte = 1901037 level 1 >> qemu-system-x86-11521 [000] 4724.170197: kvm_entry: vcpu 0= >> qemu-system-x86-11521 [000] 4724.170198: kvm_exit: reason= EPT_VIOLATION rip 0xffffffff8102ab77 info 81 0 >> qemu-system-x86-11521 [000] 4724.170199: kvm_page_fault: addres= s 3a029000 error_code 81 >> qemu-system-x86-11521 [000] 4724.170199: kvm_mmu_pagetable_walk: addr= 3a029000 pferr 0=20 >> qemu-system-x86-11521 [000] 4724.170199: kvm_mmu_paging_element: pte = 3c04c007 level 4 >> qemu-system-x86-11521 [000] 4724.170199: kvm_mmu_paging_element: pte = 3c04d007 level 3 >> qemu-system-x86-11521 [000] 4724.170199: kvm_mmu_paging_element: pte = 3c21e007 level 2 >> qemu-system-x86-11521 [000] 4724.170200: kvm_mmu_paging_element: pte = 3a029037 level 1 >> qemu-system-x86-11521 [000] 4724.170203: kvm_entry: vcpu 0= >> qemu-system-x86-11521 [000] 4724.170204: kvm_exit: reason= EPT_VIOLATION rip 0xffffffff8102ab77 info 181 0 >> qemu-system-x86-11521 [000] 4724.170204: kvm_page_fault: addres= s fed000f0 error_code 181 >> qemu-system-x86-11521 [000] 4724.170205: kvm_mmu_pagetable_walk: addr= fed000f0 pferr 0=20 >> qemu-system-x86-11521 [000] 4724.170205: kvm_mmu_paging_element: pte = 3c04c007 level 4 >> qemu-system-x86-11521 [000] 4724.170205: kvm_mmu_paging_element: pte = 3c42f003 level 3 >> qemu-system-x86-11521 [000] 4724.170205: kvm_mmu_paging_element: pte = 3c626003 level 2 >> qemu-system-x86-11521 [000] 4724.170206: kvm_mmu_paging_element: pte = fed00033 level 1 >> qemu-system-x86-11521 [000] 4724.170213: mark_mmio_spte: sptep:= 0xffff88014e8ad800 gfn fed00 access 6 gen b7f >> qemu-system-x86-11521 [000] 4724.170214: kvm_mmu_pagetable_walk: addr= ffffffff8102ab77 pferr 10 F >> qemu-system-x86-11521 [000] 4724.170215: kvm_mmu_pagetable_walk: addr= 1710000 pferr 6 W|U >> qemu-system-x86-11521 [000] 4724.170215: kvm_mmu_paging_element: pte = 3c04c007 level 4 >> qemu-system-x86-11521 [000] 4724.170215: kvm_mmu_paging_element: pte = 3c04d007 level 3 >> qemu-system-x86-11521 [000] 4724.170216: kvm_mmu_paging_element: pte = 3c059007 level 2 >> qemu-system-x86-11521 [000] 4724.170216: kvm_mmu_paging_element: pte = 1710037 level 1 >> qemu-system-x86-11521 [000] 4724.170216: kvm_mmu_paging_element: pte = 1711067 level 4 >> qemu-system-x86-11521 [000] 4724.170216: kvm_mmu_walker_error: pferr = 19 P|RSVD|F >=20 > I guess the bug is here, could you please change this code to: >=20 > - if (unlikely(is_rsvd_bits_set(&vcpu->arch.mmu, pte, > + if (unlikely(is_rsvd_bits_set(mmu, pte, > walker->level))) { >=20 > ( > In static int FNAME(walk_addr_generic)(struct guest_walker *walker, > struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, > gva_t addr, u32 access) > ) >=20 > and try again? >=20 Thanks, that fixed the bug! Obviously, previous version were less strict or imprecise with reserved bit checking as this pattern exists in the version that worked here as we= ll. Jan --bwP6JXDigRv0i2FBDdn8CgrTPfEUqKaBI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlH+hGQACgkQitSsb3rl5xTuzwCePHelzADfa22rCZtAScoN+7qH wp0An1SiB66Ao0kA0eyF8RxRaouRhbLm =ixYA -----END PGP SIGNATURE----- --bwP6JXDigRv0i2FBDdn8CgrTPfEUqKaBI--