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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 42E09C4338F for ; Tue, 27 Jul 2021 18:20:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0466160F37 for ; Tue, 27 Jul 2021 18:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0466160F37 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=UUU2wvP3YEZjT3n2XfcxWqiER+9HBQhkaeQUCsn44C8=; b=xHvclMMeFtCv/m pjWOmvo79KC2NmlIFFbq3BuUQVSqwSvTaYnu2SDGtfg3VUCBYlpSLGA9TKzuxKL6yP4HanOsiiIkF WCM10serrEvjG/sFJ33s5ct7JQTrtt+H3wGsD+Wt5JMZKFJeRkVo9GDXhejLG1gHJO/Nx7SEwJHnX g+j1YHUwHC+NbhHdF77DZ2PYrHrSVlY12BObSQbZNqDTYfLmGEshN8D+rA6jyi9I7D813iCvZ5yMT QUIcy39iAP2ZVkwzkfbIwJCPw/HgD4bItJSUMV32sYSzhOn2UF271Ff3/v3JpDC6bfWQGudSxfXH6 BTs+yqS9yLyD0XGUVV3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8Reh-00Fnhm-6c; Tue, 27 Jul 2021 18:18:15 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8RXW-00FkNq-U4 for linux-arm-kernel@lists.infradead.org; Tue, 27 Jul 2021 18:10:52 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6349760F4F; Tue, 27 Jul 2021 18:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627409450; bh=1idsSsOLd6j5B3mlucoHIl85eXG29dW6Ac2vbhUO3Bs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EoFDUbpRaPCpop/dEtf4WAzlFiaUP3CjPo5T53gFnwUy4wbJ3B+0hT3gzFVMjsnrB gLndl4KBOIAQZyvL0c0pZSAOT1BEAhGFCmvzU3sAIoChqIerKeR98fF/2S2rQCDG5k phec+IZQs88i19ZKdLrLG/MT0rWFQp6Gr6SN/pSGHk77wCP1zP2QUcyqX54Z5C8OfW 7/tAQFHm9Px4MW92GtYwlqwqMSfND8kFmfuzSsZaLwaZe6xug/nkg39LP9h2p2l4sP 4rLd4bMxC2v7t5Scn4P2rhF4xDAP0+ukEt9wsgzbZmQbttMuWmezJZhFtCFQUOrOxx UFuCQq1bIr3ww== Date: Tue, 27 Jul 2021 19:10:45 +0100 From: Will Deacon To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qperret@google.com, dbrazdil@google.com, Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: Re: [PATCH 02/16] KVM: arm64: Don't issue CMOs when the physical address is invalid Message-ID: <20210727181044.GB19173@willie-the-truck> References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-3-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210715163159.1480168-3-maz@kernel.org> 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-20210727_111051_063849_C0882ACA X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, Jul 15, 2021 at 05:31:45PM +0100, Marc Zyngier wrote: > Make sure we don't issue CMOs when mapping something that > is not a memory address in the S2 page tables. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp/pgtable.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 05321f4165e3..a5874ebd0354 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -619,12 +619,16 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > } > > /* Perform CMOs before installation of the guest stage-2 PTE */ > - if (mm_ops->dcache_clean_inval_poc && stage2_pte_cacheable(pgt, new)) > - mm_ops->dcache_clean_inval_poc(kvm_pte_follow(new, mm_ops), > - granule); > - > - if (mm_ops->icache_inval_pou && stage2_pte_executable(new)) > - mm_ops->icache_inval_pou(kvm_pte_follow(new, mm_ops), granule); > + if (kvm_phys_is_valid(phys)) { > + if (mm_ops->dcache_clean_inval_poc && > + stage2_pte_cacheable(pgt, new)) > + mm_ops->dcache_clean_inval_poc(kvm_pte_follow(new, > + mm_ops), > + granule); > + if (mm_ops->icache_inval_pou && stage2_pte_executable(new)) > + mm_ops->icache_inval_pou(kvm_pte_follow(new, mm_ops), > + granule); > + } Given that this check corresponds to checking the validity of 'new', I wonder whether we'd be better off pushing the validity checks down into stage2_pte_{cacheable,executable}()? I.e. have stage2_pte_cacheable() return false if !kvm_pte_valid() Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel