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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C52CDC77B61 for ; Thu, 13 Apr 2023 07:37:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbjDMHhd (ORCPT ); Thu, 13 Apr 2023 03:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbjDMHhb (ORCPT ); Thu, 13 Apr 2023 03:37:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F33B88A5E for ; Thu, 13 Apr 2023 00:37:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F44163C05 for ; Thu, 13 Apr 2023 07:37:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5C34C433EF; Thu, 13 Apr 2023 07:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681371446; bh=ZMaTT/8mex5sR6Nngfj6wEcDaoj9Ognv7dOGr/aRgto=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Kk8Cmqob/uAaFqjhNG8AudM4RYOaTC8XnFKWnDzD9UX2Xa1nsbkKvWE02x/yDZqkH Gkx9TgMe03pH0XmVhj6d1OLq+TWugXF74jyduQvuJNoc6VTSpbNAPSdTmgRv5dPDoM C8Z2XgeUPgefmVg2OVrBg9s+Eg+MTVfrMpFhSDD5MSMw+sjo9ck5p8KVmwclPlHaMu oxQkt/yUVtSLk2rFByYdEoTScnwiIRnR8vcmjXhrp9p4HVccyQ9A6BvOLsUAryCGX3 +p0aIppsNfm44GjHyOsnOM+zSALtSPtZEtOxBqwWqWHPkpkmgyhsGcgIuK7Ye4WZT+ rTYIhFZFWFRcQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pmrWF-0082ML-Kp; Thu, 13 Apr 2023 08:37:23 +0100 Date: Thu, 13 Apr 2023 08:37:23 +0100 Message-ID: <86leiwkzbg.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Zenghui Yu , Will Deacon Subject: Re: [PATCH v2 2/5] KVM: arm64: nvhe: Synchronise with page table walker on TLBI In-Reply-To: References: <20230408160427.10672-1-maz@kernel.org> <20230408160427.10672-3-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, 13 Apr 2023 01:09:20 +0100, Oliver Upton wrote: > > Hi Marc, > > On Sat, Apr 08, 2023 at 05:04:24PM +0100, Marc Zyngier wrote: > > A TLBI from EL2 impacting EL1 involves messing with the EL1&0 > > translation regime, and the page table walker may still be > > performing speculative walks. > > > > Piggyback on the existing DSBs to always have a DSB ISH that > > will synchronise all load/store operations that the PTW may > > still have. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kvm/hyp/nvhe/tlb.c | 24 +++++++++++++++++++----- > > 1 file changed, 19 insertions(+), 5 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c > > index d296d617f589..e86dd04d49ff 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/tlb.c > > +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c > > @@ -17,6 +17,23 @@ struct tlb_inv_context { > > static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu, > > struct tlb_inv_context *cxt) > > { > > + /* > > + * We have two requirements: > > + * > > + * - ensure that the page table updates are visible to all > > + * CPUs, for which a dsb(ishst) is what we need > > + * > > + * - complete any speculative page table walk started before > > + * we trapped to EL2 so that we can mess with the MM > > + * registers out of context, for which dsb(nsh) is enough > > + * > > + * The composition of these two barriers is a dsb(ish). This > > + * might be slightly over the top for non-shareable TLBIs, but > > + * they are so vanishingly rare that it isn't worth the > > + * complexity. > > + */ > > + dsb(ish); > > + > > Ricardo is carrying a patch for non-shareable TLBIs on permission > relaxation [*], and he's found that it produces some rather desirable > performance improvements. I appreciate the elegance of your approach, > but given what's coming does it make sense to have the TLBI handlers > continue to explicitly perform the appropriate DSB? Ah, I forgot about my own patch! :D Right, let me see if I can do something clever here... Thanks, M. -- Without deviation from the norm, progress is not possible.