From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 7/9] KVM, pkeys: Add pkeys support for gva_to_gpa funcions Date: Mon, 9 Nov 2015 14:23:00 +0100 Message-ID: <56409E34.2050400@redhat.com> References: <1447070055-4207-1-git-send-email-huaitong.han@intel.com> <1447070055-4207-8-git-send-email-huaitong.han@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Huaitong Han , gleb@kernel.org Return-path: Received: from mail-wm0-f42.google.com ([74.125.82.42]:38637 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbbKINXE (ORCPT ); Mon, 9 Nov 2015 08:23:04 -0500 Received: by wmec201 with SMTP id c201so69472521wme.1 for ; Mon, 09 Nov 2015 05:23:02 -0800 (PST) In-Reply-To: <1447070055-4207-8-git-send-email-huaitong.han@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/11/2015 12:54, Huaitong Han wrote: > index 7a84b83..6e9156d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3960,6 +3960,8 @@ gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, > struct x86_exception *exception) > { > u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; > + access |= is_long_mode(vcpu) && kvm_read_cr4_bits(vcpu, X86_CR4_PKE) > + ? PFERR_PK_MASK : 0; > return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, exception); I think checking is_long_mode is not necessary here, since is_long_mode is not checked in update_permission_bitmask but (dynamically) in permission_fault. > > + gpa_t gpa; > + > + access |= is_long_mode(vcpu) && kvm_read_cr4_bits(vcpu, X86_CR4_PKE) > + ? PFERR_PK_MASK : 0; Fetches never have PFERR_PK_MASK set. Thanks, Paolo > /* Inline kvm_read_guest_virt_helper for speed. */ > - gpa_t gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr, access|PFERR_FETCH_MASK, > - exception); > + gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr, > + access | PFERR_FETCH_MASK, exception);