Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754720AbbEKPQX (ORCPT ); Mon, 11 May 2015 11:16:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43092 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103AbbEKPQV (ORCPT ); Mon, 11 May 2015 11:16:21 -0400 Message-ID: <5550C7BD.5020400@redhat.com> Date: Mon, 11 May 2015 17:16:13 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Xiao Guangrong CC: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: MMU: document smap_andnot_wp References: <1431356122-8500-1-git-send-email-guangrong.xiao@linux.intel.com> <1431356122-8500-2-git-send-email-guangrong.xiao@linux.intel.com> In-Reply-To: <1431356122-8500-2-git-send-email-guangrong.xiao@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2615 Lines: 56 On 11/05/2015 16:55, Xiao Guangrong wrote: > Document this new role field > > Signed-off-by: Xiao Guangrong > --- > Documentation/virtual/kvm/mmu.txt | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/Documentation/virtual/kvm/mmu.txt b/Documentation/virtual/kvm/mmu.txt > index 53838d9..c59bd9b 100644 > --- a/Documentation/virtual/kvm/mmu.txt > +++ b/Documentation/virtual/kvm/mmu.txt > @@ -169,6 +169,10 @@ Shadow pages contain the following information: > Contains the value of cr4.smep && !cr0.wp for which the page is valid > (pages for which this is true are different from other pages; see the > treatment of cr0.wp=0 below). > + role.smap_andnot_wp: > + Contains the value of cr4.smap && !cr0.wp for which the page is valid > + (pages for which this is true are different from other pages; see the > + treatment of cr0.wp=0 below). > gfn: > Either the guest page table containing the translations shadowed by this > page, or the base page frame for linear translations. See role.direct. > @@ -344,10 +348,16 @@ on fault type: > > (user write faults generate a #PF) > > -In the first case there is an additional complication if CR4.SMEP is > -enabled: since we've turned the page into a kernel page, the kernel may now > -execute it. We handle this by also setting spte.nx. If we get a user > -fetch or read fault, we'll change spte.u=1 and spte.nx=gpte.nx back. > +In the first case there are two additional complications: > +- if CR4.SMEP is enabled: since we've turned the page into a kernel page, > + the kernel may now execute it. We handle this by also setting spte.nx. > + If we get a user fetch or read fault, we'll change spte.u=1 and > + spte.nx=gpte.nx back. > +- if CR4.SMAP is disabled: since the page has been changed to a kernel > + page, it can not be reused when CR4.SMAP is enabled. We set > + CR4.SMAP && !CR0.WP into shadow page's role to avoid this case. Note, > + here we do not care the case that CR4.SMAP is enabled since KVM will > + directly inject #PF to guest due to failed permission check. > > To prevent an spte that was converted into a kernel page with cr0.wp=0 > from being written by the kernel after cr0.wp has changed to 1, we make > Thanks, squashed with 1/2 and both applied. Paolo -- 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/