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 6509CF46139 for ; Mon, 23 Mar 2026 14:59:00 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From: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=ZzLEa3KL5XVk7DKMlxQHZBfsBy0BGZb9ScjlDMpdRtc=; b=xK69PBpERrEygZwBprN5cXbHQU aitqb2LQQUvYCI6W+05tDfproYzF/xp4K69dxuQsvIQaZW9NafAEJhwNFNXil/23E3KRKcFOEK7dp VXdAFnk+ionkph+XkeswXEu6HXyXSnPmXl+R/VWrxb6WIj5OYdThJgAXdi8vKF1s1ymPQ8ui5y2hZ w45UbHCqUT7Jm+jjXDciHSRURFV0zdpJ1MW9Y1PVa99eXe5v98+DbQ1S9Ealp0K7gwzpmDPfYrj39 87w+8wC8TY6lWVidPDezNTpLA7Gp5ZQAW3PfLJQN3NsWpDpGijpXydh5r9Gpsp8hzNdTEmHXu9KeU 67uhpzjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w4gk2-0000000Gxsx-1FK4; Mon, 23 Mar 2026 14:58:54 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w4gk1-0000000Gxsq-112B for linux-arm-kernel@lists.infradead.org; Mon, 23 Mar 2026 14:58:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 40836600CB; Mon, 23 Mar 2026 14:58:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70A55C2BC9E; Mon, 23 Mar 2026 14:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774277901; bh=f8dCaoHE8v13TX7zhudBhLxwnKyjtp2XPdiKUD8OWGE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IHzOAlF5Ymj0Vgg4Oh1oKLaVDPOpYje9/8/qWu57Nft5V+j/b0M8g+Cu2UNVc6R2g 9z51ACWPv4nBFHk3tat/R5aiNl9d6UIGIGIW/DRNqcAJfViMhrS4WoeXWXkeCrJFS3 OVU5yeag7Iq9MfbIWCHBciePzpm3nX0Ep7Zbu7flioBdRslEKuD+Zg2iSXUjp65M66 +u4EeDR8uDD3tEYcKpc+pwswo37xLvEvjYMC+uBe1EPQAXy9u54A2GzLtkBsPJCGOA HKZqV3VnVcs32rR4WDHocLGDgK4gLNw+YGhBTZjtuF33JfgvEWfVmp8ja2HrD1dXBJ Y4Nkya3ai0L8Q== Date: Mon, 23 Mar 2026 14:58:16 +0000 From: Will Deacon To: Marc Zyngier Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Quentin Perret , Fuad Tabba , Vincent Donnefort , Mostafa Saleh , Alexandru Elisei Subject: Re: [PATCH v3 25/36] KVM: arm64: Reclaim faulting page from pKVM in spurious fault handler Message-ID: References: <20260305144351.17071-1-will@kernel.org> <20260305144351.17071-26-will@kernel.org> <864ima5v6c.wl-maz@kernel.org> <87fr5tcyim.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fr5tcyim.wl-maz@kernel.org> 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 Sat, Mar 21, 2026 at 09:39:13AM +0000, Marc Zyngier wrote: > On Fri, 20 Mar 2026 16:20:59 +0000, > Marc Zyngier wrote: > > > > On Thu, 05 Mar 2026 14:43:38 +0000, > > Will Deacon wrote: > > > > > > Host kernel accesses to pages that are inaccessible at stage-2 result in > > > the injection of a translation fault, which is fatal unless an exception > > > table fixup is registered for the faulting PC (e.g. for user access > > > routines). This is undesirable, since a get_user_pages() call could be > > > used to obtain a reference to a donated page and then a subsequent > > > access via a kernel mapping would lead to a panic(). > > > > > > Rework the spurious fault handler so that stage-2 faults injected back > > > into the host result in the target page being forcefully reclaimed when > > > no exception table fixup handler is registered. > > > > Is there any reason why you prefer the 'inject fault' followed by > > 'gimme that page' dance over a more direct 'unconditionally reclaim > > the page on the back of the fault'? > > > > I can't figure out what would go wrong in the latter approach, as you > > always have an opportunity to inject a (fatal) fault if you can't > > safely reclaim the page. > > To be clear, the reason I'm asking this is that with RME (whether > that's with the dreaded CCA or something else), injecting a fault into > the host would involve EL3, and I don't trust EL3 to do that. There is > also the small detail that the fault syndrome is not strictly > architectural, meaning that EL3 would have to learn a pKVM-specific > behaviour. > > But EL3 should be able to report a GPC fault to RL-EL2, which then > could act the exact same way as pKVM, unmapping, clearing and > releasing the page. I wonder if we should try to get this changed/extended, given that it's all software? Perhaps RL-EL2 could populate parts of the fault syndrome that get injected back into the host? Ideally, we'd run something at RL-EL2 that is tightly-coupled with KVM and so we wouldn't need to teach EL3 anything as long as it lets the two talk to each other... > Thoughts? I think we need to retain the exception injection behaviour, for two reasons: 1. The kernel can over-read strings via load_unaligned_zeropad(). If this happens to walk into a protected page, we have to inject a fault so that the exception handler can fix things up. Otherwise, we'd silently poison protected pages due to software-speculative accesses. 2. If the fault comes directly from userspace (e.g. because of an out-of-bounds access or a virtio problem), the fault handler in the kernel will inject a signal back to userspace which can be caught and handled synchronously. I suppose we could require the VMM to make the guest memory PROT_NONE if it wanted to preserve this behaviour (assuming it doesn't break GUP). Still, it feels desirable to report the problem synchronously when we can. Will