From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 393E43E0222; Wed, 10 Jun 2026 10:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781089032; cv=none; b=fza7dyBF6jrL6AmFatbUtc13qHv0kdiIE3wOlj5NZEylfAaQT6bq4/ma2eSNtji13KhTk28G/6iu9AeuVV6EWu2L73gHAdw5WUuPHfBALyUMdPlWKJC6AQGhcUx6wBRK1JJvVvNBHL566yNWcc/nS/sX+l2LK4RPn4HluclswPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781089032; c=relaxed/simple; bh=KXuB7L6cHgfycrnWvf78zDcejpO/GHoR/FwkhRqqE2E=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=sQ9fOLWnY/UwJW5BAEa5H/3vRXrNoTbaBN4wZ0zzi0MBDrCjZ3bTtasuhNSkzGmAA0FkPW1KppMolZvFMpSdm76LTewvDIeWhXveD5pppGt6/5X0QLBv+3Ao2/58TmIc2HwCJbAOfjE1av2yMizLEweq5YOX46aOe+6UF0Ppko0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hz56KSCK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hz56KSCK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ED6E1F00893; Wed, 10 Jun 2026 10:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781089027; bh=4dsbxE+UpFB1gxbxB8yCHBRmb9YT0B/b0rsLXt8UlE8=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Hz56KSCKIKm/QlVi1yOtRaw7l4oEe9zAxUjfmOc6JyuyyWD5xyoPjHlQXM7Yk4dDQ giJAlyKINKAWCr1aSwhyx1s6HFoN4z37ksD3v0vL6duPnaioiVGw4u/CK1d11qjHpA osJ8EKeg2WahzWjQrkatbBrfdNIJP5YFL/oI01LPep6l9ELR0xQuDIbw2lWzBzwQaL fe1s+OoSC4TGPpZzlJAAQ+GgnBVgo5Qu2M1Dl1L3LdkwM9bzT0CCxf/foXMEFb6XLr K+8Gd9NE7C2KrZAi08XtNsjcYdCRGTIZcanKCMrQXtl13BCliIWvpTi1Xc4zUGsp92 M8kjVkTei2BpA== 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.98.2) (envelope-from ) id 1wXGcL-0000000BJXq-12qI; Wed, 10 Jun 2026 10:57:05 +0000 Date: Wed, 10 Jun 2026 11:57:04 +0100 Message-ID: <868q8mu0hr.wl-maz@kernel.org> From: Marc Zyngier To: Yosry Ahmed Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Steffen Eiden , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: Re: [PATCH] KVM: arm64: Hold kvm->mmu_lock while initialising vcpu->arch.vncr_tlb In-Reply-To: References: <20260608081108.2244133-1-maz@kernel.org> <86ldcotbub.wl-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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: yosry@kernel.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 09 Jun 2026 18:57:26 +0100, Yosry Ahmed wrote: > > > > If yes, I think the code looks confusing, at least to a layman like > > > myself. It initially seems like the lock protects against concurrent > > > initializations, but then the NULL check is not done again under the > > > lock. The goal of the lock is not clear without the original report. > > > > > > Mayeb it's clearer to explicitly use barriers if the goal is preventing > > > reordering? > > > > This would require both the initialisation of vncr_tlb to use a store > > release, *and* all the other call sites to use a load acquire. > > > > I really don't think it is worth the churn, nor the (very small) > > burden on the readers. > > That's fair. I was mainly just pointing out my initial confusion and > that others may share it. Avoiding the churn on the readers' side is > understandable. Maybe a comment here would help explain why the lock > needs to be held? I have added this: /* * Taking the lock on assignment ensures that the TLB is * seen as initialised when following the pointer (release * semantics of the unlock), and avoids having acquires on * each user which already take the lock. */ Thanks, M. -- Without deviation from the norm, progress is not possible.