Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1EB0C4338F for ; Tue, 27 Jul 2021 15:59:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C290861B7B for ; Tue, 27 Jul 2021 15:59:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236974AbhG0P73 (ORCPT ); Tue, 27 Jul 2021 11:59:29 -0400 Received: from foss.arm.com ([217.140.110.172]:40702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbhG0P73 (ORCPT ); Tue, 27 Jul 2021 11:59:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D938A31B; Tue, 27 Jul 2021 08:59:28 -0700 (PDT) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C5A6A3F70D; Tue, 27 Jul 2021 08:59:26 -0700 (PDT) Subject: Re: [PATCH v2 3/6] KVM: arm64: Avoid mapping size adjustment on permission fault To: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-mm@kvack.org Cc: Sean Christopherson , Matthew Wilcox , Paolo Bonzini , Will Deacon , Quentin Perret , James Morse , Suzuki K Poulose , kernel-team@android.com References: <20210726153552.1535838-1-maz@kernel.org> <20210726153552.1535838-4-maz@kernel.org> From: Alexandru Elisei Message-ID: <5216fbb0-1df2-325c-5e4d-98245c7470e6@arm.com> Date: Tue, 27 Jul 2021 17:00:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210726153552.1535838-4-maz@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Marc, On 7/26/21 4:35 PM, Marc Zyngier wrote: > Since we only support PMD-sized mappings for THP, getting > a permission fault on a level that results in a mapping > being larger than PAGE_SIZE is a sure indication that we have > already upgraded our mapping to a PMD. > > In this case, there is no need to try and parse userspace page > tables, as the fault information already tells us everything. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/mmu.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 0adc1617c557..ebb28dd4f2c9 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -1076,9 +1076,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > * If we are not forced to use page mapping, check if we are > * backed by a THP and thus use block mapping if possible. > */ > - if (vma_pagesize == PAGE_SIZE && !(force_pte || device)) > - vma_pagesize = transparent_hugepage_adjust(kvm, memslot, hva, > - &pfn, &fault_ipa); > + if (vma_pagesize == PAGE_SIZE && !(force_pte || device)) { > + if (fault_status == FSC_PERM && fault_granule > PAGE_SIZE) > + vma_pagesize = fault_granule; > + else > + vma_pagesize = transparent_hugepage_adjust(kvm, memslot, > + hva, &pfn, > + &fault_ipa); > + } Looks good: Reviewed-by: Alexandru Elisei Thanks, Alex > > if (fault_status != FSC_PERM && !device && kvm_has_mte(kvm)) { > /* Check the VMM hasn't introduced a new VM_SHARED VMA */