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 0CCC3385509 for ; Wed, 3 Jun 2026 10:12:11 +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=1780481533; cv=none; b=TogOGI9WB/twgjyIqSWjfiDR2IHUW1t1ap1etxVRV0BMOUoowWQk2RNNKNArjICRKLNxPptq/FprJhi23r4gS/V6ISvGRbT4cZZCGFei5FBbC9OL03hhWmCT3ZXdYpuov5jkFfMqgWVX4FrEN+fjrsUtbPbP2aV+gzQbHEnBDgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481533; c=relaxed/simple; bh=fGTyeVYAfWL4rXKWP8jyLPVlcYjcF45jBG0YBs2uh94=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LEsE7O9HO1X0A18YRoqmtaljmHtnB5+CktW8HVGyfm58o8izXrOVV1NAHlChuU1v8nFUxhvmrY+lb6u72eiPHT6WhEJsHOf1ZWYKl7qYT1rcYfCE7HA/eaDdmhW9W4gfvsudiYQG2nNqNQVmBAgYEizoBEuTdmY3jZY6Zn1QBDQ= 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=Rltgadw/; 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="Rltgadw/" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490b3e03939so4475105e9.1 for ; Wed, 03 Jun 2026 03:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780481530; x=1781086330; 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=pIaWOz4jzomrlICte653zCUp4/MwcwzwiqZTiopmMBg=; b=Rltgadw/WHlo+CIkm6iiXdesuwn3kNmK+kYYAPZesiu7JkKzrb1D9ZiuZVR0eLsNrV 90DhWnNYqgpfq9hJ8ypLHH2ooiS+bOOxn3XXp4oyvjK9pWpuXT6mfMHpj1ERAfbKLVk9 rMaMRNV/D+/GnEDg+0wJGDLKVEgFTwiciqDNe6wlBo+W3QCuvF6K5mDf7USt4HnQeGKp zjSjYMY+pcJUJkZKxU9JlmjgZQMHuIE5alTTSSLGjCJ51fP6kO6mN4eYPkSPh6SAFkms F+acNsP1g3E0RVajaiOUsKw3ZHZw1lU9j0s7JNy9ALViUgroRwTqKNI3WTbrWFNXs5Ty KHVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481530; x=1781086330; 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=pIaWOz4jzomrlICte653zCUp4/MwcwzwiqZTiopmMBg=; b=lFkt5VOOmnM5po20mfzPwiwG/7yt3vZ7H1KNa99vFpHlmrZN7wVCMJD6Vy+r5IEPUk DKWKrTzhkYVRUL0C7X3f17TB69Cc3LPKh5yiSzu/hbZ1OMicsK4NRldJm0iLnnCgyz8+ jVKIPPJU7ajve3yq+0rLD4X0MeBNsmbmGqkf/m4TMnSPscIvhypgYZpXBUwVjzjUu3E7 o7jJE2PcUsYwhq5H/q3mSMGrgbytC4D4uJdn8G/g+x47iVEB2sD7zjBaiJ70MqCzI5Tb kigTCQjnbfZh1BZqjo1JtG6UlHkRatGJF94XHVrdleVSjGA/hUvoquOpDEcwLlU2ffbu doYg== X-Forwarded-Encrypted: i=1; AFNElJ8s/HGi/ZHBeBmCKlbZV96ll2VSzwCHmb1AaE0c3l/pJMvsHGpnPRY64uptvBm7Kaoi3fnC1j+5S9czDns=@vger.kernel.org X-Gm-Message-State: AOJu0Ywu5phlnIg756fxfK3lkuAmTwbp/fVzlLTqKRNxZraLrmJLak6n 8va9OtNLy+b8jMGNFVNqu2h+ZBqIcuBx7ugn53O+WbGixWWek8XUwqB7xV3ZNInlvcVdBHDj3ph MKVx8BQ== X-Gm-Gg: Acq92OEJ0VODUPCg81tEbV5qDpbbMX5wW/QxBwTNU0oSCHPsrSpoguUwvvo58+uM2wY QsNj6clVTIEPpnnaHH2nsL38v6vCXJ7B9x+Airgrt6vPBEbLqog/XK6Usxh+bsM9m/mGdDhiXht Gaan3ZlmSjVVraKQuk6o4uKTk32yo6ieydrl3gknJNZUYCMx06JjM+rgrFbr4WrH8xzmDf000T6 UYs2pnMTVWIAHKJN3R98t/DG+HH5zNzXL+wJC/5ziVFL0i76C/q2J1tVRc/ZjHZ1dMkcOOEbQxh 4gRgz5s1Vb1/dfwel9g/AaR8s1lL0Y/y5oLwlt5szeBqSGbuMjTn5VQ2Bf0kAiQbUklZQQ5BDrx K40s/unTp528pLoIT2orlDkFpi+xYRExNkItgl2kurL/S8V89Lyr0XKdiLE/13jUe4ofjn1mcG4 bXwKXUhlIu10UOlEbD659kh9QHaXwGAI8QSAiTlq6M1g65MoQf6Xn3naNE/riwXRDy4/zs1H9Zj ct4yZXUyMgYFMqr X-Received: by 2002:a05:600c:8488:b0:490:b4cb:3866 with SMTP id 5b1f17b1804b1-490b613f181mr34363835e9.10.1780481530006; Wed, 03 Jun 2026 03:12:10 -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-490b63e63d7sm51863845e9.12.2026.06.03.03.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:12:09 -0700 (PDT) Date: Wed, 3 Jun 2026 11:12:05 +0100 From: Vincent Donnefort To: tabba@google.com Cc: Marc Zyngier , 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 v2 0/3] KVM: arm64: Fix host/hyp tracking on share/unshare hypercall failure Message-ID: References: <20260529121755.2923500-1-tabba@google.com> 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: <20260529121755.2923500-1-tabba@google.com> On Fri, May 29, 2026 at 01:17:52PM +0100, tabba@google.com wrote: > Hi folks, > > The first two started as bugs I found testing Sashiko locally with > fixes to review-prompts. The third grew out of the v1 discussion. > > 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. The > hypercalls they wrap can fail (page-state mismatch, EL2 refcount still > held), and neither the per-pfn helpers nor the multi-page wrappers > cleaned up correctly on failure: > > - share_pfn_hyp() left its tracking node in the tree on failure, > leaking the allocation and presenting a phantom share to a later > unshare (patch 1). > > - unshare_pfn_hyp() erased its tracking node before the hypercall, so > on failure the host lost its record while EL2 still owned the share > (patch 2). > > - kvm_share_hyp() returned on the first per-page failure, stranding the > pages already shared by that call: the caller treats the whole range > as failed and never unshares them (patch 3). > > As Vincent and Marc noted on v1, none of this compromises isolation. A > page that cannot be unshared is simply leaked: it stays shared with the > hypervisor and is no longer reusable for pKVM. So kvm_share_hyp() now > rolls back on failure, and the unshare WARN_ON()s are left non-fatal > and documented rather than promoted to BUG_ON(). The system keeps > running, and only later pKVM reuse of a leaked page would fail. We do > not expect any of these paths to trigger in practice. > > Severity is low and this can wait for 7.2. Patch 3 builds on patch 2, > otherwise they are independent. > > Changes since v1: > - New patch 3: roll back partial shares in kvm_share_hyp(); document > the deliberate leak-on-WARN in kvm_unshare_hyp() (Vincent, Marc). > - Patches 1 and 2 functionally unchanged (patch 2 gains the call-site > comment). > - v1: https://lore.kernel.org/all/20260529074341.2271950-1-tabba@google.com/ > > Cheers, > /fuad For the whole series: Reviewed-by: Vincent Donnefort > > Fuad Tabba (3): > KVM: arm64: Free hyp-share tracking node when share hypercall fails > KVM: arm64: Avoid host/hyp share desync on unshare hypercall failure > KVM: arm64: Roll back partial shares on kvm_share_hyp() failure > > arch/arm64/kvm/mmu.c | 39 +++++++++++++++++++++++++++++++++------ > 1 file changed, 33 insertions(+), 6 deletions(-) > > -- > 2.54.0.929.g9b7fa37559-goog >