Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp506852imm; Wed, 11 Jul 2018 06:24:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpef26aikdEx40a4/gOvB3IVzsRQFJ3JJbGlX7kdkjLLt3j7/84w9wgstLNzz9Xeye0bM7en X-Received: by 2002:a17:902:112b:: with SMTP id d40-v6mr29093475pla.123.1531315489842; Wed, 11 Jul 2018 06:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531315489; cv=none; d=google.com; s=arc-20160816; b=PHp49jpdc4ES6SWjvXi+QcqSeHFmxlHMn+nZOgjg8gCMzoQFpGWIuuEEHcxU16Grun Li4JH3ZjthdvgIL046UabvF1An4ZlsNZlupoGpHu2XzUBLL4DmDui8EUrNRV+pMBsZ6G UMYTU0Ayd7kILNAeI2HQgCY/U5XuYcHF+5YQvXMQPfwZCWj/T7Yg8N7uXcRUjpCGr/e+ YZzkvCXvfuMVXjb07XcuhP+QBIbrCp8ugiGYA6ArkYLbsFbBfhjnDrg6/iP4rd68UsyG Ttfn5JZ5DZsNamLiGGa2ANxYP1MKf+Nfc73cV19A38X/eicznDrEjC/5sAMcVmZi7LG9 NIxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=ZMDRT6FA4xsHAGO5mSMtIWo5bwfKSVGHSHCA80wfiIQ=; b=QQIY3SKEa2Fv4bBb/G1RGvX58b3aD3EF2vcIudvNcEHdsqH4Qi4HNIB3gP2yKEfdfI EZn27lFi8gbqKBN6EvIAG1ikN9TorvN7n9an/UnXs1tGk5sdwFQdxILJegQk1Kzx6GlN wtBT8zjn3IbfL7T3S6o775whjDhlCZtM8qe9MX4aEeaeeC5Ijj0NmL7pQUGtP23m3h3v C7kgITnuVsGya59k68RxOiSD4W/e2nR6Q1b1HMmnFUr5bbRWhrJFEQvNAY6ER0WLyWkl R49qP6FTBzFPytp/caL/QXvn26QHUlKyVR5RlyKHpj3SXnYzH2xmKLDnY0XIBz33lcyO eb1g== 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 v6-v6si18942012plp.60.2018.07.11.06.24.34; Wed, 11 Jul 2018 06:24:49 -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 S2387834AbeGKN1t (ORCPT + 99 others); Wed, 11 Jul 2018 09:27:49 -0400 Received: from foss.arm.com ([217.140.101.70]:35782 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732530AbeGKN1t (ORCPT ); Wed, 11 Jul 2018 09:27:49 -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 B8A577A9; Wed, 11 Jul 2018 06:23:29 -0700 (PDT) Received: from [10.1.206.73] (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 12D303F5AD; Wed, 11 Jul 2018 06:23:27 -0700 (PDT) Subject: Re: [PATCH v5 6/7] KVM: arm64: Update age handlers to support PUD hugepages To: Punit Agrawal , kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, christoffer.dall@arm.com, linux-kernel@vger.kernel.org, will.deacon@arm.com, Russell King , Catalin Marinas References: <20180709143835.28971-1-punit.agrawal@arm.com> <20180709144124.29164-1-punit.agrawal@arm.com> <20180709144124.29164-6-punit.agrawal@arm.com> From: Suzuki K Poulose Message-ID: <5156c953-c49e-72c7-666e-c7894b728bef@arm.com> Date: Wed, 11 Jul 2018 14:23:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180709144124.29164-6-punit.agrawal@arm.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/07/18 15:41, Punit Agrawal wrote: > In preparation for creating larger hugepages at Stage 2, add support > to the age handling notifiers for PUD hugepages when encountered. > > Provide trivial helpers for arm32 to allow sharing code. > > 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 | 6 ++++ > arch/arm64/include/asm/kvm_mmu.h | 5 ++++ > arch/arm64/include/asm/pgtable.h | 1 + > virt/kvm/arm/mmu.c | 51 ++++++++++++++++++-------------- > 4 files changed, 40 insertions(+), 23 deletions(-) > > diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h > index a4298d429efc..8e1e8aee229e 100644 > --- a/arch/arm/include/asm/kvm_mmu.h > +++ b/arch/arm/include/asm/kvm_mmu.h > @@ -110,6 +110,12 @@ static inline pud_t kvm_s2pud_mkyoung(pud_t pud) > return pud; > } > > +static inline bool kvm_s2pud_young(pud_t pud) > +{ > + BUG(); > + return false; > +} > + > 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 4d2780c588b0..c542052fb199 100644 > --- a/arch/arm64/include/asm/kvm_mmu.h > +++ b/arch/arm64/include/asm/kvm_mmu.h > @@ -261,6 +261,11 @@ static inline pud_t kvm_s2pud_mkyoung(pud_t pud) > return pud_mkyoung(pud); > } > > +static inline bool kvm_s2pud_young(pud_t pud) > +{ > + return pud_young(pud); > +} > + > static inline bool kvm_page_empty(void *ptr) > { > struct page *ptr_page = virt_to_page(ptr); > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index a64a5c35beb1..4d9476e420d9 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -385,6 +385,7 @@ static inline int pmd_protnone(pmd_t pmd) > #define pfn_pmd(pfn,prot) __pmd(__phys_to_pmd_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) > #define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) > > +#define pud_young(pud) pte_young(pud_pte(pud)) > #define pud_mkyoung(pud) pte_pud(pte_mkyoung(pud_pte(pud))) > #define pud_write(pud) pte_write(pud_pte(pud)) > > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > index d2c705e31584..a6d3ac9d7c7a 100644 > --- a/virt/kvm/arm/mmu.c > +++ b/virt/kvm/arm/mmu.c > @@ -1172,6 +1172,11 @@ static int stage2_pmdp_test_and_clear_young(pmd_t *pmd) > return stage2_ptep_test_and_clear_young((pte_t *)pmd); > } > > +static int stage2_pudp_test_and_clear_young(pud_t *pud) > +{ > + return stage2_ptep_test_and_clear_young((pte_t *)pud); > +} > + > /** > * kvm_phys_addr_ioremap - map a device range to guest IPA > * > @@ -1879,42 +1884,42 @@ void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) > > static int kvm_age_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data) > { > - pmd_t *pmd; > - pte_t *pte; > + pud_t *pud = NULL; > + pmd_t *pmd = NULL; > + pte_t *pte = NULL; minor nit: If you are spinning another revision, it would be good to get the stage2_get_leaf_entry() to set the input parameters to NULL, rather than expecting NULL and sprinkling this initialisation everywhere. > + bool found; > > - WARN_ON(size != PAGE_SIZE && size != PMD_SIZE); > - pmd = stage2_get_pmd(kvm, NULL, gpa); > - if (!pmd || pmd_none(*pmd)) /* Nothing there */ > + WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE); > + found = stage2_get_leaf_entry(kvm, gpa, &pud, &pmd, &pte); > + if (!found) > return 0; minor nit: You may skip the variable here and below. > static int kvm_test_age_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data) > { > - pmd_t *pmd; > - pte_t *pte; > + pud_t *pud = NULL; > + pmd_t *pmd = NULL; > + pte_t *pte = NULL; > + bool found; > > - WARN_ON(size != PAGE_SIZE && size != PMD_SIZE); > - pmd = stage2_get_pmd(kvm, NULL, gpa); > - if (!pmd || pmd_none(*pmd)) /* Nothing there */ > + WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE); > + found = stage2_get_leaf_entry(kvm, gpa, &pud, &pmd, &pte); > + if (!found) > return 0; Either way, Reviewed-by: Suzuki K Poulose