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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 17DE2CD6E45 for ; Fri, 29 May 2026 09:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x+wn2xwmOPgbdli+f4h1F8xYQqZCthpocGdhsOC/V1g=; b=lJNwUOGb0X2BkF1Qau6S6eMcr8 Lft5qSwZGs/UnEJKzVemFwyO7/LP9KdYHxlFJBd95ue52A2m9yLDbGveE2cl7Jg8KcgfARukZXffX Oh0/yaSjOhawaiuQkbyuvhkparlEH36/E/CLP4w6UVTMwzhOR3ei79cIEqeMSIg+ouZMOUnyllKWd LANe1thBPPmlcmEb+3a3IiQeIVG/XDWvcbL0XPd/kPZPs6O2gP0SY6pwRk762KvdAPwj+7/Fn3WHX xMeE7WWxvmlQzCbv03naFDzehoTo10HcCsfsQ874YGKSSGSLBDF0N6DgWlAH4qvkQ/TKWmdM9hi5p pCqAUlaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wStXF-000000074PE-3JVi; Fri, 29 May 2026 09:29:45 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wStXE-000000074Oi-17wf for linux-arm-kernel@lists.infradead.org; Fri, 29 May 2026 09:29:44 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 637F56022B; Fri, 29 May 2026 09:29:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A2251F00893; Fri, 29 May 2026 09:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780046983; bh=x+wn2xwmOPgbdli+f4h1F8xYQqZCthpocGdhsOC/V1g=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=jEZ6+muOXXzXBy1issD8TifMjcpo4WwGShahaFoEScPVnwmo4LbrTSYY9SfVyROUD 3smwSkQt6L9XpLm+dr4dFcxytKEmyBzetrDyI3fkiM42GHpX1zoGwSONra/D0lDoou xB2/VgwO9vHaM5fWjjN1VbLGf2lzGwXk/yI2vJC5Tulav2/cBkNmFWU4rtJ6s4FrqP yKlkLp+CSfCQJMeVqAdqzQXBKFusVEX/PcksyzWVHJYuXUfdULcKmuLqYUXATWsbwj v6WnYTX4vKIiJU/qM7vtsDOjqtVciDom7E6Ny8OahLP3PDjKltOuGr1cLzOnSb5vpK NXLSfQGBMA4iA== 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 1wStXB-00000007LbO-1403; Fri, 29 May 2026 09:29:41 +0000 Date: Fri, 29 May 2026 10:29:40 +0100 Message-ID: <867bomva0r.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Vincent Donnefort , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Quentin Perret , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] KVM: arm64: Fix host/hyp tracking on share/unshare hypercall failure In-Reply-To: References: <20260529074341.2271950-1-tabba@google.com> <86a4tivdh3.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) 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: tabba@google.com, vdonnefort@google.com, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, qperret@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@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 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 29 May 2026 09:20:50 +0100, Fuad Tabba wrote: > > On Fri, 29 May 2026 at 09:15, Marc Zyngier wrote: > > > > On Fri, 29 May 2026 09:05:35 +0100, > > Fuad Tabba wrote: > > > > > > On Fri, 29 May 2026 at 09:02, Vincent Donnefort wrote: > > > > > > > > On Fri, May 29, 2026 at 08:43:39AM +0100, tabba@google.com wrote: > > > > > Hi folks, > > > > > > > > > > Yet another bug I found while testing Sashiko locally with fixes to > > > > > review-prompts. > > > > > > > > > > share_pfn_hyp() and unshare_pfn_hyp() in arch/arm64/kvm/mmu.c > > > > > maintain a host-side RB-tree mirroring the set of pages shared with > > > > > EL2. Both invoke a hypercall that can fail (page-state mismatch, > > > > > EL2 refcount still held), but neither cleans up on failure: > > > > > > > > > > - share_pfn_hyp() inserts the tracking node before the hypercall > > > > > and leaves it in the tree on failure, leaking the allocation and > > > > > presenting a phantom share to a later unshare. > > > > > > > > > > - unshare_pfn_hyp() erases the tracking node before the hypercall; > > > > > on failure the host loses its record while EL2 still owns the > > > > > share, breaking later operations on the same pfn. > > > > > > > > > > Severity is low (no isolation impact) and the failure paths are rare > > > > > in practice, but the desync is real. Both patches are independent and > > > > > apply cleanly to current mainline. In other words, this can wait for > > > > > 7.2. > > > > > > > > > > > > I believe I fixed that here lore.kernel.org/all/acyKhZL2di_QQ9xm@google.com but > > > > as Quentin pointed-out, there's absolutely no reason for the hypercall to fail. > > > > So I haven't sent a v2. > > > > > > At the very least we need to add a comment, otherwise, people like me > > > and LLMs like Sashiko would stumble upon it. > > > > > > That said, this fix adds no real overhead, makes the code clearer, and > > > guards us against a future where that call might fail. > > > Self-documenting in essense. > > > > > > WDYT? > > > > If a hypercall really cannot fail, why does it have a return value? > > Good point. If we know it cannot fail, how about just `void`? > > That said, Vincen't exact words are: `very much unlikely`, not the > same as cannot fail :) > > https://lore.kernel.org/all/acyKhZL2di_QQ9xm@google.com/ I think the rules are simple: - if something can fail, we need to handle the failure - if something should not fail and has the potential of compromising the system, we should panic - if something absolutely cannot fail, then there is nothing to handle Thanks, M. -- Without deviation from the norm, progress is not possible.