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 2CBB5390C85; Fri, 31 Jul 2026 08:23:46 +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=1785486228; cv=none; b=cvKf3Crr33/fRnvvyPl/iPxzuKCrTEJMcRWQjm4Y3u8gRADu908fF8o6yKiaEGy4R4/4+G4XF8H9lDZJXA5UzPHAR3GgWMhFnwkivuOjZKpTMKRksdH9gJtZQbAoK4108eXGM9wGVUriLcgCzGI0WzzEqaf2O4bXrjV7LW9Un/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785486228; c=relaxed/simple; bh=u0XzHzHKgDIelDozkivhOpPafuYkC2zE7UgSQ/lkDiY=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=iEJ1y7jusPKQB70reXbDE5OKgsvNj2JM8zNRUgfDs7EOh7E0KYbchYU/3Rs72jrW27iza/9x+xoGoPQeJEhIaSQH76Pq6e1gEftytfy0xc03t5ojBVqHaZ5A675ziespRjja0/lJB4vBkBMkKCLLLfdg0hXWWdwDcfjIX4wTaMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BDZLs4f9; 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="BDZLs4f9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAB191F000E9; Fri, 31 Jul 2026 08:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785486226; bh=RSdWbM+abWi+vwG5OznmwW0QSMQjk5ndwXEpSTWN+KM=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=BDZLs4f90qFg00VaiR414IWSmjBA/tfDMZ7hFoqwE+Sj5M4WRsZFTGtLVaN/wnprk UhJ/Ig+dK5zUJ2CX49ZL8gSE31xIEkZamFjhvWbR2o6XoCuKkDhxBiQ6YjM4iiH85P oobABKfRW+S6oyf4RZkYaJEpEp/GgYgOVOUL+hySNhPhtZq+iR1ggc6qPcsbzvUClM ehNLQUpo5xY3K9N7wQ4yfMFCeVQXSdYXN6QywpZpuaiS9v/qwDbQEEkEi2vVS1HOPq XJS3TdtPrE9PEzP8PpBJzvwsSPMloy2+ZDr/gsr4u+xQtFWrXEU2fpoNlo09x3Zo2V 0pWZ7mGIIywQg== 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 1wpiWu-0000000Aqb9-1kkY; Fri, 31 Jul 2026 08:23:44 +0000 Date: Fri, 31 Jul 2026 09:23:43 +0100 Message-ID: <86cxw3d0ts.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: Fuad Tabba , sashiko-reviews@lists.linux.dev, kvmarm@lists.linux.dev Subject: Re: [PATCH v5 3/7] KVM: arm64: Top up stage-2 memcache for dirty logging faults In-Reply-To: References: <20260717130317.1953574-1-fuad.tabba@linux.dev> <20260717130317.1953574-4-fuad.tabba@linux.dev> <20260717131537.71F531F000E9@smtp.kernel.org> <87cxwkr8k0.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: oupton@kernel.org, fuad.tabba@linux.dev, sashiko-reviews@lists.linux.dev, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 31 Jul 2026 08:10:56 +0100, Oliver Upton wrote: > > Hey, > > Sorry for the latency, stumbled upon this as I was looking for stuff to > grab for 7.3... > > On Sat, Jul 18, 2026 at 09:44:31AM +0100, Marc Zyngier wrote: > > On Fri, 17 Jul 2026 15:17:00 +0100, > > Fuad Tabba wrote: > > > > > > On Fri, 17 Jul 2026 at 14:15, wrote: > > > > > > > > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > > > > > > > > Pre-existing issues: > > > > - [High] A malicious nested (L1) guest can crash the KVM host via a Break-Before-Make (BBM) violation that triggers a BUG_ON() due to an empty memory cache during a permission fault. > > > > > > From my understanding of NV code, this looks like a real issue. I > > > don't think it changes this patch, though: this one only widens the > > > top-up for the dirty-logging case, and the path you describe is a > > > non-logging permission fault. So, it would be a separate fix, a top up > > > for nested permission faults too, the same way we already do for pKVM? > > > > > > if (!perm_fault || memslot_is_logging(s2fd->memslot) || > > > is_protected_kvm_enabled() || s2fd->nested) { > > > > > > If that's right, I'll send a separate fix later. Marc, what do you think? > > > > I don't think this is correct. Yes, this papers over the guest being > > buggy, but i don't think that's what we should really do. > > > > Doing the same thing (changing the output size without a TLBI) on real > > HW would result in a permission fault being signalled to EL2, and we > > should model our SW MMU the same way. > > FEAT_BBML3 shifts responsibility onto the implementation to reconcile > multihit due to mapping granularity changes. A hypervisor could choose > to do eager page splitting at the beginning of dirty logging and elide > TLBIs. Sure. We just don't advertise BBML3. and I'm not even sure we always can emulate it. > > > I think the latent bug here is the way we always walk L1's S2 on S2 > > fault, irrespective of the fault type, and that feels wrong. This is > > ignoring the fact that we already have a TLB (the shadow S2) for this > > mapping, and rewalk anyway. Since we now find valid permissions, we > > take it at face value and try to install this new translation (which > > could point to a different OA, and even bigger problem). > > > > So ideally we'd simply tell the guest to bugger off, but we need to > > solve a few problems first: > > > > - some permission faults are caused by the host rather than the guest > > (dirty logging, HAFDBS), and we need to treat those specially. > > > > - we need to rebuild an ESR based on the content of our TLB, not L1's > > S2, which is not always easy to obtain (we have some limited TTL > > caching in the shadow S2, but that's not always reliable). > > > > All of this strongly intersects with Wei-Lin's reverse map, and > > Oliver's HAFDBS support. > > > > Oliver? > > Hmm, I'm more of the mind that we should just keep the memcache topped > up for any fault because clearly the prediction has gotten out of sync > with what happens later down the line. We're bound to screw it up again. > > Generating faults solely based on the TLB seems to be at odds with > supporting FEAT_ETS* in the shadow stage-2 and practically means we > need to re-walk for most stage-2 aborts anyway. And as you point out, I > need to do this for HAFDBS dirty state updates. > > BBML3 and ETS2/3 aren't terribly high priority but I'd rather not paper > over a rather straightforward KVM bug by making design decisions that > limit our feature set for nested. My problem here is not the top-up of the memcache, but the fact that the OA may have changed in L1's S2. This potentially result in an inconsistent S2, and in the future a wonky reverse map. So I'm not advocating we paper over anything. It's exactly the opposite. As for future features, I don't think they should take priority over correctness, and taking the guest S2 at face value is incorrect. If you want to hide this from the guest, fine. But that probably means that we need to detect this situation, and nuke part (or all) of the shadow S2 as a consequence. Today, we're just going to mess things up. Thanks, M. -- Without deviation from the norm, progress is not possible.