From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH V4 5/7] KVM, pkeys: Add pkeys support for gva_to_gpa funcions Date: Sun, 6 Mar 2016 22:33:13 +0100 Message-ID: <56DCA219.3010003@redhat.com> References: <1457177252-7577-1-git-send-email-huaitong.han@intel.com> <1457177252-7577-6-git-send-email-huaitong.han@intel.com> <56DBE3D6.70407@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org To: Xiao Guangrong , Huaitong Han , gleb@kernel.org Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:32786 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718AbcCFVdW (ORCPT ); Sun, 6 Mar 2016 16:33:22 -0500 Received: by mail-wm0-f66.google.com with SMTP id n186so7716504wmn.0 for ; Sun, 06 Mar 2016 13:33:21 -0800 (PST) In-Reply-To: <56DBE3D6.70407@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/03/2016 09:01, Xiao Guangrong wrote: > > > On 03/05/2016 07:27 PM, Huaitong Han wrote: >> This patch adds pkeys support for gva_to_gpa funcions. > > It is not needed if you follow the approach i raised in the previous patch. It's not needed anyway, I think. PFERR_PK_MASK is set to CR4.PKE. However, patch 3 sets pku to false if CR4.PKE is clear, and then the corresponding bit is always clear in mmu->permissions[byte]. Thus I think permission_fault() operates in just the same way even if PFERR_PK_MASK is always set; CR4.PKE=0 is caught through the permissions bitmask (as it's meant to be). Instead of setting PFERR_PK_MASK, we can instead handle it in permission_fault like: pkru = is_long_mode(vcpu) ? read_pkru() : 0; if (unlikely(pkru)) { ... /* Set PK bit of pfec if pkru_bits is non-zero */ pfec |= pkru_bits ? PFERR_PK_MASK : 0; } I'll get to the topic of branches in another message. Paolo