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 04A1D348C61; Fri, 29 May 2026 08:15:06 +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=1780042507; cv=none; b=c4Dl1fXRpXWF8WEWQa1fsKoJK4EEb+Ri3Vsf6l2Z4OgnkU9B3rMb12jkip6VzdF5wmNYzDeKBtXZwfrMJkfuHySSbt2xd+MmrEWBLUZZfgjN1yz58gx4UzxNX4zUXur0l8Bf8Cj89t838MYpcft9ELGjt72RbszLEtCsvyOjGtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780042507; c=relaxed/simple; bh=fiIwkwsJ0+KdwncTLQPBsxKibDidUVSrFxNYNQq0aC8=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=tS8zX8ZsUF+hEFC4efGwXWRRyIzpMj4lP6VWLiU9kS2cqLatr8yURcWhsDZejZzaTvoSrN6WiRG/dX1o6vVkbC95T4O8we1HuiS7dHK8yatqyPc5nJ7m34sxktJijEw7WZidO7NDGctrvQyRQ4DXvx4DPu2JIg8bMGnh+XaJ1e8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LknxlMJl; 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="LknxlMJl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A58C01F00893; Fri, 29 May 2026 08:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780042506; bh=vISZXmW7d64JDmjfGiO5dCpQmHuaFYKlaeIq42DDx9I=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=LknxlMJlmPTMlZtMw37pza5r1lI44t+USBpbe35WV6NrhHSAXui2pTx8PpPo1SoXi Y6f6m5HPX0+JoKxtH+sd1BrqST1tCjMBXJ7tMde7+lMrzEqn8rx9Q/35/jaJes/i1u 5ibB/hbSLQ8uuEDGTO3fWvL/REcRMJc9tYF2sm46C5fSO1ok5EUx11LGFVUAYF62K1 WKWPs+ZUg/MDLHciVrVMtC6iWZsJngWC00mV5Dg2uYWc4yePw8vm54W+goaNBem6es mVZJMGR6naZMsVBecO4G6QRI2yN2lKFSvnLmyP287YbQG5kUcl1ReozJbLJt8u3XUf SVtjg849lB/Tw== 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 1wSsMy-00000007KAi-2XBz; Fri, 29 May 2026 08:15:04 +0000 Date: Fri, 29 May 2026 09:15:04 +0100 Message-ID: <86a4tivdh3.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> 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: 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 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? M. -- Without deviation from the norm, progress is not possible.