Received: by 10.192.165.148 with SMTP id m20csp582666imm; Fri, 27 Apr 2018 04:16:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoBnD1RRw0Q6xqacxHuTEc5syJV00iGDE8SeNvBz8x3qDJewgvpL/+KjCc2KsBwcQEFekN/ X-Received: by 2002:a63:8dca:: with SMTP id z193-v6mr1774556pgd.418.1524827773813; Fri, 27 Apr 2018 04:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524827773; cv=none; d=google.com; s=arc-20160816; b=ntQ8zez2aCzrzP8d0kuKKVwdwo5eqXkizJXUf/q9gxDcTNoCvlAqRLzfkQbIVzMmGV FjooVBDd3VcN9PiEAbKfLtgn2LRYRXfddTZeqfPuOWCGVoMDOtIHXHcH5UEhJDfiyEB9 5ILJffBy8ysK30XLTDgnye7li57NSuXkgr9O2Fd1SL/SlnrhJnT5dxMaK4DSiHyOp5c6 WwqiesfO8yvtKFHgS7d5ZcKFsOmvaok//1u4zxedG4YXro16fVVvknzgaKJvxDu2Y5vL W9VzydTcLjiHh0nbyIJE+R9/V7dRs/c/Rep+XeNszW17XgWKy2fhrn3n6y2BNsS48r5p j1fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=f32wPcTFbtqjn37Ez5beMGKx541mEPIPehlAB9JQBRk=; b=rR1dPXdmt65FlRqI/1b5bG3gjQLj4kxDNCCL5PlKjWRxvG0tCXy2l+R7Y2PkYkPo2m IeyaJ8IWL2z0KS/nzqGN59kL6K7leKMq6McK8bYhuLztMiJV3nXsx7ZFDqJiMC4l8BUW JaxyFEi2YwzefEEJeLxqhUPmhrprMKop2cQs5on/RwQFYwSUGQQtgestodurEw8Gi5jh jIZy9CrGRA9WiXOCBzdbBKkBfx2oyGlJ/EqdSATxax7JjIhxPEDn39M0cllwgJijqQu2 HGp/mDZUikFi7wKQSiggJA1qh8ge6O9bXYCslRxa+9ycZsS2hk3uGCekXtH4+fR/oRTZ 9t4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y139si1074750pfc.163.2018.04.27.04.15.59; Fri, 27 Apr 2018 04:16:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757413AbeD0LOq (ORCPT + 99 others); Fri, 27 Apr 2018 07:14:46 -0400 Received: from foss.arm.com ([217.140.101.70]:38642 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751464AbeD0LOo (ORCPT ); Fri, 27 Apr 2018 07:14:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9158F1529; Fri, 27 Apr 2018 04:14:44 -0700 (PDT) Received: from localhost (unknown [10.37.9.163]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 001013F4FF; Fri, 27 Apr 2018 04:14:43 -0700 (PDT) Date: Fri, 27 Apr 2018 13:14:41 +0200 From: Christoffer Dall To: Punit Agrawal Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, suzuki.poulose@arm.com, Russell King , Catalin Marinas , Will Deacon Subject: Re: [PATCH 2/4] KVM: arm/arm64: Introduce helpers to manupulate page table entries Message-ID: <20180427111441.GM13249@C02W217FHV2R.local> References: <20180420145409.24485-1-punit.agrawal@arm.com> <20180420145409.24485-3-punit.agrawal@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180420145409.24485-3-punit.agrawal@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 03:54:07PM +0100, Punit Agrawal wrote: > Introduce helpers to abstract architectural handling of the conversion > of pfn to page table entries and marking a PMD page table entry as a > block entry. > > The helpers are introduced in preparation for supporting PUD hugepages > at stage 2 - which are supported on arm64 but do not exist on arm. > > Signed-off-by: Punit Agrawal > Cc: Christoffer Dall > Cc: Marc Zyngier > Cc: Russell King > Cc: Catalin Marinas > Cc: Will Deacon Acked-by: Christoffer Dall > --- > arch/arm/include/asm/kvm_mmu.h | 5 +++++ > arch/arm64/include/asm/kvm_mmu.h | 5 +++++ > virt/kvm/arm/mmu.c | 7 ++++--- > 3 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h > index 707a1f06dc5d..5907a81ad5c1 100644 > --- a/arch/arm/include/asm/kvm_mmu.h > +++ b/arch/arm/include/asm/kvm_mmu.h > @@ -75,6 +75,11 @@ phys_addr_t kvm_get_idmap_vector(void); > int kvm_mmu_init(void); > void kvm_clear_hyp_idmap(void); > > +#define kvm_pfn_pte(pfn, prot) pfn_pte(pfn, prot) > +#define kvm_pfn_pmd(pfn, prot) pfn_pmd(pfn, prot) > + > +#define kvm_pmd_mkhuge(pmd) pmd_mkhuge(pmd) > + > static inline void kvm_set_pmd(pmd_t *pmd, pmd_t new_pmd) > { > *pmd = new_pmd; > diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h > index 082110993647..d962508ce4b3 100644 > --- a/arch/arm64/include/asm/kvm_mmu.h > +++ b/arch/arm64/include/asm/kvm_mmu.h > @@ -173,6 +173,11 @@ void kvm_clear_hyp_idmap(void); > #define kvm_set_pte(ptep, pte) set_pte(ptep, pte) > #define kvm_set_pmd(pmdp, pmd) set_pmd(pmdp, pmd) > > +#define kvm_pfn_pte(pfn, prot) pfn_pte(pfn, prot) > +#define kvm_pfn_pmd(pfn, prot) pfn_pmd(pfn, prot) > + > +#define kvm_pmd_mkhuge(pmd) pmd_mkhuge(pmd) > + > static inline pte_t kvm_s2pte_mkwrite(pte_t pte) > { > pte_val(pte) |= PTE_S2_RDWR; > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > index db382c7c7cd7..f72ae7a6dea0 100644 > --- a/virt/kvm/arm/mmu.c > +++ b/virt/kvm/arm/mmu.c > @@ -1538,8 +1538,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > invalidate_icache_guest_page(pfn, vma_pagesize); > > if (hugetlb) { > - pmd_t new_pmd = pfn_pmd(pfn, mem_type); > - new_pmd = pmd_mkhuge(new_pmd); > + pmd_t new_pmd = kvm_pfn_pmd(pfn, mem_type); > + > + new_pmd = kvm_pmd_mkhuge(new_pmd); > if (writable) > new_pmd = kvm_s2pmd_mkwrite(new_pmd); > > @@ -1553,7 +1554,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > > ret = stage2_set_pmd_huge(kvm, memcache, fault_ipa, &new_pmd); > } else { > - pte_t new_pte = pfn_pte(pfn, mem_type); > + pte_t new_pte = kvm_pfn_pte(pfn, mem_type); > > if (writable) { > new_pte = kvm_s2pte_mkwrite(new_pte); > -- > 2.17.0 >