Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp554937imm; Mon, 1 Oct 2018 14:29:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61mascDOxUsT1NTg/GQmKAlYIBh7ASqKbIRylX6Q6gDEOYf9voqrAA6XmKbGC2cihcLpYZW X-Received: by 2002:a17:902:bd04:: with SMTP id p4-v6mr13781577pls.265.1538429369023; Mon, 01 Oct 2018 14:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538429368; cv=none; d=google.com; s=arc-20160816; b=QIFG3qXh1NkImZXDZAynn82AdJl+/4EzV4sziZwBluRF5SaC0EE3GAGkpN4q5p2KJC fArS1A6nWq4OMSaapj1YpBV5+8P4IR665DJ6q8i7E+fEeM46ijJr6rWvk0u7vUMDg1QB e6K/JBR/3JhUGLna7hHBeEs8E/1M4lp03zoMf/pFbeTP6rRZOGYQJVm9iz5L0gwBgYXR uKUwyn9CNj4ahoM4DUubpa7I8R/z5Y1BDYNplpgnvL/jOoyj2RqoepohkU8uEseHlcFr GYtMA2mnEH3lWEEizo+vJoXyMhqo23nGXYRHncURNsh+y8oBweqZm8q3xRTjqN1t8zlC ZU9Q== 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; bh=p4JnOykZHi1Sl6jVZXpfXhk+UGaqZH7viptUkMa0DZU=; b=SJkX569+wIr9Z8eOkNp/8duhNyVzzwI2HL2vtPLTVqDeowA8QSvG/eiUeLZM9hqEh0 3PG31FQUnq2SsHm4z0hUPCUSPa8h0QO9kV1UW+TMhNFWRnfNgE8RCHByCvTLwrQ4A0dG mcYf7uJl150J15KKaxQJB5WUoaZdSrwHQ1mfxPSf7/pnqSeLWqD9AJlOODvM5UZ3G+Tt tQAHIx32u/ciz1k9/d4r4EjQjfmc7IsLFjRh1UvQ2jjVOR31TyjqS/qcFIPcwrXT3ayI jgTNw2sBq+9/CgJadEN2B/kuUPAVyr1tDVfSnvpRnl9ACoPjiGPDMjauYzLP6p4ypzFB KeFg== 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 d4-v6si13273133pgl.147.2018.10.01.14.29.14; Mon, 01 Oct 2018 14:29:28 -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 S1726443AbeJBEIr (ORCPT + 99 others); Tue, 2 Oct 2018 00:08:47 -0400 Received: from foss.arm.com ([217.140.101.70]:56128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbeJBEIq (ORCPT ); Tue, 2 Oct 2018 00:08:46 -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 12CA080D; Mon, 1 Oct 2018 14:29:00 -0700 (PDT) Received: from [10.37.10.63] (unknown [10.37.10.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 526073F5D3; Mon, 1 Oct 2018 14:28:58 -0700 (PDT) Subject: Re: [PATCH v8 9/9] KVM: arm64: Add support for creating PUD hugepages at stage 2 To: Punit Agrawal , kvmarm@lists.cs.columbia.edu Cc: marc.zyngier@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall , Russell King , Catalin Marinas References: <20181001155443.23032-1-punit.agrawal@arm.com> <20181001155443.23032-10-punit.agrawal@arm.com> From: Suzuki K Poulose Message-ID: <3bd022cd-e470-479a-d7a5-680810db6a42@arm.com> Date: Mon, 1 Oct 2018 22:30:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20181001155443.23032-10-punit.agrawal@arm.com> Content-Type: text/plain; charset=utf-8; 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 10/01/2018 04:54 PM, Punit Agrawal wrote: > KVM only supports PMD hugepages at stage 2. Now that the various page > handling routines are updated, extend the stage 2 fault handling to > map in PUD hugepages. > > Addition of PUD hugepage support enables additional page sizes (e.g., > 1G with 4K granule) which can be useful on cores that support mapping > larger block sizes in the TLB entries. > > 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 | 20 +++++ > arch/arm/include/asm/stage2_pgtable.h | 9 +++ > arch/arm64/include/asm/kvm_mmu.h | 16 ++++ > arch/arm64/include/asm/pgtable-hwdef.h | 2 + > arch/arm64/include/asm/pgtable.h | 2 + > virt/kvm/arm/mmu.c | 106 +++++++++++++++++++++++-- > 6 files changed, 149 insertions(+), 6 deletions(-) > ... > diff --git a/arch/arm/include/asm/stage2_pgtable.h b/arch/arm/include/asm/stage2_pgtable.h > index f6a7ea805232..a4ec25360e50 100644 > --- a/arch/arm/include/asm/stage2_pgtable.h > +++ b/arch/arm/include/asm/stage2_pgtable.h > @@ -68,4 +68,13 @@ stage2_pmd_addr_end(struct kvm *kvm, phys_addr_t addr, phys_addr_t end) > #define stage2_pmd_table_empty(kvm, pmdp) kvm_page_empty(pmdp) > #define stage2_pud_table_empty(kvm, pudp) false > > +static inline bool kvm_stage2_has_pud(struct kvm *kvm) > +{ > +#if CONFIG_PGTABLE_LEVELS > 3 > + return true; > +#else > + return false; > +#endif nit: We can only have PGTABLE_LEVELS=3 on ARM with LPAE. AFAIT, this can be set to false always for ARM. > +} > + ... > @@ -1669,7 +1752,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > needs_exec = exec_fault || > (fault_status == FSC_PERM && stage2_is_exec(kvm, fault_ipa)); > > - if (hugetlb && vma_pagesize == PMD_SIZE) { > + if (hugetlb && vma_pagesize == PUD_SIZE) { > + pud_t new_pud = kvm_pfn_pud(pfn, mem_type); > + > + new_pud = kvm_pud_mkhuge(new_pud); > + if (writable) > + new_pud = kvm_s2pud_mkwrite(new_pud); > + > + if (needs_exec) > + new_pud = kvm_s2pud_mkexec(new_pud); > + > + ret = stage2_set_pud_huge(kvm, memcache, fault_ipa, &new_pud); > + } else if (hugetlb && vma_pagesize == PMD_SIZE) { > pmd_t new_pmd = kvm_pfn_pmd(pfn, mem_type); > > new_pmd = kvm_pmd_mkhuge(new_pmd); > Reviewed-by: Suzuki K Poulose