Received: by 10.192.165.148 with SMTP id m20csp359754imm; Fri, 20 Apr 2018 07:57:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+G54k/EuJgUoPuUCAG3tNnOL3hg+mbykbiqZjStceB7aT4InGJDGY+zU2UO5P2Bi0FDbWf X-Received: by 10.98.76.202 with SMTP id e71mr4973946pfj.171.1524236237766; Fri, 20 Apr 2018 07:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524236237; cv=none; d=google.com; s=arc-20160816; b=Kaes1knA5vDXvDA8XzbnvKsbVmihmRc+eOJ9uRWiXhSE93MHowrHlTE0j40HozlyTb eGJldZICmzWY02Y1IJkd9w2ZPgQYiJYaBjpcCjD77U7quo24jS7DTPeGjCNmijlmlgjH bDBWR+lW9j2yHlzdaksl82m9FzOICWzj0H33uijgPIsixLG2Q5Xr7bfKglrjD8FR9Trl TxDyMVdcxL2J/f1NslCj0mcp03Rp1oaOHSwYrktE4VD6UNfCeySJ32xSzZoDgtjlnI0b z8vME5wr6bQOR2WLQrwp6Wwv0mX2wDfzkZSLyldocA+y//mKcOXRy0wUSFcnTEk0EoEZ fkYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=kW6cbDSQfLnBIpjcz/NlRpBn/WI7ZkLb3aQPgFZCpGQ=; b=tkJCfdT2xvxJ2ChcrAsNuYCI6PgcO1hMbz8mTvdZIRhRGlzG0hX/18Xv4lRXi6TgD5 rQq2iiHvJoSIq4FNuyr/VNVyv73THfp1KM09nc4Sp1k/ujoCh7uDtFLpsq+vsCb/wksl XEA8J9pYDxWQkIfY0WwsRAsqF1PUlQfZCJWH8ZckPKCLIriDIgTcRHwh1jCP/Wxpe2mS 3wOf1SFmSujnKzsf5fhB+ggAoOBvMdWM+Yt0//mzw/8wkoFB6CUncJvU8agSzc0nnDfA 2gHn+WPaSNbjol+MJKsM+lV41w/p8gIxaE8u/enKRZhIz76T+CM732SH1s8CMB4GMF/w QLEg== 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 a6si5207552pgn.631.2018.04.20.07.57.03; Fri, 20 Apr 2018 07:57:17 -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 S1755509AbeDTOz2 (ORCPT + 99 others); Fri, 20 Apr 2018 10:55:28 -0400 Received: from foss.arm.com ([217.140.101.70]:50136 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755472AbeDTOzX (ORCPT ); Fri, 20 Apr 2018 10:55:23 -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 7814615AD; Fri, 20 Apr 2018 07:55:23 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE1903F59D; Fri, 20 Apr 2018 07:55:22 -0700 (PDT) From: Punit Agrawal To: kvmarm@lists.cs.columbia.edu Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, christoffer.dall@arm.com, linux-kernel@vger.kernel.org, suzuki.poulose@arm.com, Russell King , Catalin Marinas , Will Deacon Subject: [PATCH 2/4] KVM: arm/arm64: Introduce helpers to manupulate page table entries Date: Fri, 20 Apr 2018 15:54:07 +0100 Message-Id: <20180420145409.24485-3-punit.agrawal@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420145409.24485-1-punit.agrawal@arm.com> References: <20180420145409.24485-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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