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 708F1348C52; Fri, 29 May 2026 09:29:43 +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=1780046984; cv=none; b=CBL8XmpMvaLDJm7iiiNFgCo3JCgbTAnLUMX81KwJOWdngitMMiZ35tA8mc3fA72+MoSqbPRYfcSdIqgrsWjG2DLbSI2xQTt8H9yQ074RPVfcATWxXNdeQTje6bn+HkX0SEl5fhdXD/guDD+XeleZ54MCjgr0RHhF8R2wsrfZdjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780046984; c=relaxed/simple; bh=b2MhD3ieZH/t3ky5R+j2iTmMEHToOIw0DE9eP11azR8=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=HCFA8Fc//8yVkBlhD9Fa6HiOro65RzrrAgwn4HwkVoCLvjSFqix/xQ75N2brVTf+EYG0+Xym1hXnOK88GjtN/H0tVfAG1tqRb6Sd3KdLH6lv8fHWHZgHfjN5nMq0kZFh/iG3dRsLseHmd91kVu4Vva+Me5Wmfo0MVuFE8G+Xeqs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jEZ6+muO; 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="jEZ6+muO" 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) 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: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.