From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01E78344DBB for ; Fri, 29 May 2026 10:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780049204; cv=none; b=ZMaQUbDej6ckH41mwCSL22tvnemAkYz6SApVxMMQsvLYCDkd4NibShvHAy0xDXd+9ifr99bI4D9rxARAIPy1qVk8+GF+30ETEdUK+xS0eeL0sXe/aOIqt7vh/17+8/n08OddTxuKyPN/FIVBr9rwYkORyckuVkXMgw+pFthkmss= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780049204; c=relaxed/simple; bh=mM6ORMwsn3ciSj/I+BINnrSvpkley7x+ARd/aZm1SEc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oq5bXTSKcr81cgjYh61VaUdQVDRou/8LmUCfV4Rq1XfGMHXrDrwiv9wrNjkSEmjmhjVeSfDLxvW9MjfL+c7WsSidCf21YGUvP0IMJfFruotammuryITBdOcP/e+kMcZT2/G5ysBL57t4Ipx8sjWI3QqWt8MgwEnU61LIqDtAinA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XhHXPOGz; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XhHXPOGz" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4891c0620bcso88625165e9.1 for ; Fri, 29 May 2026 03:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780049201; x=1780654001; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=lWH+duc/f4ADBksdBfKd+ApBGYaYEoTepCNzP0jT5tc=; b=XhHXPOGzpJH05imC7i2l9rUum9ymsKcBCQlVND59C4Wsa4Yq3KTxT73w9WxzkXcqFp UDGbfTp737O3ipKELtrnvraolk3JYhYEW4OX0v64t9ipDckXEusjG3W07QOiRpLp5f/s Gy/O3ZobIkByInShQ4ZIWq22Xd+89s9PHJl1F8jxAXQqaveEWMartC6UM6v/spczutsG 8bi4a1crFxBkM8TrWrU/G6ICYGx+AqsO9O38M5caVPQ1NAo7vJOtz8FmbBM7qSXv1tRL 6B3ra7nDyW5QStiDnFyhCGFTDT89yLEIW9YCSRBFN/hpRT9F/wNU3ZL74bq5J4uixm43 UsFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780049201; x=1780654001; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lWH+duc/f4ADBksdBfKd+ApBGYaYEoTepCNzP0jT5tc=; b=bxx1IYmHWP0ThNi71eB22kZ8rKhquuHk7Ei6sAs2GdI1prjekDYtOosjMP3UCHH5oG EiIa233DggPObQUU8+R5z2GKvWS+MRvN1sbpDujsFVKetu5dak4zPwG+S1/eFvA2oOtn byRP6qEIVkQbxVUj834QtBqUHf3y6gwUVOZyx5F/mVanvWNvq8+f8shHWC0rdI42Bhrz H8K4ZCfrpcJQrY7ePIs3Hg0gYRWHMBOQmkxxVXPQdPosPojuoyt+TM1I0HRnriJKuMXO Xq2OpfhBheVJSyr10jSL4rPCzuBTqyekCBzRYRuY6KrXrnU19v1iIKd3ZYaQ0mqj08zY 493w== X-Forwarded-Encrypted: i=1; AFNElJ/JMnTtnAyvkK1Y3ITefNtpZql1I/WO3HGjqbNS5H+VWcHB80bL1OS3wveC2OZXtXcSkQM3xSbAYqAH3N4=@vger.kernel.org X-Gm-Message-State: AOJu0YyLru8fUAxNEFs6BWvxXz54xk4C6RYSxaukU0AsYYq5l40FGEcZ kFaTFv01VRIAjM+lZzML5kejmOVOxg/A0ndGhwcOF3+ICws32ue/sJsWfiJKEBfZlQ== X-Gm-Gg: Acq92OHruHjY3VVeQBifUQF39FTgfGyzRYvik1cFa0gtNHmX+yerHWkAME7L3FhX1Ic W4JhOFrra5eR0MlFzksMyIjrEPA8R0hmFnkhiP6hWC+PBwwT4kx166y6dwzgTYO3ejqo9Xf+EiI fsXyGZwEVsWcEGWyHWZ+Hpr16Q6jQQwopqcQ0SNThvCpX0RsZ8iLie/w8NG8bNpY4mG7HCeJdU2 jpgkrjJNNt1j5y4NbwXnfkKUj3LCAPjS5948Yz2pkPjja4QlhHlz1ANofewJRlaKHQyjqXFUibT 2LoNiFxcuxqc2YPLXyWTH/v8QxcnuYEgph3LCj8U1Ze9nAEIkRIoKv1nxE3lOpzMfduG5ZHbJTf +WlZzBUBnHYA2OwGYFWlUMeShpKM+4WgJ5eZ9YWUEHYjUW2Bg5JLq0Y7+sEFpp7H406y1YdwIQK PtDYN4cTLUAd7Q2x8O+Wv3Trp8yS0XEc6K8zCOK2JQSybqPd325MM1VDWaDNxUsBMdt0sA7Vqnx BsgCg== X-Received: by 2002:a05:600c:2e49:b0:490:5191:6e26 with SMTP id 5b1f17b1804b1-4909c0acb54mr23069455e9.18.1780049199966; Fri, 29 May 2026 03:06:39 -0700 (PDT) Received: from google.com (135.91.155.104.bc.googleusercontent.com. [104.155.91.135]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909c09adedsm11457715e9.2.2026.05.29.03.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 03:06:39 -0700 (PDT) Date: Fri, 29 May 2026 11:06:33 +0100 From: Vincent Donnefort To: Marc Zyngier Cc: Fuad Tabba , 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 Message-ID: References: <20260529074341.2271950-1-tabba@google.com> <86a4tivdh3.wl-maz@kernel.org> <867bomva0r.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <867bomva0r.wl-maz@kernel.org> On Fri, May 29, 2026 at 10:29:40AM +0100, Marc Zyngier wrote: > 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 Looking at kvm_share_hyp() it should then rollback the shared pages. I think that is fine. > > - if something should not fail and has the potential of compromising > the system, we should panic Then kvm_unshare_hyp() being void, should BUG_ON(unshare_pfn_hyp(pfn)); > > - if something absolutely cannot fail, then there is nothing to handle > > Thanks, > > M. > > -- > Without deviation from the norm, progress is not possible.