Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1059788imm; Tue, 2 Oct 2018 01:53:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV632aBk81wX8YJvb7jGwBohCww+raSv7l1E/c9v7xrbqj93o8QryWW3B/ZfKjU7ZNIVTBokQ X-Received: by 2002:a63:7c5e:: with SMTP id l30-v6mr13576646pgn.45.1538470392378; Tue, 02 Oct 2018 01:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538470392; cv=none; d=google.com; s=arc-20160816; b=SKQWU56P/sJSDqswyfkpWK0prxDsLpz+4AALSamkqhFTnFFs5pmjSj7FKlX7tE6IVA mswZUKrvHEiqK/xUMBHIWqE7kBW5S5uRq+HV8p8Xe4NPnIv91pHyL94SqpzJJfC9HU0a ucveyq9qGfjZaoVwWKNcCBP3dGKfE+T/LP5+fkJ90iGKUbQOpck55CfgkcJedVq4bd39 nFQx5kNAFoTRsW8qMD38jV3Uxxv+T/ME3cZ/7XTC935ObSn59zuvy7VTqIxj7Xoe6xCy BYHKC0qB+ZtQQjLzvyn6Cf47ZKRXQ+DUakOC9neS4/1sWsvvYwqh5FNVYd8mCJuKZPX8 f6+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=/VMNKIuGNXUEiNr/C4oI1yQqyEfys3UonsqF53PEGzw=; b=ofo8gSUg6smMT13DRjtVl/lzd6ZC1OfV6aYnKZxrG16w7EtMh1fh55FKCmT0oXndJ5 CPYTp3FbGspMu98pbKDq3NkbExln8TRM60dv9RstbtmISmGfIQMIMd0eEPUR0C2cWCkO 6SbXyCzybbzj20c+COi/FaEffyC0NQzNV12+mIO1SdCw8OOvEb0g8dQo2qyDu3CmktDA nhgmba76gyixMqPKJsjXXOvj11ETq86KKnpEVziFR/kDXo/XtDKwepW8UHpoJogdm3ir 3O3ptT/zzUEyr6LRkbFQRg5msKtpLnTurpRygvG7JIhu2Mc+V1Nzv+28xJDCrr9+kEMQ 4/yQ== 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 p66-v6si15268696pfp.237.2018.10.02.01.52.57; Tue, 02 Oct 2018 01:53:12 -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 S1726925AbeJBPe4 (ORCPT + 99 others); Tue, 2 Oct 2018 11:34:56 -0400 Received: from foss.arm.com ([217.140.101.70]:60928 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbeJBPe4 (ORCPT ); Tue, 2 Oct 2018 11:34:56 -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 3765F18A; Tue, 2 Oct 2018 01:52:45 -0700 (PDT) Received: from localhost (e105922-lin.Emea.Arm.com [10.4.13.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CDDE93F5B3; Tue, 2 Oct 2018 01:52:44 -0700 (PDT) From: Punit Agrawal To: Suzuki K Poulose Cc: , , , , , Christoffer Dall , Russell King , Catalin Marinas Subject: Re: [PATCH v8 9/9] KVM: arm64: Add support for creating PUD hugepages at stage 2 References: <20181001155443.23032-1-punit.agrawal@arm.com> <20181001155443.23032-10-punit.agrawal@arm.com> <3bd022cd-e470-479a-d7a5-680810db6a42@arm.com> Date: Tue, 02 Oct 2018 09:52:43 +0100 In-Reply-To: <3bd022cd-e470-479a-d7a5-680810db6a42@arm.com> (Suzuki K. Poulose's message of "Mon, 1 Oct 2018 22:30:00 +0100") Message-ID: <87y3bgk9wk.fsf@e105922-lin.cambridge.arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Suzuki K Poulose writes: > 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. I debated this and veered towards being generic but not committed either ways. I've updated this locally but will wait for further comments before re-posting. > >> +} >> + > > ... > >> @@ -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 Thanks a lot for going through the series.