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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 420B4C433E2 for ; Thu, 3 Sep 2020 12:31:47 +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 EFEAD20639 for ; Thu, 3 Sep 2020 12:31:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kooIW6oB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="iBqBAKHv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFEAD20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OHj/eKcgZIgmvZ30GPkZakyifm9QFRZoiubRStVuRR8=; b=kooIW6oBRB35Nqc0UEcqZhSUv L/PaFC1nZ52wLNY5xqPTC4RubbTpGVXkOIhjhSTVSWzYTH4R316J+d/MB1hBk1jpB6WFJbGdlkdSd fViPNokVxfDhTzTvVrBllWKaUNa4Nu89ubfVVYLrAOoqUEhZOMzA/pBC2BUtqmnGMp288IA6ybOHV QLovCeyqedg4WG3+Vp7uJy4EINQFUCkhcOmo1Jc1tmvNkD6WJ6CuMQ5Nk6gb8oxdN2Agvd1xzEK3e 9k3XP9/OvnvSm4GWg6KB3OJ36nbfKTxRqesxeqcjDLtC7qa2JRc01+hoVl5PWVVHNz0nHvlw4EA42 S1D/uMuFA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDoO2-00061V-MW; Thu, 03 Sep 2020 12:30:42 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDoNz-000608-1Q for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 12:30:40 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 60E74206E7; Thu, 3 Sep 2020 12:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599136238; bh=xFR3P+zYPHxM2sBzwoV1/YxIxKxtNl1+GVkKMJb59tY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iBqBAKHvrS6U8lGNjU7J3nwf+8JfMYD0wbak01Z+bZkNTzcvpZpOOcEAfW2Q5pjkB Rl2JqgOioqJQuwVn2U29c1Lngw01Q3lrkIDlrbv3J/nsj4HVIFvchRjhNqg0oeUN5l RAC/SpwLHpkfEA2rnbNoonfm05QJi25IoKhpFcNs= Date: Thu, 3 Sep 2020 13:30:33 +0100 From: Will Deacon To: Gavin Shan Subject: Re: [PATCH v3 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table Message-ID: <20200903123032.GB7412@willie-the-truck> References: <20200825093953.26493-1-will@kernel.org> <20200825093953.26493-7-will@kernel.org> <4cb1fbc9-c20d-35f1-c0cc-da21c0562f0a@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4cb1fbc9-c20d-35f1-c0cc-da21c0562f0a@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_083039_224218_8BC8BBA8 X-CRM114-Status: GOOD ( 19.08 ) 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: 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 On Thu, Sep 03, 2020 at 09:18:27PM +1000, Gavin Shan wrote: > On 8/25/20 7:39 PM, Will Deacon wrote: > > Add stage-2 map() and unmap() operations to the generic page-table code. > > > > Cc: Marc Zyngier > > Cc: Quentin Perret > > Signed-off-by: Will Deacon > > --- > > arch/arm64/include/asm/kvm_pgtable.h | 39 ++++ > > arch/arm64/kvm/hyp/pgtable.c | 262 +++++++++++++++++++++++++++ > > 2 files changed, 301 insertions(+) [...] > > +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); > > + } > > + > > + return ret; > > +} > > + > > As discussed in another thread, *ptep has been invalidated in stage2_map_walk_table_pre(). > It means *ptep has value of zero. The following call to free_page() is going to release > the page frame corresponding to physical address 0x0. It's not correct. We might cache > the original value of this page table entry so that it can be used here. Ah, yes, I see what you mean. But it's odd that I haven't run into this myself, so let me try to reproduce the issue first. Another solution is to invalidate the table entry only by clearing the valid bit of the pte, rather than zapping the entire thing to 0, which can be done later when we clear the anchor. Cheers, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel