From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 3/4] KVM: Add SMAP support when setting CR4 Date: Fri, 28 Mar 2014 07:23:00 +0100 Message-ID: <53351544.2060403@redhat.com> References: <1395923135-15329-1-git-send-email-feng.wu@intel.com> <1395923135-15329-4-git-send-email-feng.wu@intel.com> <53340FA5.1050905@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To: "Zhang, Yang Z" , "Wu, Feng" , "gleb@redhat.com" , "hpa@zytor.com" , "kvm@vger.kernel.org" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:62658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbaC1GXH (ORCPT ); Fri, 28 Mar 2014 02:23:07 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 28/03/2014 06:47, Zhang, Yang Z ha scritto: >>> >> + smap = smap && u && !uf && >>> >> + !((kvm_x86_ops->get_cpl(vcpu) < 3) && >>> >> + ((kvm_x86_ops->get_rflags(vcpu) & >>> >> + X86_EFLAGS_AC) == 1)); >> > >> > Unfortunately this doesn't work. >> > >> > The reason is that changing X86_EFLAGS_AC doesn't trigger >> > update_permission_bitmask. So the value of CPL < 3 && AC = 1 must not >> > be checked in update_permission_bitmask; instead, it must be included >> > in the index into the permissions array. You can reuse the >> > PFERR_RSVD_MASK bit, like >> > >> > smapf = pfec & PFERR_RSVD_MASK; >> > ... >> > smap = smap && smapf u && !uf; >> > >> > The VCPU can then be passed to permission_fault in order to get the >> > value of the CPL and the AC bit. > > Is CPL check needed? Shouldn't it already have been covered by U bit? It is not needed but actually it is covered by !uf, I think. Paolo