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 33358CE7A88 for ; Sun, 24 Sep 2023 10:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbjIXKMk (ORCPT ); Sun, 24 Sep 2023 06:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjIXKMk (ORCPT ); Sun, 24 Sep 2023 06:12:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 067BC103; Sun, 24 Sep 2023 03:12:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FEB0C433C7; Sun, 24 Sep 2023 10:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695550353; bh=iE012DIofnvNiLEBPxa64IhAAtSpcHdUQPnWCWNe0hs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VkdbkxTrTIyE6RPsVyRx7EOTaIay5Ow6IZCYlL7n1KqkaPfbPsbp3bFNDdI8jWOp8 dh3xLE8ynpKcGJoTzmYmjbyU3H6tH6ztz/xJbFicPZ8y94CUTnOp93Ft0ikh4jJ+3f CMfIZzpxSLhQ0D5BVoG2/u9g2XjmMtWZduoVYEExsg+u9JO20fIxJoVRDNommj85qN WSfMeBvO0Amf+flFSblQL6r4guhqnizM3hjPXeS6Pb6eseJeSmgPWNA9kkZ2qBj7oc BI87XYpNBepX50zFDQ5a7304vry1pEUv1Bdw4HujYEhvgf//6lf3FD+3PiRlZROQ5K ZZcZq5NaCM7ng== Received: from [85.255.234.76] (helo=wait-a-minute.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 1qkM6J-00Ffma-Fk; Sun, 24 Sep 2023 11:12:31 +0100 Date: Sun, 24 Sep 2023 11:12:30 +0100 Message-ID: <87ttrj5181.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , Vipin Sharma , Jing Zhang , stable@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Always invalidate TLB for stage-2 permission faults In-Reply-To: References: <20230922223229.1608155-1-oliver.upton@linux.dev> 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 (x86_64-pc-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: 85.255.234.76 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, vipinsh@google.com, jingzhangos@google.com, stable@vger.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: stable@vger.kernel.org On Sat, 23 Sep 2023 00:08:21 +0100, Oliver Upton wrote: > > On Fri, Sep 22, 2023 at 10:32:29PM +0000, Oliver Upton wrote: > > It is possible for multiple vCPUs to fault on the same IPA and attempt > > to resolve the fault. One of the page table walks will actually update > > the PTE and the rest will return -EAGAIN per our race detection scheme. > > KVM elides the TLB invalidation on the racing threads as the return > > value is nonzero. > > > > Before commit a12ab1378a88 ("KVM: arm64: Use local TLBI on permission > > relaxation") KVM always used broadcast TLB invalidations when handling > > permission faults, which had the convenient property of making the > > stage-2 updates visible to all CPUs in the system. However now we do a > > local invalidation, and TLBI elision leads to vCPUs getting stuck in a > > permission fault loop. Remember that the architecture permits the TLB to > > cache translations that precipitate a permission fault. > > The effects of this are slightly overstated (got ahead of myself). > EAGAIN only crops up if the cmpxchg() fails, we return 0 if the PTE > didn't need to be updated. > > On the subsequent permission fault we'll do the right thing and > invalidate the TLB, so this change is purely an optimization rather than > a correctness issue. Can you measure the actual effect of this change? In my (limited) experience, I had to actually trick the guest into doing this, and opportunistically invalidating TLBs didn't have any significant benefit. Thanks, M. -- Without deviation from the norm, progress is not possible.