Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964880AbbHDNXH (ORCPT ); Tue, 4 Aug 2015 09:23:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52537 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933972AbbHDNXE (ORCPT ); Tue, 4 Aug 2015 09:23:04 -0400 Subject: Re: [PATCH 6/9] KVM: MMU: introduce the framework to check reserved bits on sptes To: Xiao Guangrong References: <1438685961-8107-1-git-send-email-guangrong.xiao@linux.intel.com> <1438685961-8107-7-git-send-email-guangrong.xiao@linux.intel.com> <55C0AC9C.6070606@redhat.com> <55C0B9B1.9070504@linux.intel.com> Cc: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org From: Paolo Bonzini Message-ID: <55C0BCB4.3020601@redhat.com> Date: Tue, 4 Aug 2015 15:23:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55C0B9B1.9070504@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1827 Lines: 53 On 04/08/2015 15:10, Xiao Guangrong wrote: >> >> This should be cpu_has_nx, I think. > > cpu_has_nx() checks the feature on host CPU, however, this is the shadow > page table which completely follow guest's features. > > E.g, if guest does not execution-protect the physical page, then > KVM does not do it either. That's just true for current code. In principle you could add a memslot flag for KVM_MEMSLOT_NO_EXECUTE, then NX would be true on an spte but not on a PTE. >> >>> + guest_cpuid_has_gbpages(vcpu), >> >> This should be cpu_has_gbpages. > > E.g, if guest does not use 1G page size, it's also not used in shadow page > table. However, bit 7 in the shadow PDPTE is not reserved. If you're not testing "is this bit reserved" but rather "should this bit be always zero" in the SPTE, then checking guest_cpuid is okay. But in that case shadow_rsvd_check is really more like shadow_always_zero_check. >> >>> is_pse(vcpu)); >> >> This should be cpu_has_pse. > > E.g, guest does no use 4M page size, then KVM does not use it either. Right, it should always be true, not cpu_has_pse, because PAE and 64-bit page tables always support huge (2M) pages. Or as above, if you're testing "should this bit be always zero" then it's a different story. Paolo > BTW, cpu_pse only hurts 32 bit page table which is not used by shadow > page table (32 PAE and 64 Long mode are used in shadow page). > > Only tdp only follows host CPU's features, KVM does not use NX to > protect the page, so i always mark it as false in > reset_tdp_shadow_rsvds_bits_mask(). -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/