From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 AA4BAC43461 for ; Thu, 10 Sep 2020 13:56:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23EF72087C for ; Thu, 10 Sep 2020 13:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ySrb+h1G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23EF72087C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eLnJzVVgBRQVw0t3Z0Fc2Eit2/w6nVy8l19bHzgCU+c=; b=ySrb+h1GjoZz0A42+3KfO4Flf vTIqiVtf2JPLL7hWa7wZZaIfwZK+vnnkJzrcVfckhbr/zBouFBAoObke4NQDGnVJu0de3LqLmKkrc iSh1QktC3mdm4GbDh+h49u714UnJN+dGf2CI80SKr/RPkhNlbMHkaj14cdTgNnH5BRMcGGzFD5qKw 31BB76tDHH/SbQcagHacFIlz4xICzQVHra38WAu31bBqfhQTXqHacTqY0sMqZYerpah5U6A/CkC5v NphHRxPprsgVQVfsjdoAUsQ5KJ4v5GydVvTjysbJ6PYp24/X0Z8d3rmHzou+mFRoAI254V9GKmSGC ezO8HiahA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGN2Q-0002fd-7R; Thu, 10 Sep 2020 13:54:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGN2N-0002f1-8L for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 13:54:56 +0000 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 566EB113E; Thu, 10 Sep 2020 06:54:53 -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 135243F66E; Thu, 10 Sep 2020 06:54:51 -0700 (PDT) Subject: Re: [PATCH v4 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table To: Will Deacon References: <20200907152344.12978-1-will@kernel.org> <20200907152344.12978-7-will@kernel.org> <20200910123404.GA18100@willie-the-truck> From: Alexandru Elisei Message-ID: Date: Thu, 10 Sep 2020 14:55:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200910123404.GA18100@willie-the-truck> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_095455_339349_9D2865A8 X-CRM114-Status: GOOD ( 22.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gavin Shan , Suzuki Poulose , Marc Zyngier , Quentin Perret , James Morse , Catalin Marinas , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Will, On 9/10/20 1:34 PM, Will Deacon wrote: > On Thu, Sep 10, 2020 at 12:20:42PM +0100, Alexandru Elisei wrote: >> On 9/7/20 4:23 PM, Will Deacon wrote: >>> +static int stage2_map_walk_table_post(u64 addr, u64 end, u32 level, >>> + kvm_pte_t *ptep, >>> + struct stage2_map_data *data) >>> +{ >>> + int ret = 0; >>> + >>> + if (!data->anchor) >>> + return 0; >>> + >>> + free_page((unsigned long)kvm_pte_follow(*ptep)); >>> + put_page(virt_to_page(ptep)); >>> + >>> + if (data->anchor == ptep) { >>> + data->anchor = NULL; >>> + ret = stage2_map_walk_leaf(addr, end, level, ptep, data); >>> + } >> I had another look at this function. If we're back to the anchor entry, then that >> means that we know from the pre-order visitor that 1. the mapping is supported at >> this level and 2. that the pte was invalidated. This means that >> kvm_set_valid_leaf_pte() will succeed in changing the entry. How about instead of >> calling stage2_map_walk_leaf() -> stage2_map_walker_try_leaf() -> >> kvm_set_valid_leaf_pte() we call kvm_set_valid_leaf_pte() directly, followed by >> get_page(virt_to_page(ptep)? It would make the code a lot easier to follow >> (stage2_map_walk_leaf() is pretty complicated, imo, but that can't really be >> avoided), and also slightly faster. > I'm not sure I agree. I would consider kvm_set_valid_leaf_pte() to be lower > level, and not the right function to be calling here. Rather, > stage2_map_walk_leaf() is what would have been called if we hadn't spotted > the potential for a block mapping anyway, so I much prefer that symmetry. It > also means that if stage2_map_walk_leaf() grows some extra logic in future > that we need to take into account here, we won't miss anything. Sure, that makes sense. Thanks, Alex _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel